ExtracurricularExercisesMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. INSERT INTO extracurricular_exercises (teacher_id_,student_id_list_,batch_no_,
  57. title_,attachments_,content_,expire_date_,completed_num_,expect_num_,create_time_,update_time_)
  58. VALUES(#{teacherId},#{studentIdList},#{batchNo},#{title},#{attachments},
  59. #{content},#{expireDate},#{completedNum},#{expectNum},NOW(), NOW())
  60. </insert>
  61. <!-- 根据主键查询一条记录 -->
  62. <update id="update" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercises">
  63. UPDATE extracurricular_exercises
  64. <set>
  65. <if test="studentIdList != null">
  66. student_id_list_ = #{studentIdList},
  67. </if>
  68. <if test="expireDate != null">
  69. expire_date_ = #{expireDate},
  70. </if>
  71. <if test="batchNo != null">
  72. batch_no_ = #{batchNo},
  73. </if>
  74. <if test="teacherId != null">
  75. teacher_id_ = #{teacherId},
  76. </if>
  77. <if test="title != null">
  78. title_ = #{title},
  79. </if>
  80. <if test="expectNum != null">
  81. expect_num_ = #{expectNum},
  82. </if>
  83. <if test="content != null">
  84. content_ = #{content},
  85. </if>
  86. <if test="attachments != null">
  87. attachments_ = #{attachments},
  88. </if>
  89. <if test="completedNum != null">
  90. completed_num_ = #{completedNum},
  91. </if>
  92. update_time_ = NOW()
  93. </set> WHERE id_ = #{id}
  94. </update>
  95. <!-- 根据主键删除一条记录 -->
  96. <delete id="delete" >
  97. DELETE FROM extracurricular_exercises WHERE id_ = #{id}
  98. </delete>
  99. <!-- 分页查询 -->
  100. <select id="queryPage" resultMap="ExtracurricularExercises" parameterType="map">
  101. SELECT ee.*,u.real_name_ username_,o.name_ organ_name_
  102. FROM extracurricular_exercises ee left join sys_user u on ee.teacher_id_ = u.id_
  103. left join teacher t on t.id_ = ee.teacher_id_
  104. left join organization o on o.id_ = t.organ_id_
  105. <include refid="queryPageCondition"/>
  106. ORDER BY id_ <include refid="global.limit"/>
  107. </select>
  108. <!-- 查询当前表的总记录数 -->
  109. <select id="queryCount" resultType="int">
  110. SELECT COUNT(ee.id_) FROM extracurricular_exercises ee left join sys_user u on ee.teacher_id_ = u.id_
  111. left join teacher t on t.id_ = ee.teacher_id_
  112. left join organization o on o.id_ = t.organ_id_
  113. <include refid="queryPageCondition"/>
  114. </select>
  115. <sql id="queryExtraExercisesCondition">
  116. <where>
  117. <if test="teacherId!=null">
  118. teacher_id_=#{teacherId}
  119. </if>
  120. <if test="createTime!=null">
  121. AND DATE_FORMAT(create_time_, '%Y-%m') = DATE_FORMAT(#{createTime}, '%Y-%m')
  122. </if>
  123. </where>
  124. </sql>
  125. <select id="countExtraExercises" resultType="int">
  126. SELECT COUNT(id_) FROM extracurricular_exercises
  127. <include refid="queryExtraExercisesCondition"/>
  128. </select>
  129. <select id="findExtraExercises" resultMap="ExtracurricularExercises">
  130. SELECT * FROM extracurricular_exercises
  131. <include refid="queryExtraExercisesCondition"/>
  132. ORDER BY create_time_ DESC
  133. <include refid="global.limit"/>
  134. </select>
  135. <select id="findRepeatLastExercises" resultMap="ExtracurricularExercises">
  136. SELECT
  137. *
  138. FROM
  139. extracurricular_exercises
  140. WHERE
  141. teacher_id_ = #{teacherId}
  142. AND student_id_list_ = #{studentIdList}
  143. AND content_ = #{content}
  144. ORDER BY create_time_ DESC LIMIT 1
  145. </select>
  146. <select id="findNoExercisesStudentsInThisWeekWithTeacher"
  147. resultType="com.ym.mec.biz.dal.dto.BasicUserDto">
  148. SELECT
  149. su.id_ userId,
  150. su.username_ name,
  151. su.avatar_ headUrl,
  152. GROUP_CONCAT(sub.name_) subjectName,
  153. stu.member_rank_setting_id_ memberRankSettingId,
  154. stu.subject_id_list_ subjectIdList
  155. FROM
  156. student_extracurricular_exercises_situation_ sees
  157. <if test="musicGroupId!=null and musicGroupId!=''">
  158. LEFT JOIN student_registration sr ON sees.student_id_=sr.user_id_
  159. </if>
  160. <if test="classGroupId!=null">
  161. LEFT JOIN class_group_student_mapper cgsm ON sees.student_id_ = cgsm.user_id_
  162. </if>
  163. LEFT JOIN student stu ON stu.user_id_ = sees.student_id_
  164. LEFT JOIN sys_user su ON su.id_ = sees.student_id_
  165. LEFT JOIN `subject` sub ON FIND_IN_SET( sub.id_, stu.subject_id_list_ )
  166. WHERE
  167. sees.monday_ = #{startDate}
  168. AND sees.teacher_id_ = #{teacherId}
  169. AND sees.actual_exercises_num_ &lt; sees.expect_exercises_num_
  170. AND sees.serve_type_ = 'EXERCISE'
  171. <if test="hasMember != null">
  172. <if test="hasMember == 1">
  173. AND stu.member_rank_setting_id_ IS NOT NULL
  174. </if>
  175. <if test="hasMember == 0">
  176. AND stu.member_rank_setting_id_ IS NULL
  177. </if>
  178. </if>
  179. <if test="musicGroupId!=null and musicGroupId!=''">
  180. AND sr.music_group_id_=#{musicGroupId}
  181. </if>
  182. <if test="classGroupId!=null">
  183. AND cgsm.class_group_id_ = #{classGroupId}
  184. </if>
  185. <if test="subjectId!=null">
  186. AND FIND_IN_SET(#{subjectId}, stu.subject_id_list_)
  187. </if>
  188. <if test="search!=null">
  189. AND (su.username_ LIKE CONCAT('%', #{search}, '%') OR su.phone_ LIKE CONCAT(#{search}, '%'))
  190. </if>
  191. GROUP BY su.id_
  192. ORDER BY
  193. su.id_;
  194. </select>
  195. </mapper>