Added inital job entity and services. Added released works API integration.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using JSMR.Application.Enums;
|
||||
using JSMR.Domain.ValueObjects;
|
||||
using JSMR.Infrastructure.Globalization;
|
||||
|
||||
namespace JSMR.Infrastructure.Scanning;
|
||||
|
||||
@@ -90,7 +91,10 @@ public sealed class DLSiteSearchFilterBuilder
|
||||
|
||||
public string BuildSearchQuery(int pageNumber, int pageSize)
|
||||
{
|
||||
var (localeAbbreviation, localeCode) = LocaleMap.Map[_locale];
|
||||
//string localeAbbreviation = LocaleMapper.ToAbbreviation(_locale);
|
||||
//string localeCode = LocaleMapper.ToDLSiteLocale(_locale);
|
||||
|
||||
var (localeAbbreviation, localeCode) = LocaleMapper.Map[_locale];
|
||||
|
||||
using (var writer = new StringWriter())
|
||||
{
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
using JSMR.Application.Enums;
|
||||
|
||||
namespace JSMR.Infrastructure.Scanning;
|
||||
|
||||
internal class LocaleMap
|
||||
{
|
||||
public static readonly IReadOnlyDictionary<Locale, (string Abbreviation, string Code)> Map =
|
||||
new Dictionary<Locale, (string, string)>
|
||||
{
|
||||
{ Locale.Japanese, ("jp", "ja_JP") },
|
||||
{ Locale.English, ("en", "en_US") },
|
||||
{ Locale.ChineseSimplified, ("zh-cn", "zh_CN") },
|
||||
{ Locale.ChineseTraditional, ("zh-tw", "zh_TW") },
|
||||
{ Locale.Korean, ("ko", "ko_KR") },
|
||||
};
|
||||
}
|
||||
39
JSMR.Infrastructure/Scanning/ReleasedWorksProvider.cs
Normal file
39
JSMR.Infrastructure/Scanning/ReleasedWorksProvider.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using JSMR.Application.Enums;
|
||||
using JSMR.Application.Integrations.DLSite.Models.ReleasedWorks;
|
||||
using JSMR.Application.Integrations.DLSite.Ports;
|
||||
using JSMR.Application.Scanning.Contracts;
|
||||
using JSMR.Application.Scanning.Ports;
|
||||
|
||||
namespace JSMR.Infrastructure.Scanning;
|
||||
|
||||
public class ReleasedWorksProvider(IDLSiteClient dlsiteClient) : IReleasedWorksProvider
|
||||
{
|
||||
public async Task<ReleasedWorksCollection> GetReleasedWorksAsync(VoiceWorkScanResult scanResult, CancellationToken cancellationToken)
|
||||
{
|
||||
DateOnly[] salesDates =
|
||||
[
|
||||
.. scanResult.Works
|
||||
.Where(x => x.SalesDate.HasValue)
|
||||
.Select(x => x.SalesDate!.Value)
|
||||
];
|
||||
|
||||
if (salesDates.Length == 0)
|
||||
return [];
|
||||
|
||||
DateOnly minDate = salesDates.Min();
|
||||
DateOnly maxDate = salesDates.Max();
|
||||
|
||||
DateOnly requestDate = minDate.AddDays(-1);
|
||||
DateOnly requestEndDate = maxDate.AddDays(1);
|
||||
|
||||
int period = (requestEndDate.DayNumber - requestDate.DayNumber) + 1;
|
||||
|
||||
ReleasedWorksRequest releasedWorksRequest = new(
|
||||
Locale: Locale.English,
|
||||
Date: requestDate,
|
||||
Period: period
|
||||
);
|
||||
|
||||
return await dlsiteClient.GetReleasedWorksAsync(releasedWorksRequest, cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user