package com.hotwj.platform.resourceManagement.companyLaborContract.controller;

import com.hotwj.platform.resourceManagement.companyLaborContract.domain.bo.HotCompanyLaborContractBo;
import com.hotwj.platform.resourceManagement.companyLaborContract.domain.vo.HotCompanyLaborContractVo;
import com.hotwj.platform.resourceManagement.companyLaborContract.service.IHotCompanyLaborContractService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公司劳动合同
 *
 * @author shihongwei
 * @date 2025-12-10
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/resourceManagement/companyLaborContract")
@Tag(name = "公司劳动合同", description = "公司劳动合同增删改查")
public class HotCompanyLaborContractController extends BaseController {

    private final IHotCompanyLaborContractService hotCompanyLaborContractService;

    /**
     * 查询公司劳动合同列表
     */
    //@SaCheckPermission("resourceManagement:companyLaborContract:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询公司劳动合同列表")
    public TableDataInfo<HotCompanyLaborContractVo> list(HotCompanyLaborContractBo bo, PageQuery pageQuery) {
        return hotCompanyLaborContractService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出公司劳动合同列表
     */
    //@SaCheckPermission("resourceManagement:companyLaborContract:export")
    @Log(title = "公司劳动合同", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出公司劳动合同列表")
    public void export(HotCompanyLaborContractBo bo, HttpServletResponse response) {
        List<HotCompanyLaborContractVo> list = hotCompanyLaborContractService.queryList(bo);
        ExcelUtil.exportExcel(list, "公司劳动合同", HotCompanyLaborContractVo.class, response);
    }

    /**
     * 获取公司劳动合同详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("resourceManagement:companyLaborContract:query")
    @GetMapping("/{id}")
    @Operation(summary = "查询公司劳动合同详情")
    public R<HotCompanyLaborContractVo> getInfo(@NotNull(message = "主键不能为空")
                                                @PathVariable Long id) {
        return R.ok(hotCompanyLaborContractService.queryById(id));
    }

    /**
     * 新增公司劳动合同
     */
    //@SaCheckPermission("resourceManagement:companyLaborContract:add")
    @Log(title = "公司劳动合同", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增公司劳动合同")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotCompanyLaborContractBo bo) {
        return toAjax(hotCompanyLaborContractService.insertByBo(bo));
    }

    /**
     * 修改公司劳动合同
     */
    //@SaCheckPermission("resourceManagement:companyLaborContract:edit")
    @Log(title = "公司劳动合同", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改公司劳动合同")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotCompanyLaborContractBo bo) {
        return toAjax(hotCompanyLaborContractService.updateByBo(bo));
    }

    /**
     * 删除公司劳动合同
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("resourceManagement:companyLaborContract:remove")
    @Log(title = "公司劳动合同", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除公司劳动合同")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(hotCompanyLaborContractService.deleteWithValidByIds(List.of(ids), true));
    }
}
