<?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.jeecg.modules.system.mapper.NationDepartMapper">

    <select id="queryDepartByCode" resultType="org.jeecg.modules.system.entity.NationDepart">
        select * from nation_depart where sub_code = #{subCode} limit 1
    </select>
    <select id="queryDepartByUserId" resultType="org.jeecg.modules.system.entity.NationDepart">
        SELECT
            a.*
        FROM
            nation_depart a
            LEFT JOIN sys_depart b ON a.sub_code = b.depart_code
            LEFT JOIN sys_user_depart c ON b.id = c.dep_id
        WHERE
            b.STATUS = 1
            AND c.user_id = #{userId}
            AND b.del_flag = 0
            LIMIT 1
    </select>
</mapper>