From 5c85e83c3e39974be6a3f69b992b27940e4f48bf Mon Sep 17 00:00:00 2001 From: asesidaa <1061472754@qq.com> Date: Tue, 14 Feb 2023 00:38:19 +0800 Subject: [PATCH] Migrate read --- Application/Dto/CardBDatumDto.cs | 15 ++++ Application/Dto/CardDetailDto.cs | 2 +- Application/Dto/CoinDto.cs | 24 +++++ Application/Dto/MusicAouDto.cs | 15 ++++ Application/Dto/MusicExtraDto.cs | 15 ++++ Application/Dto/NavigatorDto.cs | 27 ++++++ Application/Dto/SkinDto.cs | 27 ++++++ Application/Dto/SoundEffectDto.cs | 27 ++++++ Application/Dto/TitleDto.cs | 27 ++++++ Application/Dto/TotalTrophyDto.cs | 12 +++ Application/Dto/UnlockKeyNumDto.cs | 36 ++++++++ .../Game/Card/Read/ReadAllCardDetailsQuery.cs | 8 +- Application/Game/Card/Read/ReadAvatarQuery.cs | 4 +- .../Game/Card/Read/ReadCardBDataQuery.cs | 27 +++++- Application/Game/Card/Read/ReadCoinQuery.cs | 17 +++- Application/Game/Card/Read/ReadCondQuery.cs | 6 +- .../Game/Card/Read/ReadEventRewardQuery.cs | 6 +- .../Game/Card/Read/ReadGetMessageQuery.cs | 6 +- .../Game/Card/Read/ReadMusicAouQuery.cs | 24 ++++- .../Game/Card/Read/ReadMusicExtraQuery.cs | 20 ++++- .../Game/Card/Read/ReadNavigatorQuery.cs | 24 ++++- Application/Game/Card/Read/ReadSkinQuery.cs | 25 +++++- .../Game/Card/Read/ReadSoundEffectQuery.cs | 24 ++++- Application/Game/Card/Read/ReadTitleQuery.cs | 25 +++++- .../Game/Card/Read/ReadTotalTrophyQuery.cs | 13 ++- .../Game/Card/Read/ReadUnlockKeynumQuery.cs | 22 ++++- .../Game/Card/Read/ReadUnlockRewardQuery.cs | 87 ++++++++++++++++++- Application/Mappers/CardBDatumMapper.cs | 11 +++ Application/Mappers/CardDetailMapper.cs | 2 + Application/Mappers/MusicAouMapper.cs | 13 +++ Application/Mappers/MusicExtraMapper.cs | 13 +++ Domain/Config/GameConfig.cs | 2 + Domain/Config/UnlockRewardConfig.cs | 14 +++ MainServer/Configurations/game.json | 37 ++++++++ 34 files changed, 632 insertions(+), 25 deletions(-) create mode 100644 Application/Dto/CardBDatumDto.cs create mode 100644 Application/Dto/CoinDto.cs create mode 100644 Application/Dto/MusicAouDto.cs create mode 100644 Application/Dto/MusicExtraDto.cs create mode 100644 Application/Dto/NavigatorDto.cs create mode 100644 Application/Dto/SkinDto.cs create mode 100644 Application/Dto/SoundEffectDto.cs create mode 100644 Application/Dto/TitleDto.cs create mode 100644 Application/Dto/TotalTrophyDto.cs create mode 100644 Application/Dto/UnlockKeyNumDto.cs create mode 100644 Application/Mappers/CardBDatumMapper.cs create mode 100644 Application/Mappers/MusicAouMapper.cs create mode 100644 Application/Mappers/MusicExtraMapper.cs create mode 100644 Domain/Config/UnlockRewardConfig.cs diff --git a/Application/Dto/CardBDatumDto.cs b/Application/Dto/CardBDatumDto.cs new file mode 100644 index 0000000..d9e27d3 --- /dev/null +++ b/Application/Dto/CardBDatumDto.cs @@ -0,0 +1,15 @@ +using System.Xml.Serialization; + +namespace Application.Dto; + +public class CardBDatumDto +{ + [XmlElement(ElementName = "card_id")] + public long CardId { get; set; } + + [XmlElement(ElementName = "bdata")] + public string CardBdata { get; set; } = string.Empty; + + [XmlElement(ElementName = "bdata_size")] + public int BDataSize { get; set; } +} \ No newline at end of file diff --git a/Application/Dto/CardDetailDto.cs b/Application/Dto/CardDetailDto.cs index 63d6bd7..8808023 100644 --- a/Application/Dto/CardDetailDto.cs +++ b/Application/Dto/CardDetailDto.cs @@ -51,7 +51,7 @@ public class CardDetailDto [XmlElement(ElementName = "last_play_tenpo_id")] [DefaultValue("GC local server")] - public string LastPlayShopId { get; set; } = "GC local server"; + public string LastPlayTenpoId { get; set; } = "GC local server"; [XmlElement("fcol1")] public int Fcol1 { get; set; } diff --git a/Application/Dto/CoinDto.cs b/Application/Dto/CoinDto.cs new file mode 100644 index 0000000..31efb21 --- /dev/null +++ b/Application/Dto/CoinDto.cs @@ -0,0 +1,24 @@ +using System.Xml.Serialization; + +namespace Application.Dto; + +public class CoinDto +{ + [XmlElement(ElementName = "card_id")] + public long CardId { get; set; } + + [XmlElement(ElementName = "current")] + public int CurrentCoins { get; set; } + + [XmlElement(ElementName = "total")] + public int TotalCoins { get; set; } + + [XmlElement("monthly")] + public int MonthlyCoins { get; set; } + + [XmlElement("created")] + public string Created { get; set; } = string.Empty; + + [XmlElement("modified")] + public string Modified { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/Application/Dto/MusicAouDto.cs b/Application/Dto/MusicAouDto.cs new file mode 100644 index 0000000..7c6ec04 --- /dev/null +++ b/Application/Dto/MusicAouDto.cs @@ -0,0 +1,15 @@ +using System.Xml.Serialization; + +namespace Application.Dto; + +public class MusicAouDto +{ + [XmlAttribute(AttributeName = "id")] + public int Id { get; set; } + + [XmlElement(ElementName = "music_id")] + public int MusicId { get; set; } + + [XmlElement(ElementName = "use_flag")] + public int UseFlag { get; set; } +} \ No newline at end of file diff --git a/Application/Dto/MusicExtraDto.cs b/Application/Dto/MusicExtraDto.cs new file mode 100644 index 0000000..1edb304 --- /dev/null +++ b/Application/Dto/MusicExtraDto.cs @@ -0,0 +1,15 @@ +using System.Xml.Serialization; + +namespace Application.Dto; + +public class MusicExtraDto +{ + [XmlAttribute(AttributeName = "id")] + public int Id { get; set; } + + [XmlElement(ElementName = "music_id")] + public int MusicId { get; set; } + + [XmlElement(ElementName = "use_flag")] + public int UseFlag { get; set; } +} \ No newline at end of file diff --git a/Application/Dto/NavigatorDto.cs b/Application/Dto/NavigatorDto.cs new file mode 100644 index 0000000..930b637 --- /dev/null +++ b/Application/Dto/NavigatorDto.cs @@ -0,0 +1,27 @@ +using System.Xml.Serialization; + +namespace Application.Dto; + +public class NavigatorDto +{ + [XmlAttribute(AttributeName = "id")] + public int Id { get; set; } + + [XmlElement(ElementName = "card_id")] + public long CardId { get; set; } + + [XmlElement(ElementName = "navigator_id")] + public int NavigatorId { get; set; } + + [XmlElement("created")] + public string Created { get; set; } = string.Empty; + + [XmlElement("modified")] + public string Modified { get; set; } = string.Empty; + + [XmlElement("new_flag")] + public int NewFlag { get; set; } + + [XmlElement("use_flag")] + public int UseFlag { get; set; } +} \ No newline at end of file diff --git a/Application/Dto/SkinDto.cs b/Application/Dto/SkinDto.cs new file mode 100644 index 0000000..b05cae5 --- /dev/null +++ b/Application/Dto/SkinDto.cs @@ -0,0 +1,27 @@ +using System.Xml.Serialization; + +namespace Application.Dto; + +public class SkinDto +{ + [XmlAttribute(AttributeName = "id")] + public int Id { get; set; } + + [XmlElement(ElementName = "card_id")] + public long CardId { get; set; } + + [XmlElement(ElementName = "skin_id")] + public int SkinId { get; set; } + + [XmlElement("created")] + public string Created { get; set; } = string.Empty; + + [XmlElement("modified")] + public string Modified { get; set; } = string.Empty; + + [XmlElement("new_flag")] + public int NewFlag { get; set; } + + [XmlElement("use_flag")] + public int UseFlag { get; set; } +} \ No newline at end of file diff --git a/Application/Dto/SoundEffectDto.cs b/Application/Dto/SoundEffectDto.cs new file mode 100644 index 0000000..4a17b26 --- /dev/null +++ b/Application/Dto/SoundEffectDto.cs @@ -0,0 +1,27 @@ +using System.Xml.Serialization; + +namespace Application.Dto; + +public class SoundEffectDto +{ + [XmlAttribute(AttributeName = "id")] + public int Id { get; set; } + + [XmlElement(ElementName = "card_id")] + public long CardId { get; set; } + + [XmlElement(ElementName = "sound_effect_id")] + public int SoundEffectId { get; set; } + + [XmlElement("created")] + public string Created { get; set; } = string.Empty; + + [XmlElement("modified")] + public string Modified { get; set; } = string.Empty; + + [XmlElement("new_flag")] + public int NewFlag { get; set; } + + [XmlElement("use_flag")] + public int UseFlag { get; set; } +} \ No newline at end of file diff --git a/Application/Dto/TitleDto.cs b/Application/Dto/TitleDto.cs new file mode 100644 index 0000000..8f22dcb --- /dev/null +++ b/Application/Dto/TitleDto.cs @@ -0,0 +1,27 @@ +using System.Xml.Serialization; + +namespace Application.Dto; + +public class TitleDto +{ + [XmlAttribute(AttributeName = "id")] + public int Id { get; set; } + + [XmlElement(ElementName = "card_id")] + public long CardId { get; set; } + + [XmlElement(ElementName = "title_id")] + public int TitleId { get; set; } + + [XmlElement("created")] + public string Created { get; set; } = string.Empty; + + [XmlElement("modified")] + public string Modified { get; set; } = string.Empty; + + [XmlElement("new_flag")] + public int NewFlag { get; set; } + + [XmlElement("use_flag")] + public int UseFlag { get; set; } +} \ No newline at end of file diff --git a/Application/Dto/TotalTrophyDto.cs b/Application/Dto/TotalTrophyDto.cs new file mode 100644 index 0000000..1e37f89 --- /dev/null +++ b/Application/Dto/TotalTrophyDto.cs @@ -0,0 +1,12 @@ +using System.Xml.Serialization; + +namespace Application.Dto; + +public class TotalTrophyDto +{ + [XmlElement(ElementName = "card_id")] + public long CardId { get; set; } + + [XmlElement(ElementName = "total_trophy_num")] + public int TrophyNum { get; set; } +} \ No newline at end of file diff --git a/Application/Dto/UnlockKeyNumDto.cs b/Application/Dto/UnlockKeyNumDto.cs new file mode 100644 index 0000000..806f2c5 --- /dev/null +++ b/Application/Dto/UnlockKeyNumDto.cs @@ -0,0 +1,36 @@ +using System.Xml.Serialization; + +namespace Application.Dto; + +public class UnlockKeyNumDto +{ + [XmlAttribute(AttributeName = "id")] + public int Id { get; set; } + + [XmlElement(ElementName = "card_id")] + public long CardId { get; set; } + + [XmlElement(ElementName = "reward_id")] + public int RewardId { get; set; } + + [XmlElement(ElementName = "key_num")] + public int KeyNum { get; set; } + + [XmlElement(ElementName = "reward_count")] + public int RewardCount { get; set; } + + [XmlElement("expired_flag")] + public int ExpiredFlag { get; set; } + + [XmlElement("use_flag")] + public int UseFlag { get; set; } + + [XmlElement("cash_flag")] + public int CashFlag { get; set; } + + [XmlElement("created")] + public string Created { get; set; } = string.Empty; + + [XmlElement("modified")] + public string Modified { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/Application/Game/Card/Read/ReadAllCardDetailsQuery.cs b/Application/Game/Card/Read/ReadAllCardDetailsQuery.cs index 5af4e68..489ce5b 100644 --- a/Application/Game/Card/Read/ReadAllCardDetailsQuery.cs +++ b/Application/Game/Card/Read/ReadAllCardDetailsQuery.cs @@ -14,8 +14,8 @@ public record ReadAllCardDetailsQuery(long CardId) : IRequestWrapper; public class ReadAllCardDetailsQueryHandler : CardRequestHandlerBase { - private const string CARD_DETAILS_XPATH = "/root/card_detail/record"; - private const string EMPTY_XPATH = "/root/card_detail"; + private const string CARD_DETAILS_XPATH = "/root/card_detail"; + private const string RECORD_XPATH = $"{CARD_DETAILS_XPATH}/record"; private readonly ILogger logger; @@ -43,7 +43,7 @@ public class ReadAllCardDetailsQueryHandler : CardRequestHandlerBase(result); diff --git a/Application/Game/Card/Read/ReadAvatarQuery.cs b/Application/Game/Card/Read/ReadAvatarQuery.cs index 3211ad4..9cb1f55 100644 --- a/Application/Game/Card/Read/ReadAvatarQuery.cs +++ b/Application/Game/Card/Read/ReadAvatarQuery.cs @@ -31,8 +31,8 @@ public class ReadAvatarQueryHandler : CardRequestHandlerBase; public class ReadCardBDataQueryHandler : CardRequestHandlerBase { - public ReadCardBDataQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate) + private const string CARD_BDATA_XPATH = "/root/card_bdata"; + + private readonly ILogger logger; + + public ReadCardBDataQueryHandler(ICardDependencyAggregate aggregate, ILogger logger) : base(aggregate) { + this.logger = logger; } - public override Task> Handle(ReadCardBDataQuery request, CancellationToken cancellationToken) + public override async Task> Handle(ReadCardBDataQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var exists = await CardDbContext.CardMains.AnyAsync(card => card.CardId == request.CardId, cancellationToken: cancellationToken); + if (!exists) + { + logger.LogWarning("Card id: {CardId} does not exist!", request.CardId); + return ServiceResult.Failed( + new ServiceError($"Card id: {request.CardId} does not exist!", (int)CardReturnCode.CardNotRegistered)); + } + + var bdata = await CardDbContext.CardBdata.FirstOrDefaultAsync( + card => card.CardId == request.CardId, cancellationToken: cancellationToken); + + var result = bdata?.CardBDatumToDto().SerializeCardData(CARD_BDATA_XPATH) + ?? new object().SerializeCardData(CARD_BDATA_XPATH); + + return new ServiceResult(result); } } diff --git a/Application/Game/Card/Read/ReadCoinQuery.cs b/Application/Game/Card/Read/ReadCoinQuery.cs index 105ce07..e9358d3 100644 --- a/Application/Game/Card/Read/ReadCoinQuery.cs +++ b/Application/Game/Card/Read/ReadCoinQuery.cs @@ -1,5 +1,6 @@ using Application.Common.Extensions; using Application.Common.Models; +using Application.Dto; using Application.Interfaces; using Domain.Enums; using Microsoft.EntityFrameworkCore; @@ -11,12 +12,26 @@ public record ReadCoinQuery(long CardId) : IRequestWrapper; public class ReadCoinQueryHandler : CardRequestHandlerBase { + private const string COIN_XPATH = "/root/coin"; + public ReadCoinQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate) { } public override Task> Handle(ReadCoinQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var dto = new CoinDto + { + CardId = request.CardId, + CurrentCoins = 900000, + MonthlyCoins = 900000, + TotalCoins = 900000, + Created = "2013-01-01 08:00:00", + Modified = "2013-01-01 08:00:00" + }; + + var result = dto.SerializeCardData(COIN_XPATH); + + return Task.FromResult(new ServiceResult(result)); } } diff --git a/Application/Game/Card/Read/ReadCondQuery.cs b/Application/Game/Card/Read/ReadCondQuery.cs index 97b06ff..e8cb258 100644 --- a/Application/Game/Card/Read/ReadCondQuery.cs +++ b/Application/Game/Card/Read/ReadCondQuery.cs @@ -11,12 +11,16 @@ public record ReadCondQuery(long CardId) : IRequestWrapper; public class ReadCondQueryHandler : CardRequestHandlerBase { + private const string COND_XPATH = "/root/cond"; + public ReadCondQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate) { } public override Task> Handle(ReadCondQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var result = new object().SerializeCardData(COND_XPATH); + + return Task.FromResult(new ServiceResult(result)); } } diff --git a/Application/Game/Card/Read/ReadEventRewardQuery.cs b/Application/Game/Card/Read/ReadEventRewardQuery.cs index 99e5180..6f18ba7 100644 --- a/Application/Game/Card/Read/ReadEventRewardQuery.cs +++ b/Application/Game/Card/Read/ReadEventRewardQuery.cs @@ -11,12 +11,16 @@ public record ReadEventRewardQuery(long CardId) : IRequestWrapper; public class ReadEventRewardQueryHandler : CardRequestHandlerBase { + private const string EVENT_REWARD_XPATH = "/root/event_reward"; + public ReadEventRewardQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate) { } public override Task> Handle(ReadEventRewardQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var result = new object().SerializeCardData(EVENT_REWARD_XPATH); + + return Task.FromResult(new ServiceResult(result)); } } diff --git a/Application/Game/Card/Read/ReadGetMessageQuery.cs b/Application/Game/Card/Read/ReadGetMessageQuery.cs index 4038892..e89ea93 100644 --- a/Application/Game/Card/Read/ReadGetMessageQuery.cs +++ b/Application/Game/Card/Read/ReadGetMessageQuery.cs @@ -11,12 +11,16 @@ public record ReadGetMessageQuery(long CardId) : IRequestWrapper; public class ReadGetMessageQueryHandler : CardRequestHandlerBase { + private const string GET_MESSAGE_XPATH = "/root/get_message"; + public ReadGetMessageQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate) { } public override Task> Handle(ReadGetMessageQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var result = new object().SerializeCardData(GET_MESSAGE_XPATH); + + return Task.FromResult(new ServiceResult(result)); } } diff --git a/Application/Game/Card/Read/ReadMusicAouQuery.cs b/Application/Game/Card/Read/ReadMusicAouQuery.cs index e7042f5..cc4adcb 100644 --- a/Application/Game/Card/Read/ReadMusicAouQuery.cs +++ b/Application/Game/Card/Read/ReadMusicAouQuery.cs @@ -1,6 +1,9 @@ +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; using Application.Common.Extensions; using Application.Common.Models; using Application.Interfaces; +using Application.Mappers; using Domain.Enums; using Microsoft.EntityFrameworkCore; @@ -11,12 +14,29 @@ public record ReadMusicAouQuery(long CardId) : IRequestWrapper; public class ReadMusicAouQueryHandler : CardRequestHandlerBase { + private const string MUSIC_AOU_XPATH = "/root/music_aou"; + + private const string RECORD_XPATH = $"{MUSIC_AOU_XPATH}/record"; + public ReadMusicAouQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate) { } - public override Task> Handle(ReadMusicAouQuery request, CancellationToken cancellationToken) + [SuppressMessage("ReSharper.DPA", "DPA0007: Large number of DB records", + Justification = "To return all musics, the whole table need to be returned")] + public override async Task> Handle(ReadMusicAouQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var musics = await MusicDbContext.MusicAous.ToListAsync(cancellationToken: cancellationToken); + var dtoList = musics.Select((aou, i) => + { + var dto = aou.MusicAouToDto(); + dto.Id = i; + return dto; + }).ToList(); + + var result = dtoList.Count == 0 ? new object().SerializeCardData(MUSIC_AOU_XPATH) + : dtoList.SerializeCardDataList(RECORD_XPATH); + + return new ServiceResult(result); } } diff --git a/Application/Game/Card/Read/ReadMusicExtraQuery.cs b/Application/Game/Card/Read/ReadMusicExtraQuery.cs index 6814b44..30e491a 100644 --- a/Application/Game/Card/Read/ReadMusicExtraQuery.cs +++ b/Application/Game/Card/Read/ReadMusicExtraQuery.cs @@ -1,6 +1,7 @@ using Application.Common.Extensions; using Application.Common.Models; using Application.Interfaces; +using Application.Mappers; using Domain.Enums; using Microsoft.EntityFrameworkCore; @@ -11,12 +12,27 @@ public record ReadMusicExtraQuery(long CardId) : IRequestWrapper; public class ReadMusicExtraQueryHandler : CardRequestHandlerBase { + private const string MUSIC_EXTRA_XPATH = "/root/music_extra"; + + private const string RECORD_XPATH = $"{MUSIC_EXTRA_XPATH}/record"; + public ReadMusicExtraQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate) { } - public override Task> Handle(ReadMusicExtraQuery request, CancellationToken cancellationToken) + public override async Task> Handle(ReadMusicExtraQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var musics = await MusicDbContext.MusicExtras.ToListAsync(cancellationToken: cancellationToken); + var dtoList = musics.Select((aou, i) => + { + var dto = aou.MusicExtraToDto(); + dto.Id = i; + return dto; + }).ToList(); + + var result = dtoList.Count == 0 ? new object().SerializeCardData(MUSIC_EXTRA_XPATH) + : dtoList.SerializeCardDataList(RECORD_XPATH); + + return new ServiceResult(result); } } diff --git a/Application/Game/Card/Read/ReadNavigatorQuery.cs b/Application/Game/Card/Read/ReadNavigatorQuery.cs index e0a9cd9..5da8a32 100644 --- a/Application/Game/Card/Read/ReadNavigatorQuery.cs +++ b/Application/Game/Card/Read/ReadNavigatorQuery.cs @@ -1,5 +1,6 @@ using Application.Common.Extensions; using Application.Common.Models; +using Application.Dto; using Application.Interfaces; using Domain.Config; using Domain.Enums; @@ -13,6 +14,7 @@ public record ReadNavigatorQuery(long CardId) : IRequestWrapper; public class ReadNavigatorQueryHandler : CardRequestHandlerBase { + private const string NAVIGATOR_XPATH = "/root/navigator/record"; public ReadNavigatorQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate) { @@ -20,6 +22,26 @@ public class ReadNavigatorQueryHandler : CardRequestHandlerBase> Handle(ReadNavigatorQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var count = Config.NavigatorCount; + + var list = new List(); + for (int i = 0; i < count; i++) + { + var navigator = new NavigatorDto + { + Id = i, + CardId = request.CardId, + NavigatorId = i, + Created = "2013-01-01 08:00:00", + Modified = "2013-01-01 08:00:00", + NewFlag = 0, + UseFlag = 1 + }; + list.Add(navigator); + } + + var result = list.SerializeCardDataList(NAVIGATOR_XPATH); + + return Task.FromResult(new ServiceResult(result)); } } diff --git a/Application/Game/Card/Read/ReadSkinQuery.cs b/Application/Game/Card/Read/ReadSkinQuery.cs index 68516dd..b14cbb1 100644 --- a/Application/Game/Card/Read/ReadSkinQuery.cs +++ b/Application/Game/Card/Read/ReadSkinQuery.cs @@ -1,5 +1,6 @@ using Application.Common.Extensions; using Application.Common.Models; +using Application.Dto; using Application.Interfaces; using Domain.Enums; using Microsoft.EntityFrameworkCore; @@ -11,12 +12,34 @@ public record ReadSkinQuery(long CardId) : IRequestWrapper; public class ReadSkinQueryHandler : CardRequestHandlerBase { + private const string SKIN_XPATH = "/root/skin/record"; + public ReadSkinQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate) { } public override Task> Handle(ReadSkinQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var count = Config.SkinCount; + + var list = new List(); + for (int i = 0; i < count; i++) + { + var skin = new SkinDto + { + Id = i, + CardId = request.CardId, + SkinId = i, + Created = "2013-01-01 08:00:00", + Modified = "2013-01-01 08:00:00", + NewFlag = 0, + UseFlag = 1 + }; + list.Add(skin); + } + + var result = list.SerializeCardDataList(SKIN_XPATH); + + return Task.FromResult(new ServiceResult(result)); } } diff --git a/Application/Game/Card/Read/ReadSoundEffectQuery.cs b/Application/Game/Card/Read/ReadSoundEffectQuery.cs index 197fb29..3c9958b 100644 --- a/Application/Game/Card/Read/ReadSoundEffectQuery.cs +++ b/Application/Game/Card/Read/ReadSoundEffectQuery.cs @@ -1,5 +1,6 @@ using Application.Common.Extensions; using Application.Common.Models; +using Application.Dto; using Application.Interfaces; using Domain.Enums; using Microsoft.EntityFrameworkCore; @@ -11,12 +12,33 @@ public record ReadSoundEffectQuery(long CardId) : IRequestWrapper; public class ReadSoundEffectQueryHandler : CardRequestHandlerBase { + private const string SOUND_EFFECT_XPATH = "/root/sound_effect/record"; public ReadSoundEffectQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate) { } public override Task> Handle(ReadSoundEffectQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var count = Config.SeCount; + + var list = new List(); + for (int i = 0; i < count; i++) + { + var soundEffect = new SoundEffectDto + { + Id = i, + CardId = request.CardId, + SoundEffectId = i, + Created = "2013-01-01 08:00:00", + Modified = "2013-01-01 08:00:00", + NewFlag = 0, + UseFlag = 1 + }; + list.Add(soundEffect); + } + + var result = list.SerializeCardDataList(SOUND_EFFECT_XPATH); + + return Task.FromResult(new ServiceResult(result)); } } diff --git a/Application/Game/Card/Read/ReadTitleQuery.cs b/Application/Game/Card/Read/ReadTitleQuery.cs index 29eb4d5..8345991 100644 --- a/Application/Game/Card/Read/ReadTitleQuery.cs +++ b/Application/Game/Card/Read/ReadTitleQuery.cs @@ -1,5 +1,6 @@ using Application.Common.Extensions; using Application.Common.Models; +using Application.Dto; using Application.Interfaces; using Domain.Enums; using Microsoft.EntityFrameworkCore; @@ -11,12 +12,34 @@ public record ReadTitleQuery(long CardId) : IRequestWrapper; public class ReadTitleQueryHandler : CardRequestHandlerBase { + private const string TITLE_XPATH = "/root/title/record"; + public ReadTitleQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate) { } public override Task> Handle(ReadTitleQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var count = Config.TitleCount; + + var list = new List(); + for (int i = 0; i < count; i++) + { + var soundEffect = new TitleDto + { + Id = i, + CardId = request.CardId, + TitleId = i, + Created = "2013-01-01 08:00:00", + Modified = "2013-01-01 08:00:00", + NewFlag = 0, + UseFlag = 1 + }; + list.Add(soundEffect); + } + + var result = list.SerializeCardDataList(TITLE_XPATH); + + return Task.FromResult(new ServiceResult(result)); } } diff --git a/Application/Game/Card/Read/ReadTotalTrophyQuery.cs b/Application/Game/Card/Read/ReadTotalTrophyQuery.cs index 047cb2f..d90d00b 100644 --- a/Application/Game/Card/Read/ReadTotalTrophyQuery.cs +++ b/Application/Game/Card/Read/ReadTotalTrophyQuery.cs @@ -1,5 +1,6 @@ using Application.Common.Extensions; using Application.Common.Models; +using Application.Dto; using Application.Interfaces; using Domain.Enums; using Microsoft.EntityFrameworkCore; @@ -11,12 +12,22 @@ public record ReadTotalTrophyQuery(long CardId) : IRequestWrapper; public class ReadTotalTrophyQueryHandler : CardRequestHandlerBase { + private const string TOTAL_TROPHY_XPATH = "/root/total_trophy"; + public ReadTotalTrophyQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate) { } public override Task> Handle(ReadTotalTrophyQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var trophy = new TotalTrophyDto + { + CardId = request.CardId, + TrophyNum = 8 + }; + + var result = trophy.SerializeCardData(TOTAL_TROPHY_XPATH); + + return Task.FromResult(new ServiceResult(result)); } } diff --git a/Application/Game/Card/Read/ReadUnlockKeynumQuery.cs b/Application/Game/Card/Read/ReadUnlockKeynumQuery.cs index cdbeeda..10eeda0 100644 --- a/Application/Game/Card/Read/ReadUnlockKeynumQuery.cs +++ b/Application/Game/Card/Read/ReadUnlockKeynumQuery.cs @@ -1,5 +1,6 @@ using Application.Common.Extensions; using Application.Common.Models; +using Application.Dto; using Application.Interfaces; using Domain.Enums; using Microsoft.EntityFrameworkCore; @@ -11,12 +12,31 @@ public record ReadUnlockKeynumQuery(long CardId) : IRequestWrapper; public class ReadUnlockKeynumQueryHandler : CardRequestHandlerBase { + private const string UNLOCK_KEYNUM_XPATH = "/root/unlock_keynum/record"; public ReadUnlockKeynumQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate) { } public override Task> Handle(ReadUnlockKeynumQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var unlockables = Config.UnlockRewards; + var list = unlockables.Select((unlockable, index) => new UnlockKeyNumDto + { + Id = index, + CardId = request.CardId, + RewardId = unlockable.RewardId, + KeyNum = 0, + RewardCount = 0, + CashFlag = 0, + ExpiredFlag = 0, + UseFlag = 1, + Created = "2013-01-01 08:00:00", + Modified = "2020-01-01 08:00:00" + }) + .ToList(); + var result = list.SerializeCardDataList(UNLOCK_KEYNUM_XPATH); + + return Task.FromResult(new ServiceResult(result)); + } } diff --git a/Application/Game/Card/Read/ReadUnlockRewardQuery.cs b/Application/Game/Card/Read/ReadUnlockRewardQuery.cs index d84ea28..e655a15 100644 --- a/Application/Game/Card/Read/ReadUnlockRewardQuery.cs +++ b/Application/Game/Card/Read/ReadUnlockRewardQuery.cs @@ -1,3 +1,4 @@ +using System.Xml.Serialization; using Application.Common.Extensions; using Application.Common.Models; using Application.Interfaces; @@ -11,12 +12,96 @@ public record ReadUnlockRewardQuery(long CardId) : IRequestWrapper; public class ReadUnlockRewardQueryHandler : CardRequestHandlerBase { + private const string UNLOCK_REWARD_XPATH = "/root/unlock_reward/record"; + public ReadUnlockRewardQueryHandler(ICardDependencyAggregate aggregate) : base(aggregate) { } public override Task> Handle(ReadUnlockRewardQuery request, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var config = Config.UnlockRewards; + var list = config.Select((rewardConfig, i) => new UnlockRewardModel + { + Id = i, + CardId = request.CardId, + RewardId = rewardConfig.RewardId, + RewardType = rewardConfig.RewardType, + TargetId = rewardConfig.TargetId, + TargetNum = rewardConfig.TargetNum, + KeyNum = rewardConfig.KeyNum, + DisplayFlag = 1, + UseFlag = 1, + LimitedFlag = 0, + Created = "2013-01-01 08:00:00", + Modified = "2013-01-01 08:00:00", + OpenDate = "2013-01-01", + CloseDate = "2030-01-01", + OpenTime = "00:00:01", + CloseTime = "23:59:59", + OpenUnixTime = new DateTimeOffset(2013, 1, 1, 0, 0, 1, TimeSpan.Zero).ToUnixTimeSeconds(), + CloseUnixTime = new DateTimeOffset(2030, 1, 1, 23, 59, 59, TimeSpan.Zero).ToUnixTimeSeconds() + }); + + var result = list.SerializeCardDataList(UNLOCK_REWARD_XPATH); + + return Task.FromResult(new ServiceResult(result)); } } + +public class UnlockRewardModel +{ + [XmlAttribute(AttributeName = "id")] + public int Id { get; set; } + + [XmlElement(ElementName = "card_id")] + public long CardId { get; set; } + + [XmlElement(ElementName = "reward_id")] + public int RewardId { get; set; } + + [XmlElement(ElementName = "reward_type")] + public int RewardType { get; set; } + + [XmlElement(ElementName = "open_date")] + public string OpenDate { get; set; } = "2013-01-01"; + + [XmlElement(ElementName = "close_date")] + public string CloseDate { get; set; } = "2030-01-01"; + + [XmlElement(ElementName = "open_time")] + public string OpenTime { get; set; } = "00:00:01"; + + [XmlElement(ElementName = "close_time")] + public string CloseTime { get; set; } = "23:59:59"; + + [XmlElement(ElementName = "target_id")] + public int TargetId { get; set; } + + [XmlElement(ElementName = "target_num")] + public int TargetNum { get; set; } + + [XmlElement(ElementName = "key_num")] + public int KeyNum { get; set; } + + [XmlElement("display_flag")] + public int DisplayFlag { get; set; } + + [XmlElement("use_flag")] + public int UseFlag { get; set; } + + [XmlElement("limited_flag")] + public int LimitedFlag { get; set; } + + [XmlElement("open_unixtime")] + public long OpenUnixTime { get; set; } + + [XmlElement("close_unixtime")] + public long CloseUnixTime { get; set; } + + [XmlElement("created")] + public string Created { get; set; } = string.Empty; + + [XmlElement("modified")] + public string Modified { get; set; } = string.Empty; +} diff --git a/Application/Mappers/CardBDatumMapper.cs b/Application/Mappers/CardBDatumMapper.cs new file mode 100644 index 0000000..0af30f6 --- /dev/null +++ b/Application/Mappers/CardBDatumMapper.cs @@ -0,0 +1,11 @@ +using Application.Dto; +using Domain.Entities; +using Riok.Mapperly.Abstractions; + +namespace Application.Mappers; + +[Mapper] +public static partial class CardBDatumMapper +{ + public static partial CardBDatumDto CardBDatumToDto(this CardBdatum cardBdatum); +} \ No newline at end of file diff --git a/Application/Mappers/CardDetailMapper.cs b/Application/Mappers/CardDetailMapper.cs index 94c9f5a..24a107c 100644 --- a/Application/Mappers/CardDetailMapper.cs +++ b/Application/Mappers/CardDetailMapper.cs @@ -8,4 +8,6 @@ namespace Application.Mappers; public static partial class CardDetailMapper { public static partial CardDetailDto CardDetailToDto(this CardDetail cardDetail); + + public static partial CardDetail DtoToCardDetail(this CardDetailDto dto); } \ No newline at end of file diff --git a/Application/Mappers/MusicAouMapper.cs b/Application/Mappers/MusicAouMapper.cs new file mode 100644 index 0000000..da3e393 --- /dev/null +++ b/Application/Mappers/MusicAouMapper.cs @@ -0,0 +1,13 @@ +using Application.Dto; +using Domain.Entities; +using Riok.Mapperly.Abstractions; + +namespace Application.Mappers; + +[Mapper] +public static partial class MusicAouMapper +{ + public static partial MusicAouDto MusicAouToDto(this MusicAou musicAou); + + private static int BoolToInt(bool value) => value ? 1 : 0; +} \ No newline at end of file diff --git a/Application/Mappers/MusicExtraMapper.cs b/Application/Mappers/MusicExtraMapper.cs new file mode 100644 index 0000000..2a9a54f --- /dev/null +++ b/Application/Mappers/MusicExtraMapper.cs @@ -0,0 +1,13 @@ +using Application.Dto; +using Domain.Entities; +using Riok.Mapperly.Abstractions; + +namespace Application.Mappers; + +[Mapper] +public static partial class MusicExtraMapper +{ + public static partial MusicExtraDto MusicExtraToDto(this MusicExtra musicExtra); + + private static int BoolToInt(bool value) => value ? 1 : 0; +} \ No newline at end of file diff --git a/Domain/Config/GameConfig.cs b/Domain/Config/GameConfig.cs index c121938..c7a5c00 100644 --- a/Domain/Config/GameConfig.cs +++ b/Domain/Config/GameConfig.cs @@ -17,4 +17,6 @@ public class GameConfig public int TitleCount { get; set; } public List UnlockableSongIds { get; set; } = new(); + + public List UnlockRewards { get; set; } = new(); } \ No newline at end of file diff --git a/Domain/Config/UnlockRewardConfig.cs b/Domain/Config/UnlockRewardConfig.cs new file mode 100644 index 0000000..5209bae --- /dev/null +++ b/Domain/Config/UnlockRewardConfig.cs @@ -0,0 +1,14 @@ +namespace Domain.Config; + +public class UnlockRewardConfig +{ + public int RewardId { get; set; } + + public int RewardType { get; set; } + + public int TargetId { get; set; } + + public int TargetNum { get; set; } + + public int KeyNum { get; set; } +} \ No newline at end of file diff --git a/MainServer/Configurations/game.json b/MainServer/Configurations/game.json index 1c7a24e..e8b45c2 100644 --- a/MainServer/Configurations/game.json +++ b/MainServer/Configurations/game.json @@ -12,6 +12,43 @@ 494, 498, 520, 548, 551, 558, 561, 565, 570, 577, 583, 612, 615, 622, 632, 659, 666, 668, 670, 672, 676, 680, 682, 685, 686, 697, 700, 701, 711, 720, 749, 875, 876, 877 + ], + "UnlockReward": [ + { + "RewardId" : 1, + "RewardType" : 1, + "TargetId" : 1, + "TargetNum": 1, + "KeyNum": 1 + }, + { + "RewardId" : 2, + "RewardType" : 2, + "TargetId" : 11, + "TargetNum": 1, + "KeyNum": 1 + }, + { + "RewardId" : 3, + "RewardType" : 3, + "TargetId" : 11, + "TargetNum": 1, + "KeyNum": 1 + }, + { + "RewardId" : 4, + "RewardType" : 4, + "TargetId" : 11, + "TargetNum": 1, + "KeyNum": 1 + }, + { + "RewardId" : 5, + "RewardType" : 5, + "TargetId" : 11, + "TargetNum": 1, + "KeyNum": 1 + } ] } } \ No newline at end of file