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 }