From 52642c4d3845443abc1dc5f3827948a52d6104a9 Mon Sep 17 00:00:00 2001 From: GiteaAdmin Date: Tue, 28 Mar 2023 15:07:18 +0800 Subject: [PATCH] =?UTF-8?q?front=20API=20debug=20:=20=20input=20user=20?= =?UTF-8?q?=E6=89=80=E9=81=B8=E6=A8=93=E5=B1=A4=EF=BC=8C=E5=9B=9E=E5=82=B3?= =?UTF-8?q?=E6=A8=93=E4=B8=8A=E9=82=A3=E5=B1=A4=EF=BC=8C=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=98=AF=E9=A0=82=E6=A8=93=20=E5=89=87=E5=9B=9E=E8=87=AA?= =?UTF-8?q?=E5=B7=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/DeviceManageController.cs | 26 ++++++++++++++++--- FrontendWebApi/Models/Build.cs | 2 ++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/FrontendWebApi/ApiControllers/DeviceManageController.cs b/FrontendWebApi/ApiControllers/DeviceManageController.cs index 9ea8cdb..60ee4c7 100644 --- a/FrontendWebApi/ApiControllers/DeviceManageController.cs +++ b/FrontendWebApi/ApiControllers/DeviceManageController.cs @@ -910,7 +910,7 @@ namespace FrontendWebApi.ApiControllers } /// - /// 樓層列表 + /// input user 所選樓層,回傳樓上那層,如果是頂樓 則回自己 /// /// /// @@ -934,8 +934,28 @@ namespace FrontendWebApi.ApiControllers // AND building_tag = (SELECT building_tag FROM floor WHERE floor_guid = @floor_guid)) // AND building_tag = (SELECT building_tag FROM floor WHERE floor_guid = @floor_guid)"; - var sqlString = $@" SELECT * FROM floor WHERE floor_guid = @floor_guid;"; - var param = new { @floor_guid = f.floor_guid }; + //找出同一棟 User 所選的上一樓(要拿掉天花板),如已經是頂樓則回傳自己 + var sqlString = $@"select * from + ( + SELECT * FROM floor -- 下一樓 + where building_tag = @building_tag and priority > ( + select priority from floor + where building_tag = @building_tag and floor_guid = @floor_guid + ) + order by priority limit 1 + )a + union + select * from + ( + SELECT * FROM floor -- 如果是頂樓則回傳自己 + where building_tag = @building_tag and priority >= ( + select priority from floor + where building_tag = @building_tag and floor_guid = @floor_guid + ) + order by priority limit 1 + )b + order by priority desc limit 1 "; + var param = new { @building_tag = f.building_tag, @floor_guid = f.floor_guid }; var fr = await backendRepository.GetOneAsync(sqlString, param); apiResult.Code = "0000"; diff --git a/FrontendWebApi/Models/Build.cs b/FrontendWebApi/Models/Build.cs index 3e87117..88e80f5 100644 --- a/FrontendWebApi/Models/Build.cs +++ b/FrontendWebApi/Models/Build.cs @@ -115,6 +115,8 @@ namespace FrontendWebApi.Models public class Floor { public string floor_guid { get; set; } + + public string building_tag { get; set; } public string full_name { get; set; } public string InitMapName { get; set; } public string Floor_map_name { get; set; }