<?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.AclPractitionerSettingMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.customer.AclPractitionerSetting">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="practitioner_id" jdbcType="BIGINT" property="practitionerId" />
    <result column="practitioner_type_id" jdbcType="BIGINT" property="practitionerTypeId" />
    <result column="practitioner_level" jdbcType="BIGINT" property="practitionerLevel" />
    <result column="level_start_date" jdbcType="DATE" property="levelStartDate" />
    <result column="level_end_date" jdbcType="DATE" property="levelEndDate" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <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_type_id, practitioner_level, level_start_date, 
    level_end_date, remark, is_active, 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_practitioner_setting
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ag_acl_practitioner_setting
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AclPractitionerSetting" useGeneratedKeys="true">
    insert into ag_acl_practitioner_setting (practitioner_id, practitioner_type_id, 
      practitioner_level, level_start_date, level_end_date, 
      remark, is_active, created_at, 
      created_by, updated_at, updated_by
      )
    values (#{practitionerId,jdbcType=BIGINT}, #{practitionerTypeId,jdbcType=BIGINT}, 
      #{practitionerLevel,jdbcType=BIGINT}, #{levelStartDate,jdbcType=DATE}, #{levelEndDate,jdbcType=DATE}, 
      #{remark,jdbcType=VARCHAR}, #{isActive,jdbcType=INTEGER}, #{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.AclPractitionerSetting" useGeneratedKeys="true">
    insert into ag_acl_practitioner_setting
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="practitionerId != null">
        practitioner_id,
      </if>
      <if test="practitionerTypeId != null">
        practitioner_type_id,
      </if>
      <if test="practitionerLevel != null">
        practitioner_level,
      </if>
      <if test="levelStartDate != null">
        level_start_date,
      </if>
      <if test="levelEndDate != null">
        level_end_date,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="isActive != null">
        is_active,
      </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="practitionerTypeId != null">
        #{practitionerTypeId,jdbcType=BIGINT},
      </if>
      <if test="practitionerLevel != null">
        #{practitionerLevel,jdbcType=BIGINT},
      </if>
      <if test="levelStartDate != null">
        #{levelStartDate,jdbcType=DATE},
      </if>
      <if test="levelEndDate != null">
        #{levelEndDate,jdbcType=DATE},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="isActive != null">
        #{isActive,jdbcType=INTEGER},
      </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.AclPractitionerSetting">
    update ag_acl_practitioner_setting
    <set>
      <if test="practitionerId != null">
        practitioner_id = #{practitionerId,jdbcType=BIGINT},
      </if>
      <if test="practitionerTypeId != null">
        practitioner_type_id = #{practitionerTypeId,jdbcType=BIGINT},
      </if>
      <if test="practitionerLevel != null">
        practitioner_level = #{practitionerLevel,jdbcType=BIGINT},
      </if>
      <if test="levelStartDate != null">
        level_start_date = #{levelStartDate,jdbcType=DATE},
      </if>
      <if test="levelEndDate != null">
        level_end_date = #{levelEndDate,jdbcType=DATE},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="isActive != null">
        is_active = #{isActive,jdbcType=INTEGER},
      </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.AclPractitionerSetting">
    update ag_acl_practitioner_setting
    set practitioner_id = #{practitionerId,jdbcType=BIGINT},
      practitioner_type_id = #{practitionerTypeId,jdbcType=BIGINT},
      practitioner_level = #{practitionerLevel,jdbcType=BIGINT},
      level_start_date = #{levelStartDate,jdbcType=DATE},
      level_end_date = #{levelEndDate,jdbcType=DATE},
      remark = #{remark,jdbcType=VARCHAR},
      is_active = #{isActive,jdbcType=INTEGER},
      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="findByPractitionerIdList" resultMap="BaseResultMap">
      select
      <include refid="Base_Column_List" />
      from ag_acl_practitioner_setting
      where practitioner_id in
      <foreach collection="practitionerIds" index="index" item="item" open="(" separator="," close=")">
        #{item}
      </foreach>
    </select>
</mapper>