1128
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
@@ -8,108 +7,55 @@
|
||||
<Deterministic>true</Deterministic>
|
||||
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
|
||||
<Configurations>Debug;Release;Shipping</Configurations>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<NoWarn>8600,8602,8603,8604</NoWarn>
|
||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
<ImportDirectoryBuildProps>true</ImportDirectoryBuildProps>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<ConsoleOutputEncoding>UTF-8</ConsoleOutputEncoding>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- <Target Name="PreventDepsJsonAndRuntimeConfigFromBeingDeleted" AfterTargets="AddDepsJsonAndRuntimeConfigToCopyItemsForReferencingProjects" Condition="'$(HasRuntimeOutput)' == 'true'">-->
|
||||
<!-- <ItemGroup>-->
|
||||
<!-- <AllItemsFullPathWithTargetPath Remove="$(ProjectDepsFilePath)" />-->
|
||||
<!-- <AllItemsFullPathWithTargetPath Remove="$(ProjectRuntimeConfigFilePath)" />-->
|
||||
<!-- <AllItemsFullPathWithTargetPath Remove="$(ProjectRuntimeConfigDevFilePath)" />-->
|
||||
<!-- </ItemGroup>-->
|
||||
<!-- </Target>-->
|
||||
|
||||
<Target Name="PreventDepsJsonAndRuntimeConfigFromBeingDeleted" AfterTargets="AddDepsJsonAndRuntimeConfigToCopyItemsForReferencingProjects" Condition="'$(HasRuntimeOutput)' == 'true'">
|
||||
<ItemGroup>
|
||||
<AllItemsFullPathWithTargetPath Remove="$(ProjectDepsFilePath)"/>
|
||||
<AllItemsFullPathWithTargetPath Remove="$(ProjectRuntimeConfigFilePath)"/>
|
||||
<AllItemsFullPathWithTargetPath Remove="$(ProjectRuntimeConfigDevFilePath)"/>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<!-- <OutputPath>..\..\bin\Debug\</OutputPath>-->
|
||||
<DefineConstants>$(DefineConstants);SEQUENCE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<!-- <OutputPath>..\..\bin\Release\</OutputPath>-->
|
||||
<DefineConstants>$(DefineConstants);SEQUENCE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Shipping|AnyCPU'">
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<!-- <OutputPath>..\..\bin\Shipping\</OutputPath>-->
|
||||
<DefineConstants>$(DefineConstants);SEQUENCE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- <PropertyGroup>-->
|
||||
<!-- <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>-->
|
||||
<!-- </PropertyGroup>-->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Asp.Versioning.Mvc" />
|
||||
<PackageReference Include="Asp.Versioning.Mvc"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations"/>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Tools\ControlCenter\ControlCenter.NamedPipeHost\ControlCenter.NamedPipeHost.csproj" />
|
||||
<ProjectReference Include="..\BrokerApiCore\BrokerApiCore.csproj" />
|
||||
<ProjectReference Include="..\ServerCommon\ServerCommon.csproj" />
|
||||
<ProjectReference Include="..\ServerCore\ServerCore.csproj" />
|
||||
<ProjectReference Include="..\..\Tools\ControlCenter\ControlCenter.NamedPipeHost\ControlCenter.NamedPipeHost.csproj"/>
|
||||
<ProjectReference Include="..\BrokerApiCore\BrokerApiCore.csproj"/>
|
||||
<ProjectReference Include="..\ServerCommon\ServerCommon.csproj"/>
|
||||
<ProjectReference Include="..\ServerCore\ServerCore.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<_ContentIncludedByDefault Remove="_Config\nlog.config" />
|
||||
<_ContentIncludedByDefault Remove="_Config\ServerConfig-Local.json" />
|
||||
<_ContentIncludedByDefault Remove="_Config\ServerConfig.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- <ItemGroup>-->
|
||||
<!-- <Compile Remove="obj\**" />-->
|
||||
<!-- <Compile Remove="Config\**" />-->
|
||||
<!-- </ItemGroup>-->
|
||||
|
||||
<!-- <ItemGroup>-->
|
||||
<!-- <EmbeddedResource Remove="obj\**" />-->
|
||||
<!-- <EmbeddedResource Remove="Config\**" />-->
|
||||
<!-- </ItemGroup>-->
|
||||
|
||||
<!-- <ItemGroup>-->
|
||||
<!-- <Content Remove="obj\**" />-->
|
||||
<!-- <Content Remove="Config\**" />-->
|
||||
<!-- </ItemGroup>-->
|
||||
|
||||
<!-- <ItemGroup>-->
|
||||
<!-- <None Remove="obj\**" />-->
|
||||
<!-- <None Remove="Config\**" />-->
|
||||
<!-- </ItemGroup>-->
|
||||
|
||||
<!-- <ItemGroup>-->
|
||||
<!-- <_ContentIncludedByDefault Remove="obj\BrokerApiServer.csproj.nuget.dgspec.json" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="obj\Debug\staticwebassets.build.endpoints.json" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="obj\Debug\staticwebassets.build.json" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="obj\project.assets.json" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="obj\project.packagespec.json" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="Config\nlog.config" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="Config\ServerConfig.json" />-->
|
||||
<!-- </ItemGroup>-->
|
||||
|
||||
<!-- <ItemGroup>-->
|
||||
<!-- <_ContentIncludedByDefault Remove="bin\Debug\net8.0\Config\nlog.config" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="bin\Shipping\net8.0\linux-x64\Config\nlog.config" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="bin\Debug\net8.0\BrokerApiServer.deps.json" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="bin\Debug\net8.0\BrokerApiServer.runtimeconfig.json" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="bin\Debug\net8.0\BrokerApiServer.staticwebassets.endpoints.json" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="bin\Debug\net8.0\Config\ServerConfig.json" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="bin\Shipping\net8.0\linux-x64\BrokerApiServer.deps.json" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="bin\Shipping\net8.0\linux-x64\BrokerApiServer.runtimeconfig.json" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="bin\Shipping\net8.0\linux-x64\BrokerApiServer.staticwebassets.endpoints.json" />-->
|
||||
<!-- <_ContentIncludedByDefault Remove="bin\Shipping\net8.0\linux-x64\Config\ServerConfig.json" />-->
|
||||
<!-- </ItemGroup>-->
|
||||
|
||||
</Project>
|
||||
|
||||
111
BrokerApiServer/BrokerServerService.cs
Normal file
111
BrokerApiServer/BrokerServerService.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using CommandLine;
|
||||
|
||||
using ControlCenter.NamedPipe.Model;
|
||||
|
||||
using ServerBase;
|
||||
|
||||
using ServerCore;
|
||||
|
||||
namespace BrokerApiServer;
|
||||
|
||||
using BrokerApiCore;
|
||||
|
||||
public class BrokerServerService
|
||||
{
|
||||
public class CmdOptions
|
||||
{
|
||||
[Option("config", Default = "ServerConfig.json")]
|
||||
public string Config { get; set; } = "ServerConfig.json";
|
||||
|
||||
[Option('p', "port", Default = 12000, Required = true, HelpText = "Server Port")]
|
||||
public int Port { get; init; } = 12000;
|
||||
|
||||
[Option('s', "swagger", Default = false, Required = false, HelpText = "Show Swagger Mode")]
|
||||
public bool UseSwagger { get; init; } = false;
|
||||
}
|
||||
|
||||
private BrokerServerLogic? _serverLogic;
|
||||
private CancellationTokenSource _onStartCts = new();
|
||||
public BrokerServerLogic ServerLogic => _serverLogic!;
|
||||
public CmdOptions Options { get; private set; } = new();
|
||||
|
||||
public bool IsRunning { get; private set; } = false;
|
||||
|
||||
public async Task<List<ServerInfo>> GetServerInfosByServerType(ServerType serverType)
|
||||
{
|
||||
var (result, serverInfos) = await ServerLogic.getServerInfosByServerType(serverType);
|
||||
return result.isFail() ? [] : serverInfos;
|
||||
}
|
||||
|
||||
public async Task<int> Run(string[] args)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
Log.getLogger().info($"GameServer start");
|
||||
|
||||
var name = nameof(BrokerServerService);
|
||||
|
||||
ParserResult<CmdOptions>? parser_result = Parser.Default.ParseArguments<CmdOptions>(args);
|
||||
Options = parser_result?.Value ?? new CmdOptions();
|
||||
try
|
||||
{
|
||||
await RunServer(Options);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var err_msg = $"Exception !!!, {name}.runServer() : message:{e}";
|
||||
result.setFail(ServerErrorCode.TryCatchException, err_msg);
|
||||
await _onStartCts.CancelAsync();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (result.isFail())
|
||||
{
|
||||
Log.getLogger().error($"{name} finally error !!! - {result.toBasicString()}");
|
||||
}
|
||||
}
|
||||
|
||||
Log.getLogger().info($"{name} terminated");
|
||||
Log.shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
private async Task<Result> RunServer(CmdOptions argCmdOptions)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var key_options = new Dictionary<string, string> { { "config", argCmdOptions.Config }, };
|
||||
|
||||
var configuration = new ConfigurationBuilder().AddInMemoryCollection(key_options!).Build();
|
||||
NullReferenceCheckHelper.throwIfNull(configuration, () => $"configuration is null !!!");
|
||||
var server_config = new ServerConfig();
|
||||
server_config.setAppParamPort((ushort)argCmdOptions.Port);
|
||||
|
||||
_serverLogic = new BrokerServerLogic(server_config);
|
||||
_serverLogic.setServerType(nameof(ServerType.BrokerApi));
|
||||
_serverLogic.setConfiguration(configuration);
|
||||
_serverLogic.OnServerStart = () => { _onStartCts.Cancel(); };
|
||||
|
||||
var namedOptionBuilder = new NamedPipeClientOptionBuilder();
|
||||
namedOptionBuilder.setIP(NetworkHelper.getEthernetLocalIPv4())
|
||||
.setPort(argCmdOptions.Port)
|
||||
.setType(nameof(ServerType.BrokerApi))
|
||||
.setServiceCategory(nameof(ServiceCategory.Caliverse));
|
||||
|
||||
result = await _serverLogic.onRunServer(namedOptionBuilder);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task WaitOnStart()
|
||||
{
|
||||
while (!_onStartCts.IsCancellationRequested)
|
||||
{
|
||||
await Task.Delay(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
73
BrokerApiServer/BrokerServiceExtensions.cs
Normal file
73
BrokerApiServer/BrokerServiceExtensions.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using ServerBase;
|
||||
using ServerCore;
|
||||
using System.Reflection;
|
||||
using static ControlCenter.NamedPipeHost.Extensions.ExtensionsForClient;
|
||||
|
||||
namespace BrokerApiServer;
|
||||
public static class BrokerServiceExtensions
|
||||
{
|
||||
public static void AddBrokerServerService(this IServiceCollection services, string[] args)
|
||||
{
|
||||
var server = new BrokerServerService();
|
||||
_ = server.Run(args);
|
||||
server.WaitOnStart().Wait();
|
||||
|
||||
var broker_server_config = AppBuilderExtensions.initBrokerServerConfig();
|
||||
|
||||
services.AddSingleton(server);
|
||||
services.AddSingleton<IServerLogic>(server.ServerLogic);
|
||||
services.AddSingleton<ServerConfig>(x => server.ServerLogic.getServerConfig());
|
||||
services.AddSingleton<DynamoDbClient>(x => server.ServerLogic.getDynamoDbClient());
|
||||
services.addCoreServices(broker_server_config);
|
||||
services.addInfraServices(broker_server_config);
|
||||
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddEndpointsApiExplorer();
|
||||
services.AddControllers(options => { options.Filters.Add(new ResultExceptionFilter()); });
|
||||
services.AddHealthChecks();
|
||||
services.AddSwaggerGen(SwaggerSettingHelper.setSwaggerGen);
|
||||
|
||||
var useControlCenter = broker_server_config.ServiceType != nameof(ServiceType.Dev);
|
||||
if (useControlCenter)
|
||||
{
|
||||
var assemblies = new List<Assembly>(AppDomain.CurrentDomain.GetAssemblies());
|
||||
services.AddNamedPipelineClientManager(assemblies, ServerControlCenter.ServerType.BrokerApi,
|
||||
nameof(ServiceCategory.Caliverse), NetworkHelper.getEthernetLocalIPv4(), server.Options.Port);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UseBrokerServerService(this WebApplication app)
|
||||
{
|
||||
var server = app.Services.GetRequiredService<BrokerServerService>();
|
||||
app.UseCors("Everything");
|
||||
app.UseHttpsRedirection();
|
||||
app.UseMiddleware<ResultLoggingMiddleware>();
|
||||
app.UseAuthorization();
|
||||
app.UseRouting();
|
||||
app.MapControllers();
|
||||
if (server.Options.UseSwagger)
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.MapHealthChecks("/healthcheck");
|
||||
app.metadataMangerInit();
|
||||
app.validateRepoConnections();
|
||||
|
||||
var useControlCenter = server.ServerLogic.getServerConfig().ServiceType != nameof(ServiceType.Dev);
|
||||
if (useControlCenter)
|
||||
{
|
||||
app.UseNamedPipelineClientManager();
|
||||
}
|
||||
|
||||
// 호스트 시작 종료 콜백 처리
|
||||
var logger = Log.getLogger();
|
||||
var serviceProvider = app.Services;
|
||||
serviceProvider.GetRequiredService<IHostApplicationLifetime>().ApplicationStarted.Register(() =>
|
||||
{
|
||||
logger.Info($"Broker Api Server Service Started");
|
||||
});
|
||||
serviceProvider.GetRequiredService<IHostApplicationLifetime>().ApplicationStopped.Register(Log.shutdown);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,8 @@
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
||||
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
using ServerCore;
|
||||
|
||||
namespace BrokerApiServer;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using BrokerApiCore;
|
||||
using BrokerApiCore;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
||||
namespace BrokerApiServer;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
||||
using BrokerApiCore;
|
||||
using BrokerApiCore;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
||||
namespace BrokerApiServer;
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using BrokerApiCore;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
||||
using ServerCore;
|
||||
using BrokerApiCore;
|
||||
|
||||
namespace BrokerApiServer;
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
// using Microsoft.AspNetCore.Mvc;
|
||||
//
|
||||
// using Swashbuckle.AspNetCore.Annotations;
|
||||
//
|
||||
// using BrokerCore.ApiModels;
|
||||
// using BrokerCore.Common;
|
||||
//
|
||||
// namespace BrokerApiServer.Controllers;
|
||||
//
|
||||
// using BrokerCore.Services;
|
||||
//
|
||||
// using Common;
|
||||
//
|
||||
// [Route("api/v1/account")]
|
||||
// [ApiController, SwaggerTag("**PlanetUser 항목으로 이전 후 삭제 예정** (3월 말 예정)")]
|
||||
// // 플래닛에서 b2b 유저 로그인하는 컨트롤러
|
||||
// public class AccountController : PlanetAuthControllerBase
|
||||
// {
|
||||
// private readonly UserAuthService m_user_auth_service;
|
||||
//
|
||||
// public AccountController(UserAuthService userAuthService)
|
||||
// {
|
||||
// m_user_auth_service = userAuthService;
|
||||
// }
|
||||
//
|
||||
// [SwaggerIgnore]
|
||||
// [HttpPost, Route("login"), RequirePlanetAuth]
|
||||
// [Produces("application/json")]
|
||||
// [ProducesResponseType(typeof(LoginResponse), StatusCodes.Status200OK)]
|
||||
// [ProducesResponseType(typeof(ApiErrorResponse), StatusCodes.Status400BadRequest)]
|
||||
// [SwaggerOperation(Summary = "웹 포털 런처 토큰으로 칼리버스 유저 인증 처리 (삭제 예정 - 3월말 런칭에 불포함)",
|
||||
// Description = "플래닛의 클라이언트 구동 시 항상 유저 인증 후 실행해야 함")]
|
||||
// public async Task<IActionResult> login([FromBody] LoginRequest request)
|
||||
// {
|
||||
// Guard.Against.isNull(request, ServerErrorCode.InvalidRequest, "Request is empty");
|
||||
// Guard.Against.isNullOrEmptyOrWhiteSpace(request.WebPortalToken, ServerErrorCode.InvalidRequest,
|
||||
// "WebPortalToken does not exist");
|
||||
//
|
||||
// var result = await m_user_auth_service.authByWebPortalToken(request.WebPortalToken, this.PlanetId);
|
||||
// Guard.Against.resultFail(result);
|
||||
// return Ok(new LoginResponse { UserGuid = m_user_auth_service.UserGuid, Nickname = m_user_auth_service.Nickname, });
|
||||
// }
|
||||
//
|
||||
// [SwaggerIgnore]
|
||||
// [HttpPost, Route("dummy")]
|
||||
// public async Task<IActionResult> dummy([FromBody] DummyRequest request)
|
||||
// {
|
||||
// await Task.CompletedTask;
|
||||
// return Ok(new DummyResponse { Dummy = request.Dummy });
|
||||
// }
|
||||
// }
|
||||
@@ -1,13 +1,10 @@
|
||||
using BrokerApiServer;
|
||||
using BrokerApiCore;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
|
||||
|
||||
using BrokerApiCore;
|
||||
namespace BrokerApiServer.Controllers;
|
||||
|
||||
[Route("api/v1/admin")]
|
||||
[ApiController]
|
||||
// 운영자만 접근 가능한 컨트롤러
|
||||
@@ -118,4 +115,49 @@ public class AdminController : ControllerBase
|
||||
});
|
||||
return Ok(new PlanetItemExchangeOrderListResponse { Orders = order_dtos, TotalCount = total_count });
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("planet_provider_create"), RequireAdminAuth]
|
||||
[Produces("application/json")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(AdminPlanetProviderInfoCreateResponse))]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
||||
[SwaggerOperation(Summary = "서비스 제공자 생성 [Bearer 인증 필요]")]
|
||||
public async Task<IActionResult> planetProviderCreate(AdminPlanetProviderInfoCreateRequest request)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return Ok(new { });
|
||||
}
|
||||
|
||||
[HttpPost("planet_provider_delete"), RequireAdminAuth]
|
||||
[Produces("application/json")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(AdminPlanetProviderInfoDeleteResponse))]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
||||
[SwaggerOperation(Summary = "서비스 제공자 삭제 [Bearer 인증 필요]")]
|
||||
public async Task<IActionResult> planetProviderDelete(AdminPlanetProviderInfoDeleteRequest request)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return Ok(new { });
|
||||
}
|
||||
|
||||
[HttpPost("planet_provider_get"), RequireAdminAuth]
|
||||
[Produces("application/json")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(AdminPlanetProviderInfoGetResponse))]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
||||
[SwaggerOperation(Summary = "서비스 제공자 정보 조회 [Bearer 인증 필요]")]
|
||||
public async Task<IActionResult> planetProviderRead(AdminPlanetProviderInfoGetRequest request)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return Ok(new { });
|
||||
}
|
||||
|
||||
[HttpPost("planet_provider_update"), RequireAdminAuth]
|
||||
[Produces("application/json")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(AdminPlanetProviderInfoUpdateResponse))]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
||||
[SwaggerOperation(Summary = "서비스 제공자 정보 수정 [Bearer 인증 필요]")]
|
||||
public async Task<IActionResult> planetProviderUpdate(AdminPlanetProviderInfoUpdateRequest request)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return Ok(new { });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
// using Asp.Versioning;
|
||||
//
|
||||
// using BrokerCore.ApiModels;
|
||||
// using BrokerCore.Common;
|
||||
// using BrokerCore.Services;
|
||||
// using BrokerCore.DbEntity;
|
||||
//
|
||||
// using Microsoft.AspNetCore.Mvc;
|
||||
//
|
||||
// using Swashbuckle.AspNetCore.Annotations;
|
||||
//
|
||||
// namespace BrokerApiServer.Controllers;
|
||||
//
|
||||
// using Common;
|
||||
//
|
||||
// [ApiVersion("1.0")]
|
||||
// [Route("api/v1")]
|
||||
// [ApiController, SwaggerTag("**PlanetUser 항목으로 이전 후 삭제 예정** (3월 말 예정)")]
|
||||
// // 플래닛에서 b2b로 통신하는 컨트롤러
|
||||
// public sealed class CurrencyController : PlanetAuthControllerBase
|
||||
// {
|
||||
// private readonly SapphireExchangeService m_exchange_service;
|
||||
//
|
||||
// public CurrencyController(
|
||||
// SapphireExchangeService exchangeService)
|
||||
// {
|
||||
// m_exchange_service = exchangeService;
|
||||
// }
|
||||
//
|
||||
// [SwaggerIgnore]
|
||||
// [HttpPost("balance/sapphire"), RequirePlanetAuth]
|
||||
// [Produces("application/json")]
|
||||
// [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(SapphireResponse))]
|
||||
// [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
||||
// [SwaggerOperation(Summary = "사파이어 현재 수량 조회")]
|
||||
// public async Task<IActionResult> getSapphireBalance(SapphireRequest request)
|
||||
// {
|
||||
// await m_exchange_service.authUser(request.UserGuid, this.PlanetId);
|
||||
//
|
||||
// var current_sapphire_amount = await m_exchange_service.getCurrentSapphire();
|
||||
// return Ok(new SapphireResponse { Amount = current_sapphire_amount });
|
||||
// }
|
||||
//
|
||||
// [SwaggerIgnore]
|
||||
// [HttpPost("exchange/order/list"), RequirePlanetAuth]
|
||||
// [Produces("application/json")]
|
||||
// [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(ExchangeOrderListResponse))]
|
||||
// [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
||||
// [SwaggerOperation(Summary = "사파이어 교환 주문 목록 조회")]
|
||||
// public async Task<IActionResult> getOrders(
|
||||
// [SwaggerRequestBody] ExchangeOrderListRequest request,
|
||||
// CancellationToken cancellationToken)
|
||||
// {
|
||||
// var planet_id = this.PlanetId;
|
||||
// var user_guid = request.UserGuid;
|
||||
// await m_exchange_service.authUser(user_guid, this.PlanetId);
|
||||
//
|
||||
// ExchangeOrderStatus? order_status = request switch
|
||||
// {
|
||||
// { Option: FindOption.Completed } => ExchangeOrderStatus.Completed,
|
||||
// { Option: FindOption.Pending } => ExchangeOrderStatus.Pending,
|
||||
// _ => null // 전체 조회
|
||||
// };
|
||||
// var orders =
|
||||
// await m_exchange_service.findOrderList(planet_id, user_guid, order_status, request.PageIndex,
|
||||
// request.PageSize, "desc", cancellationToken);
|
||||
// var mapped_orders = orders.Select(x => new ExchangeOrder
|
||||
// {
|
||||
// OrderId = x.OrderId,
|
||||
// SapphireAmount = x.SapphireReducedDelta,
|
||||
// SapphireReduceAmount = x.SapphireReducedDelta,
|
||||
// EmeraldAmount = x.PlanetMoneyIncDelta,
|
||||
// CreatedAt = x.CreatedAt,
|
||||
// CompletedAt = x.CompletedAt,
|
||||
// Status = x.OrderStatus
|
||||
// });
|
||||
// return Ok(new ExchangeOrderListResponse { Orders = mapped_orders });
|
||||
// }
|
||||
//
|
||||
// // [HttpPost("exchange/order/list_for_user"), RequireUserJwtAuth]
|
||||
// // [Produces("application/json")]
|
||||
// // [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(ExchangeOrderListResponse))]
|
||||
// // [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
||||
// // [SwaggerOperation(Summary = "사파이어 교환 주문 목록 조회")]
|
||||
// // public async Task<IActionResult> getOrdersForUser(
|
||||
// // [SwaggerRequestBody] ExchangeOrderListRequest request,
|
||||
// // CancellationToken cancellationToken)
|
||||
// // {
|
||||
// // var planet_id = this.PlanetId;
|
||||
// // var user_guid = request.UserGuid;
|
||||
// // await m_exchange_service.authUser(user_guid, planet_id);
|
||||
// //
|
||||
// // ExchangeOrderStatus? order_status = request switch
|
||||
// // {
|
||||
// // { Option: FindOption.Completed } => ExchangeOrderStatus.Completed,
|
||||
// // { Option: FindOption.Pending } => ExchangeOrderStatus.Pending,
|
||||
// // _ => null // 전체 조회
|
||||
// // };
|
||||
// // var orders =
|
||||
// // await m_exchange_service.findOrderList(planet_id, user_guid, order_status, request.PageIndex,
|
||||
// // request.PageSize, request.SortOrder, cancellationToken);
|
||||
// // var mapped_orders = orders.Select(x => new ExchangeOrder
|
||||
// // {
|
||||
// // OrderId = x.OrderId,
|
||||
// // SapphireAmount = x.SapphireReducedDelta,
|
||||
// // SapphireReduceAmount = x.SapphireReducedDelta,
|
||||
// // EmeraldAmount = x.PlanetMoneyIncDelta,
|
||||
// // CreatedAt = x.CreatedAt,
|
||||
// // CompletedAt = x.CompletedAt,
|
||||
// // Status = x.OrderStatus
|
||||
// // });
|
||||
// // return Ok(new ExchangeOrderListResponse { Orders = mapped_orders });
|
||||
// // }
|
||||
//
|
||||
// [SwaggerIgnore]
|
||||
// [HttpPost("exchange/order/create"), RequirePlanetAuth]
|
||||
// [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(ExchangeOrderResponse))]
|
||||
// [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
||||
// [SwaggerOperation(Summary = "사파이어 교환 주문 체결 (사파이어 차감)")]
|
||||
// public async Task<IActionResult> createOrder(
|
||||
// ExchangeOrderRequest request,
|
||||
// CancellationToken cancellationToken)
|
||||
// {
|
||||
// var user_guid = request.UserGuid;
|
||||
// await m_exchange_service.authUser(user_guid, this.PlanetId);
|
||||
// // 메타버스 클라이언트에서 정상적으로
|
||||
// Guard.Against.isTrue(m_exchange_service.isUserLoggedIn(),
|
||||
// ServerErrorCode.MetaverseClientOnConnected,
|
||||
// "메타버스에 접속 중인 상태. 메타버스에서 정상적으로 로그아웃 한 후에 다시 시도 바람.");
|
||||
//
|
||||
// var (order, current_sapphire_balance) =
|
||||
// await m_exchange_service.createOrder(this.PlanetId, this.PlanetServerType, request.Sapphire,
|
||||
// request.Emerald);
|
||||
//
|
||||
// var response = new ExchangeOrderResponse
|
||||
// {
|
||||
// OrderId = order.OrderId,
|
||||
// SapphireAmount = order.SapphireReducedDelta,
|
||||
// EmeraldAmount = order.PlanetMoneyIncDelta,
|
||||
// CurrentSapphireBalance = current_sapphire_balance,
|
||||
// };
|
||||
// return Ok(response);
|
||||
// }
|
||||
//
|
||||
// [SwaggerIgnore]
|
||||
// [HttpPost("exchange/order/complete"), RequirePlanetAuth]
|
||||
// [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(ExchangeOrderCompleteResponse))]
|
||||
// [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
||||
// [SwaggerOperation(Summary = "사파이어 교환 완료 (완료된 이후에 에메랄드 지급")]
|
||||
// public async Task<IActionResult> completeOrder(
|
||||
// ExchangeOrderCompleteRequest request,
|
||||
// CancellationToken cancellationToken)
|
||||
// {
|
||||
// await m_exchange_service.authUser(request.UserGuid, this.PlanetId);
|
||||
//
|
||||
// var order = await m_exchange_service.completeOrder(request.OrderId, cancellationToken);
|
||||
// var response = new ExchangeOrderCompleteResponse
|
||||
// {
|
||||
// OrderId = order.OrderId,
|
||||
// SapphireAmount = order.SapphireReducedDelta,
|
||||
// EmeraldAmount = order.PlanetMoneyIncDelta,
|
||||
// Status = order.OrderStatus,
|
||||
// };
|
||||
// return Ok(response);
|
||||
// }
|
||||
// }
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using BrokerApiCore;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using BrokerApiCore;
|
||||
|
||||
namespace BrokerApiServer.Controllers;
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System.ComponentModel;
|
||||
using BrokerApiCore;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
|
||||
using BrokerApiCore;
|
||||
|
||||
namespace BrokerApiServer;
|
||||
|
||||
[Route("api/v1/planet/user")]
|
||||
@@ -34,6 +33,7 @@ public class PlanetUserController : PlanetAuthControllerBase
|
||||
|
||||
var result = await m_user_auth_service.authByWebPortalToken(request.WebPortalToken, this.PlanetId);
|
||||
Guard.Against.resultFail(result);
|
||||
|
||||
return Ok(new LoginResponse
|
||||
{
|
||||
UserGuid = m_user_auth_service.UserGuid, Nickname = m_user_auth_service.Nickname,
|
||||
@@ -54,21 +54,6 @@ public class PlanetUserController : PlanetAuthControllerBase
|
||||
return Ok(new CurrencyBalanceResponse { CaliverseCurrencyType = request.CaliverseCurrencyType, Amount = current_sapphire_amount });
|
||||
}
|
||||
|
||||
// [SwaggerIgnore]
|
||||
// [HttpPost("sapphire"), RequirePlanetAuth]
|
||||
// [Produces("application/json")]
|
||||
// [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(CurrencyBalanceResponse))]
|
||||
// [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
||||
// [SwaggerOperation(Summary = "!! 삭제 예정 => 칼리버스 측 재화 현재 수량 조회로 대체 [Bearer 인증 필요]")]
|
||||
// public async Task<IActionResult> getSapphireBalance(CurrencyBalanceRequest request)
|
||||
// {
|
||||
// var sso_account_id = string.Empty;
|
||||
// await m_exchange_service.validateAndGetUser(sso_account_id, request.UserGuid, this.PlanetId);
|
||||
//
|
||||
// var current_sapphire_amount = await m_exchange_service.getCurrentSapphire();
|
||||
// return Ok(new CurrencyBalanceResponse { Amount = current_sapphire_amount });
|
||||
// }
|
||||
|
||||
[HttpPost("exchange/order/list"), RequirePlanetAuth]
|
||||
[Produces("application/json")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(PlanetItemExchangeOrderListResponse))]
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
//
|
||||
// using Asp.Versioning;
|
||||
//
|
||||
// using BrokerCore.ApiModels;
|
||||
// using BrokerCore.Common;
|
||||
// using BrokerCore.DbEntity;
|
||||
// using BrokerCore.Services;
|
||||
//
|
||||
// using Microsoft.AspNetCore.Mvc;
|
||||
//
|
||||
// using ServerCommon;
|
||||
//
|
||||
// using Swashbuckle.AspNetCore.Annotations;
|
||||
//
|
||||
// namespace BrokerApiServer.Controllers;
|
||||
//
|
||||
// [ApiVersion("1.0")]
|
||||
// [Route("api/v1/user")]
|
||||
// [ApiController, SwaggerTag("**PlanetUser 항목으로 이전 후 삭제 예정** (3월 말 예정)")]
|
||||
// // 특별한 인증 없이 런처 토큰만으로도 사용 가능한 컨트롤러
|
||||
// public class UserController : ControllerBase
|
||||
// {
|
||||
// private readonly SapphireExchangeService m_exchange_service;
|
||||
// private readonly IServerLogic m_server_logic;
|
||||
//
|
||||
// public UserController(
|
||||
// IServerLogic serverLogic,
|
||||
// SapphireExchangeService exchangeService)
|
||||
// {
|
||||
// m_server_logic = serverLogic;
|
||||
// m_exchange_service = exchangeService;
|
||||
// }
|
||||
//
|
||||
// [SwaggerIgnore]
|
||||
// [HttpPost("balance/sapphire"), RequireUserJwtAuth]
|
||||
// [Produces("application/json")]
|
||||
// [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(UserSapphireResponse))]
|
||||
// [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
||||
// [SwaggerOperation(Summary = "유저 사파이어 현재 수량 조회 (유저 sso jwt bearer header 필요)",
|
||||
// Description = "웹 런처에서 발급한 토큰을 header의 authorization에 bearer 형식으로 넣어주세요.")]
|
||||
// public async Task<IActionResult> getSapphireBalance(UserSapphireRequest _)
|
||||
// {
|
||||
// var dynamo_db_client = m_server_logic.getDynamoDbClient();
|
||||
// var user_guid = this.HttpContext.Items["user_guid"] as string ?? string.Empty;
|
||||
// CurrencyControlHelper.setDbConnector(dynamo_db_client);
|
||||
// var (result, current_sapphire_amount_double) =
|
||||
// await CurrencyControlHelper.getMoneyByUserGuid(user_guid, CurrencyType.Sapphire);
|
||||
// Guard.Against.resultFail(result);
|
||||
//
|
||||
// var current_sapphire_amount = Convert.ToInt64(current_sapphire_amount_double);
|
||||
// return Ok(new UserSapphireResponse { SapphireAmount = current_sapphire_amount });
|
||||
// }
|
||||
//
|
||||
// [SwaggerIgnore]
|
||||
// [HttpPost("exchange/order/list"), RequireUserJwtAuth]
|
||||
// [Produces("application/json")]
|
||||
// [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(UserExchangeOrderListResponse))]
|
||||
// [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
||||
// [SwaggerOperation(Summary = "유저 사파이어 교환 주문 목록 조회 (유저 sso jwt bearer header 필요)",
|
||||
// Description = "웹 런처에서 발급한 토큰을 header의 authorization에 bearer 형식으로 넣어주세요.\n 이기몹의 PlanetId는 igm26_iggymob 입니다.")]
|
||||
// public async Task<IActionResult> getOrdersForUser(
|
||||
// [SwaggerRequestBody] UserExchangeOrderListRequest request,
|
||||
// CancellationToken cancellationToken)
|
||||
// {
|
||||
// var planet_id = request.PlanetId;
|
||||
// var user_guid = this.HttpContext.Items["user_guid"]?.ToString() ?? string.Empty;
|
||||
// Guard.Against.isNullOrEmptyOrWhiteSpace(user_guid,
|
||||
// ServerErrorCode.AccountNotFound, "해당 유저를 찾을 수 없음");
|
||||
// await m_exchange_service.authUser(user_guid, string.Empty);
|
||||
//
|
||||
// ExchangeOrderStatus? order_status = request switch
|
||||
// {
|
||||
// { Option: FindOption.Completed } => ExchangeOrderStatus.Completed,
|
||||
// { Option: FindOption.Pending } => ExchangeOrderStatus.Pending,
|
||||
// _ => null // 전체 조회
|
||||
// };
|
||||
// var orders =
|
||||
// await m_exchange_service.findOrderList(planet_id, user_guid, order_status,
|
||||
// request.PageIndex, request.PageSize, request.SortOrder,
|
||||
// cancellationToken);
|
||||
// var mapped_orders = orders.Select(x => new ExchangeOrder
|
||||
// {
|
||||
// OrderId = x.OrderId,
|
||||
// SapphireAmount = x.SapphireReducedDelta,
|
||||
// SapphireReduceAmount = x.SapphireReducedDelta,
|
||||
// EmeraldAmount = x.PlanetMoneyIncDelta,
|
||||
// CreatedAt = x.CreatedAt,
|
||||
// CompletedAt = x.CompletedAt,
|
||||
// Status = x.OrderStatus
|
||||
// });
|
||||
// return Ok(new UserExchangeOrderListResponse { Orders = mapped_orders });
|
||||
// }
|
||||
// }
|
||||
@@ -1,8 +1,8 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<BaseIntermediateOutputPath>..\..\obj\AnyCPU\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
|
||||
<BaseOutputPath>..\..\bin\</BaseOutputPath>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using System.Text;
|
||||
using BrokerApiCore;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
using ServerBase;
|
||||
using ServerCore;
|
||||
using BrokerApiCore;
|
||||
|
||||
namespace BrokerApiServer;
|
||||
|
||||
@@ -13,19 +12,8 @@ public static class AppBuilderExtensions
|
||||
{
|
||||
public static void initGlobalNlog()
|
||||
{
|
||||
// nlog 설정
|
||||
var nlog_config_path = "./Config/nlog.config";
|
||||
var full_path = Path.GetFullPath(nlog_config_path);
|
||||
if (!File.Exists(full_path))
|
||||
{
|
||||
full_path = Path.GetFullPath(nlog_config_path, AppContext.BaseDirectory);
|
||||
if (!File.Exists(full_path))
|
||||
{
|
||||
throw new ApplicationException($"nlog.config 파일을 찾을 수 없음 => {full_path}");
|
||||
}
|
||||
}
|
||||
|
||||
Log.NLogFileName = full_path;
|
||||
Log.initLog(nameof(ServerType.BrokerApi), "Developer"); // nlog 설정
|
||||
Log.getLogger().info("NLog Init");
|
||||
}
|
||||
|
||||
public static ServerConfigMetaverseBroker initBrokerServerConfig()
|
||||
@@ -42,35 +30,18 @@ public static class AppBuilderExtensions
|
||||
throw new ApplicationException("ServerConfig.json 파일을 찾을 수 없음");
|
||||
}
|
||||
}
|
||||
|
||||
server_config.setConfigFilePath(full_path);
|
||||
var result = server_config.tryLoadConfig().GetAwaiter().GetResult();
|
||||
Guard.Against.resultFail(result);
|
||||
return server_config;
|
||||
}
|
||||
|
||||
public static void addBrokerServerLogic(this IServiceCollection services,
|
||||
ServerConfigMetaverseBroker serverConfig)
|
||||
{
|
||||
var broker_logic = new BrokerServerLogic(serverConfig);
|
||||
var result = broker_logic.onInit().GetAwaiter().GetResult();
|
||||
if (result.isFail())
|
||||
{
|
||||
Log.getLogger().error($"BrokerServerLogic Init Failed => {result}");
|
||||
throw new ApplicationException($"BrokerServerLogic Init Failed => {result}");
|
||||
}
|
||||
ServerLogicApp.setServerLogicApp(broker_logic);
|
||||
services.AddSingleton<IServerLogic>(broker_logic);
|
||||
}
|
||||
|
||||
public static void addCoreServices(this IServiceCollection services,
|
||||
ServerConfigMetaverseBroker serverConfig)
|
||||
{
|
||||
services.AddSingleton(serverConfig);
|
||||
|
||||
var broker_logic = new BrokerServerLogic(serverConfig);
|
||||
var result = broker_logic.onInit().GetAwaiter().GetResult();
|
||||
services.AddSingleton<IServerLogic>(broker_logic);
|
||||
|
||||
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
.AddJwtBearer(options =>
|
||||
{
|
||||
@@ -80,7 +51,9 @@ public static class AppBuilderExtensions
|
||||
ValidateAudience = false,
|
||||
ValidateLifetime = true,
|
||||
ValidateIssuerSigningKey = true,
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(serverConfig.MetaverseBroker?.JwtSecretKey ?? String.Empty))
|
||||
IssuerSigningKey =
|
||||
new SymmetricSecurityKey(
|
||||
Encoding.UTF8.GetBytes(serverConfig.MetaverseBroker?.JwtSecretKey ?? String.Empty))
|
||||
};
|
||||
});
|
||||
|
||||
@@ -90,7 +63,7 @@ public static class AppBuilderExtensions
|
||||
|
||||
// 메타데이터 관련 서비스 등록
|
||||
services.AddSingleton<BrokerApiMetaLoader>();
|
||||
services.AddScoped<BrokerMetaTableRef>( provider =>
|
||||
services.AddScoped<BrokerMetaTableRef>(provider =>
|
||||
{
|
||||
var meta_loader = provider.GetRequiredService<BrokerApiMetaLoader>();
|
||||
return new BrokerMetaTableRef(meta_loader.getMetaTable());
|
||||
@@ -104,14 +77,8 @@ public static class AppBuilderExtensions
|
||||
};
|
||||
services.AddSingleton(jwt_option);
|
||||
|
||||
services.AddScoped<JwtGenerator>(provider =>
|
||||
{
|
||||
return new JwtGenerator(jwt_option);
|
||||
});
|
||||
services.AddScoped<JwtParser>(provider =>
|
||||
{
|
||||
return new JwtParser(jwt_option);
|
||||
});
|
||||
services.AddScoped<JwtGenerator>(provider => { return new JwtGenerator(jwt_option); });
|
||||
services.AddScoped<JwtParser>(provider => { return new JwtParser(jwt_option); });
|
||||
|
||||
services.AddScoped<PlanetService>();
|
||||
|
||||
@@ -128,6 +95,8 @@ public static class AppBuilderExtensions
|
||||
services.AddScoped<PlanetItemExchangeOrderAmountTotalLimitRepo>();
|
||||
services.AddScoped<PlanetItemExchangeOrderAmountUserLimitRepo>();
|
||||
|
||||
services.AddSingleton<DynamoDbClient>();
|
||||
|
||||
services.AddDbContext<SsoAccountDbContext>(options =>
|
||||
{
|
||||
var connection_string = serverConfig.SsoAccountDb;
|
||||
@@ -148,29 +117,19 @@ public static class AppBuilderExtensions
|
||||
{
|
||||
var connection_string = serverConfig.MetaverseBroker?.MetaverseBrokerDb;
|
||||
|
||||
options.UseMySql(connection_string, ServerVersion.AutoDetect(connection_string), my_sql_options =>
|
||||
options.UseMySql(connection_string, ServerVersion.AutoDetect(connection_string), mySqlOptions =>
|
||||
{
|
||||
my_sql_options.EnableRetryOnFailure(
|
||||
mySqlOptions.EnableRetryOnFailure(
|
||||
maxRetryCount: 10,
|
||||
maxRetryDelay: TimeSpan.FromSeconds(30),
|
||||
errorNumbersToAdd: null
|
||||
);
|
||||
my_sql_options.CommandTimeout(60);
|
||||
my_sql_options.MaxBatchSize(20);
|
||||
mySqlOptions.CommandTimeout(60);
|
||||
mySqlOptions.MaxBatchSize(20);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// todo: isLocal 삭제 예정
|
||||
public static void addAppServices(this WebApplicationBuilder builder)
|
||||
{
|
||||
initGlobalNlog();
|
||||
var server_config = initBrokerServerConfig();
|
||||
builder.Services.addBrokerServerLogic(server_config);
|
||||
builder.Services.addCoreServices(server_config);
|
||||
builder.Services.addInfraServices(server_config);
|
||||
}
|
||||
|
||||
public static void brokerServerLogicInit(this IApplicationBuilder app)
|
||||
{
|
||||
var server_logic = app.ApplicationServices.GetRequiredService<IServerLogic>() as BrokerServerLogic;
|
||||
@@ -191,20 +150,29 @@ public static class AppBuilderExtensions
|
||||
|
||||
public static void validateRepoConnections(this IApplicationBuilder app)
|
||||
{
|
||||
var env = app.ApplicationServices.GetRequiredService<IWebHostEnvironment>();
|
||||
// db 접속 유무 검사
|
||||
using var scope = app.ApplicationServices.CreateScope();
|
||||
var services = scope.ServiceProvider;
|
||||
validateSsoAccountDb().Wait();
|
||||
validateMetaverseBrokerDb().Wait();
|
||||
migrateMetaverseBrokerDbForDevelopment().Wait();
|
||||
try
|
||||
{
|
||||
validateSsoAccountDb().Wait();
|
||||
validateMetaverseBrokerDb().Wait();
|
||||
// 마이그레이션은 코드에서 호출하지 말고, 별도의 migration script를 통해서 수행한다.
|
||||
migrateMetaverseBrokerDbForDevelopment().Wait();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.getLogger().error($"[Check Tunneling] Repo Connections Validation Failed => {ex.Message}");
|
||||
throw new ApplicationException($"Repo Connections Validation Failed => {ex.Message}");
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
async Task validateSsoAccountDb()
|
||||
{
|
||||
var context = services.GetRequiredService<SsoAccountDbContext>();
|
||||
try
|
||||
{
|
||||
var context = services.GetRequiredService<SsoAccountDbContext>();
|
||||
if (await context.Database.CanConnectAsync())
|
||||
{
|
||||
Log.getLogger().info($"Sso Account DB Connection OK => {context.Database.GetConnectionString()}");
|
||||
@@ -217,17 +185,17 @@ public static class AppBuilderExtensions
|
||||
{
|
||||
Log.getLogger()
|
||||
.error(
|
||||
$"Sso Account DB Connection Failed => {ex.Message}, {context.Database.GetConnectionString()}");
|
||||
$"Sso Account DB Connection Failed => {ex.Message}");
|
||||
}
|
||||
|
||||
throw new ApplicationException($"Failed to connect Sso Account Db !!!");
|
||||
// throw new ApplicationException($"Failed to connect Sso Account Db !!!");
|
||||
}
|
||||
|
||||
async Task validateMetaverseBrokerDb()
|
||||
{
|
||||
var context = services.GetRequiredService<MetaverseBrokerDbContext>();
|
||||
try
|
||||
{
|
||||
var context = services.GetRequiredService<MetaverseBrokerDbContext>();
|
||||
if (await context.Database.CanConnectAsync())
|
||||
{
|
||||
Log.getLogger()
|
||||
@@ -237,15 +205,16 @@ public static class AppBuilderExtensions
|
||||
if (migrations.Any())
|
||||
{
|
||||
Log.getLogger().error($"{context.Database.ToString()} 마이그레션이 필요함 !!!");
|
||||
migrations.Select( x => x.ToString()).ToList().ForEach(x => Log.getLogger().warn(x));
|
||||
migrations.Select(x => x.ToString()).ToList().ForEach(x => Log.getLogger().warn(x));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.getLogger()
|
||||
.error($"Metaverse-Broker DB 접속 예외 발생 => {ex.Message}, {context.Database.GetConnectionString()}");
|
||||
.error($"Metaverse-Broker DB 접속 예외 발생 => {ex.Message}");
|
||||
}
|
||||
|
||||
throw new ApplicationException($"Failed to connect Broker Db !!!");
|
||||
@@ -268,4 +237,80 @@ public static class AppBuilderExtensions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void addDynamoDb(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<DynamoDbClient>(x =>
|
||||
{
|
||||
var dynamo_db_client = new DynamoDbClient();
|
||||
return dynamo_db_client;
|
||||
// var result = new Result();
|
||||
// var config = x.GetRequiredService<ServerConfig>();
|
||||
//
|
||||
// (var error_code, var table_names) =
|
||||
// ServerConfigHelper.getDynamoDbTableNamesWithServiceType(config.ServiceType);
|
||||
// if (error_code.isFail())
|
||||
// {
|
||||
// var err_msg =
|
||||
// $"Failed to DynamoDbClient.getDynamoDbTableNameWithServiceType() !!! : {config.toBasicString()}";
|
||||
// result.setFail(error_code, err_msg);
|
||||
// Log.getLogger().error(err_msg);
|
||||
// Guard.Against.resultFail(result);
|
||||
// }
|
||||
//
|
||||
// var dynamo_db_client = new DynamoDbClient();
|
||||
// var dynamodb_url = config.Dynamodb;
|
||||
// var region = config.AWS.Region;
|
||||
// var access_key = config.AWS.AccessKey;
|
||||
// var secret_key = config.AWS.SecretKey;
|
||||
// var use_local_db = config.AWS.LocalDynamoDB;
|
||||
// if (result.isFail())
|
||||
// {
|
||||
// Log.getLogger().error($"Failed to connectToDb !!! ");
|
||||
// Guard.Against.resultFail(result);
|
||||
// }
|
||||
//
|
||||
// dynamo_db_client.connectToDb(table_names, use_local_db, dynamodb_url, access_key, secret_key, region);
|
||||
// return dynamo_db_client;
|
||||
});
|
||||
}
|
||||
|
||||
public static void useDynamoDb(this IApplicationBuilder app)
|
||||
{
|
||||
var result = new Result();
|
||||
var config = app.ApplicationServices.GetRequiredService<ServerConfig>();
|
||||
|
||||
(var error_code, var table_names) =
|
||||
ServerConfigHelper.getDynamoDbTableNamesWithServiceType(config.ServiceType);
|
||||
if (error_code.isFail())
|
||||
{
|
||||
var err_msg =
|
||||
$"Failed to DynamoDbClient.getDynamoDbTableNameWithServiceType() !!! : {config.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
Guard.Against.resultFail(result);
|
||||
}
|
||||
|
||||
var dynamo_db_client = app.ApplicationServices.GetRequiredService<DynamoDbClient>();
|
||||
var dynamodb_url = config.Dynamodb;
|
||||
var region = config.AWS.Region;
|
||||
var access_key = config.AWS.AccessKey;
|
||||
var secret_key = config.AWS.SecretKey;
|
||||
var use_local_db = config.AWS.LocalDynamoDB;
|
||||
result = dynamo_db_client.connectToDb(table_names, use_local_db, dynamodb_url, access_key, secret_key, region);
|
||||
if (result.isFail())
|
||||
{
|
||||
Log.getLogger().error($"Failed to connectToDb !!! ");
|
||||
Guard.Against.resultFail(result);
|
||||
}
|
||||
|
||||
var task = dynamo_db_client.createDBIfNotExists(false);
|
||||
task.Wait();
|
||||
if (false == task.Result)
|
||||
{
|
||||
var err_msg = $"Failed to create DB Table !!!";
|
||||
result.setFail(ServerErrorCode.DynamoDbTableCreateFailed, err_msg);
|
||||
Guard.Against.resultFail(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,33 @@
|
||||
using ControlCenter.NamedPipe;
|
||||
using ControlCenter.NamedPipeHost.Manager;
|
||||
using ServerBase;
|
||||
using ServerControlCenter;
|
||||
|
||||
using ServerCore;
|
||||
|
||||
|
||||
namespace BrokerApiServer;
|
||||
namespace MatchServer;
|
||||
|
||||
public class ForceStopServerMessageReceiver : NamedPipeReceiver<A2S_REQ_FORCE_STOP_SERVER>
|
||||
{
|
||||
private readonly ServerInfoManager m_info_manager;
|
||||
// private readonly ServerInfoManager m_info_manager;
|
||||
|
||||
public ForceStopServerMessageReceiver(ServerInfoManager infoManager)
|
||||
{
|
||||
m_info_manager = infoManager;
|
||||
}
|
||||
public ForceStopServerMessageReceiver()
|
||||
{
|
||||
// m_info_manager = infoManager;
|
||||
}
|
||||
|
||||
public override async Task Handle(A2S_REQ_FORCE_STOP_SERVER message, string message_id)
|
||||
{
|
||||
Log.getLogger().debug($"{nameof(ForceStopServerMessageReceiver)}: Receive - message_id[{message_id}] / message[{message}]");
|
||||
public override async Task Handle(A2S_REQ_FORCE_STOP_SERVER message, string message_id)
|
||||
{
|
||||
Log.getLogger().debug($"{nameof(ForceStopServerMessageReceiver)}: Receive - message_id[{message_id}] / message[{message}]");
|
||||
|
||||
m_info_manager.setServerStatus(ServerStatus.Stop);
|
||||
await NamedPipeMonitor.ChangeServerStatus(ServerStatus.Stop);
|
||||
// m_info_manager.setServerStatus(ServerStatus.Stop);
|
||||
|
||||
// 정보 전달 대기
|
||||
await Task.Delay(1_000);
|
||||
// 정보 전달 대기
|
||||
await Task.Delay(1_000);
|
||||
|
||||
// process 종료
|
||||
Environment.Exit(0);
|
||||
}
|
||||
// process 종료
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,25 +5,26 @@ using ServerCore;
|
||||
|
||||
namespace BrokerApiServer;
|
||||
|
||||
using ControlCenter.NamedPipe;
|
||||
|
||||
using ServerBase;
|
||||
|
||||
public class StopServerMessageReceiver : NamedPipeReceiver<A2S_REQ_STOP_SERVER>
|
||||
{
|
||||
private readonly ServerInfoManager m_info_manager;
|
||||
public StopServerMessageReceiver()
|
||||
{
|
||||
}
|
||||
|
||||
public StopServerMessageReceiver(ServerInfoManager infoManager)
|
||||
{
|
||||
m_info_manager = infoManager;
|
||||
}
|
||||
public override async Task Handle(A2S_REQ_STOP_SERVER message, string message_id)
|
||||
{
|
||||
Log.getLogger().debug($"{nameof(StopServerMessageReceiver)}: Receive - message_id[{message_id}] / message[{message}]");
|
||||
|
||||
public override async Task Handle(A2S_REQ_STOP_SERVER message, string message_id)
|
||||
{
|
||||
Log.getLogger().debug($"{nameof(StopServerMessageReceiver)}: Receive - message_id[{message_id}] / message[{message}]");
|
||||
await NamedPipeMonitor.ChangeServerStatus(ServerStatus.Stop);
|
||||
|
||||
m_info_manager.setServerStatus(ServerStatus.Stop);
|
||||
// 정보 전달 대기
|
||||
await Task.Delay(1_000);
|
||||
|
||||
// 정보 전달 대기
|
||||
await Task.Delay(1_000);
|
||||
|
||||
// process 종료
|
||||
Environment.Exit(0);
|
||||
}
|
||||
// process 종료
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +1,18 @@
|
||||
using System.Reflection;
|
||||
using BrokerApiServer;
|
||||
using CommandLine;
|
||||
using ControlCenter.NamedPipeHost.Extensions;
|
||||
using ServerCore;
|
||||
|
||||
//=============================================================================
|
||||
// 인자 설정
|
||||
//=============================================================================
|
||||
var port = 12000;
|
||||
var use_swagger = false;
|
||||
var parsed_arguments = Parser.Default.ParseArguments<CommandLineOption>(args);
|
||||
if (parsed_arguments is Parsed<CommandLineOption> parsed)
|
||||
|
||||
var parsed_arguments = Parser.Default.ParseArguments<BrokerServerService.CmdOptions>(args);
|
||||
if (parsed_arguments is Parsed<BrokerServerService.CmdOptions> parsed)
|
||||
{
|
||||
port = parsed.Value.Port;
|
||||
use_swagger = parsed.Value.UseSwagger ? true : false;
|
||||
}
|
||||
|
||||
var cmd_options = new string[] { "--urls", $"http://*:{port}" };
|
||||
|
||||
var builder = WebApplication.CreateBuilder(cmd_options);
|
||||
builder.addAppServices();
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddControllers(options => { options.Filters.Add(new ResultExceptionFilter()); });
|
||||
builder.Services.AddHealthChecks();
|
||||
builder.Services.AddSwaggerGen(SwaggerSettingHelper.setSwaggerGen);
|
||||
|
||||
var assemblies = new List<Assembly>(AppDomain.CurrentDomain.GetAssemblies());
|
||||
builder.Services.AddNamedPipelineClientManager(assemblies, ServerControlCenter.ServerType.BrokerApi,
|
||||
ServiceCategory.Caliverse.ToString(), NetworkHelper.getEthernetLocalIPv4(), port);
|
||||
builder.Services.AddBrokerServerService(args);
|
||||
|
||||
var app = builder.Build();
|
||||
app.UseCors("Everything");
|
||||
app.UseHttpsRedirection();
|
||||
app.UseMiddleware<ResultLoggingMiddleware>();
|
||||
app.UseAuthorization();
|
||||
app.UseRouting();
|
||||
app.MapControllers();
|
||||
if (use_swagger)
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.MapHealthChecks("/healthcheck");
|
||||
|
||||
app.validateRepoConnections();
|
||||
app.brokerServerLogicInit();
|
||||
|
||||
// todo: 스키마 변경 시 자동으로 앱에서 마이그레이션 하지 않고, dotnet ef 툴을 사용할 것
|
||||
// app.metadataMangerInit();
|
||||
|
||||
app.Services.GetRequiredService<IHostApplicationLifetime>().ApplicationStarted.Register(() =>
|
||||
{
|
||||
Log.getLogger().info($"Env : {app.Environment.EnvironmentName}");
|
||||
Log.getLogger().info($"BrokerApiServer started {app.Urls}");
|
||||
});
|
||||
app.Services.GetRequiredService<IHostApplicationLifetime>().ApplicationStopped.Register(Log.shutdown);
|
||||
|
||||
app.UseNamedPipelineClientManager();
|
||||
|
||||
app.UseBrokerServerService();
|
||||
app.Run();
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "-p 12000 -s --named-pipe true",
|
||||
"commandLineArgs": "-p 12000 -s",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:12000"
|
||||
"applicationUrl": "http://localhost:12000",
|
||||
"workingDirectory": "../../bin/$(Configuration)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user