package com.hotwj.platform.regulationManagement.policyRevision.controller;

import com.hotwj.platform.regulationManagement.policyRevision.domain.bo.HotPolicyRevisionBo;
import com.hotwj.platform.regulationManagement.policyRevision.domain.vo.HotPolicyRevisionVo;
import com.hotwj.platform.regulationManagement.policyRevision.service.IHotPolicyRevisionService;
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-11
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/regulationManagement/policyRevision")
@Tag(name = "制度修正记录", description = "制度修正记录增删改查与导出")
public class HotPolicyRevisionController extends BaseController {

    private final IHotPolicyRevisionService hotPolicyRevisionService;

    /**
     * 查询制度修正记录列表
     */
    //@SaCheckPermission("regulationManagement:policyRevision:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询制度修正记录列表")
    public TableDataInfo<HotPolicyRevisionVo> list(HotPolicyRevisionBo bo, PageQuery pageQuery) {
        return hotPolicyRevisionService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出制度修正记录列表
     */
    //@SaCheckPermission("regulationManagement:policyRevision:export")
    @Log(title = "制度修正记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出制度修正记录列表")
    public void export(HotPolicyRevisionBo bo, HttpServletResponse response) {
        List<HotPolicyRevisionVo> list = hotPolicyRevisionService.queryList(bo);
        ExcelUtil.exportExcel(list, "制度修正记录", HotPolicyRevisionVo.class, response);
    }

    /**
     * 获取制度修正记录详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("regulationManagement:policyRevision:query")
    @GetMapping("/{id}")
    @Operation(summary = "查询制度修正记录详情")
    public R<HotPolicyRevisionVo> getInfo(@NotNull(message = "主键不能为空")
                                          @PathVariable Long id) {
        return R.ok(hotPolicyRevisionService.queryById(id));
    }

    /**
     * 新增制度修正记录
     */
    //@SaCheckPermission("regulationManagement:policyRevision:add")
    @Log(title = "制度修正记录", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增制度修正记录")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotPolicyRevisionBo bo) {
        return toAjax(hotPolicyRevisionService.insertByBo(bo));
    }

    /**
     * 修改制度修正记录
     */
    //@SaCheckPermission("regulationManagement:policyRevision:edit")
    @Log(title = "制度修正记录", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改制度修正记录")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotPolicyRevisionBo bo) {
        return toAjax(hotPolicyRevisionService.updateByBo(bo));
    }

    /**
     * 删除制度修正记录
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("regulationManagement:policyRevision:remove")
    @Log(title = "制度修正记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除制度修正记录")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(hotPolicyRevisionService.deleteWithValidByIds(List.of(ids), true));
    }
}
