<?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.MusicGroupOrganizationCourseSettingsDetailDao">
    <resultMap id="MusicGroupOrganizationCourseSettingsDetail"
               type="com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettingsDetail">
        <!--@mbg.generated-->
        <!--@Table music_group_organization_course_settings_detail-->
        <id column="id_" property="id"/>
        <result column="music_group_organization_course_settings_id_"
                property="musicGroupOrganizationCourseSettingsId"/>
        <result column="course_type_" property="courseType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="course_total_minuties_" property="courseTotalMinuties"/>
        <result column="unit_price_" property="unitPrice"/>
        <result column="course_original_price_" property="courseOriginalPrice"/>
        <result column="course_current_price_" property="courseCurrentPrice"/>
        <result column="is_student_optional_" property="isStudentOptional"/>
        <result column="create_time_" property="createTime"/>
        <result column="update_time_" property="updateTime"/>
        <result column="tenant_id_" property="tenantId"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id_, music_group_organization_course_settings_id_, course_type_, course_total_minuties_,
        unit_price_, course_original_price_, course_current_price_, is_student_optional_,
        create_time_, update_time_,tenant_id_
    </sql>
    <select id="get" parameterType="java.lang.Integer" resultMap="MusicGroupOrganizationCourseSettingsDetail">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from music_group_organization_course_settings_detail
        where id_ = #{id}
    </select>
    <delete id="delete" parameterType="java.lang.Integer">
        <!--@mbg.generated-->
        delete from music_group_organization_course_settings_detail
        where id_ = #{id}
    </delete>
    <insert id="insert" keyColumn="id_" keyProperty="id"
            parameterType="com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettingsDetail"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into music_group_organization_course_settings_detail (music_group_organization_course_settings_id_,
        course_type_, course_total_minuties_,
        unit_price_, course_original_price_, course_current_price_, is_student_optional_,
        create_time_, update_time_,tenant_id_)
        values (#{musicGroupOrganizationCourseSettingsId}, #{courseType}, #{courseTotalMinuties},
        #{unitPrice}, #{courseOriginalPrice}, #{courseCurrentPrice}, #{isStudentOptional},
        NOW(),NOW(),#{tenantId})
    </insert>
    <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettingsDetail">
        <!--@mbg.generated-->
        update music_group_organization_course_settings_detail
        <set>
            <if test="musicGroupOrganizationCourseSettingsId != null">
                music_group_organization_course_settings_id_ = #{musicGroupOrganizationCourseSettingsId},
            </if>
            <if test="courseType != null">
                course_type_ = #{courseType},
            </if>
            <if test="courseTotalMinuties != null">
                course_total_minuties_ = #{courseTotalMinuties},
            </if>
            <if test="unitPrice != null">
                unit_price_ = #{unitPrice},
            </if>
            <if test="courseOriginalPrice != null">
                course_original_price_ = #{courseOriginalPrice},
            </if>
            <if test="courseCurrentPrice != null">
                course_current_price_ = #{courseCurrentPrice},
            </if>
            <if test="isStudentOptional != null">
                is_student_optional_ = #{isStudentOptional},
            </if>
            <if test="createTime != null">
                create_time_ = #{createTime},
            </if>
            <if test="updateTime != null">
                update_time_ = #{updateTime},
            </if>
        </set>
        where id_ = #{id} and tenant_id_ = #{tenantId}
    </update>

    <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
        insert into music_group_organization_course_settings_detail (music_group_organization_course_settings_id_,
        course_type_, course_total_minuties_,
        unit_price_, course_original_price_, course_current_price_, is_student_optional_,
        create_time_, update_time_,tenant_id_)
        VALUE
        <foreach collection="settingDetails" separator="," item="settingDetail">
            (#{settingDetail.musicGroupOrganizationCourseSettingsId}, #{settingDetail.courseType},
            #{settingDetail.courseTotalMinuties},
            #{settingDetail.unitPrice}, #{settingDetail.courseOriginalPrice}, #{settingDetail.courseCurrentPrice},
            #{settingDetail.isStudentOptional},
            NOW(),NOW(),#{settingDetail.tenantId})
        </foreach>
    </insert>

    <!-- 分页查询 -->
    <select id="queryPage" resultMap="MusicGroupOrganizationCourseSettingsDetail" parameterType="map">
        SELECT * FROM music_group_organization_course_settings_detail where tenant_id_ = #{tenantId} ORDER BY id_
        <include refid="global.limit"/>
    </select>

    <!-- 查询当前表的总记录数 -->
    <select id="queryCount" resultType="int">
        SELECT COUNT(*)
        FROM music_group_organization_course_settings_detail where tenant_id_ = #{tenantId}
    </select>

    <delete id="deleteBySettingId" parameterType="java.lang.Integer">
        DELETE FROM music_group_organization_course_settings_detail WHERE music_group_organization_course_settings_id_ = #{settingId}
    </delete>

    <select id="queryByMusicGroupOrganizationCourseSettingsId" resultMap="MusicGroupOrganizationCourseSettingsDetail">
        SELECT * FROM music_group_organization_course_settings_detail
        where music_group_organization_course_settings_id_ = #{musicGroupOrganizationCourseSettingsId}
    </select>
</mapper>