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

import com.hotwj.platform.securityManagement.hiddenDanger.domain.bo.HotHiddenDangerReviewRecordBo;
import com.hotwj.platform.securityManagement.hiddenDanger.domain.vo.HotHiddenDangerReviewRecordVo;
import com.hotwj.platform.securityManagement.hiddenDanger.service.IHotHiddenDangerReviewRecordService;
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 2026-01-04
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/securityManagement/hiddenDangerReviewRecord")
@Tag(name = "隐患复查记录", description = "隐患复查记录管理")
public class HotHiddenDangerReviewRecordController extends BaseController {

    private final IHotHiddenDangerReviewRecordService reviewRecordService;

    /**
     * 查询隐患复查记录列表
     */
    //@SaCheckPermission("securityManagement:hiddenDangerReviewRecord:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询隐患复查记录列表")
    public TableDataInfo<HotHiddenDangerReviewRecordVo> list(HotHiddenDangerReviewRecordBo bo, PageQuery pageQuery) {
        return reviewRecordService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出隐患复查记录列表
     */
    //@SaCheckPermission("securityManagement:hiddenDangerReviewRecord:export")
    @Log(title = "隐患复查记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出隐患复查记录列表")
    public void export(HotHiddenDangerReviewRecordBo bo, HttpServletResponse response) {
        List<HotHiddenDangerReviewRecordVo> list = reviewRecordService.queryList(bo);
        ExcelUtil.exportExcel(list, "隐患复查记录", HotHiddenDangerReviewRecordVo.class, response);
    }

    /**
     * 获取隐患复查记录详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("securityManagement:hiddenDangerReviewRecord:query")
    @GetMapping("/{id}")
    @Operation(summary = "获取隐患复查记录详细信息")
    public R<HotHiddenDangerReviewRecordVo> getInfo(@NotNull(message = "主键不能为空")
                                                    @Parameter(name = "id", description = "主键", required = true, example = "1")
                                                    @PathVariable Long id) {
        return R.ok(reviewRecordService.queryById(id));
    }

    /**
     * 新增隐患复查记录
     */
    //@SaCheckPermission("securityManagement:hiddenDangerReviewRecord:add")
    @Log(title = "隐患复查记录", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增隐患复查记录")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotHiddenDangerReviewRecordBo bo) {
        return toAjax(reviewRecordService.insertByBo(bo));
    }

    /**
     * 修改隐患复查记录
     */
    //@SaCheckPermission("securityManagement:hiddenDangerReviewRecord:edit")
    @Log(title = "隐患复查记录", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改隐患复查记录")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotHiddenDangerReviewRecordBo bo) {
        return toAjax(reviewRecordService.updateByBo(bo));
    }

    /**
     * 删除隐患复查记录
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("securityManagement:hiddenDangerReviewRecord: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(reviewRecordService.deleteWithValidByIds(List.of(ids), true));
    }
}
