@@ -1,25 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service.Common
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 开始时候一些帮助 比如根据配置的字典生成枚举
|
||||
/// </summary>
|
||||
/// <param name="_dictionaryRepository"></param>
|
||||
[ApiExplorerSettings(GroupName = "Common")]
|
||||
public class DevelopService(IRepository<Dictionary> _dictionaryRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据配置的字典名生成后端枚举
|
||||
/// </summary>
|
||||
/// <param name="dicName"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> BackDicGenerateEnum(string dicName)
|
||||
{
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,37 +26,6 @@ namespace IRaCIS.Core.Application.Service
|
||||
IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrial, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IDictionaryService
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
// 添加 XML 注释作为枚举描述
|
||||
enumCode.AppendLine($" /// <summary>");
|
||||
enumCode.AppendLine($" /// {item.ValueCN}"); // 假设你有一个描述字段
|
||||
enumCode.AppendLine($" /// </summary>");
|
||||
// 每个枚举值生成
|
||||
enumCode.AppendLine($" {item.Value.Trim().Replace(" ", "")} = {item.Code},");
|
||||
|
||||
}
|
||||
|
||||
enumCode.AppendLine("}");
|
||||
|
||||
// 返回生成的枚举代码
|
||||
var enumStr = enumCode.ToString();
|
||||
|
||||
return ResponseOutput.Ok(enumStr);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加bool
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user