package com.vetti.web.controller.hotake;

import cn.hutool.core.collection.CollectionUtil;
import com.vetti.common.annotation.Log;
import com.vetti.common.core.controller.BaseController;
import com.vetti.common.core.domain.AjaxResult;
import com.vetti.common.core.domain.R;
import com.vetti.common.core.page.TableWebDataInfo;
import com.vetti.common.enums.BusinessType;
import com.vetti.common.utils.SecurityUtils;
import com.vetti.hotake.domain.HotakeRolesInfo;
import com.vetti.hotake.domain.dto.HotakeRolesInfoDto;
import com.vetti.hotake.service.IHotakeRolesInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 岗位信息Controller
 * 
 * @author wangxiangshun
 * @date 2025-12-11
 */
@Api(tags ="岗位信息")
@RestController
@RequestMapping("/hotake/rolesInfo")
public class HotakeRolesInfoController extends BaseController
{
    @Autowired
    private IHotakeRolesInfoService hotakeRolesInfoService;

    /**
     * 查询岗位信息列表
     */
    @ApiOperation("查询岗位信息列表")
    @GetMapping("/getPageList")
    public TableWebDataInfo<HotakeRolesInfo> listPage(HotakeRolesInfo hotakeRolesInfo)
    {
        hotakeRolesInfo.setRecruiterId(SecurityUtils.getUserId());
        startPage();
        List<HotakeRolesInfo> list = hotakeRolesInfoService.selectHotakeRolesInfoList(hotakeRolesInfo);
        return getWebDataTable(list);
    }

    /**
     * 查询岗位信息列表(无分页)
     */
    @ApiOperation("查询岗位信息列表(无分页)")
    @GetMapping("/getList")
    public R<List<HotakeRolesInfo>> list(HotakeRolesInfo hotakeRolesInfo)
    {
        hotakeRolesInfo.setRecruiterId(SecurityUtils.getUserId());
        List<HotakeRolesInfo> list = hotakeRolesInfoService.selectHotakeRolesInfoList(hotakeRolesInfo);
        return R.ok(list,"");
    }


    /**
     * 查询岗位信息列表
     */
    @ApiOperation("查询岗位信息列表(首页)")
    @GetMapping("/home/getPageList")
    public TableWebDataInfo<HotakeRolesInfo> listHomePage(HotakeRolesInfo hotakeRolesInfo)
    {
        startPage();
        List<HotakeRolesInfo> list = hotakeRolesInfoService.selectHotakeRolesInfoList(hotakeRolesInfo);
        return getWebDataTable(list);
    }

    /**
     * 查询岗位信息列表(无分页)
     */
    @ApiOperation("查询岗位信息列表(无分页-首页)")
    @GetMapping("/home/getList")
    public R<List<HotakeRolesInfo>> listHome(HotakeRolesInfo hotakeRolesInfo)
    {
        List<HotakeRolesInfo> list = hotakeRolesInfoService.selectHotakeRolesInfoList(hotakeRolesInfo);
        return R.ok(list,"");
    }


    /**
     * 获取岗位信息详细信息
     */
    @ApiOperation("获取岗位信息详细信息")
    @GetMapping(value = "/{id}")
    public R<HotakeRolesInfoDto> getInfo(@PathVariable("id") Long id)
    {
        return R.ok(hotakeRolesInfoService.selectHotakeRolesInfoDtoById(id),"");
    }

    /**
     * 新增岗位信息
     */
    @ApiOperation("新增岗位信息")
    @Log(title = "岗位信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotakeRolesInfo hotakeRolesInfo)
    {
        return toAjax(hotakeRolesInfoService.insertHotakeRolesInfo(hotakeRolesInfo));
    }

    /**
     * 修改岗位信息
     */
    @ApiOperation("修改岗位信息")
    @Log(title = "岗位信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotakeRolesInfo hotakeRolesInfo)
    {
        return toAjax(hotakeRolesInfoService.updateHotakeRolesInfo(hotakeRolesInfo));
    }

    /**
     * 删除岗位信息
     */
    @ApiOperation("删除岗位信息")
    @Log(title = "岗位信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public R<?> remove(@PathVariable Long[] ids)
    {
        return R.ok(hotakeRolesInfoService.deleteHotakeRolesInfoByIds(ids));
    }

    /**
     * 保存岗位信息
     */
    @ApiOperation("保存岗位信息")
    @Log(title = "保存岗位信息", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    public R<HotakeRolesInfoDto> save(@RequestBody HotakeRolesInfoDto hotakeRolesInfo)
    {
        return R.ok(hotakeRolesInfoService.saveHotakeRolesInfo(hotakeRolesInfo));
    }

    /**
     * 获取岗位信息详细信息(UUID)
     */
    @ApiOperation("获取岗位信息详细信息(UUID)")
    @GetMapping(value = "/interview/{uuid}")
    public R<HotakeRolesInfoDto> getInfoUuid(@PathVariable("uuid") String uuid)
    {
        HotakeRolesInfo query = new HotakeRolesInfo();
        query.setUuid(uuid);
        List<HotakeRolesInfo> list = hotakeRolesInfoService.selectHotakeRolesInfoList(query);
        Long id = 0L;
        if(CollectionUtil.isNotEmpty(list)){
            id = list.get(0).getId();
        }
        return R.ok(hotakeRolesInfoService.selectHotakeRolesInfoDtoById(id),"");
    }

}
