package com.sqx.modules.sendRecord.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.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 com.sqx.modules.resumes.service.PostPushService;
import com.sqx.modules.sendRecord.entity.SendRecord;
import com.sqx.modules.sendRecord.service.SendRecordService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * <p>
 * 投递记录
 * </p>
 *
 * @author wuchang
 * @since 2023-02-02
 */
@RestController
@RequestMapping("/app/sendRecord/")
public class SendRecordController {

    @Autowired
    private SendRecordService recordService;
    @Autowired
    private SendRecordService sendRecordService;
    @Autowired
    private ChatConversationService chatConversationService;

    @Login
    @ApiOperation("新增一个投递")
    @PostMapping(value = "addSendRecord")
    public Result addSendRecord(@RequestAttribute("userId")Long userId,Long resumesId,Long postPushId){
        return  sendRecordService.addSendRecord(userId,postPushId);
    }
    @Login
    @ApiOperation("获取我的投递列表V2")
    @GetMapping(value = "getMyRecordListV2")
    public Result getMyRecordListV2(@RequestAttribute("userId") Long userId, Integer page, Integer limit, SendRecord sendRecord, PostPush postPush) {
        sendRecord.setUserId(userId);
        return Result.success().put("data", recordService.getMyRecordListV2(page, limit, sendRecord, postPush));
    }

    @Login
    @ApiOperation("获取我的投递列表")
    @GetMapping(value = "getMyRecordList")
    public Result getRecordList(@RequestAttribute("userId") Long userId, Integer page, Integer limit, SendRecord sendRecord) {
        sendRecord.setUserId(userId);
        return Result.success().put("data", recordService.getRecordList(page, limit, sendRecord));
    }

    @Login
    @ApiOperation("企业获取投递列表V2")
    @GetMapping(value = "getCompanyRecordListV2")
    public Result getCompanyRecordList(@RequestAttribute("userId") Long userId, Integer page, Integer limit, SendRecord sendRecord, Resumes resumes) {
        sendRecord.setCompanyUserId(userId);
        return Result.success().put("data", recordService.getCompanyRecordListV2(page, limit, sendRecord, resumes));
    }

    @Login
    @ApiOperation("企业获取投递列表")
    @GetMapping(value = "getCompanyRecordList")
    public Result getCompanyRecordList(@RequestAttribute("userId") Long userId, Integer page, Integer limit, SendRecord sendRecord) {
        sendRecord.setCompanyUserId(userId);
        return Result.success().put("data", recordService.getRecordList(page, limit, sendRecord));
    }

    @Login
    @ApiOperation("将面试记录设置为已读")
    @GetMapping(value = "seeRecord")
    public Result seeRecord(Long recordId) {
        return recordService.seeRecord(recordId);
    }
    @Login
    @ApiOperation("获取沟通过的岗位接口")
    @GetMapping("getConversationList") public Result getConversationList(@RequestAttribute("userId")Long userId, Integer page, Integer limit, ChatConversation chatConversation){
        chatConversation.setUserId(userId);
        return Result.success().put("data", chatConversationService.getConversationList(page, limit, chatConversation));
    }
}

