mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
[fix]首页面板数据缓存未更新
This commit is contained in:
@@ -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列表数据
|
||||
|
||||
@@ -17,7 +17,7 @@ server:
|
||||
rate:
|
||||
enable: true
|
||||
rate-num: 100
|
||||
db-type: postgresql
|
||||
db-type: mysql
|
||||
# 是否开启数据库表初始化
|
||||
isInitTable: false
|
||||
excel-dir: ./resource/excel/
|
||||
|
||||
8
pkg/cache/panel.go
vendored
8
pkg/cache/panel.go
vendored
@@ -1,8 +0,0 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/cache"
|
||||
"time"
|
||||
)
|
||||
|
||||
var PanelCache = cache.NewTimedCache(cache.NoExpiration, 600*time.Second)
|
||||
Reference in New Issue
Block a user