Skip to content

Commit d74dbc6

Browse files
zuohuaijungitee-org
authored andcommitted
!1749 update Admin.NET/Admin.NET.Core/Service/Config/SysUserConfigService.cs.
Merge pull request !1749 from Lzh666/N/A
2 parents 567153d + d9451fa commit d74dbc6

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Admin.NET/Admin.NET.Core/Service/Config/SysUserConfigService.cs

+17-2
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,34 @@ public async Task<string> GetConfigValueByCode(string code, string defaultValue
196196
/// <summary>
197197
/// 获取配置参数值
198198
/// </summary>
199+
/// <typeparam name="T">类型</typeparam>
199200
/// <param name="code">编码</param>
200201
/// <param name="defaultValue">默认值</param>
201202
/// <returns></returns>
202203
[NonAction]
203204
public async Task<T> GetConfigValueByCode<T>(string code, T defaultValue = default)
205+
{
206+
return await GetConfigValueByCode<T>(code, _userManager.UserId, defaultValue);
207+
}
208+
209+
/// <summary>
210+
/// 获取配置参数值
211+
/// </summary>
212+
/// <typeparam name="T">类型</typeparam>
213+
/// <param name="code">编码</param>
214+
/// <param name="userId">用户Id</param>
215+
/// <param name="defaultValue">默认值</param>
216+
/// <returns></returns>
217+
[NonAction]
218+
public async Task<T> GetConfigValueByCode<T>(string code, long userId, T defaultValue = default)
204219
{
205220
if (string.IsNullOrWhiteSpace(code)) return defaultValue;
206221

207-
var value = _sysCacheService.Get<string>($"{CacheConst.KeyUserConfig}{_userManager.UserId}{code}");
222+
var value = _sysCacheService.Get<string>($"{CacheConst.KeyUserConfig}{userId}{code}");
208223
if (string.IsNullOrEmpty(value))
209224
{
210225
value = (await VSysConfig.FirstAsync(u => u.Code == code))?.Value;
211-
_sysCacheService.Set($"{CacheConst.KeyUserConfig}{_userManager.UserId}{code}", value);
226+
_sysCacheService.Set($"{CacheConst.KeyUserConfig}{userId}{code}", value);
212227
}
213228
if (string.IsNullOrWhiteSpace(value)) return defaultValue;
214229
return (T)Convert.ChangeType(value, typeof(T));

0 commit comments

Comments
 (0)