<?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.cai.mapper.ReportMapper">

    <resultMap type="com.ruoyi.cai.domain.Report" id="CaiReportResult">
        <result property="id" column="id"/>
        <result property="type" column="type"/>
        <result property="cateName" column="cate_name"/>
        <result property="cateId" column="cate_id"/>
        <result property="userId" column="user_id"/>
        <result property="reportUid" column="report_uid"/>
        <result property="content" column="content"/>
        <result property="status" column="status"/>
        <result property="createTime" column="create_time"/>
    </resultMap>
    <select id="pageAdmin" resultType="com.ruoyi.cai.dto.admin.vo.ReportAdminVo">
        select t1.*,
        t2.usercode,t2.nickname,t2.mobile,t2.avatar,t2.gender,t2.age,
        t3.usercode as report_usercode,t3.nickname as report_nickname,t3.mobile as report_mobile,t3.avatar as report_avatar,t3.gender as report_gender,t3.age as report_age
        from cai_report t1
        left join cai_user t2 on t1.user_id = t2.id
        left join cai_user t3 on t1.report_uid = t3.id
        <where>
            <if test="bo.mobile != null and bo.mobile != ''">
                and t2.mobile = #{bo.mobile}
            </if>
            <if test="bo.usercode != null and bo.usercode != ''">
                and t2.usercode = #{bo.usercode}
            </if>
            <if test="bo.reportMobile != null and bo.reportMobile != ''">
                and t3.mobile = #{bo.reportMobile}
            </if>
            <if test="bo.reportUsercode != null and bo.reportUsercode != ''">
                and t3.usercode = #{bo.reportUsercode}
            </if>
        </where>
        order by t1.create_time desc
    </select>


</mapper>
