EduQuestionnaireMapper.xml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.jeeplus.modules.questionnaire.mapper.EduQuestionnaireMapper">
  4. <sql id="eduQuestionnaireColumns">
  5. a.id AS "id",
  6. a.title AS "title",
  7. a.start_time AS "startTime",
  8. a.end_time AS "endTime",
  9. u.name AS "createBy.name",
  10. a.create_by AS "createBy.id",
  11. a.create_date AS "createDate",
  12. a.update_by AS "updateBy.id",
  13. a.update_date AS "updateDate",
  14. a.del_flag AS "delFlag",
  15. a.sort AS "sort"
  16. </sql>
  17. <sql id="eduQuestionnaireJoins">
  18. left join sys_user u on a.create_by = u.id
  19. </sql>
  20. <select id="get" resultType="EduQuestionnaire" >
  21. SELECT
  22. <include refid="eduQuestionnaireColumns"/>
  23. FROM edu_questionnaire a
  24. <include refid="eduQuestionnaireJoins"/>
  25. WHERE a.id = #{id}
  26. </select>
  27. <select id="findList" resultType="EduQuestionnaire" >
  28. SELECT
  29. <include refid="eduQuestionnaireColumns"/>
  30. FROM edu_questionnaire a
  31. <include refid="eduQuestionnaireJoins"/>
  32. <where>
  33. a.del_flag = #{DEL_FLAG_NORMAL}
  34. ${dataScope}
  35. <if test="title != null and title != ''">
  36. AND a.title LIKE
  37. <if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
  38. <if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
  39. <if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
  40. </if>
  41. <if test="sort != null and sort != ''">
  42. AND a.sort = #{sort}
  43. </if>
  44. </where>
  45. <choose>
  46. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  47. ORDER BY ${page.orderBy}
  48. </when>
  49. <otherwise>
  50. ORDER BY a.update_date DESC
  51. </otherwise>
  52. </choose>
  53. </select>
  54. <select id="findAllList" resultType="EduQuestionnaire" >
  55. SELECT
  56. <include refid="eduQuestionnaireColumns"/>
  57. FROM edu_questionnaire a
  58. <include refid="eduQuestionnaireJoins"/>
  59. <where>
  60. a.del_flag = #{DEL_FLAG_NORMAL}
  61. ${dataScope}
  62. </where>
  63. <choose>
  64. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  65. ORDER BY ${page.orderBy}
  66. </when>
  67. <otherwise>
  68. ORDER BY a.update_date DESC
  69. </otherwise>
  70. </choose>
  71. </select>
  72. <insert id="insert">
  73. INSERT INTO edu_questionnaire(
  74. id,
  75. title,
  76. start_time,
  77. end_time,
  78. create_by,
  79. create_date,
  80. update_by,
  81. update_date,
  82. del_flag,
  83. sort
  84. ) VALUES (
  85. #{id},
  86. #{title},
  87. #{startTime},
  88. #{endTime},
  89. #{createBy.id},
  90. #{createDate},
  91. #{updateBy.id},
  92. #{updateDate},
  93. #{delFlag},
  94. #{sort}
  95. )
  96. </insert>
  97. <update id="update">
  98. UPDATE edu_questionnaire SET
  99. title = #{title},
  100. start_time = #{startTime},
  101. end_time = #{endTime},
  102. update_by = #{updateBy.id},
  103. update_date = #{updateDate},
  104. sort = #{sort}
  105. WHERE id = #{id}
  106. </update>
  107. <!--物理删除-->
  108. <update id="delete">
  109. DELETE FROM edu_questionnaire
  110. WHERE id = #{id}
  111. </update>
  112. <!--逻辑删除-->
  113. <update id="deleteByLogic">
  114. UPDATE edu_questionnaire SET
  115. del_flag = #{DEL_FLAG_DELETE}
  116. WHERE id = #{id}
  117. </update>
  118. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  119. <select id="findUniqueByProperty" resultType="EduQuestionnaire" statementType="STATEMENT">
  120. select * FROM edu_questionnaire where ${propertyName} = '${value}'
  121. </select>
  122. </mapper>