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
7 changes: 4 additions & 3 deletions internal/dms/service/data_export_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ func (d *DMSService) ListDataExportWorkflow(ctx context.Context, req *dmsV1.List
if len(creater) > 0 {
ret[i].Creater = creater[0]
}
if w.WorkflowRecord.WorkflowSteps[w.WorkflowRecord.CurrentWorkflowStepId-1].State == "init" {
// 结束时不显示当前步骤操作人,其他状态显示当前步骤操作人
if w.Status != string(dmsV1.StatusFinish) {
ret[i].CurrentStepAssigneeUsers = convertBizUidWithName(d.UserUsecase.GetBizUserIncludeDeletedWithNameByUids(ctx, w.WorkflowRecord.WorkflowSteps[w.WorkflowRecord.CurrentWorkflowStepId-1].Assignees))
}

}

return &dmsV1.ListDataExportWorkflowsReply{
Expand Down Expand Up @@ -191,7 +191,8 @@ func (d *DMSService) GetGlobalWorkflowsList(ctx context.Context, req *dmsV1.Filt
if len(creater) > 0 {
ret[i].Creater = creater[0]
}
if w.WorkflowRecord.WorkflowSteps[w.WorkflowRecord.CurrentWorkflowStepId-1].State == "init" {
// 结束时不显示当前步骤操作人,其他状态显示当前步骤操作人
if w.Status != string(dmsV1.StatusFinish) {
ret[i].CurrentStepAssigneeUsers = convertBizUidWithName(d.UserUsecase.GetBizUserIncludeDeletedWithNameByUids(ctx, w.WorkflowRecord.WorkflowSteps[w.WorkflowRecord.CurrentWorkflowStepId-1].Assignees))
}
}
Expand Down
13 changes: 12 additions & 1 deletion internal/dms/storage/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,18 @@ type WorkflowRecord struct {
type Strings []string

func (t *Strings) Scan(value interface{}) error {
bytesValue, _ := value.([]byte)
if value == nil {
return nil
}
var bytesValue []byte
switch v := value.(type) {
case []byte:
bytesValue = v
case string:
bytesValue = []byte(v)
default:
return fmt.Errorf("failed to scan Strings: expected []byte or string, got %T", value)
}
return json.Unmarshal(bytesValue, t)
}

Expand Down
30 changes: 24 additions & 6 deletions internal/dms/storage/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ SELECT
w.create_user_uid,
CAST("" AS DATETIME) AS create_user_deleted_at,
w.created_at AS create_time,
curr_ws.assignees AS current_step_assignee_user_id_list,
IF(wr.status = 'rejected', JSON_ARRAY(w.create_user_uid), curr_ws.assignees) AS current_step_assignee_user_id_list,
curr_ws.state AS current_step_state,
wr.status,
wr.current_workflow_step_id AS current_workflow_step_id,
Expand Down Expand Up @@ -413,7 +413,8 @@ w.workflow_type='data_export'
{{- if .check_user_can_access }}
AND (
w.create_user_uid = :current_user_id
OR curr_ws.assignees REGEXP :current_user_id
OR (wr.status != 'rejected' AND curr_ws.assignees REGEXP :current_user_id)
OR (wr.status = 'rejected' AND w.create_user_uid = :current_user_id)


{{- if .viewable_db_service_uids }}
Expand All @@ -440,7 +441,7 @@ AND wr.status IN (:filter_status)
{{- end }}

{{- if .filter_current_step_assignee_user_id }}
AND curr_ws.assignees REGEXP :filter_current_step_assignee_user_id
AND ((wr.status != 'rejected' AND curr_ws.assignees REGEXP :filter_current_step_assignee_user_id) OR (wr.status = 'rejected' AND w.create_user_uid = :filter_current_step_assignee_user_id))
{{- end }}

{{- if .filter_db_service_uid }}
Expand Down Expand Up @@ -573,10 +574,27 @@ func (d *WorkflowRepo) GetGlobalWorkflowsByParameterMap(ctx context.Context, dat
}

// Set the current step data
if result.CurrentWorkflowStepId > 0 {
currentStepIndex := result.CurrentWorkflowStepId - 1
if result.CurrentWorkflowStepId > 0 || result.Status == "rejected" {
currentStepIndex := int64(result.CurrentWorkflowStepId) - 1
if currentStepIndex < 0 {
currentStepIndex = 0
}
// Ensure WorkflowSteps has enough capacity
if len(workflow.WorkflowRecord.WorkflowSteps) <= int(currentStepIndex) {
newSteps := make([]*biz.WorkflowStep, currentStepIndex+1)
copy(newSteps, workflow.WorkflowRecord.WorkflowSteps)
for i := len(workflow.WorkflowRecord.WorkflowSteps); i <= int(currentStepIndex); i++ {
newSteps[i] = &biz.WorkflowStep{
StepId: uint64(i + 1),
WorkflowRecordUid: result.WorkflowRecordUID,
Assignees: []string{},
}
}
workflow.WorkflowRecord.WorkflowSteps = newSteps
}

workflow.WorkflowRecord.WorkflowSteps[currentStepIndex] = &biz.WorkflowStep{
StepId: result.CurrentWorkflowStepId,
StepId: uint64(currentStepIndex + 1),
WorkflowRecordUid: result.WorkflowRecordUID,
State: result.CurrentStepState,
Assignees: result.CurrentStepAssigneeUserIDList,
Expand Down