<?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.customer.AgAclChannelDao">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.customer.AgAclChannel">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="customer_id" jdbcType="BIGINT" property="customerId" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="name_en" jdbcType="VARCHAR" property="nameEn" />
    <result column="effective_start_date" jdbcType="DATE" property="effectiveStartDate" />
    <result column="effective_end_date" jdbcType="DATE" property="effectiveEndDate" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <result column="referral_rate" jdbcType="DECIMAL" property="referralRate" />
    <result column="contact_name" jdbcType="VARCHAR" property="contactName" />
    <result column="contact_no" jdbcType="VARCHAR" property="contactNo" />
    <result column="contact_email" jdbcType="VARCHAR" property="contactEmail" />
    <result column="contact_address" jdbcType="VARCHAR" property="contactAddress" />
    <result column="tax_no" jdbcType="VARCHAR" property="taxNo" />
    <result column="grant_plans" jdbcType="VARCHAR" property="grantPlans" />
    <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, customer_id, code, `name`, name_en, effective_start_date, effective_end_date, 
    is_active, referral_rate, contact_name, contact_no, contact_email, contact_address, 
    tax_no, grant_plans, 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_channel
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ag_acl_channel
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AgAclChannel" useGeneratedKeys="true">
    insert into ag_acl_channel (customer_id, code, `name`, 
      name_en, effective_start_date, effective_end_date, 
      is_active, referral_rate, contact_name, 
      contact_no, contact_email, contact_address, 
      tax_no, grant_plans, created_at, 
      created_by, updated_at, updated_by
      )
    values (#{customerId,jdbcType=BIGINT}, #{code,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, 
      #{nameEn,jdbcType=VARCHAR}, #{effectiveStartDate,jdbcType=DATE}, #{effectiveEndDate,jdbcType=DATE}, 
      #{isActive,jdbcType=INTEGER}, #{referralRate,jdbcType=DECIMAL}, #{contactName,jdbcType=VARCHAR}, 
      #{contactNo,jdbcType=VARCHAR}, #{contactEmail,jdbcType=VARCHAR}, #{contactAddress,jdbcType=VARCHAR}, 
      #{taxNo,jdbcType=VARCHAR}, #{grantPlans,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.customer.AgAclChannel" useGeneratedKeys="true">
    insert into ag_acl_channel
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="customerId != null">
        customer_id,
      </if>
      <if test="code != null">
        code,
      </if>
      <if test="name != null">
        `name`,
      </if>
      <if test="nameEn != null">
        name_en,
      </if>
      <if test="effectiveStartDate != null">
        effective_start_date,
      </if>
      <if test="effectiveEndDate != null">
        effective_end_date,
      </if>
      <if test="isActive != null">
        is_active,
      </if>
      <if test="referralRate != null">
        referral_rate,
      </if>
      <if test="contactName != null">
        contact_name,
      </if>
      <if test="contactNo != null">
        contact_no,
      </if>
      <if test="contactEmail != null">
        contact_email,
      </if>
      <if test="contactAddress != null">
        contact_address,
      </if>
      <if test="taxNo != null">
        tax_no,
      </if>
      <if test="grantPlans != null">
        grant_plans,
      </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="customerId != null">
        #{customerId,jdbcType=BIGINT},
      </if>
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="nameEn != null">
        #{nameEn,jdbcType=VARCHAR},
      </if>
      <if test="effectiveStartDate != null">
        #{effectiveStartDate,jdbcType=DATE},
      </if>
      <if test="effectiveEndDate != null">
        #{effectiveEndDate,jdbcType=DATE},
      </if>
      <if test="isActive != null">
        #{isActive,jdbcType=INTEGER},
      </if>
      <if test="referralRate != null">
        #{referralRate,jdbcType=DECIMAL},
      </if>
      <if test="contactName != null">
        #{contactName,jdbcType=VARCHAR},
      </if>
      <if test="contactNo != null">
        #{contactNo,jdbcType=VARCHAR},
      </if>
      <if test="contactEmail != null">
        #{contactEmail,jdbcType=VARCHAR},
      </if>
      <if test="contactAddress != null">
        #{contactAddress,jdbcType=VARCHAR},
      </if>
      <if test="taxNo != null">
        #{taxNo,jdbcType=VARCHAR},
      </if>
      <if test="grantPlans != null">
        #{grantPlans,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.customer.AgAclChannel">
    update ag_acl_channel
    <set>
      <if test="customerId != null">
        customer_id = #{customerId,jdbcType=BIGINT},
      </if>
      <if test="code != null">
        code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="nameEn != null">
        name_en = #{nameEn,jdbcType=VARCHAR},
      </if>
      <if test="effectiveStartDate != null">
        effective_start_date = #{effectiveStartDate,jdbcType=DATE},
      </if>
      <if test="effectiveEndDate != null">
        effective_end_date = #{effectiveEndDate,jdbcType=DATE},
      </if>
      <if test="isActive != null">
        is_active = #{isActive,jdbcType=INTEGER},
      </if>
      <if test="referralRate != null">
        referral_rate = #{referralRate,jdbcType=DECIMAL},
      </if>
      <if test="contactName != null">
        contact_name = #{contactName,jdbcType=VARCHAR},
      </if>
      <if test="contactNo != null">
        contact_no = #{contactNo,jdbcType=VARCHAR},
      </if>
      <if test="contactEmail != null">
        contact_email = #{contactEmail,jdbcType=VARCHAR},
      </if>
      <if test="contactAddress != null">
        contact_address = #{contactAddress,jdbcType=VARCHAR},
      </if>
      <if test="taxNo != null">
        tax_no = #{taxNo,jdbcType=VARCHAR},
      </if>
      <if test="grantPlans != null">
        grant_plans = #{grantPlans,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.customer.AgAclChannel">
    update ag_acl_channel
    set customer_id = #{customerId,jdbcType=BIGINT},
      code = #{code,jdbcType=VARCHAR},
      `name` = #{name,jdbcType=VARCHAR},
      name_en = #{nameEn,jdbcType=VARCHAR},
      effective_start_date = #{effectiveStartDate,jdbcType=DATE},
      effective_end_date = #{effectiveEndDate,jdbcType=DATE},
      is_active = #{isActive,jdbcType=INTEGER},
      referral_rate = #{referralRate,jdbcType=DECIMAL},
      contact_name = #{contactName,jdbcType=VARCHAR},
      contact_no = #{contactNo,jdbcType=VARCHAR},
      contact_email = #{contactEmail,jdbcType=VARCHAR},
      contact_address = #{contactAddress,jdbcType=VARCHAR},
      tax_no = #{taxNo,jdbcType=VARCHAR},
      grant_plans = #{grantPlans,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>
</mapper>