七月迭代短暂完结,还有很多后端的关键东西没有弄,这是一版赶时间做的东西
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m26s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m26s
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/storage"
|
||||
@@ -27,6 +28,12 @@ type DeviceImportPayload struct {
|
||||
TaskID uint `json:"task_id"`
|
||||
}
|
||||
|
||||
// DeviceBatchAllocationExecutor 定义 Worker 复用现有设备分配与系列绑定规则的最小接口。
|
||||
type DeviceBatchAllocationExecutor interface {
|
||||
AllocateDevices(ctx context.Context, req *dto.AllocateDevicesRequest, operatorID uint, operatorShopID *uint) (*dto.AllocateDevicesResponse, error)
|
||||
BatchSetSeriesBinding(ctx context.Context, req *dto.BatchSetDeviceSeriesBindngRequest, operatorShopID *uint) (*dto.BatchSetDeviceSeriesBindngResponse, error)
|
||||
}
|
||||
|
||||
type DeviceImportHandler struct {
|
||||
db *gorm.DB
|
||||
redis *redis.Client
|
||||
@@ -38,6 +45,7 @@ type DeviceImportHandler struct {
|
||||
assetIdentifierStore *postgres.AssetIdentifierStore
|
||||
storageService *storage.Service
|
||||
logger *zap.Logger
|
||||
allocationExecutor DeviceBatchAllocationExecutor
|
||||
}
|
||||
|
||||
func NewDeviceImportHandler(
|
||||
@@ -51,6 +59,7 @@ func NewDeviceImportHandler(
|
||||
assetIdentifierStore *postgres.AssetIdentifierStore,
|
||||
storageSvc *storage.Service,
|
||||
logger *zap.Logger,
|
||||
allocationExecutor DeviceBatchAllocationExecutor,
|
||||
) *DeviceImportHandler {
|
||||
return &DeviceImportHandler{
|
||||
db: db,
|
||||
@@ -63,6 +72,7 @@ func NewDeviceImportHandler(
|
||||
assetIdentifierStore: assetIdentifierStore,
|
||||
storageService: storageSvc,
|
||||
logger: logger,
|
||||
allocationExecutor: allocationExecutor,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +121,9 @@ func (h *DeviceImportHandler) HandleDeviceImport(ctx context.Context, task *asyn
|
||||
zap.String("task_no", importTask.TaskNo),
|
||||
zap.String("storage_key", importTask.StorageKey),
|
||||
)
|
||||
if importTask.OperationType != "" && importTask.OperationType != constants.DeviceImportOperationCreate {
|
||||
return h.handleDeviceBatchAllocation(ctx, importTask)
|
||||
}
|
||||
|
||||
parseResult, err := h.downloadAndParse(ctx, importTask)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user