package com.sqx.modules.app.controller.app;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.app.entity.UserBrowse;
import com.sqx.modules.app.service.UserBrowseService;
import com.sqx.modules.resumes.entity.PostPush;
import com.sqx.modules.resumes.entity.Resumes;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@AllArgsConstructor
@RequestMapping("/app/userBrowse")
@Api(value = "浏览记录 ", tags = {"浏览记录"})
public class AppUserBrowseController {
    @Autowired
    private UserBrowseService userBrowseService;

    @ApiOperation("查询我的浏览记录V2")
    @Login
    @GetMapping("/selectMyBrowseV2")
    public Result selectMyBrowseV2(@RequestAttribute("userId") Long userId, Integer page, Integer limit, UserBrowse userBrowse, PostPush postPush) {
        userBrowse.setBrowseType(1);
        userBrowse.setUserId(userId);
        return Result.success().put("data", userBrowseService.selectMyBrowseV2(userId, page, limit, userBrowse, postPush));
    }

    @ApiOperation("查询我的浏览记录")
    @Login
    @GetMapping("/selectMyBrowse")
    public Result selectMyBrowse(@RequestAttribute("userId") Long userId, Integer page, Integer limit, UserBrowse userBrowse) {
        return Result.success().put("data", userBrowseService.selectMyBrowse(userId, page, limit, userBrowse));
    }

    @ApiOperation("企业查询我的浏览记录")
    @Login
    @GetMapping("/selectCompayBrowse")
    public Result selectCompayBrowse(@RequestAttribute("userId") Long userId, Integer page, Integer limit, UserBrowse userBrowse, Resumes resumes,String startTime,String endTime) {
        userBrowse.setUserId(userId);
        return Result.success().put("data", userBrowseService.selectCompanyBrowse(userId, page, limit, userBrowse, resumes, startTime, endTime));
    }

    @Login
    @ApiOperation("删除浏览记录")
    @GetMapping("/deleteBrowse")
    public Result deleteBrowse(Long id) {
        return userBrowseService.deleteMyBrowse(id);
    }

}
