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 ReadAvatarQuery(long CardId) : IRequestWrapper<string>;
|
|
|
|
|
|
|
|
public class ReadAvatarQueryHandler : CardRequestHandlerBase<ReadAvatarQuery, string>
|
|
|
|
{
|
|
|
|
private const string AVATAR_XPATH = "/root/avatar/record";
|
2023-02-12 19:12:26 +01:00
|
|
|
|
|
|
|
public ReadAvatarQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate)
|
2023-02-12 18:46:08 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public override Task<ServiceResult<string>> Handle(ReadAvatarQuery request, CancellationToken cancellationToken)
|
|
|
|
{
|
2023-02-12 19:12:26 +01:00
|
|
|
var count = Config.AvatarCount;
|
2023-02-12 18:46:08 +01:00
|
|
|
var list = new List<AvatarDto>();
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
var avatar = new AvatarDto
|
|
|
|
{
|
|
|
|
Id = i,
|
|
|
|
CardId = request.CardId,
|
2023-02-16 08:26:13 +01:00
|
|
|
AvatarId = i + 1,
|
2023-02-13 17:38:19 +01:00
|
|
|
Created = "2013-01-01 08:00:00",
|
|
|
|
Modified = "2013-01-01 08:00:00",
|
2023-02-12 18:46:08 +01:00
|
|
|
NewFlag = 0,
|
2023-02-16 08:26:13 +01:00
|
|
|
UseFlag = i == 10 ? 0 : 1
|
2023-02-12 18:46:08 +01:00
|
|
|
};
|
|
|
|
list.Add(avatar);
|
|
|
|
}
|
|
|
|
|
|
|
|
var result = list.SerializeCardDataList(AVATAR_XPATH);
|
|
|
|
|
|
|
|
return Task.FromResult(new ServiceResult<string>(result));
|
|
|
|
}
|
|
|
|
}
|