package me.zhengjie.modules.system.rest;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.system.domain.dto.DashboardDataVo;
import me.zhengjie.modules.system.service.DashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
* @author Tz
* @date 2025-05-07
*/
@RestController
@RequiredArgsConstructor
@Api(tags = "系统：可视化")
@RequestMapping("/api/dashboard")
public class DashboardController {

    @Autowired
    private DashboardService dashboardService;

    @ApiOperation("卡片数据")
    @GetMapping("/cardData")
    public ResponseEntity<Map<String, Object>> getCardData() {
        Map<String, Object> data = dashboardService.getCardData();
        return new ResponseEntity<>(data, HttpStatus.OK);
    }

    @ApiOperation("折线图数据")
    @GetMapping("/lineChartData")
    public ResponseEntity<List<Integer>> getLineChartData(String type) {
        List<Integer> data = dashboardService.getLineChartData(type);
        return new ResponseEntity<>(data, HttpStatus.OK);
    }

    @ApiOperation("扇形数据")
    @GetMapping("/pieChatData")
    public ResponseEntity<List<DashboardDataVo>> getPieChatData() {
        List<DashboardDataVo> data = dashboardService.getPieChatData();
        return new ResponseEntity<>(data, HttpStatus.OK);
    }
}













































































































































































