<?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.ChargeTypeSubjectMapperDao">

    <resultMap type="com.ym.mec.biz.dal.entity.ChargeTypeSubjectMapper" id="ChargeTypeSubjectMapper">
        <result column="id_" property="id"/>
        <result column="charge_type_id_" property="chargeTypeId"/>
        <result column="subject_id_" property="subjectId"/>
        <result column="create_time_" property="createTime"/>
        <result column="update_time_" property="updateTime"/>
        <result column="kit_group_purchase_type_" property="kitGroupPurchaseTypeEnum" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
        <result column="deposit_fee_" property="depositFee"/>
        <result column="fee_" property="fee"/>
    </resultMap>

    <!-- 根据主键查询一条记录 -->
    <select id="get" resultMap="ChargeTypeSubjectMapper">
		SELECT * FROM charge_type_subject_mapper WHERE id_ = #{id} 
	</select>

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

    <!-- 向数据库增加一条记录 -->
    <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ChargeTypeSubjectMapper" useGeneratedKeys="true"
            keyColumn="id" keyProperty="id">
        INSERT INTO charge_type_subject_mapper (charge_type_id_,subject_id_,kit_group_purchase_type_,deposit_fee_,fee_,create_time_,update_time_)
        VALUES(#{chargeTypeId},#{subjectId},#{kitGroupPurchaseTypeEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{depositFee},#{fee},now(),now())
    </insert>
    <insert id="batchAdd">
        INSERT INTO charge_type_subject_mapper (charge_type_id_,subject_id_,create_time_,update_time_) VALUES
        <foreach collection="subjectIds" item="item" separator=",">
            (#{chargeTypeId},#{item},now(),now())
        </foreach>
    </insert>

    <!-- 根据主键查询一条记录 -->
    <update id="update" parameterType="com.ym.mec.biz.dal.entity.ChargeTypeSubjectMapper">
        UPDATE charge_type_subject_mapper
        <set>
            <if test="subjectId != null">
                subject_id_ = #{subjectId},
            </if>
            <if test="chargeTypeId != null">
                charge_type_id_ = #{chargeTypeId},
            </if>
            <if test="updateTime != null">
                update_time_ = #{updateTime},
            </if>
        </set>
        WHERE id_ = #{id}
    </update>

    <!-- 根据主键删除一条记录 -->
    <delete id="delete">
		DELETE FROM charge_type_subject_mapper WHERE id_ = #{id} 
	</delete>

    <delete id="deleteByChargeTypeId">
        DELETE FROM charge_type_subject_mapper WHERE charge_type_id_ = #{chargeTypeId}
    </delete>

    <!-- 分页查询 -->
    <select id="queryPage" resultMap="ChargeTypeSubjectMapper" parameterType="map">
        SELECT * FROM charge_type_subject_mapper ORDER BY id_
        <include refid="global.limit"/>
    </select>

    <!-- 查询当前表的总记录数 -->
    <select id="queryCount" resultType="int">
		SELECT COUNT(*) FROM charge_type_subject_mapper
	</select>
</mapper>
