package com.zioinfo.mes.dashboard;

import com.zioinfo.mes.common.ApiResponse;
import com.zioinfo.mes.dashboard.mapper.DashboardMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * MES 대시보드 API — 실시간 생산·재고·품질·설비·출하 요약(조회 Viewer+).
 */
@RestController
@RequestMapping("/api/mes/dashboard")
@RequiredArgsConstructor
public class DashboardController {

    private final DashboardMapper mapper;

    @GetMapping("/summary")
    public ApiResponse<Map<String, Object>> summary() {
        return ApiResponse.ok(mapper.summary());
    }

    @GetMapping("/workorder-status")
    public ApiResponse<List<Map<String, Object>>> workorderStatus() {
        return ApiResponse.ok(mapper.workorderByStatus());
    }

    @GetMapping("/shipping-status")
    public ApiResponse<List<Map<String, Object>>> shippingStatus() {
        return ApiResponse.ok(mapper.shippingByStatus());
    }

    @GetMapping("/equipment-status")
    public ApiResponse<List<Map<String, Object>>> equipmentStatus() {
        return ApiResponse.ok(mapper.equipmentRunStatus());
    }
}
