2025-07-09 11:58:18 +08:00
|
|
|
|
using JiShe.IoT.CommonServices.Dto;
|
|
|
|
|
|
using JiShe.ServicePro.Commons;
|
|
|
|
|
|
using JiShe.ServicePro.Core;
|
|
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
|
using System.Collections.Generic;
|
2025-07-11 16:14:05 +08:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using static FreeSql.Internal.GlobalFilter;
|
2025-07-09 11:58:18 +08:00
|
|
|
|
|
|
|
|
|
|
namespace JiShe.IoT.CommonServices
|
|
|
|
|
|
{
|
|
|
|
|
|
public class CommonService : IoTAppService, ICommonService
|
|
|
|
|
|
{
|
|
|
|
|
|
private static ConcurrentDictionary<string, List<SelectResult>> _selectListType = new();
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 初始化所有固定的枚举下拉框字典
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public void InitSelectTypetList()
|
|
|
|
|
|
{
|
|
|
|
|
|
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
|
|
|
|
|
var typeList = assemblies.SelectMany(x => x.GetTypes()).Where(x => x.IsDefined(typeof(SelectResultAttribute), false));
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var typeInfoItem in typeList)
|
|
|
|
|
|
{
|
2025-07-11 16:14:05 +08:00
|
|
|
|
SelectResultAttribute[] selectResultAttribute =
|
|
|
|
|
|
(SelectResultAttribute[])typeInfoItem.GetCustomAttributes(typeof(SelectResultAttribute), false);
|
2025-07-09 11:58:18 +08:00
|
|
|
|
|
2025-07-11 16:14:05 +08:00
|
|
|
|
_selectListType.TryAdd(typeInfoItem.Name, CommonHelper.GetTypeAttributeList(typeInfoItem, selectResultAttribute[0].IsGetPropertie));
|
2025-07-09 11:58:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据type名称获取下拉框数据,主要是枚举等
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public List<SelectResult> GetSelectResultList(SelectResultListInput input)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<SelectResult> selectResults = _selectListType.TryGetValue(input.TypeName, out var list) ? list : new List<SelectResult>();
|
|
|
|
|
|
|
|
|
|
|
|
return selectResults;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|