<?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.salary.AgAclSalaryMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.salary.AgAclSalary">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="practitioner_id" jdbcType="BIGINT" property="practitionerId" />
    <result column="practitioner_code" jdbcType="VARCHAR" property="practitionerCode" />
    <result column="year_month" jdbcType="VARCHAR" property="yearMonth" />
    <result column="salary_type" jdbcType="VARCHAR" property="salaryType" />
    <result column="salary_code" jdbcType="VARCHAR" property="salaryCode" />
    <result column="salary_name" jdbcType="VARCHAR" property="salaryName" />
    <result column="amount" jdbcType="DECIMAL" property="amount" />
    <result column="tax" jdbcType="DECIMAL" property="tax" />
    <result column="after_tax_amount" jdbcType="DECIMAL" property="afterTaxAmount" />
    <result column="life_practitioner_salary_id" jdbcType="BIGINT" property="lifePractitionerSalaryId" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <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">
    id, practitioner_id, practitioner_code, `year_month`, salary_type, salary_code, salary_name, 
    amount, tax, after_tax_amount, life_practitioner_salary_id, is_active, remark, created_at, 
    created_by, updated_at, updated_by
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from ag_acl_salary
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ag_acl_salary
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.salary.AgAclSalary" useGeneratedKeys="true">
    insert into ag_acl_salary (practitioner_id, practitioner_code, 
      `year_month`, salary_type, salary_code, 
      salary_name, amount, tax, 
      after_tax_amount, life_practitioner_salary_id, 
      is_active, remark, created_at, 
      created_by, updated_at, updated_by
      )
    values (#{practitionerId,jdbcType=BIGINT}, #{practitionerCode,jdbcType=VARCHAR}, 
      #{yearMonth,jdbcType=VARCHAR}, #{salaryType,jdbcType=VARCHAR}, #{salaryCode,jdbcType=VARCHAR},
      #{salaryName,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{tax,jdbcType=DECIMAL}, 
      #{afterTaxAmount,jdbcType=DECIMAL}, #{lifePractitionerSalaryId,jdbcType=BIGINT}, 
      #{isActive,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, #{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.salary.AgAclSalary" useGeneratedKeys="true">
    insert into ag_acl_salary
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="practitionerId != null">
        practitioner_id,
      </if>
      <if test="practitionerCode != null">
        practitioner_code,
      </if>
      <if test="yearMonth != null">
        `year_month`,
      </if>
      <if test="salaryType != null">
        salary_type,
      </if>
      <if test="salaryCode != null">
        salary_code,
      </if>
      <if test="salaryName != null">
        salary_name,
      </if>
      <if test="amount != null">
        amount,
      </if>
      <if test="tax != null">
        tax,
      </if>
      <if test="afterTaxAmount != null">
        after_tax_amount,
      </if>
      <if test="lifePractitionerSalaryId != null">
        life_practitioner_salary_id,
      </if>
      <if test="isActive != null">
        is_active,
      </if>
      <if test="remark != null">
        remark,
      </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="practitionerId != null">
        #{practitionerId,jdbcType=BIGINT},
      </if>
      <if test="practitionerCode != null">
        #{practitionerCode,jdbcType=VARCHAR},
      </if>
      <if test="yearMonth != null">
        #{yearMonth,jdbcType=VARCHAR},
      </if>
      <if test="salaryType != null">
        #{salaryType,jdbcType=INTEGER},
      </if>
      <if test="salaryCode != null">
        #{salaryCode,jdbcType=VARCHAR},
      </if>
      <if test="salaryName != null">
        #{salaryName,jdbcType=VARCHAR},
      </if>
      <if test="amount != null">
        #{amount,jdbcType=DECIMAL},
      </if>
      <if test="tax != null">
        #{tax,jdbcType=DECIMAL},
      </if>
      <if test="afterTaxAmount != null">
        #{afterTaxAmount,jdbcType=DECIMAL},
      </if>
      <if test="lifePractitionerSalaryId != null">
        #{lifePractitionerSalaryId,jdbcType=BIGINT},
      </if>
      <if test="isActive != null">
        #{isActive,jdbcType=INTEGER},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </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.salary.AgAclSalary">
    update ag_acl_salary
    <set>
      <if test="practitionerId != null">
        practitioner_id = #{practitionerId,jdbcType=BIGINT},
      </if>
      <if test="practitionerCode != null">
        practitioner_code = #{practitionerCode,jdbcType=VARCHAR},
      </if>
      <if test="yearMonth != null">
        `year_month` = #{yearMonth,jdbcType=VARCHAR},
      </if>
      <if test="salaryType != null">
        salary_type = #{salaryType,jdbcType=VARCHAR},
      </if>
      <if test="salaryCode != null">
        salary_code = #{salaryCode,jdbcType=VARCHAR},
      </if>
      <if test="salaryName != null">
        salary_name = #{salaryName,jdbcType=VARCHAR},
      </if>
      <if test="amount != null">
        amount = #{amount,jdbcType=DECIMAL},
      </if>
      <if test="tax != null">
        tax = #{tax,jdbcType=DECIMAL},
      </if>
      <if test="afterTaxAmount != null">
        after_tax_amount = #{afterTaxAmount,jdbcType=DECIMAL},
      </if>
      <if test="lifePractitionerSalaryId != null">
        life_practitioner_salary_id = #{lifePractitionerSalaryId,jdbcType=BIGINT},
      </if>
      <if test="isActive != null">
        is_active = #{isActive,jdbcType=INTEGER},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </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.salary.AgAclSalary">
    update ag_acl_salary
    set practitioner_id = #{practitionerId,jdbcType=BIGINT},
      practitioner_code = #{practitionerCode,jdbcType=VARCHAR},
      `year_month` = #{yearMonth,jdbcType=VARCHAR},
      salary_type = #{salaryType,jdbcType=VARCHAR},
      salary_code = #{salaryCode,jdbcType=VARCHAR},
      salary_name = #{salaryName,jdbcType=VARCHAR},
      amount = #{amount,jdbcType=DECIMAL},
      tax = #{tax,jdbcType=DECIMAL},
      after_tax_amount = #{afterTaxAmount,jdbcType=DECIMAL},
      life_practitioner_salary_id = #{lifePractitionerSalaryId,jdbcType=BIGINT},
      is_active = #{isActive,jdbcType=INTEGER},
      remark = #{remark,jdbcType=VARCHAR},
      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>

  <select id="queryListByPractitionerId" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select * from  ag_acl_salary
    where practitioner_id = #{practitionerId,jdbcType=BIGINT}
  </select>

  <select id="queryByRecord" parameterType="com.yd.dal.entity.salary.AgAclSalary" resultMap="BaseResultMap">
    select * from  ag_acl_salary
    where 1=1
      <if test="practitionerId != null">
        and practitioner_id = #{practitionerId,jdbcType=BIGINT}
      </if>
      <if test="practitionerCode != null">
        and practitioner_code = #{practitionerCode,jdbcType=VARCHAR}
      </if>
      <if test="yearMonth != null">
        and `year_month` = #{yearMonth,jdbcType=VARCHAR}
      </if>
      <if test="salaryType != null">
        and salary_type = #{salaryType,jdbcType=VARCHAR}
      </if>
      <if test="salaryCode != null">
        and salary_code = #{salaryCode,jdbcType=VARCHAR}
      </if>
      <if test="salaryName != null">
        and salary_name = #{salaryName,jdbcType=VARCHAR}
      </if>
      <if test="amount != null">
        and amount = #{amount,jdbcType=DECIMAL}
      </if>
      <if test="tax != null">
        and tax = #{tax,jdbcType=DECIMAL}
      </if>
      <if test="afterTaxAmount != null">
        and after_tax_amount = #{afterTaxAmount,jdbcType=DECIMAL}
      </if>
      <if test="lifePractitionerSalaryId != null">
        and life_practitioner_salary_id = #{lifePractitionerSalaryId,jdbcType=BIGINT}
      </if>
      <if test="isActive != null">
        and is_active = #{isActive,jdbcType=INTEGER}
      </if>
      <if test="remark != null">
        and remark = #{remark,jdbcType=VARCHAR}
      </if>
      <if test="createdAt != null">
        and created_at = #{createdAt,jdbcType=TIMESTAMP}
      </if>
      <if test="createdBy != null">
        and created_by = #{createdBy,jdbcType=BIGINT}
      </if>
      <if test="updatedAt != null">
        and updated_at = #{updatedAt,jdbcType=TIMESTAMP}
      </if>
      <if test="updatedBy != null">
        and updated_by = #{updatedBy,jdbcType=BIGINT}
      </if>
  </select>
</mapper>