2023-02-12 18:46:08 +01:00
|
|
|
using Application.Common.Extensions;
|
|
|
|
using Application.Common.Models;
|
|
|
|
using Application.Dto;
|
|
|
|
using Application.Interfaces;
|
|
|
|
using Domain.Config;
|
|
|
|
using Domain.Enums;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
|
|
|
namespace Application.Game.Card.Read;
|
|
|
|
|
|
|
|
public record ReadItemQuery(long CardId) : IRequestWrapper<string>;
|
|
|
|
|
|
|
|
public class ReadItemQueryHandler : CardRequestHandlerBase<ReadItemQuery, string>
|
|
|
|
{
|
|
|
|
private const string ITEM_XPATH = "/root/item/record";
|
2023-02-12 19:12:26 +01:00
|
|
|
|
|
|
|
public ReadItemQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate)
|
2023-02-12 18:46:08 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public override Task<ServiceResult<string>> Handle(ReadItemQuery request, CancellationToken cancellationToken)
|
|
|
|
{
|
2023-02-12 19:12:26 +01:00
|
|
|
var count = Config.ItemCount;
|
2023-02-12 18:46:08 +01:00
|
|
|
var list = new List<ItemDto>();
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
{
|
2023-02-12 19:12:26 +01:00
|
|
|
var item = new ItemDto
|
2023-02-12 18:46:08 +01:00
|
|
|
{
|
|
|
|
Id = i,
|
|
|
|
CardId = request.CardId,
|
2023-02-16 08:26:13 +01:00
|
|
|
ItemId = i + 1,
|
2023-02-12 18:46:08 +01:00
|
|
|
ItemNum = 90,
|
|
|
|
Created = "2013-01-01",
|
|
|
|
Modified = "2013-01-01",
|
|
|
|
NewFlag = 0,
|
|
|
|
UseFlag = 1
|
|
|
|
};
|
2023-02-12 19:12:26 +01:00
|
|
|
list.Add(item);
|
2023-02-12 18:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var result = list.SerializeCardDataList(ITEM_XPATH);
|
|
|
|
|
|
|
|
return Task.FromResult(new ServiceResult<string>(result));
|
|
|
|
}
|
|
|
|
}
|