<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~
  ~      Copyright (c) 2018-2025, lengleng All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the yifu4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: lengleng (wangiegie@gmail.com)
  ~
  -->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.yifu.cloud.plus.v1.yifu.archives.mapper.TPreEmpContactInfoMapper">

  <resultMap id="tPreEmpContactInfoMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TPreEmpContactInfo">
    <id property="id" column="ID"/>
    <result property="preMainId" column="PRE_MAIN_ID"/>
    <result property="empId" column="EMP_ID"/>
    <result property="empName" column="EMP_NAME"/>
	<result property="empIdcard" column="EMP_IDCARD"/>
    <result property="relationType" column="RELATION_TYPE"/>
    <result property="address" column="ADDRESS"/>
    <result property="tel" column="TEL"/>
    <result property="createBy" column="CREATE_BY"/>
    <result property="updateBy" column="UPDATE_BY"/>
    <result property="createName" column="CREATE_NAME"/>
    <result property="createTime" column="CREATE_TIME"/>
    <result property="updateTime" column="UPDATE_TIME"/>
	  <result property="oldId" column="OLD_ID"/>

	  <result property="relationProvince" column="RELATION_PROVINCE"/>
	  <result property="relationCity" column="RELATION_CITY"/>
	  <result property="relationTown" column="RELATION_TOWN"/>
  </resultMap>
    <sql id="Base_Column_List">
                a.ID,
                a.PRE_MAIN_ID,
                a.EMP_ID,
                a.EMP_NAME,
                a.EMP_IDCARD,
                a.RELATION_TYPE,
                a.ADDRESS,
                a.TEL,
                a.CREATE_BY,
                a.UPDATE_BY,
                a.CREATE_NAME,
                a.CREATE_TIME,
                a.OLD_ID,
                a.UPDATE_TIME,

                a.RELATION_PROVINCE,
                a.RELATION_CITY,
                a.RELATION_TOWN
    </sql>
    <sql id="tPreEmpContactInfo_where">
        <if test="tPreEmpContactInfo != null">
                    <if test="tPreEmpContactInfo.id != null and tPreEmpContactInfo.id.trim() != ''">
                        AND a.ID = #{tPreEmpContactInfo.id}
                    </if>
                    <if test="tPreEmpContactInfo.preMainId != null and tPreEmpContactInfo.preMainId.trim() != ''">
                        AND a.PRE_MAIN_ID = #{tPreEmpContactInfo.preMainId}
                    </if>
                    <if test="tPreEmpContactInfo.empName != null and tPreEmpContactInfo.empName.trim() != ''">
                        AND a.EMP_NAME = #{tPreEmpContactInfo.empName}
                    </if>
                    <if test="tPreEmpContactInfo.relationType != null and tPreEmpContactInfo.relationType.trim() != ''">
                        AND a.RELATION_TYPE = #{tPreEmpContactInfo.relationType}
                    </if>
                    <if test="tPreEmpContactInfo.address != null and tPreEmpContactInfo.address.trim() != ''">
                        AND a.ADDRESS = #{tPreEmpContactInfo.address}
                    </if>
                    <if test="tPreEmpContactInfo.tel != null and tPreEmpContactInfo.tel.trim() != ''">
                        AND a.TEL = #{tPreEmpContactInfo.tel}
                    </if>
                    <if test="tPreEmpContactInfo.createBy != null and tPreEmpContactInfo.createBy.trim() != ''">
                        AND a.CREATE_BY = #{tPreEmpContactInfo.createBy}
                    </if>
                    <if test="tPreEmpContactInfo.updateBy != null and tPreEmpContactInfo.updateBy.trim() != ''">
                        AND a.UPDATE_BY = #{tPreEmpContactInfo.updateBy}
                    </if>
                    <if test="tPreEmpContactInfo.createName != null and tPreEmpContactInfo.createName.trim() != ''">
                        AND a.CREATE_NAME = #{tPreEmpContactInfo.createName}
                    </if>
                    <if test="tPreEmpContactInfo.createTime != null">
                        AND a.CREATE_TIME = #{tPreEmpContactInfo.createTime}
                    </if>
                    <if test="tPreEmpContactInfo.updateTime != null">
                        AND a.UPDATE_TIME = #{tPreEmpContactInfo.updateTime}
                    </if>
        </if>
    </sql>
    <!--tPreEmpContactInfo简单分页查询-->
    <select id="getTPreEmpContactInfoList" resultMap="tPreEmpContactInfoMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_pre_emp_contact_info a
        where PRE_MAIN_ID = #{preMainId} order by a.create_time desc
		limit 1
    </select>
</mapper>