package com.hotwj.platform.securityManagement.safetyInvestment.controller;

import com.hotwj.platform.securityManagement.safetyInvestment.domain.bo.HotSafetyInvestmentBo;
import com.hotwj.platform.securityManagement.safetyInvestment.domain.vo.HotSafetyInvestmentVo;
import com.hotwj.platform.securityManagement.safetyInvestment.service.IHotSafetyInvestmentService;
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-17
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/securityManagement/safetyInvestment")
@Tag(name = "安全生产投入", description = "安全生产投入管理")
public class HotSafetyInvestmentController extends BaseController {

    private final IHotSafetyInvestmentService hotSafetyInvestmentService;

    /**
     * 查询安全生产投入列表
     */
    //@SaCheckPermission("securityManagement:safetyInvestment:list")
    @GetMapping("/list")
    @Operation(summary = "查询安全生产投入列表")
    public TableDataInfo<HotSafetyInvestmentVo> list(HotSafetyInvestmentBo bo, PageQuery pageQuery) {
        return hotSafetyInvestmentService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出安全生产投入列表
     */
    //@SaCheckPermission("securityManagement:safetyInvestment:export")
    @Log(title = "安全生产投入", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出安全生产投入列表")
    public void export(HotSafetyInvestmentBo bo, HttpServletResponse response) {
        List<HotSafetyInvestmentVo> list = hotSafetyInvestmentService.queryList(bo);
        ExcelUtil.exportExcel(list, "安全生产投入", HotSafetyInvestmentVo.class, response);
    }

    /**
     * 获取安全生产投入详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("securityManagement:safetyInvestment:query")
    @GetMapping("/{id}")
    @Operation(summary = "获取安全生产投入详细信息")
    public R<HotSafetyInvestmentVo> getInfo(@NotNull(message = "主键不能为空")
                                            @PathVariable Long id) {
        return R.ok(hotSafetyInvestmentService.queryById(id));
    }

    /**
     * 新增安全生产投入
     */
    //@SaCheckPermission("securityManagement:safetyInvestment:add")
    @Log(title = "安全生产投入", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增安全生产投入")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotSafetyInvestmentBo bo) {
        return toAjax(hotSafetyInvestmentService.insertByBo(bo));
    }

    /**
     * 修改安全生产投入
     */
    //@SaCheckPermission("securityManagement:safetyInvestment:edit")
    @Log(title = "安全生产投入", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改安全生产投入")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotSafetyInvestmentBo bo) {
        return toAjax(hotSafetyInvestmentService.updateByBo(bo));
    }

    /**
     * 删除安全生产投入
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("securityManagement:safetyInvestment:remove")
    @Log(title = "安全生产投入", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除安全生产投入")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(hotSafetyInvestmentService.deleteWithValidByIds(List.of(ids), true));
    }
}
