package com.ruoyi.system.controller;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.EpsInitialTrafficData;
import com.ruoyi.system.service.EpsInitialTrafficDataService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * EPS初始流量数据控制器
 * 提供流量数据的REST接口
 */
@RestController
@RequestMapping("/epsTrafficData")
@RequiredArgsConstructor
public class EpsInitialTrafficDataController {

    private final EpsInitialTrafficDataService epsInitialTrafficDataService;

    /**
     * 保存单条流量数据
     * @param data 流量数据实体
     * @return 操作结果
     */
    @PostMapping
    public ResponseEntity<Void> save(@RequestBody EpsInitialTrafficData data) {
        epsInitialTrafficDataService.save(data);
        return ResponseEntity.ok().build();
    }

    /**
     * 批量保存流量数据
     * @param dataList 流量数据表
     * @return 操作结果
     */
    @PostMapping("/batch")
    public ResponseEntity<Void> saveBatch(@RequestBody EpsInitialTrafficData dataList) {
        epsInitialTrafficDataService.saveBatch(dataList);
        return ResponseEntity.ok().build();
    }
    /**
     * 查询流量数据（POST方式）
     * @param queryParam 查询参数实体
     * @return 流量数据列表
     */
    @PostMapping("/query")
    public ResponseEntity<List<EpsInitialTrafficData>> query(@RequestBody EpsInitialTrafficData queryParam) {
        List<EpsInitialTrafficData> result = epsInitialTrafficDataService.query(queryParam);
        return ResponseEntity.ok(result);
    }

    /**
     * 图形分析 - 95值/日
     * @return
     */
    @RequiresPermissions("system:bandwidth:list")
    @PostMapping("/getServerGraphicalAnalysisDaily")
    public AjaxResult getServerGraphicalAnalysisDaily(@RequestBody EpsInitialTrafficData queryParam){
        List<Map<String, Object>> echartsData = epsInitialTrafficDataService.getServerGraphicalAnalysisDaily(queryParam);
        return AjaxResult.success(echartsData);
    }
    /**
     * 图形分析 - 95值/日
     * @return
     */
    @RequiresPermissions("system:bandwidth:list")
    @PostMapping("/getServerGraphicalAnalysisMonthy")
    public AjaxResult getServerGraphicalAnalysisMonthy(@RequestBody EpsInitialTrafficData queryParam){
        List<Map<String, Object>> echartsData = epsInitialTrafficDataService.getServerGraphicalAnalysisMonthy(queryParam);
        return AjaxResult.success(echartsData);
    }
}