<?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.ffxc.mapper.JwtdFfxcMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="jwtdFfxcResultMap" type="org.springblade.modules.ffxc.pojo.entity.JwtdFfxcEntity">
        <result column="xcbt" property="xcbt"/>
        <result column="xcnr" property="xcnr"/>
        <result column="xclx" property="xclx"/>
        <result column="fbdw" property="fbdw"/>
        <result column="jf" property="jf"/>
    </resultMap>

    <select id="selectJwtdFfxcPage" resultMap="jwtdFfxcResultMap">
        select
            jf.*,
            (select count(0) from jwtd_ffxc_llls jfl where jfl.ffxc_id = jf.id) as count,
            bdb.dict_value as xclxmc
        from jwtd_ffxc jf
        left join blade_dict_biz bdb on jf.xclx = bdb.dict_key and bdb.code = 'ffxclx'
        where jf.is_deleted = 0
        <if test="jwtdFfxc.xcbt != null and jwtdFfxc.xcbt != ''">
            and jf.xcbt like '%' || #{jwtdFfxc.xcbt} || '%'
        </if>
        <if test="jwtdFfxc.xclx != null and jwtdFfxc.xclx != ''">
            and jf.xclx = #{jwtdFfxc.xclx}
        </if>
        <if test="jwtdFfxc.fbdw != null and jwtdFfxc.fbdw != ''">
            and jf.fbdw = #{jwtdFfxc.fbdw}
        </if>
        order by jf.status desc,count desc
    </select>

    <select id="exportJwtdFfxc" resultType="org.springblade.modules.ffxc.excel.JwtdFfxcExcel">
        SELECT * FROM jwtd_ffxc ${ew.customSqlSegment}
    </select>

    <select id="detailApp" resultMap="jwtdFfxcResultMap">
        select
            jf.*,
            (select count(0) from jwtd_ffxc_llls jfl where jfl.ffxc_id = jf.id) as count,
            bdb.dict_value as xclxmc
        from jwtd_ffxc jf
        left join blade_dict_biz bdb on jf.xclx = bdb.dict_key and bdb.code = 'ffxclx'
        where jf.id = #{id} and jf.is_deleted = 0
    </select>
</mapper>
