<?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.AnchorMapper">

    <resultMap type="com.ruoyi.cai.domain.Anchor" id="CaiAnchorResult">
        <result property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="openVideoStatus" column="open_video_status"/>
        <result property="videoStatus" column="video_status"/>
        <result property="orderSwitch" column="order_switch"/>
        <result property="indexDisplay" column="index_display"/>
        <result property="giveScore" column="give_score"/>
        <result property="serviceCount" column="service_count"/>
        <result property="serviceTime" column="service_time"/>
        <result property="videoRate" column="video_rate"/>
        <result property="giftRate" column="gift_rate"/>
        <result property="recommendStatus" column="recommend_status"/>
        <result property="createTime" column="create_time"/>
        <result property="status" column="status"/>
    </resultMap>
    <select id="pageAdmin" resultType="com.ruoyi.cai.dto.admin.vo.AnchorAdminVo">
        select
            t1.*,t2.age,t2.avatar,t2.usercode,t2.nickname,t2.mobile,t2.gender,t2.age,t2.city
        from cai_anchor t1
        left join cai_user t2 on t1.user_id = t2.id
        order by t1.create_time desc
    </select>
    <select id="pageApp" resultType="com.ruoyi.cai.dto.app.vo.AnchorListVo">
        select t1.id as user_id,t1.avatar,t1.gender,t1.city,t1.nickname,t1.usercode,t1.city_id,t1.city,t2.give_score
        from cai_user t1
        join cai_anchor t2 on t1.id = t2.user_id
        join cai_user_online t3 on t1.id = t3.user_id
        where t1.status = 0 and t1.is_anchor = 1
        <if test="query.cityId != null and query.cityId != ''">
            and t1.city_id = #{query.cityId}
        </if>
        <if test="query.type != null">
            <if test="query.type == 1">
                order by t3.last_live_time desc
            </if>
            <if test="query.type == 1">
                order by t1.create_time desc
            </if>
        </if>
    </select>


</mapper>
