计划逻辑迁移
This commit is contained in:
@@ -53,7 +53,7 @@ func NewPlanToResponse(plan *models.Plan) (*PlanResponse, error) {
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// NewPlanFromCreateRequest 将CreatePlanRequest转换为Plan模型,并进行业务规则验证
|
||||
// NewPlanFromCreateRequest 将CreatePlanRequest转换为Plan模型
|
||||
func NewPlanFromCreateRequest(req *CreatePlanRequest) (*models.Plan, error) {
|
||||
if req == nil {
|
||||
return nil, nil
|
||||
@@ -75,7 +75,7 @@ func NewPlanFromCreateRequest(req *CreatePlanRequest) (*models.Plan, error) {
|
||||
for i, childPlanID := range subPlanSlice {
|
||||
plan.SubPlans[i] = models.SubPlan{
|
||||
ChildPlanID: childPlanID,
|
||||
ExecutionOrder: i, // 默认执行顺序, ReorderSteps会再次确认
|
||||
ExecutionOrder: i, // 默认执行顺序
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,19 +93,10 @@ func NewPlanFromCreateRequest(req *CreatePlanRequest) (*models.Plan, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// 1. 首先,执行重复性验证
|
||||
if err := plan.ValidateExecutionOrder(); err != nil {
|
||||
// 如果检测到重复,立即返回错误
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 2. 然后,调用方法来修复顺序断层
|
||||
plan.ReorderSteps()
|
||||
|
||||
return plan, nil
|
||||
}
|
||||
|
||||
// NewPlanFromUpdateRequest 将UpdatePlanRequest转换为Plan模型,并进行业务规则验证
|
||||
// NewPlanFromUpdateRequest 将UpdatePlanRequest转换为Plan模型
|
||||
func NewPlanFromUpdateRequest(req *UpdatePlanRequest) (*models.Plan, error) {
|
||||
if req == nil {
|
||||
return nil, nil
|
||||
@@ -127,7 +118,7 @@ func NewPlanFromUpdateRequest(req *UpdatePlanRequest) (*models.Plan, error) {
|
||||
for i, childPlanID := range subPlanSlice {
|
||||
plan.SubPlans[i] = models.SubPlan{
|
||||
ChildPlanID: childPlanID,
|
||||
ExecutionOrder: i, // 默认执行顺序, ReorderSteps会再次确认
|
||||
ExecutionOrder: i, // 默认执行顺序
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,15 +136,6 @@ func NewPlanFromUpdateRequest(req *UpdatePlanRequest) (*models.Plan, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// 1. 首先,执行重复性验证
|
||||
if err := plan.ValidateExecutionOrder(); err != nil {
|
||||
// 如果检测到重复,立即返回错误
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 2. 然后,调用方法来修复顺序断层
|
||||
plan.ReorderSteps()
|
||||
|
||||
return plan, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user