EduTrainPlanMapper.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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.train.mapper.EduTrainPlanMapper">
  4. <sql id="eduTrainPlanColumns">
  5. a.id AS "id",
  6. a.title AS "title",
  7. a.train_date AS "trainDate",
  8. a.train_range AS "trainRange",
  9. a.content AS "content",
  10. a.teacher AS "teacher",
  11. a.place AS "place",
  12. a.create_by AS "createBy.id",
  13. a.create_date AS "createDate",
  14. a.update_by AS "updateBy.id",
  15. a.update_date AS "updateDate",
  16. a.del_flag AS "delFlag",
  17. a.status AS "status"
  18. </sql>
  19. <sql id="eduTrainPlanSignerColumns">
  20. a.id AS "id",
  21. a.title AS "title",
  22. a.train_date AS "trainDate",
  23. a.train_range AS "trainRange",
  24. a.content AS "content",
  25. a.teacher AS "teacher",
  26. a.place AS "place",
  27. a.create_by AS "createBy.id",
  28. a.create_date AS "createDate",
  29. a.update_by AS "updateBy.id",
  30. a.update_date AS "updateDate",
  31. a.del_flag AS "delFlag",
  32. a.status AS "status",
  33. enroll.status AS "signer"
  34. </sql>
  35. <sql id="eduTrainPlanJoins">
  36. </sql>
  37. <resultMap type="EduTrainPlan" id="EduTrainPlanResult" autoMapping="true">
  38. <result column="content" property="content" typeHandler="com.jeeplus.core.mapper.ConvertBlobTypeHandler"/>
  39. </resultMap>
  40. <select id="get" resultMap="EduTrainPlanResult" >
  41. SELECT
  42. <include refid="eduTrainPlanColumns"/>
  43. FROM edu_train_plan a
  44. <include refid="eduTrainPlanJoins"/>
  45. WHERE a.id = #{id}
  46. </select>
  47. <select id="findList" resultMap="EduTrainPlanResult" >
  48. SELECT
  49. <include refid="eduTrainPlanColumns"/>
  50. FROM edu_train_plan a
  51. <include refid="eduTrainPlanJoins"/>
  52. <where>
  53. a.del_flag = #{DEL_FLAG_NORMAL}
  54. ${dataScope}
  55. <if test="title != null and title != ''">
  56. AND a.title LIKE
  57. <if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
  58. <if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
  59. <if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
  60. </if>
  61. <if test="teacher != null and teacher != ''">
  62. AND a.teacher LIKE
  63. <if test="dbName == 'oracle'">'%'||#{teacher}||'%'</if>
  64. <if test="dbName == 'mssql'">'%'+#{teacher}+'%'</if>
  65. <if test="dbName == 'mysql'">concat('%',#{teacher},'%')</if>
  66. </if>
  67. <if test="place != null and place != ''">
  68. AND a.place LIKE
  69. <if test="dbName == 'oracle'">'%'||#{place}||'%'</if>
  70. <if test="dbName == 'mssql'">'%'+#{place}+'%'</if>
  71. <if test="dbName == 'mysql'">concat('%',#{place},'%')</if>
  72. </if>
  73. </where>
  74. <choose>
  75. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  76. ORDER BY ${page.orderBy}
  77. </when>
  78. <otherwise>
  79. ORDER BY a.update_date DESC
  80. </otherwise>
  81. </choose>
  82. </select>
  83. <select id="findListSign" resultMap="EduTrainPlanResult" >
  84. SELECT
  85. <include refid="eduTrainPlanSignerColumns"/>
  86. FROM edu_train_plan a
  87. left join edu_train_enroll enroll
  88. on a.id = enroll.plan_id and enroll.create_by = #{signer}
  89. <choose>
  90. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  91. ORDER BY ${page.orderBy}
  92. </when>
  93. <otherwise>
  94. ORDER BY a.update_date DESC
  95. </otherwise>
  96. </choose>
  97. </select>
  98. <select id="findAllList" resultMap="EduTrainPlanResult" >
  99. SELECT
  100. <include refid="eduTrainPlanColumns"/>
  101. FROM edu_train_plan a
  102. <include refid="eduTrainPlanJoins"/>
  103. <where>
  104. a.del_flag = #{DEL_FLAG_NORMAL}
  105. ${dataScope}
  106. </where>
  107. <choose>
  108. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  109. ORDER BY ${page.orderBy}
  110. </when>
  111. <otherwise>
  112. ORDER BY a.update_date DESC
  113. </otherwise>
  114. </choose>
  115. </select>
  116. <insert id="insert">
  117. INSERT INTO edu_train_plan(
  118. id,
  119. title,
  120. train_date,
  121. train_range,
  122. content,
  123. teacher,
  124. place,
  125. create_by,
  126. create_date,
  127. update_by,
  128. update_date,
  129. del_flag,
  130. status
  131. ) VALUES (
  132. #{id},
  133. #{title},
  134. #{trainDate},
  135. #{trainRange},
  136. #{content},
  137. #{teacher},
  138. #{place},
  139. #{createBy.id},
  140. #{createDate},
  141. #{updateBy.id},
  142. #{updateDate},
  143. #{delFlag},
  144. #{status}
  145. )
  146. </insert>
  147. <update id="update">
  148. UPDATE edu_train_plan SET
  149. title = #{title},
  150. train_date = #{trainDate},
  151. train_range = #{trainRange},
  152. content = #{content},
  153. teacher = #{teacher},
  154. place = #{place},
  155. update_by = #{updateBy.id},
  156. update_date = #{updateDate},
  157. status = #{status}
  158. WHERE id = #{id}
  159. </update>
  160. <!--物理删除-->
  161. <update id="delete">
  162. DELETE FROM edu_train_plan
  163. WHERE id = #{id}
  164. </update>
  165. <!--逻辑删除-->
  166. <update id="deleteByLogic">
  167. UPDATE edu_train_plan SET
  168. del_flag = #{DEL_FLAG_DELETE}
  169. WHERE id = #{id}
  170. </update>
  171. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  172. <select id="findUniqueByProperty" resultType="EduTrainPlan" statementType="STATEMENT">
  173. select * FROM edu_train_plan where ${propertyName} = '${value}'
  174. </select>
  175. </mapper>