package com.yaoai.admin.dashboard;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.yaoai.admin.dashboard.dto.DashboardOverview;
import com.yaoai.admin.dashboard.dto.DashboardProviderStats;
import com.yaoai.admin.dashboard.dto.DashboardTaskStats;
import com.yaoai.admin.dashboard.dto.DashboardTrendPoint;
import com.yaoai.common.result.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin-api/dashboard")
@RequiredArgsConstructor
@SaCheckLogin(type = "admin")
public class DashboardController {

    private final DashboardService dashboardService;

    @GetMapping("/overview")
    public Result<DashboardOverview> overview() {
        return Result.ok(dashboardService.overview());
    }

    @GetMapping("/trends")
    public Result<List<DashboardTrendPoint>> trends(@RequestParam(defaultValue = "30") int days) {
        return Result.ok(dashboardService.trends(days));
    }

    @GetMapping("/tasks")
    public Result<List<DashboardTaskStats>> tasks() {
        return Result.ok(dashboardService.tasks());
    }

    @GetMapping("/providers")
    public Result<List<DashboardProviderStats>> providers() {
        return Result.ok(dashboardService.providers());
    }
}
