<?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.AclPractitionerPotentialMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.customer.AclPractitionerPotential">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="age" jdbcType="BIGINT" property="age" />
    <result column="customer_id" jdbcType="BIGINT" property="customerId" />
    <result column="gender" jdbcType="INTEGER" property="gender" />
    <result column="mobile_no" jdbcType="VARCHAR" property="mobileNo" />
    <result column="wechat_id" jdbcType="VARCHAR" property="wechatId" />
    <result column="qq_id" jdbcType="VARCHAR" property="qqId" />
    <result column="others_contacts" jdbcType="VARCHAR" property="othersContacts" />
    <result column="education_level" jdbcType="VARCHAR" property="educationLevel" />
    <result column="introducer" jdbcType="VARCHAR" property="introducer" />
    <result column="tag" jdbcType="VARCHAR" property="tag" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="resource_drop_master_id" jdbcType="BIGINT" property="resourceDropMasterId" />
    <result column="oss_path_resume" jdbcType="VARCHAR" property="ossPathResume" />
    <result column="practitioner_assigned_ids" jdbcType="VARCHAR" property="practitionerAssignedIds" />
    <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="creator_type" jdbcType="BIGINT" property="creatorType" />
    <result column="updater_type" jdbcType="BIGINT" property="updaterType" />
  </resultMap>
  <sql id="Base_Column_List">
    id, customer_id,`name`, age, gender, mobile_no, wechat_id, qq_id, others_contacts, education_level,
    introducer, tag, remark, resource_drop_master_id, oss_path_resume, practitioner_assigned_ids,
    is_active, created_at, created_by, updated_at, updated_by,creator_type,updater_type
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from ag_acl_practitioner_potential
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ag_acl_practitioner_potential
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AclPractitionerPotential" useGeneratedKeys="true">
    insert into ag_acl_practitioner_potential (`name`,customer_id, age, gender,
      mobile_no, wechat_id, qq_id, 
      others_contacts, education_level, introducer, 
      tag, remark, resource_drop_master_id, 
      oss_path_resume, practitioner_assigned_ids, is_active,
      created_at, created_by, updated_at, 
      updated_by,updater_type,creator_type)
    values (#{name,jdbcType=VARCHAR},#{customerId,jdbcType=BIGINT}, #{age,jdbcType=BIGINT}, #{gender,jdbcType=INTEGER},
      #{mobileNo,jdbcType=VARCHAR}, #{wechatId,jdbcType=VARCHAR}, #{qqId,jdbcType=VARCHAR}, 
      #{othersContacts,jdbcType=VARCHAR}, #{educationLevel,jdbcType=VARCHAR}, #{introducer,jdbcType=VARCHAR}, 
      #{tag,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{resourceDropMasterId,jdbcType=BIGINT}, 
      #{ossPathResume,jdbcType=VARCHAR}, #{practitionerAssignedIds,jdbcType=VARCHAR}, #{isActive,jdbcType=INTEGER},
      #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, #{updatedAt,jdbcType=TIMESTAMP}, 
      #{updatedBy,jdbcType=BIGINT},#{updaterType,jdbcType=INTEGER},#{creatorType,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.customer.AclPractitionerPotential" useGeneratedKeys="true">
    insert into ag_acl_practitioner_potential
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="name != null">
        `name`,
      </if>
      <if test="age != null">
        age,
      </if>
      <if test="gender != null">
        gender,
      </if>
      <if test="mobileNo != null">
        mobile_no,
      </if>
      <if test="wechatId != null">
        wechat_id,
      </if>
      <if test="qqId != null">
        qq_id,
      </if>
      <if test="othersContacts != null">
        others_contacts,
      </if>
      <if test="educationLevel != null">
        education_level,
      </if>
      <if test="introducer != null">
        introducer,
      </if>
      <if test="tag != null">
        tag,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="resourceDropMasterId != null">
        resource_drop_master_id,
      </if>
      <if test="ossPathResume != null">
        oss_path_resume,
      </if>
      <if test="practitionerAssignedIds != null">
        practitioner_assigned_ids,
      </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="creatorType != null">
        creator_type,
      </if>
      <if test="updaterType != null">
        updater_type,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="age != null">
        #{age,jdbcType=BIGINT},
      </if>
      <if test="gender != null">
        #{gender,jdbcType=INTEGER},
      </if>
      <if test="mobileNo != null">
        #{mobileNo,jdbcType=VARCHAR},
      </if>
      <if test="wechatId != null">
        #{wechatId,jdbcType=VARCHAR},
      </if>
      <if test="qqId != null">
        #{qqId,jdbcType=VARCHAR},
      </if>
      <if test="othersContacts != null">
        #{othersContacts,jdbcType=VARCHAR},
      </if>
      <if test="educationLevel != null">
        #{educationLevel,jdbcType=VARCHAR},
      </if>
      <if test="introducer != null">
        #{introducer,jdbcType=VARCHAR},
      </if>
      <if test="tag != null">
        #{tag,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="resourceDropMasterId != null">
        #{resourceDropMasterId,jdbcType=BIGINT},
      </if>
      <if test="ossPathResume != null">
        #{ossPathResume,jdbcType=VARCHAR},
      </if>
      <if test="practitionerAssignedIds != null">
        #{practitionerAssignedIds,jdbcType=BIGINT},
      </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="creatorType != null">
        #{creatorType,jdbcType=INTEGER},
      </if>
      <if test="updaterType != null">
        #{updaterType,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.customer.AclPractitionerPotential">
    update ag_acl_practitioner_potential
    <set>
      <if test="name != null">
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="age != null">
        age = #{age,jdbcType=BIGINT},
      </if>
      <if test="gender != null">
        gender = #{gender,jdbcType=INTEGER},
      </if>
      <if test="mobileNo != null">
        mobile_no = #{mobileNo,jdbcType=VARCHAR},
      </if>
      <if test="wechatId != null">
        wechat_id = #{wechatId,jdbcType=VARCHAR},
      </if>
      <if test="qqId != null">
        qq_id = #{qqId,jdbcType=VARCHAR},
      </if>
      <if test="othersContacts != null">
        others_contacts = #{othersContacts,jdbcType=VARCHAR},
      </if>
      <if test="educationLevel != null">
        education_level = #{educationLevel,jdbcType=VARCHAR},
      </if>
      <if test="introducer != null">
        introducer = #{introducer,jdbcType=VARCHAR},
      </if>
      <if test="tag != null">
        tag = #{tag,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="resourceDropMasterId != null">
        resource_drop_master_id = #{resourceDropMasterId,jdbcType=BIGINT},
      </if>
      <if test="ossPathResume != null">
        oss_path_resume = #{ossPathResume,jdbcType=VARCHAR},
      </if>
      <if test="practitionerAssignedIds != null">
        practitioner_assigned_ids = #{practitionerAssignedIds,jdbcType=BIGINT},
      </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="creatorType != null">
        creator_type = #{creatorType,jdbcType=INTEGER},
      </if>
      <if test="updaterType != null">
        updater_type = #{updaterType,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.customer.AclPractitionerPotential">
    update ag_acl_practitioner_potential
    set `name` = #{name,jdbcType=VARCHAR},
      age = #{age,jdbcType=BIGINT},
      gender = #{gender,jdbcType=INTEGER},
      mobile_no = #{mobileNo,jdbcType=VARCHAR},
      wechat_id = #{wechatId,jdbcType=VARCHAR},
      qq_id = #{qqId,jdbcType=VARCHAR},
      others_contacts = #{othersContacts,jdbcType=VARCHAR},
      education_level = #{educationLevel,jdbcType=VARCHAR},
      introducer = #{introducer,jdbcType=VARCHAR},
      tag = #{tag,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      resource_drop_master_id = #{resourceDropMasterId,jdbcType=BIGINT},
      oss_path_resume = #{ossPathResume,jdbcType=VARCHAR},
      practitioner_assigned_ids = #{practitionerAssignedIds,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},
      creator_type = #{creatorType,jdbcType=INTEGER},
      updater_type = #{updaterType,jdbcType=INTEGER}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <select id="findByMobileNo" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from ag_acl_practitioner_potential
    where mobile_no = #{mobileNo,jdbcType=VARCHAR}
    and is_active = #{isActive,jdbcType=INTEGER}
  </select>
    <select id="findByPractitionerIdAndLasted"
            resultType="com.yd.api.practitioner.vo.recruit.PractitionerPotentialInfo">
      SELECT
        p.id potentialId,
        p.`name` NAME,
        p.gender gender,
        p.age age,
        p.mobile_no mobileNo,
        p.wechat_id wechatId,
        p.qq_id qqId,
        p.others_contacts othersContacts,
        p.education_level educationLevel,
        p.resource_drop_master_id resourceDropMasterId,
        p.introducer introducer,
        p.tag tag,
        p.remark remark,
        p.oss_path_resume ossPathResume,
        t.track_status_id trackStatusId,
        t.id trackId,
        t.created_at updateAt,
        date_format(p.created_at,'%Y-%m-%d') createdAt,
        h.id hiringBasicInfoId
      FROM
        ag_acl_practitioner_potential p
          INNER JOIN ag_acl_practitioner_potential_assigned_track t ON p.id = t.practitioner_potential_id
          LEFT JOIN ag_acl_practitioner_hiring_basic_info h ON p.id = h.practitioner_potential_id
      WHERE
        t.practitioner_assigned_id = #{practitionerId,jdbcType=BIGINT}
      order by p.id desc;
    </select>
</mapper>