@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user