|
@@ -31,71 +31,76 @@ func (a *HelpDocController) ClassifyList(c *gin.Context) {
|
|
|
resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
|
|
|
return
|
|
|
}
|
|
|
- //etaOb := new(crm.EtaBusiness)
|
|
|
- //var pars []interface{}
|
|
|
- //pars = append(pars, req.BusCode)
|
|
|
- //etaBusiness, e := etaOb.GetItemByCondition("code_encrypt=?", pars, "sort asc,classify_id asc")
|
|
|
- //if e != nil {
|
|
|
- // resp.FailMsg("获取失败", "获取帮助文档列表失败, Err: "+e.Error(), c)
|
|
|
- // return
|
|
|
- //}
|
|
|
-
|
|
|
-
|
|
|
- // 获取列表数据
|
|
|
- docOb := new(crm.HelpDocClassify)
|
|
|
- rootList, e := docOb.GetItemsByCondition("parent_id=0", make([]interface{}, 0), "sort asc,classify_id asc")
|
|
|
+ etaOb := new(crm.EtaBusiness)
|
|
|
+ var pars []interface{}
|
|
|
+ pars = append(pars, req.BusCode)
|
|
|
+ etaBusiness, e := etaOb.GetItemByCondition("code_encrypt=?", pars, "")
|
|
|
if e != nil {
|
|
|
resp.FailMsg("获取失败", "获取帮助文档列表失败, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- classifyAll, e := docOb.GetItemsByCondition("", make([]interface{}, 0), "sort asc,classify_id asc")
|
|
|
- if e != nil {
|
|
|
- resp.FailMsg("获取失败", "获取帮助文档列表失败, Err: "+e.Error(), c)
|
|
|
- return
|
|
|
- }
|
|
|
+ nodeAll := make([]*crm.HelpDocClassifyItems, 0)
|
|
|
+
|
|
|
+ if etaBusiness != nil{
|
|
|
+ // 获取列表数据
|
|
|
+ docOb := new(crm.HelpDocClassify)
|
|
|
+ var pars []interface{}
|
|
|
+ pars = append(pars, etaBusiness.EtaBusinessId)
|
|
|
+ rootList, e := docOb.GetItemsByCondition("parent_id=0 AND FIND_IN_SET(?,visible_business_ids) > 0 ", pars, "sort asc,classify_id asc")
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("获取失败", "获取帮助文档列表失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- classifies := make([]*crm.HelpDocClassifyItems, 0)
|
|
|
- for _, v := range classifyAll {
|
|
|
- child := make([]*crm.HelpDocClassifyItems, 0)
|
|
|
- item := crm.HelpDocClassifyItems{
|
|
|
- ClassifyId: v.ClassifyId,
|
|
|
- ClassifyName: v.ClassifyName,
|
|
|
- ParentId: v.ParentId,
|
|
|
- Level: v.Level,
|
|
|
- Sort: v.Sort,
|
|
|
- SysUserId: v.SysUserId,
|
|
|
- SysUserRealName: v.SysUserRealName,
|
|
|
- VisibleBusinessIds: v.VisibleBusinessIds,
|
|
|
- Children: child,
|
|
|
+ classifyAll, e := docOb.GetItemsByCondition("FIND_IN_SET(?,visible_business_ids) > 0", pars, "sort asc,classify_id asc")
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("获取失败", "获取帮助文档列表失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ classifies := make([]*crm.HelpDocClassifyItems, 0)
|
|
|
+ for _, v := range classifyAll {
|
|
|
+ child := make([]*crm.HelpDocClassifyItems, 0)
|
|
|
+ item := crm.HelpDocClassifyItems{
|
|
|
+ ClassifyId: v.ClassifyId,
|
|
|
+ ClassifyName: v.ClassifyName,
|
|
|
+ ParentId: v.ParentId,
|
|
|
+ Level: v.Level,
|
|
|
+ Sort: v.Sort,
|
|
|
+ SysUserId: v.SysUserId,
|
|
|
+ SysUserRealName: v.SysUserRealName,
|
|
|
+ VisibleBusinessIds: v.VisibleBusinessIds,
|
|
|
+ Children: child,
|
|
|
+ }
|
|
|
+ classifies = append(classifies, &item)
|
|
|
}
|
|
|
- classifies = append(classifies, &item)
|
|
|
- }
|
|
|
|
|
|
+ roots := make([]*crm.HelpDocClassifyItems, 0)
|
|
|
+ for _, v := range rootList {
|
|
|
+ child := make([]*crm.HelpDocClassifyItems, 0)
|
|
|
+ item := crm.HelpDocClassifyItems{
|
|
|
+ ClassifyId: v.ClassifyId,
|
|
|
+ ClassifyName: v.ClassifyName,
|
|
|
+ ParentId: v.ParentId,
|
|
|
+ Level: v.Level,
|
|
|
+ Sort: v.Sort,
|
|
|
+ SysUserId: v.SysUserId,
|
|
|
+ SysUserRealName: v.SysUserRealName,
|
|
|
+ VisibleBusinessIds: v.VisibleBusinessIds,
|
|
|
+ Children: child,
|
|
|
+ }
|
|
|
+ roots = append(roots, &item)
|
|
|
+ }
|
|
|
|
|
|
- roots := make([]*crm.HelpDocClassifyItems, 0)
|
|
|
- for _, v := range rootList {
|
|
|
- child := make([]*crm.HelpDocClassifyItems, 0)
|
|
|
- item := crm.HelpDocClassifyItems{
|
|
|
- ClassifyId: v.ClassifyId,
|
|
|
- ClassifyName: v.ClassifyName,
|
|
|
- ParentId: v.ParentId,
|
|
|
- Level: v.Level,
|
|
|
- Sort: v.Sort,
|
|
|
- SysUserId: v.SysUserId,
|
|
|
- SysUserRealName: v.SysUserRealName,
|
|
|
- VisibleBusinessIds: v.VisibleBusinessIds,
|
|
|
- Children: child,
|
|
|
+ for k := range roots {
|
|
|
+ rootNode := roots[k]
|
|
|
+ services.HelpDocClassifyItemsMakeTree(classifies, rootNode)
|
|
|
+ nodeAll = append(nodeAll, rootNode)
|
|
|
}
|
|
|
- roots = append(roots, &item)
|
|
|
- }
|
|
|
- nodeAll := make([]*crm.HelpDocClassifyItems, 0)
|
|
|
- for k := range roots {
|
|
|
- rootNode := roots[k]
|
|
|
- services.HelpDocClassifyItemsMakeTree(classifies, rootNode)
|
|
|
- nodeAll = append(nodeAll, rootNode)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
resp.OkData("获取成功", nodeAll, c)
|
|
|
}
|
|
|
|