package org.jk.rag.controller;

import java.util.List;

import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.jk.common.excel.utils.ExcelUtil;
import org.jk.rag.domain.bo.ServerNetDownloadMonitorBo;
import org.jk.rag.domain.vo.ServerNetDownloadMonitorVo;
import org.jk.rag.service.IServerNetDownloadMonitorService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.jk.common.idempotent.annotation.RepeatSubmit;
import org.jk.common.log.annotation.Log;
import org.jk.common.web.core.BaseController;
import org.jk.common.mybatis.core.page.PageQuery;
import org.jk.common.core.domain.R;
import org.jk.common.core.validate.AddGroup;
import org.jk.common.core.validate.EditGroup;
import org.jk.common.log.enums.BusinessType;
import org.jk.common.mybatis.core.page.TableDataInfo;

/**
 * 服务器网络下行状态监控-独立
 *
 * @author Lion Li
 * @date 2026-01-19
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/netDownloadMonitor")
public class ServerNetDownloadMonitorController extends BaseController {

    private final IServerNetDownloadMonitorService serverNetDownloadMonitorService;

    /**
     * 查询服务器网络下行状态监控-独立列表
     */
    //@SaCheckPermission("system:netDownloadMonitor:list")
    @GetMapping("/list")
    public TableDataInfo<ServerNetDownloadMonitorVo> list(ServerNetDownloadMonitorBo bo, PageQuery pageQuery) {
        return serverNetDownloadMonitorService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出服务器网络下行状态监控-独立列表
     */
    //@SaCheckPermission("system:netDownloadMonitor:export")
    @Log(title = "服务器网络下行状态监控-独立", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(ServerNetDownloadMonitorBo bo, HttpServletResponse response) {
        List<ServerNetDownloadMonitorVo> list = serverNetDownloadMonitorService.queryList(bo);
        ExcelUtil.exportExcel(list, "服务器网络下行状态监控-独立", ServerNetDownloadMonitorVo.class, response);
    }

    /**
     * 获取服务器网络下行状态监控-独立详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("system:netDownloadMonitor:query")
    @GetMapping("/{id}")
    public R<ServerNetDownloadMonitorVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(serverNetDownloadMonitorService.queryById(id));
    }

    /**
     * 新增服务器网络下行状态监控-独立
     */
    //@SaCheckPermission("system:netDownloadMonitor:add")
    @Log(title = "服务器网络下行状态监控-独立", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody ServerNetDownloadMonitorBo bo) {
        return toAjax(serverNetDownloadMonitorService.insertByBo(bo));
    }

    /**
     * 修改服务器网络下行状态监控-独立
     */
    //@SaCheckPermission("system:netDownloadMonitor:edit")
    @Log(title = "服务器网络下行状态监控-独立", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody ServerNetDownloadMonitorBo bo) {
        return toAjax(serverNetDownloadMonitorService.updateByBo(bo));
    }

    /**
     * 删除服务器网络下行状态监控-独立
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("system:netDownloadMonitor:remove")
    @Log(title = "服务器网络下行状态监控-独立", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(serverNetDownloadMonitorService.deleteWithValidByIds(List.of(ids), true));
    }
}
