CourseGroupMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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.CourseGroupDao">
  4. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.CourseGroup">
  5. <id column="id_" jdbcType="BIGINT" property="id"/>
  6. <result column="type_" jdbcType="VARCHAR" property="type"/>
  7. <result column="teacher_id_" jdbcType="INTEGER" property="teacherId"/>
  8. <result column="name_" jdbcType="VARCHAR" property="name"/>
  9. <result column="subject_id_" jdbcType="INTEGER" property="subjectId"/>
  10. <result column="single_course_minutes_" jdbcType="INTEGER" property="singleCourseMinutes"/>
  11. <result column="course_num_" jdbcType="INTEGER" property="courseNum"/>
  12. <result column="complete_course_num_" jdbcType="INTEGER" property="completeCourseNum"/>
  13. <result column="course_introduce_" jdbcType="VARCHAR" property="courseIntroduce"/>
  14. <result column="course_price_" jdbcType="VARCHAR" property="coursePrice"/>
  15. <result column="status_" jdbcType="VARCHAR" property="status"/>
  16. <result column="sales_start_date_" jdbcType="TIMESTAMP" property="salesStartDate"/>
  17. <result column="sales_end_date_" jdbcType="TIMESTAMP" property="salesEndDate"/>
  18. <result column="background_pic_" jdbcType="VARCHAR" property="backgroundPic"/>
  19. <result column="mix_student_num_" jdbcType="INTEGER" property="mixStudentNum"/>
  20. <result column="course_start_time_" jdbcType="TIMESTAMP" property="courseStartTime"/>
  21. <result column="created_by_" jdbcType="INTEGER" property="createdBy"/>
  22. <result column="created_time_" jdbcType="TIMESTAMP" property="createdTime"/>
  23. <result column="updated_by_" jdbcType="INTEGER" property="updatedBy"/>
  24. <result column="updated_time_" jdbcType="TIMESTAMP" property="updatedTime"/>
  25. <result column="pre_student_num_" jdbcType="INTEGER" property="preStudentNum"/>
  26. </resultMap>
  27. <sql id="Base_Column_List">
  28. id_
  29. , type_, teacher_id_, name_, subject_id_, single_course_minutes_, course_num_, complete_course_num_, course_introduce_, course_price_, status_, sales_start_date_, sales_end_date_, background_pic_, mix_student_num_,pre_student_num_, course_start_time_, created_by_, created_time_, updated_by_, updated_time_
  30. </sql>
  31. <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
  32. parameterType="com.yonge.cooleshow.biz.dal.entity.CourseGroup">
  33. insert into course_group(type_, teacher_id_, name_, subject_id_, single_course_minutes_, course_num_,
  34. complete_course_num_, course_introduce_, course_price_, status_, sales_start_date_, sales_end_date_, background_pic_,
  35. mix_student_num_,pre_student_num_, course_start_time_, created_by_, created_time_, updated_by_, updated_time_)
  36. values
  37. <foreach collection="entities" item="entity" separator=",">
  38. (#{entity.type}, #{entity.teacherId}, #{entity.name}, #{entity.subjectId}, #{entity.singleCourseMinutes},
  39. #{entity.courseNum}, #{entity.completeCourseNum}, #{entity.courseIntroduce}, #{entity.coursePrice}, #{entity.status},
  40. #{entity.salesStartDate}, #{entity.salesEndDate}, #{entity.backgroundPic}, #{entity.mixStudentNum},
  41. #{entity.preStudentNum},#{entity.courseStartTime}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy},
  42. #{entity.updatedTime})
  43. </foreach>
  44. </insert>
  45. <select id="queryTeacherCourseGroup" resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupVo">
  46. select
  47. b.id_ as courseGroupId,
  48. b.name_ as courseGroupName,
  49. s.name_ as subjectName,
  50. a.teacher_id_ as teacherId,
  51. u.real_name_ as teacherName,
  52. b.course_start_time_ as courseStartTime,
  53. b.single_course_minutes_ as singleCourseMinutes,
  54. a.status_ as `status`,
  55. ifnull(b.pre_student_num_, 0) as studentCount,
  56. b.background_pic_ as backgroundPic,
  57. b.course_price_ as coursePrice,
  58. b.course_num_ as courseNum
  59. from course_group as b
  60. left join course_schedule as a on a.course_group_id_ = b.id_
  61. left join subject as s on b.subject_id_ = s.id_
  62. left join sys_user as u on a.teacher_id_ = u.id_
  63. <where>
  64. a.lock_ = 0
  65. <if test="param.teacherId != null">
  66. and b.teacher_id_ = #{param.teacherId}
  67. </if>
  68. <if test="param.status != null">
  69. and a.status_ = #{param.status}
  70. </if>
  71. <if test="param.groupStatus != null">
  72. and b.status_ = #{param.groupStatus}
  73. </if>
  74. <if test="param.type_ != null">
  75. and a.type_ = #{param.type}
  76. </if>
  77. <if test="param.startDate != null">
  78. AND <![CDATA[ a.class_date_ >= #{param.startDate} ]]>
  79. </if>
  80. <if test="param.endDate != null">
  81. AND <![CDATA[ a.class_date_ <= #{param.endDate} ]]>
  82. </if>
  83. <if test="param.subjectId != null">
  84. AND b.subject_id_ = #{param.subjectId}
  85. </if>
  86. </where>
  87. </select>
  88. <select id="selectAdminLivePage" resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupVo">
  89. select distinct
  90. cg.id_ as courseGroupId,
  91. cg.name_ as name,
  92. cg.complete_course_num_ as endCourseNum,
  93. if(cg.complete_course_num_ = 0 ,cg.course_num_,cg.course_num_ - cg.complete_course_num_) as noStartCourseNum,
  94. cg.course_price_ as coursePrice,
  95. cg.pre_student_num_ as preStudentNum,
  96. cg.status_ as status,
  97. cg.course_num_ as courseNum,
  98. cg.created_time_ as createTime,
  99. cg.course_introduce_ as courseIntroduce
  100. from course_group cg
  101. left join course_schedule_student_payment cssp on cg.id_ = cssp.course_group_id_
  102. <if test="param.search != null and param.search != ''">
  103. left join sys_user su on su.id_ = cssp.user_id_
  104. </if>
  105. <where>
  106. <if test="param.teacherId != null">
  107. and #{param.teacherId} = cg.teacher_id_
  108. </if>
  109. <if test="param.search != null and param.search !=''">
  110. and (
  111. cg.id_ like concat('%',#{param.search},'%')
  112. or su.id_ like concat('%',#{param.search},'%')
  113. or su.username_ like concat('%',#{param.search},'%')
  114. or su.phone_ like concat('%',#{param.search},'%')
  115. )
  116. </if>
  117. <if test="param.orderNo != null and param.orderNo != ''">
  118. and cssp.order_no_ like concat('%',#{param.orderNo},'%')
  119. </if>
  120. <if test="param.subjectId != null">
  121. and #{param.subjectId} = cg.subject_id_
  122. </if>
  123. <if test="param.status != null">
  124. and #{param.status} = cg.status_
  125. </if>
  126. <if test="param.startTime != null">
  127. and #{param.startTime} &lt;= cg.created_time_
  128. </if>
  129. <if test="param.endTime != null">
  130. and #{param.endTime} &gt;= cg.created_time_
  131. </if>
  132. <if test="param.courseType != null">
  133. and #{param.courseType} = cg.type_
  134. </if>
  135. </where>
  136. </select>
  137. <select id="selectCourseGroupSubject" resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupVo">
  138. select
  139. cg.id_ as courseGroupId,
  140. s.name_ as subjectName
  141. from course_group cg
  142. left join subject s on cg.subject_id_ = s.id_
  143. <where>
  144. <if test="courseGroupIdList != null and courseGroupIdList.size() != 0">
  145. and cg.id_ in
  146. <foreach collection="courseGroupIdList" item="item" open="(" close=")" separator=",">
  147. #{item}
  148. </foreach>
  149. </if>
  150. </where>
  151. <if test="courseGroupIdList != null and courseGroupIdList.size() != 0">
  152. order by field(cg.id_,
  153. <foreach collection="courseGroupIdList" item="item" open="" close=")" separator=",">
  154. #{item}
  155. </foreach>
  156. </if>
  157. </select>
  158. <select id="selectAdminLiveStudentPage" resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupStudentVo">
  159. select
  160. su.id_ as studentId,
  161. su.username_ as studentName,
  162. cssp.actual_price_ as price,
  163. cssp.order_no_ as orderNo,
  164. cssp.created_time_ as payTime
  165. from course_schedule_student_payment cssp
  166. left join sys_user su on cssp.user_id_ = su.id_
  167. <where>
  168. <if test="param.courseGroupId != null">
  169. and #{param.courseGroupId} = cssp.course_group_id_
  170. </if>
  171. <if test="param.search != null and param.search != ''">
  172. and (
  173. cssp.course_group_id_ like concat('%',#{param.search},'%')
  174. or su.id_ like concat('%',#{param.search},'%')
  175. or su.username_ like concat('%',#{param.search},'%')
  176. or su.phone_ like concat('%',#{param.search},'%')
  177. )
  178. </if>
  179. <if test="param.orderNo != null and param.orderNo != ''">
  180. and cssp.order_no_ like concat('%',#{param.orderNo},'%')
  181. </if>
  182. <if test="param.startTime != null">
  183. and #{param.startTime} &lt;= cssp.created_time_
  184. </if>
  185. <if test="param.endTime != null">
  186. and #{param.endTime} &gt;= cssp.created_time_
  187. </if>
  188. </where>
  189. </select>
  190. <select id="selectAdminLivePlan" resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupPlanVo">
  191. select
  192. cs.id_ as courseId,
  193. cs.class_num_ as classNum,
  194. cs.class_date_ as classDate,
  195. cs.start_time_ as startTime,
  196. cs.end_time_ as endTime,
  197. cs.status_ as courseStatus,
  198. cp.plan_ as planInfo,
  199. lrv.url_ as videoUrl
  200. from course_schedule cs
  201. left join live_room_video lrv on cs.id_ = lrv.course_id_
  202. left join course_plan cp on cp.course_group_id_ = cs.course_group_id_ and cp.class_num_ = cs.class_num_
  203. <where>
  204. <if test="courseGroupId != null">
  205. and #{courseGroupId} = cs.course_group_id_
  206. </if>
  207. </where>
  208. order by cs.class_num_
  209. </select>
  210. </mapper>