maxiaoshan 4 年之前
父节点
当前提交
2581f569a0
共有 1 个文件被更改,包括 13 次插入10 次删除
  1. 13 10
      projectinfo/src/task.go

+ 13 - 10
projectinfo/src/task.go

@@ -197,18 +197,21 @@ func GetProjectData(sid, eid string) {
 			//buyerclass
 			ent, _ := MixMgo.FindOne(CollEnt, bson.M{"buyer_name": buyer})
 			if len(*ent) > 0 && (*ent)["buyerclass"] != nil {
-				arr := (*ent)["buyerclass"].([]interface{})
-				if len(arr) == 1 {
-					pro["buyerclass"] = arr
-				} else {
-					var arrTmp []string
-					for _, v := range arr {
-						val := qu.ObjToString(v)
-						if val != "其它" {
-							arrTmp = append(arrTmp, val)
+				if buyerclassStr, ok := (*ent)["buyerclass"].(string); ok {
+					pro["buyerclass"] = []string{buyerclassStr}
+				} else if buyerclassArr, ok := (*ent)["buyerclass"].([]interface{}); ok {
+					if len(buyerclassArr) == 1 {
+						pro["buyerclass"] = buyerclassArr
+					} else {
+						var arrTmp []string
+						for _, v := range buyerclassArr {
+							val := qu.ObjToString(v)
+							if val != "其它" {
+								arrTmp = append(arrTmp, val)
+							}
 						}
+						pro["buyerclass"] = arrTmp
 					}
-					pro["buyerclass"] = arrTmp
 				}
 			}
 			maps := []map[string]interface{}{}