feat(03.1-01): 修复静态 DTO 映射缺口
- toDeviceResponse() 补全 5 个 DB 缓存字段(OnlineStatus/LastOnlineTime/SoftwareVersion/SwitchMode/LastGatewaySyncAt) - ListBindings() 补全 IsCurrent 字段映射 - buildDeviceResolveResponse() 补全 isCurrentMap + BoundCardInfo.IsCurrent + 5 个 DB 缓存字段 - GetRealtimeStatus() device case 补全 isCurrentMap + BoundCardInfo.IsCurrent
This commit is contained in:
@@ -114,6 +114,11 @@ func (s *Service) buildDeviceResolveResponse(ctx context.Context, device *model.
|
|||||||
DeviceType: device.DeviceType,
|
DeviceType: device.DeviceType,
|
||||||
MaxSimSlots: device.MaxSimSlots,
|
MaxSimSlots: device.MaxSimSlots,
|
||||||
Manufacturer: device.Manufacturer,
|
Manufacturer: device.Manufacturer,
|
||||||
|
OnlineStatus: device.OnlineStatus,
|
||||||
|
LastOnlineTime: device.LastOnlineTime,
|
||||||
|
SoftwareVersion: device.SoftwareVersion,
|
||||||
|
SwitchMode: device.SwitchMode,
|
||||||
|
LastGatewaySyncAt: device.LastGatewaySyncAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查绑定卡
|
// 查绑定卡
|
||||||
@@ -122,9 +127,11 @@ func (s *Service) buildDeviceResolveResponse(ctx context.Context, device *model.
|
|||||||
resp.BoundCardCount = len(bindings)
|
resp.BoundCardCount = len(bindings)
|
||||||
cardIDs := make([]uint, 0, len(bindings))
|
cardIDs := make([]uint, 0, len(bindings))
|
||||||
slotMap := make(map[uint]int, len(bindings))
|
slotMap := make(map[uint]int, len(bindings))
|
||||||
|
isCurrentMap := make(map[uint]bool, len(bindings))
|
||||||
for _, b := range bindings {
|
for _, b := range bindings {
|
||||||
cardIDs = append(cardIDs, b.IotCardID)
|
cardIDs = append(cardIDs, b.IotCardID)
|
||||||
slotMap[b.IotCardID] = b.SlotPosition
|
slotMap[b.IotCardID] = b.SlotPosition
|
||||||
|
isCurrentMap[b.IotCardID] = b.IsCurrent
|
||||||
}
|
}
|
||||||
cards, _ := s.iotCardStore.GetByIDs(ctx, cardIDs)
|
cards, _ := s.iotCardStore.GetByIDs(ctx, cardIDs)
|
||||||
for _, c := range cards {
|
for _, c := range cards {
|
||||||
@@ -135,6 +142,7 @@ func (s *Service) buildDeviceResolveResponse(ctx context.Context, device *model.
|
|||||||
NetworkStatus: c.NetworkStatus,
|
NetworkStatus: c.NetworkStatus,
|
||||||
RealNameStatus: c.RealNameStatus,
|
RealNameStatus: c.RealNameStatus,
|
||||||
SlotPosition: slotMap[c.ID],
|
SlotPosition: slotMap[c.ID],
|
||||||
|
IsCurrent: isCurrentMap[c.ID],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -271,9 +279,11 @@ func (s *Service) GetRealtimeStatus(ctx context.Context, assetType string, id ui
|
|||||||
if err == nil && len(bindings) > 0 {
|
if err == nil && len(bindings) > 0 {
|
||||||
cardIDs := make([]uint, 0, len(bindings))
|
cardIDs := make([]uint, 0, len(bindings))
|
||||||
slotMap := make(map[uint]int, len(bindings))
|
slotMap := make(map[uint]int, len(bindings))
|
||||||
|
isCurrentMap := make(map[uint]bool, len(bindings))
|
||||||
for _, b := range bindings {
|
for _, b := range bindings {
|
||||||
cardIDs = append(cardIDs, b.IotCardID)
|
cardIDs = append(cardIDs, b.IotCardID)
|
||||||
slotMap[b.IotCardID] = b.SlotPosition
|
slotMap[b.IotCardID] = b.SlotPosition
|
||||||
|
isCurrentMap[b.IotCardID] = b.IsCurrent
|
||||||
}
|
}
|
||||||
cards, _ := s.iotCardStore.GetByIDs(ctx, cardIDs)
|
cards, _ := s.iotCardStore.GetByIDs(ctx, cardIDs)
|
||||||
for _, c := range cards {
|
for _, c := range cards {
|
||||||
@@ -284,6 +294,7 @@ func (s *Service) GetRealtimeStatus(ctx context.Context, assetType string, id ui
|
|||||||
NetworkStatus: c.NetworkStatus,
|
NetworkStatus: c.NetworkStatus,
|
||||||
RealNameStatus: c.RealNameStatus,
|
RealNameStatus: c.RealNameStatus,
|
||||||
SlotPosition: slotMap[c.ID],
|
SlotPosition: slotMap[c.ID],
|
||||||
|
IsCurrent: isCurrentMap[c.ID],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ func (s *Service) ListBindings(ctx context.Context, deviceID uint) (*dto.ListDev
|
|||||||
CarrierName: card.CarrierName, // 直接使用 IotCard 的冗余字段
|
CarrierName: card.CarrierName, // 直接使用 IotCard 的冗余字段
|
||||||
Status: card.Status,
|
Status: card.Status,
|
||||||
BindTime: binding.BindTime,
|
BindTime: binding.BindTime,
|
||||||
|
IsCurrent: binding.IsCurrent,
|
||||||
}
|
}
|
||||||
responses = append(responses, resp)
|
responses = append(responses, resp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -556,6 +556,11 @@ func (s *Service) toDeviceResponse(device *model.Device, shopMap map[uint]string
|
|||||||
ActivatedAt: device.ActivatedAt,
|
ActivatedAt: device.ActivatedAt,
|
||||||
CreatedAt: device.CreatedAt,
|
CreatedAt: device.CreatedAt,
|
||||||
UpdatedAt: device.UpdatedAt,
|
UpdatedAt: device.UpdatedAt,
|
||||||
|
OnlineStatus: device.OnlineStatus,
|
||||||
|
LastOnlineTime: device.LastOnlineTime,
|
||||||
|
SoftwareVersion: device.SoftwareVersion,
|
||||||
|
SwitchMode: device.SwitchMode,
|
||||||
|
LastGatewaySyncAt: device.LastGatewaySyncAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
if device.ShopID != nil && *device.ShopID > 0 {
|
if device.ShopID != nil && *device.ShopID > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user