package dao type CountDevice struct { CountNum int `json:"countNum"` DeviceType string `json:"deviceType"` } func GetDeviceCount(tenantId int) ([]CountDevice, error) { var result []CountDevice var count CountDevice Db.Debug().Model(&LampPole{}).Select(" count(*) count_num, 'lamppole' device_type "). Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count) result = append(result, count) Db.Debug().Model(&CameraDevice{}).Select(" count(*) count_num, 'camera' device_type "). Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count) result = append(result, count) Db.Debug().Model(&Gateway{}).Select(" count(*) count_num, 'gateway' device_type "). Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count) result = append(result, count) Db.Debug().Model(&LightControl{}).Select(" count(*) count_num, 'control' device_type "). Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count) result = append(result, count) Db.Debug().Model(&SwitchBox{}).Select(" count(*) count_num, 'box' device_type "). Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count) result = append(result, count) Db.Debug().Model(&InfoBoard{}).Select(" count(*) count_num, 'board' device_type "). Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count) result = append(result, count) Db.Debug().Model(&OptoSensor{}).Select(" count(*) count_num, 'sensor' device_type "). Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count) result = append(result, count) Db.Debug().Model(&Zigbee{}).Select(" count(*) count_num, 'zigbee' device_type "). Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count) result = append(result, count) Db.Debug().Model(&AlarmTerminal{}).Select(" count(*) count_num, 'terminal' device_type "). Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count) result = append(result, count) Db.Debug().Model(&Alarm{}).Select(" count(*) count_num, 'alarmserve' device_type "). Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count) result = append(result, count) Db.Debug().Model(&IpBroadcast{}).Select(" count(*) count_num, 'ipcast' device_type "). Where("tenant_id = ? and is_deleted = 0", tenantId).Scan(&count) result = append(result, count) return result, nil } type CountAlarm struct { LastYearAlarm int `json:"lastYearAlarm"` LastMonthAlarm int `json:"lastMonthAlarm"` Backlog int `json:"backlog"` } func GetAlarmCount(tenantId int) (*CountAlarm, error) { var alarm CountAlarm return &alarm, nil } type CountJobTodo struct { BackJob int `json:"backJob"` LastMonthJob int `json:"lastMonthJob"` LastYearJob int `json:"lastYearJob"` } func GetCountJobTodo(tenantId int) (*CountJobTodo, error) { var todos CountJobTodo return &todos, nil } type Notification struct { Category int `json:"category"` Title string `json:"title"` } func GetNotification(tenantId int) (*Notification, error) { var notification Notification return ¬ification, nil }