<?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.fjInfo.mapper.FjInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="fjInfoResultMap" type="org.springblade.modules.fjInfo.entity.FjInfoEntity">
    </resultMap>


    <select id="selectFjInfoPage" resultMap="fjInfoResultMap">
        select * from blade_fj_info where is_deleted = 0
    </select>


    <select id="exportFjInfo" resultType="org.springblade.modules.fjInfo.excel.FjInfoExcel">
        SELECT * FROM blade_fj_info ${ew.customSqlSegment}
    </select>

    <update id="updateStatusQy">
        update jdrh.blade_mj_fj set status = 0,mj_id = #{mjId} where fj_id = #{fjId}
    </update>

    <update id="updateStatusTy">
        update jdrh.blade_mj_fj set status = 1 where mj_id = #{mjId} and fj_id = #{fjId}
    </update>

    <select id="selectMjFj" resultMap="fjInfoResultMap">
        select * from jdrh.blade_mj_fj where fj_id = #{id} and is_deleted = 0
    </select>

    <update id="deleteFj">
        update jdrh.blade_mj_fj set is_deleted = 1 where fj_id = #{id}
    </update>

    <select id="getMjId" resultType="org.springblade.modules.system.entity.User">
        SELECT
            bu.id AS userId,
            bu.account,
            bu.jh
        FROM
            jdrh.blade_mj_fj mfj
        LEFT JOIN jdrh.blade_user bu ON bu.ID = mfj.mj_id
        WHERE
            mfj.fj_id = #{userId}
          AND mfj.is_deleted = 0
    </select>
</mapper>
