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

    <resultMap type="com.ruoyi.cai.domain.UserFollow" id="CaiUserFollowResult">
        <result property="userId" column="user_id"/>
        <result property="followUser" column="follow_user"/>
        <result property="isWatch" column="is_watch"/>
        <result property="remark" column="remark"/>
        <result property="createTime" column="create_time"/>
    </resultMap>
    <select id="pageApp" resultType="com.ruoyi.cai.dto.app.vo.user.UserStarOrVisitorList">
        select
            t1.create_time as happen_time,t1.is_watch,
            t2.avatar,t2.gender,t2.city,t2.nickname,t2.usercode,t2.age
        from cai_user_follow t1
        join cai_user t2 on t1.user_id = t2.id
        <where>
            <if test="query.type == 1">
                and t1.user_id = #{query.userId}
            </if>
            <if test="query.type == 2">
                and t1.follow_user = #{query.userId}
            </if>
        </where>
        order by create_time desc
    </select>


</mapper>
