package com.ruoyi.cai.controller.app;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.cai.dto.app.query.StarOrVisitorReq;
import com.ruoyi.cai.dto.app.query.StarQuery;
import com.ruoyi.cai.dto.app.vo.user.UserStarOrVisitorList;
import com.ruoyi.cai.service.UserFollowService;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/user/star")
@Tag(name = "关注相关接口")
public class UserStartAppController {

    @Autowired
    private UserFollowService userFollowService;

    @PostMapping("/star")
    @Operation(summary = "关注用户")
    public R<Boolean> star(@RequestBody StarOrVisitorReq starOrVisitorReq){
        boolean bool = userFollowService.star(starOrVisitorReq);
        return R.ok(bool);
    }

    @PostMapping("/unstar")
    @Operation(summary = "取消关注用户")
    public R<Boolean> unStar(@RequestBody StarOrVisitorReq starOrVisitorReq){
        boolean bool = userFollowService.unStar(starOrVisitorReq);
        return R.ok(bool);
    }

    @GetMapping("/page")
    @Operation(summary = "关注、粉丝列表查询")
    public TableDataInfo<UserStarOrVisitorList> page(StarQuery query, PageQuery pageQuery){
        Page<UserStarOrVisitorList> res = userFollowService.pageApp(pageQuery,query);
        return TableDataInfo.build(res);
    }

}
