<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jeeplus.human.enrollment.enrollmentRegistration.mapper.EnrollmentKeyCardMapper">

    <sql id="Base_Column_List">
        a.id,
        a.create_by_id,
        a.create_time,
        a.update_by_id,
        a.update_time,
        a.del_flag,
        a.type,
        a.proc_ins_id,
        a.process_definition_id,
        a.enrollment_registration_id,
        a.remarks
    </sql>
    <update id="updateStatusById">
        UPDATE human_resources_enrollment_key_card SET type = #{type}
		WHERE id = #{registrationId}
    </update>

    <select id="getById"
            resultType="com.jeeplus.human.enrollment.enrollmentRegistration.domain.EnrollmentKeyCard">
        select
        <include refid="Base_Column_List"></include>,
        re.name as userName,
        so.name as departmentName
        from human_resources_enrollment_key_card a
        left join human_resources_enrollment_registration re on a.enrollment_registration_id = re.id
        left join sys_office so on re.department = so.id
        where a.id = #{id} and a.del_flag = '0'
    </select>
    <select id="getNoticeUserId" resultType="java.lang.String">
        select user_id from human_resources_enrollment_registration
        where
        id = (select enrollment_registration_id from human_resources_enrollment_key_card
                where id = #{id} and del_flag = '0')
        and del_flag = '0'
    </select>
</mapper>