ziwen 1 anno fa
parent
commit
d26b21c7d6

+ 19 - 14
controllers/help_doc/doc.go

@@ -2,7 +2,6 @@ package help_doc
 
 import (
 	"encoding/json"
-	"fmt"
 	"hongze/hz_crm_api/controllers"
 	"hongze/hz_crm_api/models"
 	"hongze/hz_crm_api/models/help_doc"
@@ -44,12 +43,16 @@ func (this *HelpDocController) Add() {
 		br.Msg = "请输入内容"
 		return
 	}
-	anchor,err := json.Marshal(req.AnchorData)
-	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
-		return
+	var anchor []byte
+	if req.AnchorData != nil{
+		anchor,err = json.Marshal(req.AnchorData)
+		if err != nil {
+			br.Msg = "参数解析异常!"
+			br.ErrMsg = "参数解析失败,Err:" + err.Error()
+			return
+		}
 	}
+
 	item := new(help_doc.HelpDoc)
 	item.ClassifyId = req.ClassifyId
 	item.Title = req.Title
@@ -80,7 +83,7 @@ func (this *HelpDocController) Add() {
 	br.Success = true
 
 }
-//
+
 //// @Title 编辑报告接口
 //// @Description 编辑报告
 //// @Param	request	body models.EditEnglishReportReq true "type json string"
@@ -160,7 +163,7 @@ func (this *HelpDocController) Add() {
 //	br.Msg = "保存成功"
 //	br.Data = resp
 //}
-//
+
 
 
 // @Title 获取报告详情接口
@@ -195,13 +198,15 @@ func (this *HelpDocController) Detail() {
 	item.Content = html.UnescapeString(item.Content)
 
 	var anchor []help_doc.AnchorList
-	err = json.Unmarshal([]byte(item.Anchor),&anchor)
-	if err != nil {
-		br.Msg = "解析失败"
-		br.ErrMsg = "解析失败,Err:" + err.Error()
-		return
+	if item.Anchor != "" {
+		err = json.Unmarshal([]byte(item.Anchor),&anchor)
+		if err != nil {
+			br.Msg = "解析失败"
+			br.ErrMsg = "解析失败,Err:" + err.Error()
+			return
+		}
 	}
-fmt.Println("anchor",anchor)
+
 	resp := help_doc.HelpDocResp{
 		Id:            item.Id,
 		ClassifyId:    item.ClassifyId,

+ 0 - 6
models/help_doc/help_doc.go

@@ -59,12 +59,6 @@ type AnchorList struct {
 	Child    []AnchorList
 }
 
-type Anchor struct {
-	AnchorId string
-	Anchor   string
-	Child    []AnchorList
-}
-
 func AddHelpDoc(item *HelpDoc) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)

+ 2 - 4
services/data/help_doc_classify.go

@@ -23,13 +23,11 @@ func HelpDocClassifyItemsMakeTree(allNode []*help_doc.HelpDocClassifyItems, node
 			if has {
 				HelpDocClassifyItemsMakeTree(allNode, v) //递归添加节点
 			} else {
-				childrenArr := make([]*help_doc.HelpDocClassifyItems, 0)
-				v.Children = childrenArr
+				v.Children = nil
 			}
 		}
 	} else {
-		childrenArr := make([]*help_doc.HelpDocClassifyItems, 0)
-		node.Children = childrenArr
+		node.Children = nil
 	}
 }