123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439 |
- <?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.SubjectDao">
- <resultMap type="com.ym.mec.biz.dal.entity.Subject" id="Subject">
- <result column="id_" property="id"/>
- <result column="cbs_subject_id_" property="cbsSubjectId"/>
- <result column="name_" property="name"/>
- <result column="code_" property="code"/>
- <result column="parent_subject_id_" property="parentSubjectId"/>
- <result column="img_" property="img"/>
- <result column="create_time_" property="createTime"/>
- <result column="update_time_" property="updateTime"/>
- <result column="instrumentIds" property="instrumentIds"/>
- <result column="del_flag_" property="delFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- </resultMap>
-
- <select id="get" resultMap="Subject">
- SELECT * FROM subject WHERE id_ = #{id}
- </select>
-
- <select id="findAll" resultMap="Subject">
- SELECT * FROM subject ORDER BY id_
- </select>
-
- <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Subject" useGeneratedKeys="true" keyColumn="id"
- keyProperty="id">
- INSERT INTO subject (id_,cbs_subject_id_,name_,code_,parent_subject_id_,img_,create_time_,update_time_)
- VALUES(#{id},#{cbsSubjectId},#{name},#{code},#{parentSubjectId},#{img},now(),now())
- </insert>
-
- <update id="update" parameterType="com.ym.mec.biz.dal.entity.Subject">
- UPDATE subject
- <set>
- <if test="delFlag != null">
- del_flag_ = #{delFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="parentSubjectId != null">
- parent_subject_id_ = #{parentSubjectId},
- </if>
- <if test="cbsSubjectId != null">
- cbs_subject_id_ = #{cbsSubjectId},
- </if>
- <if test="code != null">
- code_ = #{code},
- </if>
- <if test="img != null">
- img_ = #{img},
- </if>
- <if test="updateTime != null">
- update_time_ = NOW(),
- </if>
- <if test="name != null">
- name_ = #{name},
- </if>
- </set>
- WHERE id_ = #{id}
- </update>
-
- <update id="delete">
- UPDATE `subject` SET del_flag_ = 1 WHERE id_ = #{id} OR parent_subject_id_ = #{id}
- </update>
-
- <select id="queryPage" resultMap="Subject" parameterType="map">
- SELECT * FROM subject
- <include refid="querySubPageSql"/>
- ORDER BY id_
- <include refid="global.limit"/>
- </select>
-
- <select id="queryCount" resultType="int">
- SELECT COUNT(*) FROM subject <include refid="querySubPageSql"/>
- </select>
- <select id="findSubByMusicGroupId" resultMap="Subject">
- SELECT s.* FROM music_group_subject_plan mgsp
- LEFT JOIN `subject` s ON mgsp.subject_id_ = s.id_
- WHERE mgsp.music_group_id_ = #{musicGroupId} AND s.del_flag_ = 0
- </select>
- <select id="findByParentId" resultMap="Subject">
- SELECT * FROM subject <include refid="querySubPageSql"/>
- </select>
- <select id="findDefaultSubByChargeTypeId" resultMap="Subject">
- SELECT s.* FROM charge_type_subject_mapper ctsm
- LEFT JOIN `subject` s ON subject_id_ = s.id_
- WHERE ctsm.course_view_type_ = #{courseViewType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} AND s.del_flag_ = 0
- </select>
- <resultMap id="subApplyDetail" type="com.ym.mec.biz.dal.dto.SubjectApplyDetailDto">
- <result column="pay_num_" property="payNum"/>
- <result column="name_" property="subjectName"/>
- <result column="subject_id_" property="subjectId"/>
- <result column="expected_student_num_" property="expectedStudentNum"/>
- <result column="music_group_subject_plan_id_" property="musicGroupSubjectPlanId"/>
- <result column="apply_student_num_" property="applyStudentNum"/>
- <result column="not_part_class_num_" property="notPartClassNum"/>
- </resultMap>
- <select id="findSubApplyDetail" resultMap="subApplyDetail">
- SELECT mgsp.subject_id_,s.name_,mgsp.expected_student_num_,mgsp.apply_student_num_,
- mgsp.paid_student_num_ pay_num_,mgsp.id_ music_group_subject_plan_id_
- FROM music_group_subject_plan mgsp
- LEFT JOIN `subject` s ON mgsp.subject_id_ = s.id_
- WHERE mgsp.music_group_id_ = #{musicGroupId} AND s.del_flag_ = 0
- </select>
- <select id="findBySubIds" resultType="string">
- SELECT name_ FROM `subject` WHERE del_flag_ = 0 AND FIND_IN_SET (id_,#{subIds})
- </select>
- <select id="findTeacherSubjects" resultMap="Subject">
- SELECT s.* FROM teacher t
- LEFT JOIN `subject` s ON FIND_IN_SET(s.id_,t.subject_id_)
- WHERE t.id_=#{teacherId} AND s.del_flag_ = 0
- </select>
- <select id="findSubjectConditions" resultType="com.ym.mec.biz.dal.dto.ConditionDto">
- select id_ id,name_ `name` from subject where parent_subject_id_ != 0 AND del_flag_ = 0
- </select>
- <select id="queryNameByIds" resultType="java.util.Map">
- select id_ `key`,name_ `value` FROM `subject` s WHERE FIND_IN_SET(s.id_,#{subjectIds}) AND s.del_flag_ = 0
- </select>
- <select id="findBySubjecIds" resultType="java.util.Map">
- select id_ `key`,name_ `value` FROM `subject` s WHERE FIND_IN_SET(s.id_,#{subjectIds}) AND s.del_flag_ = 0
- </select>
- <select id="findSubSubjects" resultMap="Subject">
- SELECT * FROM `subject`
- <where>
- parent_subject_id_ != 0 AND del_flag_ = 0
- <if test="parentSubjectId != null and parentSubjectId != ''">
- AND parent_subject_id_ = #{parentSubjectId}
- </if>
- <if test="cbsFlag != null and cbsFlag == true">
- AND cbs_subject_id_ IS NOT NULL
- </if>
- </where>
- </select>
- <select id="queryPageByIdOrNameCount" resultType="integer">
- SELECT count(1) FROM `subject`
- <where>
- del_flag_ = 0 AND parent_subject_id_ != 0
- <if test="parentSubjectId != null and parentSubjectId != ''">
- AND parent_subject_id_ = #{parentSubjectId}
- </if>
- <if test="search != null and search != ''">
- AND (id_ = #{search} or name_ like concat('%', #{search}, '%'))
- </if>
- </where>
- </select>
- <select id="queryPageByIdOrName" resultMap="Subject">
- SELECT *,
- (select name_ from `subject` s1 where s.parent_subject_id_ = s1.id_) as parentSubjectName
- FROM `subject` s
- <where>
- s.del_flag_ = 0 AND s.parent_subject_id_ != 0
- <if test="parentSubjectId != null and parentSubjectId != ''">
- AND s.parent_subject_id_ = #{parentSubjectId}
- </if>
- <if test="search != null and search != ''">
- AND (s.id_ = #{search} or s.name_ like concat('%', #{search}, '%'))
- </if>
- </where>
- <include refid="global.limit"/>
- </select>
- <sql id="querySubPageSql">
- <where>
- <if test="parentId != null">
- AND parent_subject_id_ = #{parentId}
- </if>
- <if test="delFlag != null">
- AND del_flag_ = #{delFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- </where>
- </sql>
- <select id="findBySubjectByIdList" resultMap="Subject">
- SELECT * FROM `subject` WHERE del_flag_ = 0 AND FIND_IN_SET(id_,#{subjectIdList})
- </select>
- <select id="findByMusicGroupUserSubject" resultType="map">
- SELECT
- sr.user_id_ AS `key`,
- s.name_ AS `value`
- FROM
- student_registration sr
- LEFT JOIN `subject` s ON sr.actual_subject_id_=s.id_
- WHERE sr.music_group_id_=#{musicGroupId} AND s.del_flag_ = 0 AND sr.music_group_status_ != 'QUIT'
- AND sr.user_id_ IN
- <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
- #{userId}
- </foreach>
- </select>
- <select id="findSubjectNameCourseMaps" resultType="java.util.Map">
- SELECT
- cs.id_ AS 'key',
- GROUP_CONCAT(s.name_) AS 'value'
- FROM
- course_schedule cs
- LEFT JOIN class_group cg ON cs.class_group_id_=cg.id_
- LEFT JOIN `subject` s ON FIND_IN_SET(s.id_,cg.subject_id_list_)
- WHERE cs.id_ IN
- <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
- #{courseScheduleId}
- </foreach>
- AND cg.subject_id_list_ IS NOT NULL
- GROUP BY cs.id_
- </select>
- <select id="findClassGroupSubjectId" resultType="java.util.Map">
- SELECT
- cs.id_ AS 'key',
- cg.subject_id_list_ AS 'value'
- FROM
- course_schedule cs
- LEFT JOIN class_group cg ON cs.class_group_id_=cg.id_
- WHERE cs.id_ IN
- <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
- #{courseScheduleId}
- </foreach>
- AND cg.subject_id_list_ IS NOT NULL
- GROUP BY cs.id_
- </select>
- <select id="findNames" resultType="java.lang.String">
- SELECT GROUP_CONCAT(DISTINCT s.name_) FROM `subject` s WHERE FIND_IN_SET(s.id_,#{subjectIdList})
- </select>
- <select id="findStudentSubjectNameMaps" resultType="java.util.Map">
- SELECT
- sr.user_id_ as 'key',
- s.name_ as 'value'
- FROM
- student_registration sr
- LEFT JOIN `subject` s ON sr.actual_subject_id_ = s.id_
- WHERE 1=1
- AND
- <foreach collection="studentInfos" item="student" open="(" close=")" separator=" OR ">
- sr.user_id_=#{student.studentId} AND sr.music_group_id_=#{student.musicGroupId}
- </foreach>
- </select>
- <select id="findStudentSubjectIdMaps" resultType="java.util.Map">
- SELECT
- sr.user_id_ as 'key',
- sr.actual_subject_id_ as 'value'
- FROM
- student_registration sr
- WHERE 1=1
- AND
- <foreach collection="studentInfos" item="student" open="(" close=")" separator=" OR ">
- sr.user_id_=#{student.studentId} AND sr.music_group_id_=#{student.musicGroupId}
- </foreach>
- </select>
- <select id="findBySubjectIds" resultMap="Subject">
- SELECT * FROM subject WHERE id_ IN
- <foreach collection="subjectIds" item="subjectId" separator="," open="(" close=")">
- #{subjectId}
- </foreach>
- </select>
- <select id="getRegisterSubject" resultMap="com.ym.mec.biz.dal.dao.StudentRegistrationDao.StudentRegistration">
- SELECT sr.user_id_, s.name_ subject_name_,sr.actual_subject_id_ FROM student_registration sr
- LEFT JOIN subject s ON sr.actual_subject_id_=s.id_
- WHERE sr.music_group_id_=#{musicGroupId} AND s.del_flag_ = 0
- AND sr.user_id_ IN
- <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
- #{userId}
- </foreach>
- </select>
- <select id="list" resultMap="Subject">
- select * from subject where del_flag_ = 0 and parent_subject_id_ != 0
- </select>
- <select id="getSubjectByStudentId" resultType="com.ym.mec.biz.dal.dto.StudentSubjectDto">
- SELECT
- sr.user_id_ AS studentId,
- s.id_ AS subjectId,
- s.name_ AS subjectName
- FROM
- student sr
- LEFT JOIN `subject` s ON sr.subject_id_list_=s.id_
- WHERE sr.user_id_ IN
- <foreach collection="studentIds" item="userId" open="(" close=")" separator=",">
- #{userId}
- </foreach>
- </select>
- <select id="getSubjectListByIdAndCoopId" resultType="com.ym.mec.biz.dal.entity.Subject">
- SELECT
- distinct s.id_ as id
- ,s.name_ as name
- FROM
- `subject` s
- LEFT JOIN music_group_subject_plan mgsp on s.id_ = mgsp.subject_id_
- LEFT JOIN music_group mg on mg.id_ = mgsp.music_group_id_
- WHERE
- s.del_flag_ = 0 and mg.status_ = 'PROGRESS'
- <if test="musicGroupId != null and musicGroupId != ''">
- AND mg.id_ = #{musicGroupId}
- </if>
- <if test="coopId != null">
- AND mg.cooperation_organ_id_ = #{coopId}
- </if>
- </select>
- <select id="findByNames" resultMap="Subject">
- SELECT * FROM `subject` where name_ IN ('长笛','单簧管','萨克斯','小号','长号','圆号','上低音号','大号','打击乐') and del_flag_ = 0
- </select>
- <select id="queryCbsList" resultMap="Subject">
- SELECT * FROM `subject` WHERE del_flag_ = 0 AND parent_subject_id_ != 0 AND cbs_subject_id_ IS NOT NULL
- <if test="cbsSubjectIds != null and cbsSubjectIds.size > 0">
- AND cbs_subject_id_ IN
- <foreach collection="cbsSubjectIds" item="cbsSubjectId" open="(" close=")" separator=",">
- #{cbsSubjectId}
- </foreach>
- </if>
- </select>
- <select id="notInSubjectIds" resultMap="Subject">
- SELECT * FROM subject WHERE del_flag_ = 0 and id_ != #{subjectId}
- </select>
- <select id="findCount" resultType="java.lang.Integer">
- select count(DISTINCT t.id_) from
- (SELECT t.id_
- FROM subject t
- LEFT JOIN instrument i on t.id_ = i.subject_id_
- <where>
- <if test="parentSubjectId != null">
- AND t.parent_subject_id_ = #{parentSubjectId}
- </if>
- <if test="parentSubjectId == null">
- AND t.parent_subject_id_ != 0 AND t.cbs_subject_id_ is not null
- </if>
- <if test="keyword != null and keyword != ''">
- AND (t.name_ LIKE CONCAT('%',#{keyword},'%') OR t.code_ LIKE CONCAT('%',#{keyword},'%'))
- </if>
- <if test="delFlag != null">
- AND t.del_flag_ = #{delFlag}
- </if>
- <if test="subjectId != null">
- AND t.id_ = #{subjectId}
- </if>
- <if test="subjectIds != null">
- AND find_in_set(t.id_,#{subjectIds})
- </if>
- <if test="instrumentIds != null">
- AND find_in_set(i.id_, #{instrumentIds})
- </if>
- <if test="enableFlag != null">
- AND t.enable_flag_ = #{enableFlag} and i.enable_flag_ = #{enableFlag}
- </if>
- </where>
- group by t.id_
- <if test="hasInstrument != null">
- <if test="hasInstrument == true">
- having count(i.id_) > 0
- </if>
- <if test="hasInstrument == false">
- having count(i.id_) = 0
- </if>
- </if>) t
- </select>
- <sql id="baseColumns">
- t.id_ as id
- , t.name_ as name
- , t.code_ as code
- , t.parent_subject_id_ as parentSubjectId
- , t.img_ as img
- , t.del_flag_ as delFlag
- , t.update_time_ as updateTime
- , t.create_time_ as createTime
- ,t.cbs_subject_id_ as cbsSubjectId
- </sql>
- <select id="findPage" resultType="com.ym.mec.biz.dal.wrapper.SubjectWrapper$Subject">
- SELECT
- <include refid="baseColumns" />
- FROM subject t
- LEFT JOIN instrument i on t.id_ = i.subject_id_
- <where>
- <if test="parentSubjectId != null">
- AND t.parent_subject_id_ = #{parentSubjectId}
- </if>
- <if test="parentSubjectId == null">
- AND t.parent_subject_id_ != 0 AND t.cbs_subject_id_ is not null
- </if>
- <if test="keyword != null and keyword != ''">
- AND (t.name_ LIKE CONCAT('%',#{keyword},'%') OR t.code_ LIKE CONCAT('%',#{keyword},'%'))
- </if>
- <if test="delFlag != null">
- AND t.del_flag_ = #{delFlag}
- </if>
- <if test="subjectId != null">
- AND t.id_ = #{subjectId}
- </if>
- <if test="subjectIds != null">
- AND find_in_set(t.id_,#{subjectIds})
- </if>
- <if test="instrumentIds != null">
- AND find_in_set(i.id_, #{instrumentIds})
- </if>
- <if test="enableFlag != null">
- AND t.enable_flag_ = #{enableFlag} and i.enable_flag_ = #{enableFlag}
- </if>
- </where>
- group by t.id_
- <if test="hasInstrument != null">
- <if test="hasInstrument == true">
- having count(i.id_) > 0
- </if>
- <if test="hasInstrument == false">
- having count(i.id_) = 0
- </if>
- </if>
- <include refid="global.limit"/>
- </select>
- <select id="queryCbsSubjects"
- resultType="com.dayaedu.cbs.openfeign.wrapper.music.CbsSubjectApiWrapper$Subject">
- SELECT id_ subjectId,cbs_subject_id_ cbsSubjectId,name_ subjectName,code_ code FROM `subject`
- WHERE del_flag_ = 0 AND cbs_subject_id_ IS NOT NULL
- <if test="query.cbsSubjectIds != null and query.cbsSubjectIds.size > 0">
- AND cbs_subject_id_ IN
- <foreach collection="query.cbsSubjectIds" item="cbsSubjectId" open="(" close=")" separator=",">
- #{cbsSubjectId}
- </foreach>
- </if>
- <if test="query.subjectIds != null and query.subjectIds.size > 0">
- AND id_ IN
- <foreach collection="query.subjectIds" item="subjectId" open="(" close=")" separator=",">
- #{subjectId}
- </foreach>
- </if>
- </select>
- </mapper>
|