Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions api/dms/service/v1/data_export_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ type FilterGlobalDataExportWorkflowReq struct {
// db_service UIDs with view_others_workflow permission for check_user_can_access
// in:query
ViewableDBServiceUids []string `json:"viewable_db_service_uids" query:"viewable_db_service_uids"`
// filter create time from
// in:query
FilterCreateTimeFrom string `json:"filter_create_time_from" query:"filter_create_time_from"`
// filter create time to
// in:query
FilterCreateTimeTo string `json:"filter_create_time_to" query:"filter_create_time_to"`
// filter update time from
// in:query
FilterUpdateTimeFrom string `json:"filter_update_time_from" query:"filter_update_time_from"`
// filter update time to
// in:query
FilterUpdateTimeTo string `json:"filter_update_time_to" query:"filter_update_time_to"`
}

// swagger:model GetGlobalDataExportWorkflowsReply
Expand All @@ -142,6 +154,7 @@ type GlobalDataExportWorkflow struct {
Description string `json:"desc"` // 数据导出工单的描述
Creater UidWithName `json:"creater"` // 数据导出工单的创建人
CreatedAt time.Time `json:"created_at"` // 数据导出工单的创建时间
UpdatedAt time.Time `json:"updated_at"` // 数据导出工单的更新时间
Status DataExportWorkflowStatus `json:"status"` // 数据导出工单的状态

CurrentStepAssigneeUsers []UidWithName `json:"current_step_assignee_user_list"` // 工单待操作人
Expand Down
5 changes: 5 additions & 0 deletions api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -12433,6 +12433,11 @@
"x-go-enum-desc": "wait_for_approve DataExportWorkflowStatusWaitForApprove\nwait_for_export DataExportWorkflowStatusWaitForExport\nexporting DataExportWorkflowStatusWaitForExporting\nrejected DataExportWorkflowStatusRejected\ncancel DataExportWorkflowStatusCancel\nfailed DataExportWorkflowStatusFailed\nfinish DataExportWorkflowStatusFinish",
"x-go-name": "Status"
},
"updated_at": {
"type": "string",
"format": "date-time",
"x-go-name": "UpdatedAt"
},
"workflow_name": {
"type": "string",
"x-go-name": "WorkflowName"
Expand Down
4 changes: 4 additions & 0 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3144,6 +3144,10 @@ definitions:
failed DataExportWorkflowStatusFailed
finish DataExportWorkflowStatusFinish
x-go-name: Status
updated_at:
format: date-time
type: string
x-go-name: UpdatedAt
workflow_name:
type: string
x-go-name: WorkflowName
Expand Down
1 change: 1 addition & 0 deletions internal/dms/biz/data_export_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ type WorkflowRecord struct {
CurrentWorkflowStepId uint64
CurrentStep *WorkflowStep
WorkflowSteps []*WorkflowStep
UpdateTime time.Time
}

type WorkflowStep struct {
Expand Down
1 change: 1 addition & 0 deletions internal/dms/service/data_export_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func (d *DMSService) GetGlobalWorkflowsList(ctx context.Context, req *dmsV1.Filt
WorkflowName: w.Name,
Description: w.Desc,
CreatedAt: w.CreatedAt,
UpdatedAt: w.WorkflowRecord.UpdateTime,
Status: dmsV1.DataExportWorkflowStatus(w.WorkflowRecord.Status),
DBServiceInfos: w.DBServiceInfos,
}
Expand Down
19 changes: 18 additions & 1 deletion internal/dms/storage/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ SELECT
wr.current_workflow_step_id AS current_workflow_step_id,
wr.uid AS workflow_record_uid,
t.db_service_uid AS db_service_uid,
ds.name AS db_service_name
ds.name AS db_service_name,
wr.updated_at AS update_time
{{- template "body" . -}}

ORDER BY wr.updated_at DESC
Expand Down Expand Up @@ -491,7 +492,21 @@ AND w.project_uid IN (:filter_project_uids)
AND (w.name like :fuzzy_keyword or w.uid like :fuzzy_keyword or w.desc like :fuzzy_keyword)
{{- end }}

{{- if .filter_create_time_from }}
AND w.created_at >= :filter_create_time_from
{{- end }}

{{- if .filter_create_time_to }}
AND w.created_at <= :filter_create_time_to
{{- end }}

{{- if .filter_update_time_from }}
AND wr.updated_at >= :filter_update_time_from
{{- end }}

{{- if .filter_update_time_to }}
AND wr.updated_at <= :filter_update_time_to
{{- end }}

{{ end }}

Expand All @@ -508,6 +523,7 @@ func (d *WorkflowRepo) GetGlobalWorkflowsByParameterMap(ctx context.Context, dat
CreateUserUID string `gorm:"column:create_user_uid"`
CreateUserDeletedAt *time.Time `gorm:"column:create_user_deleted_at"`
CreateTime time.Time `gorm:"column:create_time"`
UpdateTime time.Time `gorm:"column:update_time"`
CurrentStepAssigneeUserIDList model.Strings `gorm:"column:current_step_assignee_user_id_list"`
CurrentStepState string `gorm:"column:current_step_state"`
Status string `gorm:"column:status"`
Expand Down Expand Up @@ -584,6 +600,7 @@ func (d *WorkflowRepo) GetGlobalWorkflowsByParameterMap(ctx context.Context, dat
Status: biz.DataExportWorkflowStatus(result.Status),
CurrentWorkflowStepId: result.CurrentWorkflowStepId,
WorkflowSteps: make([]*biz.WorkflowStep, result.CurrentWorkflowStepId),
UpdateTime: result.UpdateTime,
}

// Fill the WorkflowSteps array with placeholder steps
Expand Down
5 changes: 5 additions & 0 deletions pkg/dms-common/api/dms/v1/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ type FilterGlobalDataExportWorkflowReq struct {
FilterCurrentStepAssigneeUserUid string `json:"filter_current_step_assignee_user_uid" query:"filter_current_step_assignee_user_uid"`
FilterByDBServiceUid string `json:"filter_by_db_service_uid" query:"filter_by_db_service_uid"`
FuzzyKeyword string `json:"fuzzy_keyword" query:"fuzzy_keyword"`
FilterCreateTimeFrom string `json:"filter_create_time_from" query:"filter_create_time_from"`
FilterCreateTimeTo string `json:"filter_create_time_to" query:"filter_create_time_to"`
FilterUpdateTimeFrom string `json:"filter_update_time_from" query:"filter_update_time_from"`
FilterUpdateTimeTo string `json:"filter_update_time_to" query:"filter_update_time_to"`

// CheckUserCanAccess enables OR-based self-relevant filtering:
// (creator OR current assignee OR viewable db_service). When true,
Expand Down Expand Up @@ -47,6 +51,7 @@ type ListDataExportWorkflow struct {
Description string `json:"desc"` // 数据导出工单的描述
Creater UidWithName `json:"creater"` // 数据导出工单的创建人
CreatedAt time.Time `json:"created_at"` // 数据导出工单的创建时间
UpdatedAt time.Time `json:"updated_at"` // 数据导出工单的更新时间
Status DataExportWorkflowStatus `json:"status"` // 数据导出工单的状态
CurrentStepAssigneeUsers []UidWithName `json:"current_step_assignee_user_list"` // 工单待操作人
DBServiceInfos []*DBServiceUidWithNameInfo `json:"db_service_info,omitempty"` // 所属数据源信息
Expand Down
16 changes: 16 additions & 0 deletions pkg/dms-common/dmsobject/data_export_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ func GetGlobalDataExportWorkflowsList(ctx context.Context, dmsAddr string, req d
}
}

if req.FilterCreateTimeFrom != "" {
query.Set("filter_create_time_from", req.FilterCreateTimeFrom)
}

if req.FilterCreateTimeTo != "" {
query.Set("filter_create_time_to", req.FilterCreateTimeTo)
}

if req.FilterUpdateTimeFrom != "" {
query.Set("filter_update_time_from", req.FilterUpdateTimeFrom)
}

if req.FilterUpdateTimeTo != "" {
query.Set("filter_update_time_to", req.FilterUpdateTimeTo)
}

// 将查询参数附加到 URL
baseURL.RawQuery = query.Encode()

Expand Down