Pushing the addTokenCountController I forgot to push before
This commit is contained in:
parent
e3c790309c
commit
5b1f641532
@ -1,15 +1,56 @@
|
|||||||
namespace TaikoLocalServer.Controllers.Game;
|
using System.Text.Json;
|
||||||
|
using Throw;
|
||||||
|
|
||||||
|
namespace TaikoLocalServer.Controllers.Game;
|
||||||
|
|
||||||
[Route("/v12r00_cn/chassis/addtokencount.php")]
|
[Route("/v12r00_cn/chassis/addtokencount.php")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class AddTokenCountController : BaseController<AddTokenCountController>
|
public class AddTokenCountController : BaseController<AddTokenCountController>
|
||||||
{
|
{
|
||||||
|
private readonly IUserDatumService userDatumService;
|
||||||
|
|
||||||
|
public AddTokenCountController(IUserDatumService userDatumService)
|
||||||
|
{
|
||||||
|
this.userDatumService = userDatumService;
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/protobuf")]
|
[Produces("application/protobuf")]
|
||||||
public IActionResult AddTokenCount([FromBody] AddTokenCountRequest request)
|
public async Task<IActionResult> AddTokenCount([FromBody] AddTokenCountRequest request)
|
||||||
{
|
{
|
||||||
Logger.LogInformation("AddTokenCount request : {Request}", request.Stringify());
|
Logger.LogInformation("AddTokenCount request : {Request}", request.Stringify());
|
||||||
|
|
||||||
|
var user = await userDatumService.GetFirstUserDatumOrNull(request.Baid);
|
||||||
|
user.ThrowIfNull($"User with baid {request.Baid} does not exist!");
|
||||||
|
|
||||||
|
var tokenCountDict = new Dictionary<uint, int>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tokenCountDict = !string.IsNullOrEmpty(user.TokenCountDict)
|
||||||
|
? JsonSerializer.Deserialize<Dictionary<uint, int>>(user.TokenCountDict)
|
||||||
|
: new Dictionary<uint, int>();
|
||||||
|
}
|
||||||
|
catch (JsonException e)
|
||||||
|
{
|
||||||
|
Logger.LogError(e, "Parsing TokenCountDict data for user with baid {Request} failed!", request.Baid);
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenCountDict.ThrowIfNull("TokenCountDict should never be null");
|
||||||
|
|
||||||
|
foreach (var addTokenCountData in request.AryAddTokenCountDatas)
|
||||||
|
{
|
||||||
|
var tokenId = addTokenCountData.TokenId;
|
||||||
|
var addTokenCount = addTokenCountData.AddTokenCount;
|
||||||
|
|
||||||
|
if (tokenCountDict.ContainsKey(tokenId))
|
||||||
|
tokenCountDict[tokenId] += addTokenCount;
|
||||||
|
else
|
||||||
|
tokenCountDict.Add(tokenId, addTokenCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
user.TokenCountDict = JsonSerializer.Serialize(tokenCountDict);
|
||||||
|
await userDatumService.UpdateUserDatum(user);
|
||||||
|
|
||||||
var response = new AddTokenCountResponse
|
var response = new AddTokenCountResponse
|
||||||
{
|
{
|
||||||
Result = 1
|
Result = 1
|
||||||
|
@ -22,10 +22,10 @@ public class GetDanOdaiController : BaseController<GetDanOdaiController>
|
|||||||
Result = 1
|
Result = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
if (request.Type == 2)
|
// if (request.Type == 2)
|
||||||
{
|
// {
|
||||||
return Ok(response);
|
// return Ok(response);
|
||||||
}
|
// }
|
||||||
|
|
||||||
foreach (var danId in request.DanIds)
|
foreach (var danId in request.DanIds)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,9 @@ public class InitialDataCheckController : BaseController<InitialDataCheckControl
|
|||||||
UraReleaseBit = uraReleaseBit,
|
UraReleaseBit = uraReleaseBit,
|
||||||
SongIntroductionEndDatetime = DateTime.Now.AddYears(10).ToString(Constants.DATE_TIME_FORMAT),
|
SongIntroductionEndDatetime = DateTime.Now.AddYears(10).ToString(Constants.DATE_TIME_FORMAT),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var movieDataDictionary = gameDataService.GetMovieDataDictionary();
|
||||||
|
foreach (var movieData in movieDataDictionary) response.AryMovieInfoes.Add(movieData.Value);
|
||||||
|
|
||||||
var verupNo1 = new uint[] { 2, 3, 4, 5, 6, 7, 8, 13, 15, 24, 25, 26, 27, 28, 29, 30, 31, 104 };
|
var verupNo1 = new uint[] { 2, 3, 4, 5, 6, 7, 8, 13, 15, 24, 25, 26, 27, 28, 29, 30, 31, 104 };
|
||||||
var aryVerUp = verupNo1.Select(i => new InitialdatacheckResponse.VerupNoData1
|
var aryVerUp = verupNo1.Select(i => new InitialdatacheckResponse.VerupNoData1
|
||||||
@ -65,6 +68,13 @@ public class InitialDataCheckController : BaseController<InitialDataCheckControl
|
|||||||
verUp2Type101.AryInformationDatas.AddRange(danData);
|
verUp2Type101.AryInformationDatas.AddRange(danData);
|
||||||
response.AryVerupNoData2s.Add(verUp2Type101);
|
response.AryVerupNoData2s.Add(verUp2Type101);
|
||||||
|
|
||||||
|
var verUp2Type102 = new InitialdatacheckResponse.VerupNoData2
|
||||||
|
{
|
||||||
|
MasterType = 102,
|
||||||
|
};
|
||||||
|
verUp2Type102.AryInformationDatas.AddRange(danData);
|
||||||
|
response.AryVerupNoData2s.Add(verUp2Type102);
|
||||||
|
|
||||||
var eventFolderData = new List<InitialdatacheckResponse.VerupNoData2.InformationData>();
|
var eventFolderData = new List<InitialdatacheckResponse.VerupNoData2.InformationData>();
|
||||||
foreach (var folderId in Constants.EVENT_FOLDER_IDS)
|
foreach (var folderId in Constants.EVENT_FOLDER_IDS)
|
||||||
{
|
{
|
||||||
@ -98,9 +108,6 @@ public class InitialDataCheckController : BaseController<InitialDataCheckControl
|
|||||||
response.AryVerupNoData2s.Add(verUp2Type105);
|
response.AryVerupNoData2s.Add(verUp2Type105);
|
||||||
|
|
||||||
response.AryChassisFunctionIds = new uint[] {1,2,3};
|
response.AryChassisFunctionIds = new uint[] {1,2,3};
|
||||||
|
|
||||||
var movieDataDictionary = gameDataService.GetMovieDataDictionary();
|
|
||||||
foreach (var movieData in movieDataDictionary) response.AryMovieInfoes.Add(movieData.Value);
|
|
||||||
|
|
||||||
return Ok(response);
|
return Ok(response);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public class VerifyQrCodeController : BaseController<VerifyQrCodeController>
|
|||||||
var response = new VerifyQrcodeResponse
|
var response = new VerifyQrcodeResponse
|
||||||
{
|
{
|
||||||
Result = 1,
|
Result = 1,
|
||||||
QrcodeId = 1
|
QrcodeId = 999999001
|
||||||
};
|
};
|
||||||
|
|
||||||
return Ok(response);
|
return Ok(response);
|
||||||
|
Loading…
Reference in New Issue
Block a user