<?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.sqx.modules.chat.dao.RoomAuditDao">

    <select id="selectRoomAuditList" resultType="com.sqx.modules.chat.entity.RoomAudit">
        select ra.*,u.user_name as userName,u.phone,ru.user_name as roomUserName,ru.phone as roomPhone
        from room_audit ra
        left join tb_user u on u.user_id=ra.user_id
        left join tb_user ru on ru.user_id=ra.room_user_id
        where 1=1
        <if test="userId!=null">
            and ra.user_id=#{userId}
        </if>
        <if test="roomUserId!=null">
            and ra.room_user_id=#{userId}
        </if>
        <if test="roomNo!=null and roomNo!=''">
            and ra.room_no=#{roomNo}
        </if>
        <if test="roomUserName!=null and roomUserName!=''">
            and ru.user_name like concat('%',#{roomUserName},'%')
        </if>
        <if test="roomPhone!=null and roomPhone!=''">
            and ru.phone like concat('%',#{roomPhone},'%')
        </if>
        <if test="userName!=null and userName!=''">
            and u.user_name like concat('%',#{userName},'%')
        </if>
        <if test="phone!=null and phone!=''">
            and u.phone like concat('%',#{phone},'%')
        </if>
        <if test="status!=null">
            and ra.status=#{status}
        </if>
        order by ra.create_time desc
    </select>


</mapper>