<?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.practice.logwrite.mapper.RegistrationWorkLogMapper">

    <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.start_time,
        a.end_time,
        a.internship_days,
        a.internship_location,
        a.tracking_project_name,
        a.work,
        a.remarks,
        a.project_manager,
        a.work_name,
        a.all_money
    </sql>

    <update id="removeById">
        update human_resources_practice_registration_work_log set del_flag = '1' where id = #{id}
    </update>
    <update id="updateStatusById">
        UPDATE human_resources_practice_registration_work_log SET type = #{type}
		WHERE id = #{id}
    </update>

    <select id="findList" resultType="com.jeeplus.human.practice.logwrite.service.dto.RegistrationWorkLogDto">
        select
        <include refid="Base_Column_List"></include>,
        d.ID_ AS task_id,
        su.name as createName,
        su2.name as projectManagerName
        from human_resources_practice_registration_work_log a
        LEFT JOIN act_ru_task d ON a.proc_ins_id = d.PROC_INST_ID_
        left join sys_user su on a.create_by_id = su.id and su.del_flag = '0'
        left join sys_user su2 on a.project_manager = su2.id and su2.del_flag = '0'
        ${ew.customSqlSegment}
        ORDER BY a.create_time DESC
    </select>
    <select id="getById" resultType="com.jeeplus.human.practice.logwrite.domain.RegistrationWorkLog">
        select
        <include refid="Base_Column_List"></include>,
        d.ID_ AS task_id
        from human_resources_practice_registration_work_log a
        LEFT JOIN act_ru_task d ON a.proc_ins_id = d.PROC_INST_ID_
        where a.id = #{id} and a.del_flag = '0'
    </select>
    <select id="getLastWorkDay" resultType="java.lang.String">
        SELECT end_time FROM human_resources_practice_registration_work_log WHERE create_by_id = #{createById} ORDER BY end_time desc limit 1
    </select>
</mapper>