<?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.jwtdGwc.mapper.JwtdGwcMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="jwtdGwcResultMap" type="org.springblade.modules.jwtdGwc.pojo.entity.JwtdGwcEntity">
        <result column="user_id" property="userId"/>
        <result column="sp_id" property="spId"/>
    </resultMap>

    <select id="selectJwtdGwcPage" resultMap="jwtdGwcResultMap">
        select
            jg.sp_id,
            js.spmc,
            js.spkcl,
            js.spzp,
            js.dhsxjf
        from jwtd_gwc jg
        left join jwtd_spgl js on jg.sp_id = js.id
        where js.is_deleted = 0 and jg.is_deleted = 0 and js.spzt = '1' and jg.user_id = #{jwtdGwc.userId}
    </select>

    <select id="exportJwtdGwc" resultType="org.springblade.modules.jwtdGwc.excel.JwtdGwcExcel">
        SELECT * FROM jwtd_gwc ${ew.customSqlSegment}
    </select>

    <update id="updateIsDeleted">
        update jwtd_gwc set is_deleted = 1 where user_id = #{userId} and sp_id = #{spId}
    </update>

    <select id="selectSp" resultMap="jwtdGwcResultMap">
        select * from jwtd_gwc where is_deleted = 0 and user_id = #{userId} and sp_id = #{spId}
    </select>
</mapper>
