fix: resolve 接口 series_name 永远为空,asset service 注入套餐系列 store
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m58s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m58s
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -148,7 +148,7 @@ func initServices(s *stores, deps *Dependencies) *services {
|
||||
PollingAlert: pollingSvc.NewAlertService(s.PollingAlertRule, s.PollingAlertHistory, deps.Redis, deps.Logger),
|
||||
PollingCleanup: pollingSvc.NewCleanupService(s.DataCleanupConfig, s.DataCleanupLog, deps.Logger),
|
||||
PollingManualTrigger: pollingSvc.NewManualTriggerService(s.PollingManualTriggerLog, s.IotCard, deps.Redis, deps.Logger),
|
||||
Asset: assetSvc.New(deps.DB, s.Device, s.IotCard, s.PackageUsage, s.Package, s.DeviceSimBinding, s.Shop, deps.Redis, iotCard),
|
||||
Asset: assetSvc.New(deps.DB, s.Device, s.IotCard, s.PackageUsage, s.Package, s.PackageSeries, s.DeviceSimBinding, s.Shop, deps.Redis, iotCard),
|
||||
StopResumeService: iotCardSvc.NewStopResumeService(deps.DB, deps.Redis, s.IotCard, s.DeviceSimBinding, deps.GatewayClient, deps.Logger),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ type Service struct {
|
||||
iotCardStore *postgres.IotCardStore
|
||||
packageUsageStore *postgres.PackageUsageStore
|
||||
packageStore *postgres.PackageStore
|
||||
packageSeriesStore *postgres.PackageSeriesStore
|
||||
deviceSimBindingStore *postgres.DeviceSimBindingStore
|
||||
shopStore *postgres.ShopStore
|
||||
redis *redis.Client
|
||||
@@ -44,6 +45,7 @@ func New(
|
||||
iotCardStore *postgres.IotCardStore,
|
||||
packageUsageStore *postgres.PackageUsageStore,
|
||||
packageStore *postgres.PackageStore,
|
||||
packageSeriesStore *postgres.PackageSeriesStore,
|
||||
deviceSimBindingStore *postgres.DeviceSimBindingStore,
|
||||
shopStore *postgres.ShopStore,
|
||||
redisClient *redis.Client,
|
||||
@@ -55,6 +57,7 @@ func New(
|
||||
iotCardStore: iotCardStore,
|
||||
packageUsageStore: packageUsageStore,
|
||||
packageStore: packageStore,
|
||||
packageSeriesStore: packageSeriesStore,
|
||||
deviceSimBindingStore: deviceSimBindingStore,
|
||||
shopStore: shopStore,
|
||||
redis: redisClient,
|
||||
@@ -136,6 +139,9 @@ func (s *Service) buildDeviceResolveResponse(ctx context.Context, device *model.
|
||||
// 查 shop 名称
|
||||
s.fillShopName(ctx, resp)
|
||||
|
||||
// 查套餐系列名称
|
||||
s.fillSeriesName(ctx, resp)
|
||||
|
||||
// 查 Redis 保护期
|
||||
resp.DeviceProtectStatus = s.getDeviceProtectStatus(ctx, device.ID)
|
||||
|
||||
@@ -188,6 +194,9 @@ func (s *Service) buildCardResolveResponse(ctx context.Context, card *model.IotC
|
||||
// 查 shop 名称
|
||||
s.fillShopName(ctx, resp)
|
||||
|
||||
// 查套餐系列名称
|
||||
s.fillSeriesName(ctx, resp)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -221,6 +230,17 @@ func (s *Service) fillShopName(ctx context.Context, resp *dto.AssetResolveRespon
|
||||
}
|
||||
}
|
||||
|
||||
// fillSeriesName 填充套餐系列名称
|
||||
func (s *Service) fillSeriesName(ctx context.Context, resp *dto.AssetResolveResponse) {
|
||||
if resp.SeriesID == nil || *resp.SeriesID == 0 {
|
||||
return
|
||||
}
|
||||
series, err := s.packageSeriesStore.GetByID(ctx, *resp.SeriesID)
|
||||
if err == nil && series != nil {
|
||||
resp.SeriesName = series.SeriesName
|
||||
}
|
||||
}
|
||||
|
||||
// GetRealtimeStatus 获取资产实时状态(只读DB/Redis)
|
||||
func (s *Service) GetRealtimeStatus(ctx context.Context, assetType string, id uint) (*dto.AssetRealtimeStatusResponse, error) {
|
||||
resp := &dto.AssetRealtimeStatusResponse{
|
||||
|
||||
Reference in New Issue
Block a user