ExtracurricularExercisesMapper.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.ExtracurricularExercisesDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.ExtracurricularExercises" id="ExtracurricularExercises">
  9. <result column="id_" property="id" />
  10. <result column="teacher_id_" property="teacherId" />
  11. <result column="username_" property="teacher.username" />
  12. <result column="student_id_list_" property="studentIdList" />
  13. <result column="batch_no_" property="batchNo" />
  14. <result column="title_" property="title" />
  15. <result column="attachments_" property="attachments" />
  16. <result column="content_" property="content" />
  17. <result column="expire_date_" property="expireDate" />
  18. <result column="completed_num_" property="completedNum" />
  19. <result column="expect_num_" property="expectNum" />
  20. <result column="create_time_" property="createTime" />
  21. <result column="update_time_" property="updateTime" />
  22. <result column="organ_name_" property="organName" />
  23. </resultMap>
  24. <sql id="queryPageCondition">
  25. <where>
  26. <if test="teacherId != null">
  27. and teacher_id_ = #{teacherId}
  28. </if>
  29. <if test="title != null">
  30. and title_ like '%' #{title} '%'
  31. </if>
  32. <if test="batchNo != null">
  33. and batch_no_ = #{batchNo}
  34. </if>
  35. <if test="organIdList != null">
  36. AND FIND_IN_SET(o.id_, #{organIdList})
  37. </if>
  38. <if test="assignStartTime != null">
  39. AND date(ee.create_time_) &gt;= #{assignStartTime}
  40. </if>
  41. <if test="assignEndTime != null">
  42. AND date(ee.create_time_) &lt;= #{assignEndTime}
  43. </if>
  44. </where>
  45. </sql>
  46. <!-- 根据主键查询一条记录 -->
  47. <select id="get" resultMap="ExtracurricularExercises" >
  48. SELECT * FROM extracurricular_exercises WHERE id_ = #{id}
  49. </select>
  50. <!-- 全查询 -->
  51. <select id="findAll" resultMap="ExtracurricularExercises">
  52. SELECT * FROM extracurricular_exercises ORDER BY id_
  53. </select>
  54. <!-- 向数据库增加一条记录 -->
  55. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercises" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  56. <!--
  57. <selectKey resultClass="int" keyProperty="id" >
  58. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  59. </selectKey>
  60. -->
  61. INSERT INTO extracurricular_exercises (id_,teacher_id_,student_id_list_,batch_no_,title_,attachments_,content_,expire_date_,completed_num_,expect_num_,create_time_,update_time_)
  62. VALUES(#{id},#{teacherId},#{studentIdList},#{batchNo},#{title},#{attachments},#{content},#{expireDate},#{completedNum},#{expectNum},NOW(), NOW())
  63. </insert>
  64. <!-- 根据主键查询一条记录 -->
  65. <update id="update" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercises">
  66. UPDATE extracurricular_exercises
  67. <set>
  68. <if test="studentIdList != null">
  69. student_id_list_ = #{studentIdList},
  70. </if>
  71. <if test="expireDate != null">
  72. expire_date_ = #{expireDate},
  73. </if>
  74. <if test="batchNo != null">
  75. batch_no_ = #{batchNo},
  76. </if>
  77. <if test="id != null">
  78. id_ = #{id},
  79. </if>
  80. <if test="teacherId != null">
  81. teacher_id_ = #{teacherId},
  82. </if>
  83. <if test="title != null">
  84. title_ = #{title},
  85. </if>
  86. <if test="expectNum != null">
  87. expect_num_ = #{expectNum},
  88. </if>
  89. <if test="content != null">
  90. content_ = #{content},
  91. </if>
  92. <if test="attachments != null">
  93. attachments_ = #{attachments},
  94. </if>
  95. <if test="completedNum != null">
  96. completed_num_ = #{completedNum},
  97. </if>
  98. update_time_ = NOW()
  99. </set> WHERE id_ = #{id}
  100. </update>
  101. <!-- 根据主键删除一条记录 -->
  102. <delete id="delete" >
  103. DELETE FROM extracurricular_exercises WHERE id_ = #{id}
  104. </delete>
  105. <!-- 分页查询 -->
  106. <select id="queryPage" resultMap="ExtracurricularExercises" parameterType="map">
  107. SELECT ee.*,u.real_name_ username_,o.name_ organ_name_
  108. FROM extracurricular_exercises ee left join sys_user u on ee.teacher_id_ = u.id_
  109. left join teacher t on t.id_ = ee.teacher_id_
  110. left join organization o on o.id_ = t.organ_id_
  111. <include refid="queryPageCondition"/>
  112. ORDER BY id_ <include refid="global.limit"/>
  113. </select>
  114. <!-- 查询当前表的总记录数 -->
  115. <select id="queryCount" resultType="int">
  116. SELECT COUNT(ee.id_) FROM extracurricular_exercises ee left join sys_user u on ee.teacher_id_ = u.id_
  117. left join teacher t on t.id_ = ee.teacher_id_
  118. left join organization o on o.id_ = t.organ_id_
  119. <include refid="queryPageCondition"/>
  120. </select>
  121. <sql id="queryExtraExercisesCondition">
  122. <where>
  123. <if test="teacherId!=null">
  124. teacher_id_=#{teacherId}
  125. </if>
  126. <if test="createTime!=null">
  127. AND DATE_FORMAT(create_time_, '%Y-%m') = DATE_FORMAT(#{createTime}, '%Y-%m')
  128. </if>
  129. </where>
  130. </sql>
  131. <select id="countExtraExercises" resultType="int">
  132. SELECT COUNT(id_) FROM extracurricular_exercises
  133. <include refid="queryExtraExercisesCondition"/>
  134. </select>
  135. <select id="findExtraExercises" resultMap="ExtracurricularExercises">
  136. SELECT * FROM extracurricular_exercises
  137. <include refid="queryExtraExercisesCondition"/>
  138. ORDER BY create_time_ DESC
  139. <include refid="global.limit"/>
  140. </select>
  141. <select id="findRepeatLastExercises" resultMap="ExtracurricularExercises">
  142. SELECT
  143. *
  144. FROM
  145. extracurricular_exercises
  146. WHERE
  147. teacher_id_ = #{teacherId}
  148. AND student_id_list_ = #{studentIdList}
  149. AND content_ = #{content}
  150. ORDER BY create_time_ DESC LIMIT 1
  151. </select>
  152. <select id="findNoExercisesStudentsInThisWeekWithTeacher"
  153. resultType="com.ym.mec.biz.dal.dto.BasicUserDto">
  154. SELECT
  155. su.id_ userId,
  156. su.username_ name,
  157. su.avatar_ headUrl,
  158. GROUP_CONCAT(sub.name_) subjectName
  159. FROM
  160. student_extracurricular_exercises_situation_ sees
  161. LEFT JOIN student stu ON stu.user_id_ = sees.student_id_
  162. LEFT JOIN sys_user su ON su.id_ = sees.student_id_
  163. LEFT JOIN `subject` sub ON FIND_IN_SET( sub.id_, stu.subject_id_list_ )
  164. WHERE
  165. sees.monday_ = #{startDate}
  166. AND sees.teacher_id_ = #{teacherId}
  167. AND sees.actual_exercises_num_ &lt; sees.expect_exercises_num_
  168. AND sees.serve_type_ = 'EXERCISE'
  169. <if test="search!=null">
  170. AND (su.username_ LIKE CONCAT('%', #{search}, '%') OR su.phone_ LIKE CONCAT(#{search}, '%'))
  171. </if>
  172. GROUP BY su.id_
  173. ORDER BY
  174. su.id_;
  175. </select>
  176. </mapper>