实现动态下拉框获取
This commit is contained in:
parent
652d8dcb47
commit
7f42ee56d3
@ -14,9 +14,6 @@ namespace JiShe.IoT.CommonServices.Dto
|
|||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 类型名称
|
/// 类型名称
|
||||||
/// MalignantLoadLevelEnum 恶性负载等级
|
|
||||||
/// DurationOfAutomaticClosingEnum 自动合闸时长类型
|
|
||||||
/// MalignLoadTypeEnum 恶性负载类型
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Required]
|
[Required]
|
||||||
public string TypeName { get; set; }
|
public string TypeName { get; set; }
|
||||||
|
|||||||
@ -14,20 +14,17 @@ namespace JiShe.IoT.CommonServices
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ICommonService
|
public interface ICommonService
|
||||||
{
|
{
|
||||||
#region 公共依赖接口
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化所有固定的枚举下拉框字典
|
/// 初始化所有固定的枚举下拉框字典
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task InitSelectTypetList();
|
void InitSelectTypetList();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据type名称获取下拉框数据,主要是枚举等
|
/// 根据type名称获取下拉框数据,主要是枚举等
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<SelectResult>> GetSelectResultList(SelectResultListInput input);
|
List<SelectResult> GetSelectResultList(SelectResultListInput input);
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
41
src/JiShe.IoT.Application/CommonServices/CommonService.cs
Normal file
41
src/JiShe.IoT.Application/CommonServices/CommonService.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using JiShe.IoT.CommonServices.Dto;
|
||||||
|
using JiShe.ServicePro.Commons;
|
||||||
|
using JiShe.ServicePro.Core;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
|
||||||
|
_selectListType.TryAdd(typeInfoItem.Name, CommonHelper.GetEnumAttributeList(typeInfoItem));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
using JiShe.IoT.CommonServices;
|
||||||
using JiShe.IoT.Jobs.ToMysql;
|
using JiShe.IoT.Jobs.ToMysql;
|
||||||
using JiShe.IoT.Jobs.ToRedis;
|
using JiShe.IoT.Jobs.ToRedis;
|
||||||
using JiShe.ServicePro.CTWingManagement;
|
using JiShe.ServicePro.CTWingManagement;
|
||||||
@ -10,6 +11,7 @@ using JiShe.ServicePro.IoTDBManagement;
|
|||||||
using JiShe.ServicePro.OneNETManagement;
|
using JiShe.ServicePro.OneNETManagement;
|
||||||
using JiShe.ServicePro.TemplateManagement;
|
using JiShe.ServicePro.TemplateManagement;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Volo.Abp;
|
||||||
|
|
||||||
namespace JiShe.IoT
|
namespace JiShe.IoT
|
||||||
{
|
{
|
||||||
@ -56,5 +58,11 @@ namespace JiShe.IoT
|
|||||||
context.Services.AddHostedService<CacheDeviceDataToRedisJob>();
|
context.Services.AddHostedService<CacheDeviceDataToRedisJob>();
|
||||||
context.Services.AddHostedService<CacheFocusDataToRedisJob>();
|
context.Services.AddHostedService<CacheFocusDataToRedisJob>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
||||||
|
{
|
||||||
|
var commonService = context.ServiceProvider.GetRequiredService<ICommonService>();
|
||||||
|
commonService.InitSelectTypetList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,9 +45,5 @@
|
|||||||
<ProjectReference Include="..\JiShe.IoT.Application.Contracts\JiShe.IoT.Application.Contracts.csproj" />
|
<ProjectReference Include="..\JiShe.IoT.Application.Contracts\JiShe.IoT.Application.Contracts.csproj" />
|
||||||
<ProjectReference Include="..\JiShe.IoT.Domain\JiShe.IoT.Domain.csproj" />
|
<ProjectReference Include="..\JiShe.IoT.Domain\JiShe.IoT.Domain.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="CommonServices\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
32
src/JiShe.IoT.HttpApi/Controllers/CommonController.cs
Normal file
32
src/JiShe.IoT.HttpApi/Controllers/CommonController.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using JiShe.IoT.CommonServices;
|
||||||
|
using JiShe.IoT.CommonServices.Dto;
|
||||||
|
using JiShe.ServicePro.Commons;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JiShe.IoT.Controllers
|
||||||
|
{
|
||||||
|
public class CommonController:IoTController
|
||||||
|
{
|
||||||
|
private readonly ICommonService _commonService;
|
||||||
|
public CommonController(ICommonService commonService)
|
||||||
|
{
|
||||||
|
_commonService = commonService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据type名称获取下拉框数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("get-select-list")]
|
||||||
|
[SwaggerOperation(summary: "根据type名称获取下拉框数据", Tags = new[] { "Common" })]
|
||||||
|
public List<SelectResult> GetSelectResultList(SelectResultListInput input)
|
||||||
|
{
|
||||||
|
return _commonService.GetSelectResultList(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,10 @@
|
|||||||
|
using JiShe.ServicePro.SwaggerConfigs;
|
||||||
|
|
||||||
namespace JiShe.IoT.Controllers
|
namespace JiShe.IoT.Controllers
|
||||||
{
|
{
|
||||||
/* Inherit your controllers from this class.
|
/* Inherit your controllers from this class.
|
||||||
*/
|
*/
|
||||||
|
[ApiExplorerSettings(GroupName = nameof(SwaggerGroupEnum.IoTAdmin))]
|
||||||
public abstract class IoTController : AbpController
|
public abstract class IoTController : AbpController
|
||||||
{
|
{
|
||||||
protected IoTController()
|
protected IoTController()
|
||||||
Loading…
x
Reference in New Issue
Block a user