<?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.ctop.finance.policy.mapper.CwjsCompanyApprovalUserMapper">
    <select id="queryByCompanySubjectIdAndUserId" resultType="org.jeecg.ctop.finance.policy.entity.CwjsCompanyApprovalUser">
        select * from ctop_cwjs_company_approval_user where company_subject_id = #{companySubjectId} and approval_user_id = #{userId} and del_flag = 0 limit 1
    </select>
    <select id="queryByUserId" resultType="org.jeecg.ctop.finance.policy.entity.CwjsCompanyApprovalUser">
        select * from ctop_cwjs_company_approval_user where approval_user_id = #{userId} and del_flag = 0
    </select>
    <select id="queryByCompanySubjectId" resultType="org.jeecg.ctop.finance.policy.entity.CwjsCompanyApprovalUser">
        select * from ctop_cwjs_company_approval_user where company_subject_id = #{companySubjectId} and del_flag = 0 ORDER BY level
    </select>
    <select id="queryByCompanySubjectIdAndLevel" resultType="org.jeecg.ctop.finance.policy.entity.CwjsCompanyApprovalUser">
        select * from ctop_cwjs_company_approval_user where company_subject_id = #{companySubjectId} and level = #{level} and del_flag = 0
    </select>



<!-- 根据主体查询 最后一个审核人员-->
    <select id="getEndApprovalUserBySub" resultType="org.jeecg.ctop.finance.policy.entity.CwjsCompanyApprovalUser">
        select * from ctop_cwjs_company_approval_user
        where del_flag = 0
        and company_subject_id = #{companySubjectId}
        ORDER BY level DESC
            limit 1
    </select>


</mapper>