<?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.SysPaymentConfigDao">
    <resultMap id="SysPaymentConfig" type="com.ym.mec.biz.dal.entity.SysPaymentConfig">
        <!--@Table sys_payment_config-->
        <id column="id_" jdbcType="INTEGER" property="id"/>
        <result column="organ_id_" jdbcType="INTEGER" property="organId"/>
        <result column="type_" jdbcType="INTEGER" property="type"/>
        <result column="organ_name" jdbcType="VARCHAR" property="organName"/>
        <result column="per_scale_" jdbcType="INTEGER" property="perScale"/>
        <result column="com_scale_" jdbcType="INTEGER" property="comScale"/>
        <result column="course_fee_" jdbcType="VARCHAR" property="courseFee"/>
        <result column="instrument_fee_" jdbcType="VARCHAR" property="instrumentFee"/>
        <result column="accessories_fee_" jdbcType="VARCHAR" property="accessoriesFee"/>
        <result column="other_fee_" jdbcType="VARCHAR" property="otherFee"/>
        <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id_, organ_id_,type_, per_scale_, com_scale_, course_fee_, instrument_fee_, accessories_fee_,
        other_fee_, create_time_, update_time_
    </sql>
    <select id="get" parameterType="java.lang.Integer" resultMap="SysPaymentConfig">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from sys_payment_config
        where id_ = #{id,jdbcType=INTEGER}
    </select>
    <delete id="delete" parameterType="java.lang.Integer">
        delete from sys_payment_config
        where id_ = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.SysPaymentConfig"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into sys_payment_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="type != null">
                type_,
            </if>
            <if test="organId != null">
                organ_id_,
            </if>
            <if test="perScale != null">
                per_scale_,
            </if>
            <if test="comScale != null">
                com_scale_,
            </if>
            <if test="courseFee != null">
                course_fee_,
            </if>
            <if test="instrumentFee != null">
                instrument_fee_,
            </if>
            <if test="accessoriesFee != null">
                accessories_fee_,
            </if>
            <if test="otherFee != null">
                other_fee_,
            </if>
            <if test="createTime != null">
                create_time_,
            </if>
            <if test="updateTime != null">
                update_time_,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="type != null">
                #{type,jdbcType=INTEGER},
            </if>
            <if test="organId != null">
                #{organId,jdbcType=INTEGER},
            </if>
            <if test="perScale != null">
                #{perScale,jdbcType=INTEGER},
            </if>
            <if test="comScale != null">
                #{comScale,jdbcType=INTEGER},
            </if>
            <if test="courseFee != null">
                #{courseFee,jdbcType=VARCHAR},
            </if>
            <if test="instrumentFee != null">
                #{instrumentFee,jdbcType=VARCHAR},
            </if>
            <if test="accessoriesFee != null">
                #{accessoriesFee,jdbcType=VARCHAR},
            </if>
            <if test="otherFee != null">
                #{otherFee,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
    <update id="update" parameterType="com.ym.mec.biz.dal.entity.SysPaymentConfig">
        <!--@mbg.generated-->
        update sys_payment_config
        <set>
            <if test="type != null">
                type_ = #{type,jdbcType=INTEGER},
            </if>
            <if test="organId != null">
                organ_id_ = #{organId,jdbcType=INTEGER},
            </if>
            <if test="perScale != null">
                per_scale_ = #{perScale,jdbcType=INTEGER},
            </if>
            <if test="comScale != null">
                com_scale_ = #{comScale,jdbcType=INTEGER},
            </if>
            <if test="courseFee != null">
                course_fee_ = #{courseFee,jdbcType=VARCHAR},
            </if>
            <if test="instrumentFee != null">
                instrument_fee_ = #{instrumentFee,jdbcType=VARCHAR},
            </if>
            <if test="accessoriesFee != null">
                accessories_fee_ = #{accessoriesFee,jdbcType=VARCHAR},
            </if>
            <if test="otherFee != null">
                other_fee_ = #{otherFee,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time_ = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                update_time_ = #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id_ = #{id,jdbcType=INTEGER}
    </update>

    <!-- 全查询 -->
    <select id="findAll" resultMap="SysPaymentConfig">
        SELECT *
        FROM sys_payment_config
        ORDER BY id_
    </select>

    <!-- 分页查询 -->
    <select id="queryPage" resultMap="SysPaymentConfig" parameterType="map">
        SELECT spc.*,o.name_ organ_name FROM sys_payment_config spc LEFT JOIN organization o on spc.organ_id_ = o.id_
        <include refid="global.limit"/>
    </select>

    <!-- 查询当前表的总记录数 -->
    <select id="queryCount" resultType="int">
        SELECT COUNT(*) FROM sys_payment_config
        <include refid="global.limit"/>
    </select>

    <!-- 按分部编号查配置 -->
    <select id="findPaymentConfigByOrganId" resultMap="SysPaymentConfig">
        SELECT * FROM sys_payment_config WHERE organ_id_ = #{organId}
    </select>
</mapper>