package com.mcwl.web.controller.resource;

import com.github.pagehelper.PageInfo;
import com.mcwl.common.annotation.RepeatSubmit;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.resource.domain.SysUserInfo;
import com.mcwl.resource.domain.vo.PageVo;
import com.mcwl.resource.service.SysUserAttentionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 关注
 * @author DaiZibo
 * @date 2025/1/3
 * @apiNote
 */
@Api(tags = "关注")
@RequestMapping("/attention")
@RestController
public class SysUserAttentionController {

    @Autowired
    private SysUserAttentionService sysUserAttentionService;

    /**
     * 添加/取消关注
     * @param userId
     * @return
     */
    @ApiOperation(value = "添加/取消关注")
    @RepeatSubmit
    @GetMapping("/addAttention")
    public R addAttention(@RequestParam Long userId) {

        return sysUserAttentionService.addAttention(userId);

    }

    /**
     *查询是否关注用户
     * @param userId
     * @return
     */
    @ApiOperation(value = "查询是否关注用户")
    @GetMapping("/selectAttention")
    public R<Boolean> selectAttention(@RequestParam Long userId) {

        Boolean aBoolean = sysUserAttentionService.selectAttention(userId);

        return R.ok(aBoolean);
    }

    /**
     * 查询个人粉丝，关注，下载量，喜欢
     * @return
     */
    @ApiOperation(value = "查询个人粉丝，关注，下载量，喜欢")
    @GetMapping("/selectUserInfo")
    public R<SysUserInfo> selectUserInfo(Long userId){

        SysUserInfo sysUserInfo = sysUserAttentionService.selectUserInfo(userId);

        return R.ok(sysUserInfo);
    }


    /**
     * 查看关注列表
     * @return
     */
    @ApiOperation(value = "查询关注列表")
    @PostMapping("/selectAttentionList")
    public R<PageInfo<SysUser>> selectAttentionList(@RequestBody PageVo pageVo){

        PageInfo<SysUser> sysUserList = sysUserAttentionService.selectAttentionPage(pageVo);

        return R.ok(sysUserList);
    }


    /**
     * 查看关注列表
     * @return
     */
    @ApiOperation(value = "查询粉丝列表")
    @PostMapping("/selectToAttention")
    public R<PageInfo<SysUser>> selectToAttention(@RequestBody PageVo pageVo){

        PageInfo<SysUser> sysUserList = sysUserAttentionService.selectToAttentionPage(pageVo);

        return R.ok(sysUserList);
    }
}
