package com.ruoyi.controller;

import com.ruoyi.annotations.UserLoginToken;
import com.ruoyi.controller.req.CollectPageReq;
import com.ruoyi.frequency.browserecord.service.BrowseRecordService;
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.*;

/**
 * 浏览记录
 */
@CrossOrigin
@RestController
@RequestMapping("/api/browse")
@Api(tags = "浏览记录")
public class ApiBrowserController extends RyController {

    @Autowired
    private BrowseRecordService browseRecordService;


    @PostMapping("/browsePage")
    @ApiOperation(value = "浏览列表", notes = "浏览列表")
    @UserLoginToken
    public ResponseData browsePage(@RequestBody CollectPageReq req) {
        UserVo userVo = getUserVo();
        req.setUserId(userVo.getUserId());
        req.setUserType(userVo.getUserType());
        return browseRecordService.browsePage(req, userVo);
    }

    @PostMapping("/otherBrowsePage")
    @ApiOperation(value = "浏览列表(别人查看)", notes = "浏览列表(别人查看)")
    public ResponseData otherBrowsePage(@RequestBody CollectPageReq req) {
        return browseRecordService.otherBrowsePage(req,getUserVo());
    }

}