修改 Bootstrap 注入 Gateway Client 依赖到 IotCardHandler 和 DeviceHandler
This commit is contained in:
@@ -30,9 +30,9 @@ func initHandlers(svc *services, deps *Dependencies) *Handlers {
|
||||
EnterpriseDeviceH5: h5.NewEnterpriseDeviceHandler(svc.EnterpriseDevice),
|
||||
Authorization: admin.NewAuthorizationHandler(svc.Authorization),
|
||||
MyCommission: admin.NewMyCommissionHandler(svc.MyCommission),
|
||||
IotCard: admin.NewIotCardHandler(svc.IotCard),
|
||||
IotCard: admin.NewIotCardHandler(svc.IotCard, deps.GatewayClient),
|
||||
IotCardImport: admin.NewIotCardImportHandler(svc.IotCardImport),
|
||||
Device: admin.NewDeviceHandler(svc.Device),
|
||||
Device: admin.NewDeviceHandler(svc.Device, deps.GatewayClient),
|
||||
DeviceImport: admin.NewDeviceImportHandler(svc.DeviceImport),
|
||||
AssetAllocationRecord: admin.NewAssetAllocationRecordHandler(svc.AssetAllocationRecord),
|
||||
Storage: admin.NewStorageHandler(deps.StorageService),
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/gateway"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
deviceService "github.com/break/junhong_cmp_fiber/internal/service/device"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
@@ -14,12 +15,14 @@ import (
|
||||
)
|
||||
|
||||
type DeviceHandler struct {
|
||||
service *deviceService.Service
|
||||
service *deviceService.Service
|
||||
gatewayClient *gateway.Client
|
||||
}
|
||||
|
||||
func NewDeviceHandler(service *deviceService.Service) *DeviceHandler {
|
||||
func NewDeviceHandler(service *deviceService.Service, gatewayClient *gateway.Client) *DeviceHandler {
|
||||
return &DeviceHandler{
|
||||
service: service,
|
||||
service: service,
|
||||
gatewayClient: gatewayClient,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package admin
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/gateway"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
iotCardService "github.com/break/junhong_cmp_fiber/internal/service/iot_card"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
@@ -12,11 +13,15 @@ import (
|
||||
)
|
||||
|
||||
type IotCardHandler struct {
|
||||
service *iotCardService.Service
|
||||
service *iotCardService.Service
|
||||
gatewayClient *gateway.Client
|
||||
}
|
||||
|
||||
func NewIotCardHandler(service *iotCardService.Service) *IotCardHandler {
|
||||
return &IotCardHandler{service: service}
|
||||
func NewIotCardHandler(service *iotCardService.Service, gatewayClient *gateway.Client) *IotCardHandler {
|
||||
return &IotCardHandler{
|
||||
service: service,
|
||||
gatewayClient: gatewayClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *IotCardHandler) ListStandalone(c *fiber.Ctx) error {
|
||||
|
||||
Reference in New Issue
Block a user