package com.ruoyi.controller;

import com.ruoyi.annotations.UserLoginToken;
import com.ruoyi.controller.req.CollectObjectReq;
import com.ruoyi.controller.req.CollectPageReq;
import com.ruoyi.frequency.collect.service.CollectService;
import com.ruoyi.response.ResponseData;
import com.ruoyi.vo.RyController;
import com.ruoyi.vo.UserVo;
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/collect")
@Api(tags = "收藏")
public class ApiCollectController extends RyController {

    @Autowired
    private CollectService collectService;

    @PostMapping("/collectObject")
    @UserLoginToken
    @ApiOperation(value = "收藏", notes = "收藏")
    public ResponseData collectObject(@Valid @RequestBody CollectObjectReq req) {
        return collectService.collectObject(req, getUserVo());
    }


    @PostMapping("/collectPage")
    @ApiOperation(value = "收藏列表", notes = "收藏列表")
    @UserLoginToken
    public ResponseData collectPage(@RequestBody CollectPageReq req) {
        UserVo userVo = getUserVo();
        req.setUserId(userVo.getUserId());
        req.setUserType(userVo.getUserType());
        return collectService.collectPage(req, userVo);
    }

    @PostMapping("/otherCollectPage")
    @ApiOperation(value = "收藏列表(别人查看)", notes = "收藏列表(别人查看)")
    public ResponseData otherCollectPage(@RequestBody CollectPageReq req) {
        return collectService.otherCollectPage(req,getUserVo());
    }

}