StudentCourseHomeworkMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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.StudentCourseHomeworkDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.StudentCourseHomework" id="StudentCourseHomework">
  9. <result column="id_" property="id"/>
  10. <result column="user_id_" property="userId"/>
  11. <result column="username_" property="userName"/>
  12. <result column="phone_" property="phone"/>
  13. <result column="avatar_" property="avatar"/>
  14. <result column="course_homework_id_" property="courseHomeworkId"/>
  15. <result column="course_schedule_id_" property="courseScheduleId"/>
  16. <result column="attachments_" property="attachments"/>
  17. <result column="score_" property="score"/>
  18. <result column="create_time_" property="createTime"/>
  19. <result column="update_time_" property="updateTime"/>
  20. <result column="remark_" property="remark"/>
  21. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  22. <result column="is_replied_" property="isReplied" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  23. <result column="is_view_" property="isView" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  24. </resultMap>
  25. <resultMap type="com.ym.mec.biz.dal.dto.CourseHomeworkStudentDetailDto" id="CourseHomeworkStudentDetailDto">
  26. <result column="musicGroupName" property="musicGroupName"/>
  27. <result column="classGroupName" property="classGroupName"/>
  28. <result column="courseHomeworkId" property="courseHomeworkId"/>
  29. <result column="content_" property="content"/>
  30. <result column="expiry_date_" property="expiryDate"/>
  31. <result column="completed_num_" property="completedNum"/>
  32. <result column="expect_num_" property="expectNum"/>
  33. <result column="attachments_" property="attachments"/>
  34. <result column="score_" property="score"/>
  35. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  36. <result column="is_replied_" property="isReplied" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  37. </resultMap>
  38. <resultMap type="com.ym.mec.biz.dal.entity.StudentCourseHomework" id="StudentCourseHomeworkFull"
  39. extends="StudentCourseHomework">
  40. <result column="musicGroupName" property="courseHomework.musicGroup.name"/>
  41. <result column="classGroupName" property="courseHomework.classGroup.name"/>
  42. </resultMap>
  43. <!-- 根据主键查询一条记录 -->
  44. <select id="get" resultMap="StudentCourseHomework">
  45. SELECT * FROM student_course_homework WHERE id_ = #{id}
  46. </select>
  47. <!-- 全查询 -->
  48. <select id="findAll" resultMap="StudentCourseHomework">
  49. SELECT * FROM student_course_homework ORDER BY id_
  50. </select>
  51. <!-- 向数据库增加一条记录 -->
  52. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentCourseHomework" useGeneratedKeys="true"
  53. keyColumn="id" keyProperty="id">
  54. <!--
  55. <selectKey resultClass="int" keyProperty="id" >
  56. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  57. </selectKey>
  58. -->
  59. INSERT INTO student_course_homework
  60. (id_,user_id_,course_schedule_id_,course_homework_id_,attachments_,score_,create_time_,update_time_,remark_,status_,is_replied_,is_view_)
  61. VALUES(#{id},#{userId},#{courseScheduleId},#{courseHomeworkId},#{attachments},#{score},now(),now(),#{remark},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isView,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  62. </insert>
  63. <insert id="batchInsertStudentCourseHomeworkRecord" parameterType="java.util.List" useGeneratedKeys="true"
  64. keyColumn="id_">
  65. INSERT INTO student_course_homework
  66. (user_id_,course_schedule_id_,course_homework_id_,attachments_,score_,create_time_,update_time_,remark_,status_,is_replied_,is_view_)
  67. VALUE
  68. <foreach collection="list" item="homework" separator=",">
  69. (#{homework.userId},#{homework.courseScheduleId},#{homework.courseHomeworkId},#{homework.attachments},#{homework.score},now(),now(),#{homework.remark},#{homework.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{homework.isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{homework.isView,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  70. </foreach>
  71. </insert>
  72. <!-- 根据主键查询一条记录 -->
  73. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentCourseHomework">
  74. UPDATE student_course_homework
  75. <set>
  76. <if test="id != null">
  77. id_ = #{id},
  78. </if>
  79. <if test="courseHomeworkId != null">
  80. course_homework_id_ = #{courseHomeworkId},
  81. </if>
  82. <if test="courseScheduleId != null">
  83. course_schedule_id_ = #{courseScheduleId},
  84. </if>
  85. <if test="updateTime != null">
  86. update_time_ = NOW(),
  87. </if>
  88. <if test="score != null">
  89. score_ = #{score},
  90. </if>
  91. <if test="attachments != null">
  92. attachments_ = #{attachments},
  93. </if>
  94. <if test="createTime != null">
  95. create_time_ = #{createTime},
  96. </if>
  97. <if test="remark != null">
  98. remark_ = #{remark},
  99. </if>
  100. <if test="status != null">
  101. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  102. </if>
  103. <if test="isReplied != null">
  104. is_replied_ = #{isReplied,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  105. </if>
  106. <if test="isView != null">
  107. is_view_ = #{isView,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  108. </if>
  109. </set>
  110. WHERE id_ = #{id}
  111. </update>
  112. <!-- 根据主键删除一条记录 -->
  113. <delete id="delete">
  114. DELETE FROM student_course_homework WHERE id_ = #{id}
  115. </delete>
  116. <resultMap type="com.ym.mec.biz.dal.dto.CourseHomeworkListDto" id="CourseHomeworkDto">
  117. <result column="id_" property="id"/>
  118. <result column="course_schedule_id_" property="courseScheduleId"/>
  119. <result column="content_" property="content"/>
  120. <result column="create_time_" property="createTime"/>
  121. <result column="start_class_time_" property="startClassTime"/>
  122. <result column="expiry_date_" property="expiryDate"/>
  123. <result column="music_group_id_" property="musicGroupId"/>
  124. <result column="music_group_name_" property="musicGroupName"/>
  125. <result column="class_group_id_" property="classGroupId"/>
  126. <result column="class_group_name_" property="classGroupName"/>
  127. <result column="completed_num_" property="completedNum"/>
  128. <result column="expect_num_" property="expectNum"/>
  129. <result column="next_class_date_" property="expiryDate"/>
  130. <result column="remark_" property="remark"/>
  131. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  132. <result column="is_replied_" property="isReplied" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  133. </resultMap>
  134. <sql id="queryCondition">
  135. <where>
  136. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  137. AND cg.group_type_ = 'MUSIC'
  138. <if test="createTime != null">
  139. AND DATE_FORMAT(ch.create_time_,"%Y%m%d") = DATE_FORMAT(#{createTime},"%Y%m%d")
  140. </if>
  141. <if test="musicGroupId != null">
  142. AND cg.music_group_id_ = #{musicGroupId}
  143. </if>
  144. <if test="classGroupId != null">
  145. AND ch.class_group_id_ = #{classGroupId}
  146. </if>
  147. <if test="userId != null">
  148. AND sch.user_id_ = #{userId}
  149. </if>
  150. </where>
  151. </sql>
  152. <!-- 分页查询 -->
  153. <select id="queryPage" resultMap="CourseHomeworkDto" parameterType="map">
  154. SELECT
  155. sch.id_,
  156. ch.*,
  157. mg.name_ music_group_name_,
  158. cg.name_ class_group_name_,
  159. temp.next_class_date_,
  160. sch.remark_,
  161. sch.status_,
  162. sch.is_replied_
  163. FROM student_course_homework sch
  164. LEFT JOIN course_homework ch ON sch.course_homework_id_=ch.id_
  165. LEFT JOIN course_schedule cs ON ch.course_schedule_id_=cs.id_
  166. LEFT JOIN music_group mg ON ch.music_group_id_=mg.id_
  167. LEFT JOIN class_group cg ON ch.class_group_id_=cg.id_
  168. LEFT JOIN (SELECT
  169. class_group_id_,
  170. MIN(CONCAT( class_date_, ' ', start_class_time_ )) next_class_date_
  171. FROM
  172. course_schedule
  173. WHERE CONCAT( class_date_, ' ', start_class_time_ )>now()
  174. GROUP BY class_group_id_) temp ON ch.class_group_id_=temp.class_group_id_
  175. <include refid="queryCondition"/>
  176. ORDER BY ch.id_
  177. <include refid="global.limit"/>
  178. </select>
  179. <!-- 查询当前表的总记录数 -->
  180. <select id="queryCount" resultType="int">
  181. SELECT COUNT(*) FROM student_course_homework sch
  182. LEFT JOIN course_homework ch ON sch.course_homework_id_=ch.id_
  183. LEFT JOIN course_schedule cs ON ch.course_schedule_id_=cs.id_
  184. LEFT JOIN music_group mg ON ch.music_group_id_=mg.id_
  185. LEFT JOIN class_group cg ON ch.class_group_id_=cg.id_
  186. <include refid="queryCondition"/>
  187. </select>
  188. <select id="findCourseHomeworkStudentDetail" resultMap="CourseHomeworkStudentDetailDto">
  189. SELECT
  190. mg.name_ musicGroupName,
  191. cg.name_ classGroupName,
  192. ch.id_ courseHomeworkId,
  193. ch.content_,
  194. ch.expiry_date_,
  195. ch.completed_num_,
  196. ch.expect_num_,
  197. ch.expiry_date_,
  198. sch.attachments_,
  199. sch.score_,
  200. sch.status_,
  201. sch.is_replied_
  202. FROM
  203. course_homework ch
  204. LEFT JOIN student_course_homework sch ON ch.id_=sch.course_homework_id_
  205. LEFT JOIN music_group mg ON ch.music_group_id_=mg.id_
  206. LEFT JOIN class_group cg ON ch.class_group_id_=cg.id_
  207. WHERE ch.course_schedule_id_=#{courseScheduleID} AND sch.user_id_=#{userID}
  208. </select>
  209. <select id="constructInitialStudentHomeworkRecords" resultMap="StudentCourseHomework">
  210. SELECT
  211. #{courseHomeworkID} course_homework_id_,
  212. sa.user_id_,
  213. 0 status_,
  214. 0 is_replied_
  215. FROM
  216. student_attendance sa
  217. WHERE
  218. sa.course_schedule_id_ = #{courseScheduleID}
  219. AND status_ = "NORMAL"
  220. </select>
  221. <select id="constructInitialStudentHomeworkRecordsWithPayment" resultMap="StudentCourseHomework">
  222. SELECT
  223. #{courseHomeworkID} course_homework_id_,
  224. #{courseScheduleID} course_schedule_id_,
  225. sa.user_id_,
  226. 0 status_,
  227. 0 is_replied_
  228. FROM
  229. course_schedule_student_payment sa
  230. WHERE
  231. sa.course_schedule_id_ = #{courseScheduleID}
  232. </select>
  233. <select id="findByCourseSchedule" resultMap="StudentCourseHomework">
  234. SELECT
  235. sch.*,
  236. su.username_,
  237. su.avatar_
  238. FROM
  239. student_course_homework sch
  240. LEFT JOIN sys_user su ON sch.user_id_=su.id_
  241. <where>
  242. sch.course_schedule_id_=#{courseScheduleId}
  243. <if test="userName!=null and userName!=''">
  244. AND su.username_ LIKE CONCAT('%',#{userName},'%')
  245. </if>
  246. </where>
  247. </select>
  248. <select id="findByStudentAndCourseHomewok" resultMap="StudentCourseHomework">
  249. SELECT * FROM student_course_homework WHERE user_id_=#{userId} AND course_homework_id_=#{courseHomeworkId}
  250. </select>
  251. <select id="queryNotDoneHomeworkList" resultMap="StudentCourseHomeworkFull">
  252. SELECT sch.*,cg.name_ classGroupName,mg.name_ musicGroupName FROM student_course_homework sch left join course_homework ch on sch.course_homework_id_ = ch.id_ left join music_group mg on ch.music_group_id_ = mg.id_ left join class_group cg on ch.class_group_id_ = cg.id_ where sch.status_ = 0
  253. </select>
  254. <select id="countStudentCourseHomeworks" resultType="java.lang.Integer">
  255. SELECT COUNT(id_) FROM course_schedule_student_payment WHERE course_schedule_id_ = #{search}
  256. </select>
  257. <resultMap id="StudentCourseHomeworkDtoMap" type="com.ym.mec.biz.dal.dto.StudentCourseHomeworkDto">
  258. <result column="username_" property="username"/>
  259. <result column="phone_" property="phone"/>
  260. <result column="attachments_" property="url"/>
  261. <result column="is_replied_" property="isReplied"/>
  262. <result column="is_view_" property="isView"/>
  263. <result column="create_time_" property="createTime"/>
  264. </resultMap>
  265. <select id="findStudentCourseHomeworks" resultMap="StudentCourseHomeworkDtoMap">
  266. SELECT sch.attachments_,sch.is_replied_,sch.is_view_,sch.create_time_,su.username_,su.phone_
  267. FROM course_schedule_student_payment cssp
  268. LEFT JOIN student_course_homework sch ON sch.course_schedule_id_ = cssp.course_schedule_id_
  269. LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
  270. WHERE cssp.course_schedule_id_ = #{search}
  271. ORDER BY sch.id_ DESC
  272. <include refid="global.limit"/>
  273. </select>
  274. </mapper>