|
@@ -0,0 +1,128 @@
|
|
|
+<?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.ChildrenDayReserveDao">
|
|
|
+ <resultMap id="ChildrenDayReserve" type="com.ym.mec.biz.dal.entity.ChildrenDayReserve">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ <id column="id_" property="id"/>
|
|
|
+ <result column="user_id_" property="userId"/>
|
|
|
+ <result column="organ_id_" property="organId"/>
|
|
|
+ <result column="cooperation_organ_id_" property="cooperationOrganId"/>
|
|
|
+ <result column="music_group_id_" property="musicGroupId"/>
|
|
|
+ <result column="is_reserve_" property="isReserve" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
|
|
|
+ <result column="create_time_" property="createTime"/>
|
|
|
+ <result column="update_time_" property="updateTime"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <select id="get" parameterType="java.lang.Integer" resultMap="ChildrenDayReserve">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ select *
|
|
|
+ from children_day_reserve
|
|
|
+ where id_ = #{id}
|
|
|
+ </select>
|
|
|
+ <delete id="delete" parameterType="java.lang.Integer">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ delete from children_day_reserve
|
|
|
+ where id_ = #{id}
|
|
|
+ </delete>
|
|
|
+ <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.ChildrenDayReserve"
|
|
|
+ useGeneratedKeys="true">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ insert into children_day_reserve (user_id_, organ_id_, cooperation_organ_id_, music_group_id_, is_reserve_,
|
|
|
+ create_time_, update_time_)
|
|
|
+ values (#{userId}, #{organId}, #{cooperationOrganId}, #{musicGroupId},
|
|
|
+ #{isReserve,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},NOW(), NOW())
|
|
|
+ </insert>
|
|
|
+ <update id="update" parameterType="com.ym.mec.biz.dal.entity.ChildrenDayReserve">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ update children_day_reserve
|
|
|
+ <set>
|
|
|
+ <if test="userId != null">
|
|
|
+ user_id_ = #{userId},
|
|
|
+ </if>
|
|
|
+ <if test="organId != null">
|
|
|
+ organ_id_ = #{organId},
|
|
|
+ </if>
|
|
|
+ <if test="cooperationOrganId != null">
|
|
|
+ cooperation_organ_id_ = #{cooperationOrganId},
|
|
|
+ </if>
|
|
|
+ <if test="musicGroupId != null">
|
|
|
+ music_group_id_ = #{musicGroupId},
|
|
|
+ </if>
|
|
|
+ <if test="isReserve != null">
|
|
|
+ is_reserve_ = #{isReserve,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
|
|
|
+ </if>
|
|
|
+ <if test="createTime != null">
|
|
|
+ create_time_ = #{createTime},
|
|
|
+ </if>
|
|
|
+ <if test="updateTime != null">
|
|
|
+ update_time_ = #{updateTime},
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ where id_ = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <!-- 分页查询 -->
|
|
|
+ <select id="queryPage" resultMap="ChildrenDayReserve" parameterType="map">
|
|
|
+ SELECT * FROM children_day_reserve
|
|
|
+ <include refid="global.limit"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询当前表的总记录数 -->
|
|
|
+ <select id="queryCount" resultType="int">
|
|
|
+ SELECT COUNT(*)
|
|
|
+ FROM children_day_reserve
|
|
|
+ </select>
|
|
|
+ <resultMap id="ChildrenStatisticsDtoMap" type="com.ym.mec.biz.dal.dto.ChildrenStatisticsDto">
|
|
|
+ <result property="buyMusicTheoryAmount" column="buy_music_theory_amount_"/>
|
|
|
+ <result property="buyMusicTheoryNum" column="buy_music_theory_num_"/>
|
|
|
+ <result property="buyVipAmount" column="buy_vip_amount_"/>
|
|
|
+ <result property="buyVipNum" column="buy_vip_num_"/>
|
|
|
+ <result property="cooperationOrganName" column="cooperation_organ_name_"/>
|
|
|
+ <result property="instrumentalMusicNum" column="instrumental_music_num_"/>
|
|
|
+ <result property="musicGroupName" column="music_group_name_"/>
|
|
|
+ <result property="musicTheoryNum" column="music_theory_num_"/>
|
|
|
+ <result property="noReserveNum" column="no_reserve_num_"/>
|
|
|
+ <result property="normalNum" column="normal_num_"/>
|
|
|
+ <result property="organName" column="organ_name_"/>
|
|
|
+ <result property="reserveNum" column="reserve_num_"/>
|
|
|
+ </resultMap>
|
|
|
+ <select id="queryChildrenStatistics" resultMap="ChildrenStatisticsDtoMap">
|
|
|
+ SELECT o.name_ organ_name_,co.name_ cooperation_organ_name_,mg.name_ music_group_name_,COUNT(sr.user_id_)
|
|
|
+ normal_num_,
|
|
|
+ COUNT(CASE WHEN cdr.is_reserve_ = 1 THEN 1 ELSE NULL END) 'reserve_num_',
|
|
|
+ COUNT(CASE WHEN cdr.is_reserve_ = 0 THEN 1 ELSE NULL END) 'no_reserve_num_'
|
|
|
+ FROM children_day_reserve cdr
|
|
|
+ LEFT JOIN music_group mg ON mg.id_ = cdr.music_group_id_
|
|
|
+ LEFT JOIN student_registration sr ON sr.music_group_id_ = cdr.music_group_id_ AND sr.music_group_status_ =
|
|
|
+ 'NORMAL'
|
|
|
+ LEFT JOIN cooperation_organ co ON co.id_ = cdr.cooperation_organ_id_
|
|
|
+ LEFT JOIN organization o ON o.id_ = cdr.organ_id_
|
|
|
+ <include refid="queryChildrenStatisticsSql"/>
|
|
|
+ GROUP BY cdr.music_group_id_
|
|
|
+ </select>
|
|
|
+ <select id="countChildrenStatistics" resultType="java.lang.Integer">
|
|
|
+ SELECT COUNT(cdr.id_)
|
|
|
+ FROM children_day_reserve cdr
|
|
|
+ <include refid="queryChildrenStatisticsSql"/>
|
|
|
+ GROUP BY cdr.music_group_id_
|
|
|
+ </select>
|
|
|
+ <sql id="queryChildrenStatisticsSql">
|
|
|
+ <where>
|
|
|
+ <if test="cooperationId != null">
|
|
|
+ AND cdr.cooperation_organ_id_ = #{cooperationId}
|
|
|
+ </if>
|
|
|
+ <if test="musicGroupId != null and musicGroupId != ''">
|
|
|
+ AND cdr.music_group_id_ = #{musicGroupId}
|
|
|
+ </if>
|
|
|
+ <if test="organId != null">
|
|
|
+ AND FIND_IN_SET(cdr.organ_id_,#{organId})
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="getByUserId" resultMap="ChildrenDayReserve">
|
|
|
+ SELECT *
|
|
|
+ FROM children_day_reserve
|
|
|
+ WHERE user_id_ = #{userId}
|
|
|
+ </select>
|
|
|
+</mapper>
|