<?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.AclPractitionerPotentialAssignedsMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.customer.AclPractitionerPotentialAssigneds">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="assigned_practitioner_id" jdbcType="BIGINT" property="assignedPractitionerId" />
    <result column="practitioner_potential_id" jdbcType="BIGINT" property="practitionerPotentialId" />
    <result column="time_to_onboarding" jdbcType="TIMESTAMP" property="timeToOnboarding" />
    <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" />
    <result column="updater_type" jdbcType="INTEGER" property="updaterType" />
    <result column="creator_type" jdbcType="INTEGER" property="creatorType" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
  </resultMap>
  <sql id="Base_Column_List">
    id, assigned_practitioner_id, practitioner_potential_id, time_to_onboarding, is_active, 
    created_at, created_by, updated_at, updated_by, updater_type, creator_type,remark
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from ag_acl_practitioner_potential_assigneds
    where id = #{id,jdbcType=BIGINT}
  </select>
  <select id="findByPotentialIdAndPractitionerId" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from ag_acl_practitioner_potential_assigneds
    where practitioner_potential_id = #{potentialId,jdbcType=BIGINT} and assigned_practitioner_id = #{practitionerId,jdbcType=BIGINT}
  </select>
  <select id="findByPractitionerId" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from ag_acl_practitioner_potential_assigneds
    where assigned_practitioner_id = #{practitionerId,jdbcType=BIGINT}
  </select>
    <select id="findByPractitionerIdAndPotentialIdList" resultMap="BaseResultMap">
      select
      <include refid="Base_Column_List" />
      from ag_acl_practitioner_potential_assigneds
      where assigned_practitioner_id = #{practitionerId,jdbcType=BIGINT}
      and practitioner_potential_id in
      <foreach collection="potentialIdList" index="index" item="item" open="(" separator="," close=")">
        #{item}
      </foreach>
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ag_acl_practitioner_potential_assigneds
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AclPractitionerPotentialAssigneds" useGeneratedKeys="true">
    insert into ag_acl_practitioner_potential_assigneds (assigned_practitioner_id, practitioner_potential_id, 
      time_to_onboarding, is_active, created_at, 
      created_by, updated_at, updated_by, 
      updater_type, creator_type,remark)
    values (#{assignedPractitionerId,jdbcType=BIGINT}, #{practitionerPotentialId,jdbcType=BIGINT}, 
      #{timeToOnboarding,jdbcType=TIMESTAMP}, #{isActive,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP}, 
      #{createdBy,jdbcType=BIGINT}, #{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT}, 
      #{updaterType,jdbcType=INTEGER}, #{creatorType,jdbcType=INTEGER},#{remark,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AclPractitionerPotentialAssigneds" useGeneratedKeys="true">
    insert into ag_acl_practitioner_potential_assigneds
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="assignedPractitionerId != null">
        assigned_practitioner_id,
      </if>
      <if test="practitionerPotentialId != null">
        practitioner_potential_id,
      </if>
      <if test="timeToOnboarding != null">
        time_to_onboarding,
      </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>
      <if test="updaterType != null">
        updater_type,
      </if>
      <if test="creatorType != null">
        creator_type,
      </if>
      <if test="remark != null">
        remark,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="assignedPractitionerId != null">
        #{assignedPractitionerId,jdbcType=BIGINT},
      </if>
      <if test="practitionerPotentialId != null">
        #{practitionerPotentialId,jdbcType=BIGINT},
      </if>
      <if test="timeToOnboarding != null">
        #{timeToOnboarding,jdbcType=TIMESTAMP},
      </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>
      <if test="updaterType != null">
        #{updaterType,jdbcType=INTEGER},
      </if>
      <if test="creatorType != null">
        #{creatorType,jdbcType=INTEGER},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.customer.AclPractitionerPotentialAssigneds">
    update ag_acl_practitioner_potential_assigneds
    <set>
      <if test="assignedPractitionerId != null">
        assigned_practitioner_id = #{assignedPractitionerId,jdbcType=BIGINT},
      </if>
      <if test="practitionerPotentialId != null">
        practitioner_potential_id = #{practitionerPotentialId,jdbcType=BIGINT},
      </if>
      <if test="timeToOnboarding != null">
        time_to_onboarding = #{timeToOnboarding,jdbcType=TIMESTAMP},
      </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>
      <if test="updaterType != null">
        updater_type = #{updaterType,jdbcType=INTEGER},
      </if>
      <if test="creatorType != null">
        creator_type = #{creatorType,jdbcType=INTEGER},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.customer.AclPractitionerPotentialAssigneds">
    update ag_acl_practitioner_potential_assigneds
    set assigned_practitioner_id = #{assignedPractitionerId,jdbcType=BIGINT},
      practitioner_potential_id = #{practitionerPotentialId,jdbcType=BIGINT},
      time_to_onboarding = #{timeToOnboarding,jdbcType=TIMESTAMP},
      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},
      updater_type = #{updaterType,jdbcType=INTEGER},
      creator_type = #{creatorType,jdbcType=INTEGER},
      remark = #{remark,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <insert id="insertList"  parameterType="java.util.List" useGeneratedKeys="true">
    insert into ag_acl_practitioner_potential_assigneds (assigned_practitioner_id, practitioner_potential_id,
                                                         time_to_onboarding, is_active, created_at,
                                                         created_by, updated_at, updated_by,
                                                         updater_type, creator_type,remark)
      values
    <foreach collection="potentialAssignedsList" item="item" index="index" separator=",">
      (
      #{item.assignedPractitionerId},
      #{item.practitionerPotentialId},
      #{item.timeToOnboarding},
      #{item.isActive},
      #{item.createdAt},
      #{item.createdBy},
      #{item.updatedAt},
      #{item.updatedBy},
      #{item.updaterType},
      #{item.creatorType},
      #{item.remark}
      )
    </foreach>
  </insert>

</mapper>