【feat】首页面板数据

This commit is contained in:
XM-GO
2023-09-23 16:55:24 +08:00
parent 79314f6f7e
commit d3a7deb66f
10 changed files with 393 additions and 2 deletions

View File

@@ -24,10 +24,25 @@ import (
type DeviceApi struct {
DeviceApp services.DeviceModel
DeviceAlarmApp services.DeviceAlarmModel
ProductApp services.ProductModel
ProductTemplateApp services.ProductTemplateModel
}
func (p *DeviceApi) GetDevicePanel(rc *restfulx.ReqCtx) {
get, err := global.Cache.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
}
// GetDeviceList Device列表数据
func (p *DeviceApi) GetDeviceList(rc *restfulx.ReqCtx) {
data := entity.Device{}