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

	<resultMap id="tGzEmpWorkMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TGzEmpWork">
		<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="workUnit" column="work_unit"/>
		<result property="workStartDate" column="work_start_date"/>
		<result property="workEndDate" column="work_end_date"/>
		<result property="workDept" column="work_dept"/>
		<result property="workJob" column="work_job"/>
		<result property="certifierName" column="certifier_name"/>
		<result property="certifierPhone" column="certifier_phone"/>
	</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.work_unit,
                a.work_start_date,
                a.work_end_date,
                a.work_dept,
                a.work_job,
                a.certifier_name,
                a.certifier_phone
    </sql>
	<sql id="tGzEmpWork_where">
		<if test="tGzEmpWork != null">
			<if test="tGzEmpWork.id != null and tGzEmpWork.id.trim() != ''">
				AND a.id = #{tGzEmpWork.id}
			</if>
			<if test="tGzEmpWork.empId != null and tGzEmpWork.empId.trim() != ''">
				AND a.emp_id = #{tGzEmpWork.empId}
			</if>
			<if test="tGzEmpWork.delFlag != null and tGzEmpWork.delFlag.trim() != ''">
				AND a.del_flag = #{tGzEmpWork.delFlag}
			</if>
			<if test="tGzEmpWork.createTime != null">
				AND a.create_time = #{tGzEmpWork.createTime}
			</if>
			<if test="tGzEmpWork.createBy != null and tGzEmpWork.createBy.trim() != ''">
				AND a.create_by = #{tGzEmpWork.createBy}
			</if>
			<if test="tGzEmpWork.createName != null and tGzEmpWork.createName.trim() != ''">
				AND a.create_name = #{tGzEmpWork.createName}
			</if>
			<if test="tGzEmpWork.updateBy != null and tGzEmpWork.updateBy.trim() != ''">
				AND a.update_by = #{tGzEmpWork.updateBy}
			</if>
			<if test="tGzEmpWork.updateTime != null">
				AND a.update_time = #{tGzEmpWork.updateTime}
			</if>
			<if test="tGzEmpWork.workUnit != null and tGzEmpWork.workUnit.trim() != ''">
				AND a.work_unit = #{tGzEmpWork.workUnit}
			</if>
			<if test="tGzEmpWork.workStartDate != null">
				AND a.work_start_date = #{tGzEmpWork.workStartDate}
			</if>
			<if test="tGzEmpWork.workEndDate != null">
				AND a.work_end_date = #{tGzEmpWork.workEndDate}
			</if>
			<if test="tGzEmpWork.workDept != null and tGzEmpWork.workDept.trim() != ''">
				AND a.work_dept = #{tGzEmpWork.workDept}
			</if>
			<if test="tGzEmpWork.workJob != null and tGzEmpWork.workJob.trim() != ''">
				AND a.work_job = #{tGzEmpWork.workJob}
			</if>
			<if test="tGzEmpWork.certifierName != null and tGzEmpWork.certifierName.trim() != ''">
				AND a.certifier_name = #{tGzEmpWork.certifierName}
			</if>
			<if test="tGzEmpWork.certifierPhone != null and tGzEmpWork.certifierPhone.trim() != ''">
				AND a.certifier_phone = #{tGzEmpWork.certifierPhone}
			</if>
		</if>
	</sql>
	<!--tGzEmpWork简单分页查询-->
	<select id="getTGzEmpWorkPage" resultMap="tGzEmpWorkMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_gz_emp_work a
		<where>
			1=1
			<include refid="tGzEmpWork_where"/>
		</where>
	</select>

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

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

</mapper>
