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

  <resultMap id="tEmployeeInfoMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo">
    <id property="id" column="ID"/>
    <result property="empCode" column="EMP_CODE"/>
    <result property="empNatrue" column="EMP_NATRUE"/>
    <result property="empName" column="EMP_NAME"/>
    <result property="empIdcard" column="EMP_IDCARD"/>
    <result property="validityStart" column="VALIDITY_START"/>
    <result property="validityEnd" column="VALIDITY_END"/>
    <result property="empSex" column="EMP_SEX"/>
    <result property="empBirthday" column="EMP_BIRTHDAY"/>
    <result property="empAge" column="EMP_AGE"/>
    <result property="empMarriStatus" column="EMP_MARRI_STATUS"/>
    <result property="empNational" column="EMP_NATIONAL"/>
    <result property="politicalStatus" column="POLITICAL_STATUS"/>
    <result property="empEmail" column="EMP_EMAIL"/>
    <result property="empPhone" column="EMP_PHONE"/>
    <result property="idProvince" column="ID_PROVINCE"/>
    <result property="idCity" column="ID_CITY"/>
    <result property="idTown" column="ID_TOWN"/>
    <result property="empRegisType" column="EMP_REGIS_TYPE"/>
    <result property="fileProvince" column="FILE_PROVINCE"/>
    <result property="fileCity" column="FILE_CITY"/>
    <result property="fileTown" column="FILE_TOWN"/>
    <result property="isCollege" column="IS_COLLEGE"/>
    <result property="hignEducation" column="HIGN_EDUCATION"/>
    <result property="school" column="SCHOOL"/>
    <result property="major" column="MAJOR"/>
    <result property="admissionDate" column="ADMISSION_DATE"/>
    <result property="gradutionDate" column="GRADUTION_DATE"/>
    <result property="remark" column="REMARK"/>
    <result property="fileSource" column="FILE_SOURCE"/>
    <result property="status" column="STATUS"/>
    <result property="fileStatus" column="FILE_STATUS"/>
    <result property="projectNum" column="PROJECT_NUM"/>
    <result property="contractStatus" column="CONTRACT_STATUS"/>
    <result property="insuranceStatus" column="INSURANCE_STATUS"/>
    <result property="socialStatus" column="SOCIAL_STATUS"/>
    <result property="fundStatus" column="FUND_STATUS"/>
    <result property="salaryStatus" column="SALARY_STATUS"/>
    <result property="deleteFlag" column="DELETE_FLAG"/>
    <result property="createBy" column="CREATE_BY"/>
    <result property="createName" column="CREATE_NAME"/>
    <result property="createTime" column="CREATE_TIME"/>
    <result property="updateBy" column="UPDATE_BY"/>
    <result property="updateTime" column="UPDATE_TIME"/>
    <result property="leaveUser" column="LEAVE_USER"/>
    <result property="leaveTime" column="LEAVE_TIME"/>
    <result property="leaveReason" column="LEAVE_REASON"/>
    <result property="leaveRemark" column="LEAVE_REMARK"/>
  </resultMap>

	<sql id="baseParam">
		a.ID,
		a.EMP_CODE,
		a.EMP_NATRUE,
		a.EMP_NAME,
		a.EMP_IDCARD,
		a.VALIDITY_START,
		a.VALIDITY_END,
		a.EMP_SEX,
		a.EMP_BIRTHDAY,
		a.EMP_AGE,
		a.EMP_MARRI_STATUS,
		a.EMP_NATIONAL,
		a.POLITICAL_STATUS,
		a.EMP_EMAIL,
		a.EMP_PHONE,
		a.ID_PROVINCE,
		a.ID_CITY,
		a.ID_TOWN,
		a.EMP_REGIS_TYPE,
		a.FILE_PROVINCE,
		a.FILE_CITY,
		a.FILE_TOWN,
		a.IS_COLLEGE,
		a.HIGN_EDUCATION,
		a.SCHOOL,
		a.MAJOR,
		a.ADMISSION_DATE,
		a.GRADUTION_DATE,
		a.REMARK,
		a.FILE_SOURCE,
		a.STATUS,
		a.FILE_STATUS,
		a.PROJECT_NUM,
		a.CONTRACT_STATUS,
		a.INSURANCE_STATUS,
		a.SOCIAL_STATUS,
		a.FUND_STATUS,
		a.SALARY_STATUS,
		a.DELETE_FLAG,
		a.CREATE_BY,
		a.CREATE_NAME,
		a.CREATE_TIME,
		a.UPDATE_BY,
		a.UPDATE_TIME,
		a.LEAVE_USER,
		a.LEAVE_TIME,
		a.LEAVE_REASON,
		a.LEAVE_REMARK
	</sql>

	<update id="updateEducationOfEmp">
		update t_employee_info
		<trim prefix="set" suffixOverrides=",">
			<if test="education.isCollege != null">is_college=#{education.isCollege},</if>
			<if test="education.hignEducation != null">hign_education=#{education.hignEducation},</if>
			<if test="education.school != null">school=#{education.school},</if>
			<if test="education.major != null">major=#{education.major},</if>
			<if test="education.admissionDate != null">admission_date=#{education.admissionDate},</if>
			<if test="education.gradutionDate != null">gradution_date=#{education.gradutionDate},</if>
		</trim>
		WHERE id=#{education.empId}
	</update>

	<sql id="employeeInfo_where">
		<if test="employeeInfo != null">
			<if test="employeeInfo.id != null and employeeInfo.id.trim() != ''">
				AND a.id = #{employeeInfo.id}
			</if>
			<if test="employeeInfo.empName != null and employeeInfo.empName.trim() != ''">
				AND a.EMP_NAME = #{employeeInfo.empName}
			</if>
			<if test="employeeInfo.empIdcard != null and employeeInfo.empIdcard.trim() != ''">
				AND a.EMP_IDCARD = #{employeeInfo.empIdcard}
			</if>
		</if>
	</sql>

	<!-- hgw 分页查询 -->
	<select id="getPage" resultMap="tEmployeeInfoMap">
		select
			<include refid="baseParam"/>
		from t_employee_info a
		where 1=1
			<include refid="employeeInfo_where"/>
		${sql}
		order by a.CREATE_TIME desc
	</select>

</mapper>
