2
0

2 Commity 4fd6a1642d ... 2e37e0d188

Autor SHA1 Správa Dátum
  gmy 2e37e0d188 Merge branch 'gn_optimize_307_1205@guomengyuan' 1 deň pred
  gmy e802c32838 国能知识资源优化 2 týždňov pred
1 zmenil súbory, kde vykonal 37 pridanie a 35 odobranie
  1. 37 35
      controllers/knowledge/resource.go

+ 37 - 35
controllers/knowledge/resource.go

@@ -532,57 +532,59 @@ func (this *ResourceController) Add() {
 		br.Ret = 408
 		return
 	}
-	var req knowledge.AddReq
-	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	var reqList []knowledge.AddReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &reqList)
 	if err != nil {
 		br.Msg = "参数解析异常!"
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
 
-	if req.Title == `` {
-		br.Msg = "标题不能为空"
-		br.ErrMsg = "标题不能为空"
-		br.IsSendEmail = false
-		return
-	}
-	// 判断标题长度,如果超过600个字符则报错
-	//fmt.Println(len(req.Title))
-	if len(req.Title) > 600 {
-		br.Msg = "标题过长"
-		return
-	}
+	for _, req := range reqList {
+		if req.Title == `` {
+			br.Msg = "标题不能为空"
+			br.ErrMsg = "标题不能为空"
+			br.IsSendEmail = false
+			return
+		}
+		// 判断标题长度,如果超过600个字符则报错
+		//fmt.Println(len(req.Title))
+		if len(req.Title) > 600 {
+			br.Msg = "标题过长"
+			return
+		}
 
-	if req.ClassifyId <= 0 {
-		br.Msg = "分类必填"
-		br.ErrMsg = "分类必填"
-		br.IsSendEmail = false
-		return
-	}
-	if req.ResourceType == knowledge.KnowledgeResourceTypeEvent || req.ResourceType == knowledge.KnowledgeResourceTypePolicy {
-		if req.StartTime == "" {
-			br.Msg = "开始时间必填"
-			br.ErrMsg = "开始时间必填"
+		if req.ClassifyId <= 0 {
+			br.Msg = "分类必填"
+			br.ErrMsg = "分类必填"
+			br.IsSendEmail = false
 			return
 		}
-	}
-	item, err, errMsg := knowledgeServ.AddResource(&req, sysUser)
-	if err != nil {
-		br.Msg = "保存失败"
-		if errMsg != "" {
-			br.Msg = errMsg
+		if req.ResourceType == knowledge.KnowledgeResourceTypeEvent || req.ResourceType == knowledge.KnowledgeResourceTypePolicy {
+			if req.StartTime == "" {
+				br.Msg = "开始时间必填"
+				br.ErrMsg = "开始时间必填"
+				return
+			}
+		}
+		_, err, errMsg := knowledgeServ.AddResource(&req, sysUser)
+		if err != nil {
+			br.Msg = "保存失败"
+			if errMsg != "" {
+				br.Msg = errMsg
+			}
+			br.ErrMsg = "保存失败,Err:" + err.Error()
+			return
 		}
-		br.ErrMsg = "保存失败,Err:" + err.Error()
-		return
 	}
 
-	resp := new(knowledge.AddResp)
+	/*resp := new(knowledge.AddResp)
 	resp.KnowledgeResourceId = item.KnowledgeResourceId
-	resp.ResourceCode = item.ResourceCode
+	resp.ResourceCode = item.ResourceCode*/
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "保存成功"
-	br.Data = resp
+	//br.Data = resp
 }
 
 // Edit