From 07c3893132b8d2cec752b4d1cabf55a10aa7e8cb Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Tue, 7 Jul 2026 11:45:28 +0900 Subject: [PATCH] =?UTF-8?q?260707=5F01=5FENH:=20pkey=20=EC=95=94=ED=98=B8?= =?UTF-8?q?=ED=99=94,=20short=20url=20=EC=83=9D=EC=84=B1=EC=97=90=20api?= =?UTF-8?q?=ED=82=A4=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- REPORT_API_ver6/Controllers/SecurityAPI.cs | 19 ++++++++++++++----- REPORT_API_ver6/Controllers/UriAPI.cs | 19 ++++++++++++++++--- REPORT_API_ver6/Enums/SortDirection.cs | 13 +++++++++++++ REPORT_API_ver6/Models/CommonModels.cs | 21 +++++++++++++++++++++ 4 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 REPORT_API_ver6/Enums/SortDirection.cs diff --git a/REPORT_API_ver6/Controllers/SecurityAPI.cs b/REPORT_API_ver6/Controllers/SecurityAPI.cs index 3e62297..98a3d56 100644 --- a/REPORT_API_ver6/Controllers/SecurityAPI.cs +++ b/REPORT_API_ver6/Controllers/SecurityAPI.cs @@ -16,13 +16,22 @@ namespace REPORT_API_ver6.Controllers [Route("pkey")] [HttpGet] - public IActionResult EncryptString([FromHeader] string token, [FromHeader]string pkey, [FromHeader]string iskiwi) + public IActionResult EncryptString + ( + [FromHeader(Name = "token")] string? token, + [FromHeader(Name = "X-API-Key")] string? xApiKey, + [FromHeader]string pkey, + [FromHeader]string iskiwi + ) { HttpContextAccessor hcAccessor = new HttpContextAccessor(); hcAccessor.HttpContext.Response.ContentType = "text/plain"; - - UserInfo userInfo = Security.ValidateToken(token); - if (userInfo != null) + + var configuration = Common.GetConfiguration(); + var value = configuration.GetSection("X-API-Key")[xApiKey ?? ""]; + UserInfo? userInfo = String.IsNullOrEmpty(token)? null : Security.ValidateToken(token); + + if (userInfo != null || !String.IsNullOrEmpty(value)) { Project project = new Project(); if (project.getProjectInfo(pkey, Convert.ToInt32(iskiwi)).Rows.Count > 0) @@ -35,7 +44,7 @@ namespace REPORT_API_ver6.Controllers pkey = "|K|W|" + pkey; } returnString = WebUtility.UrlEncode(security.encryptString(pkey)); - + Response.StatusCode = (int)HttpStatusCode.OK; return Content(returnString); } diff --git a/REPORT_API_ver6/Controllers/UriAPI.cs b/REPORT_API_ver6/Controllers/UriAPI.cs index e1b855a..7f360d8 100644 --- a/REPORT_API_ver6/Controllers/UriAPI.cs +++ b/REPORT_API_ver6/Controllers/UriAPI.cs @@ -18,19 +18,32 @@ namespace REPORT_API_ver6.Controllers [Route("short")] [HttpPost] - public IActionResult ShortURL([FromHeader] string token, [FromBody] ShortURLParam shortURLParam, [FromHeader] string skey) + public IActionResult ShortURL + ( + [FromHeader(Name = "token")] string? token, + [FromHeader(Name = "X-API-Key")] string? xApiKey, + [FromHeader] string skey, + [FromBody] ShortURLParam shortURLParam + ) { HttpContextAccessor hcAccessor = new HttpContextAccessor(); hcAccessor.HttpContext.Response.ContentType = "text/plain"; - UserInfo userInfo = Security.ValidateToken(token); - if (userInfo != null) + var configuration = Common.GetConfiguration(); + var value = configuration.GetSection("X-API-Key")[xApiKey ?? ""]; + UserInfo? userInfo = String.IsNullOrEmpty(token)? null : Security.ValidateToken(token); + + if (userInfo != null || !String.IsNullOrEmpty(value)) { string okey = "REPORT"; if(userInfo.ID == "KON" || userInfo.ID == "KIWI" || userInfo.ID == "NEWSSAK") { okey = userInfo.ID; } + else if(!String.IsNullOrEmpty(value)) + { + okey = value; + } PkeyInfo pkeyInfo = new PkeyInfo(skey); Project project = new Project(); diff --git a/REPORT_API_ver6/Enums/SortDirection.cs b/REPORT_API_ver6/Enums/SortDirection.cs new file mode 100644 index 0000000..75e6534 --- /dev/null +++ b/REPORT_API_ver6/Enums/SortDirection.cs @@ -0,0 +1,13 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +[JsonConverter(typeof(StringEnumConverter))] +public enum SortDirection +{ + [EnumMember(Value = "asc")] + Asc, + + [EnumMember(Value = "desc")] + Desc +} \ No newline at end of file diff --git a/REPORT_API_ver6/Models/CommonModels.cs b/REPORT_API_ver6/Models/CommonModels.cs index 6df54f6..bf2f44c 100644 --- a/REPORT_API_ver6/Models/CommonModels.cs +++ b/REPORT_API_ver6/Models/CommonModels.cs @@ -12,4 +12,25 @@ public class DataTabelToExcelSheet SheetName = sheetName; } public DataTabelToExcelSheet() { } +} + +public class PageRequest +{ + public int PageIndex { get; set; } + public int PageSize { get; set; } + public string SortBy {get; set; } = string.Empty; + public SortDirection SortDir { get; set; } +} + +public class PageResponseDto +{ + public List Content { get; set; } = new List(); + public int TotalElements { get; set; } + public int TotalPages { get; set; } + public int PageIndex { get; set; } + public int PageSize { get; set; } + public int NumberOfElements { get; set; } + public bool First { get; set; } + public bool Last { get; set; } + public bool Empty { get; set; } } \ No newline at end of file