<?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="org.springblade.modules.ffxcLlls.mapper.JwtdFfxcLllsMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="jwtdFfxcLllsResultMap" type="org.springblade.modules.ffxcLlls.pojo.entity.JwtdFfxcLllsEntity">
        <result column="ffxc_id" property="ffxcId"/>
        <result column="user_id" property="userId"/>
        <result column="llzt" property="llzt"/>
    </resultMap>

    <select id="selectJwtdFfxcLllsPage" resultMap="jwtdFfxcLllsResultMap">
        select * from jwtd_ffxc_llls where is_deleted = 0
    </select>

    <select id="exportJwtdFfxcLlls" resultType="org.springblade.modules.ffxcLlls.excel.JwtdFfxcLllsExcel">
        SELECT * FROM jwtd_ffxc_llls ${ew.customSqlSegment}
    </select>

    <select id="getFfxcLljl" resultMap="jwtdFfxcLllsResultMap">
        select
            bu.name,
            jfl.create_time,
            case when jfl.llzt = '0' then '未完成' when jfl.llzt = '1' then '已完成' end as llzt,
            jfl.jf
        from jwtd_ffxc_llls jfl
        left join blade_user bu on bu.id = jfl.user_id
        where jfl.is_deleted = 0 and jfl.ffxc_id = #{id}
    </select>

    <select id="selectLllsByUserIdAndFfxcId" resultMap="jwtdFfxcLllsResultMap">
        select * from jwtd_ffxc_llls where is_deleted = 0 and user_id = #{userId} and ffxc_id = #{ffxcId}
    </select>

    <select id="selectNewId" resultType="java.lang.Long">
        select id from jwtd_ffxc_llls where is_deleted = 0 and user_id = #{userId} and ffxc_id = #{ffxcId} order by create_time desc limit 1
    </select>
</mapper>
