From ec0457d7d3f4836c93cd26e620251aba4b08db6f Mon Sep 17 00:00:00 2001 From: PandaX <18610165312@163.com> Date: Tue, 21 Nov 2023 08:46:35 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=E9=A6=96=E9=A1=B5=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BC=93=E5=AD=98=E6=9C=AA=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/device/api/device.go | 19 +++++++------------ config.yml | 2 +- pkg/cache/panel.go | 8 -------- 3 files changed, 8 insertions(+), 21 deletions(-) delete mode 100644 pkg/cache/panel.go diff --git a/apps/device/api/device.go b/apps/device/api/device.go index b5b5977..7d28d61 100644 --- a/apps/device/api/device.go +++ b/apps/device/api/device.go @@ -11,7 +11,6 @@ import ( "github.com/PandaXGO/PandaKit/model" "github.com/PandaXGO/PandaKit/restfulx" "pandax/apps/device/util" - "pandax/pkg/cache" "pandax/pkg/global" model2 "pandax/pkg/global/model" "pandax/pkg/shadow" @@ -30,17 +29,13 @@ type DeviceApi struct { } func (p *DeviceApi) GetDevicePanel(rc *restfulx.ReqCtx) { - get, err := cache.PanelCache.ComputeIfAbsent("panel", func(k any) (any, error) { - var data entity.DeviceTotalOutput - data.DeviceInfo = p.DeviceApp.FindDeviceCount() - data.DeviceLinkStatusInfo = p.DeviceApp.FindDeviceCountGroupByLinkStatus() - data.DeviceCountType = p.DeviceApp.FindDeviceCountGroupByType() - data.AlarmInfo = p.DeviceAlarmApp.FindAlarmCount() - data.ProductInfo = p.ProductApp.FindProductCount() - return data, nil - }) - biz.ErrIsNil(err, "获取面板数据失败") - rc.ResData = get + var data entity.DeviceTotalOutput + data.DeviceInfo = p.DeviceApp.FindDeviceCount() + data.DeviceLinkStatusInfo = p.DeviceApp.FindDeviceCountGroupByLinkStatus() + data.DeviceCountType = p.DeviceApp.FindDeviceCountGroupByType() + data.AlarmInfo = p.DeviceAlarmApp.FindAlarmCount() + data.ProductInfo = p.ProductApp.FindProductCount() + rc.ResData = data } // GetDeviceList Device列表数据 diff --git a/config.yml b/config.yml index 60a0172..4642600 100644 --- a/config.yml +++ b/config.yml @@ -17,7 +17,7 @@ server: rate: enable: true rate-num: 100 - db-type: postgresql + db-type: mysql # 是否开启数据库表初始化 isInitTable: false excel-dir: ./resource/excel/ diff --git a/pkg/cache/panel.go b/pkg/cache/panel.go deleted file mode 100644 index 0302cf4..0000000 --- a/pkg/cache/panel.go +++ /dev/null @@ -1,8 +0,0 @@ -package cache - -import ( - "github.com/PandaXGO/PandaKit/cache" - "time" -) - -var PanelCache = cache.NewTimedCache(cache.NoExpiration, 600*time.Second)