Fix alive, migrate write, add online matching stub, start rank
This commit is contained in:
parent
5c85e83c3e
commit
02a241567c
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ChoETL" Version="1.2.1.52" />
|
<PackageReference Include="ChoETL" Version="1.2.1.52" />
|
||||||
|
<PackageReference Include="FlexLabs.EntityFrameworkCore.Upsert" Version="7.0.0" />
|
||||||
<PackageReference Include="MediatR" Version="11.1.0" />
|
<PackageReference Include="MediatR" Version="11.1.0" />
|
||||||
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
|
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||||
@ -21,4 +22,8 @@
|
|||||||
<PackageReference Include="Throw" Version="1.3.1" />
|
<PackageReference Include="Throw" Version="1.3.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Game\Rank" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
9
Application/Common/Helpers/TimeHelper.cs
Normal file
9
Application/Common/Helpers/TimeHelper.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace Application.Common.Helpers;
|
||||||
|
|
||||||
|
public static class TimeHelper
|
||||||
|
{
|
||||||
|
public static string CurrentTimeToString()
|
||||||
|
{
|
||||||
|
return DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,18 @@
|
|||||||
namespace Application.Game.Card.OnlineMatching;
|
using Application.Common.Models;
|
||||||
|
using Application.Interfaces;
|
||||||
|
|
||||||
public class StartOnlineMatchingCommand
|
namespace Application.Game.Card.OnlineMatching;
|
||||||
|
|
||||||
|
public record StartOnlineMatchingCommand(long CardId, string Data) : IRequestWrapper<string>;
|
||||||
|
|
||||||
|
public class StartOnlineMatchingCommandHandler : CardRequestHandlerBase<StartOnlineMatchingCommand, string>
|
||||||
{
|
{
|
||||||
|
public StartOnlineMatchingCommandHandler(ICardDependencyAggregate aggregate) : base(aggregate)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task<ServiceResult<string>> Handle(StartOnlineMatchingCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,18 @@
|
|||||||
namespace Application.Game.Card.OnlineMatching;
|
using Application.Common.Models;
|
||||||
|
using Application.Interfaces;
|
||||||
|
|
||||||
public class UpdateOnlineMatchingCommand
|
namespace Application.Game.Card.OnlineMatching;
|
||||||
|
|
||||||
|
public record UpdateOnlineMatchingCommand(long CardId, string Data) : IRequestWrapper<string>;
|
||||||
|
|
||||||
|
public class UpdateOnlineMatchingCommandHandler : CardRequestHandlerBase<UpdateOnlineMatchingCommand, string>
|
||||||
{
|
{
|
||||||
|
public UpdateOnlineMatchingCommandHandler(ICardDependencyAggregate aggregate) : base(aggregate)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task<ServiceResult<string>> Handle(UpdateOnlineMatchingCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,18 @@
|
|||||||
namespace Application.Game.Card.OnlineMatching;
|
using Application.Common.Models;
|
||||||
|
using Application.Interfaces;
|
||||||
|
|
||||||
public class UploadOnlineMatchingResultCommand
|
namespace Application.Game.Card.OnlineMatching;
|
||||||
|
|
||||||
|
public record UploadOnlineMatchingResultCommand(long CardId, string Data) : IRequestWrapper<string>;
|
||||||
|
|
||||||
|
public class UploadOnlineMatchingResultCommandHandler : CardRequestHandlerBase<UploadOnlineMatchingResultCommand, string>
|
||||||
{
|
{
|
||||||
|
public UploadOnlineMatchingResultCommandHandler(ICardDependencyAggregate aggregate) : base(aggregate)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task<ServiceResult<string>> Handle(UploadOnlineMatchingResultCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
42
Application/Game/Card/Write/WriteCardBDataCommand.cs
Normal file
42
Application/Game/Card/Write/WriteCardBDataCommand.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
using Application.Common.Extensions;
|
||||||
|
using Application.Common.Models;
|
||||||
|
using Application.Dto;
|
||||||
|
using Application.Interfaces;
|
||||||
|
using Application.Mappers;
|
||||||
|
using Domain.Enums;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace Application.Game.Card.Write;
|
||||||
|
|
||||||
|
public record WriteCardBDataCommand(long CardId, string Data) : IRequestWrapper<string>;
|
||||||
|
|
||||||
|
public class WriteCardBDataCommandHandler : CardRequestHandlerBase<WriteCardBDataCommand, string>
|
||||||
|
{
|
||||||
|
private readonly ILogger<WriteCardBDataCommandHandler> logger;
|
||||||
|
|
||||||
|
public WriteCardBDataCommandHandler(ICardDependencyAggregate aggregate, ILogger<WriteCardBDataCommandHandler> logger) : base(aggregate)
|
||||||
|
{
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<ServiceResult<string>> Handle(WriteCardBDataCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
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<string>(
|
||||||
|
new ServiceError($"Card id: {request.CardId} does not exist!", (int)CardReturnCode.CardNotRegistered));
|
||||||
|
}
|
||||||
|
|
||||||
|
var dto = request.Data.DeserializeCardData<CardBDatumDto>();
|
||||||
|
var data = dto.DtoToCardBDatum();
|
||||||
|
data.CardId = request.CardId;
|
||||||
|
CardDbContext.CardBdata.Upsert(data);
|
||||||
|
|
||||||
|
await CardDbContext.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
|
return new ServiceResult<string>(request.Data);
|
||||||
|
}
|
||||||
|
}
|
53
Application/Game/Card/Write/WriteCardCommand.cs
Normal file
53
Application/Game/Card/Write/WriteCardCommand.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using Application.Common.Extensions;
|
||||||
|
using Application.Common.Helpers;
|
||||||
|
using Application.Common.Models;
|
||||||
|
using Application.Dto;
|
||||||
|
using Application.Interfaces;
|
||||||
|
using Application.Mappers;
|
||||||
|
using Domain.Enums;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace Application.Game.Card.Write;
|
||||||
|
|
||||||
|
public record WriteCardCommand(long CardId, string Data) : IRequestWrapper<string>;
|
||||||
|
|
||||||
|
public class WriteCardCommandHandler : CardRequestHandlerBase<WriteCardCommand, string>
|
||||||
|
{
|
||||||
|
private readonly ILogger<WriteCardCommandHandler> logger;
|
||||||
|
|
||||||
|
public WriteCardCommandHandler(ICardDependencyAggregate aggregate, ILogger<WriteCardCommandHandler> logger) : base(aggregate)
|
||||||
|
{
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<ServiceResult<string>> Handle(WriteCardCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var dto = request.Data.DeserializeCardData<CardDto>();
|
||||||
|
dto.CardId = request.CardId;
|
||||||
|
|
||||||
|
var card = await CardDbContext.CardMains.FirstOrDefaultAsync(card => card.CardId == request.CardId, cancellationToken: cancellationToken);
|
||||||
|
|
||||||
|
if (card is null)
|
||||||
|
{
|
||||||
|
logger.LogInformation("Creating new card {CardId}", request.CardId);
|
||||||
|
card = dto.CardDtoToCardMain();
|
||||||
|
card.Created = TimeHelper.CurrentTimeToString();
|
||||||
|
CardDbContext.CardMains.Add(card);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogInformation("Updating {CardId}", request.CardId);
|
||||||
|
card.Fcol1 = dto.Fcol1;
|
||||||
|
card.Fcol2 = dto.Fcol2;
|
||||||
|
card.Fcol3 = dto.Fcol3;
|
||||||
|
card.ScoreI1 = dto.ScoreI1;
|
||||||
|
card.Modified = TimeHelper.CurrentTimeToString();
|
||||||
|
CardDbContext.CardMains.Update(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
await CardDbContext.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
|
return new ServiceResult<string>(request.Data);
|
||||||
|
}
|
||||||
|
}
|
43
Application/Game/Card/Write/WriteCardDetailCommand.cs
Normal file
43
Application/Game/Card/Write/WriteCardDetailCommand.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using Application.Common.Extensions;
|
||||||
|
using Application.Common.Models;
|
||||||
|
using Application.Dto;
|
||||||
|
using Application.Interfaces;
|
||||||
|
using Application.Mappers;
|
||||||
|
using Domain.Enums;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace Application.Game.Card.Write;
|
||||||
|
|
||||||
|
public record WriteCardDetailCommand(long CardId, string Data) : IRequestWrapper<string>;
|
||||||
|
|
||||||
|
public class WriteCardDetailCommandHandler : CardRequestHandlerBase<WriteCardDetailCommand, string>
|
||||||
|
{
|
||||||
|
private readonly ILogger<WriteCardDetailCommandHandler> logger;
|
||||||
|
|
||||||
|
public WriteCardDetailCommandHandler(ICardDependencyAggregate aggregate, ILogger<WriteCardDetailCommandHandler> logger) : base(aggregate)
|
||||||
|
{
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<ServiceResult<string>> Handle(WriteCardDetailCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
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<string>(
|
||||||
|
new ServiceError($"Card id: {request.CardId} does not exist!", (int)CardReturnCode.CardNotRegistered));
|
||||||
|
}
|
||||||
|
|
||||||
|
var dto = request.Data.DeserializeCardData<CardDetailDto>();
|
||||||
|
var detail = dto.DtoToCardDetail();
|
||||||
|
detail.CardId = request.CardId;
|
||||||
|
detail.LastPlayTime = DateTime.Now;
|
||||||
|
CardDbContext.CardDetails.Upsert(detail);
|
||||||
|
|
||||||
|
await CardDbContext.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
|
return new ServiceResult<string>(request.Data);
|
||||||
|
}
|
||||||
|
}
|
@ -8,4 +8,6 @@ namespace Application.Mappers;
|
|||||||
public static partial class CardBDatumMapper
|
public static partial class CardBDatumMapper
|
||||||
{
|
{
|
||||||
public static partial CardBDatumDto CardBDatumToDto(this CardBdatum cardBdatum);
|
public static partial CardBDatumDto CardBDatumToDto(this CardBdatum cardBdatum);
|
||||||
|
|
||||||
|
public static partial CardBdatum DtoToCardBDatum(this CardBDatumDto dto);
|
||||||
}
|
}
|
@ -8,6 +8,5 @@ namespace Application.Mappers;
|
|||||||
public static partial class CardMapper
|
public static partial class CardMapper
|
||||||
{
|
{
|
||||||
public static partial CardDto CardMainToCardDto(this CardMain cardMain);
|
public static partial CardDto CardMainToCardDto(this CardMain cardMain);
|
||||||
|
|
||||||
public static partial CardMain CardDtoToCardMain(this CardDto cardDto);
|
public static partial CardMain CardDtoToCardMain(this CardDto cardDto);
|
||||||
}
|
}
|
10
Domain/Enums/RankingCommandType.cs
Normal file
10
Domain/Enums/RankingCommandType.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace Domain.Enums;
|
||||||
|
|
||||||
|
public enum RankingCommandType
|
||||||
|
{
|
||||||
|
GlobalRank = 4119,
|
||||||
|
PlayNumRank = 6657,
|
||||||
|
EventRank = 6661,
|
||||||
|
MonthlyRank = 6666,
|
||||||
|
ShopRank = 4098
|
||||||
|
}
|
@ -1,3 +1,16 @@
|
|||||||
{
|
{
|
||||||
|
"Kestrel": {
|
||||||
|
"Endpoints": {
|
||||||
|
"Http": {
|
||||||
|
"Url": "http://0.0.0.0:80"
|
||||||
|
},
|
||||||
|
"Https": {
|
||||||
|
"Url": "https://0.0.0.0:443"
|
||||||
|
},
|
||||||
|
"Test": {
|
||||||
|
"Url": "http://0.0.0.0:5107"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"ServerIp": "127.0.0.1"
|
"ServerIp": "127.0.0.1"
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ public class AliveController : ControllerBase
|
|||||||
return Ok(response);
|
return Ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("/{id}/Alive.txt")]
|
[HttpGet("{id}/Alive.txt")]
|
||||||
public IActionResult GetAliveFile()
|
public IActionResult GetAliveFile()
|
||||||
{
|
{
|
||||||
return Ok("");
|
return Ok("");
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using Application.Common.Models;
|
using Application.Common.Models;
|
||||||
using Application.Game.Card;
|
using Application.Game.Card;
|
||||||
using Application.Game.Card.Management;
|
using Application.Game.Card.Management;
|
||||||
|
using Application.Game.Card.OnlineMatching;
|
||||||
using Application.Game.Card.Read;
|
using Application.Game.Card.Read;
|
||||||
using Application.Game.Card.Session;
|
using Application.Game.Card.Session;
|
||||||
using Application.Game.Card.Write;
|
using Application.Game.Card.Write;
|
||||||
@ -28,120 +29,69 @@ public class CardController : BaseController<CardController>
|
|||||||
}
|
}
|
||||||
|
|
||||||
request.Data = WebUtility.UrlDecode(request.Data);
|
request.Data = WebUtility.UrlDecode(request.Data);
|
||||||
var result = ServiceResult.Failed<string>(ServiceError.DefaultError);
|
ServiceResult<string> result;
|
||||||
switch (cardCommandType)
|
switch (cardCommandType)
|
||||||
{
|
{
|
||||||
case CardCommandType.CardReadRequest:
|
case CardCommandType.CardReadRequest:
|
||||||
case CardCommandType.CardWriteRequest:
|
case CardCommandType.CardWriteRequest:
|
||||||
{
|
{
|
||||||
switch (cardRequestType)
|
result = cardRequestType switch
|
||||||
{
|
{
|
||||||
case CardRequestType.ReadCard:
|
CardRequestType.ReadCard => await Mediator.Send(new ReadCardQuery(request.CardId)),
|
||||||
result = await Mediator.Send(new ReadCardQuery(request.CardId));
|
CardRequestType.ReadCardDetail => await Mediator.Send(
|
||||||
break;
|
new ReadCardDetailQuery(request.CardId, request.Data)),
|
||||||
case CardRequestType.ReadCardDetail:
|
CardRequestType.ReadCardDetails => await Mediator.Send(new ReadAllCardDetailsQuery(request.CardId)),
|
||||||
result = await Mediator.Send(new ReadCardDetailQuery(request.CardId, request.Data));
|
CardRequestType.ReadCardBData => await Mediator.Send(new ReadCardBDataQuery(request.CardId)),
|
||||||
break;
|
CardRequestType.ReadAvatar => await Mediator.Send(new ReadAvatarQuery(request.CardId)),
|
||||||
case CardRequestType.ReadCardDetails:
|
CardRequestType.ReadItem => await Mediator.Send(new ReadItemQuery(request.CardId)),
|
||||||
result = await Mediator.Send(new ReadAllCardDetailsQuery(request.CardId));
|
CardRequestType.ReadSkin => await Mediator.Send(new ReadSkinQuery(request.CardId)),
|
||||||
break;
|
CardRequestType.ReadTitle => await Mediator.Send(new ReadTitleQuery(request.CardId)),
|
||||||
case CardRequestType.ReadCardBData:
|
CardRequestType.ReadMusic => await Mediator.Send(new ReadMusicQuery(request.CardId)),
|
||||||
result = await Mediator.Send(new ReadCardBDataQuery(request.CardId));
|
CardRequestType.ReadEventReward => await Mediator.Send(new ReadEventRewardQuery(request.CardId)),
|
||||||
break;
|
CardRequestType.ReadNavigator => await Mediator.Send(new ReadNavigatorQuery(request.CardId)),
|
||||||
case CardRequestType.ReadAvatar:
|
CardRequestType.ReadMusicExtra => await Mediator.Send(new ReadMusicExtraQuery(request.CardId)),
|
||||||
result = await Mediator.Send(new ReadAvatarQuery(request.CardId));
|
CardRequestType.ReadMusicAou => await Mediator.Send(new ReadMusicAouQuery(request.CardId)),
|
||||||
break;
|
CardRequestType.ReadCoin => await Mediator.Send(new ReadCoinQuery(request.CardId)),
|
||||||
case CardRequestType.ReadItem:
|
CardRequestType.ReadUnlockReward => await Mediator.Send(new ReadUnlockRewardQuery(request.CardId)),
|
||||||
result = await Mediator.Send(new ReadItemQuery(request.CardId));
|
CardRequestType.ReadUnlockKeynum => await Mediator.Send(new ReadUnlockKeynumQuery(request.CardId)),
|
||||||
break;
|
CardRequestType.ReadSoundEffect => await Mediator.Send(new ReadSoundEffectQuery(request.CardId)),
|
||||||
case CardRequestType.ReadSkin:
|
CardRequestType.ReadGetMessage => await Mediator.Send(new ReadGetMessageQuery(request.CardId)),
|
||||||
result = await Mediator.Send(new ReadSkinQuery(request.CardId));
|
CardRequestType.ReadCond => await Mediator.Send(new ReadCondQuery(request.CardId)),
|
||||||
break;
|
CardRequestType.ReadTotalTrophy => await Mediator.Send(new ReadTotalTrophyQuery(request.CardId)),
|
||||||
case CardRequestType.ReadTitle:
|
CardRequestType.GetSession or CardRequestType.StartSession => await Mediator.Send(
|
||||||
result = await Mediator.Send(new ReadTitleQuery(request.CardId));
|
new GetSessionCommand(request.CardId, request.Mac)),
|
||||||
break;
|
CardRequestType.WriteCard =>
|
||||||
case CardRequestType.ReadNavigator:
|
await Mediator.Send(new WriteCardCommand(request.CardId, request.Data)),
|
||||||
result = await Mediator.Send(new ReadNavigatorQuery(request.CardId));
|
CardRequestType.WriteCardDetail => await Mediator.Send(
|
||||||
break;
|
new WriteCardDetailCommand(request.CardId, request.Data)),
|
||||||
case CardRequestType.ReadSoundEffect:
|
CardRequestType.WriteCardBData => await Mediator.Send(
|
||||||
result = await Mediator.Send(new ReadSoundEffectQuery(request.CardId));
|
new WriteCardBDataCommand(request.CardId, request.Data)),
|
||||||
break;
|
CardRequestType.WriteAvatar => await Mediator.Send(new WriteAvatarCommand(request.CardId,
|
||||||
case CardRequestType.ReadMusic:
|
request.Data)),
|
||||||
result = await Mediator.Send(new ReadMusicQuery(request.CardId));
|
CardRequestType.WriteItem =>
|
||||||
break;
|
await Mediator.Send(new WriteItemCommand(request.CardId, request.Data)),
|
||||||
case CardRequestType.ReadMusicAou:
|
CardRequestType.WriteTitle => await Mediator.Send(new WriteTitleCommand(request.CardId,
|
||||||
result = await Mediator.Send(new ReadMusicAouQuery(request.CardId));
|
request.Data)),
|
||||||
break;
|
CardRequestType.WriteMusicDetail => await Mediator.Send(
|
||||||
case CardRequestType.ReadMusicExtra:
|
new WriteMusicDetailCommand(request.CardId, request.Data)),
|
||||||
result = await Mediator.Send(new ReadMusicExtraQuery(request.CardId));
|
CardRequestType.WriteNavigator => await Mediator.Send(
|
||||||
break;
|
new WriteNavigatorCommand(request.CardId, request.Data)),
|
||||||
case CardRequestType.ReadEventReward:
|
CardRequestType.WriteCoin =>
|
||||||
result = await Mediator.Send(new ReadEventRewardQuery(request.CardId));
|
await Mediator.Send(new WriteCoinCommand(request.CardId, request.Data)),
|
||||||
break;
|
CardRequestType.WriteSkin =>
|
||||||
case CardRequestType.ReadCoin:
|
await Mediator.Send(new WriteSkinCommand(request.CardId, request.Data)),
|
||||||
result = await Mediator.Send(new ReadCoinQuery(request.CardId));
|
CardRequestType.WriteUnlockKeynum => await Mediator.Send(
|
||||||
break;
|
new WriteUnlockKeynumCommand(request.CardId, request.Data)),
|
||||||
case CardRequestType.ReadUnlockReward:
|
CardRequestType.WriteSoundEffect => await Mediator.Send(
|
||||||
result = await Mediator.Send(new ReadUnlockRewardQuery(request.CardId));
|
new WriteSoundEffectCommand(request.CardId, request.Data)),
|
||||||
break;
|
CardRequestType.StartOnlineMatching => await Mediator.Send(
|
||||||
case CardRequestType.ReadUnlockKeynum:
|
new StartOnlineMatchingCommand(request.CardId, request.Data)),
|
||||||
result = await Mediator.Send(new ReadUnlockKeynumQuery(request.CardId));
|
CardRequestType.UpdateOnlineMatching => await Mediator.Send(
|
||||||
break;
|
new UpdateOnlineMatchingCommand(request.CardId, request.Data)),
|
||||||
case CardRequestType.ReadGetMessage:
|
CardRequestType.UploadOnlineMatchingResult => await Mediator.Send(
|
||||||
result = await Mediator.Send(new ReadGetMessageQuery(request.CardId));
|
new UploadOnlineMatchingResultCommand(request.CardId, request.Data)),
|
||||||
break;
|
_ => throw new ArgumentOutOfRangeException(nameof(cardRequestType), cardRequestType, "Should not happen")
|
||||||
case CardRequestType.ReadCond:
|
};
|
||||||
result = await Mediator.Send(new ReadCondQuery(request.CardId));
|
|
||||||
break;
|
|
||||||
case CardRequestType.ReadTotalTrophy:
|
|
||||||
result = await Mediator.Send(new ReadTotalTrophyQuery(request.CardId));
|
|
||||||
break;
|
|
||||||
case CardRequestType.GetSession:
|
|
||||||
case CardRequestType.StartSession:
|
|
||||||
result = await Mediator.Send(new GetSessionCommand(request.CardId, request.Mac));
|
|
||||||
break;
|
|
||||||
case CardRequestType.WriteCard:
|
|
||||||
break;
|
|
||||||
case CardRequestType.WriteCardDetail:
|
|
||||||
break;
|
|
||||||
case CardRequestType.WriteCardBData:
|
|
||||||
break;
|
|
||||||
case CardRequestType.WriteAvatar:
|
|
||||||
result = await Mediator.Send(new WriteAvatarCommand(request.CardId, request.Data));
|
|
||||||
break;
|
|
||||||
case CardRequestType.WriteItem:
|
|
||||||
result = await Mediator.Send(new WriteItemCommand(request.CardId, request.Data));
|
|
||||||
break;
|
|
||||||
case CardRequestType.WriteTitle:
|
|
||||||
result = await Mediator.Send(new WriteTitleCommand(request.CardId, request.Data));
|
|
||||||
break;
|
|
||||||
case CardRequestType.WriteMusicDetail:
|
|
||||||
result = await Mediator.Send(new WriteMusicDetailCommand(request.CardId, request.Data));
|
|
||||||
break;
|
|
||||||
case CardRequestType.WriteNavigator:
|
|
||||||
result = await Mediator.Send(new WriteNavigatorCommand(request.CardId, request.Data));
|
|
||||||
break;
|
|
||||||
case CardRequestType.WriteCoin:
|
|
||||||
result = await Mediator.Send(new WriteCoinCommand(request.CardId, request.Data));
|
|
||||||
break;
|
|
||||||
case CardRequestType.WriteSkin:
|
|
||||||
result = await Mediator.Send(new WriteSkinCommand(request.CardId, request.Data));
|
|
||||||
break;
|
|
||||||
case CardRequestType.WriteUnlockKeynum:
|
|
||||||
result = await Mediator.Send(new WriteUnlockKeynumCommand(request.CardId, request.Data));
|
|
||||||
break;
|
|
||||||
case CardRequestType.WriteSoundEffect:
|
|
||||||
result = await Mediator.Send(new WriteSoundEffectCommand(request.CardId, request.Data));
|
|
||||||
break;
|
|
||||||
case CardRequestType.StartOnlineMatching:
|
|
||||||
break;
|
|
||||||
case CardRequestType.UpdateOnlineMatching:
|
|
||||||
break;
|
|
||||||
case CardRequestType.UploadOnlineMatchingResult:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(message: "Should not happen", paramName:null);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CardCommandType.RegisterRequest:
|
case CardCommandType.RegisterRequest:
|
||||||
@ -151,7 +101,7 @@ public class CardController : BaseController<CardController>
|
|||||||
result = await Mediator.Send(new CardReissueCommand(request.CardId));
|
result = await Mediator.Send(new CardReissueCommand(request.CardId));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException(message: "Should not happen", paramName:null);
|
throw new ArgumentOutOfRangeException(nameof(cardCommandType), cardCommandType, "Should not happen");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.Succeeded)
|
if (result.Succeeded)
|
||||||
|
34
MainServer/Controllers/Game/RankingController.cs
Normal file
34
MainServer/Controllers/Game/RankingController.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using Domain.Enums;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Throw;
|
||||||
|
|
||||||
|
namespace MainServer.Controllers.Game;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("ranking")]
|
||||||
|
public class RankingController : BaseController<RankingController>
|
||||||
|
{
|
||||||
|
[HttpGet("ranking.php")]
|
||||||
|
public async Task<ActionResult<string>> Ranking([FromQuery(Name = "cmd_type")] int rankType)
|
||||||
|
{
|
||||||
|
var type = (RankingCommandType)rankType;
|
||||||
|
type.Throw().IfOutOfRange();
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case RankingCommandType.GlobalRank:
|
||||||
|
break;
|
||||||
|
case RankingCommandType.PlayNumRank:
|
||||||
|
break;
|
||||||
|
case RankingCommandType.EventRank:
|
||||||
|
break;
|
||||||
|
case RankingCommandType.MonthlyRank:
|
||||||
|
break;
|
||||||
|
case RankingCommandType.ShopRank:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(type), type, "Should not happen!");
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
@ -10,18 +10,18 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CertificateManager" Version="1.0.8"/>
|
<PackageReference Include="CertificateManager" Version="1.0.8" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.2"/>
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.2" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.3"/>
|
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.3" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="6.1.1-dev-00293"/>
|
<PackageReference Include="Serilog.AspNetCore" Version="6.1.1-dev-00293" />
|
||||||
<PackageReference Include="Serilog.Expressions" Version="3.4.2-dev-00119"/>
|
<PackageReference Include="Serilog.Expressions" Version="3.4.2-dev-00119" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||||
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.2"/>
|
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
|
||||||
<PackageReference Include="Throw" Version="1.3.1"/>
|
<PackageReference Include="Throw" Version="1.3.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -68,13 +68,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj"/>
|
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Controllers\API"/>
|
<Folder Include="Controllers\API" />
|
||||||
<Folder Include="Logs"/>
|
<Folder Include="Logs" />
|
||||||
<Folder Include="wwwroot"/>
|
<Folder Include="wwwroot" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -8,6 +8,7 @@ using Infrastructure.Persistence;
|
|||||||
using MainServer.Filters;
|
using MainServer.Filters;
|
||||||
using Microsoft.AspNetCore.StaticFiles;
|
using Microsoft.AspNetCore.StaticFiles;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.FileProviders;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Serilog.Extensions.Logging;
|
using Serilog.Extensions.Logging;
|
||||||
using Throw;
|
using Throw;
|
||||||
@ -64,9 +65,16 @@ try
|
|||||||
|
|
||||||
builder.Services.AddApplication();
|
builder.Services.AddApplication();
|
||||||
builder.Services.AddInfrastructure(builder.Configuration);
|
builder.Services.AddInfrastructure(builder.Configuration);
|
||||||
|
|
||||||
|
builder.Services.AddResponseCompression(options =>
|
||||||
|
{
|
||||||
|
options.EnableForHttps = true;
|
||||||
|
});
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
app.UseResponseCompression();
|
||||||
|
|
||||||
using (var scope = app.Services.CreateScope())
|
using (var scope = app.Services.CreateScope())
|
||||||
{
|
{
|
||||||
var db = scope.ServiceProvider.GetRequiredService<CardDbContext>();
|
var db = scope.ServiceProvider.GetRequiredService<CardDbContext>();
|
||||||
@ -96,13 +104,11 @@ try
|
|||||||
// Add content type for .cmp and .evt files as static files with unknown file extensions return 404 by default
|
// Add content type for .cmp and .evt files as static files with unknown file extensions return 404 by default
|
||||||
// See https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-7.0#fileextensioncontenttypeprovider
|
// See https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-7.0#fileextensioncontenttypeprovider
|
||||||
// ReSharper disable once UseObjectOrCollectionInitializer
|
// ReSharper disable once UseObjectOrCollectionInitializer
|
||||||
var provider = new FileExtensionContentTypeProvider();
|
var contentTypeProvider = new FileExtensionContentTypeProvider();
|
||||||
provider.Mappings[".cmp"] = "text/plain";
|
contentTypeProvider.Mappings[".cmp"] = "text/plain";
|
||||||
provider.Mappings[".evt"] = "text/plain";
|
contentTypeProvider.Mappings[".evt"] = "text/plain";
|
||||||
app.UseStaticFiles(new StaticFileOptions
|
|
||||||
{
|
app.UseStaticFiles();
|
||||||
ContentTypeProvider = provider
|
|
||||||
});
|
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user