字典测试生成枚举
continuous-integration/drone/push Build is passing Details

IRC_NewDev
hang 2024-09-09 18:05:59 +08:00
parent 16107dc8a9
commit 360bcd6bfe
1 changed files with 29 additions and 0 deletions

View File

@ -5,6 +5,9 @@ using Microsoft.AspNetCore.Mvc;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Infra.EFCore.Common;
using IP2Region.Net.XDB;
using System.Collections;
using System.Text;
namespace IRaCIS.Application.Services
{
@ -29,6 +32,32 @@ namespace IRaCIS.Application.Services
{
public async Task<IResponseOutput> GenerateEnumDefine(string code)
{
var searchList = await _dicRepository.Where(t => t.Parent.Code == code && t.ParentId != null && t.IsEnable).ProjectTo<BasicDicSelect>(_mapper.ConfigurationProvider).ToListAsync();
// StringBuilder 用于构建枚举代码字符串
var enumCode = new StringBuilder();
// 生成枚举定义
enumCode.AppendLine($"public enum {code}");
enumCode.AppendLine("{");
foreach (var item in searchList)
{
// 每个枚举值生成
enumCode.AppendLine($" {item.Code} = {item.ValueCN},");
}
enumCode.AppendLine("}");
// 返回生成的枚举代码
var enumStr= enumCode.ToString();
return ResponseOutput.Ok(enumStr);
}
/// <summary>
/// 添加bool
/// </summary>