mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
adjust db service parameter
This commit is contained in:
@@ -293,7 +293,7 @@ internal sealed partial class CultivationService : ICultivationService
|
||||
|
||||
if (batchConsumption is { OverallConsume: { } items })
|
||||
{
|
||||
await inventoryDbService.RemoveInventoryItemRangeByProjectId(project.InnerId, true).ConfigureAwait(false);
|
||||
await inventoryDbService.RemoveInventoryItemRangeByProjectId(project.InnerId).ConfigureAwait(false);
|
||||
await inventoryDbService.AddInventoryItemRangeByProjectId(items.SelectList(item => InventoryItem.From(project.InnerId, item.Id, (uint)((int)item.Num - item.LackNum)))).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ internal interface IInventoryDbService
|
||||
{
|
||||
ValueTask AddInventoryItemRangeByProjectId(List<InventoryItem> items);
|
||||
|
||||
ValueTask RemoveInventoryItemRangeByProjectId(Guid projectId, bool includeMora = false);
|
||||
ValueTask RemoveInventoryItemRangeByProjectId(Guid projectId);
|
||||
|
||||
void UpdateInventoryItem(InventoryItem item);
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@ internal sealed partial class InventoryDbService : IInventoryDbService
|
||||
{
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
|
||||
public async ValueTask RemoveInventoryItemRangeByProjectId(Guid projectId, bool includeMora = false)
|
||||
public async ValueTask RemoveInventoryItemRangeByProjectId(Guid projectId)
|
||||
{
|
||||
using (IServiceScope scope = serviceProvider.CreateScope())
|
||||
{
|
||||
AppDbContext appDbContext = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
await appDbContext.InventoryItems
|
||||
.AsNoTracking()
|
||||
.Where(a => a.ProjectId == projectId && (includeMora || a.ItemId != 202U)) // 摩拉
|
||||
.Where(a => a.ProjectId == projectId)
|
||||
.ExecuteDeleteAsync()
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ internal sealed partial class CalculateClient
|
||||
private readonly ILogger<CalculateClient> logger;
|
||||
private readonly HttpClient httpClient;
|
||||
|
||||
[Obsolete("Use BatchComputeAsync instead")]
|
||||
public async ValueTask<Response<Consumption>> ComputeAsync(Model.Entity.User user, AvatarPromotionDelta delta, CancellationToken token = default)
|
||||
{
|
||||
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
||||
@@ -34,20 +35,18 @@ internal sealed partial class CalculateClient
|
||||
return Response.Response.DefaultIfNull(resp);
|
||||
}
|
||||
|
||||
public async ValueTask<Response<BatchConsumption>> BatchComputeAsync(UserAndUid userAndUid, AvatarPromotionDelta delta, bool syncMaterials = false, CancellationToken token = default)
|
||||
public async ValueTask<Response<BatchConsumption>> BatchComputeAsync(UserAndUid userAndUid, AvatarPromotionDelta delta, bool syncInventory = false, CancellationToken token = default)
|
||||
{
|
||||
return await BatchComputeAsync(userAndUid, [delta], syncMaterials, token).ConfigureAwait(false);
|
||||
return await BatchComputeAsync(userAndUid, [delta], syncInventory, token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async ValueTask<Response<BatchConsumption>> BatchComputeAsync(UserAndUid userAndUid, List<AvatarPromotionDelta> deltas, bool syncMaterials = false, CancellationToken token = default)
|
||||
public async ValueTask<Response<BatchConsumption>> BatchComputeAsync(UserAndUid userAndUid, List<AvatarPromotionDelta> deltas, bool syncInventory = false, CancellationToken token = default)
|
||||
{
|
||||
//ArgumentOutOfRangeException.ThrowIfGreaterThan(deltas.Count, 8);
|
||||
|
||||
BatchConsumptionData data = new()
|
||||
{
|
||||
Items = deltas,
|
||||
Region = syncMaterials ? userAndUid.Uid.Region : default!,
|
||||
Uid = syncMaterials ? userAndUid.Uid.ToString() : default!,
|
||||
Region = syncInventory ? userAndUid.Uid.Region : default!,
|
||||
Uid = syncInventory ? userAndUid.Uid.ToString() : default!,
|
||||
};
|
||||
|
||||
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
||||
|
||||
Reference in New Issue
Block a user