package com.ruoyi.controller;

import com.ruoyi.annotations.UserLoginToken;
import com.ruoyi.common.page.PageResult;
import com.ruoyi.controller.req.FollowUserReq;
import com.ruoyi.controller.req.FollowerPageByOther;
import com.ruoyi.controller.resp.FollowPageResp;
import com.ruoyi.frequency.follow.service.FollowService;
import com.ruoyi.response.ResponseData;
import com.ruoyi.vo.RyController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 关注
 */
@CrossOrigin
@RestController
@RequestMapping("/api/follow")
@Api(tags = "关注")
public class ApiFollowController extends RyController {

    @Autowired
    private FollowService followService;

    /**
     * 关注用户
     *
     * @return
     */
    @PostMapping("/followUser")
    @UserLoginToken
    @ApiOperation("关注用户")
    public ResponseData followUser(@Valid @RequestBody FollowUserReq req) {
        return followService.followUser(req, getUserVo());
    }

    /**
     * 关注列表(自己看)
     *
     * @return
     */
    @PostMapping("/followerPageBySelf")
    @UserLoginToken
    @ApiOperation("关注列表(自己看)")
    public ResponseData<PageResult<FollowPageResp>> followerPageBySelf(@Valid @RequestBody FollowerPageByOther req) {
        return followService.followerPageBySelf(req, getUserVo());
    }

    /**
     * 关注列表(别人看)
     *
     * @return
     */
    @PostMapping("/followerPageByOther")
    @ApiOperation("关注列表(别人看)")
    public ResponseData<PageResult<FollowPageResp>> followerPageByOther(@Valid @RequestBody FollowerPageByOther req) {
        return followService.followerPageByOther(req,getUserVo());
    }



    /**
     * 粉丝列表(自己看)
     *
     * @return
     */
    @PostMapping("/fansPageBySelf")
    @UserLoginToken
    @ApiOperation("粉丝列表(自己看)")
    public ResponseData<PageResult<FollowPageResp>> fansPageBySelf(@Valid @RequestBody FollowerPageByOther req) {
        return followService.fansPageBySelf(req, getUserVo());
    }

    /**
     * 粉丝列表(别人看)
     *
     * @return
     */
    @PostMapping("/fansPageByOther")
    @ApiOperation("粉丝列表(别人看)")
    public ResponseData<PageResult<FollowPageResp>> fansPageByOther(@Valid @RequestBody FollowerPageByOther req) {
        return followService.fansPageByOther(req,getUserVo());
    }

    /**
     * 查询未关注列表
     *
     * @return
     */
    @PostMapping("/notFollowerPageBySelf")
    @ApiOperation("查询未关注列表")
    public ResponseData<PageResult<FollowPageResp>> notFollowerPageBySelf(@Valid @RequestBody FollowerPageByOther req) {
        return followService.notFollowerPageBySelf(req,getUserVo());
    }
}