CourseHomeworkMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. <mapper namespace="com.yonge.cooleshow.biz.dal.dao.CourseHomeworkDao">
  4. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.CourseHomework">
  5. <result column="id_" property="id" />
  6. <result column="course_group_id_" property="courseGroupId" />
  7. <result column="course_group_type_" property="courseGroupType" />
  8. <result column="course_schedule_id_" property="courseScheduleId" />
  9. <result column="title_" property="title" />
  10. <result column="content_" property="content" />
  11. <result column="attachments_" property="attachments" />
  12. <result column="expect_num_" property="expectNum" />
  13. <result column="completed_num_" property="completedNum" />
  14. <result column="create_time_" property="createTime" />
  15. <result column="update_time_" property="updateTime" />
  16. </resultMap>
  17. <!-- 表字段 -->
  18. <sql id="baseColumns">
  19. t.id_
  20. , t.course_group_id_
  21. , t.course_group_type_
  22. , t.course_schedule_id_
  23. , t.title_
  24. , t.content_
  25. , t.attachments_
  26. , t.expect_num_
  27. , t.completed_num_
  28. , t.create_time_
  29. , t.update_time_
  30. </sql>
  31. <select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.CourseHomeworkVo">
  32. SELECT
  33. <include refid="baseColumns"/>
  34. FROM course_homework t
  35. where t.id_ = #{id}
  36. </select>
  37. <select id="selectAdminPage" resultType="com.yonge.cooleshow.biz.dal.vo.CourseHomeworkVo">
  38. select
  39. cs.id_ AS courseId,
  40. cs.course_group_id_ AS courseGroupId,
  41. cs.class_date_ AS classDate,
  42. cs.type_ as type,
  43. cs.start_time_ AS startTime,
  44. cs.end_time_ AS endTime,
  45. ch.create_time_ as decorateTime,
  46. su2.id_ as studentId,
  47. su2.username_ as studentName,
  48. su2.avatar_ as studentAvatar,
  49. su.username_ as teacherName,
  50. su.avatar_ as teacherAvatar,
  51. sch.submit_time_ as submitTime,
  52. su.id_ as teacherId,
  53. ch.create_time_ as decorateTime
  54. from course_homework ch
  55. left join course_schedule cs on ch.course_schedule_id_ = cs.id_
  56. left join course_schedule_student_payment cssp on cssp.course_id_ = cs.id_
  57. left join sys_user su on cs.teacher_id_ = su.id_
  58. left join sys_user su2 on cssp.user_id_ = su2.id_
  59. left join student_course_homework sch on ch.id_ = sch.id_
  60. <where>
  61. <if test="param.courseStatus != null">
  62. and cs.status_ = #{param.courseStatus}
  63. </if>
  64. <if test="param.courseType != null and param.courseType.size() != 0">
  65. and cs.type_ in
  66. <foreach collection="param.courseType" item="item" open="(" close=")" separator=",">
  67. #{item}
  68. </foreach>
  69. </if>
  70. <if test="param.startTime != null">
  71. and #{param.startTime} &lt; ch.create_time_
  72. </if>
  73. <if test="param.endTime != null">
  74. and #{param.endTime} &gt; ch.create_time_
  75. </if>
  76. <if test="param.studentSearch != null and param.studentSearch != ''">
  77. and ( su2.id_ like concat('%',#{param.studentSearch},'%')
  78. or su2.username_ like concat('%',#{param.studentSearch},'%')
  79. or su2.phone_ like concat('%',#{param.studentSearch},'%') )
  80. </if>
  81. <if test="param.teacherSearch != null and param.teacherSearch != ''">
  82. and ( su.id_ like concat('%',#{param.teacherSearch},'%')
  83. or su.username_ like concat('%',#{param.teacherSearch},'%')
  84. or su.phone_ like concat('%',#{param.teacherSearch},'%') )
  85. </if>
  86. </where>
  87. order by cs.start_time_ desc
  88. </select>
  89. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.CourseHomeworkVo">
  90. select distinct
  91. cs.id_ AS courseId,
  92. cs.course_group_id_ AS courseGroupId,
  93. cs.class_date_ AS classDate,
  94. cs.class_num_ as classNum,
  95. cs.start_time_ AS startTime,
  96. cs.end_time_ AS endTime,
  97. cs.type_ as type,
  98. ch.create_time_ as decorateTime
  99. from course_schedule cs
  100. left join course_homework ch on ch.course_schedule_id_ = cs.id_
  101. left join student_course_homework sch on ch.id_ = sch.course_homework_id_
  102. left join course_schedule_student_payment cssp on cssp.course_id_ = cs.id_
  103. <where>
  104. <if test="param.decorate != null">
  105. <if test="param.decorate.code == 0">
  106. and ch.id_ is null
  107. </if>
  108. <if test="param.decorate.code == 1">
  109. and ch.id_ is not null
  110. </if>
  111. </if>
  112. <if test="param.submit != null">
  113. <if test="param.submit.code == 0">
  114. and sch.id_ is null
  115. </if>
  116. <if test="param.submit.code == 1">
  117. and sch.id_ is not null
  118. </if>
  119. </if>
  120. <if test="param.courseStatus != null">
  121. and cs.status_ = #{param.courseStatus}
  122. </if>
  123. <if test="param.courseType != null and param.courseType.size() != 0">
  124. and cs.type_ in
  125. <foreach collection="param.courseType" separator="," close=")" open="(" item="item" >
  126. #{item}
  127. </foreach>
  128. </if>
  129. <if test="param.teacherId != null">
  130. and cs.teacher_id_ = #{param.teacherId}
  131. </if>
  132. <if test="param.studentId != null">
  133. and cssp.user_id_ = #{param.studentId}
  134. </if>
  135. <if test="param.courseScheduleId != null ">
  136. and cs.id_ = #{param.courseScheduleId}
  137. </if>
  138. <if test="param.date != null and param.date != ''">
  139. and date_format(cs.class_date_,'%Y-%m') = #{param.date}
  140. </if>
  141. <if test="param.startTime != null">
  142. and #{param.startTime} &lt; ch.create_time_
  143. </if>
  144. <if test="param.endTime != null">
  145. and #{param.endTime} &gt; ch.create_time_
  146. </if>
  147. </where>
  148. order by cs.start_time_ desc
  149. </select>
  150. <select id="selectCourseHomeworkDetailByCourseId"
  151. resultType="com.yonge.cooleshow.biz.dal.vo.CourseHomeworkDetailVo">
  152. select ch.id_ as id
  153. ,cs.id_ as courseScheduleId
  154. ,ch.title_ as title
  155. ,ch.content_ as content
  156. ,ch.attachments_ as attachments
  157. ,ch.create_time_ as decorateTime
  158. ,sch.attachments_ as studentAttachments
  159. ,sch.teacher_replied_ as teacherReplied
  160. ,sch.submit_time_ as submitTime
  161. ,sch.id_ as studentHomeworkId
  162. ,sch.student_id_ as studentId
  163. ,cs.teacher_id_ as teacherId
  164. ,cs.type_ as courseType
  165. ,cs.class_date_ as classDate
  166. ,cs.start_time_ as startTime
  167. ,cs.end_time_ as endTime
  168. ,cs.status_ as courseStatus
  169. ,cs.course_group_id_ as courseGroupId
  170. ,if(ch.id_ is null,0,1) as decorateHomework
  171. ,if(sch.attachments_ is null or sch.attachments_ = '',0,1) as submitHomework
  172. ,if(sch.teacher_replied_ is null or sch.attachments_ = '',0,1) as reviewHomework
  173. from course_schedule cs
  174. left join course_homework ch on ch.course_schedule_id_ = cs.id_
  175. left join student_course_homework sch on ch.id_ = sch.course_homework_id_
  176. left join course_schedule_student_payment cssp on cs.id_ = cssp.course_id_
  177. <where>
  178. <if test="courseId != null">
  179. and cs.id_ = #{courseId}
  180. </if>
  181. <if test="studentId != null">
  182. and cssp.user_id_ = #{studentId}
  183. </if>
  184. </where>
  185. limit 1
  186. </select>
  187. <select id="selectPaymentStudentInfo" resultType="com.yonge.cooleshow.biz.dal.vo.CourseHomeworkDetailVo">
  188. select su.username_ as studentName
  189. ,su.avatar_ as stduentAvatar
  190. ,cssp.user_id_ as studentId
  191. from course_schedule cs
  192. left join course_schedule_student_payment cssp on cs.id_ = cssp.course_id_
  193. left join sys_user su on su.id_ = cssp.user_id_
  194. <where>
  195. <if test="courseScheduleId != null">
  196. and cs.id_ = #{courseScheduleId}
  197. </if>
  198. <if test="studentId != null">
  199. and cssp.user_id_ = #{studentId}
  200. </if>
  201. </where>
  202. </select>
  203. <select id="selectSubjectAndTeacherInfo" resultType="com.yonge.cooleshow.biz.dal.vo.CourseHomeworkDetailVo">
  204. select s.name_ as subjectName
  205. ,su.username_ as teacherName
  206. ,su.avatar_ as teacherAvatar
  207. ,su.id_ as teacherId
  208. from course_group cg
  209. left join subject s on cg.subject_id_ = s.id_
  210. left join sys_user su on cg.teacher_id_ = su.id_
  211. <where>
  212. <if test="courseGroupId != null">
  213. and cg.id_ = #{courseGroupId}
  214. </if>
  215. </where>
  216. </select>
  217. <select id="selectStudentInfo" resultType="com.yonge.cooleshow.biz.dal.vo.CourseHomeworkVo">
  218. select
  219. cs.id_ as courseId,
  220. cssp.user_id_ as studentId
  221. ,su.username_ as studentName
  222. ,su.avatar_ as studentAvatar
  223. from course_schedule cs
  224. left join course_schedule_student_payment cssp on cssp.course_id_ = cs.id_
  225. left join sys_user su on cssp.user_id_ = su.id_
  226. <where>
  227. <if test="records != null and records.size() != 0">
  228. and cs.id_ in
  229. <foreach collection="records" separator="," close=")" open="(" item="item" >
  230. #{item.courseId}
  231. </foreach>
  232. </if>
  233. </where>
  234. </select>
  235. <select id="selectSubjectAndGroupInfoList" resultType="com.yonge.cooleshow.biz.dal.vo.CourseHomeworkVo">
  236. select
  237. cs.id_ as courseId,
  238. s.name_ as subjectName
  239. ,cg.name_ as courseGroupName
  240. ,cg.background_pic_ as backgroundPic
  241. ,cs.class_num_ as classNum
  242. from course_schedule cs
  243. left join course_group cg on cs.course_group_id_ = cg.id_
  244. left join subject s on s.id_ = cg.subject_id_
  245. <where>
  246. <if test="records != null and records.size() != 0">
  247. and cs.id_ in
  248. <foreach collection="records" separator="," close=")" open="(" item="item" >
  249. #{item.courseId}
  250. </foreach>
  251. </if>
  252. </where>
  253. </select>
  254. <select id="selectTeacherInfo" resultType="com.yonge.cooleshow.biz.dal.vo.CourseHomeworkVo">
  255. select
  256. cs.id_ as courseId,
  257. cs.teacher_id_ as teacherId
  258. ,su.username_ as teacherName
  259. ,su.avatar_ as teacherAvatar
  260. from course_schedule cs
  261. left join sys_user su on cs.teacher_id_ = su.id_
  262. <where>
  263. <if test="records != null and records.size() != 0">
  264. and cs.id_ in
  265. <foreach collection="records" separator="," close=")" open="(" item="item" >
  266. #{item.courseId}
  267. </foreach>
  268. </if>
  269. </where>
  270. </select>
  271. <select id="selectCourseHomeworkByCourseId" resultType="com.yonge.cooleshow.biz.dal.vo.CourseScheduleHomeworkVo">
  272. select
  273. cs.id_ as courseId,
  274. cg.id_ as courseGroupId,
  275. cg.name_ as courseGroupName,
  276. cs.type_ as type,
  277. cs.class_num_ as classNum,
  278. cs.class_date_ as classDate,
  279. cs.start_time_ as startTime,
  280. cs.end_time_ as endTime,
  281. s.name_ as subjectName,
  282. ch.title_ as title,
  283. ch.content_ as content,
  284. ch.attachments_ as attachments,
  285. if(ch.id_ is null,0,1) as decorateHomework,
  286. ch.create_time_ as decorateTime,
  287. cs.status_ as courseStatus,
  288. cg.background_pic_ as backgroundPic
  289. from course_schedule cs
  290. left join course_group cg on cs.course_group_id_ = cg.id_
  291. left join course_homework ch on cs.id_ = ch.course_schedule_id_
  292. left join subject s on cg.subject_id_ = s.id_
  293. where cs.id_ = #{courseId}
  294. </select>
  295. <select id="selectStudentHomeworkByCourseId" resultType="com.yonge.cooleshow.biz.dal.vo.StudentHomeworkVo">
  296. select
  297. s.id_ as studentId,
  298. s.username_ as studentName,
  299. s.phone_ as studentAvatar,
  300. if(sch.id_ is not null,1,0) as submitHomework
  301. from course_schedule_student_payment cssp
  302. left join sys_user s on cssp.user_id_ = s.id_
  303. left join student_course_homework sch on cssp.user_id_ = sch.student_id_ and sch.course_schedule_id_ = cssp.course_id_
  304. <where>
  305. <if test="courseId != null">
  306. and cssp.course_id_ = #{courseId}
  307. </if>
  308. </where>
  309. </select>
  310. <select id="selectAbsenteeism" resultType="com.yonge.cooleshow.biz.dal.vo.CourseHomeworkVo">
  311. select
  312. cs.id_ as courseId
  313. ,if(sa.id_ is null,1,0) as absenteeism
  314. from course_schedule cs
  315. left join student_attendance sa on sa.course_schedule_id_ = cs.id_
  316. <where>
  317. sa.student_id_ = #{studentId}
  318. <if test="practiceRecord != null and practiceRecord.size() != 0">
  319. and cs.id_ in
  320. <foreach collection="practiceRecord" separator="," close=")" open="(" item="item" >
  321. #{item.courseId}
  322. </foreach>
  323. </if>
  324. </where>
  325. </select>
  326. </mapper>