fix(api): в кэш добавлены дополнительные данные о пользователе
This commit is contained in:
@@ -3,6 +3,11 @@
|
||||
public class UserCache
|
||||
{
|
||||
public required string UserIp { get; set; }
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public List<UserRoleInCache> Roles { get; set; } = new List<UserRoleInCache>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,11 @@ namespace PARR.API.Controllers.V1
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Записать в кэш и получить обратно значение из кэша
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost(ApiRoutes.Test.CreateCache)]
|
||||
public async Task<IActionResult> CreateCache([FromBody] CaheRequestTest request)
|
||||
{
|
||||
|
||||
@@ -63,7 +63,14 @@ namespace PARR.API.Services.Implementations
|
||||
}
|
||||
|
||||
// пользователь есть, добавляем в КЭШ и возвращаем роли
|
||||
var cacheData = new UserCache { UserIp = ipAddress, Roles = roles };
|
||||
var cacheData = new UserCache
|
||||
{
|
||||
UserIp = ipAddress,
|
||||
Roles = roles,
|
||||
Name = user!.Name,
|
||||
Description = user.Description ?? string.Empty
|
||||
};
|
||||
|
||||
await cacheService.SetCachedDataAsync(GetAllowKey(ipAddress), cacheData, userCacheSettings.UserCacheTtl);
|
||||
|
||||
return cacheData;
|
||||
|
||||
Reference in New Issue
Block a user