package com.ruoyi.web.work.api;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.web.work.api.config.BaseController;
import com.ruoyi.web.work.domain.ResumeDeliver;
import com.ruoyi.web.work.domain.dto.ResumeDeliverDto;
import com.ruoyi.web.work.domain.dto.ResumeInviteDto;
import com.ruoyi.web.work.domain.vo.ReceiveListVo;
import com.ruoyi.web.work.domain.vo.ReceiveVo;
import com.ruoyi.web.work.service.IResumeDeliverService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

/**
 * 简历投递
 *
 * @author lsw
 * @date 2024-06-13
 */
@RestController
@RequestMapping("/app/deliver")
public class Api_ResumeDeliverController extends BaseController {
    @Autowired
    private IResumeDeliverService resumeDeliverService;

    @GetMapping("/user/list")
    public TableDataInfo userList(ResumeDeliver resumeDeliver) {
        resumeDeliver.setUserId(getUser().getId());
        startPage();
        List<ResumeDeliver> list = resumeDeliverService.selectList(resumeDeliver);
        return getDataTable(list);
    }

    @GetMapping("/position/list")
    public TableDataInfo positionList(ResumeDeliver resumeDeliver) {
        resumeDeliver.setEnterpriseId(getUser().getId());
        startPage();
        List<ResumeDeliver> list = resumeDeliverService.selectList(resumeDeliver);
        return getDataTable(list);
    }

    @GetMapping("/receive")
    public TableDataInfo userList() {
        startPage();
        List<ReceiveVo> list = resumeDeliverService.receive(getUser().getId());
        return getDataTable(list);
    }

    @GetMapping("/receive/list")
    public TableDataInfo receiveList(ResumeDeliver resumeDeliver) {
        resumeDeliver.setEnterpriseId(getUser().getId());
        startPage();
        List<ReceiveListVo> list = resumeDeliverService.receiveList(resumeDeliver);
        return getDataTable(list);
    }

    @GetMapping("/detail/{id}")
    public AjaxResult detail(@PathVariable("id") Long id) {
        return resumeDeliverService.detail(id);
    }

    @PostMapping("/invite")
    public AjaxResult invite(@Validated @RequestBody ResumeInviteDto dto) throws ParseException {
        return resumeDeliverService.invite(dto);
    }

    @GetMapping("/remove/{id}")
    public AjaxResult remove(@PathVariable("id") Long id) {
        return resumeDeliverService.remove(id);
    }

    @GetMapping("/send/{id}")
    public AjaxResult send(@PathVariable("id") Long id) {
        return resumeDeliverService.send(id);
    }

    @GetMapping("/complete/{id}")
    public AjaxResult complete(@PathVariable("id") Long id) {
        return resumeDeliverService.complete(id);
    }

    @PostMapping("/agree")
    public AjaxResult agree(@Validated @RequestBody ResumeDeliverDto dto) {
        return resumeDeliverService.agree(dto);
    }
}
