package com.sqx.modules.app.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.chat.entity.ChatConversation;
import com.sqx.modules.chat.service.ChatConversationService;
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("/admin/userBrowse")
@Api(value = "访客|浏览", tags = {"访客|浏览"})
public class UserBrowseController {
    @Autowired
    private UserBrowseService userBrowseService;
    @Autowired
    private ChatConversationService chatConversationService;

    @ApiOperation("查询我的浏览记录")
    @GetMapping("/selectMyBrowseV2")
    public Result selectMyBrowseV2(Long userId, Integer page, Integer limit, UserBrowse userBrowse, PostPush postPush) {
        return Result.success().put("data", userBrowseService.selectMyBrowseV2(userId, page, limit, userBrowse, postPush));
    }
    @Login
    @ApiOperation("查询我的浏览记录")
    @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("删除浏览记录")
    @GetMapping("/deleteBrowse")
    public Result deleteBrowse(Long id) {
        return userBrowseService.deleteMyBrowse(id);
    }


    @ApiOperation("企业查询我的浏览记录")
    @GetMapping("/selectCompayBrowse")
    public Result selectCompayBrowse( 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));
    }

    @ApiOperation("根据招聘信息查看浏览用户")
    @GetMapping("/getUserByBrowse")
    private Result getUserByBrowse(Integer page, Integer limit,Long postPushId){
        return Result.success().put("data", userBrowseService.getUserByBrowse(page,limit,postPushId));
    }
    @ApiOperation("根据招聘信息删除浏览记录")
    @GetMapping("/deleteUserByBrowse")
    private Result deleteUserByBrowse(Long postPushId){
        return userBrowseService.remove(new QueryWrapper<UserBrowse>().eq("post_push_id", postPushId)) ? Result.success():Result.error();
    }
}
