package com.hotwj.platform.noticeManagerment.noticeReply.controller;

import com.hotwj.platform.noticeManagerment.noticeReply.domain.bo.HotNoticeReplyBo;
import com.hotwj.platform.noticeManagerment.noticeReply.domain.vo.HotNoticeReplyVo;
import com.hotwj.platform.noticeManagerment.noticeReply.service.IHotNoticeReplyService;
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-02-05
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/noticeManagerment/noticeReply")
@Tag(name = "通知整改回复记录", description = "通知整改回复记录管理")
public class HotNoticeReplyController extends BaseController {

    private final IHotNoticeReplyService hotNoticeReplyService;

    /**
     * 查询通知整改回复记录列表
     */
    //@SaCheckPermission("noticeManagerment:noticeReply:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询通知整改回复记录列表")
    public TableDataInfo<HotNoticeReplyVo> list(HotNoticeReplyBo bo, PageQuery pageQuery) {
        return hotNoticeReplyService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出通知整改回复记录列表
     */
    //@SaCheckPermission("noticeManagerment:noticeReply:export")
    @Log(title = "通知整改回复记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出通知整改回复记录列表")
    public void export(HotNoticeReplyBo bo, HttpServletResponse response) {
        List<HotNoticeReplyVo> list = hotNoticeReplyService.queryList(bo);
        ExcelUtil.exportExcel(list, "通知整改回复记录", HotNoticeReplyVo.class, response);
    }

    /**
     * 获取通知整改回复记录详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("noticeManagerment:noticeReply:query")
    @GetMapping("/{id}")
    @Operation(summary = "获取通知整改回复记录详细信息")
    public R<HotNoticeReplyVo> getInfo(@NotNull(message = "主键不能为空")
                                       @Parameter(name = "id", description = "主键", required = true, example = "1")
                                       @PathVariable Long id) {
        return R.ok(hotNoticeReplyService.queryById(id));
    }

    /**
     * 新增通知整改回复记录
     */
    //@SaCheckPermission("noticeManagerment:noticeReply:add")
    @Log(title = "通知整改回复记录", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增通知整改回复记录")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotNoticeReplyBo bo) {
        return toAjax(hotNoticeReplyService.insertByBo(bo));
    }

    /**
     * 修改通知整改回复记录
     */
    //@SaCheckPermission("noticeManagerment:noticeReply:edit")
    @Log(title = "通知整改回复记录", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改通知整改回复记录")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotNoticeReplyBo bo) {
        return toAjax(hotNoticeReplyService.updateByBo(bo));
    }

    /**
     * 企业提交整改回复
     */
    //@SaCheckPermission("noticeManagerment:noticeReply:submit")
    @Log(title = "通知整改回复记录", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping("/submit")
    @Operation(summary = "企业提交整改回复")
    public R<Void> submit(@Validated(AddGroup.class) @RequestBody HotNoticeReplyBo bo) {
        return toAjax(hotNoticeReplyService.submitReply(bo));
    }

    /**
     * 政府审核整改回复
     */
    //@SaCheckPermission("noticeManagerment:noticeReply:audit")
    @Log(title = "通知整改回复记录", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PostMapping("/audit")
    @Operation(summary = "政府审核整改回复")
    public R<Void> audit(@Validated(EditGroup.class) @RequestBody HotNoticeReplyBo bo) {
        return toAjax(hotNoticeReplyService.auditReply(bo));
    }

    /**
     * 删除通知整改回复记录
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("noticeManagerment:noticeReply: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(hotNoticeReplyService.deleteWithValidByIds(List.of(ids), true));
    }
}
