package service import ( data "iot_manager_service/app/data/service" device "iot_manager_service/app/device/service" "iot_manager_service/app/operation/model" "iot_manager_service/util/common" ) var GarbageService = new(garbageService) type garbageService struct{} func (s *garbageService) GarbageList(tenantId string, ) ([]model.GarbageDetail, *common.Errors) { var result []model.GarbageDetail devices, err := device.GarbageService.GetList(tenantId) if err != nil { return nil, err } for _, d := range devices { garbageData := data.GarbageDataService.Get(d.DeviceIMei) if garbageData != nil { result = append(result, model.GarbageDetail{ DeviceName: d.DeviceName, SensorOnePercentage: garbageData.SensorOnePercentage, SensorTwoPercentage: garbageData.SensorTwoPercentage, Longitude: d.PoleLng, Latitude: d.PoleLat, BatteryPercentage: garbageData.BatteryPercentage, NetworkState: 1, }) } } return result, nil }