ziwen 1 年之前
父节点
当前提交
c9c8fbed07
共有 2 个文件被更改,包括 24 次插入13 次删除
  1. 15 10
      controllers/yanxuan_special.go
  2. 9 3
      models/cygx_yanxuan_special.go

+ 15 - 10
controllers/yanxuan_special.go

@@ -9,6 +9,7 @@ import (
 	"hongze/hongze_clpt/services"
 	"hongze/hongze_clpt/utils"
 	"os"
+	"strings"
 	"time"
 )
 
@@ -80,9 +81,9 @@ func (this *YanxuanSpecialController) List() {
 			v.Docs = docs
 		}
 		if v.Type == 1 {
-			v.Title = "【笔记】"+v.Title
+			v.Title = "【笔记】" + v.Title
 		} else if v.Type == 2 {
-			v.Title = "【观点】"+v.Title
+			v.Title = "【观点】" + v.Title
 		}
 		if v.MyCollectNum > 0 {
 			v.IsCollect = 1
@@ -273,7 +274,11 @@ func (this *YanxuanSpecialController) Save() {
 		br.Msg = "请至少输入一个标签"
 		return
 	}
-
+	docUrl, err := json.Marshal(req.Docs)
+	if err != nil {
+		return
+	}
+	imgUrls := strings.Join(req.ImgUrl, ",")
 	item := models.CygxYanxuanSpecial{
 		Id:          req.Id,
 		UserId:      sysUser.UserId,
@@ -282,8 +287,8 @@ func (this *YanxuanSpecialController) Save() {
 		PublishTime: time.Now(),
 		Content:     req.Content,
 		Tags:        req.Tags,
-		ImgUrl:      req.ImgUrl,
-		DocUrl:      req.DocUrl,
+		ImgUrl:      imgUrls,
+		DocUrl:      string(docUrl),
 		Title:       req.Title,
 		Type:        req.Type,
 	}
@@ -872,8 +877,8 @@ func (this *YanxuanSpecialController) AuthorHeadImg() {
 	}
 
 	item := models.CygxYanxuanSpecialAuthor{
-		UserId: req.UserId,
-		HeadImg:    req.HeadImg,
+		UserId:  req.UserId,
+		HeadImg: req.HeadImg,
 	}
 
 	err = models.UpdateYanxuanSpecialAuthorHeadImg(&item)
@@ -971,7 +976,7 @@ func (this *YanxuanSpecialController) Check() {
 		return
 	}
 
-	suggest := models.WxCheckContent(itemToken.AccessToken,sysUser.OpenId, req.Content)
+	suggest := models.WxCheckContent(itemToken.AccessToken, sysUser.OpenId, req.Content)
 	if suggest == "risky" {
 		br.Msg = "文章内容含有违法违规内容"
 		br.ErrMsg = "文章内容含有违法违规内容"
@@ -1000,7 +1005,7 @@ func (this *YanxuanSpecialController) Check() {
 				br.ErrMsg = "图片内容含有违法违规内容"
 				return
 			}
-			if err := res.GetResponseError(); err !=nil {
+			if err := res.GetResponseError(); err != nil {
 				// 处理微信返回错误信息
 				return
 			}
@@ -1014,4 +1019,4 @@ func (this *YanxuanSpecialController) Check() {
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "校验成功"
-}
+}

+ 9 - 3
models/cygx_yanxuan_special.go

@@ -62,6 +62,12 @@ type Doc struct {
 	DocIcon   string
 }
 
+type DocReq struct {
+	DocName   string
+	DocSuffix string
+	DocUrl    string
+}
+
 func GetYanxuanSpecialList(userId int, condition string, pars []interface{}) (items []*CygxYanxuanSpecialItem, err error) {
 	o := orm.NewOrm()
 	sql := ``
@@ -117,8 +123,8 @@ type CygxYanxuanSpecialReq struct {
 	Content string // 内容
 	Tags    string // 标签
 	DoType  int    // 1保存 2发布
-	ImgUrl  string // 图片链接
-	DocUrl  string // 文档链接
+	ImgUrl  []string // 图片链接
+	Docs    []DocReq  // 文档链接
 	Title   string // 标题
 	Type    int    // 类型1:笔记,2:观点
 }
@@ -175,6 +181,6 @@ func DelYanxuanSpecial(id int) (err error) {
 }
 
 type CygxYanxuanSpecialCheckReq struct {
-	Content string // 内容
+	Content string   // 内容
 	ImgUrl  []string // 图片
 }