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

import com.hotwj.platform.noticeManagerment.adminNotice.domain.bo.HotAdminNoticeBo;
import com.hotwj.platform.noticeManagerment.adminNotice.domain.vo.HotAdminNoticeVo;
import com.hotwj.platform.noticeManagerment.adminNotice.service.IHotAdminNoticeService;
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-13
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/noticeManagerment/adminNotice")
@Tag(name = "行管通知", description = "行管通知管理")
public class HotAdminNoticeController extends BaseController {

    private final IHotAdminNoticeService hotAdminNoticeService;

    /**
     * 查询行管通知列表
     */
    //@SaCheckPermission("noticeManagerment:adminNotice:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询行管通知列表")
    public TableDataInfo<HotAdminNoticeVo> list(HotAdminNoticeBo bo, PageQuery pageQuery) {
        return hotAdminNoticeService.queryPageList(bo, pageQuery);
    }

    /**
     * 查询通知收到情况列表
     */
    //@SaCheckPermission("noticeManagerment:adminNotice:list")
    @GetMapping("/receiptStatusList")
    @Operation(summary = "分页查询通知收到情况列表")
    public TableDataInfo<HotAdminNoticeVo> receiptStatusList(HotAdminNoticeBo bo, PageQuery pageQuery) {
        return hotAdminNoticeService.queryReceiptStatusList(bo, pageQuery);
    }

    /**
     * 导出行管通知列表
     */
    //@SaCheckPermission("noticeManagerment:adminNotice:export")
    @Log(title = "行管通知", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出行管通知列表")
    public void export(HotAdminNoticeBo bo, HttpServletResponse response) {
        List<HotAdminNoticeVo> list = hotAdminNoticeService.queryList(bo);
        ExcelUtil.exportExcel(list, "行管通知", HotAdminNoticeVo.class, response);
    }

    /**
     * 获取行管通知详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("noticeManagerment:adminNotice:query")
    @GetMapping("/{id}")
    @Operation(summary = "获取行管通知详细信息")
    public R<HotAdminNoticeVo> getInfo(@NotNull(message = "主键不能为空")
                                       @Parameter(name = "id", description = "主键", required = true, example = "1")
                                       @PathVariable Long id) {
        return R.ok(hotAdminNoticeService.queryById(id));
    }

    /**
     * 新增行管通知
     */
    //@SaCheckPermission("noticeManagerment:adminNotice:add")
    @Log(title = "行管通知", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增行管通知")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotAdminNoticeBo bo) {
        return toAjax(hotAdminNoticeService.insertByBo(bo));
    }

    /**
     * 修改行管通知
     */
    //@SaCheckPermission("noticeManagerment:adminNotice:edit")
    @Log(title = "行管通知", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改行管通知")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotAdminNoticeBo bo) {
        return toAjax(hotAdminNoticeService.updateByBo(bo));
    }

    /**
     * 删除行管通知
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("noticeManagerment:adminNotice: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(hotAdminNoticeService.deleteWithValidByIds(List.of(ids), true));
    }
}
