Implemented qrCodeData related functions
This commit is contained in:
parent
7dd43d2617
commit
46fe93d806
10
SharedProject/Models/QRCodeData.cs
Normal file
10
SharedProject/Models/QRCodeData.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SharedProject.Models;
|
||||
|
||||
public class QRCodeData
|
||||
{
|
||||
[JsonPropertyName("serial")] public string Serial { get; set; } = null!;
|
||||
|
||||
[JsonPropertyName("id")] public uint Id { get; set; }
|
||||
}
|
@ -46,6 +46,7 @@ public class GetDanOdaiController : BaseController<GetDanOdaiController>
|
||||
Logger.LogWarning("Requested dan id {Id} does not exist!", danId);
|
||||
continue;
|
||||
}
|
||||
Logger.LogInformation(odaiData.Stringify());
|
||||
|
||||
response.AryOdaiDatas.Add(odaiData);
|
||||
}
|
||||
|
@ -4,16 +4,32 @@
|
||||
[ApiController]
|
||||
public class VerifyQrCodeController : BaseController<VerifyQrCodeController>
|
||||
{
|
||||
private readonly IGameDataService gameDataService;
|
||||
|
||||
public VerifyQrCodeController(IGameDataService gameDataService)
|
||||
{
|
||||
this.gameDataService = gameDataService;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/protobuf")]
|
||||
public IActionResult VerifyQrCode([FromBody] VerifyQrcodeRequest request)
|
||||
{
|
||||
Logger.LogInformation("VerifyQrCode request : {Request}", request.Stringify());
|
||||
|
||||
var qrCodeDataDictionary = gameDataService.GetQRCodeDataDictionary();
|
||||
|
||||
qrCodeDataDictionary.TryGetValue(request.QrcodeSerial, out var qrCodeId);
|
||||
|
||||
if (qrCodeId == 0)
|
||||
{
|
||||
Logger.LogWarning("Requested QR code serial {Serial} does not exist!", request.QrcodeSerial);
|
||||
}
|
||||
|
||||
var response = new VerifyQrcodeResponse
|
||||
{
|
||||
Result = 1,
|
||||
QrcodeId = 999999001
|
||||
QrcodeId = qrCodeId
|
||||
};
|
||||
|
||||
return Ok(response);
|
||||
|
@ -36,6 +36,8 @@ public class GameDataService : IGameDataService
|
||||
private ImmutableDictionary<uint, GetShopFolderResponse.ShopFolderData> shopFolderDictionary =
|
||||
ImmutableDictionary<uint, GetShopFolderResponse.ShopFolderData>.Empty;
|
||||
|
||||
private ImmutableDictionary<string, uint> qrCodeDataDictionary = ImmutableDictionary<string, uint>.Empty;
|
||||
|
||||
private List<uint> musics = new();
|
||||
|
||||
private List<uint> musicsWithUra = new();
|
||||
@ -110,6 +112,11 @@ public class GameDataService : IGameDataService
|
||||
{
|
||||
return lockedSongsList;
|
||||
}
|
||||
|
||||
public ImmutableDictionary<string, uint> GetQRCodeDataDictionary()
|
||||
{
|
||||
return qrCodeDataDictionary;
|
||||
}
|
||||
|
||||
public async Task InitializeAsync()
|
||||
{
|
||||
@ -126,6 +133,7 @@ public class GameDataService : IGameDataService
|
||||
var shopFolderDataPath = Path.Combine(dataPath, settings.ShopFolderDataFileName);
|
||||
var tokenDataPath = Path.Combine(dataPath, settings.TokenDataFileName);
|
||||
var lockedSongsDataPath = Path.Combine(dataPath, settings.LockedSongsDataFileName);
|
||||
var qrCodeDataPath = Path.Combine(dataPath, settings.QRCodeDataFileName);
|
||||
|
||||
if (File.Exists(compressedMusicInfoPath))
|
||||
{
|
||||
@ -145,6 +153,7 @@ public class GameDataService : IGameDataService
|
||||
await using var shopFolderDataFile = File.OpenRead(shopFolderDataPath);
|
||||
await using var tokenDataFile = File.OpenRead(tokenDataPath);
|
||||
await using var lockedSongsDataFile = File.OpenRead(lockedSongsDataPath);
|
||||
await using var qrCodeDataFile = File.OpenRead(qrCodeDataPath);
|
||||
|
||||
var infoesData = await JsonSerializer.DeserializeAsync<MusicInfoes>(musicInfoFile);
|
||||
var attributesData = await JsonSerializer.DeserializeAsync<MusicAttributes>(musicAttributeFile);
|
||||
@ -156,6 +165,7 @@ public class GameDataService : IGameDataService
|
||||
var shopFolderData = await JsonSerializer.DeserializeAsync<List<ShopFolderData>>(shopFolderDataFile);
|
||||
var tokenData = await JsonSerializer.DeserializeAsync<Dictionary<string, int>>(tokenDataFile);
|
||||
var lockedSongsData = await JsonSerializer.DeserializeAsync<Dictionary<string, uint[]>>(lockedSongsDataFile);
|
||||
var qrCodeData = await JsonSerializer.DeserializeAsync<List<QRCodeData>>(qrCodeDataFile);
|
||||
|
||||
InitializeMusicInfoes(infoesData);
|
||||
|
||||
@ -176,6 +186,8 @@ public class GameDataService : IGameDataService
|
||||
InitializeTokenData(tokenData);
|
||||
|
||||
InitializeLockedSongsData(lockedSongsData);
|
||||
|
||||
InitializeQRCodeData(qrCodeData);
|
||||
}
|
||||
|
||||
private static void TryDecompressMusicInfo()
|
||||
@ -272,6 +284,12 @@ public class GameDataService : IGameDataService
|
||||
lockedSongsData.ThrowIfNull("Shouldn't happen!");
|
||||
lockedSongsList = lockedSongsData["songNo"].ToList();
|
||||
}
|
||||
|
||||
private void InitializeQRCodeData(List<QRCodeData>? qrCodeData)
|
||||
{
|
||||
qrCodeData.ThrowIfNull("Shouldn't happen!");
|
||||
qrCodeDataDictionary = qrCodeData.ToImmutableDictionary(data => data.Serial, data => data.Id);
|
||||
}
|
||||
|
||||
private static GetDanOdaiResponse.OdaiData ToResponseOdaiData(DanData data)
|
||||
{
|
||||
|
@ -29,5 +29,7 @@ public interface IGameDataService
|
||||
public Dictionary<string, int> GetTokenDataDictionary();
|
||||
|
||||
public List<uint> GetLockedSongsList();
|
||||
|
||||
public ImmutableDictionary<string, uint> GetQRCodeDataDictionary();
|
||||
}
|
||||
|
||||
|
@ -17,4 +17,6 @@ public class DataSettings
|
||||
public string TokenDataFileName { get; set; } = "token_data.json";
|
||||
|
||||
public string LockedSongsDataFileName { get; set; } = "locked_songs_data.json";
|
||||
|
||||
public string QRCodeDataFileName { get; set; } = "qrcode_data.json";
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"movie_id": 0,
|
||||
"enable_days": 0
|
||||
"movie_id": 0,
|
||||
"enable_days": 0
|
||||
}
|
||||
]
|
6
TaikoLocalServer/wwwroot/data/qrcode_data.json
Normal file
6
TaikoLocalServer/wwwroot/data/qrcode_data.json
Normal file
@ -0,0 +1,6 @@
|
||||
[
|
||||
{
|
||||
"serial": "",
|
||||
"id": -1
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue
Block a user