Compare commits
No commits in common. "6b4350b915fcbe4255c0ad6186adb2f2d5d360e8" and "71eb131e581ec511cbd0e544427c60d8429f10c5" have entirely different histories.
6b4350b915
...
71eb131e58
@ -27,8 +27,7 @@ type CompositeCaseStep struct {
|
|||||||
StepName string `json:"step_name" gorm:"not null;size:255"`
|
StepName string `json:"step_name" gorm:"not null;size:255"`
|
||||||
StepDescription string `json:"step_description" gorm:"type:text"`
|
StepDescription string `json:"step_description" gorm:"type:text"`
|
||||||
StepType string `json:"step_type" gorm:"not null;size:100"`
|
StepType string `json:"step_type" gorm:"not null;size:100"`
|
||||||
ActivityName string `json:"activity_name" gorm:"not null;size:255"`
|
StepConfig string `json:"step_config" gorm:"type:json"`
|
||||||
ParametersJson string `json:"parameters_json" gorm:"type:json"`
|
|
||||||
IsRequired bool `json:"is_required" gorm:"default:true"`
|
IsRequired bool `json:"is_required" gorm:"default:true"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
@ -48,8 +47,7 @@ type CreateCompositeCaseStepRequest struct {
|
|||||||
StepName string `json:"step_name" binding:"required"`
|
StepName string `json:"step_name" binding:"required"`
|
||||||
StepDescription string `json:"step_description"`
|
StepDescription string `json:"step_description"`
|
||||||
StepType string `json:"step_type" binding:"required"`
|
StepType string `json:"step_type" binding:"required"`
|
||||||
ActivityName string `json:"activity_name"`
|
StepConfig string `json:"step_config"`
|
||||||
ParametersJson string `json:"parameters_json"`
|
|
||||||
IsRequired bool `json:"is_required"`
|
IsRequired bool `json:"is_required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +66,6 @@ type UpdateCompositeCaseStepRequest struct {
|
|||||||
StepName string `json:"step_name"`
|
StepName string `json:"step_name"`
|
||||||
StepDescription string `json:"step_description"`
|
StepDescription string `json:"step_description"`
|
||||||
StepType string `json:"step_type"`
|
StepType string `json:"step_type"`
|
||||||
ActivityName string `json:"activity_name"`
|
StepConfig string `json:"step_config"`
|
||||||
ParametersJson string `json:"parameters_json"`
|
|
||||||
IsRequired bool `json:"is_required"`
|
IsRequired bool `json:"is_required"`
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package services
|
|||||||
import (
|
import (
|
||||||
"beacon/models"
|
"beacon/models"
|
||||||
"beacon/pkg/dao/mysql"
|
"beacon/pkg/dao/mysql"
|
||||||
"beacon/utils"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
@ -61,15 +60,13 @@ func (s *CompositeCaseService) CreateCompositeCase(req *models.CreateCompositeCa
|
|||||||
zap.L().Info("开始创建步骤", zap.Int("steps_count", len(req.Steps)))
|
zap.L().Info("开始创建步骤", zap.Int("steps_count", len(req.Steps)))
|
||||||
var steps []models.CompositeCaseStep
|
var steps []models.CompositeCaseStep
|
||||||
for _, stepReq := range req.Steps {
|
for _, stepReq := range req.Steps {
|
||||||
activityName, _ := utils.GetActivityName(stepReq.StepType)
|
|
||||||
step := models.CompositeCaseStep{
|
step := models.CompositeCaseStep{
|
||||||
CompositeCaseID: compositeCase.ID,
|
CompositeCaseID: compositeCase.ID,
|
||||||
StepOrder: stepReq.StepOrder,
|
StepOrder: stepReq.StepOrder,
|
||||||
StepName: stepReq.StepName,
|
StepName: stepReq.StepName,
|
||||||
StepDescription: stepReq.StepDescription,
|
StepDescription: stepReq.StepDescription,
|
||||||
StepType: stepReq.StepType,
|
StepType: stepReq.StepType,
|
||||||
ActivityName: activityName,
|
StepConfig: stepReq.StepConfig,
|
||||||
ParametersJson: stepReq.ParametersJson,
|
|
||||||
IsRequired: stepReq.IsRequired,
|
IsRequired: stepReq.IsRequired,
|
||||||
}
|
}
|
||||||
steps = append(steps, step)
|
steps = append(steps, step)
|
||||||
@ -201,15 +198,13 @@ func (s *CompositeCaseService) UpdateCompositeCase(id uint, req *models.UpdateCo
|
|||||||
if len(req.Steps) > 0 {
|
if len(req.Steps) > 0 {
|
||||||
var steps []models.CompositeCaseStep
|
var steps []models.CompositeCaseStep
|
||||||
for _, stepReq := range req.Steps {
|
for _, stepReq := range req.Steps {
|
||||||
activityName, _ := utils.GetActivityName(stepReq.StepType)
|
|
||||||
step := models.CompositeCaseStep{
|
step := models.CompositeCaseStep{
|
||||||
CompositeCaseID: id,
|
CompositeCaseID: id,
|
||||||
StepOrder: stepReq.StepOrder,
|
StepOrder: stepReq.StepOrder,
|
||||||
StepName: stepReq.StepName,
|
StepName: stepReq.StepName,
|
||||||
StepDescription: stepReq.StepDescription,
|
StepDescription: stepReq.StepDescription,
|
||||||
StepType: stepReq.StepType,
|
StepType: stepReq.StepType,
|
||||||
ActivityName: activityName,
|
StepConfig: stepReq.StepConfig,
|
||||||
ParametersJson: stepReq.ParametersJson,
|
|
||||||
IsRequired: stepReq.IsRequired,
|
IsRequired: stepReq.IsRequired,
|
||||||
}
|
}
|
||||||
steps = append(steps, step)
|
steps = append(steps, step)
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetActivityName 根据步骤类型获取对应的 Activity 函数名
|
|
||||||
// 参数:
|
|
||||||
// - stepType: 数据库中的步骤类型,如 "api", "ui" 等
|
|
||||||
//
|
|
||||||
// 返回值:
|
|
||||||
// - activityName: 对应的 Temporal Activity 函数名
|
|
||||||
// - error: 如果步骤类型不支持则返回错误
|
|
||||||
func GetActivityName(stepType string) (string, error) {
|
|
||||||
// 标准化输入:转为大写并去除空格
|
|
||||||
normalizedStepType := strings.ToUpper(strings.TrimSpace(stepType))
|
|
||||||
|
|
||||||
// 步骤类型到 Activity 名称的映射表
|
|
||||||
stepTypeToActivity := map[string]string{
|
|
||||||
// ================== 测试类型 Activity ==================
|
|
||||||
"API": "RunApiTest", // API 接口测试
|
|
||||||
"UI": "RunUiTest", // UI 自动化测试
|
|
||||||
"SQL": "RunSqlTest", // SQL 执行sql语句
|
|
||||||
"PYTHON": "RunPythonTest", // PYTHON 执行python脚本处理数据
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查找对应的 Activity 名称
|
|
||||||
activityName, exists := stepTypeToActivity[normalizedStepType]
|
|
||||||
if !exists {
|
|
||||||
// 返回详细的错误信息,包含支持的类型列表
|
|
||||||
supportedTypes := make([]string, 0, len(stepTypeToActivity))
|
|
||||||
for stepType := range stepTypeToActivity {
|
|
||||||
supportedTypes = append(supportedTypes, stepType)
|
|
||||||
}
|
|
||||||
|
|
||||||
return "", fmt.Errorf("unsupported step type '%s'. Supported types: %v",
|
|
||||||
stepType, supportedTypes)
|
|
||||||
}
|
|
||||||
|
|
||||||
return activityName, nil
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user