<?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.TGzEmpContactInfoMapper">

	<resultMap id="tGzEmpContactInfoMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TGzEmpContactInfo">
		<id property="id" column="id"/>
		<result property="empId" column="emp_id"/>
		<result property="emergName" column="emerg_name"/>
		<result property="emergRelation" column="emerg_relation"/>
		<result property="emergAddress" column="emerg_address"/>
		<result property="emergPhone" column="emerg_phone"/>
		<result property="primaryNid" column="primary_nid"/>
		<result property="delFlag" column="del_flag"/>
		<result property="createTime" column="create_time"/>
		<result property="createBy" column="create_by"/>
		<result property="createName" column="create_name"/>
		<result property="updateBy" column="update_by"/>
		<result property="updateTime" column="update_time"/>
	</resultMap>
	<sql id="Base_Column_List">
                a.id,
                a.emp_id,
                a.emerg_name,
                a.emerg_relation,
                a.emerg_address,
                a.emerg_phone,
                a.primary_nid,
                a.del_flag,
                a.create_time,
                a.create_by,
                a.create_name,
                a.update_by,
                a.update_time
    </sql>
	<sql id="tGzEmpContactInfo_where">
		<if test="tGzEmpContactInfo != null">
			<if test="tGzEmpContactInfo.id != null and tGzEmpContactInfo.id.trim() != ''">
				AND a.id = #{tGzEmpContactInfo.id}
			</if>
			<if test="tGzEmpContactInfo.empId != null and tGzEmpContactInfo.empId.trim() != ''">
				AND a.emp_id = #{tGzEmpContactInfo.empId}
			</if>
			<if test="tGzEmpContactInfo.emergName != null and tGzEmpContactInfo.emergName.trim() != ''">
				AND a.emerg_name = #{tGzEmpContactInfo.emergName}
			</if>
			<if test="tGzEmpContactInfo.emergRelation != null and tGzEmpContactInfo.emergRelation.trim() != ''">
				AND a.emerg_relation = #{tGzEmpContactInfo.emergRelation}
			</if>
			<if test="tGzEmpContactInfo.emergAddress != null and tGzEmpContactInfo.emergAddress.trim() != ''">
				AND a.emerg_address = #{tGzEmpContactInfo.emergAddress}
			</if>
			<if test="tGzEmpContactInfo.emergPhone != null and tGzEmpContactInfo.emergPhone.trim() != ''">
				AND a.emerg_phone = #{tGzEmpContactInfo.emergPhone}
			</if>
			<if test="tGzEmpContactInfo.primaryNid != null and tGzEmpContactInfo.primaryNid.trim() != ''">
				AND a.primary_nid = #{tGzEmpContactInfo.primaryNid}
			</if>
			<if test="tGzEmpContactInfo.delFlag != null and tGzEmpContactInfo.delFlag.trim() != ''">
				AND a.del_flag = #{tGzEmpContactInfo.delFlag}
			</if>
			<if test="tGzEmpContactInfo.createTime != null">
				AND a.create_time = #{tGzEmpContactInfo.createTime}
			</if>
			<if test="tGzEmpContactInfo.createBy != null and tGzEmpContactInfo.createBy.trim() != ''">
				AND a.create_by = #{tGzEmpContactInfo.createBy}
			</if>
			<if test="tGzEmpContactInfo.createName != null and tGzEmpContactInfo.createName.trim() != ''">
				AND a.create_name = #{tGzEmpContactInfo.createName}
			</if>
			<if test="tGzEmpContactInfo.updateBy != null and tGzEmpContactInfo.updateBy.trim() != ''">
				AND a.update_by = #{tGzEmpContactInfo.updateBy}
			</if>
			<if test="tGzEmpContactInfo.updateTime != null">
				AND a.update_time = #{tGzEmpContactInfo.updateTime}
			</if>
		</if>
	</sql>
	<!--tGzEmpContactInfo简单分页查询-->
	<select id="getTGzEmpContactInfoPage" resultMap="tGzEmpContactInfoMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_gz_emp_contact_info a
		<where>
			1=1
			<include refid="tGzEmpContactInfo_where"/>
		</where>
	</select>

	<!--获取附属信息——保存到人员档案时使用 只有一个-->
	<select id="getOneByEmpId" resultMap="tGzEmpContactInfoMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_gz_emp_contact_info a
		where a.del_flag = '0' and a.emp_id = #{empId} order by a.create_time desc limit 1
	</select>

	<!-- 删除 -->
	<delete id="deleteByEmpId">
		delete FROM t_gz_emp_contact_info where emp_id = #{empId}
	</delete>

</mapper>
