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

import com.hotwj.platform.resourceManagement.companyInsurance.domain.bo.HotCompanyInsuranceBo;
import com.hotwj.platform.resourceManagement.companyInsurance.domain.vo.HotCompanyInsuranceVo;
import com.hotwj.platform.resourceManagement.companyInsurance.service.IHotCompanyInsuranceService;
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/companyInsurance")
@Tag(name = "公司企业保险信息", description = "公司企业保险信息增删改查")
public class HotCompanyInsuranceController extends BaseController {

    private final IHotCompanyInsuranceService hotCompanyInsuranceService;

    /**
     * 查询公司企业保险信息列表
     */
    //@SaCheckPermission("resourceManagement:companyInsurance:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询公司企业保险信息列表")
    public TableDataInfo<HotCompanyInsuranceVo> list(HotCompanyInsuranceBo bo, PageQuery pageQuery) {
        return hotCompanyInsuranceService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出公司企业保险信息列表
     */
    //@SaCheckPermission("resourceManagement:companyInsurance:export")
    @Log(title = "公司企业保险信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出公司企业保险信息列表")
    public void export(HotCompanyInsuranceBo bo, HttpServletResponse response) {
        List<HotCompanyInsuranceVo> list = hotCompanyInsuranceService.queryList(bo);
        ExcelUtil.exportExcel(list, "公司企业保险信息", HotCompanyInsuranceVo.class, response);
    }

    /**
     * 获取公司企业保险信息详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("resourceManagement:companyInsurance:query")
    @GetMapping("/{id}")
    @Operation(summary = "查询公司企业保险信息详情")
    public R<HotCompanyInsuranceVo> getInfo(@NotNull(message = "主键不能为空")
                                            @PathVariable Long id) {
        return R.ok(hotCompanyInsuranceService.queryById(id));
    }

    /**
     * 新增公司企业保险信息
     */
    //@SaCheckPermission("resourceManagement:companyInsurance:add")
    @Log(title = "公司企业保险信息", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增公司企业保险信息")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotCompanyInsuranceBo bo) {
        return toAjax(hotCompanyInsuranceService.insertByBo(bo));
    }

    /**
     * 修改公司企业保险信息
     */
    //@SaCheckPermission("resourceManagement:companyInsurance:edit")
    @Log(title = "公司企业保险信息", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改公司企业保险信息")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotCompanyInsuranceBo bo) {
        return toAjax(hotCompanyInsuranceService.updateByBo(bo));
    }

    /**
     * 删除公司企业保险信息
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("resourceManagement:companyInsurance:remove")
    @Log(title = "公司企业保险信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除公司企业保险信息")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(hotCompanyInsuranceService.deleteWithValidByIds(List.of(ids), true));
    }
}
