<?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="com.ruoyi.busi.mapper.BusiReportMapper">



    <select id="queryListPage"  resultType="com.ruoyi.busi.vo.BusiReportVo">
        select main.id, main.user_id, main.user_type, main.report_user_id, main.report_user_type,
               main.report_notice_id, main.report_type, main.content, main.images,
               main.deal_user_id, main.deal_result, main.deal_time, main.creator, main.create_time,
               su1.nick_name as userNickName,su2.nick_name as reportUserNickName,su3.nick_name as  dealUserName,
               notice.title as reportNoticeTitle, bTable.title as reportTitle
        from dl_busi_report main
        inner join sys_user su1 on main.user_id = su1.user_id and su1.del_flag = '0'
        inner join sys_user su2 on main.report_user_id = su2.user_id and su2.del_flag = '0'
        left join sys_user su3 on main.deal_user_id = su3.user_id
        left join dl_busi_notice notice on main.report_notice_id = notice.id
        left join dl_base_category bTable on main.report_type = bTable.code
        <where>
                main.del_flag = '0'
            <if test="entity.reportUserNickName != null and entity.reportUserNickName != '' ">
                 and su2.nick_name like concat('%', #{entity.reportUserNickName}, '%')
            </if>
            <if test="entity.reportNoticeTitle != null and entity.reportNoticeTitle != '' ">
                 and notice.title like concat('%', #{entity.reportNoticeTitle}, '%')
             </if>
            <if test="entity.dealUserName != null  and entity.dealUserName != ''">
                 and su3.nick_name like concat('%', #{entity.dealUserName}, '%')
            </if>
        </where>
        order by main.create_time asc
    </select>
</mapper>
