feat: 添加表单视频参数校验
This commit is contained in:
@@ -31,6 +31,35 @@ func StartLambda(ctx context.Context, input any) (any, error) {
|
||||
}
|
||||
|
||||
func FormLambda(ctx context.Context, input any) (any, error) {
|
||||
nodeInput, ok := input.(*flowDto.NodeExecutionInput)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("入参类型错误")
|
||||
}
|
||||
if !g.IsEmpty(nodeInput.Config.FormConfig) {
|
||||
for _, v := range nodeInput.Config.FormConfig {
|
||||
if strings.Contains(v.Field, "视频时长") {
|
||||
if g.IsEmpty(v.Value) {
|
||||
return nil, fmt.Errorf("视频时长不能为空")
|
||||
}
|
||||
if gconv.Int(v.Value) >= 16 {
|
||||
return nil, fmt.Errorf("视频时长超过15秒了")
|
||||
}
|
||||
if gconv.Int(v.Value) <= 3 {
|
||||
return nil, fmt.Errorf("视频时长不能小于4秒")
|
||||
}
|
||||
}
|
||||
if strings.Contains(v.Field, "视频分辨率") {
|
||||
if gconv.String(v.Value) != "480p" && gconv.String(v.Value) != "720p" {
|
||||
return nil, fmt.Errorf("视频分辨率不合法, 可选值: 480p, 720p")
|
||||
}
|
||||
}
|
||||
if strings.Contains(v.Field, "宽高比例") {
|
||||
if gconv.String(v.Value) != "21:9" && gconv.String(v.Value) != "1:1" && gconv.String(v.Value) != "16:9" && gconv.String(v.Value) != "4:3" && gconv.String(v.Value) != "9:16" && gconv.String(v.Value) != "3:4" {
|
||||
return nil, fmt.Errorf("宽高比例不合法, 可选值: 21:9, 1:1, 16:9, 4:3, 9:16, 3:4")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return input, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user