|
@@ -15,6 +15,13 @@ const (
|
|
|
encodeSegmentDynamicType = "dynamic"
|
|
|
)
|
|
|
|
|
|
+type LibraryCodeInfo struct {
|
|
|
+ ID string `json:"id" sqlresult:"column:id;"`
|
|
|
+ ParentID string `json:"parentId" sqlresult:"column:parent_id;"`
|
|
|
+ Name string `json:"name" sqlresult:"column:name;"`
|
|
|
+ Code string `json:"code" sqlresult:"column:content;"`
|
|
|
+}
|
|
|
+
|
|
|
type ConfigEncode struct {
|
|
|
InputStruct any
|
|
|
|
|
@@ -26,7 +33,7 @@ type ConfigEncode struct {
|
|
|
OperatorUserName string
|
|
|
|
|
|
inputMap map[string]any
|
|
|
- segmentValueMap map[string]string
|
|
|
+ segmentValueMap map[string]LibraryCodeInfo
|
|
|
encodeConfigInfo *EncodeConfigInfo
|
|
|
|
|
|
codeNamespace string
|
|
@@ -88,20 +95,26 @@ func (configEncode *ConfigEncode) UpdateConfigEncodeStatue() (*Code, error) {
|
|
|
|
|
|
func (configEncode *ConfigEncode) genSegmentValueMap() error {
|
|
|
if configEncode.segmentValueMap == nil {
|
|
|
- configEncode.segmentValueMap = make(map[string]string)
|
|
|
+ configEncode.segmentValueMap = make(map[string]LibraryCodeInfo)
|
|
|
}
|
|
|
for _, encodeSegment := range configEncode.encodeConfigInfo.ConfigContent {
|
|
|
- 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")
|
|
|
+ if inputFieldValueAny, ok := configEncode.inputMap[encodeSegment.FieldValue]; ok {
|
|
|
+ switch encodeSegment.EncodeSegmentType {
|
|
|
+ case encodeSegmentFormType:
|
|
|
+ fallthrough
|
|
|
+ case encodeSegmentDynamicType:
|
|
|
+ switch inputFieldValueAny.(type) {
|
|
|
+ case LibraryCodeInfo:
|
|
|
+ configEncode.segmentValueMap[encodeSegment.EncodeSegmentID] = inputFieldValueAny.(LibraryCodeInfo)
|
|
|
+ case string:
|
|
|
+ configEncode.segmentValueMap[encodeSegment.EncodeSegmentID] = LibraryCodeInfo{Name: inputFieldValueAny.(string)}
|
|
|
+ default:
|
|
|
+ return errors.New("转化业务参数失败,未知类型:" + encodeSegment.EncodeSegmentType)
|
|
|
+ }
|
|
|
+
|
|
|
+ default:
|
|
|
+ return errors.New("未知类型:" + encodeSegment.EncodeSegmentType)
|
|
|
}
|
|
|
- default:
|
|
|
- return errors.New("未知类型:" + encodeSegment.EncodeSegmentType)
|
|
|
}
|
|
|
}
|
|
|
return nil
|