<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\Db;
/**
 * 访问足迹
 */
class Uservisit extends Api
{
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];

    //我的访问列表
    public function my_visit_list(){

        $list = Db::name('user_visit')
            ->alias('visit')
            ->join('user','visit.to_uid = user.id','LEFT')
            ->field('user.id,user.nickname,user.avatar,user.bio,user.birthday,user.gender')
            ->where('visit.uid',$this->auth->id)->order('visit.updatetime desc')->autopage()->select();

        $list = list_domain_image($list,['avatar']);
        $list = list_birthday_age($list);

        $this->success('success',$list);
    }


    //访问我的人列表
    public function visit_me_list(){
        $list = Db::name('user_visit')
            ->alias('visit')
            ->join('user','visit.uid = user.id','LEFT')
            ->field('user.id,user.nickname,user.avatar,user.bio,user.birthday,user.gender')
            ->where('visit.to_uid',$this->auth->id)->order('visit.updatetime desc')->autopage()->select();

        $list = list_domain_image($list,['avatar']);
        $list = list_birthday_age($list);

        $this->success('success',$list);
    }

    //查看某人
    public function visit_one(){
       //放到usercenter/getuserinfo里了
    }


}
