|
@@ -1,7 +1,12 @@
|
|
|
package help_doc
|
|
|
|
|
|
import (
|
|
|
+ "encoding/json"
|
|
|
"hongze/hz_crm_api/controllers"
|
|
|
+ "hongze/hz_crm_api/models"
|
|
|
+ "hongze/hz_crm_api/models/help_doc"
|
|
|
+ "html"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
// HelpDocController 帮助文档
|
|
@@ -9,63 +14,76 @@ type HelpDocController struct {
|
|
|
controllers.BaseAuthController
|
|
|
}
|
|
|
|
|
|
-//// @Title 新增报告接口
|
|
|
-//// @Description 新增报告
|
|
|
-//// @Param request body help_doc.AddHelpDocReq true "type json string"
|
|
|
-//// @Success 200 {object} models.AddEnglishReportResp
|
|
|
-//// @router /add [post]
|
|
|
-//func (this *HelpDocController) Add() {
|
|
|
-// br := new(models.BaseResponse).Init()
|
|
|
-// defer func() {
|
|
|
-// this.Data["json"] = br
|
|
|
-// this.ServeJSON()
|
|
|
-// }()
|
|
|
-// sysUser := this.SysUser
|
|
|
-// if sysUser == nil {
|
|
|
-// br.Msg = "请登录"
|
|
|
-// br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
-// br.Ret = 408
|
|
|
-// return
|
|
|
-// }
|
|
|
-// var req help_doc.AddHelpDocReq
|
|
|
-// err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "参数解析异常!"
|
|
|
-// br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if req.Content == "" {
|
|
|
-// br.Msg = "请输入内容"
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// item := new(help_doc.HelpDoc)
|
|
|
-// item.ClassifyId = req.ClassifyId
|
|
|
-// item.ClassifyName = req.ClassifyName
|
|
|
-// item.Title = req.Title
|
|
|
-// item.Author = req.Author
|
|
|
-// item.Status = req.Status
|
|
|
-// item.Content = html.EscapeString(req.Content)
|
|
|
-// item.CreateTime = time.Now()
|
|
|
-// item.ModifyTime = time.Now()
|
|
|
-// item.AdminId = sysUser.AdminId
|
|
|
-// item.AdminRealName = sysUser.RealName
|
|
|
-// _, err = help_doc.AddHelpDoc(item)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "保存失败"
|
|
|
-// br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// //resp := new(models.AddEnglishReportResp)
|
|
|
-// //resp.ReportId = newReportId
|
|
|
-// //resp.ReportCode = reportCode
|
|
|
-// br.Ret = 200
|
|
|
-// br.Success = true
|
|
|
-// br.Msg = "保存成功"
|
|
|
-// //br.Data = resp
|
|
|
-//}
|
|
|
-//
|
|
|
+// @Title 新增报告接口
|
|
|
+// @Description 新增报告
|
|
|
+// @Param request body help_doc.AddHelpDocReq true "type json string"
|
|
|
+// @Success 200 {object} models.AddEnglishReportResp
|
|
|
+// @router /add [post]
|
|
|
+func (this *HelpDocController) Add() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ sysUser := this.SysUser
|
|
|
+ if sysUser == nil {
|
|
|
+ br.Msg = "请登录"
|
|
|
+ br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
+ br.Ret = 408
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var req help_doc.AddHelpDocReq
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if req.Content == "" {
|
|
|
+ br.Msg = "请输入内容"
|
|
|
+ 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
|
|
|
+ item.Author = req.Author
|
|
|
+ item.Status = req.Status
|
|
|
+ item.Content = html.EscapeString(req.Content)
|
|
|
+ item.CreateTime = time.Now()
|
|
|
+ item.ModifyTime = time.Now()
|
|
|
+ item.AdminId = sysUser.AdminId
|
|
|
+ item.AdminRealName = sysUser.RealName
|
|
|
+ item.Anchor = string(anchor)
|
|
|
+ if req.Status == 2 {
|
|
|
+ item.PublishTime = time.Now()
|
|
|
+ }
|
|
|
+ _, err = help_doc.AddHelpDoc(item)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "保存失败"
|
|
|
+ br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.Status == 1 {
|
|
|
+ br.Msg = "新增成功"
|
|
|
+ } else {
|
|
|
+ br.Msg = "发布成功"
|
|
|
+ }
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
//// @Title 编辑报告接口
|
|
|
//// @Description 编辑报告
|
|
|
//// @Param request body models.EditEnglishReportReq true "type json string"
|
|
@@ -121,8 +139,6 @@ type HelpDocController struct {
|
|
|
// // }
|
|
|
// //}
|
|
|
//
|
|
|
-// var stage int
|
|
|
-// report, _ := models.GetEnglishReportById(int(req.ReportId))
|
|
|
//
|
|
|
// item := new(help_doc.HelpDoc)
|
|
|
// item.ClassifyId = req.ClassifyIdFirst
|
|
@@ -147,55 +163,72 @@ type HelpDocController struct {
|
|
|
// br.Msg = "保存成功"
|
|
|
// br.Data = resp
|
|
|
//}
|
|
|
-//
|
|
|
-//// @Title 获取报告详情接口
|
|
|
-//// @Description 获取报告详情
|
|
|
-//// @Param request body models.ReportDetailReq true "type json string"
|
|
|
-//// @Success 200 {object} models.EnglishReportDetailView
|
|
|
-//// @router /detail [get]
|
|
|
-//func (this *HelpDocController) Detail() {
|
|
|
-// br := new(models.BaseResponse).Init()
|
|
|
-// defer func() {
|
|
|
-// this.Data["json"] = br
|
|
|
-// this.ServeJSON()
|
|
|
-// }()
|
|
|
-// /*var req models.ReportDetailReq
|
|
|
-// err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "参数解析异常!"
|
|
|
-// br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if req.ReportId <= 0 {
|
|
|
-// br.Msg = "参数错误"
|
|
|
-// return
|
|
|
-// }*/
|
|
|
-// reportId, err := this.GetInt("ReportId")
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "获取参数失败!"
|
|
|
-// br.ErrMsg = "获取参数失败,Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if reportId <= 0 {
|
|
|
-// br.Msg = "参数错误"
|
|
|
-// return
|
|
|
-// }
|
|
|
-// item, err := models.GetEnglishReportById(reportId)
|
|
|
-// if err != nil {
|
|
|
-// br.Msg = "获取失败"
|
|
|
-// br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// item.Content = html.UnescapeString(item.Content)
|
|
|
-// item.ContentSub = html.UnescapeString(item.ContentSub)
|
|
|
-//
|
|
|
-// br.Ret = 200
|
|
|
-// br.Success = true
|
|
|
-// br.Msg = "获取成功"
|
|
|
-// br.Data = item
|
|
|
-//}
|
|
|
-//
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// @Title 获取报告详情接口
|
|
|
+// @Description 获取报告详情
|
|
|
+// @Param request body models.ReportDetailReq true "type json string"
|
|
|
+// @Success 200 {object} models.EnglishReportDetailView
|
|
|
+// @router /detail [get]
|
|
|
+func (this *HelpDocController) Detail() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+
|
|
|
+ docId, err := this.GetInt("DocId")
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取参数失败!"
|
|
|
+ br.ErrMsg = "获取参数失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if docId <= 0 {
|
|
|
+ br.Msg = "参数错误"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item, err := help_doc.GetHelpDocById(docId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ item.Content = html.UnescapeString(item.Content)
|
|
|
+
|
|
|
+ var anchor []help_doc.AnchorList
|
|
|
+ if item.Anchor != "" {
|
|
|
+ err = json.Unmarshal([]byte(item.Anchor),&anchor)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "解析失败"
|
|
|
+ br.ErrMsg = "解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ resp := help_doc.HelpDocResp{
|
|
|
+ Id: item.Id,
|
|
|
+ ClassifyId: item.ClassifyId,
|
|
|
+ ClassifyName: item.ClassifyName,
|
|
|
+ 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,
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+ br.Data = resp
|
|
|
+}
|
|
|
+
|
|
|
//// @Title 获取报告列表接口
|
|
|
//// @Description 获取报告列表
|
|
|
//// @Param PageSize query int true "每页数据条数"
|