1
0
mirror of synced 2024-11-27 16:10:53 +01:00

Prepare for web ui

This commit is contained in:
asesidaa 2022-09-05 00:52:58 +08:00
parent 94e3d03762
commit b5e47900a0
22 changed files with 118 additions and 51 deletions

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>29FAECCD-4C19-44F3-963F-6535BE962E2E</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Shared</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)Models" />
</ItemGroup>
</Project>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{739247D2-9B9B-45DE-A97F-216E0D97930C}</ProjectGuid>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<Import Project="Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>

View File

@ -1,4 +1,4 @@
namespace TaikoLocalServer.Common.Enums; namespace SharedProject.Enums;
public enum CrownType public enum CrownType
{ {

View File

@ -1,4 +1,4 @@
namespace TaikoLocalServer.Common.Enums; namespace SharedProject.Enums;
public enum DanClearState public enum DanClearState
{ {

View File

@ -1,4 +1,4 @@
namespace TaikoLocalServer.Common.Enums; namespace SharedProject.Enums;
public enum Difficulty : uint public enum Difficulty : uint
{ {

View File

@ -1,4 +1,4 @@
namespace TaikoLocalServer.Common.Enums; namespace SharedProject.Enums;
public enum PlayMode public enum PlayMode
{ {

View File

@ -1,4 +1,4 @@
namespace TaikoLocalServer.Common.Enums; namespace SharedProject.Enums;
public enum ScoreRank public enum ScoreRank
{ {

View File

@ -0,0 +1,6 @@
namespace SharedProject.Models.Responses;
public class DashboardResponse
{
public List<User> Users { get; set; } = new();
}

View File

@ -0,0 +1,8 @@
namespace SharedProject.Models;
public class User
{
public string AccessCode { get; set; } = string.Empty;
public uint Baid { get; set; }
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="Models\Requests" />
</ItemGroup>
</Project>

View File

@ -5,7 +5,7 @@ VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TaikoLocalServer", "TaikoLocalServer\TaikoLocalServer.csproj", "{98FDA12C-CD3C-42D0-BEBE-4E809E6E41AC}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TaikoLocalServer", "TaikoLocalServer\TaikoLocalServer.csproj", "{98FDA12C-CD3C-42D0-BEBE-4E809E6E41AC}"
EndProject EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Shared", "Shared\Shared.shproj", "{739247D2-9B9B-45DE-A97F-216E0D97930C}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedProject", "SharedProject\SharedProject.csproj", "{34BAE5CA-D46B-489B-8617-3CEB2C0C614F}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -17,6 +17,10 @@ Global
{98FDA12C-CD3C-42D0-BEBE-4E809E6E41AC}.Debug|Any CPU.Build.0 = Debug|Any CPU {98FDA12C-CD3C-42D0-BEBE-4E809E6E41AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98FDA12C-CD3C-42D0-BEBE-4E809E6E41AC}.Release|Any CPU.ActiveCfg = Release|Any CPU {98FDA12C-CD3C-42D0-BEBE-4E809E6E41AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98FDA12C-CD3C-42D0-BEBE-4E809E6E41AC}.Release|Any CPU.Build.0 = Release|Any CPU {98FDA12C-CD3C-42D0-BEBE-4E809E6E41AC}.Release|Any CPU.Build.0 = Release|Any CPU
{34BAE5CA-D46B-489B-8617-3CEB2C0C614F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34BAE5CA-D46B-489B-8617-3CEB2C0C614F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34BAE5CA-D46B-489B-8617-3CEB2C0C614F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34BAE5CA-D46B-489B-8617-3CEB2C0C614F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -18,7 +18,7 @@ public static class Constants
public const int MIYABI_CORE_RANK_ARRAY_SIZE = MUSIC_ID_MAX + 1; public const int MIYABI_CORE_RANK_ARRAY_SIZE = MUSIC_ID_MAX + 1;
public const string DB_NAME = "taiko.db3"; public const string DEFAULT_DB_NAME = "taiko.db3";
public const string MUSIC_ATTRIBUTE_FILE_NAME = "music_attribute.json"; public const string MUSIC_ATTRIBUTE_FILE_NAME = "music_attribute.json";

View File

@ -1,7 +1,7 @@
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace TaikoLocalServer.Common; namespace TaikoLocalServer.Common.Utils;
public static class FlagCalculator public static class FlagCalculator
{ {

View File

@ -22,7 +22,7 @@
{ {
return; return;
} }
var path = Path.Combine(PathHelper.GetDataPath(), Constants.DB_NAME); var path = Path.Combine(PathHelper.GetDataPath(), Constants.DEFAULT_DB_NAME);
optionsBuilder.UseSqlite($"Data Source={path}"); optionsBuilder.UseSqlite($"Data Source={path}");
} }

View File

@ -1,10 +1,18 @@
namespace TaikoLocalServer.Controllers.AmAuth; using Microsoft.Extensions.Options;
using TaikoLocalServer.Settings;
namespace TaikoLocalServer.Controllers.AmAuth;
[ApiController] [ApiController]
[Route("/sys/servlet/PowerOn")] [Route("/sys/servlet/PowerOn")]
public class PowerOnController : BaseController<PowerOnController> public class PowerOnController : BaseController<PowerOnController>
{ {
private const string HOST_STARTUP = "vsapi.taiko-p.jp"; private readonly UrlSettings settings;
public PowerOnController(IOptions<UrlSettings> settings)
{
this.settings = settings.Value;
}
[HttpPost] [HttpPost]
public ContentResult PowerOn([FromForm] PowerOnRequest request) public ContentResult PowerOn([FromForm] PowerOnRequest request)
@ -14,8 +22,8 @@ public class PowerOnController : BaseController<PowerOnController>
var response = new Dictionary<string, string> var response = new Dictionary<string, string>
{ {
{"stat", "1"}, {"stat", "1"},
{"uri", HOST_STARTUP}, {"uri", settings.GameUrl},
{"host", HOST_STARTUP}, {"host", settings.GameUrl},
{"place_id", "JPN0123"}, {"place_id", "JPN0123"},
{"name", "NAMCO"}, {"name", "NAMCO"},
{"nickname", "NAMCO"}, {"nickname", "NAMCO"},

View File

@ -1,8 +1,16 @@
namespace TaikoLocalServer.Controllers.AmUpdater; using Microsoft.Extensions.Options;
using TaikoLocalServer.Settings;
namespace TaikoLocalServer.Controllers.AmUpdater;
public class MuchaController : BaseController<MuchaController> public class MuchaController : BaseController<MuchaController>
{ {
private const string URL_BASE = "https://v402-front.mucha-prd.nbgi-amnet.jp:10122"; private readonly UrlSettings settings;
public MuchaController(IOptions<UrlSettings> settings)
{
this.settings = settings.Value;
}
[HttpPost("/mucha_front/boardauth.do")] [HttpPost("/mucha_front/boardauth.do")]
@ -31,12 +39,12 @@ public class MuchaController : BaseController<MuchaController>
{ "AREA_FULL_3", "" }, { "AREA_FULL_3", "" },
{ "AREA_FULL_3_EN", "" }, { "AREA_FULL_3_EN", "" },
{ "AUTH_INTERVAL", "86400" }, { "AUTH_INTERVAL", "86400" },
{ "CHARGE_URL", $"{URL_BASE}/charge/" }, { "CHARGE_URL", $"{settings.MuchaUrl}/charge/" },
{ "CONSUME_TOKEN", "0" }, { "CONSUME_TOKEN", "0" },
{ "COUNTRY_CD", "JPN" }, { "COUNTRY_CD", "JPN" },
{ "DONGLE_FLG", "1" }, { "DONGLE_FLG", "1" },
{ "EXPIRATION_DATE", "null" }, { "EXPIRATION_DATE", "null" },
{ "FILE_URL", $"{URL_BASE}/file/" }, { "FILE_URL", $"{settings.MuchaUrl}/file/" },
{ "FORCE_BOOT", "0" }, { "FORCE_BOOT", "0" },
{ "PLACE_ID", request.PlaceId ?? "" }, { "PLACE_ID", request.PlaceId ?? "" },
{ "PREFECTURE_ID", "14" }, { "PREFECTURE_ID", "14" },
@ -46,9 +54,9 @@ public class MuchaController : BaseController<MuchaController>
{ "SHOP_NAME_EN", "NAMCO" }, { "SHOP_NAME_EN", "NAMCO" },
{ "SHOP_NICKNAME", "W" }, { "SHOP_NICKNAME", "W" },
{ "SHOP_NICKNAME_EN", "W" }, { "SHOP_NICKNAME_EN", "W" },
{ "URL_1", $"{URL_BASE}/url1/" }, { "URL_1", $"{settings.MuchaUrl}/url1/" },
{ "URL_2", $"{URL_BASE}/url2/" }, { "URL_2", $"{settings.MuchaUrl}/url2/" },
{ "URL_3", $"{URL_BASE}/url3/" }, { "URL_3", $"{settings.MuchaUrl}/url3/" },
{ "USE_TOKEN", "0" } { "USE_TOKEN", "0" }
}; };
var formOutput = FormOutputUtil.ToFormOutput(response); var formOutput = FormOutputUtil.ToFormOutput(response);
@ -63,10 +71,10 @@ public class MuchaController : BaseController<MuchaController>
{ {
{ "RESULTS", "001" }, { "RESULTS", "001" },
{ "UPDATE_VER_1", request.GameVersion ?? "S1210JPN08.18" }, { "UPDATE_VER_1", request.GameVersion ?? "S1210JPN08.18" },
{ "UPDATE_URL_1", $"{URL_BASE}/updUrl1/" }, { "UPDATE_URL_1", $"{settings.MuchaUrl}/updUrl1/" },
{ "UPDATE_SIZE_1", "0" }, { "UPDATE_SIZE_1", "0" },
{ "UPDATE_CRC_1", "0000000000000000" }, { "UPDATE_CRC_1", "0000000000000000" },
{ "CHECK_URL_1", $"{URL_BASE}/checkUrl/" }, { "CHECK_URL_1", $"{settings.MuchaUrl}/checkUrl/" },
{ "EXE_VER_1", request.GameVersion ?? "S1210JPN08.18" }, { "EXE_VER_1", request.GameVersion ?? "S1210JPN08.18" },
{ "INFO_SIZE_1", "0" }, { "INFO_SIZE_1", "0" },
{ "COM_SIZE_1", "0" }, { "COM_SIZE_1", "0" },

View File

@ -1,8 +1,29 @@
namespace TaikoLocalServer.Controllers.Api; using SharedProject.Models;
using SharedProject.Models.Responses;
using Swan.Mapping;
namespace TaikoLocalServer.Controllers.Api;
[ApiController] [ApiController]
[Route("/api/[controller]")] [Route("/api/[controller]")]
public class DashboardController : BaseController<DashboardController> public class DashboardController : BaseController<DashboardController>
{ {
private readonly TaikoDbContext context;
public DashboardController(TaikoDbContext context)
{
this.context = context;
}
[HttpGet]
public DashboardResponse GetDashboard()
{
var cards = context.Cards.AsEnumerable();
var users = cards.Select(card => card.CopyPropertiesToNew<User>()).ToList();
return new DashboardResponse
{
Users = users
};
}
} }

View File

@ -3,9 +3,9 @@ global using Microsoft.AspNetCore.Mvc;
global using Microsoft.EntityFrameworkCore; global using Microsoft.EntityFrameworkCore;
global using ProtoBuf; global using ProtoBuf;
global using Swan.Formatters; global using Swan.Formatters;
global using SharedProject.Enums;
global using taiko.game; global using taiko.game;
global using TaikoLocalServer.Common; global using TaikoLocalServer.Common;
global using TaikoLocalServer.Common.Enums;
global using TaikoLocalServer.Common.Utils; global using TaikoLocalServer.Common.Utils;
global using TaikoLocalServer.Context; global using TaikoLocalServer.Context;
global using TaikoLocalServer.Entities; global using TaikoLocalServer.Entities;

View File

@ -2,6 +2,7 @@ using System.Security.Authentication;
using Microsoft.AspNetCore.HttpLogging; using Microsoft.AspNetCore.HttpLogging;
using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.HttpOverrides;
using TaikoLocalServer.Middlewares; using TaikoLocalServer.Middlewares;
using TaikoLocalServer.Settings;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
// Manually enable tls 1.0 // Manually enable tls 1.0
@ -14,11 +15,17 @@ builder.WebHost.UseKestrel(kestrelOptions =>
}); });
// Add services to the container. // Add services to the container.
builder.Services.AddOptions();
builder.Services.Configure<UrlSettings>(builder.Configuration.GetSection(nameof(UrlSettings)));
builder.Services.AddControllers().AddProtoBufNet(); builder.Services.AddControllers().AddProtoBufNet();
builder.Services.AddDbContext<TaikoDbContext>(option => builder.Services.AddDbContext<TaikoDbContext>(option =>
{ {
var path = Path.Combine(PathHelper.GetDataPath(), Constants.DB_NAME); var dbName = builder.Configuration["DbFileName"];
if (string.IsNullOrEmpty(dbName))
{
dbName = Constants.DEFAULT_DB_NAME;
}
var path = Path.Combine(PathHelper.GetDataPath(), dbName);
option.UseSqlite($"Data Source={path}"); option.UseSqlite($"Data Source={path}");
}); });
builder.Services.AddHttpLogging(options => builder.Services.AddHttpLogging(options =>

View File

@ -0,0 +1,8 @@
namespace TaikoLocalServer.Settings;
public class UrlSettings
{
public string MuchaUrl { get; set; } = string.Empty;
public string GameUrl { get; set; } = string.Empty;
}

View File

@ -42,4 +42,8 @@
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SharedProject\SharedProject.csproj" />
</ItemGroup>
</Project> </Project>

View File

@ -1,4 +1,9 @@
{ {
"UrlSettings": {
"MuchaUrl": "https://v402-front.mucha-prd.nbgi-amnet.jp:10122",
"GameUrl": "vsapi.taiko-p.jp"
},
"DbFileName" : "taiko.db3",
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",