From 84ab3bad99ee2b7ffaa5808b0f409c19ed72ab7a Mon Sep 17 00:00:00 2001 From: Break Date: Tue, 16 Jun 2026 09:38:20 +0800 Subject: [PATCH] =?UTF-8?q?order=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/exporter/datasource.go | 1 + internal/exporter/query_params.go | 1 + internal/exporter/registry.go | 3 ++- internal/model/dto/export_task_dto.go | 6 +++--- internal/routes/export_task.go | 2 +- pkg/constants/constants.go | 1 + 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/exporter/datasource.go b/internal/exporter/datasource.go index a57e7c7..8e87a5b 100644 --- a/internal/exporter/datasource.go +++ b/internal/exporter/datasource.go @@ -17,5 +17,6 @@ type ExportParams struct { Filters map[string]any ScopeShopIDs []uint UserType int + CreatorShopID *uint ResolvedHeaders []string } diff --git a/internal/exporter/query_params.go b/internal/exporter/query_params.go index f9d4c59..a3498a0 100644 --- a/internal/exporter/query_params.go +++ b/internal/exporter/query_params.go @@ -15,6 +15,7 @@ func ParseExportParams(task *model.ExportTask) ExportParams { params.ScopeShopIDs = append(params.ScopeShopIDs, task.ScopeShopIDs...) params.UserType = task.CreatorUserType + params.CreatorShopID = task.CreatorShopID var raw map[string]any if len(task.QueryJSON) == 0 { diff --git a/internal/exporter/registry.go b/internal/exporter/registry.go index 491b2d6..a736f6f 100644 --- a/internal/exporter/registry.go +++ b/internal/exporter/registry.go @@ -30,6 +30,7 @@ func NewDefaultRegistry(db *gorm.DB) *Registry { return NewRegistry( NewDeviceDataSource(db), NewIotCardDataSource(db), + NewOrderDataSource(db), ) } @@ -58,7 +59,7 @@ func (r *Registry) Scenes() []string { // IsSupportedScene 判断是否为受支持的场景。 func IsSupportedScene(scene string) bool { switch scene { - case constants.ExportTaskSceneDevice, constants.ExportTaskSceneIotCard: + case constants.ExportTaskSceneDevice, constants.ExportTaskSceneIotCard, constants.ExportTaskSceneOrder: return true default: return false diff --git a/internal/model/dto/export_task_dto.go b/internal/model/dto/export_task_dto.go index 781aa82..836370a 100644 --- a/internal/model/dto/export_task_dto.go +++ b/internal/model/dto/export_task_dto.go @@ -4,7 +4,7 @@ import "time" // CreateExportTaskRequest 创建导出任务请求。 type CreateExportTaskRequest struct { - Scene string `json:"scene" validate:"required,oneof=device iot_card" required:"true" description:"导出场景 (device:设备, iot_card:IoT卡)"` + Scene string `json:"scene" validate:"required,oneof=device iot_card order" required:"true" description:"导出场景 (device:设备, iot_card:IoT卡, order:订单)"` Format string `json:"format" validate:"required,oneof=xlsx csv" required:"true" description:"导出格式 (xlsx:Excel, csv:CSV)"` Query map[string]interface{} `json:"query,omitempty" description:"导出筛选参数(JSON对象,可选)"` } @@ -22,7 +22,7 @@ type CreateExportTaskResponse struct { type ListExportTaskRequest struct { Page int `json:"page" query:"page" validate:"omitempty,min=1" minimum:"1" description:"页码"` PageSize int `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=100" minimum:"1" maximum:"100" description:"每页数量"` - Scene string `json:"scene" query:"scene" validate:"omitempty,oneof=device iot_card" description:"导出场景 (device:设备, iot_card:IoT卡)"` + Scene string `json:"scene" query:"scene" validate:"omitempty,oneof=device iot_card order" description:"导出场景 (device:设备, iot_card:IoT卡, order:订单)"` Status *int `json:"status" query:"status" validate:"omitempty,min=1,max=5" minimum:"1" maximum:"5" description:"任务状态 (1:待处理, 2:处理中, 3:已完成, 4:已失败, 5:已取消)"` StartTime *time.Time `json:"start_time" query:"start_time" description:"创建时间起始"` EndTime *time.Time `json:"end_time" query:"end_time" description:"创建时间结束"` @@ -32,7 +32,7 @@ type ListExportTaskRequest struct { type ExportTaskItem struct { ID uint `json:"id" description:"任务ID"` TaskNo string `json:"task_no" description:"任务编号"` - Scene string `json:"scene" description:"导出场景 (device:设备, iot_card:IoT卡)"` + Scene string `json:"scene" description:"导出场景 (device:设备, iot_card:IoT卡, order:订单)"` Format string `json:"format" description:"导出格式 (xlsx:Excel, csv:CSV)"` Status int `json:"status" description:"任务状态 (1:待处理, 2:处理中, 3:已完成, 4:已失败, 5:已取消)"` StatusName string `json:"status_name" description:"任务状态名称(中文)"` diff --git a/internal/routes/export_task.go b/internal/routes/export_task.go index bbd52b1..c74a45a 100644 --- a/internal/routes/export_task.go +++ b/internal/routes/export_task.go @@ -14,7 +14,7 @@ func registerExportTaskRoutes(router fiber.Router, handler *admin.ExportTaskHand Register(exportTasks, doc, groupPath, "POST", "", handler.Create, RouteSpec{ Summary: "创建导出任务", - Description: "创建统一导出任务,支持场景 scene=device/iot_card 和格式 format=xlsx/csv。", + Description: "创建统一导出任务,支持场景 scene=device/iot_card/order 和格式 format=xlsx/csv。", Tags: []string{"导出任务"}, Input: new(dto.CreateExportTaskRequest), Output: new(dto.CreateExportTaskResponse), diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 9cd9f9c..0263bcb 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -295,6 +295,7 @@ func DefaultTaskQueueWeights() map[string]int { const ( ExportTaskSceneDevice = "device" // 导出场景:设备 ExportTaskSceneIotCard = "iot_card" // 导出场景:IoT 卡 + ExportTaskSceneOrder = "order" // 导出场景:订单 ) // 导出文件格式常量