This commit is contained in:
@@ -17,5 +17,6 @@ type ExportParams struct {
|
|||||||
Filters map[string]any
|
Filters map[string]any
|
||||||
ScopeShopIDs []uint
|
ScopeShopIDs []uint
|
||||||
UserType int
|
UserType int
|
||||||
|
CreatorShopID *uint
|
||||||
ResolvedHeaders []string
|
ResolvedHeaders []string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ func ParseExportParams(task *model.ExportTask) ExportParams {
|
|||||||
|
|
||||||
params.ScopeShopIDs = append(params.ScopeShopIDs, task.ScopeShopIDs...)
|
params.ScopeShopIDs = append(params.ScopeShopIDs, task.ScopeShopIDs...)
|
||||||
params.UserType = task.CreatorUserType
|
params.UserType = task.CreatorUserType
|
||||||
|
params.CreatorShopID = task.CreatorShopID
|
||||||
|
|
||||||
var raw map[string]any
|
var raw map[string]any
|
||||||
if len(task.QueryJSON) == 0 {
|
if len(task.QueryJSON) == 0 {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ func NewDefaultRegistry(db *gorm.DB) *Registry {
|
|||||||
return NewRegistry(
|
return NewRegistry(
|
||||||
NewDeviceDataSource(db),
|
NewDeviceDataSource(db),
|
||||||
NewIotCardDataSource(db),
|
NewIotCardDataSource(db),
|
||||||
|
NewOrderDataSource(db),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ func (r *Registry) Scenes() []string {
|
|||||||
// IsSupportedScene 判断是否为受支持的场景。
|
// IsSupportedScene 判断是否为受支持的场景。
|
||||||
func IsSupportedScene(scene string) bool {
|
func IsSupportedScene(scene string) bool {
|
||||||
switch scene {
|
switch scene {
|
||||||
case constants.ExportTaskSceneDevice, constants.ExportTaskSceneIotCard:
|
case constants.ExportTaskSceneDevice, constants.ExportTaskSceneIotCard, constants.ExportTaskSceneOrder:
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import "time"
|
|||||||
|
|
||||||
// CreateExportTaskRequest 创建导出任务请求。
|
// CreateExportTaskRequest 创建导出任务请求。
|
||||||
type CreateExportTaskRequest struct {
|
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)"`
|
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对象,可选)"`
|
Query map[string]interface{} `json:"query,omitempty" description:"导出筛选参数(JSON对象,可选)"`
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ type CreateExportTaskResponse struct {
|
|||||||
type ListExportTaskRequest struct {
|
type ListExportTaskRequest struct {
|
||||||
Page int `json:"page" query:"page" validate:"omitempty,min=1" minimum:"1" description:"页码"`
|
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:"每页数量"`
|
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:已取消)"`
|
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:"创建时间起始"`
|
StartTime *time.Time `json:"start_time" query:"start_time" description:"创建时间起始"`
|
||||||
EndTime *time.Time `json:"end_time" query:"end_time" description:"创建时间结束"`
|
EndTime *time.Time `json:"end_time" query:"end_time" description:"创建时间结束"`
|
||||||
@@ -32,7 +32,7 @@ type ListExportTaskRequest struct {
|
|||||||
type ExportTaskItem struct {
|
type ExportTaskItem struct {
|
||||||
ID uint `json:"id" description:"任务ID"`
|
ID uint `json:"id" description:"任务ID"`
|
||||||
TaskNo string `json:"task_no" description:"任务编号"`
|
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)"`
|
Format string `json:"format" description:"导出格式 (xlsx:Excel, csv:CSV)"`
|
||||||
Status int `json:"status" description:"任务状态 (1:待处理, 2:处理中, 3:已完成, 4:已失败, 5:已取消)"`
|
Status int `json:"status" description:"任务状态 (1:待处理, 2:处理中, 3:已完成, 4:已失败, 5:已取消)"`
|
||||||
StatusName string `json:"status_name" description:"任务状态名称(中文)"`
|
StatusName string `json:"status_name" description:"任务状态名称(中文)"`
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ func registerExportTaskRoutes(router fiber.Router, handler *admin.ExportTaskHand
|
|||||||
|
|
||||||
Register(exportTasks, doc, groupPath, "POST", "", handler.Create, RouteSpec{
|
Register(exportTasks, doc, groupPath, "POST", "", handler.Create, RouteSpec{
|
||||||
Summary: "创建导出任务",
|
Summary: "创建导出任务",
|
||||||
Description: "创建统一导出任务,支持场景 scene=device/iot_card 和格式 format=xlsx/csv。",
|
Description: "创建统一导出任务,支持场景 scene=device/iot_card/order 和格式 format=xlsx/csv。",
|
||||||
Tags: []string{"导出任务"},
|
Tags: []string{"导出任务"},
|
||||||
Input: new(dto.CreateExportTaskRequest),
|
Input: new(dto.CreateExportTaskRequest),
|
||||||
Output: new(dto.CreateExportTaskResponse),
|
Output: new(dto.CreateExportTaskResponse),
|
||||||
|
|||||||
@@ -295,6 +295,7 @@ func DefaultTaskQueueWeights() map[string]int {
|
|||||||
const (
|
const (
|
||||||
ExportTaskSceneDevice = "device" // 导出场景:设备
|
ExportTaskSceneDevice = "device" // 导出场景:设备
|
||||||
ExportTaskSceneIotCard = "iot_card" // 导出场景:IoT 卡
|
ExportTaskSceneIotCard = "iot_card" // 导出场景:IoT 卡
|
||||||
|
ExportTaskSceneOrder = "order" // 导出场景:订单
|
||||||
)
|
)
|
||||||
|
|
||||||
// 导出文件格式常量
|
// 导出文件格式常量
|
||||||
|
|||||||
Reference in New Issue
Block a user