This commit is contained in:
he
2024-10-14 15:31:13 +08:00
parent c9a6f8b99b
commit a88ef53104
2 changed files with 107 additions and 24 deletions
@@ -1,4 +1,5 @@
using DocumentFormat.OpenXml;
using Amazon.Runtime.Internal.Util;
using DocumentFormat.OpenXml;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure;
using MimeKit;
@@ -65,11 +66,36 @@ public static class CommonEmailHelper
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public static string TranslationDictionary(TranslationDictionaryDto inDto)
public static async Task<List<string>> TranslationDictionary(TranslationDictionaryDto inDto)
{
var dic = inDto.DictionaryRepository.Where(x => x.Parent.Code == inDto.DictionaryCode && x.Code == inDto.EnumValue).FirstOrDefault();
return dic == null ? string.Empty : (inDto.IsEn_US ? dic.Value : dic.ValueCN);
var dictionaryCodelist = inDto.DictionaryList.Select(x => x.DictionaryCode).ToList();
var enumValueList = inDto.DictionaryList.Select(x => x.EnumValue).ToList();
var dicList =await inDto.DictionaryRepository.Where(x => dictionaryCodelist.Contains(x.Parent.Code) && enumValueList.Contains(x.Code)).Select(x=>new DictionaryData() {
DictionaryCode=x.Parent.Code,
EnumValue=x.Code,
Value=x.Value,
ValueCN=x.ValueCN
}).ToListAsync();
List<string> result = new List<string>();
inDto.DictionaryList.ForEach(x =>
{
var dic = dicList.Where(y => y.EnumValue == x.EnumValue && y.DictionaryCode == x.DictionaryCode).FirstOrDefault();
result.Add(dic == null ? string.Empty : (inDto.IsEn_US ? dic.Value : dic.ValueCN));
});
return result;
}
}
@@ -84,6 +110,39 @@ public class TranslationDictionaryDto
/// </summary>
public IRepository<Dictionary> DictionaryRepository { get; set; }
/// <summary>
/// 是否是英文
/// </summary>
public bool IsEn_US { get; set; }
/// <summary>
/// 字典
/// </summary>
public List<DictionaryDto> DictionaryList { get; set; } = new List<DictionaryDto>();
}
/// <summary>
/// 字典对象
/// </summary>
public class DictionaryDto
{
/// <summary>
/// 字典Code
/// </summary>
public string DictionaryCode { get; set; }
/// <summary>
/// 枚举值
/// </summary>
public string EnumValue { get; set; }
}
public class DictionaryData
{
/// <summary>
/// 字典Code
/// </summary>
@@ -95,8 +154,13 @@ public class TranslationDictionaryDto
public string EnumValue { get; set; }
/// <summary>
/// 是否是英文
///
/// </summary>
public bool IsEn_US { get; set; }
public string Value { get; set; }
/// <summary>
/// 返回
/// </summary>
public string ValueCN { get; set; }
}