From 745ee1d474b609830841a1d22f0af4ecd67308c3 Mon Sep 17 00:00:00 2001 From: dev01 Date: Fri, 13 Jan 2023 16:06:47 +0800 Subject: [PATCH] =?UTF-8?q?[FrontendWebApi]=20=E5=8F=96=E5=BE=97=E4=B8=8D?= =?UTF-8?q?=E5=8F=AF=E8=A6=963D=E6=A8=A1=E5=9E=8B=E9=A1=9E=E5=9E=8B=20API?= =?UTF-8?q?=20=E5=BB=BA=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/DeviceManageController.cs | 46 +++++++++++++++++++ FrontendWebApi/Models/Device.cs | 10 ++++ 2 files changed, 56 insertions(+) diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index 1f0e2eb..60866ea 100644 --- a/FrontendWebApi/ApiControllers/DeviceManageController.cs +++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs @@ -898,6 +898,52 @@ namespace FrontendWebApi.ApiControllers var param = new { @main_system_tag = fdi.main_system_tag, @sub_system_tag = fdi.sub_system_tag, @points = fdi.points }; var fr = await backendRepository.GetAllAsync(sqlString, param); + apiResult.Code = "0000"; + apiResult.Data = fr; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + return Ok(apiResult); + } + return Ok(apiResult); + } + + /// + /// 取得 Forge 3D 模型不可見的類型 + /// + /// + [HttpPost] + [Route("api/Device/GetForgeInvType")] + public async Task>>> GetForgeInvType([FromBody] string search_tag) + { + ApiResult> apiResult = new ApiResult>(); + + try + { + var sqlString = $@"SELECT + v1.system_key AS 'invisible_type', + v1.system_value AS 'invisible_value', + v2.system_value AS 'sub_system_tag' + FROM variable v1 + LEFT JOIN variable v2 ON v2.id = v1.system_parent_id AND v2.deleted = '0' + WHERE + v1.deleted = '0' + AND v1.system_type = 'forge_3d_invisible_type' + AND ( + (@isDef = true AND v1.system_key = 'default_value') + OR (@isDef = false AND v2.system_value = @sub_system_tag) + OR (@isDef = false AND @sub_system_tag IS NULL AND v1.system_key = 'default_value') + OR (@isDef = false AND @sub_system_tag IS NULL AND v2.system_value = v2.system_value) + )"; + + var param = new { sub_system_tag = search_tag == "forge_default" ? null : search_tag, isDef = search_tag == "forge_default" }; + + var fr = await backendRepository.GetAllAsync(sqlString, param); + + apiResult.Code = "0000"; apiResult.Data = fr; } diff --git a/FrontendWebApi/Models/Device.cs b/FrontendWebApi/Models/Device.cs index 0508d4e..92ba15a 100644 --- a/FrontendWebApi/Models/Device.cs +++ b/FrontendWebApi/Models/Device.cs @@ -164,4 +164,14 @@ namespace FrontendWebApi.Models public string points { get; set; } } + + public class ForgeInvisible + { + public string invisible_type { get; set; } + public string invisible_value { get; set; } + public string sub_system_tag { get; set; } + + } + + }