using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using QYZH.InteractiveMagazine.IService;
using QYZH.InteractiveMagazine.Models.Dto;
using QYZH.InteractiveMagazine.Models.Dto.SystemManagement;
using QYZH.InteractiveMagazine.Models.Enum;

namespace QYZH.InteractiveMagazine.WebApi.Controllers;

/// <summary>
/// 系统管理控制器
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = nameof(ApiVersionEnum.Platform))]
public class SystemManagementController : BaseController
{
    private readonly ISystemManagementService _systemManagementService;
    private readonly ILogger<SystemManagementController> _logger;

    public SystemManagementController(ISystemManagementService systemManagementService, ILogger<SystemManagementController> logger)
    {
        _systemManagementService = systemManagementService;
        _logger = logger;
    }

    /// <summary>
    /// 获取系统中所有枚举信息
    /// </summary>
    /// <returns>枚举信息列表</returns>
    [AllowAnonymous]
    [HttpGet("enums")]
    public async Task<BaseResponse<List<EnumInfoOutput>>> GetAllEnumsAsync()
    {
        try
        {
            var result = await _systemManagementService.GetAllEnumsAsync();
            return Success(result);
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "获取枚举信息异常");
            return BaseResponse<List<EnumInfoOutput>>.Fail("获取枚举信息失败");
        }
    }
}
