|
@@ -1,15 +1,20 @@
|
|
|
package cg_sdk
|
|
|
|
|
|
import (
|
|
|
- "errors"
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/api/request"
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/api/response"
|
|
|
+ "github.com/pkg/errors"
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
delimiter = "_"
|
|
|
)
|
|
|
|
|
|
+const (
|
|
|
+ encodeSegmentFormType = "form"
|
|
|
+ encodeSegmentDynamicType = "dynamic"
|
|
|
+)
|
|
|
+
|
|
|
type ConfigEncode struct {
|
|
|
InputStruct any
|
|
|
|
|
@@ -86,10 +91,17 @@ func (configEncode *ConfigEncode) genSegmentValueMap() error {
|
|
|
configEncode.segmentValueMap = make(map[string]string)
|
|
|
}
|
|
|
for _, encodeSegment := range configEncode.encodeConfigInfo.ConfigContent {
|
|
|
- if valueString, ok := configEncode.inputMap[encodeSegment.FieldValue].(string); ok {
|
|
|
- configEncode.segmentValueMap[encodeSegment.EncodeSegmentID] = valueString
|
|
|
- } else {
|
|
|
- return errors.New("转化业务参数失败:SegmentValueMap")
|
|
|
+ switch encodeSegment.EncodeSegmentType {
|
|
|
+ case encodeSegmentFormType:
|
|
|
+ fallthrough
|
|
|
+ case encodeSegmentDynamicType:
|
|
|
+ if valueString, ok := configEncode.inputMap[encodeSegment.FieldValue].(string); ok {
|
|
|
+ configEncode.segmentValueMap[encodeSegment.EncodeSegmentID] = valueString
|
|
|
+ } else {
|
|
|
+ return errors.New("转化业务参数失败:SegmentValueMap")
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ return errors.New("未知类型:" + encodeSegment.EncodeSegmentType)
|
|
|
}
|
|
|
}
|
|
|
return nil
|