Add project files.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
using JSMR.Application.Creators.Ports;
|
||||
|
||||
namespace JSMR.Application.Creators.Commands.UpdateCreatorStatus;
|
||||
|
||||
public class UpdateCreatorStatusHandler(ICreatorWriter writer)
|
||||
{
|
||||
public Task<UpdateCreatorStatusResponse> HandleAsync(UpdateCreatorStatusRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return writer.UpdateStatusAsync(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
using JSMR.Application.Creators.Contracts;
|
||||
|
||||
namespace JSMR.Application.Creators.Commands.UpdateCreatorStatus;
|
||||
|
||||
public sealed record UpdateCreatorStatusRequest(int CreatorId, CreatorStatus CreatorStatus);
|
||||
@@ -0,0 +1,5 @@
|
||||
using JSMR.Application.Creators.Contracts;
|
||||
|
||||
namespace JSMR.Application.Creators.Commands.UpdateCreatorStatus;
|
||||
|
||||
public sealed record UpdateCreatorStatusResponse(int CreatorId, CreatorStatus CreatorStatus);
|
||||
8
JSMR.Application/Creators/Contracts/CreatorStatus.cs
Normal file
8
JSMR.Application/Creators/Contracts/CreatorStatus.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace JSMR.Application.Creators.Contracts;
|
||||
|
||||
public enum CreatorStatus
|
||||
{
|
||||
Neutral,
|
||||
Favorite,
|
||||
Blacklisted
|
||||
}
|
||||
6
JSMR.Application/Creators/Ports/ICreatorReader.cs
Normal file
6
JSMR.Application/Creators/Ports/ICreatorReader.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace JSMR.Application.Creators.Ports;
|
||||
|
||||
public interface ICircleReader
|
||||
{
|
||||
|
||||
}
|
||||
8
JSMR.Application/Creators/Ports/ICreatorWriter.cs
Normal file
8
JSMR.Application/Creators/Ports/ICreatorWriter.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using JSMR.Application.Creators.Commands.UpdateCreatorStatus;
|
||||
|
||||
namespace JSMR.Application.Creators.Ports;
|
||||
|
||||
public interface ICreatorWriter
|
||||
{
|
||||
Task<UpdateCreatorStatusResponse> UpdateStatusAsync(UpdateCreatorStatusRequest request, CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace JSMR.Application.Creators.Queries.Search.Contracts;
|
||||
|
||||
public class CreatorSearchCriteria
|
||||
{
|
||||
public string? Name { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace JSMR.Application.Creators.Queries.Search.Contracts;
|
||||
|
||||
public record CreatorSearchItem
|
||||
{
|
||||
public int CreatorId { get; init; }
|
||||
public required string Name { get; init; }
|
||||
public bool Favorite { get; init; }
|
||||
public bool Blacklisted { get; init; }
|
||||
public int VoiceWorkCount { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMR.Application.Common.Search;
|
||||
|
||||
namespace JSMR.Application.Creators.Queries.Search.Contracts;
|
||||
|
||||
//public record TagSearchOptions : SearchOptions<TagSearchCriteria, TagSortField>
|
||||
//{
|
||||
|
||||
//}
|
||||
@@ -0,0 +1,8 @@
|
||||
using JSMR.Application.Common.Search;
|
||||
|
||||
namespace JSMR.Application.Creators.Queries.Search.Contracts;
|
||||
|
||||
public record CreatorSearchResults : SearchResult<CreatorSearchItem>
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace JSMR.Application.Creators.Queries.Search.Contracts;
|
||||
|
||||
public enum CreatorSortField
|
||||
{
|
||||
Name,
|
||||
Blacklisted,
|
||||
Favorite,
|
||||
VoiceWorkCount
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using JSMR.Application.Common.Search;
|
||||
using JSMR.Application.Creators.Queries.Search.Contracts;
|
||||
|
||||
namespace JSMR.Application.Creators.Queries.Search.Ports;
|
||||
|
||||
public interface ICreatorSearchProvider : ISearchProvider<CreatorSearchItem, CreatorSearchCriteria, CreatorSortField>
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using JSMR.Application.Common.Caching;
|
||||
using JSMR.Application.Common.Search;
|
||||
using JSMR.Application.Creators.Queries.Search.Contracts;
|
||||
using JSMR.Application.Creators.Queries.Search.Ports;
|
||||
|
||||
namespace JSMR.Application.Creators.Queries.Search;
|
||||
|
||||
public sealed class SearchCreatorsHandler(ICreatorSearchProvider searchProvider, ICache cache)
|
||||
{
|
||||
public async Task<SearchCreatorsResponse> HandleAsync(SearchCreatorsRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
SearchOptions<CreatorSearchCriteria, CreatorSortField> searchOptions = request.Options;
|
||||
|
||||
string cacheKey = $"creator:{searchOptions.GetHashCode()}";
|
||||
|
||||
CreatorSearchResults? cachedResults = await cache.GetAsync<CreatorSearchResults>(cacheKey, cancellationToken);
|
||||
|
||||
if (cachedResults != null)
|
||||
return new SearchCreatorsResponse(cachedResults);
|
||||
|
||||
SearchResult<CreatorSearchItem> results = await searchProvider.SearchAsync(searchOptions, cancellationToken);
|
||||
|
||||
CacheEntryOptions cacheEntryOptions = new()
|
||||
{
|
||||
SlidingExpiration = TimeSpan.FromMinutes(10)
|
||||
};
|
||||
|
||||
await cache.SetAsync(cacheKey, results, cacheEntryOptions, cancellationToken);
|
||||
|
||||
return new SearchCreatorsResponse(results);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
using JSMR.Application.Common.Search;
|
||||
using JSMR.Application.Creators.Queries.Search.Contracts;
|
||||
|
||||
namespace JSMR.Application.Creators.Queries.Search;
|
||||
|
||||
public sealed record SearchCreatorsRequest(SearchOptions<CreatorSearchCriteria, CreatorSortField> Options);
|
||||
@@ -0,0 +1,6 @@
|
||||
using JSMR.Application.Common.Search;
|
||||
using JSMR.Application.Creators.Queries.Search.Contracts;
|
||||
|
||||
namespace JSMR.Application.Creators.Queries.Search;
|
||||
|
||||
public sealed record SearchCreatorsResponse(SearchResult<CreatorSearchItem> Results);
|
||||
Reference in New Issue
Block a user