init 项目代码初始化

This commit is contained in:
2023-12-25 11:01:55 +08:00
parent 15112c0ddd
commit da09dd9f0f
112 changed files with 4114 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
using System.Reflection;
using Kurisu.AspNetCore.Utils.Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Dlhis.Common.EnumSetting;
/// <summary>
/// 枚举
/// </summary>
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class EnumsController : ControllerBase
{
/// <summary>
/// 获取所有枚举
/// </summary>
/// <param name="code">枚举code</param>
/// <returns></returns>
[HttpGet]
public object GetEnums(string code)
{
var types = Assembly.Load("Dlhis.Entity")
.GetTypes()
.Where(x => x.IsEnum)
.WhereIf(code.IsPresent(), x => x.Name == code);
return types.Select(x =>
{
var d = x.GetDescription();
return new
{
Code = x.Name,
Name = d,
Data = x.GetFields(BindingFlags.Public | BindingFlags.Static).Select(item =>
{
var e = (Enum)Enum.Parse(item.FieldType, item.GetValue(null).ToString());
var fd = e.GetDescription();
return new
{
Key = fd,
Value = (int)item.GetValue(null)
};
})
};
});
}
}