<?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.yd.dal.mapper.meta.MdIncometaxRateMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.meta.MdIncometaxRate">
    <!--@mbg.generated-->
    <!--@Table ag_md_incometax_rate-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="tax_level" jdbcType="INTEGER" property="taxLevel" />
    <result column="taxable_from" jdbcType="DECIMAL" property="taxableFrom" />
    <result column="taxable_to" jdbcType="DECIMAL" property="taxableTo" />
    <result column="tax_rate" jdbcType="INTEGER" property="taxRate" />
    <result column="est_deductable" jdbcType="DECIMAL" property="estDeductable" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
    <result column="created_by" jdbcType="BIGINT" property="createdBy" />
    <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
    <result column="updated_by" jdbcType="BIGINT" property="updatedBy" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, tax_level, taxable_from, taxable_to, tax_rate, est_deductable, created_at, created_by, 
    updated_at, updated_by
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from ag_md_incometax_rate
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from ag_md_incometax_rate
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.meta.MdIncometaxRate" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_md_incometax_rate (tax_level, taxable_from, taxable_to, 
      tax_rate, est_deductable, created_at, 
      created_by, updated_at, updated_by
      )
    values (#{taxLevel,jdbcType=INTEGER}, #{taxableFrom,jdbcType=DECIMAL}, #{taxableTo,jdbcType=DECIMAL}, 
      #{taxRate,jdbcType=INTEGER}, #{estDeductable,jdbcType=DECIMAL}, #{createdAt,jdbcType=TIMESTAMP}, 
      #{createdBy,jdbcType=BIGINT}, #{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.meta.MdIncometaxRate" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_md_incometax_rate
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="taxLevel != null">
        tax_level,
      </if>
      <if test="taxableFrom != null">
        taxable_from,
      </if>
      <if test="taxableTo != null">
        taxable_to,
      </if>
      <if test="taxRate != null">
        tax_rate,
      </if>
      <if test="estDeductable != null">
        est_deductable,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="updatedAt != null">
        updated_at,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="taxLevel != null">
        #{taxLevel,jdbcType=INTEGER},
      </if>
      <if test="taxableFrom != null">
        #{taxableFrom,jdbcType=DECIMAL},
      </if>
      <if test="taxableTo != null">
        #{taxableTo,jdbcType=DECIMAL},
      </if>
      <if test="taxRate != null">
        #{taxRate,jdbcType=INTEGER},
      </if>
      <if test="estDeductable != null">
        #{estDeductable,jdbcType=DECIMAL},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        #{updatedBy,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.meta.MdIncometaxRate">
    <!--@mbg.generated-->
    update ag_md_incometax_rate
    <set>
      <if test="taxLevel != null">
        tax_level = #{taxLevel,jdbcType=INTEGER},
      </if>
      <if test="taxableFrom != null">
        taxable_from = #{taxableFrom,jdbcType=DECIMAL},
      </if>
      <if test="taxableTo != null">
        taxable_to = #{taxableTo,jdbcType=DECIMAL},
      </if>
      <if test="taxRate != null">
        tax_rate = #{taxRate,jdbcType=INTEGER},
      </if>
      <if test="estDeductable != null">
        est_deductable = #{estDeductable,jdbcType=DECIMAL},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=BIGINT},
      </if>
      <if test="updatedAt != null">
        updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy,jdbcType=BIGINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.meta.MdIncometaxRate">
    <!--@mbg.generated-->
    update ag_md_incometax_rate
    set tax_level = #{taxLevel,jdbcType=INTEGER},
      taxable_from = #{taxableFrom,jdbcType=DECIMAL},
      taxable_to = #{taxableTo,jdbcType=DECIMAL},
      tax_rate = #{taxRate,jdbcType=INTEGER},
      est_deductable = #{estDeductable,jdbcType=DECIMAL},
      created_at = #{createdAt,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=BIGINT},
      updated_at = #{updatedAt,jdbcType=TIMESTAMP},
      updated_by = #{updatedBy,jdbcType=BIGINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update ag_md_incometax_rate
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="tax_level = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.taxLevel,jdbcType=INTEGER}
        </foreach>
      </trim>
      <trim prefix="taxable_from = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.taxableFrom,jdbcType=DECIMAL}
        </foreach>
      </trim>
      <trim prefix="taxable_to = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.taxableTo,jdbcType=DECIMAL}
        </foreach>
      </trim>
      <trim prefix="tax_rate = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.taxRate,jdbcType=INTEGER}
        </foreach>
      </trim>
      <trim prefix="est_deductable = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.estDeductable,jdbcType=DECIMAL}
        </foreach>
      </trim>
      <trim prefix="created_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.createdAt,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="created_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.createdBy,jdbcType=BIGINT}
        </foreach>
      </trim>
      <trim prefix="updated_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.updatedAt,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="updated_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when id = #{item.id,jdbcType=BIGINT} then #{item.updatedBy,jdbcType=BIGINT}
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=BIGINT}
    </foreach>
  </update>
  <update id="updateBatchSelective" parameterType="java.util.List">
    <!--@mbg.generated-->
    update ag_md_incometax_rate
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="tax_level = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.taxLevel != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.taxLevel,jdbcType=INTEGER}
          </if>
        </foreach>
      </trim>
      <trim prefix="taxable_from = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.taxableFrom != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.taxableFrom,jdbcType=DECIMAL}
          </if>
        </foreach>
      </trim>
      <trim prefix="taxable_to = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.taxableTo != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.taxableTo,jdbcType=DECIMAL}
          </if>
        </foreach>
      </trim>
      <trim prefix="tax_rate = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.taxRate != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.taxRate,jdbcType=INTEGER}
          </if>
        </foreach>
      </trim>
      <trim prefix="est_deductable = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.estDeductable != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.estDeductable,jdbcType=DECIMAL}
          </if>
        </foreach>
      </trim>
      <trim prefix="created_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.createdAt != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.createdAt,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="created_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.createdBy != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.createdBy,jdbcType=BIGINT}
          </if>
        </foreach>
      </trim>
      <trim prefix="updated_at = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.updatedAt != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.updatedAt,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="updated_by = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.updatedBy != null">
            when id = #{item.id,jdbcType=BIGINT} then #{item.updatedBy,jdbcType=BIGINT}
          </if>
        </foreach>
      </trim>
    </trim>
    where id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.id,jdbcType=BIGINT}
    </foreach>
  </update>
  <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
    <!--@mbg.generated-->
    insert into ag_md_incometax_rate
    (tax_level, taxable_from, taxable_to, tax_rate, est_deductable, created_at, created_by, 
      updated_at, updated_by)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.taxLevel,jdbcType=INTEGER}, #{item.taxableFrom,jdbcType=DECIMAL}, #{item.taxableTo,jdbcType=DECIMAL}, 
        #{item.taxRate,jdbcType=INTEGER}, #{item.estDeductable,jdbcType=DECIMAL}, #{item.createdAt,jdbcType=TIMESTAMP}, 
        #{item.createdBy,jdbcType=BIGINT}, #{item.updatedAt,jdbcType=TIMESTAMP}, #{item.updatedBy,jdbcType=BIGINT}
        )
    </foreach>
  </insert>

  <select id="findAll" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from ag_md_incometax_rate
  </select>
</mapper>