更新项目配置,新增设备同步模块,优化WebSocket和Swagger配置,增强SCADA系统的免登录接口,支持数据字典项和登录日志的免登录查询与记录。调整Java编译设置,确保更好的开发体验。
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YY.Admin.Services.Service.Config
|
||||
{
|
||||
public class SysConfigService : ISysConfigService, ISingletonDependency
|
||||
{
|
||||
private readonly ISysCacheService _sysCacheService;
|
||||
private readonly ISqlSugarClient _dbContext;
|
||||
public SysConfigService(
|
||||
ISysCacheService sysCacheService,
|
||||
ISqlSugarClient dbContext)
|
||||
{
|
||||
_sysCacheService= sysCacheService;
|
||||
_dbContext= dbContext;
|
||||
}
|
||||
public async Task<T> GetConfigValue<T>(string code)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(code)) return default;
|
||||
|
||||
var value = _sysCacheService.Get<string>($"{CacheConst.KeyConfig}{code}");
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
value = (await _dbContext.Queryable<SysConfig>().FirstAsync(u => u.Code == code))?.Value;
|
||||
_sysCacheService.Set($"{CacheConst.KeyConfig}{code}", value);
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(value)) return default;
|
||||
return (T)Convert.ChangeType(value, typeof(T));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user