|
@@ -31,7 +31,7 @@ func (this *HelpDocClassifyController) ListClassify() {
|
|
|
|
|
|
resp := new(help_doc.HelpDocClassifyListResp)
|
|
|
|
|
|
- rootList, err := help_doc.GetHelpDocClassifyByParentId(0, keyWord)
|
|
|
+ rootList, err := help_doc.GetHelpDocClassifyByParentId(0, "")
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
@@ -50,23 +50,85 @@ func (this *HelpDocClassifyController) ListClassify() {
|
|
|
classifyMap[v.ClassifyId] = 1
|
|
|
}
|
|
|
|
|
|
- classifyAll, err := help_doc.GetHelpDocClassifyAll(keyWord)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "获取失败"
|
|
|
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
- return
|
|
|
+ classifyAll := make([]*help_doc.HelpDocClassifyItems, 0)
|
|
|
+ newClassifyAll := make([]*help_doc.HelpDocClassifyItems, 0)
|
|
|
+ newRootList := make([]help_doc.HelpDocClassifyItems, 0)
|
|
|
+ //parentMap := make(map[int]int)
|
|
|
+ classifyAllMap := make(map[int]*help_doc.HelpDocClassifyItems, 0)
|
|
|
+ classifyKeyMap := make(map[int]*help_doc.HelpDocClassifyItems, 0)
|
|
|
+ rootMap := make(map[*help_doc.HelpDocClassifyItems]int, 0)
|
|
|
+ if keyWord != "" {
|
|
|
+ classifyAll, err = help_doc.GetAllHelpDocClassifyByKeyword("")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range classifyAll {
|
|
|
+ classifyAllMap[v.ClassifyId] = v
|
|
|
+ }
|
|
|
+
|
|
|
+ keywordClassify, err := help_doc.GetAllHelpDocClassifyByKeyword(keyWord)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range keywordClassify {
|
|
|
+ if v.Level == 3 {
|
|
|
+ ppid := classifyAllMap[v.ParentId].ParentId
|
|
|
+ //newRootList = append(newRootList, *classifyAllMap[ppid])
|
|
|
+ rootMap[classifyAllMap[ppid]] = 1
|
|
|
+ classifyKeyMap[v.ClassifyId] = v
|
|
|
+ classifyKeyMap[v.ParentId] = classifyAllMap[v.ParentId]
|
|
|
+ } else if v.Level == 2{
|
|
|
+ pid := classifyAllMap[v.ParentId].ClassifyId
|
|
|
+ //newRootList = append(newRootList, *classifyAllMap[pid])
|
|
|
+ rootMap[classifyAllMap[pid]] = 1
|
|
|
+ classifyKeyMap[v.ClassifyId] = v
|
|
|
+ } else if v.Level == 1 {
|
|
|
+ //newRootList = append(newRootList, *v)
|
|
|
+ rootMap[v] = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 重新组合 newRootList
|
|
|
+ //for _, v := range rootList {
|
|
|
+ // if root,ok := rootMap[v.ClassifyId]; ok{
|
|
|
+ // newRootList = append(newRootList, *root)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ for v, _ := range rootMap {
|
|
|
+ newRootList = append(newRootList, *v)
|
|
|
+ }
|
|
|
+ // 重新组合 newClassifyAll
|
|
|
+ for _, v := range classifyKeyMap {
|
|
|
+ if v.Level != 1 {
|
|
|
+ newClassifyAll = append(newClassifyAll, v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ classifyAll, err = help_doc.GetHelpDocClassifyAll("")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ newRootList = rootList
|
|
|
+ newClassifyAll = classifyAll
|
|
|
}
|
|
|
- for k := range classifyAll {
|
|
|
- _,ok := classifyMap[classifyAll[k].ClassifyId]
|
|
|
- classifyAll[k].Disabled = ok
|
|
|
+
|
|
|
+ for k := range newClassifyAll {
|
|
|
+ _,ok := classifyMap[newClassifyAll[k].ClassifyId]
|
|
|
+ newClassifyAll[k].Disabled = ok
|
|
|
}
|
|
|
|
|
|
- rootListAll := make([]help_doc.HelpDocClassifyItems, 0)
|
|
|
- rootListAll = rootList
|
|
|
+ //rootListAll := make([]help_doc.HelpDocClassifyItems, 0)
|
|
|
+ //rootListAll = rootList
|
|
|
nodeAll := make([]*help_doc.HelpDocClassifyItems, 0)
|
|
|
- for k := range rootListAll {
|
|
|
- rootNode := rootListAll[k]
|
|
|
- data.HelpDocClassifyItemsMakeTree(classifyAll, &rootNode)
|
|
|
+ for k := range newRootList {
|
|
|
+ rootNode := newRootList[k]
|
|
|
+ data.HelpDocClassifyItemsMakeTree(newClassifyAll, &rootNode)
|
|
|
nodeAll = append(nodeAll, &rootNode)
|
|
|
}
|
|
|
|
|
@@ -82,11 +144,11 @@ func (this *HelpDocClassifyController) ListClassify() {
|
|
|
classifyLevel[k].Disabled = ok
|
|
|
}
|
|
|
|
|
|
- rootListLevel := make([]help_doc.HelpDocClassifyItems, 0)
|
|
|
- rootListLevel = rootList
|
|
|
+ //rootListLevel := make([]help_doc.HelpDocClassifyItems, 0)
|
|
|
+ //rootListLevel = rootList
|
|
|
nodeAllTwoLevel := make([]*help_doc.HelpDocClassifyItems, 0)
|
|
|
- for k := range rootListLevel {
|
|
|
- rootNode := rootListLevel[k]
|
|
|
+ for k := range rootList {
|
|
|
+ rootNode := rootList[k]
|
|
|
data.HelpDocClassifyItemsMakeTree(classifyLevel, &rootNode)
|
|
|
nodeAllTwoLevel = append(nodeAllTwoLevel, &rootNode)
|
|
|
}
|