<?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.finance.mapper.InnerBillAuditMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="innerBillAuditResultMap" type="org.springblade.finance.entity.InnerBillAudit">
        <result column="AID" property="aid"/>
        <result column="SID" property="sid"/>
        <result column="AUDITTYPE" property="audittype"/>
        <result column="AUDITSTATUS" property="auditstatus"/>
        <result column="REJECTREASON" property="rejectreason"/>
        <result column="CREATEBYUSERID" property="createbyuserid"/>
        <result column="CREATEBYNAME" property="createbyname"/>
        <result column="CREATETIME" property="createtime"/>
        <result column="REJECTTIME" property="rejecttime"/>
        <result column="UPLOADFILENAME" property="uploadfilename"/>
        <result column="UPLOADFILEURI" property="uploadfileuri"/>
    </resultMap>
    <!-- 通用查询映射结果 -->
    <resultMap id="testResultMap" type="org.springblade.finance.entity.InnerBillAudit">
        <id column="AID" property="aid"/>
        <result column="SID" property="sid"/>
        <result column="AUDITTYPE" property="audittype"/>
        <result column="AUDITSTATUS" property="auditstatus"/>
        <result column="REJECTREASON" property="rejectreason"/>
        <result column="CREATEBYUSERID" property="createbyuserid"/>
        <result column="CREATEBYNAME" property="createbyname"/>
        <result column="CREATETIME" property="createtime"/>
        <result column="REJECTTIME" property="rejecttime"/>
        <result column="UPLOADFILENAME" property="uploadfilename"/>
        <result column="UPLOADFILEURI" property="uploadfileuri"/>
        <!-- 通用查询映射结果 -->
        <association property="innerAccount" column="SID" javaType="org.springblade.finance.entity.InnerAccount">
            <result column="SID" property="sid"/>
            <result column="THEMONTH" property="themonth"/>
            <result column="DEAL_TYPE" property="dealType"/>
            <result column="COMPANY" property="company"/>
            <result column="USERNUM" property="usernum"/>
            <result column="MONEY" property="money"/>
            <result column="FLAG_RENDER" property="flagRender"/>
            <result column="RENDER_USER" property="renderUser"/>
            <result column="RENDER_TIME" property="renderTime"/>
            <result column="ALLOW_PUSH" property="allowPush"/>
            <result column="DEAL_ACCOUNT_ID" property="dealAccountId"/>
        </association>
        <!-- 通用查询映射结果 -->
        <collection property="userList" column="AID" ofType="org.springblade.finance.entity.InnerBillAuditUser">
            <result column="AUID" property="auid"/>
            <result column="AID" property="aid"/>
            <result column="USERID" property="userid"/>
            <result column="USERNAME" property="username"/>
            <result column="CHECKSTATUS" property="checkstatus"/>
            <result column="CHECKTIME" property="checktime"/>
            <result column="PRIORITY" property="priority"/>
        </collection>
    </resultMap>

    <select id="customAidList" resultType="java.lang.Long">
        select A.* from (
        select distinct iba.AID from
		INNER_BILL_AUDIT iba
		left join INNER_ACCOUNT ia  on iba.SID = ia.SID
		left join INNER_BILL_AUDIT_USER ibau on iba.AID = ibau.AID
		${ew.customSqlSegment}
		) A
    </select>

    <select id="customCount" resultType="java.lang.Long">
    	select count(distinct iba.AID) from
		INNER_BILL_AUDIT iba
		left join INNER_ACCOUNT ia  on iba.SID = ia.SID
		left join INNER_BILL_AUDIT_USER ibau on iba.AID = ibau.AID
		${ew.customSqlSegment}
    </select>

    <select id="customList" resultMap="testResultMap">
        select * from
        INNER_BILL_AUDIT iba
        left join INNER_ACCOUNT ia  on iba.SID = ia.SID
        left join INNER_BILL_AUDIT_USER ibau on iba.AID = ibau.AID
        ${ew.customSqlSegment}
    </select>

</mapper>
