56 lines
1.9 KiB
C#
56 lines
1.9 KiB
C#
using Learn.Archives.API.Controllers.Dto;
|
|
using Learn.Archives.API.Expand;
|
|
using Learn.Archives.Core.Common;
|
|
using Learn.Archives.Core.Model;
|
|
using Learn.Archives.Core.Model.Dto;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Diagnostics;
|
|
using System.Security.Claims;
|
|
using UserCenter.Model;
|
|
|
|
namespace Learn.Archives.API.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 通用接口
|
|
/// </summary>
|
|
[Authorize(AuthenticationSchemes = Authentication.Admin)]
|
|
[Route("api/[controller]")]
|
|
public class PublicController : Controller
|
|
{
|
|
|
|
public PublicController(Repository<School> baseService)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// App.EntityDto.Enum 枚举转下拉列表
|
|
/// </summary>
|
|
/// <param name="type">枚举名称 例子type='ExamStatusEnum'</param>
|
|
/// <returns></returns>
|
|
[HttpGet, Route("enum/{type}")]
|
|
[ResponseCache(Duration = 5)]
|
|
public List<ComboModel> GetExamStatusData(string type)
|
|
{
|
|
if (!AppCommon.EnumType.ContainsKey(type))
|
|
Oh.Error("无效类型");
|
|
return Enum.GetValues(AppCommon.EnumType[type]).Cast<object>()
|
|
.Select(enumValue => new ComboModel() { Text = enumValue.ToString(), Value = (int)enumValue }).ToList();
|
|
}
|
|
/// <summary>
|
|
/// App.EntityDto.Enum 枚举转下拉列表
|
|
/// </summary>
|
|
/// <param name="type">枚举名称 例子type='ExamStatusEnum'</param>
|
|
/// <returns></returns>
|
|
[HttpGet, Route("enum/{type}/Dic")]
|
|
[ResponseCache(Duration = 5)]
|
|
public Dictionary<int, string?> GetExamStatusDictionary(string type)
|
|
{
|
|
if (!AppCommon.EnumType.ContainsKey(type))
|
|
Oh.Error("无效类型");
|
|
return Enum.GetValues(AppCommon.EnumType[type]).Cast<object>()
|
|
.ToDictionary(s => (int)s, s => s.ToString());
|
|
}
|
|
}
|
|
}
|