소스 검색

调整接口

wangbo 1 주 전
부모
커밋
2c442cbc39
1개의 변경된 파일19개의 추가작업 그리고 2개의 파일을 삭제
  1. 19 2
      cg_sdk.go

+ 19 - 2
cg_sdk.go

@@ -104,8 +104,8 @@ func (configEncode *ConfigEncode) genSegmentValueMap() error {
 				fallthrough
 			case encodeSegmentDynamicType:
 				switch inputFieldValueAny.(type) {
-				case LibraryCodeInfo:
-					configEncode.segmentValueMap[encodeSegment.EncodeSegmentID] = inputFieldValueAny.(LibraryCodeInfo)
+				case map[string]any:
+					configEncode.segmentValueMap[encodeSegment.EncodeSegmentID] = AnyMapToLibraryCodeInfo(inputFieldValueAny.(map[string]any))
 				case string:
 					configEncode.segmentValueMap[encodeSegment.EncodeSegmentID] = LibraryCodeInfo{Name: inputFieldValueAny.(string)}
 				default:
@@ -120,6 +120,23 @@ func (configEncode *ConfigEncode) genSegmentValueMap() error {
 	return nil
 }
 
+func AnyMapToLibraryCodeInfo(anyMap map[string]any) LibraryCodeInfo {
+	var libraryCodeInfo LibraryCodeInfo
+	if id, ok := anyMap["id"].(string); ok {
+		libraryCodeInfo.ID = id
+	}
+	if parentId, ok := anyMap["parentId"].(string); ok {
+		libraryCodeInfo.ParentID = parentId
+	}
+	if name, ok := anyMap["name"].(string); ok {
+		libraryCodeInfo.Name = name
+	}
+	if code, ok := anyMap["code"].(string); ok {
+		libraryCodeInfo.Code = code
+	}
+	return libraryCodeInfo
+}
+
 func (configEncode *ConfigEncode) createCreateJsonBody() CreateEncodeJsonBody {
 	return CreateEncodeJsonBody{
 		Namespace:                configEncode.codeNamespace,