package com.vetti.web.controller.hotake;

import com.vetti.common.annotation.Log;
import com.vetti.common.core.controller.BaseController;
import com.vetti.common.core.domain.R;
import com.vetti.common.core.page.TableWebDataInfo;
import com.vetti.common.enums.BusinessType;
import com.vetti.hotake.domain.HotakeReferenceCheck;
import com.vetti.hotake.domain.dto.VcDto.VcExperienceDto;
import com.vetti.hotake.service.IHotakeReferenceCheckService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 背景调查Controller
 *
 * @author vetti
 * @date 2026-01-29
 */
@Api(tags = "背景调查")
@RestController
@RequestMapping("/hotake/referenceCheck")
public class HotakeReferenceCheckController extends BaseController {
    @Autowired
    private IHotakeReferenceCheckService hotakeReferenceCheckService;

    /**
     * 查询背景调查列表
     */
    @ApiOperation("查询背景调查列表(分页)")
    @GetMapping("/getPagelist")
    public TableWebDataInfo<HotakeReferenceCheck> list(HotakeReferenceCheck hotakeReferenceCheck) {
        startPage();
        hotakeReferenceCheck.setCreateBy(getUsername());
        List<HotakeReferenceCheck> list = hotakeReferenceCheckService.selectHotakeReferenceCheckList(hotakeReferenceCheck);
        return getWebDataTable(list);
    }

    /**
     * 查询背景调查列表
     */
    @ApiOperation("查询背景调查列表(无分页)")
    @GetMapping("/getList")
    public R<List<HotakeReferenceCheck>> getList(HotakeReferenceCheck hotakeReferenceCheck) {
        hotakeReferenceCheck.setCreateBy(getUsername());
        List<HotakeReferenceCheck> list = hotakeReferenceCheckService.selectHotakeReferenceCheckList(hotakeReferenceCheck);
        return R.ok(list, "");
    }

    /**
     * 获取背景调查详细信息
     */
    @ApiOperation("获取背景调查详细信息")
    @GetMapping(value = "/{id}")
    public R<HotakeReferenceCheck> getInfo(@ApiParam("背景调查ID") @PathVariable("id") Integer id) {
        return R.ok(hotakeReferenceCheckService.selectHotakeReferenceCheckById(id), "");
    }

    /**
     * 新增背景调查
     */
    @ApiOperation("新增背景调查")
    @Log(title = "背景调查", businessType = BusinessType.INSERT)
    @PostMapping
    public R<HotakeReferenceCheck> add(@RequestBody HotakeReferenceCheck hotakeReferenceCheck) {
        return R.ok(hotakeReferenceCheckService.insertHotakeReferenceCheck(hotakeReferenceCheck));
    }

    /**
     * 批量新增背景调查
     */
    @ApiOperation("批量新增背景调查")
    @Log(title = "背景调查", businessType = BusinessType.INSERT)
    @PostMapping("/batch")
    public R<Integer> batchAdd(@RequestBody List<HotakeReferenceCheck> hotakeReferenceCheckList) {
        int count = hotakeReferenceCheckService.batchInsertHotakeReferenceCheck(hotakeReferenceCheckList);
        return R.ok(count);
    }

    /**
     * 修改背景调查
     */
    @ApiOperation("修改背景调查")
    @Log(title = "背景调查", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<HotakeReferenceCheck> edit(@RequestBody HotakeReferenceCheck hotakeReferenceCheck) {
        return R.ok(hotakeReferenceCheckService.updateHotakeReferenceCheck(hotakeReferenceCheck));
    }

    /**
     * 删除背景调查
     */
    @ApiOperation("删除背景调查")
    @Log(title = "背景调查", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public R remove(@PathVariable Integer id) {
        return R.ok(hotakeReferenceCheckService.deleteHotakeReferenceCheckById(id));
    }

    /**
     * 获取当前登录人的工作经验列表
     */
    @ApiOperation("获取当前登录人的工作经验列表")
    @GetMapping("/getExperienceList")
    public R<List<VcExperienceDto>> getExperienceList() {
        return R.ok(hotakeReferenceCheckService.getCurrentUserExperienceList(), "");
    }

}
