package com.hotwj.platform.config.signAuditPermissionConfig.controller;

import com.hotwj.platform.config.signAuditPermissionConfig.domain.bo.HotSignAuditPermissionConfigBo;
import com.hotwj.platform.config.signAuditPermissionConfig.domain.vo.HotSignAuditPermissionConfigVo;
import com.hotwj.platform.config.signAuditPermissionConfig.service.IHotSignAuditPermissionConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
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-29
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/config/signAuditPermissionConfig")
@Tag(name = "签字审核权限配置", description = "签字审核权限配置管理")
public class HotSignAuditPermissionConfigController extends BaseController {

    private final IHotSignAuditPermissionConfigService hotSignAuditPermissionConfigService;

    /**
     * 查询签字审核权限配置列表
     */
    //@SaCheckPermission("config:signAuditPermissionConfig:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询签字审核权限配置列表")
    public TableDataInfo<HotSignAuditPermissionConfigVo> list(HotSignAuditPermissionConfigBo bo, PageQuery pageQuery) {
        return hotSignAuditPermissionConfigService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出签字审核权限配置列表
     */
    //@SaCheckPermission("config:signAuditPermissionConfig:export")
    @Log(title = "签字审核权限配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出签字审核权限配置列表")
    public void export(HotSignAuditPermissionConfigBo bo, HttpServletResponse response) {
        List<HotSignAuditPermissionConfigVo> list = hotSignAuditPermissionConfigService.queryList(bo);
        ExcelUtil.exportExcel(list, "签字审核权限配置", HotSignAuditPermissionConfigVo.class, response);
    }

    /**
     * 获取签字审核权限配置详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("config:signAuditPermissionConfig:query")
    @GetMapping("/{id}")
    @Operation(summary = "获取签字审核权限配置详细信息")
    public R<HotSignAuditPermissionConfigVo> getInfo(@NotNull(message = "主键不能为空")
                                                     @Parameter(name = "id", description = "主键", required = true, example = "1")
                                                     @PathVariable Long id) {
        return R.ok(hotSignAuditPermissionConfigService.queryById(id));
    }

    /**
     * 新增签字审核权限配置
     */
    //@SaCheckPermission("config:signAuditPermissionConfig:add")
    @Log(title = "签字审核权限配置", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增签字审核权限配置")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotSignAuditPermissionConfigBo bo) {
        return toAjax(hotSignAuditPermissionConfigService.insertByBo(bo));
    }

    /**
     * 修改签字审核权限配置
     */
    //@SaCheckPermission("config:signAuditPermissionConfig:edit")
    @Log(title = "签字审核权限配置", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改签字审核权限配置")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotSignAuditPermissionConfigBo bo) {
        return toAjax(hotSignAuditPermissionConfigService.updateByBo(bo));
    }

    /**
     * 删除签字审核权限配置
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("config:signAuditPermissionConfig:remove")
    @Log(title = "签字审核权限配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除签字审核权限配置")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @Parameter(name = "ids", description = "主键串", required = true, example = "1,2,3")
                          @PathVariable Long[] ids) {
        return toAjax(hotSignAuditPermissionConfigService.deleteWithValidByIds(List.of(ids), true));
    }
}
