refactor: 完善枚举系统与状态类型转换,新增枚举管理接口
1. 为所有枚举添加Description特性用于中文描述 2. 移除实体类中冗余的状态字段注释与定义 3. 将所有枚举状态参数改为int类型转换,统一数据交互格式 4. 新增系统管理枚举查询接口与实现,支持获取所有枚举元数据 5. 调整宠物服务模板状态更新接口参数类型
This commit is contained in:
@ -0,0 +1,46 @@
|
||||
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("获取枚举信息失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user