123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860 |
- <?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.yonge.cooleshow.biz.dal.dao.MusicSheetDao">
- <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.MusicSheet">
- <id column="id_" jdbcType="BIGINT" property="id"/>
- <result column="music_sheet_name_" jdbcType="VARCHAR" property="musicSheetName"/>
- <result column="user_id_" jdbcType="BIGINT" property="userId"/>
- <result column="composer_" jdbcType="VARCHAR" property="composer"/>
- <result column="music_subject_" jdbcType="VARCHAR" property="musicSubject"/>
- <result column="audio_type_" jdbcType="VARCHAR" property="audioType"/>
- <result column="music_tag_" jdbcType="VARCHAR" property="musicTag"/>
- <result column="play_speed_" jdbcType="INTEGER" property="playSpeed"/>
- <result column="favorite_count_" jdbcType="INTEGER" property="favoriteCount"/>
- <result column="virtual_number_" property="virtualNumber" />
- <result column="first_pass_audit_time_" jdbcType="TIMESTAMP" property="firstPassAuditTime"/>
- <result column="can_evaluate_" jdbcType="TINYINT" property="canEvaluate"/>
- <result column="show_fingering_" jdbcType="TINYINT" property="showFingering"/>
- <result column="charge_type_" jdbcType="TINYINT" property="chargeType"/>
- <result column="audit_status_" jdbcType="TINYINT" property="auditStatus"/>
- <result column="sort_number_" jdbcType="INTEGER" property="sortNumber"/>
- <result column="top_flag_" jdbcType="TINYINT" property="topFlag"/>
- <result column="hot_flag_" jdbcType="TINYINT" property="hotFlag"/>
- <result column="exquisite_flag_" jdbcType="TINYINT" property="exquisiteFlag"/>
- <result column="music_price_" jdbcType="DECIMAL" property="musicPrice"/>
- <result column="audio_file_url_" jdbcType="VARCHAR" property="audioFileUrl"/>
- <result column="xml_file_url_" jdbcType="VARCHAR" property="xmlFileUrl"/>
- <result column="has_beat_" jdbcType="TINYINT" property="hasBeat"/>
- <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="create_by_" jdbcType="BIGINT" property="createBy"/>
- <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
- <result column="update_by_" jdbcType="BIGINT" property="updateBy"/>
- <result column="remark_" jdbcType="VARCHAR" property="remark"/>
- <result column="notation_" jdbcType="VARCHAR" property="notation"/>
- <result column="accompaniment_type_" jdbcType="VARCHAR" property="accompanimentType"/>
- <result column="title_img_" jdbcType="VARCHAR" property="titleImg"/>
- <result column="music_img_" jdbcType="VARCHAR" property="musicImg"/>
- <result column="first_tone_" jdbcType="VARCHAR" property="firstTone"/>
- <result column="fixed_tone_" jdbcType="VARCHAR" property="fixedTone"/>
- <result column="music_sheet_type_" jdbcType="VARCHAR" property="musicSheetType"/>
- <result column="provider_type_" jdbcType="VARCHAR" property="providerType"/>
- </resultMap>
- <sql id="Base_Column_List">
- t.id_ as id ,
- t.music_sheet_name_ as musicSheetName,
- t.user_id_ as userId,
- t.composer_ as composer,
- t.music_subject_ as musicSubject,
- t.audio_type_ as audioType,
- t.music_tag_ as musicTag,
- t.play_speed_ as playSpeed,
- t.favorite_count_ as favoriteCount,
- t.virtual_number_ as virtualNumber,
- t.first_pass_audit_time_ as firstPassAuditTime,
- t.can_evaluate_ as canEvaluate,
- t.show_fingering_ as showFingering,
- t.charge_type_ as chargeType,
- t.payment_type_ as paymentType,
- t.provider_type_ as providerType,
- t.state_ as state,
- t.audit_status_ as auditStatus,
- t.sort_number_ as sortNumber,
- t.top_flag_ as topFlag,
- t.exquisite_flag_ as exquisiteFlag,
- t.hot_flag_ as hotFlag,
- t.music_price_ as musicPrice,
- t.audio_file_url_ as audioFileUrl,
- t.xml_file_url_ as xmlFileUrl,
- t.has_beat_ as hasBeat,
- t.mp3_type_ as mp3Type,
- t.ext_config_json_ as extConfigJson,
- t.create_time_ as createTime,
- t.create_by_ as createBy,
- t.update_time_ as updateTime,
- t.update_by_ as updateBy,
- t.del_flag_ as delFlag,
- t.audit_version_ as auditVersion,
- t.source_type_ as sourceType,
- t.submit_audit_time_ as submitAuditTime,
- t.accompaniment_type_ as accompanimentType,
- t.remark_ as remark,
- t.first_tone_ as firstTone,
- t.fixed_tone_ as fixedTone,
- t.title_img_ as titleImg,
- t.reason_ as reason,
- t.music_img_ as musicImg,
- t.notation_ as notation,
- t.music_json_ as musicJSON,
- t.music_svg_ as musicSvg,
- t.music_jian_svg_ as musicJianSvg,
- t.music_first_svg_ as musicFirstSvg,
- t.music_sheet_type_ as musicSheetType
- </sql>
- <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
- select <include refid="Base_Column_List"/>
- ,su.username_ as addName
- ,su.avatar_ as addUserAvatar
- ,(select group_concat(mt.name_) from music_tag mt
- where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
- ,(select group_concat(s.name_) from subject s
- where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
- from music_sheet t
- left join sys_user su on t.create_by_ = su.id_
- <where>
- su.del_flag_ = 0
- <include refid="QueryInfo"/>
- <if test="param.auditVersion != null ">
- and #{param.auditVersion} = t.audit_version_
- </if>
- <if test="param.dataRecovery != null">
- AND (t.music_svg_ = '' OR t.music_svg_ IS NULL OR t.music_first_svg_ = '' OR t.music_first_svg_ IS NULL OR t.music_jian_svg_ = '' OR t.music_jian_svg_ IS NULL)
- </if>
- <if test="param.notation">
- AND t.notation_ = #{param.notation}
- </if>
- <if test="param.DataCorrect != null">
- AND t.correct_time_ <= '2023-02-07 15:00:00'
- </if>
- </where>
- order by
- <if test="param.myself == null or param.myself == false ">
- t.top_flag_ desc,t.sort_number_ desc,
- </if>
- t.id_ desc
- </select>
- <sql id="QueryInfo">
- <if test="param.musicSheetType != null">
- and t.music_sheet_type_ = #{param.musicSheetType}
- </if>
- <if test="param.idAndName != null and param.idAndName != ''">
- and (t.id_ like concat('%',#{param.idAndName},'%') or
- t.music_sheet_name_ like concat('%',#{param.idAndName},'%') or
- t.composer_ like concat ('%',#{param.idAndName},'%') or
- su.username_ like concat ('%',#{param.idAndName},'%') )
- </if>
- <if test="param.providerType != null">
- and t.provider_type_ = #{param.providerType}
- </if>
- <if test="param.musicTagIds != null and param.musicTagIds != ''">
- and
- <foreach collection="param.musicTagIdList" open="(" close=")" separator="or" item="item">
- find_in_set(#{item},t.music_tag_)
- </foreach>
- </if>
- <if test="param.subjectIdList != null and param.subjectIdList.size() != 0">
- and(
- <foreach collection="param.subjectIdList" separator="or" item="item" open="(" close=")">
- find_in_set(#{item},t.music_subject_)
- </foreach>
- or t.music_subject_ is null or t.music_subject_ = '' or t.music_sheet_type_ = 'CONCERT'
- )
- </if>
- <if test="param.musicSheetIdlist != null and param.musicSheetIdlist.size() != 0">
- and t.id_ in
- <foreach collection="param.musicSheetIdlist" separator="," item="item" open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="param.state != null">
- and t.state_ = #{param.state}
- </if>
- <if test="param.auditStatus != null">
- and t.audit_status_ = #{param.auditStatus}
- </if>
- <if test="param.createBy != null">
- and t.create_by_ = #{param.createBy}
- </if>
- <if test="param.delFlag != null">
- and t.del_flag_ = #{param.delFlag}
- </if>
- <if test="param.sourceType != null">
- and t.source_type_ = #{param.sourceType}
- </if>
- <if test="param.chargeType != null">
- and (FIND_IN_SET(#{param.chargeType}, t.payment_type_))
- </if>
- <if test="param.topFlag != null">
- and t.top_flag_ = #{param.topFlag}
- </if>
- <if test="param.exquisiteFlag != null">
- and t.exquisite_flag_ = #{param.exquisiteFlag}
- </if>
- <if test="param.accompanimentType != null">
- and t.accompaniment_type_ = #{param.accompanimentType}
- </if>
- <if test="param.audioType != null">
- and t.audio_type_ = #{param.audioType}
- </if>
- </sql>
- <select id="selectAlbumDetailPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
- select distinct <include refid="Base_Column_List"/>
- ,su.username_ as addName
- ,su.avatar_ as addUserAvatar
- ,(select group_concat(mt.name_) from music_tag mt
- where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
- ,(select group_concat(s.name_) from subject s
- where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
- ,amr.sort_number_ as albumSortNumber
- from music_sheet t
- left join album_music_relate amr on t.id_ = amr.music_sheet_id_
- left join sys_user su on t.create_by_ = su.id_
- <where>
- <if test="param.composer != null">
- AND t.composer_ LIKE '%${param.composer}%'
- </if>
- <if test="param.providerType != null">
- and t.provider_type_ = #{param.providerType}
- </if>
- <if test="param.idAndName != null and param.idAndName != ''">
- and (t.id_ like concat('%',#{param.idAndName},'%') or
- t.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
- </if>
- <if test="param.chargeType != null">
- and t.charge_type_ = #{param.chargeType}
- </if>
- <if test="param.musicTagIds != null and param.musicTagIds != ''">
- and
- <foreach collection="param.musicTagIdList" separator="or" item="item" open="(" close=")" >
- find_in_set(#{item},t.music_tag_)
- </foreach>
- </if>
- <if test="param.subjectIdList != null and param.subjectIdList.size() != 0">
- and
- <foreach collection="param.subjectIdList" separator="or" item="item" open="(" close=")" >
- find_in_set(#{item},t.music_subject_)
- </foreach>
- </if>
- <if test="param.musicSheetType != null">
- and t.music_sheet_type_ = #{param.musicSheetType}
- </if>
- <if test="param.state != null">
- and t.state_ = #{param.state}
- </if>
- <if test="param.delFlag != null">
- and t.del_flag_ = #{param.delFlag}
- </if>
- <if test="param.sourceType != null">
- AND t.source_type_ = #{param.sourceType}
- </if>
- <if test="param.chargeType != null">
- AND (t.payment_type_ = 'FREE' OR FIND_IN_SET(#{param.chargeType}, t.payment_type_))
- </if>
- <if test="param.paymentTypes != null">
- AND t.payment_type_ IN (<foreach collection="param.paymentTypes" separator="," item="item">#{item}</foreach>)
- </if>
- <if test="param.id != null">
- <if test="param.type == 2">
- and amr.album_id_ = #{param.id}
- order by amr.sort_number_ desc, t.id_ desc
- </if>
- <if test="param.type == 1">
- and t.id_ not in(select amr2.music_sheet_id_ from album_music_relate amr2
- where amr2.album_id_ = #{param.id})
- order by t.id_ desc
- </if>
- </if>
- </where>
- </select>
- <select id="detail" resultMap="DetailResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- ,t.url_ as url
- ,t.midi_url_ as midiUrl
- ,t.metronome_url_ as metronomeUrl
- ,msa.id_ as accompanimentId
- ,msa.music_sheet_id_ as accompanimentMusicSheetId
- ,msa.music_subject_ as accompanimentMusicSubject
- ,msa.audio_file_url_ as accompanimentAudioFileUrl
- ,msa.sort_number_ as accompanimentSortNumber
- ,msa.create_time_ as accompanimentCreateTime
- ,msa.metronome_url_ as accompanimentMetronomeUrl
- ,msa.track_ as track
- ,su.username_ as userName
- ,su.avatar_ as userAvatar
- ,(
- select group_concat(mt.name_) from music_tag mt
- where find_in_set(mt.id_,t.music_tag_)
- and mt.del_flag_ = 0 and mt.state_ = 1
- ) as musicTagNames
- ,s2.name_ as subjectNames
- ,s2.code_ as code
- ,su.real_name_ as realName
- ,s2.ai_default_frequency_ as aiDefaultFrequency
- FROM music_sheet t
- left join music_sheet_accompaniment msa on msa.music_sheet_id_ = t.id_
- left join sys_user su on t.create_by_ = su.id_
- left join subject s2 on t.music_subject_ = s2.id_
- where t.id_ = #{id}
- order by msa.sort_number_
- </select>
- <resultMap id="DetailResultMap" type="com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="musicSheetName" jdbcType="VARCHAR" property="musicSheetName"/>
- <result column="userId" jdbcType="BIGINT" property="userId"/>
- <result column="composer" jdbcType="VARCHAR" property="composer"/>
- <result column="titleImg" jdbcType="VARCHAR" property="titleImg"/>
- <result column="musicSubject" jdbcType="VARCHAR" property="musicSubject"/>
- <result column="audioType" jdbcType="VARCHAR" property="audioType"/>
- <result column="providerType" jdbcType="VARCHAR" property="providerType"/>
- <result column="musicTag" jdbcType="VARCHAR" property="musicTag"/>
- <result column="playSpeed" jdbcType="INTEGER" property="playSpeed"/>
- <result column="canEvaluate" jdbcType="TINYINT" property="canEvaluate"/>
- <result column="showFingering" jdbcType="TINYINT" property="showFingering"/>
- <result column="chargeType" jdbcType="TINYINT" property="chargeType"/>
- <result column="auditStatus" property="auditStatus"/>
- <result column="state" jdbcType="TINYINT" property="state"/>
- <result column="sortNumber" jdbcType="INTEGER" property="sortNumber"/>
- <result column="topFlag" jdbcType="TINYINT" property="topFlag"/>
- <result column="hotFlag" jdbcType="TINYINT" property="hotFlag"/>
- <result column="musicPrice" jdbcType="DECIMAL" property="musicPrice"/>
- <result column="audioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
- <result column="musicTagNames" jdbcType="VARCHAR" property="musicTagNames"/>
- <result column="subjectNames" jdbcType="VARCHAR" property="subjectNames"/>
- <result column="xmlFileUrl" jdbcType="VARCHAR" property="xmlFileUrl"/>
- <result column="hasBeat" jdbcType="TINYINT" property="hasBeat"/>
- <result column="createTime" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="createBy" jdbcType="BIGINT" property="createBy"/>
- <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime"/>
- <result column="updateBy" jdbcType="BIGINT" property="updateBy"/>
- <result column="delFlag" jdbcType="BOOLEAN" property="delFlag"/>
- <result column="url" jdbcType="BOOLEAN" property="url"/>
- <result column="metronomeUrl" jdbcType="BOOLEAN" property="metronomeUrl"/>
- <result column="midiUrl" jdbcType="BOOLEAN" property="midiUrl"/>
- <result column="mp3Type" jdbcType="VARCHAR" property="mp3Type"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <result column="userName" jdbcType="VARCHAR" property="userName"/>
- <result column="auditVersion" jdbcType="VARCHAR" property="auditVersion"/>
- <result column="code" jdbcType="VARCHAR" property="code"/>
- <result column="reason" jdbcType="VARCHAR" property="reason"/>
- <result column="accompanimentType" jdbcType="VARCHAR" property="accompanimentType"/>
- <result column="notation" jdbcType="VARCHAR" property="notation"/>
- <result column="musicImg" jdbcType="VARCHAR" property="musicImg"/>
- <result column="favoriteCount" jdbcType="VARCHAR" property="favoriteCount"/>
- <result column="firstPassAuditTime" jdbcType="VARCHAR" property="firstPassAuditTime"/>
- <result column="realName" jdbcType="VARCHAR" property="realName"/>
- <result column="auditTime" jdbcType="VARCHAR" property="auditTime"/>
- <result column="auditName" jdbcType="VARCHAR" property="auditName"/>
- <result column="auditReason" jdbcType="VARCHAR" property="auditReason"/>
- <result column="aiDefaultFrequency" jdbcType="VARCHAR" property="aiDefaultFrequency"/>
- <result column="musicJSON" jdbcType="VARCHAR" property="musicJSON"/>
- <result column="musicSvg" jdbcType="VARCHAR" property="musicSvg"/>
- <result column="musicJianSvg" jdbcType="VARCHAR" property="musicJianSvg"/>
- <result column="musicFirstSvg" jdbcType="VARCHAR" property="musicFirstSvg"/>
- <result column="musicSheetType" jdbcType="VARCHAR" property="musicSheetType"/>
- <collection property="background" ofType="com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment">
- <id column="accompanimentId" jdbcType="BIGINT" property="id"/>
- <result column="accompanimentMusicSheetId" jdbcType="BIGINT" property="musicSheetId"/>
- <result column="accompanimentMusicSubject" jdbcType="VARCHAR" property="musicSubjectId"/>
- <result column="accompanimentAudioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
- <result column="accompanimentSortNumber" jdbcType="TINYINT" property="sortNumber"/>
- <result column="accompanimentCreateTime" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="accompanimentMetronomeUrl" jdbcType="VARCHAR" property="metronomeUrl"/>
- <result column="track" jdbcType="VARCHAR" property="track"/>
- </collection>
- </resultMap>
- <select id="selectStudentMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
- select <include refid="Base_Column_List"/>
- ,su.username_ as addName
- ,su.avatar_ as addUserAvatar
- from music_sheet t
- left join sys_user su on t.create_by_ = su.id_
- <where>
- su.del_flag_ = 0
- <include refid="QueryInfo"/>
- <if test="param.auditVersion != null ">
- and #{param.auditVersion} = t.audit_version_
- </if>
- </where>
- order by
- <choose>
- <when test="param.musicSortType != null and param.musicSortType.code == 'TOP'">
- t.top_flag_ desc, t.sort_number_ desc,
- </when>
- <when test="param.musicSortType != null and param.musicSortType.code == 'HOT'">
- t.favorite_count_ desc,
- </when>
- <when test="param.musicSortType != null and param.musicSortType.code == 'NEW'">
- t.first_pass_audit_time_ desc,
- </when>
- <otherwise>
- <if test="param.myself == null or param.myself == false ">
- t.top_flag_ desc, t.sort_number_ desc, t.favorite_count_ desc,
- </if>
- </otherwise>
- </choose>
- t.id_ desc
- </select>
- <select id="selectMyMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
- select distinct <include refid="Base_Column_List"/>
- ,su.username_ as addName
- ,su.avatar_ as addUserAvatar
- ,(select group_concat(mt.name_) from music_tag mt
- where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
- ,(select group_concat(s.name_) from subject s
- where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
- ,if(mf.id_ is not null,1,0) as favorite
- from music_sheet t
- left join sys_user su on t.create_by_ = su.id_
- left join music_sheet_purchase_record mspr on mspr.music_sheet_id_ = t.id_
- left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mspr.student_id_ = mf.user_id_
- <where>
- <include refid="QueryInfo"/>
- <if test="param.studentId != null">
- and mspr.student_id_ = #{param.studentId}
- and mspr.order_status_ = 'PAID'
- </if>
- <if test="param.userType != null">
- and mspr.client_type_ = #{param.userType}
- </if>
- <if test="param.purchaseType != null">
- AND mspr.purchase_type_ = #{param.purchaseType}
- </if>
- <if test="param.courseGift != null">
- AND mspr.course_music_album_id_ <choose><when test="param.courseGift == 0"> = </when><otherwise> > </otherwise> </choose> 0
- </if>
- </where>
- order by mspr.id_ desc
- </select>
- <select id="selectFavoriteMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
- select <include refid="Base_Column_List"/>
- ,su.username_ as addName
- ,su.avatar_ as addUserAvatar
- ,(select group_concat(mt.name_) from music_tag mt
- where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
- ,(select group_concat(s.name_) from subject s
- where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
- ,if(mf.id_ is not null,1,0) as favorite
- from music_sheet t
- left join sys_user su on t.create_by_ = su.id_
- left join music_favorite mf on t.id_ = mf.music_sheet_id_
- <where>
- su.del_flag_ = 0
- <include refid="QueryInfo"/>
- <if test="clientType != null">
- AND mf.client_type_ = #{clientType}
- </if>
- <if test="param.studentId != null">
- and mf.user_id_ = #{param.studentId}
- </if>
- </where>
- order by mf.id_ desc
- </select>
- <select id="selectPracticeMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
- select <include refid="Base_Column_List"/>
- ,su.username_ as addName
- ,su.avatar_ as addUserAvatar
- ,(select group_concat(mt.name_) from music_tag mt
- where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
- ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
- ,if(mf.id_ is not null,1,0) as favorite
- from sys_music_compare_record mspr
- left join music_sheet t on mspr.music_sheet_id_ = t.id_
- left join sys_user su on t.create_by_ = su.id_
- left join music_favorite mf on (t.id_ = mf.music_sheet_id_ and mspr.user_id_ = mf.user_id_ <if test="param.clientType != null"> AND mf.client_type_ = #{param.clientType}</if> )
- <where>
- su.del_flag_ = 0
- <include refid="QueryInfo"/>
- <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
- and mspr.id_ in
- <foreach collection="practiceMusicIdList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </where>
- <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
- order by field(mspr.id_,
- <foreach collection="practiceMusicIdList" item="item" separator=",">
- #{item}
- </foreach>
- </if>
- )
- </select>
- <select id="selectStudentOrderPage" resultType="com.yonge.cooleshow.biz.dal.vo.StudentMusicSheetOrderVo">
- select distinct mspr.music_sheet_id_ as musicSheetId
- ,ms.music_sheet_name_ as musicSheetName
- ,ms.composer_ as composer
- ,ms.title_img_ as titleImg
- ,ms.music_tag_ as musicTag
- ,(select group_concat(mt.name_) from music_tag mt
- where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
- ,mspr.purchase_price_ as purchasePrice
- ,mspr.order_no_ as orderNo
- ,mspr.purchase_time_ as purchaseTime
- from music_sheet_purchase_record mspr
- left join music_sheet ms on mspr.music_sheet_id_ = ms.id_
- <where>
- mspr.order_status_ = 'PAID' and mspr.purchase_type_ = 'MUSIC'
- <if test="param.idAndName != null and param.idAndName != ''">
- and (ms.id_ like concat('%',#{param.idAndName} ,'%')
- or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
- </if>
- <if test="param.studentId != null">
- and mspr.student_id_ = #{param.studentId}
- </if>
- <if test="param.orderNo != null and param.orderNo != ''">
- and mspr.order_no_ = #{param.orderNo}
- </if>
- <if test="param.musicTagList != null and param.musicTagList.size() != 0">
- and
- <foreach collection="param.musicTagList" separator="or" item="item" open="(" close=")" >
- find_in_set(#{item},ms.music_tag_)
- </foreach>
- </if>
- <if test="param.startTime != null">
- and mspr.purchase_time_ > #{param.startTime}
- </if>
- <if test="param.endTime != null">
- and mspr.purchase_time_ < #{param.endTime}
- </if>
- </where>
- order by mspr.id_ desc
- </select>
- <select id="selectTeacherPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
- select ms.id_ as musicSheetId
- ,ms.music_sheet_name_ as musicSheetName
- ,ms.composer_ as composer
- ,ms.title_img_ as titleImg
- ,ms.accompaniment_type_ as accompanimentType
- ,ms.music_tag_ as musicTag
- ,(select group_concat(mt.name_) from music_tag mt
- where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
- ,ms.play_speed_ as playSpeed
- ,ms.music_price_ as musicPrice
- ,ms.create_time_ as createTime
- ,ms.audit_status_ as auditStatus
- ,su.username_ as auditName
- from music_sheet ms
- left join music_sheet_auth_record msar on ms.id_ = msar.music_sheet_id_
- left join sys_user su on msar.verify_user_id_ = su.id_
- <where>
- <if test="param.idAndName != null and param.idAndName != ''">
- and (ms.id_ like concat('%',#{param.idAndName} ,'%')
- or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%')
- or ms.composer_ like concat('%',#{param.idAndName},'%'))
- </if>
- <if test="param.teacherId != null">
- and ms.create_by_ = #{param.teacherId} and ms.source_type_ = 'TEACHER'
- </if>
- <if test="param.startTime != null">
- and ms.create_time_ > #{param.startTime}
- </if>
- <if test="param.endTime != null">
- and ms.create_time_ < #{param.endTime}
- </if>
- <if test="param.delFlag != null">
- and ms.del_flag_ = #{param.delFlag}
- </if>
- </where>
- order by ms.id_ desc
- </select>
- <select id="selectAuditPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
- select
- msar.id_ as authMusicSheetId,
- ms.create_by_ as teacherId
- ,ms.exquisite_flag_ as exquisiteFlag
- ,ms.title_img_ as titleImg
- ,ms.accompaniment_type_ as accompanimentType
- ,su.username_ as username
- ,su.real_name_ as realName
- ,su.phone_ as phone
- ,ms.id_ as musicSheetId
- ,ms.music_sheet_name_ as musicSheetName
- ,ms.composer_ as composer
- ,ms.music_tag_ as musicTag
- ,(select group_concat(mt.name_) from music_tag mt
- where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
- ,ms.play_speed_ as playSpeed
- ,ms.music_price_ as musicPrice
- ,ms.update_time_ as createTime
- ,if(msar.audit_state_ is null,ms.audit_status_,msar.audit_state_) as auditStatus
- ,su2.username_ as auditName
- ,msar.first_auth_ as firstAuth
- from music_sheet_auth_record msar
- left join music_sheet ms on ms.id_ = msar.music_sheet_id_
- left join sys_user su on su.id_ = ms.create_by_
- left join sys_user su2 on msar.verify_user_id_ = su2.id_
- <where>
- su.del_flag_ = 0 and
- ms.source_type_ = 'TEACHER'
- <if test="param.idAndName != null and param.idAndName != ''">
- and (su.id_ like concat('%',#{param.idAndName} ,'%')
- or su.username_ like concat('%',#{param.idAndName},'%')
- or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%')
- or su.phone_ like concat('%',#{param.idAndName},'%'))
- </if>
- <if test="param.auditName != null and param.auditName != ''">
- and su2.username_ like concat('%',#{param.auditName},'%')
- </if>
- <if test="param.authStatus != null">
- and msar.audit_state_ = #{param.authStatus}
- </if>
- <if test="param.startTime != null">
- and ms.create_time_ > #{param.startTime}
- </if>
- <if test="param.endTime != null">
- and ms.create_time_ < #{param.endTime}
- </if>
- <if test="param.chargeType != null">
- and ms.charge_type_ = #{param.chargeType}
- </if>
- <if test="param.firstAuth != null">
- and msar.first_auth_ = #{param.firstAuth}
- </if>
- <if test="param.exquisiteFlag != null">
- and ms.exquisite_flag_ = #{param.exquisiteFlag}
- </if>
- </where>
- order by field(ms.audit_status_,'DOING') desc, ms.submit_audit_time_ desc
- </select>
- <select id="selectTeacherMusicSheetCount" resultType="java.lang.Integer">
- select count(1)
- from music_sheet
- where user_id_ = #{userId}
- and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0 and source_type_ = 'TEACHER'
- </select>
- <select id="selectMusicNum" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo">
- select
- sum(if(ms.source_type_ = 'PLATFORM',1,0)) as musicSheetPlatformCount,
- sum(if(ms.source_type_ = 'TEACHER',1,0)) as musicSheetTeacherCount,
- count(1) as musicSheetCount
- from music_sheet ms
- where ms.state_ = 1 and ms.del_flag_ = 0 and ms.audit_status_ = 'PASS' and find_in_set('CHARGE',ms.payment_type_)
- </select>
- <select id="selectPayMusicSheet" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo$MusicSheetSmall">
- SELECT
- ms.id_ as musicSheetId,
- ms.music_sheet_name_ as musicSheetName,
- count(DISTINCT pr.student_id_) as num
- FROM
- music_sheet ms
- LEFT JOIN music_sheet_purchase_record pr ON ms.id_ = pr.music_sheet_id_
- WHERE
- ms.del_flag_=0
- AND ms.charge_type_='CHARGE'
- AND ms.state_=1
- AND pr.order_status_='PAID'
- GROUP BY ms.id_
- ORDER BY count(DISTINCT pr.student_id_) DESC,ms.id_ desc
- limit 5
- </select>
- <select id="selectTeacherCount" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherAuditMusicSheetVo">
- select
- sum(if(t.audit_status_ = 'DOING',1,0)) as doing,
- sum(if(t.audit_status_ = 'PASS'
- and t.state_ = 1,1,0)) as pass,
- sum(if(t.audit_status_ = 'UNPASS',1,0)) as upPass
- from
- music_sheet t
- where t.user_id_ = #{userId}
- </select>
- <select id="queryStudentTotal" resultType="com.yonge.cooleshow.biz.dal.vo.StudentTotalVo">
- select
- t.user_id_ as userId,
- a.musicAlbumNum,
- b.musicSheetNum
- from student t
- left join (
- select
- user_id_, count(1) as musicAlbumNum
- from album_favorite
- <where>
- <if test="null != userId">
- and user_id_ = #{userId}
- </if>
- </where>
- group by user_id_
- ) a on t.user_id_ = a.user_id_
- left join (
- select
- user_id_, count(1) as musicSheetNum
- from music_favorite
- <where>
- <if test="null != userId">
- and user_id_ = #{userId}
- </if>
- </where>
- group by user_id_
- ) b on t.user_id_ = b.user_id_
- <where>
- <if test="null != userId">
- and t.user_id_ = #{userId}
- </if>
- </where>
- </select>
- <select id="queryTeacherTotal" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherTotalVo">
- select
- t.user_id_ as userId,
- a.musicSheetNum as musicSheetNum
- from teacher t
- left join (
- select
- user_id_, count(1) as musicSheetNum
- from music_sheet
- where source_type_ = 'TEACHER' and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0
- <if test="null != userId">
- and user_id_ = #{userId}
- </if>
- group by user_id_
- ) a on t.user_id_ = a.user_id_
- <where>
- <if test="null != userId">
- and t.user_id_ = #{userId}
- </if>
- </where>
- </select>
- <select id="auditDetailList" resultMap="DetailResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- ,t.url_ as url
- ,t.midi_url_ as midiUrl
- ,t.metronome_url_ as metronomeUrl
- ,msa.id_ as accompanimentId
- ,msa.music_sheet_id_ as accompanimentMusicSheetId
- ,msa.music_subject_ as accompanimentMusicSubject
- ,msa.audio_file_url_ as accompanimentAudioFileUrl
- ,msa.sort_number_ as accompanimentSortNumber
- ,msa.create_time_ as accompanimentCreateTime
- ,msa.metronome_url_ as accompanimentMetronomeUrl
- ,msa.track_ as track
- ,su.username_ as userName
- ,su.avatar_ as userAvatar
- ,(
- select group_concat(mt.name_) from music_tag mt
- where find_in_set(mt.id_,t.music_tag_)
- and mt.del_flag_ = 0 and mt.state_ = 1
- ) as musicTagNames
- ,s2.name_ as subjectNames
- ,s2.code_ as code
- ,s2.ai_default_frequency_ as aiDefaultFrequency
- ,su.real_name_ as realName
- ,msar.update_time_ as auditTime
- ,su2.username_ as auditName
- ,msar.reason_ as auditReason
- from music_sheet_auth_record msar
- left join music_sheet t on t.id_ = msar.music_sheet_id_
- left join sys_user su on su.id_ = t.create_by_
- left join sys_user su2 on msar.verify_user_id_ = su2.id_
- left join music_sheet_accompaniment msa on msa.music_sheet_id_ = t.id_
- left join subject s2 on t.music_subject_ = s2.id_
- <where>
- <if test="originalMusicSheetId != null">
- and #{originalMusicSheetId} = msar.original_music_sheet_id_
- </if>
- <if test="authMusicSheetId != null">
- and #{authMusicSheetId} > msar.id_
- </if>
- </where>
- order by msar.id_ desc
- </select>
- <!--单曲专辑数量统计-->
- <select id="selectMusicAlbumStatInfo" resultType="com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper">
- SELECT t1.music_sheet_id_ AS id, COUNT(DISTINCT t1.id_) AS total
- FROM album_music_relate t1 JOIN music_sheet t2 ON (t1.music_sheet_id_ = t2.id_)
- <where>
- <if test="musicIds != null">
- AND t1.music_sheet_id_ IN (<foreach collection="musicIds" separator="," item="item">#{item}</foreach>)
- </if>
- </where>
- GROUP BY t1.music_sheet_id_
- </select>
- <update id="updateFavoriteCount">
- update music_sheet set favorite_count_ =
- <choose>
- <when test="state.code == 0">
- favorite_count_ - 1
- </when>
- <when test="state.code == 1">
- favorite_count_ + 1
- </when>
- <otherwise>
- favorite_count_
- </otherwise>
- </choose>
- where id_ = #{musicSheetId}
- </update>
- <select id="countByUser" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetUploadCountVo">
- select user_id_ userId, count(id_) count
- from music_sheet
- where del_flag_ = false and state_ =1 and source_type_ = 'TEACHER' and user_id_ in
- <foreach collection="userIds" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- group by user_id_
- </select>
- <select id="searchMusic" resultType="java.lang.Long">
- select t.id_ from music_sheet t
- <if test="param.tenantAlbumIds != null and param.tenantAlbumIds.size() != 0">
- left join tenant_album_music tam on t.id_ = tam.music_sheet_id_
- </if>
- <where>
- t.state_=1 and t.audit_version_ = 0 and t.del_flag_ = 0 and t.audit_status_ = 'PASS'
- <if test="param.subjectId != null">
- and ( t.music_subject_ = #{param.subjectId} or t.music_subject_ is null or t.music_subject_ = '' or t.music_sheet_type_ = 'CONCERT')
- </if>
- <if test="param.name != null and param.name != ''">
- and t.music_sheet_name_ like concat('%',#{param.name},'%')
- </if>
- <if test="param.tenantAlbumIds != null and param.tenantAlbumIds.size() != 0">
- and tam.tenant_album_id_ in
- <foreach collection="param.tenantAlbumIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- and tam.del_flag_=0
- and tam.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT')
- </if>
- <if test="param.providerType != null">
- and t.provider_type_ = #{param.providerType}
- </if>
- </where>
- order by t.top_flag_ desc, t.sort_number_ desc, t.favorite_count_ desc
- </select>
- <select id="searchAlbum" resultType="java.lang.Long">
- select id_ from music_album t
- <where>
- t.album_status_=1 and del_flag_=0 and audit_version_ = 0
- <if test="param.subjectId != null">
- and ( t.subject_id_ = #{param.subjectId} or t.subject_id_ is null or t.subject_id_ = '')
- </if>
- <if test="param.name != null and param.name != ''">
- and t.album_name_ like concat('%',#{param.name},'%')
- </if>
- </where>
- order by t.sort_number_ desc
- </select>
- <!--单曲专辑数量统计-->
- </mapper>
|