package com.writeoff.module.dashboard.controller;

import com.writeoff.common.api.ApiResponse;
import com.writeoff.module.dashboard.service.OperationsDashboardService;
import com.writeoff.security.DataScopeType;
import com.writeoff.security.RequirePermission;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/operations/dashboard")
public class OperationsDashboardController {
    private final OperationsDashboardService operationsDashboardService;

    public OperationsDashboardController(OperationsDashboardService operationsDashboardService) {
        this.operationsDashboardService = operationsDashboardService;
    }

    @GetMapping
    @RequirePermission(value = "dashboard.read", dataScope = DataScopeType.TENANT, auditAction = "OPERATIONS_DASHBOARD_SUMMARY")
    public ApiResponse<Map<String, Object>> summary() {
        return ApiResponse.success(operationsDashboardService.summary());
    }
}
