<?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="vip.xiaonuo.disk.mapper.CapacityReAuditInfoMapper">


    <select id="getCapacityAuditList" resultType="vip.xiaonuo.disk.vo.storage.CapacityReAuditInfoVo">
        select ca.*,
               us.ACCOUNT as username,
               us.NAME as nickName
        from CAPACITYRE_AUDIT_INFO as ca left join SYS_USER as us on ca.APPLICANT_USER_ID = us.ID
        <where>
            us.DELETE_FLAG = 'NOT_DELETE'
            <if test="auditState != null">
                AND ca.AUDIT_STATE = #{auditState}
            </if>
            <if test="usernameOrNickname != null and usernameOrNickname != ''">
                and (us.NAME LIKE CONCAT('%', #{usernameOrNickname}, '%') OR us.ACCOUNT LIKE CONCAT('%', #{usernameOrNickname}, '%'))
            </if>
        </where>
        order by ca.CREATE_TIME desc
    </select>

    <select id="getCapacityAuditById" resultType="vip.xiaonuo.disk.vo.storage.CapacityReAuditInfoVo">
        select ca.*,
               us.ACCOUNT as username,
               us.NAME as nickName
        from CAPACITYRE_AUDIT_INFO as ca left join SYS_USER as us on ca.APPLICANT_USER_ID = us.ID
        where us.DELETE_FLAG = 'NOT_DELETE' and ca.ID = #{id}
    </select>

    <select id="getUserCapacityAuditList" resultType="vip.xiaonuo.disk.vo.storage.CapacityReAuditInfoVo">
        select ca.*,
               us.ACCOUNT as username,
               us.NAME as nickName
        from CAPACITYRE_AUDIT_INFO as ca left join SYS_USER as us on ca.APPLICANT_USER_ID = us.ID
        <where>
            us.DELETE_FLAG = 'NOT_DELETE' and us.ID = #{id}
            <if test="auditState != null">
                AND ca.AUDIT_STATE = #{auditState}
            </if>
        </where>
    </select>

</mapper>
