From 02a241567cdfe8ee68037e82cf58eda93deec84a Mon Sep 17 00:00:00 2001
From: asesidaa <1061472754@qq.com>
Date: Tue, 14 Feb 2023 02:47:08 +0800
Subject: [PATCH] Fix alive, migrate write, add online matching stub, start
rank
---
Application/Application.csproj | 5 +
Application/Common/Helpers/TimeHelper.cs | 9 +
.../StartOnlineMatchingCommand.cs | 18 +-
.../UpdateOnlineMatchingCommand.cs | 18 +-
.../UploadOnlineMatchingResultCommand.cs | 18 +-
.../Game/Card/Write/WriteCardBDataCommand.cs | 42 +++++
.../Game/Card/Write/WriteCardCommand.cs | 53 ++++++
.../Game/Card/Write/WriteCardDetailCommand.cs | 43 +++++
Application/Mappers/CardBDatumMapper.cs | 2 +
Application/Mappers/CardMapper.cs | 1 -
Domain/Enums/RankingCommandType.cs | 10 ++
MainServer/Configurations/server.json | 13 ++
.../Controllers/Game/AliveController.cs | 2 +-
MainServer/Controllers/Game/CardController.cs | 168 ++++++------------
.../Controllers/Game/RankingController.cs | 34 ++++
MainServer/MainServer.csproj | 24 +--
MainServer/Program.cs | 20 ++-
17 files changed, 341 insertions(+), 139 deletions(-)
create mode 100644 Application/Common/Helpers/TimeHelper.cs
create mode 100644 Application/Game/Card/Write/WriteCardBDataCommand.cs
create mode 100644 Application/Game/Card/Write/WriteCardCommand.cs
create mode 100644 Application/Game/Card/Write/WriteCardDetailCommand.cs
create mode 100644 Domain/Enums/RankingCommandType.cs
create mode 100644 MainServer/Controllers/Game/RankingController.cs
diff --git a/Application/Application.csproj b/Application/Application.csproj
index a11bca2..0322e9c 100644
--- a/Application/Application.csproj
+++ b/Application/Application.csproj
@@ -12,6 +12,7 @@
+
@@ -21,4 +22,8 @@
+
+
+
+
diff --git a/Application/Common/Helpers/TimeHelper.cs b/Application/Common/Helpers/TimeHelper.cs
new file mode 100644
index 0000000..0f81959
--- /dev/null
+++ b/Application/Common/Helpers/TimeHelper.cs
@@ -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");
+ }
+}
\ No newline at end of file
diff --git a/Application/Game/Card/OnlineMatching/StartOnlineMatchingCommand.cs b/Application/Game/Card/OnlineMatching/StartOnlineMatchingCommand.cs
index 15a91b2..375fdb6 100644
--- a/Application/Game/Card/OnlineMatching/StartOnlineMatchingCommand.cs
+++ b/Application/Game/Card/OnlineMatching/StartOnlineMatchingCommand.cs
@@ -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;
+
+public class StartOnlineMatchingCommandHandler : CardRequestHandlerBase
{
-
+ public StartOnlineMatchingCommandHandler(ICardDependencyAggregate aggregate) : base(aggregate)
+ {
+ }
+
+ public override Task> Handle(StartOnlineMatchingCommand request, CancellationToken cancellationToken)
+ {
+ throw new NotImplementedException();
+ }
}
\ No newline at end of file
diff --git a/Application/Game/Card/OnlineMatching/UpdateOnlineMatchingCommand.cs b/Application/Game/Card/OnlineMatching/UpdateOnlineMatchingCommand.cs
index 0893cab..6dc35e7 100644
--- a/Application/Game/Card/OnlineMatching/UpdateOnlineMatchingCommand.cs
+++ b/Application/Game/Card/OnlineMatching/UpdateOnlineMatchingCommand.cs
@@ -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;
+
+public class UpdateOnlineMatchingCommandHandler : CardRequestHandlerBase
{
-
+ public UpdateOnlineMatchingCommandHandler(ICardDependencyAggregate aggregate) : base(aggregate)
+ {
+ }
+
+ public override Task> Handle(UpdateOnlineMatchingCommand request, CancellationToken cancellationToken)
+ {
+ throw new NotImplementedException();
+ }
}
\ No newline at end of file
diff --git a/Application/Game/Card/OnlineMatching/UploadOnlineMatchingResultCommand.cs b/Application/Game/Card/OnlineMatching/UploadOnlineMatchingResultCommand.cs
index 00075ee..a05bd09 100644
--- a/Application/Game/Card/OnlineMatching/UploadOnlineMatchingResultCommand.cs
+++ b/Application/Game/Card/OnlineMatching/UploadOnlineMatchingResultCommand.cs
@@ -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;
+
+public class UploadOnlineMatchingResultCommandHandler : CardRequestHandlerBase
{
-
+ public UploadOnlineMatchingResultCommandHandler(ICardDependencyAggregate aggregate) : base(aggregate)
+ {
+ }
+
+ public override Task> Handle(UploadOnlineMatchingResultCommand request, CancellationToken cancellationToken)
+ {
+ throw new NotImplementedException();
+ }
}
\ No newline at end of file
diff --git a/Application/Game/Card/Write/WriteCardBDataCommand.cs b/Application/Game/Card/Write/WriteCardBDataCommand.cs
new file mode 100644
index 0000000..7005108
--- /dev/null
+++ b/Application/Game/Card/Write/WriteCardBDataCommand.cs
@@ -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;
+
+public class WriteCardBDataCommandHandler : CardRequestHandlerBase
+{
+ private readonly ILogger logger;
+
+ public WriteCardBDataCommandHandler(ICardDependencyAggregate aggregate, ILogger logger) : base(aggregate)
+ {
+ this.logger = logger;
+ }
+
+ public override async Task> 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(
+ new ServiceError($"Card id: {request.CardId} does not exist!", (int)CardReturnCode.CardNotRegistered));
+ }
+
+ var dto = request.Data.DeserializeCardData();
+ var data = dto.DtoToCardBDatum();
+ data.CardId = request.CardId;
+ CardDbContext.CardBdata.Upsert(data);
+
+ await CardDbContext.SaveChangesAsync(cancellationToken);
+
+ return new ServiceResult(request.Data);
+ }
+}
\ No newline at end of file
diff --git a/Application/Game/Card/Write/WriteCardCommand.cs b/Application/Game/Card/Write/WriteCardCommand.cs
new file mode 100644
index 0000000..20870af
--- /dev/null
+++ b/Application/Game/Card/Write/WriteCardCommand.cs
@@ -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;
+
+public class WriteCardCommandHandler : CardRequestHandlerBase
+{
+ private readonly ILogger logger;
+
+ public WriteCardCommandHandler(ICardDependencyAggregate aggregate, ILogger logger) : base(aggregate)
+ {
+ this.logger = logger;
+ }
+
+ public override async Task> Handle(WriteCardCommand request, CancellationToken cancellationToken)
+ {
+ var dto = request.Data.DeserializeCardData();
+ 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(request.Data);
+ }
+}
\ No newline at end of file
diff --git a/Application/Game/Card/Write/WriteCardDetailCommand.cs b/Application/Game/Card/Write/WriteCardDetailCommand.cs
new file mode 100644
index 0000000..6f90d08
--- /dev/null
+++ b/Application/Game/Card/Write/WriteCardDetailCommand.cs
@@ -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;
+
+public class WriteCardDetailCommandHandler : CardRequestHandlerBase
+{
+ private readonly ILogger logger;
+
+ public WriteCardDetailCommandHandler(ICardDependencyAggregate aggregate, ILogger logger) : base(aggregate)
+ {
+ this.logger = logger;
+ }
+
+ public override async Task> 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(
+ new ServiceError($"Card id: {request.CardId} does not exist!", (int)CardReturnCode.CardNotRegistered));
+ }
+
+ var dto = request.Data.DeserializeCardData();
+ var detail = dto.DtoToCardDetail();
+ detail.CardId = request.CardId;
+ detail.LastPlayTime = DateTime.Now;
+ CardDbContext.CardDetails.Upsert(detail);
+
+ await CardDbContext.SaveChangesAsync(cancellationToken);
+
+ return new ServiceResult(request.Data);
+ }
+}
\ No newline at end of file
diff --git a/Application/Mappers/CardBDatumMapper.cs b/Application/Mappers/CardBDatumMapper.cs
index 0af30f6..a457cec 100644
--- a/Application/Mappers/CardBDatumMapper.cs
+++ b/Application/Mappers/CardBDatumMapper.cs
@@ -8,4 +8,6 @@ namespace Application.Mappers;
public static partial class CardBDatumMapper
{
public static partial CardBDatumDto CardBDatumToDto(this CardBdatum cardBdatum);
+
+ public static partial CardBdatum DtoToCardBDatum(this CardBDatumDto dto);
}
\ No newline at end of file
diff --git a/Application/Mappers/CardMapper.cs b/Application/Mappers/CardMapper.cs
index 8779e56..2634331 100644
--- a/Application/Mappers/CardMapper.cs
+++ b/Application/Mappers/CardMapper.cs
@@ -8,6 +8,5 @@ namespace Application.Mappers;
public static partial class CardMapper
{
public static partial CardDto CardMainToCardDto(this CardMain cardMain);
-
public static partial CardMain CardDtoToCardMain(this CardDto cardDto);
}
\ No newline at end of file
diff --git a/Domain/Enums/RankingCommandType.cs b/Domain/Enums/RankingCommandType.cs
new file mode 100644
index 0000000..62a542e
--- /dev/null
+++ b/Domain/Enums/RankingCommandType.cs
@@ -0,0 +1,10 @@
+namespace Domain.Enums;
+
+public enum RankingCommandType
+{
+ GlobalRank = 4119,
+ PlayNumRank = 6657,
+ EventRank = 6661,
+ MonthlyRank = 6666,
+ ShopRank = 4098
+}
\ No newline at end of file
diff --git a/MainServer/Configurations/server.json b/MainServer/Configurations/server.json
index dd5ca8c..b7f229b 100644
--- a/MainServer/Configurations/server.json
+++ b/MainServer/Configurations/server.json
@@ -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"
}
\ No newline at end of file
diff --git a/MainServer/Controllers/Game/AliveController.cs b/MainServer/Controllers/Game/AliveController.cs
index 044abca..dc01923 100644
--- a/MainServer/Controllers/Game/AliveController.cs
+++ b/MainServer/Controllers/Game/AliveController.cs
@@ -17,7 +17,7 @@ public class AliveController : ControllerBase
return Ok(response);
}
- [HttpGet("/{id}/Alive.txt")]
+ [HttpGet("{id}/Alive.txt")]
public IActionResult GetAliveFile()
{
return Ok("");
diff --git a/MainServer/Controllers/Game/CardController.cs b/MainServer/Controllers/Game/CardController.cs
index baaf4f5..5cba455 100644
--- a/MainServer/Controllers/Game/CardController.cs
+++ b/MainServer/Controllers/Game/CardController.cs
@@ -2,6 +2,7 @@
using Application.Common.Models;
using Application.Game.Card;
using Application.Game.Card.Management;
+using Application.Game.Card.OnlineMatching;
using Application.Game.Card.Read;
using Application.Game.Card.Session;
using Application.Game.Card.Write;
@@ -28,120 +29,69 @@ public class CardController : BaseController
}
request.Data = WebUtility.UrlDecode(request.Data);
- var result = ServiceResult.Failed(ServiceError.DefaultError);
+ ServiceResult result;
switch (cardCommandType)
{
case CardCommandType.CardReadRequest:
case CardCommandType.CardWriteRequest:
{
- switch (cardRequestType)
+ result = cardRequestType switch
{
- case CardRequestType.ReadCard:
- result = await Mediator.Send(new ReadCardQuery(request.CardId));
- break;
- case CardRequestType.ReadCardDetail:
- result = await Mediator.Send(new ReadCardDetailQuery(request.CardId, request.Data));
- break;
- case CardRequestType.ReadCardDetails:
- result = await Mediator.Send(new ReadAllCardDetailsQuery(request.CardId));
- break;
- case CardRequestType.ReadCardBData:
- result = await Mediator.Send(new ReadCardBDataQuery(request.CardId));
- break;
- case CardRequestType.ReadAvatar:
- result = await Mediator.Send(new ReadAvatarQuery(request.CardId));
- break;
- case CardRequestType.ReadItem:
- result = await Mediator.Send(new ReadItemQuery(request.CardId));
- break;
- case CardRequestType.ReadSkin:
- result = await Mediator.Send(new ReadSkinQuery(request.CardId));
- break;
- case CardRequestType.ReadTitle:
- result = await Mediator.Send(new ReadTitleQuery(request.CardId));
- break;
- case CardRequestType.ReadNavigator:
- result = await Mediator.Send(new ReadNavigatorQuery(request.CardId));
- break;
- case CardRequestType.ReadSoundEffect:
- result = await Mediator.Send(new ReadSoundEffectQuery(request.CardId));
- break;
- case CardRequestType.ReadMusic:
- result = await Mediator.Send(new ReadMusicQuery(request.CardId));
- break;
- case CardRequestType.ReadMusicAou:
- result = await Mediator.Send(new ReadMusicAouQuery(request.CardId));
- break;
- case CardRequestType.ReadMusicExtra:
- result = await Mediator.Send(new ReadMusicExtraQuery(request.CardId));
- break;
- case CardRequestType.ReadEventReward:
- result = await Mediator.Send(new ReadEventRewardQuery(request.CardId));
- break;
- case CardRequestType.ReadCoin:
- result = await Mediator.Send(new ReadCoinQuery(request.CardId));
- break;
- case CardRequestType.ReadUnlockReward:
- result = await Mediator.Send(new ReadUnlockRewardQuery(request.CardId));
- break;
- case CardRequestType.ReadUnlockKeynum:
- result = await Mediator.Send(new ReadUnlockKeynumQuery(request.CardId));
- break;
- case CardRequestType.ReadGetMessage:
- result = await Mediator.Send(new ReadGetMessageQuery(request.CardId));
- break;
- 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);
- }
+ CardRequestType.ReadCard => await Mediator.Send(new ReadCardQuery(request.CardId)),
+ CardRequestType.ReadCardDetail => await Mediator.Send(
+ new ReadCardDetailQuery(request.CardId, request.Data)),
+ CardRequestType.ReadCardDetails => await Mediator.Send(new ReadAllCardDetailsQuery(request.CardId)),
+ CardRequestType.ReadCardBData => await Mediator.Send(new ReadCardBDataQuery(request.CardId)),
+ CardRequestType.ReadAvatar => await Mediator.Send(new ReadAvatarQuery(request.CardId)),
+ CardRequestType.ReadItem => await Mediator.Send(new ReadItemQuery(request.CardId)),
+ CardRequestType.ReadSkin => await Mediator.Send(new ReadSkinQuery(request.CardId)),
+ CardRequestType.ReadTitle => await Mediator.Send(new ReadTitleQuery(request.CardId)),
+ CardRequestType.ReadMusic => await Mediator.Send(new ReadMusicQuery(request.CardId)),
+ CardRequestType.ReadEventReward => await Mediator.Send(new ReadEventRewardQuery(request.CardId)),
+ CardRequestType.ReadNavigator => await Mediator.Send(new ReadNavigatorQuery(request.CardId)),
+ CardRequestType.ReadMusicExtra => await Mediator.Send(new ReadMusicExtraQuery(request.CardId)),
+ CardRequestType.ReadMusicAou => await Mediator.Send(new ReadMusicAouQuery(request.CardId)),
+ CardRequestType.ReadCoin => await Mediator.Send(new ReadCoinQuery(request.CardId)),
+ CardRequestType.ReadUnlockReward => await Mediator.Send(new ReadUnlockRewardQuery(request.CardId)),
+ CardRequestType.ReadUnlockKeynum => await Mediator.Send(new ReadUnlockKeynumQuery(request.CardId)),
+ CardRequestType.ReadSoundEffect => await Mediator.Send(new ReadSoundEffectQuery(request.CardId)),
+ CardRequestType.ReadGetMessage => await Mediator.Send(new ReadGetMessageQuery(request.CardId)),
+ CardRequestType.ReadCond => await Mediator.Send(new ReadCondQuery(request.CardId)),
+ CardRequestType.ReadTotalTrophy => await Mediator.Send(new ReadTotalTrophyQuery(request.CardId)),
+ CardRequestType.GetSession or CardRequestType.StartSession => await Mediator.Send(
+ new GetSessionCommand(request.CardId, request.Mac)),
+ CardRequestType.WriteCard =>
+ await Mediator.Send(new WriteCardCommand(request.CardId, request.Data)),
+ CardRequestType.WriteCardDetail => await Mediator.Send(
+ new WriteCardDetailCommand(request.CardId, request.Data)),
+ CardRequestType.WriteCardBData => await Mediator.Send(
+ new WriteCardBDataCommand(request.CardId, request.Data)),
+ CardRequestType.WriteAvatar => await Mediator.Send(new WriteAvatarCommand(request.CardId,
+ request.Data)),
+ CardRequestType.WriteItem =>
+ await Mediator.Send(new WriteItemCommand(request.CardId, request.Data)),
+ CardRequestType.WriteTitle => await Mediator.Send(new WriteTitleCommand(request.CardId,
+ request.Data)),
+ CardRequestType.WriteMusicDetail => await Mediator.Send(
+ new WriteMusicDetailCommand(request.CardId, request.Data)),
+ CardRequestType.WriteNavigator => await Mediator.Send(
+ new WriteNavigatorCommand(request.CardId, request.Data)),
+ CardRequestType.WriteCoin =>
+ await Mediator.Send(new WriteCoinCommand(request.CardId, request.Data)),
+ CardRequestType.WriteSkin =>
+ await Mediator.Send(new WriteSkinCommand(request.CardId, request.Data)),
+ CardRequestType.WriteUnlockKeynum => await Mediator.Send(
+ new WriteUnlockKeynumCommand(request.CardId, request.Data)),
+ CardRequestType.WriteSoundEffect => await Mediator.Send(
+ new WriteSoundEffectCommand(request.CardId, request.Data)),
+ CardRequestType.StartOnlineMatching => await Mediator.Send(
+ new StartOnlineMatchingCommand(request.CardId, request.Data)),
+ CardRequestType.UpdateOnlineMatching => await Mediator.Send(
+ new UpdateOnlineMatchingCommand(request.CardId, request.Data)),
+ CardRequestType.UploadOnlineMatchingResult => await Mediator.Send(
+ new UploadOnlineMatchingResultCommand(request.CardId, request.Data)),
+ _ => throw new ArgumentOutOfRangeException(nameof(cardRequestType), cardRequestType, "Should not happen")
+ };
break;
}
case CardCommandType.RegisterRequest:
@@ -151,7 +101,7 @@ public class CardController : BaseController
result = await Mediator.Send(new CardReissueCommand(request.CardId));
break;
default:
- throw new ArgumentOutOfRangeException(message: "Should not happen", paramName:null);
+ throw new ArgumentOutOfRangeException(nameof(cardCommandType), cardCommandType, "Should not happen");
}
if (result.Succeeded)
diff --git a/MainServer/Controllers/Game/RankingController.cs b/MainServer/Controllers/Game/RankingController.cs
new file mode 100644
index 0000000..48bca02
--- /dev/null
+++ b/MainServer/Controllers/Game/RankingController.cs
@@ -0,0 +1,34 @@
+using Domain.Enums;
+using Microsoft.AspNetCore.Mvc;
+using Throw;
+
+namespace MainServer.Controllers.Game;
+
+[ApiController]
+[Route("ranking")]
+public class RankingController : BaseController
+{
+ [HttpGet("ranking.php")]
+ public async Task> 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 "";
+ }
+}
\ No newline at end of file
diff --git a/MainServer/MainServer.csproj b/MainServer/MainServer.csproj
index db3c256..1ce8fa4 100644
--- a/MainServer/MainServer.csproj
+++ b/MainServer/MainServer.csproj
@@ -10,18 +10,18 @@
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
+
+
+
+
+
+
@@ -68,13 +68,13 @@
-
+
-
-
-
+
+
+
diff --git a/MainServer/Program.cs b/MainServer/Program.cs
index 1cc9870..f5d26e6 100644
--- a/MainServer/Program.cs
+++ b/MainServer/Program.cs
@@ -8,6 +8,7 @@ using Infrastructure.Persistence;
using MainServer.Filters;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.FileProviders;
using Serilog;
using Serilog.Extensions.Logging;
using Throw;
@@ -64,9 +65,16 @@ try
builder.Services.AddApplication();
builder.Services.AddInfrastructure(builder.Configuration);
+
+ builder.Services.AddResponseCompression(options =>
+ {
+ options.EnableForHttps = true;
+ });
var app = builder.Build();
+ app.UseResponseCompression();
+
using (var scope = app.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService();
@@ -96,13 +104,11 @@ try
// 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
// ReSharper disable once UseObjectOrCollectionInitializer
- var provider = new FileExtensionContentTypeProvider();
- provider.Mappings[".cmp"] = "text/plain";
- provider.Mappings[".evt"] = "text/plain";
- app.UseStaticFiles(new StaticFileOptions
- {
- ContentTypeProvider = provider
- });
+ var contentTypeProvider = new FileExtensionContentTypeProvider();
+ contentTypeProvider.Mappings[".cmp"] = "text/plain";
+ contentTypeProvider.Mappings[".evt"] = "text/plain";
+
+ app.UseStaticFiles();
app.MapControllers();