<?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.swzdr.mapper.RyDjspMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="rySpResultMap" type="org.springblade.swzdr.pojo.entity.RyDjspEntity">
        <result column="id" property="id"/>
        <result column="user_id" property="userId"/>
        <result column="source_level" property="sourceLevel"/>
        <result column="target_level" property="targetLevel"/>
        <result column="sqyy" property="sqyy"/>
        <result column="jjyy" property="jjyy"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>

    <select id="selectRySpPage" resultMap="rySpResultMap">
        SELECT
            sp.*
        FROM
            swzdr_ry_sp sp
        LEFT JOIN blade_dept dept ON dept.id = sp.create_dept
        WHERE
            sp.is_deleted = 0
        AND (dept.id = #{params.deptId} ::int8 OR dept.ancestors LIKE '%' || #{params.deptId} || '%')
    </select>

    <select id="exportRySp" resultType="org.springblade.swzdr.excel.RySpExcel">
        SELECT * FROM swzdr_ry_sp ${ew.customSqlSegment}
    </select>

</mapper>
