using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using TakeoutSaaS.Shared.Abstractions.Results;
using TakeoutSaaS.Shared.Web.Api;

namespace TakeoutSaaS.UserApi.Controllers;

/// <summary>
/// 用户端 - 健康检查。
/// </summary>
[ApiVersion("1.0")]
[AllowAnonymous]
[Route("api/user/v{version:apiVersion}/[controller]")]
public class HealthController : BaseApiController
{
    /// <summary>
    /// 获取服务健康状态。
    /// </summary>
    /// <returns>健康状态</returns>
    [HttpGet]
    [ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status200OK)]
    public ApiResponse<object> Get()
    {
        // 1. 构造健康状态
        var payload = new { status = "OK", service = "UserApi", time = DateTime.UtcNow };

        // 2. 返回健康响应
        return ApiResponse<object>.Ok(payload);
    }
}
