StudentCourseHomeworkMapper.xml 12 KB

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