Quellcode durchsuchen

修复复制后的排序问题

boweniac vor 2 Monaten
Ursprung
Commit
798c5d8107
1 geänderte Dateien mit 4 neuen und 1 gelöschten Zeilen
  1. 4 1
      internal/logic/sop_stage/sop_stage_copy_logic.go

+ 4 - 1
internal/logic/sop_stage/sop_stage_copy_logic.go

@@ -42,6 +42,9 @@ func (l *SopStageCopyLogic) SopStageCopy(req *types.StageCopyReq) (resp *types.B
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
 	}
 
+	// 查询任务的阶段数量
+	count, err := l.svcCtx.DB.SopStage.Query().Where(sopstage.TaskIDEQ(data.TaskID)).Count(l.ctx)
+
 	//  创建新阶段
 	newStage, err := tx.SopStage.Create().
 		SetTaskID(data.TaskID).
@@ -53,7 +56,7 @@ func (l *SopStageCopyLogic) SopStageCopy(req *types.StageCopyReq) (resp *types.B
 		SetNotNilActionLabelAdd(data.ActionLabelAdd).
 		SetNotNilActionLabelDel(data.ActionLabelDel).
 		SetNotNilActionForward(&data.ActionForward).
-		SetIndexSort(data.IndexSort).
+		SetIndexSort(count + 1).
 		Save(l.ctx)
 	if err != nil {
 		_ = tx.Rollback()