<?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.CwjsPolicyApprovalLogMapper">


    <!-- 根据政策id 查询 审核意见记录  手动转给领导的审核意见 不包含自动转 -->
    <select id="getOneByPolicyId" resultType="org.jeecg.ctop.finance.policy.entity.CwjsPolicyApprovalLog">
        select * from ctop_cwjs_policy_approval_log
        where policy_id = #{policyId}
          and approval_status = #{status}
        and approval_content != '转审领导。'
        order by create_time desc
        LIMIT 1
    </select>

    <!-- 根据政策id 查询 法务最新审核意见  -->
    <select id="getOneByPolicyLegalInfo" resultType="org.jeecg.ctop.finance.policy.entity.CwjsPolicyApprovalLog">
        SELECT
            l.*
        FROM
            ctop_cwjs_policy_approval_log l
                LEFT JOIN sys_user_role ur ON l.create_user_id = ur.user_id
                LEFT JOIN sys_role r ON r.id = ur.role_id
        WHERE
            r.role_name = '法务'
          AND l.policy_id = #{policyId}
          and l.approval_content != null
        ORDER BY
            l.create_time DESC
            LIMIT 1
    </select>



    <!-- 根据政策id 查询 老板审核意见记录   -->
    <select id="getBossOneByPolicyId" resultType="org.jeecg.ctop.finance.policy.entity.CwjsPolicyApprovalLog">
        select * from ctop_cwjs_policy_approval_log
        where policy_id = #{policyId}
          and approval_status = #{status}
          and approval_content != null
        order by create_time desc
            LIMIT 1
    </select>





</mapper>