using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace MiGu.Server.Controllers;

/// <summary>
/// 投影 API 占位：真实落地时由 YARP 反代到 SimpleLite WebAPI 的 /api/projection/* 路径。
/// 本地 Mock 数据仅用于无 SimpleLite 运行时的开发联调。
///
/// AR-4: 全 class 加 [Authorize] —— 任何登录用户都能读 mock 投影数据；未登录直接 401。
/// </summary>
[ApiController]
[Authorize]
[Route("api/projection")]
public class ProjectionController : ControllerBase
{
    [HttpGet("sites")]
    public IActionResult Sites() => Ok(new[]
    {
        new { id = "S001", name = "A 区-入库点", x = 1000, y = 2000 },
        new { id = "S002", name = "A 区-出库点", x = 3000, y = 2000 },
        new { id = "S003", name = "B 区-缓存区", x = 5000, y = 2000 }
    });

    [HttpGet("tracks")]
    public IActionResult Tracks() => Ok(new[]
    {
        new { id = "T001", kind = "line", fromSiteId = "S001", toSiteId = "S002" },
        new { id = "T002", kind = "line", fromSiteId = "S002", toSiteId = "S003" }
    });

    [HttpGet("cars")]
    public IActionResult Cars() => Ok(new[]
    {
        new { id = "C01", name = "AGV-001", state = "running", batterySoc = 0.86 },
        new { id = "C02", name = "AGV-002", state = "idle", batterySoc = 0.42 }
    });

    [HttpGet("missions")]
    public IActionResult Missions() => Ok(new[]
    {
        new { id = "M01", name = "A 区送料 #1", status = "running", priority = 50 },
        new { id = "M02", name = "A→B 缓存搬运", status = "queued", priority = 60 }
    });
}
