2022-07-27 18:14:07 +05:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudApp.Services
|
|
|
|
|
{
|
2022-08-09 11:10:01 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// репозиторий для личных настроек пользователя
|
|
|
|
|
/// </summary>
|
2022-07-27 18:14:07 +05:00
|
|
|
|
public interface IUserSettingsRepository
|
|
|
|
|
{
|
2022-08-09 11:10:01 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// код ошибки: ключ не найден
|
|
|
|
|
/// </summary>
|
2022-07-27 18:14:07 +05:00
|
|
|
|
public const int ErrorKeyNotFound = -1;
|
2022-08-09 11:10:01 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// код ошибки: ключ уже занят
|
|
|
|
|
/// </summary>
|
2022-07-27 18:14:07 +05:00
|
|
|
|
public const int ErrorKeyIsUsed = -2;
|
2022-08-09 11:10:01 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получить настройки по ключу для пользователя
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="userId"></param>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2023-05-17 12:31:29 +05:00
|
|
|
|
Task<System.Text.Json.JsonDocument?> GetOrDefaultAsync(int userId, string key, CancellationToken token);
|
2022-08-09 11:10:01 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-08-15 13:19:44 +05:00
|
|
|
|
/// Добавить или изменить настройки с ключем для пользователя
|
2022-08-09 11:10:01 +05:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="userId"></param>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-08-15 13:19:44 +05:00
|
|
|
|
Task<int> UpsertAsync(int userId, string key, System.Text.Json.JsonDocument value, CancellationToken token);
|
2022-08-09 11:10:01 +05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Удалить настройки с ключем для пользователя
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="userId"></param>
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
/// <param name="token"></param>
|
|
|
|
|
/// <returns></returns>
|
2022-07-27 18:14:07 +05:00
|
|
|
|
Task<int> DeleteAsync(int userId, string key, CancellationToken token);
|
|
|
|
|
}
|
|
|
|
|
}
|