[성현모] KMS 서비스 기능 추가
This commit is contained in:
@ -7,7 +7,63 @@
|
|||||||
"API": [
|
"API": [
|
||||||
{
|
{
|
||||||
"ApiName": "kms",
|
"ApiName": "kms",
|
||||||
"Address": "https://1.237.74.86:5698/"
|
"Functions": [
|
||||||
|
{
|
||||||
|
"Name": "EcuID_SupplierEcuID",
|
||||||
|
"Method": "Post",
|
||||||
|
"Url": "https://1.237.74.86:5698/app/automotive/supplierEcuID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "MasterEcuKey_SupplierKeyProvisioning",
|
||||||
|
"Method": "Post",
|
||||||
|
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeyProvisioning"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "MasterEcuKey_SupplierKeyProvisioningResult",
|
||||||
|
"Method": "Put",
|
||||||
|
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeyProvisioning"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "SupplierSymmKey_SupplierKeyProvisioning",
|
||||||
|
"Method": "Post",
|
||||||
|
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeyProvisioning"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "SupplierSymmKey_SupplierKeyProvisioningResult",
|
||||||
|
"Method": "Put",
|
||||||
|
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeyProvisioning"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "SupplierSymmKey_SupplierKeySyncValue",
|
||||||
|
"Method": "Post",
|
||||||
|
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeySyncValue"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "SupplierSymmKey_SupplierKeySyncValueResult",
|
||||||
|
"Method": "Put",
|
||||||
|
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeySyncValue"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "SecOCKey_SupplierKeyProvisioning",
|
||||||
|
"Method": "Post",
|
||||||
|
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeyProvisioning"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "SecOCKey_SupplierKeyProvisioningResult",
|
||||||
|
"Method": "Put",
|
||||||
|
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeyProvisioning"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "SecOCKey_SupplierKeySyncValue",
|
||||||
|
"Method": "Post",
|
||||||
|
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeySyncValue"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "SecOCKey_SupplierKeySyncValueResult",
|
||||||
|
"Method": "Put",
|
||||||
|
"Url": "https://1.237.74.86:5698/app/automotive/supplierKeySyncValue"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -25,41 +25,38 @@ namespace WebApi.Project.ProxyKMS.Controllers
|
|||||||
Guid guid = Guid.NewGuid();
|
Guid guid = Guid.NewGuid();
|
||||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
|
var response = await _kmsMetaService.PostKms<EcuID.Request_SupplierEcuID, EcuID.Response_SupplierEcuID>(request, guid.ToString());
|
||||||
|
|
||||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// return Results.Ok(response);
|
return Results.Ok(response);
|
||||||
return Results.Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//2. MasterECUKEy
|
//2. MasterECUKEy
|
||||||
[HttpPost("MasterEcuKey/SupplierKeyProvisioning")]
|
[HttpPost("MasterEcuKey/SupplierKeyProvisioning")]
|
||||||
public async Task<IResult> MasterEcuKey_SupplierKeyProvisioning([FromBody] EcuID.Request_SupplierEcuID request)
|
public async Task<IResult> MasterEcuKey_SupplierKeyProvisioning([FromBody] MasterEcuKey.Request_SupplierKeyProvisioning request)
|
||||||
{
|
{
|
||||||
Guid guid = Guid.NewGuid();
|
Guid guid = Guid.NewGuid();
|
||||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
|
var response = await _kmsMetaService.PostKms<MasterEcuKey.Request_SupplierKeyProvisioning, MasterEcuKey.Response_SupplierKeyProvisioning>(request, guid.ToString());
|
||||||
|
|
||||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// return Results.Ok(response);
|
return Results.Ok(response);
|
||||||
return Results.Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("MasterEcuKey/SupplierKeyProvisioning")]
|
[HttpPut("MasterEcuKey/SupplierKeyProvisioning")]
|
||||||
public async Task<IResult> MasterEcuKey_SupplierKeyProvisioningResult([FromBody] MasterEcuKey.Request_SupplierKeyProvisioning request)
|
public async Task<IResult> MasterEcuKey_SupplierKeyProvisioningResult([FromBody] MasterEcuKey.Request_SupplierKeyProvisioning_Result request)
|
||||||
{
|
{
|
||||||
Guid guid = Guid.NewGuid();
|
Guid guid = Guid.NewGuid();
|
||||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
|
var response = await _kmsMetaService.PutKms<MasterEcuKey.Request_SupplierKeyProvisioning_Result, MasterEcuKey.Response_SupplierKeyProvisioning_Result>(request, guid.ToString());
|
||||||
|
|
||||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// return Results.Ok(response);
|
return Results.Ok(response);
|
||||||
return Results.Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//3. SupplierSymmKey
|
//3. SupplierSymmKey
|
||||||
@ -69,12 +66,11 @@ namespace WebApi.Project.ProxyKMS.Controllers
|
|||||||
Guid guid = Guid.NewGuid();
|
Guid guid = Guid.NewGuid();
|
||||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
|
var response = await _kmsMetaService.PostKms<SupplierSymmKey.Request_SupplierKeyProvisioning, SupplierSymmKey.Response_SupplierKeyProvisioning>(request, guid.ToString());
|
||||||
|
|
||||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// return Results.Ok(response);
|
return Results.Ok(response);
|
||||||
return Results.Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("SupplierSymmKey/SupplierKeyProvisioning")]
|
[HttpPut("SupplierSymmKey/SupplierKeyProvisioning")]
|
||||||
@ -83,40 +79,37 @@ namespace WebApi.Project.ProxyKMS.Controllers
|
|||||||
Guid guid = Guid.NewGuid();
|
Guid guid = Guid.NewGuid();
|
||||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
|
var response = await _kmsMetaService.PutKms<SupplierSymmKey.Request_SupplierKeyProvisioning_Result, SupplierSymmKey.Response_SupplierKeyProvisioning_Result>(request, guid.ToString());
|
||||||
|
|
||||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// return Results.Ok(response);
|
return Results.Ok(response);
|
||||||
return Results.Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("SupplierSymmKey/SupplierKeySyncValue")]
|
[HttpPost("SupplierSymmKey/SupplierKeySyncValue")]
|
||||||
public async Task<IResult> SupplierSymmKey_SupplierKeySyncValue([FromBody] SupplierSymmKey.Request_SupplierKeyProvisioning request)
|
public async Task<IResult> SupplierSymmKey_SupplierKeySyncValue([FromBody] SupplierSymmKey.Request_SupplierKeySyncValue request)
|
||||||
{
|
{
|
||||||
Guid guid = Guid.NewGuid();
|
Guid guid = Guid.NewGuid();
|
||||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
|
var response = await _kmsMetaService.PostKms<SupplierSymmKey.Request_SupplierKeySyncValue, SupplierSymmKey.Response_SupplierKeySyncValue>(request, guid.ToString());
|
||||||
|
|
||||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// return Results.Ok(response);
|
return Results.Ok(response);
|
||||||
return Results.Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("SupplierSymmKey/SupplierKeySyncValue")]
|
[HttpPut("SupplierSymmKey/SupplierKeySyncValue")]
|
||||||
public async Task<IResult> SupplierSymmKey_SupplierKeySyncValueResult([FromBody] SupplierSymmKey.Request_SupplierKeyProvisioning_Result request)
|
public async Task<IResult> SupplierSymmKey_SupplierKeySyncValueResult([FromBody] SupplierSymmKey.Request_SupplierKeySyncValue_Result request)
|
||||||
{
|
{
|
||||||
Guid guid = Guid.NewGuid();
|
Guid guid = Guid.NewGuid();
|
||||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
|
var response = await _kmsMetaService.PutKms<SupplierSymmKey.Request_SupplierKeySyncValue_Result, SupplierSymmKey.Response_SupplierKeySyncValue_Result>(request, guid.ToString());
|
||||||
|
|
||||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// return Results.Ok(response);
|
return Results.Ok(response);
|
||||||
return Results.Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//4,SecOCKey
|
//4,SecOCKey
|
||||||
@ -126,12 +119,11 @@ namespace WebApi.Project.ProxyKMS.Controllers
|
|||||||
Guid guid = Guid.NewGuid();
|
Guid guid = Guid.NewGuid();
|
||||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
|
var response = await _kmsMetaService.PostKms<SecOCKey.Request_SupplierKeyProvisioning, SecOCKey.Response_SupplierKeyProvisioning>(request, guid.ToString());
|
||||||
|
|
||||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// return Results.Ok(response);
|
return Results.Ok(response);
|
||||||
return Results.Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("SecOCKey/SupplierKeyProvisioning")]
|
[HttpPut("SecOCKey/SupplierKeyProvisioning")]
|
||||||
@ -140,40 +132,37 @@ namespace WebApi.Project.ProxyKMS.Controllers
|
|||||||
Guid guid = Guid.NewGuid();
|
Guid guid = Guid.NewGuid();
|
||||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
|
var response = await _kmsMetaService.PutKms<SecOCKey.Request_SupplierKeyProvisioning_Result, SecOCKey.Response_SupplierKeyProvisioning_Result>(request, guid.ToString());
|
||||||
|
|
||||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// return Results.Ok(response);
|
return Results.Ok(response);
|
||||||
return Results.Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("SecOCKey/SupplierKeySyncValue")]
|
[HttpPost("SecOCKey/SupplierKeySyncValue")]
|
||||||
public async Task<IResult> SecOCKey_SupplierKeySyncValue([FromBody] SecOCKey.Request_SupplierKeyProvisioning request)
|
public async Task<IResult> SecOCKey_SupplierKeySyncValue([FromBody] SecOCKey.Request_SupplierKeySyncValue request)
|
||||||
{
|
{
|
||||||
Guid guid = Guid.NewGuid();
|
Guid guid = Guid.NewGuid();
|
||||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
|
var response = await _kmsMetaService.PostKms<SecOCKey.Request_SupplierKeySyncValue, SecOCKey.Request_SupplierKeySyncValue>(request, guid.ToString());
|
||||||
|
|
||||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// return Results.Ok(response);
|
return Results.Ok(response);
|
||||||
return Results.Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("SecOCKey/SupplierKeySyncValue")]
|
[HttpPut("SecOCKey/SupplierKeySyncValue")]
|
||||||
public async Task<IResult> SecOCKey_SupplierKeySyncValueResult([FromBody] SecOCKey.Request_SupplierKeyProvisioning_Result request)
|
public async Task<IResult> SecOCKey_SupplierKeySyncValueResult([FromBody] SecOCKey.Request_SupplierKeySyncValue_Result request)
|
||||||
{
|
{
|
||||||
Guid guid = Guid.NewGuid();
|
Guid guid = Guid.NewGuid();
|
||||||
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Request][{GetRequestMethod()}:{GetMethodName()}][Client IP:{GetClientIP()}][RequestUrl:{GetRequestUrl()}]::({guid}){Environment.NewLine} {request.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// EcuID.Response_SupplierEcuID response = await _kmsMetaService.SetWbmsMeta(request, guid.ToString());
|
var response = await _kmsMetaService.PutKms<SecOCKey.Request_SupplierKeySyncValue_Result, SecOCKey.Response_SupplierKeySyncValue_Result>(request, guid.ToString());
|
||||||
|
|
||||||
// LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
LogXnet.WriteLine($"[Response]::({guid}){Environment.NewLine} {response.ToJson()}", LogXLabel.CONTROLLER);
|
||||||
|
|
||||||
// return Results.Ok(response);
|
return Results.Ok(response);
|
||||||
return Results.Ok();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,5 +4,20 @@ namespace WebApi.Project.ProxyKMS.Models
|
|||||||
{
|
{
|
||||||
public class ProxyKMSConfig : WebApiConfig
|
public class ProxyKMSConfig : WebApiConfig
|
||||||
{
|
{
|
||||||
|
public List<API> API { get; set; } = new List<API>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class API
|
||||||
|
{
|
||||||
|
public string ApiName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public List<Function> Functions { get; set; } = new List<Function>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Function
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Method { get; set; }
|
||||||
|
public string Url { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ var builder = WebApplication.CreateBuilder(args);
|
|||||||
builder.Services.AddSingleton<ConfigService<ProxyKMSConfig>>();
|
builder.Services.AddSingleton<ConfigService<ProxyKMSConfig>>();
|
||||||
|
|
||||||
//scoped
|
//scoped
|
||||||
|
builder.Services.AddSingleton<HttpService>();
|
||||||
builder.Services.AddSingleton<KmsService>();
|
builder.Services.AddSingleton<KmsService>();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
@ -30,6 +31,7 @@ builder.Services.AddControllers();
|
|||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen();
|
builder.Services.AddSwaggerGen();
|
||||||
builder.Services.AddHttpContextAccessor();
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
|
||||||
//config preload, auth set
|
//config preload, auth set
|
||||||
ConfigService<ProxyKMSConfig> preloadConfig = new ConfigService<ProxyKMSConfig>();
|
ConfigService<ProxyKMSConfig> preloadConfig = new ConfigService<ProxyKMSConfig>();
|
||||||
|
|||||||
@ -1,6 +1,55 @@
|
|||||||
namespace WebApi.Project.ProxyKMS.Services
|
using System;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using SystemX.Core.DB;
|
||||||
|
using SystemX.Core.Services;
|
||||||
|
using WebApi.Library.Enums;
|
||||||
|
using WebApi.Project.ProxyKMS.Models;
|
||||||
|
|
||||||
|
namespace WebApi.Project.ProxyKMS.Services
|
||||||
{
|
{
|
||||||
public class KmsService
|
public class KmsService : HttpService
|
||||||
{
|
{
|
||||||
|
private readonly IServiceScopeFactory _scopeFactory;
|
||||||
|
private readonly ConfigService<ProxyKMSConfig>? _configService;
|
||||||
|
|
||||||
|
private API KmsApi = new API();
|
||||||
|
|
||||||
|
public KmsService(IServiceProvider serviceProvider, IServiceScopeFactory scopeFactory, ConfigService<ProxyKMSConfig> configSerice)
|
||||||
|
{
|
||||||
|
_scopeFactory = scopeFactory;
|
||||||
|
_configService = configSerice;
|
||||||
|
|
||||||
|
KmsApi = _configService.GetConfig().API.Find(x=>x.ApiName.ToLower() == "kms");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RESPONSE?> PostKms<REQUEST,RESPONSE>(REQUEST request, string guid = "", [CallerMemberName] string memberName = "") where REQUEST : class where RESPONSE : class
|
||||||
|
{
|
||||||
|
RESPONSE? response = default(RESPONSE);
|
||||||
|
|
||||||
|
LogXnet.WriteLine($"KmsService.PostKms::{memberName}", LogXLabel.Debug);
|
||||||
|
|
||||||
|
if (request != null)
|
||||||
|
{
|
||||||
|
var function = KmsApi.Functions.Find(x => x.Name == memberName);
|
||||||
|
response = await PostJsonAsync<REQUEST, RESPONSE>($"{function.Url}", request);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<RESPONSE?> PutKms<REQUEST, RESPONSE>(REQUEST request, string guid = "", [CallerMemberName] string memberName = "") where REQUEST : class where RESPONSE : class
|
||||||
|
{
|
||||||
|
RESPONSE? response = default(RESPONSE);
|
||||||
|
|
||||||
|
LogXnet.WriteLine($"KmsService.PutKms::{memberName}", LogXLabel.Debug);
|
||||||
|
|
||||||
|
if (request != null)
|
||||||
|
{
|
||||||
|
var function = KmsApi.Functions.Find(x => x.Name == memberName);
|
||||||
|
response = await PutJsonAsync<REQUEST, RESPONSE>($"{function.Url}", request);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user