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

  <resultMap id="tPreEmpFamilyMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TPreEmpFamily">
    <id property="id" column="ID"/>
    <result property="preMainId" column="PRE_MAIN_ID"/>
    <result property="empId" column="EMP_ID"/>
    <result property="empCode" column="EMP_CODE"/>
    <result property="empName" column="EMP_NAME"/>
    <result property="empIdcard" column="EMP_IDCARD"/>
    <result property="relationshipSelf" column="RELATIONSHIP_SELF"/>
    <result property="familyName" column="FAMILY_NAME"/>
    <result property="birthday" column="BIRTHDAY"/>
    <result property="workUnit" column="WORK_UNIT"/>
    <result property="contractTel" column="CONTRACT_TEL"/>
    <result property="deleteFlag" column="DELETE_FLAG"/>
    <result property="settleDomain" column="SETTLE_DOMAIN"/>
    <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="remark" column="REMARK"/>
	  <result property="oldId" column="OLD_ID"/>
  </resultMap>
    <sql id="Base_Column_List">
                a.ID,
                a.PRE_MAIN_ID,
                a.EMP_ID,
                a.EMP_CODE,
                a.EMP_NAME,
                a.EMP_IDCARD,
                a.RELATIONSHIP_SELF,
                a.FAMILY_NAME,
                a.BIRTHDAY,
                a.WORK_UNIT,
                a.CONTRACT_TEL,
                a.DELETE_FLAG,
                a.SETTLE_DOMAIN,
                a.CREATE_BY,
                a.UPDATE_BY,
                a.CREATE_NAME,
                a.CREATE_TIME,
                a.UPDATE_TIME,
                a.OLD_ID,
                a.REMARK
    </sql>
    <sql id="tPreEmpFamily_where">
        <if test="tPreEmpFamily != null">
                    <if test="tPreEmpFamily.id != null and tPreEmpFamily.id.trim() != ''">
                        AND a.ID = #{tPreEmpFamily.id}
                    </if>
                    <if test="tPreEmpFamily.preMainId != null and tPreEmpFamily.preMainId.trim() != ''">
                        AND a.PRE_MAIN_ID = #{tPreEmpFamily.preMainId}
                    </if>
                    <if test="tPreEmpFamily.empId != null and tPreEmpFamily.empId.trim() != ''">
                        AND a.EMP_ID = #{tPreEmpFamily.empId}
                    </if>
                    <if test="tPreEmpFamily.empCode != null and tPreEmpFamily.empCode.trim() != ''">
                        AND a.EMP_CODE = #{tPreEmpFamily.empCode}
                    </if>
                    <if test="tPreEmpFamily.empName != null and tPreEmpFamily.empName.trim() != ''">
                        AND a.EMP_NAME = #{tPreEmpFamily.empName}
                    </if>
                    <if test="tPreEmpFamily.empIdcard != null and tPreEmpFamily.empIdcard.trim() != ''">
                        AND a.EMP_IDCARD = #{tPreEmpFamily.empIdcard}
                    </if>
                    <if test="tPreEmpFamily.relationshipSelf != null and tPreEmpFamily.relationshipSelf.trim() != ''">
                        AND a.RELATIONSHIP_SELF = #{tPreEmpFamily.relationshipSelf}
                    </if>
                    <if test="tPreEmpFamily.familyName != null and tPreEmpFamily.familyName.trim() != ''">
                        AND a.FAMILY_NAME = #{tPreEmpFamily.familyName}
                    </if>
                    <if test="tPreEmpFamily.birthday != null">
                        AND a.BIRTHDAY = #{tPreEmpFamily.birthday}
                    </if>
                    <if test="tPreEmpFamily.workUnit != null and tPreEmpFamily.workUnit.trim() != ''">
                        AND a.WORK_UNIT = #{tPreEmpFamily.workUnit}
                    </if>
                    <if test="tPreEmpFamily.contractTel != null and tPreEmpFamily.contractTel.trim() != ''">
                        AND a.CONTRACT_TEL = #{tPreEmpFamily.contractTel}
                    </if>
                    <if test="tPreEmpFamily.deleteFlag != null and tPreEmpFamily.deleteFlag.trim() != ''">
                        AND a.DELETE_FLAG = #{tPreEmpFamily.deleteFlag}
                    </if>
                    <if test="tPreEmpFamily.settleDomain != null and tPreEmpFamily.settleDomain.trim() != ''">
                        AND a.SETTLE_DOMAIN = #{tPreEmpFamily.settleDomain}
                    </if>
                    <if test="tPreEmpFamily.createBy != null and tPreEmpFamily.createBy.trim() != ''">
                        AND a.CREATE_BY = #{tPreEmpFamily.createBy}
                    </if>
                    <if test="tPreEmpFamily.updateBy != null and tPreEmpFamily.updateBy.trim() != ''">
                        AND a.UPDATE_BY = #{tPreEmpFamily.updateBy}
                    </if>
                    <if test="tPreEmpFamily.createName != null and tPreEmpFamily.createName.trim() != ''">
                        AND a.CREATE_NAME = #{tPreEmpFamily.createName}
                    </if>
                    <if test="tPreEmpFamily.createTime != null">
                        AND a.CREATE_TIME = #{tPreEmpFamily.createTime}
                    </if>
                    <if test="tPreEmpFamily.updateTime != null">
                        AND a.UPDATE_TIME = #{tPreEmpFamily.updateTime}
                    </if>
                    <if test="tPreEmpFamily.remark != null and tPreEmpFamily.remark.trim() != ''">
                        AND a.REMARK = #{tPreEmpFamily.remark}
                    </if>
        </if>
    </sql>
    <!--tPreEmpFamily简单分页查询-->
    <select id="getTPreEmpFamilyList" resultMap="tPreEmpFamilyMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_pre_emp_family a
		where PRE_MAIN_ID = #{preMainId}
    </select>

	<delete id="deleteFamilyByMainId">
		delete from t_pre_emp_family where PRE_MAIN_ID = #{preMainId}
	</delete>

</mapper>