<?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.MusicGroupOrganizationCourseSettingsDao">
    <resultMap id="MusicGroupOrganizationCourseSettings"
               type="com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettings">
        <!--@mbg.generated-->
        <!--@Table music_group_organization_course_settings-->
        <id column="id_" property="id"/>
        <result column="name_" property="name"/>
        <result column="organ_id_" property="organId"/>
        <result column="charge_type_id_" property="chargeTypeId"/>
        <result column="total_current_price_" property="totalCurrentPrice"/>
        <result column="total_original_price_" property="totalOriginalPrice"/>
        <result column="create_time_" property="createTime"/>
        <result column="update_time_" property="updateTime"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id_, name_, organ_id_, charge_type_id_, total_current_price_, total_original_price_,
        create_time_, update_time_
    </sql>
    <select id="get" parameterType="java.lang.Integer" resultMap="MusicGroupOrganizationCourseSettings">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from music_group_organization_course_settings
        where id_ = #{id}
    </select>
    <delete id="delete" parameterType="java.lang.Integer">
        <!--@mbg.generated-->
        delete from music_group_organization_course_settings
        where id_ = #{id}
    </delete>
    <insert id="insert" keyColumn="id_" keyProperty="id"
            parameterType="com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettings" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into music_group_organization_course_settings (name_, organ_id_, charge_type_id_, total_current_price_,
        total_original_price_,
        create_time_, update_time_)
        values (#{name}, #{organId}, #{chargeTypeId}, #{totalCurrentPrice}, #{totalOriginalPrice},
        NOW(),NOW())
    </insert>
    <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettings">
        <!--@mbg.generated-->
        update music_group_organization_course_settings
        <set>
            <if test="name != null">
                name_ = #{name},
            </if>
            <if test="organId != null">
                organ_id_ = #{organId},
            </if>
            <if test="chargeTypeId != null">
                charge_type_id_ = #{chargeTypeId},
            </if>
            <if test="totalCurrentPrice != null">
                total_current_price_ = #{totalCurrentPrice},
            </if>
            <if test="totalOriginalPrice != null">
                total_original_price_ = #{totalOriginalPrice},
            </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="MusicGroupOrganizationCourseSettings" parameterType="map">
        SELECT mgocs.* FROM music_group_organization_course_settings mgocs
        <include refid="queryCondition"/>
        <include refid="global.limit"/>
    </select>

    <!-- 查询当前表的总记录数 -->
    <select id="queryCount" resultType="int">
        SELECT COUNT(mgocs.id_) FROM music_group_organization_course_settings mgocs
        <include refid="queryCondition"/>
    </select>

    <sql id="queryCondition">
        <where>
            <if test="organId != null">
                AND mgocs.organ_id_=#{organId}
            </if>
            <if test="chargeTypeId != null">
                AND mgocs.charge_type_id_ = #{chargeTypeId}
            </if>
        </where>
    </sql>

</mapper>