| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <!--
- 这个文件是自动生成的。
- 不要修改此文件。所有改动将在下次重新自动生成时丢失。
- -->
- <mapper namespace="com.ym.mec.biz.dal.dao.CoursesGroupDao">
-
- <resultMap type="com.ym.mec.biz.dal.entity.CoursesGroup" id="CoursesGroup">
- <result column="id_" property="id" />
- <result column="name_" property="name" />
- <result column="subject_id_" property="subjectId" />
- <result column="courses_start_date_" property="coursesStartDate" />
- <result column="courses_end_date_" property="coursesEndDate" />
- <result column="teaching_arrangement_" property="teachingArrangement" />
- <result column="organ_id_" property="organId" />
- <result column="single_class_minutes_" property="singleClassMinutes" />
- <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="memo_" property="memo" />
- <result column="teacher_id_" property="teacherId" />
- <result column="max_student_num_" property="maxStudentNum" />
- <result column="apply_closing_date_" property="applyClosingDate" />
- <result column="teaching_plan_" property="teachingPlan" />
- <result column="teacher_salary_settlement_method_" property="teacherSalarySettlementMethod" />
- <result column="total_courses_price_" property="totalCoursesPrice" />
- <result column="total_course_discount_price_" property="totalCourseDiscountPrice" />
- <result column="create_time_" property="createTime" />
- <result column="update_time_" property="updateTime" />
- <result column="educational_teacher_id_" property="educationalTeacherId" />
- </resultMap>
- <resultMap id="CourseGroupExtendDto" type="com.ym.mec.biz.dal.dto.CourseGroupExtendDto" extends="CoursesGroup">
- </resultMap>
-
- <!-- 根据主键查询一条记录 -->
- <select id="get" resultMap="CoursesGroup" >
- SELECT * FROM courses_group WHERE id_ = #{id}
- </select>
- <select id="lockGroup" resultMap="CoursesGroup" >
- SELECT * FROM courses_group WHERE id_ = #{groupId} FOR UPDATE
- </select>
-
- <!-- 全查询 -->
- <select id="findAll" resultMap="CoursesGroup">
- SELECT * FROM courses_group ORDER BY id_
- </select>
-
- <!-- 向数据库增加一条记录 -->
- <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CoursesGroup" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
- INSERT INTO courses_group (id_,name_,subject_id_,courses_start_date_,courses_end_date_,teaching_arrangement_,
- organ_id_,single_class_minutes_,status_,memo_,teacher_id_,max_student_num_,apply_closing_date_,
- teaching_plan_,teacher_salary_settlement_method_,total_courses_price_,total_course_discount_price_,create_time_,update_time_,educational_teacher_id_)
- VALUES(#{id},#{name},#{subjectId},#{coursesStartDate},#{coursesEndDate},#{teachingArrangement},
- #{organId},#{singleClassMinutes},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- #{memo},#{teacherId},#{maxStudentNum},#{applyClosingDate},#{teachingPlan},#{teacherSalarySettlementMethod},
- #{totalCoursesPrice},#{totalCourseDiscountPrice},NOW(),NOW(),#{educationalTeacherId})
- </insert>
-
- <!-- 根据主键查询一条记录 -->
- <update id="update" parameterType="com.ym.mec.biz.dal.entity.CoursesGroup">
- UPDATE courses_group
- <set>
- <if test="coursesEndDate != null">
- courses_end_date_ = #{coursesEndDate},
- </if>
- <if test="educationalTeacherId != null">
- educational_teacher_id_ = #{educationalTeacherId},
- </if>
- <if test="subjectId != null">
- subject_id_ = #{subjectId},
- </if>
- <if test="status != null">
- status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="organId != null">
- organ_id_ = #{organId},
- </if>
- <if test="totalCourseDiscountPrice != null">
- total_course_discount_price_ = #{totalCourseDiscountPrice},
- </if>
- <if test="id != null">
- id_ = #{id},
- </if>
- <if test="coursesStartDate != null">
- courses_start_date_ = #{coursesStartDate},
- </if>
- <if test="memo != null">
- memo_ = #{memo},
- </if>
- <if test="maxStudentNum != null">
- max_student_num_ = #{maxStudentNum},
- </if>
- <if test="name != null">
- name_ = #{name},
- </if>
- <if test="teacherSalarySettlementMethod != null">
- teacher_salary_settlement_method_ = #{teacherSalarySettlementMethod},
- </if>
- <if test="createTime != null">
- create_time_ = #{createTime},
- </if>
- <if test="teachingPlan != null">
- teaching_plan_ = #{teachingPlan},
- </if>
- <if test="applyClosingDate != null">
- apply_closing_date_ = #{applyClosingDate},
- </if>
- <if test="totalCoursesPrice != null">
- total_courses_price_ = #{totalCoursesPrice},
- </if>
- <if test="teachingArrangement != null">
- teaching_arrangement_ = #{teachingArrangement},
- </if>
- <if test="teacherId != null">
- teacher_id_ = #{teacherId},
- </if>
- <if test="singleClassMinutes != null">
- single_class_minutes_ = #{singleClassMinutes},
- </if>
- update_time_ = NOW()
- </set> WHERE id_ = #{id}
- </update>
- <update id="updateGroupStatus">
- UPDATE courses_group SET status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} WHERE id_ IN
- <foreach collection="groupIds" item="groupId" open="(" close=")" separator=",">
- #{groupId}
- </foreach>
- </update>
- <!-- 根据主键删除一条记录 -->
- <delete id="delete" >
- DELETE FROM courses_group WHERE id_ = #{id}
- </delete>
-
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="CoursesGroup" parameterType="map">
- SELECT * FROM courses_group ORDER BY id_ <include refid="global.limit"/>
- </select>
-
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(*) FROM courses_group
- </select>
- <select id="findTeacherCourseGroups" resultMap="CoursesGroup">
- SELECT * FROM courses_group WHERE teacher_id_=#{teacherId}
- <if test="groupStatus!=null">
- AND status_ = #{groupStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- ORDER BY id_ DESC
- <include refid="global.limit"/>
- </select>
- <select id="countTeacherGroups" resultType="int">
- SELECT COUNT(id_) FROM courses_group WHERE teacher_id_=#{teacherId}
- <if test="groupStatus!=null">
- AND status_ = #{groupStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- </select>
- <sql id="teacherCourseGroupsQueryCondition">
- <where>
- <if test="teacherId!=null">
- AND teacher_id_=#{teacherId}
- </if>
- <if test="search!=null">
- AND (name_ LIKE CONCAT('%', #{search}, '%') OR id_ LIKE CONCAT('%', #{search}, '%'))
- </if>
- <if test="groupStatus!=null">
- AND status_ = #{groupStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- </where>
- </sql>
- <select id="findTeacherCourseGroupsWithWeb" resultMap="CourseGroupExtendDto">
- SELECT * FROM courses_group
- <include refid="teacherCourseGroupsQueryCondition"/>
- ORDER BY id_ DESC
- <include refid="global.limit"/>
- </select>
- <select id="countTeacherGroupsWithWeb" resultType="int">
- SELECT COUNT(id_) FROM courses_group
- <include refid="teacherCourseGroupsQueryCondition"/>
- </select>
- <select id="queryTeacherCourseGroups" resultMap="CoursesGroup">
- SELECT * FROM courses_group
- WHERE teacher_id_=#{userId} AND status_ IN ('NOT_START', 'NORMAL', 'FINISH','CANCEL')
- ORDER BY id_ DESC
- <include refid="global.limit"/>
- </select>
- <select id="countTeacherCourseGroups" resultType="int">
- SELECT COUNT(0) FROM courses_group
- WHERE teacher_id_ = #{userId} AND status_ IN ('NOT_START', 'NORMAL', 'FINISH','CANCEL')
- </select>
- <select id="findFreezeMinutes" resultType="java.util.Map">
- SELECT COUNT(DISTINCT cs.id_) * cg.single_class_minutes_ 'value',cg.id_ 'key' FROM courses_group cg
- LEFT JOIN course_schedule cs ON cg.id_ = cs.music_group_id_
- WHERE cg.id_ IN
- <foreach collection="groupIds" separator="," open="(" close=")" item="item">
- #{item}
- </foreach>
- AND cs.group_type_ = 'COMM' AND CONCAT(cs.class_date_,' ',cs.start_class_time_) > NOW()
- GROUP BY cg.id_
- </select>
- <select id="findConsumeMinutes" resultType="java.util.Map">
- SELECT COUNT(DISTINCT cs.id_) * cg.single_class_minutes_ 'value',cg.id_ 'key' FROM courses_group cg
- LEFT JOIN course_schedule cs ON cg.id_ = cs.music_group_id_
- WHERE cg.id_ IN
- <foreach collection="groupIds" separator="," open="(" close=")" item="item">
- #{item}
- </foreach>
- AND cs.group_type_ = 'COMM' AND CONCAT(cs.class_date_,' ',cs.start_class_time_) <= NOW()
- GROUP BY cg.id_
- </select>
- <select id="findNoStudentsGroups" resultMap="CoursesGroup">
- SELECT
- csg.*
- FROM
- courses_group csg
- LEFT JOIN class_group cg ON cg.music_group_id_ = csg.id_
- LEFT JOIN course_schedule cs ON cs.music_group_id_ = csg.id_
- WHERE
- cg.group_type_ = 'COMM'
- AND cs.group_type_ = 'COMM'
- AND cg.student_num_ = 0
- AND csg.status_='NORMAL'
- GROUP BY csg.id_ HAVING MIN(cs.class_date_)<=DATE_FORMAT(#{startDate}, '%Y-%m-%d')
- </select>
- <select id="findNoCoursesGroups" resultMap="CoursesGroup">
- SELECT
- cg.*
- FROM
- courses_group cg
- LEFT JOIN course_schedule cs ON cs.music_group_id_ = cg.id_
- AND cs.group_type_ = 'COMM'
- AND CONCAT( cs.class_date_, ' ', cs.end_class_time_ ) > NOW( )
- WHERE
- cg.status_ = 'NORMAL'
- GROUP BY
- cg.id_
- HAVING
- COUNT( cs.id_ ) <=0
- </select>
- <select id="findStudentCourseGroupsWithWeb" resultMap="CourseGroupExtendDto">
- SELECT csg.* FROM class_group_student_mapper cgsm LEFT JOIN courses_group csg ON csg.id_=cgsm.music_group_id_
- WHERE cgsm.user_id_=#{studentId} AND cgsm.group_type_='COMM'
- <if test="search!=null">
- AND (csg.name_ LIKE CONCAT('%', #{search}, '%') OR csg.id_ LIKE CONCAT('%', #{search}, '%'))
- </if>
- <if test="groupStatus!=null">
- AND csg.status_ = #{groupStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- ORDER BY id_ DESC
- <include refid="global.limit"/>
- </select>
- <select id="countStudentGroupsWithWeb" resultType="int">
- SELECT COUNT(csg.id_) FROM class_group_student_mapper cgsm LEFT JOIN courses_group csg ON csg.id_=cgsm.music_group_id_
- WHERE
- cgsm.user_id_=#{studentId} AND cgsm.group_type_='COMM'
- <if test="search!=null">
- AND (csg.name_ LIKE CONCAT('%', #{search}, '%') OR csg.id_ LIKE CONCAT('%', #{search}, '%'))
- </if>
- <if test="groupStatus!=null">
- AND csg.status_ = #{groupStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- </select>
- </mapper>
|