|
@@ -1,7 +1,7 @@
|
|
|
package controller
|
|
|
|
|
|
import (
|
|
|
- "fmt"
|
|
|
+ "encoding/json"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"github.com/go-playground/validator/v10"
|
|
|
"hongze/hz_eta_docs_api/controller/resp"
|
|
@@ -9,13 +9,14 @@ import (
|
|
|
"hongze/hz_eta_docs_api/models/crm"
|
|
|
"hongze/hz_eta_docs_api/models/request"
|
|
|
"hongze/hz_eta_docs_api/services"
|
|
|
+ "html"
|
|
|
)
|
|
|
|
|
|
// HelpDocController 帮助文档
|
|
|
type HelpDocController struct{}
|
|
|
|
|
|
-// Menu
|
|
|
-// @Description 菜单
|
|
|
+// ClassifyList
|
|
|
+// @Description 帮助文档分类列表
|
|
|
// @Success 200 {string} string "获取成功"
|
|
|
// @Router /help_doc/classify/list [get]
|
|
|
func (a *HelpDocController) ClassifyList(c *gin.Context) {
|
|
@@ -30,16 +31,25 @@ func (a *HelpDocController) ClassifyList(c *gin.Context) {
|
|
|
resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
|
|
|
return
|
|
|
}
|
|
|
-fmt.Println("code:",req.BusCode)
|
|
|
+ //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
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
// 获取列表数据
|
|
|
- logOb := new(crm.HelpDocClassify)
|
|
|
- rootList, e := logOb.GetItemsByCondition("parent_id=0", make([]interface{}, 0), "sort asc,classify_id asc")
|
|
|
+ docOb := new(crm.HelpDocClassify)
|
|
|
+ rootList, e := docOb.GetItemsByCondition("parent_id=0", make([]interface{}, 0), "sort asc,classify_id asc")
|
|
|
if e != nil {
|
|
|
resp.FailMsg("获取失败", "获取帮助文档列表失败, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- classifyAll, e := logOb.GetItemsByCondition("", make([]interface{}, 0), "sort asc,classify_id asc")
|
|
|
+ classifyAll, e := docOb.GetItemsByCondition("", make([]interface{}, 0), "sort asc,classify_id asc")
|
|
|
if e != nil {
|
|
|
resp.FailMsg("获取失败", "获取帮助文档列表失败, Err: "+e.Error(), c)
|
|
|
return
|
|
@@ -88,3 +98,69 @@ fmt.Println("code:",req.BusCode)
|
|
|
|
|
|
resp.OkData("获取成功", nodeAll, c)
|
|
|
}
|
|
|
+
|
|
|
+// Detail
|
|
|
+// @Description 文章详情
|
|
|
+// @Success 200 {string} string "获取成功"
|
|
|
+// @Router /help_doc/detail [get]
|
|
|
+func (a *HelpDocController) Detail(c *gin.Context) {
|
|
|
+ var req request.HelpDocClassifyDetailReq
|
|
|
+ err := c.Bind(&req)
|
|
|
+ if err != nil {
|
|
|
+ errs, ok := err.(validator.ValidationErrors)
|
|
|
+ if !ok {
|
|
|
+ resp.FailData("参数解析失败", "Err:"+err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.FailData("参数解析失败", errs.Translate(global.Trans), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取列表数据
|
|
|
+ docOb := new(crm.HelpDoc)
|
|
|
+ var pars []interface{}
|
|
|
+ pars = append(pars, req.ClassifyId)
|
|
|
+ item, e := docOb.GetItemByCondition("classify_id=?", pars, "")
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("获取失败", "获取帮助文档列表失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ item.Content = html.UnescapeString(item.Content)
|
|
|
+
|
|
|
+ var anchor []crm.AnchorList
|
|
|
+ if item.Anchor != "" {
|
|
|
+ err = json.Unmarshal([]byte(item.Anchor), &anchor)
|
|
|
+ if err != nil {
|
|
|
+ resp.FailMsg("解析失败", "解析锚点失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var recommend []crm.RecommendList
|
|
|
+ if item.Recommend != "" {
|
|
|
+ err = json.Unmarshal([]byte(item.Recommend), &recommend)
|
|
|
+ if err != nil {
|
|
|
+ resp.FailMsg("解析失败", "解析推荐链接失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ respItem := crm.HelpDocResp{
|
|
|
+ Id: item.Id,
|
|
|
+ ClassifyId: item.ClassifyId,
|
|
|
+ Title: item.Title,
|
|
|
+ Author: item.Author,
|
|
|
+ CreateTime: item.CreateTime,
|
|
|
+ ModifyTime: item.ModifyTime,
|
|
|
+ Status: item.Status,
|
|
|
+ PublishTime: item.PublishTime,
|
|
|
+ Content: item.Content,
|
|
|
+ AdminId: item.AdminId,
|
|
|
+ AdminRealName: item.AdminRealName,
|
|
|
+ Anchor: anchor,
|
|
|
+ Recommend: recommend,
|
|
|
+ }
|
|
|
+
|
|
|
+ resp.OkData("获取成功", respItem, c)
|
|
|
+}
|