StudentCourseHomeworkMapper.xml 9.4 KB

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