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

	<resultMap id="tGzEmpEducationMap" type="com.yifu.cloud.plus.v1.yifu.archives.entity.TGzEmpEducation">
		<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="eduQual" column="edu_qual"/>
		<result property="eduDegree" column="edu_degree"/>
		<result property="eduType" column="edu_type"/>
		<result property="school" column="school"/>
		<result property="eduStartDate" column="edu_start_date"/>
		<result property="eduEndDate" column="edu_end_date"/>
		<result property="gradutionType" column="gradution_type"/>
		<result property="major" column="major"/>
		<result property="highEduQualFlag" column="high_edu_qual_flag"/>
		<result property="highEduDegreeFlag" column="high_edu_degree_flag"/>
		<result property="firstDegreeFlag" column="first_degree_flag"/>
	</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.edu_qual,
                a.edu_degree,
                a.edu_type,
                a.school,
                a.edu_start_date,
                a.edu_end_date,
                a.gradution_type,
                a.major,
                a.high_edu_qual_flag,
                a.high_edu_degree_flag,
                a.first_degree_flag
    </sql>
	<sql id="tGzEmpEducation_where">
		<if test="tGzEmpEducation != null">
			<if test="tGzEmpEducation.id != null and tGzEmpEducation.id.trim() != ''">
				AND a.id = #{tGzEmpEducation.id}
			</if>
			<if test="tGzEmpEducation.empId != null and tGzEmpEducation.empId.trim() != ''">
				AND a.emp_id = #{tGzEmpEducation.empId}
			</if>
			<if test="tGzEmpEducation.delFlag != null and tGzEmpEducation.delFlag.trim() != ''">
				AND a.del_flag = #{tGzEmpEducation.delFlag}
			</if>
			<if test="tGzEmpEducation.createTime != null">
				AND a.create_time = #{tGzEmpEducation.createTime}
			</if>
			<if test="tGzEmpEducation.createBy != null and tGzEmpEducation.createBy.trim() != ''">
				AND a.create_by = #{tGzEmpEducation.createBy}
			</if>
			<if test="tGzEmpEducation.createName != null and tGzEmpEducation.createName.trim() != ''">
				AND a.create_name = #{tGzEmpEducation.createName}
			</if>
			<if test="tGzEmpEducation.updateBy != null and tGzEmpEducation.updateBy.trim() != ''">
				AND a.update_by = #{tGzEmpEducation.updateBy}
			</if>
			<if test="tGzEmpEducation.updateTime != null">
				AND a.update_time = #{tGzEmpEducation.updateTime}
			</if>
			<if test="tGzEmpEducation.eduQual != null and tGzEmpEducation.eduQual.trim() != ''">
				AND a.edu_qual = #{tGzEmpEducation.eduQual}
			</if>
			<if test="tGzEmpEducation.eduDegree != null and tGzEmpEducation.eduDegree.trim() != ''">
				AND a.edu_degree = #{tGzEmpEducation.eduDegree}
			</if>
			<if test="tGzEmpEducation.eduType != null and tGzEmpEducation.eduType.trim() != ''">
				AND a.edu_type = #{tGzEmpEducation.eduType}
			</if>
			<if test="tGzEmpEducation.school != null and tGzEmpEducation.school.trim() != ''">
				AND a.school = #{tGzEmpEducation.school}
			</if>
			<if test="tGzEmpEducation.eduStartDate != null">
				AND a.edu_start_date = #{tGzEmpEducation.eduStartDate}
			</if>
			<if test="tGzEmpEducation.eduEndDate != null">
				AND a.edu_end_date = #{tGzEmpEducation.eduEndDate}
			</if>
			<if test="tGzEmpEducation.gradutionType != null and tGzEmpEducation.gradutionType.trim() != ''">
				AND a.gradution_type = #{tGzEmpEducation.gradutionType}
			</if>
			<if test="tGzEmpEducation.major != null and tGzEmpEducation.major.trim() != ''">
				AND a.major = #{tGzEmpEducation.major}
			</if>
			<if test="tGzEmpEducation.highEduQualFlag != null and tGzEmpEducation.highEduQualFlag.trim() != ''">
				AND a.high_edu_qual_flag = #{tGzEmpEducation.highEduQualFlag}
			</if>
			<if test="tGzEmpEducation.highEduDegreeFlag != null and tGzEmpEducation.highEduDegreeFlag.trim() != ''">
				AND a.high_edu_degree_flag = #{tGzEmpEducation.highEduDegreeFlag}
			</if>
			<if test="tGzEmpEducation.firstDegreeFlag != null and tGzEmpEducation.firstDegreeFlag.trim() != ''">
				AND a.first_degree_flag = #{tGzEmpEducation.firstDegreeFlag}
			</if>
		</if>
	</sql>
	<!--tGzEmpEducation简单分页查询-->
	<select id="getTGzEmpEducationPage" resultMap="tGzEmpEducationMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_gz_emp_education a
		<where>
			1=1
			<include refid="tGzEmpEducation_where"/>
		</where>
	</select>

	<!--获取附属信息——保存到人员档案时使用—— 教育经历只有一个最高的-->
	<select id="getOneByEmpId" resultMap="tGzEmpEducationMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_gz_emp_education 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_education where emp_id = #{empId}
	</delete>

</mapper>
