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

	<resultMap id="tGzEmpFamilyMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TGzEmpFamily">
		<id property="id" column="id"/>
		<result property="empId" column="emp_id"/>
		<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"/>
		<result property="familyRelation" column="family_relation"/>
		<result property="familyName" column="family_name"/>
		<result property="familyPhone" column="family_phone"/>
		<result property="familyAddress" column="family_address"/>
		<result property="familyCompany" column="family_company"/>
		<result property="gzEmeFlag" column="gz_eme_flag"/>
		<result property="jobCode" column="job_code"/>
	</resultMap>
	<sql id="Base_Column_List">
                a.id,
                a.emp_id,
                a.del_flag,
                a.create_time,
                a.create_by,
                a.create_name,
                a.update_by,
                a.update_time,
                a.family_relation,
                a.family_name,
                a.family_phone,
                a.family_address,
                a.family_company,
                a.gz_eme_flag,
                a.job_code
    </sql>
	<sql id="tGzEmpFamily_where">
		<if test="tGzEmpFamily != null">
			<if test="tGzEmpFamily.id != null and tGzEmpFamily.id.trim() != ''">
				AND a.id = #{tGzEmpFamily.id}
			</if>
			<if test="tGzEmpFamily.empId != null and tGzEmpFamily.empId.trim() != ''">
				AND a.emp_id = #{tGzEmpFamily.empId}
			</if>
			<if test="tGzEmpFamily.delFlag != null and tGzEmpFamily.delFlag.trim() != ''">
				AND a.del_flag = #{tGzEmpFamily.delFlag}
			</if>
			<if test="tGzEmpFamily.createTime != null">
				AND a.create_time = #{tGzEmpFamily.createTime}
			</if>
			<if test="tGzEmpFamily.createBy != null and tGzEmpFamily.createBy.trim() != ''">
				AND a.create_by = #{tGzEmpFamily.createBy}
			</if>
			<if test="tGzEmpFamily.createName != null and tGzEmpFamily.createName.trim() != ''">
				AND a.create_name = #{tGzEmpFamily.createName}
			</if>
			<if test="tGzEmpFamily.updateBy != null and tGzEmpFamily.updateBy.trim() != ''">
				AND a.update_by = #{tGzEmpFamily.updateBy}
			</if>
			<if test="tGzEmpFamily.updateTime != null">
				AND a.update_time = #{tGzEmpFamily.updateTime}
			</if>
			<if test="tGzEmpFamily.familyRelation != null and tGzEmpFamily.familyRelation.trim() != ''">
				AND a.family_relation = #{tGzEmpFamily.familyRelation}
			</if>
			<if test="tGzEmpFamily.familyName != null and tGzEmpFamily.familyName.trim() != ''">
				AND a.family_name = #{tGzEmpFamily.familyName}
			</if>
			<if test="tGzEmpFamily.familyPhone != null and tGzEmpFamily.familyPhone.trim() != ''">
				AND a.family_phone = #{tGzEmpFamily.familyPhone}
			</if>
			<if test="tGzEmpFamily.familyAddress != null and tGzEmpFamily.familyAddress.trim() != ''">
				AND a.family_address = #{tGzEmpFamily.familyAddress}
			</if>
			<if test="tGzEmpFamily.familyCompany != null and tGzEmpFamily.familyCompany.trim() != ''">
				AND a.family_company = #{tGzEmpFamily.familyCompany}
			</if>
			<if test="tGzEmpFamily.gzEmeFlag != null and tGzEmpFamily.gzEmeFlag.trim() != ''">
				AND a.gz_eme_flag = #{tGzEmpFamily.gzEmeFlag}
			</if>
			<if test="tGzEmpFamily.jobCode != null and tGzEmpFamily.jobCode.trim() != ''">
				AND a.job_code = #{tGzEmpFamily.jobCode}
			</if>
		</if>
	</sql>
	<!--tGzEmpFamily简单分页查询-->
	<select id="getTGzEmpFamilyPage" resultMap="tGzEmpFamilyMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_gz_emp_family a
		<where>
			1=1
			<include refid="tGzEmpFamily_where"/>
		</where>
	</select>

	<!--获取附属信息——保存到人员档案时使用-->
	<select id="getListByEmpId" resultMap="tGzEmpFamilyMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_gz_emp_family a
		where a.del_flag = '0' and a.emp_id = #{empId}
	</select>

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

</mapper>
