ziwen 1 年之前
父節點
當前提交
b7eaafadda

+ 2 - 2
controllers/report.go

@@ -915,7 +915,7 @@ func (this *MobileReportController) SearchReport() {
 			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 			return
 		}
-		listYx, err := models.GetArticleResearchList(conditionYx, pars, startSize, pageSize, user.UserId)
+		listYx, err := models.GetArticleResearchList(conditionYx, pars, startSize, pageSize, user.UserId, true)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
@@ -997,7 +997,7 @@ func (this *MobileReportController) SearchReport() {
 		if articleType == 1 {
 			list, err = models.GetArticleResearchListHz(condition, pars, startSize, pageSize, user.UserId)
 		} else {
-			list, err = models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId)
+			list, err = models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId, true)
 		}
 		if err != nil {
 			br.Msg = "获取信息失败"

+ 34 - 5
controllers/research.go

@@ -91,7 +91,7 @@ func (this *MobileResearchController) ArticleNewList() {
 	var conditiontype string
 	var pars []interface{}
 	condition = `    AND publish_status = 1  `
-	if articleTypeIds == "" {
+	if articleTypeIds == "" || strings.Contains(articleTypeIds,"999") {
 		conditiontype = " AND is_show_yanx  = 1 "
 	} else {
 		conditiontype = ` AND   group_id IN  (` + articleTypeIds + `) `
@@ -102,19 +102,28 @@ func (this *MobileResearchController) ArticleNewList() {
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
+	needYanxuanSpecial := true
+	if articleTypeIds != "" && !strings.Contains(articleTypeIds, "999") {
+		needYanxuanSpecial = false
+	}
+
+	//只勾选了研选专栏时去掉文章的统计
+	if articleTypeIds == "999" {
+		condition += ` AND 1<0 `
+	}
 	articleTypeIds = ""
 	for _, v := range listType {
 		articleTypeIds += strconv.Itoa(v.ArticleTypeId) + ","
 	}
 	articleTypeIds = strings.TrimRight(articleTypeIds, ",")
 	condition += `   AND a.article_type_id IN (` + articleTypeIds + `) `
-	total, err := models.GetArticleResearchCount(condition, pars)
+	total, err := models.GetArticleResearchCount(condition, pars, needYanxuanSpecial)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "GetArticleResearchCount,Err:" + err.Error()
 		return
 	}
-	list, err := models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId)
+	list, err := models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId, needYanxuanSpecial)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
@@ -153,6 +162,17 @@ func (this *MobileResearchController) ArticleNewList() {
 			ArticleTypeName: nameMap[v.ArticleTypeId],
 			ButtonStyle:     styleMap[v.ArticleTypeId],
 			List:            v.List,
+			IsSpecial:       v.IsSpecial,
+			SpecialTags:     v.SpecialTags,
+			UserId:          v.UserId,
+		}
+		if v.ArticleTypeId == -1 {
+			item.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
+		}
+		if v.SpecialType == 1 {
+			item.Title = "【笔记】" + item.Title
+		} else if v.SpecialType == 2 {
+			item.Title = "【观点】" + item.Title
 		}
 		if item.ArticleTypeName == "纪要" || item.ArticleTypeName == "沙龙" || item.ArticleTypeName == "专家访谈" {
 			item.Annotation = "核心结论:" + item.Annotation
@@ -549,6 +569,15 @@ func (this *MobileResearchController) DepartmentIdDetail() {
 		br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
 		return
 	}
+	needYanxuanSpecial := true
+	if articleTypeIds != "" && !strings.Contains(articleTypeIds, "999") {
+		needYanxuanSpecial = false
+	}
+
+	//只勾选了研选专栏时去掉文章的统计
+	if articleTypeIds == "999" {
+		condition += ` AND 1<0 `
+	}
 	if articleTypeIds != "" {
 		condition = ` AND a.article_type_id IN (` + articleTypeIds + `)  `
 	} else {
@@ -574,13 +603,13 @@ func (this *MobileResearchController) DepartmentIdDetail() {
 	}
 
 	condition += `  AND a.department_id = ` + strconv.Itoa(departmentId)
-	total, err := models.GetArticleResearchCount(condition, pars)
+	total, err := models.GetArticleResearchCount(condition, pars, needYanxuanSpecial)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "GetArticleResearchCount,Err:" + err.Error()
 		return
 	}
-	list, err := models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId)
+	list, err := models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId, needYanxuanSpecial)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()

+ 71 - 0
controllers/resource.go

@@ -143,3 +143,74 @@ func (this *ResourceController) Upload() {
 	br.Data = resp
 	return
 }
+
+// @Title 文件上传
+// @Description 文件上传接口
+// @Param   file   query   file  true       "文件"
+// @Success 200 新增成功
+// @router /file/upload [post]
+func (this *ResourceController) FileUpload() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	f, h, err := this.GetFile("file")
+	if err != nil {
+		br.Msg = "获取资源信息失败"
+		br.ErrMsg = "获取资源信息失败,Err:" + err.Error()
+		return
+	}
+	ext := path.Ext(h.Filename)
+	dateDir := time.Now().Format("20060102")
+	uploadDir := "static/temp/" + dateDir
+	err = os.MkdirAll(uploadDir, 777)
+	if err != nil {
+		br.Msg = "存储目录创建失败"
+		br.ErrMsg = "存储目录创建失败,Err:" + err.Error()
+		return
+	}
+	randStr := utils.GetRandStringNoSpecialChar(28)
+	fileName := randStr + ext
+	fpath := uploadDir + "/" + fileName
+	defer f.Close() //关闭上传文件
+	err = this.SaveToFile("file", fpath)
+	if err != nil {
+		br.Msg = "文件上传失败"
+		br.ErrMsg = "文件上传失败,Err:" + err.Error()
+		return
+	}
+	savePath := uploadDir + time.Now().Format("200601/20060102/")
+	savePath += fileName
+	//上传到阿里云
+	err = services.UploadFileToAliyun("", fpath, savePath)
+	if err != nil {
+		br.Msg = "文件上传失败"
+		br.ErrMsg = "文件上传失败,Err:" + err.Error()
+		return
+	}
+	fileHost := "https://hzstatic.hzinsights.com/"
+	resourceUrl := fileHost + savePath
+	defer func() {
+		os.Remove(fpath)
+	}()
+	item := new(models.Resource)
+	item.ResourceUrl = resourceUrl
+	item.ResourceType = 1
+	item.CreateTime = time.Now()
+	newId, err := models.AddResource(item)
+	if err != nil {
+		br.Msg = "资源上传失败"
+		br.ErrMsg = "资源上传失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.ResourceResp)
+	resp.Id = newId
+	resp.ResourceUrl = resourceUrl
+
+	br.Msg = "上传成功"
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+	return
+}

+ 25 - 12
controllers/user.go

@@ -902,19 +902,32 @@ func (this *UserController) CollectList() {
 	for i := 0; i < lenList; i++ {
 		item := list[i]
 		article := articleMap[item.ArticleId]
-		list[i].Title = article.Title
-		list[i].DepartmentId = article.DepartmentId
-		list[i].NickName = article.NickName
-		list[i].PublishDate = article.PublishDate
-		if article.ArticleId < utils.SummaryArticleId {
-			list[i].Source = 1
-		} else {
-			list[i].Source = 2
+		if list[i].IsSpecial != 1 {
+			list[i].Title = article.Title
+			list[i].DepartmentId = article.DepartmentId
+			list[i].NickName = article.NickName
+			list[i].PublishDate = article.PublishDate
+			if article.ArticleId < utils.SummaryArticleId {
+				list[i].Source = 1
+			} else {
+				list[i].Source = 2
+			}
+			if mapArticleCollectNum[article.ArticleId] != nil {
+				list[i].CollectNum = mapArticleCollectNum[article.ArticleId].CollectNum
+				list[i].Pv = mapArticleCollectNum[article.ArticleId].Pv
+				list[i].IsCollect = mapArticleCollectNum[article.ArticleId].IsCollect
+			}
+		}
+		if item.ArticleTypeId == -1 {
+			list[i].ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
+		}
+		if item.SpecialType == 1 {
+			list[i].Title = "【笔记】"+list[i].Title
+		} else if list[i].SpecialType == 2 {
+			list[i].Title = "【观点】"+list[i].Title
 		}
-		if mapArticleCollectNum[article.ArticleId] != nil {
-			list[i].CollectNum = mapArticleCollectNum[article.ArticleId].CollectNum
-			list[i].Pv = mapArticleCollectNum[article.ArticleId].Pv
-			list[i].IsCollect = mapArticleCollectNum[article.ArticleId].IsCollect
+		if item.MyCollectNum > 0 {
+			list[i].IsCollect = true
 		}
 		//list[i].TitleEn = article.TitleEn
 		//list[i].UpdateFrequency = article.UpdateFrequency

+ 1017 - 0
controllers/yanxuan_special.go

@@ -0,0 +1,1017 @@
+package controllers
+
+import (
+	"encoding/json"
+	"github.com/medivhzhan/weapp/v2"
+	"github.com/rdlucklib/rdluck_tools/file"
+	"github.com/rdlucklib/rdluck_tools/http"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/services"
+	"hongze/hongze_clpt/utils"
+	"os"
+	"time"
+)
+
+type YanxuanSpecialController struct {
+	BaseAuthController
+}
+
+// @Title 专栏列表
+// @Description 专栏列表
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /list [get]
+func (this *YanxuanSpecialController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	userId, _ := this.GetInt("UserId", 0)
+	var condition string
+	var pars []interface{}
+
+	var specialUser *models.CygxYanxuanSpecialAuthorItem
+	var err error
+	if userId > 0 {
+		condition += ` AND a.user_id = ? `
+		pars = append(pars, userId)
+	}
+
+	specialUser, err = models.GetYanxuanSpecialAuthor(sysUser.UserId, sysUser.UserId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + err.Error()
+		return
+	}
+
+	condition += ` AND a.status = 3 `
+
+	list, tmpErr := models.GetYanxuanSpecialList(sysUser.UserId, condition, pars)
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+	for _, v := range list {
+		hasImg, err := utils.ArticleHasImgUrl(v.Content)
+		if err != nil {
+			return
+		}
+		if hasImg {
+			v.ContentHasImg = 1
+		}
+		if v.DocUrl != "" {
+			var docs []models.Doc
+			err := json.Unmarshal([]byte(v.DocUrl), &docs)
+			if err != nil {
+				br.Msg = "参数解析异常!"
+				br.ErrMsg = "参数解析失败,Err:" + err.Error()
+				return
+			}
+			v.Docs = docs
+		}
+		if v.Type == 1 {
+			v.Title = "【笔记】"+v.Title
+		} else if v.Type == 2 {
+			v.Title = "【观点】"+v.Title
+		}
+		if v.MyCollectNum > 0 {
+			v.IsCollect = 1
+		}
+	}
+	resp := new(models.SpecialListResp)
+
+	if specialUser != nil {
+		resp.IsAuthor = true
+	}
+	resp.List = list
+
+	br.Data = resp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 专栏详情
+// @Description 专栏详情
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /detail [get]
+func (this *YanxuanSpecialController) Detail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	specialId, _ := this.GetInt("Id", 0)
+
+	if specialId <= 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误"
+		return
+	}
+
+	item, tmpErr := models.GetYanxuanSpecialById(specialId, sysUser.UserId)
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+	if item.MyCollectNum > 0 {
+		item.IsCollect = 1
+	}
+
+	var resp models.CygxYanxuanSpecialResp
+	resp.CygxYanxuanSpecialItem = *item
+	if item.DocUrl != "" {
+		var docs []models.Doc
+		err := json.Unmarshal([]byte(item.DocUrl), &docs)
+		if err != nil {
+			br.Msg = "参数解析异常!"
+			br.ErrMsg = "参数解析失败,Err:" + err.Error()
+			return
+		}
+		resp.Docs = docs
+	}
+
+	go services.AddSpecialRecord(this.User, specialId)
+
+	br.Data = resp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 新增保存专栏作者详情
+// @Description 新增保存专栏作者详情
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /author/save [post]
+func (this *YanxuanSpecialController) AuthorSave() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req models.SaveCygxYanxuanSpecialAuthorReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.UserId <= 0 {
+		br.Msg = "用户id有误"
+		return
+	}
+	if req.SpecialName == "" {
+		br.Msg = "请输入专栏名称"
+		return
+	}
+	if req.NickName == "" {
+		br.Msg = "请输入昵称"
+		return
+	}
+
+	item := models.CygxYanxuanSpecialAuthor{
+		UserId:       req.UserId,
+		SpecialName:  req.SpecialName,
+		Introduction: req.Introduction,
+		Label:        req.Label,
+		NickName:     req.NickName,
+		CreateTime:   time.Now(),
+		ModifyTime:   time.Now(),
+		BgImg:        "",
+		Status:       1,
+	}
+
+	//if req.Id == 0{
+	//	_, err = models.AddCygxYanxuanSpecialAuthor(&item)
+	//	if err != nil {
+	//		br.Msg = "新增失败"
+	//		br.ErrMsg = "新增失败,Err:" + err.Error()
+	//		return
+	//	}
+	//} else {
+	//	err = models.UpdateYanxuanSpecialAuthor(&item)
+	//	if err != nil {
+	//		br.Msg = "保存失败"
+	//		br.ErrMsg = "保存失败,Err:" + err.Error()
+	//		return
+	//	}
+	//}
+	err = models.UpdateYanxuanSpecialAuthor(&item)
+	if err != nil {
+		br.Msg = "保存失败"
+		br.ErrMsg = "保存失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "保存成功"
+}
+
+// @Title 新增保存专栏
+// @Description 新增保存专栏
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /save [post]
+func (this *YanxuanSpecialController) Save() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req models.CygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Content == "" && req.DoType == 2 {
+		br.Msg = "请输入内容"
+		return
+	}
+	if req.Tags == "" && req.DoType == 2 {
+		br.Msg = "请至少输入一个标签"
+		return
+	}
+
+	item := models.CygxYanxuanSpecial{
+		Id:          req.Id,
+		UserId:      sysUser.UserId,
+		CreateTime:  time.Now(),
+		ModifyTime:  time.Now(),
+		PublishTime: time.Now(),
+		Content:     req.Content,
+		Tags:        req.Tags,
+		ImgUrl:      req.ImgUrl,
+		DocUrl:      req.DocUrl,
+		Title:       req.Title,
+		Type:        req.Type,
+	}
+	if req.DoType == 1 {
+		item.Status = 1
+	} else {
+		item.Status = 2
+	}
+
+	if req.Id == 0 {
+		_, err = models.AddCygxYanxuanSpecial(&item)
+		if err != nil {
+			br.Msg = "新增失败"
+			br.ErrMsg = "新增失败,Err:" + err.Error()
+			return
+		}
+	} else {
+		err = models.UpdateYanxuanSpecial(&item)
+		if err != nil {
+			br.Msg = "保存失败"
+			br.ErrMsg = "保存失败,Err:" + err.Error()
+			return
+		}
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "保存成功"
+}
+
+// @Title 专栏作者详情
+// @Description 专栏作者详情
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /author/detail [get]
+func (this *YanxuanSpecialController) AuthorDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	userId, _ := this.GetInt("UserId", 0)
+	if userId == 0 {
+		userId = sysUser.UserId
+	}
+	item, tmpErr := models.GetYanxuanSpecialAuthor(userId, sysUser.UserId)
+	if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Data = item
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 审批研选专栏
+// @Description 审批研选专栏
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /enable [post]
+func (this *YanxuanSpecialController) Enable() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.EnableCygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Id <= 0 {
+		br.Msg = "文章id错误"
+		return
+	}
+	if req.Status <= 0 {
+		br.Msg = "参数错误"
+		return
+	}
+	status := 0
+	if req.Status == 1 {
+		status = 3
+	} else {
+		status = 4
+	}
+	if tmpErr := models.EnableYanxuanSpecial(req.Id, status, req.Reason); tmpErr != nil {
+		br.Msg = "审批失败"
+		br.ErrMsg = "审批失败, Err:" + tmpErr.Error()
+		return
+	}
+	if req.Status == 1 {
+		go services.SendWxMsgSpecialFollow(req.Id)
+	}
+	br.Msg = "审批成功"
+	br.Ret = 200
+	br.Success = true
+}
+
+// @Title 研选专栏收藏
+// @Description 研选专栏收藏
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /collect [post]
+func (this *YanxuanSpecialController) Collect() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.CollectCygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Id <= 0 {
+		br.Msg = "文章id错误"
+		return
+	}
+	if req.Status <= 0 {
+		br.Msg = "参数错误"
+		return
+	}
+	var sellerName string
+	sellerName, err = models.GetCompanySellerName(sysUser.CompanyId)
+	if err != nil {
+		br.Msg = "报名失败!"
+		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		return
+	}
+	if req.Status == 1 {
+		item := models.CygxYanxuanSpecialCollect{
+			UserId:           sysUser.UserId,
+			Mobile:           sysUser.Mobile,
+			Email:            sysUser.Email,
+			CompanyId:        sysUser.CompanyId,
+			CompanyName:      sysUser.CompanyName,
+			RealName:         sysUser.RealName,
+			SellerName:       sellerName,
+			CreateTime:       time.Now(),
+			ModifyTime:       time.Now(),
+			RegisterPlatform: utils.REGISTER_PLATFORM,
+			YanxuanSpecialId: req.Id,
+		}
+		_, err = models.AddCygxYanxuanSpecialCollect(&item)
+		if err != nil {
+			br.Msg = "新增失败"
+			br.ErrMsg = "新增失败,Err:" + err.Error()
+			return
+		}
+		br.Msg = "收藏成功"
+	} else {
+		err = models.DelCygxYanxuanSpecialCollect(sysUser.UserId, req.Id)
+		if err != nil {
+			br.Msg = "删除失败"
+			br.ErrMsg = "删除失败,Err:" + err.Error()
+			return
+		}
+		br.Msg = "取消收藏成功"
+	}
+
+	br.Ret = 200
+	br.Success = true
+}
+
+// @Title 专栏内容中心
+// @Description 专栏内容中心
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /center [get]
+func (this *YanxuanSpecialController) Center() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	// 1:未发布,2:审核中 3:已发布 4:驳回
+	status, _ := this.GetInt("Status", 0)
+
+	if status <= 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误"
+		return
+	}
+
+	var condition string
+	var pars []interface{}
+
+	condition += ` AND a.user_id = ? `
+	pars = append(pars, sysUser.UserId)
+
+	condition += ` AND a.status = ? `
+	pars = append(pars, status)
+
+	list, tmpErr := models.GetYanxuanSpecialList(sysUser.UserId, condition, pars)
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Data = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 专栏点击记录
+// @Description 专栏点击记录
+// @Param	request	body models.AddCygxReportSelectionSubjectHistoryReq true "type json string"
+// @router /record [post]
+func (this *YanxuanSpecialController) Record() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	var req models.AddCygxYanxuanSpecialRecordReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.SpecialId <= 0 {
+		br.Msg = "文章不存在"
+		br.ErrMsg = "文章不存在,文章ID错误"
+		return
+	}
+	var sellerName string
+	sellerName, err = models.GetCompanySellerName(user.CompanyId)
+	if err != nil {
+		br.Msg = "报名失败!"
+		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		return
+	}
+	item := models.CygxYanxuanSpecialRecord{
+		UserId:           user.UserId,
+		Mobile:           user.Mobile,
+		Email:            user.Email,
+		CompanyId:        user.CompanyId,
+		CompanyName:      user.CompanyName,
+		RealName:         user.RealName,
+		SellerName:       sellerName,
+		CreateTime:       time.Now(),
+		ModifyTime:       time.Now(),
+		RegisterPlatform: utils.REGISTER_PLATFORM,
+		YanxuanSpecialId: req.SpecialId,
+	}
+	_, err = models.AddCygxYanxuanSpecialRecord(&item)
+	if err != nil {
+		br.Msg = "记录失败"
+		br.ErrMsg = "记录失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "记录成功"
+}
+
+// @Title 研选专栏关注
+// @Description 研选专栏关注
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /follow [post]
+func (this *YanxuanSpecialController) Follow() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.FollowCygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.FollowUserId <= 0 {
+		br.Msg = "被关注的用户id"
+		return
+	}
+	if req.Status <= 0 {
+		br.Msg = "参数错误"
+		return
+	}
+	var sellerName string
+	sellerName, err = models.GetCompanySellerName(sysUser.CompanyId)
+	if err != nil {
+		br.Msg = "报名失败!"
+		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		return
+	}
+	if req.Status == 1 {
+		item := models.CygxYanxuanSpecialFollow{
+			UserId:           sysUser.UserId,
+			FollowUserId:     req.FollowUserId,
+			Mobile:           sysUser.Mobile,
+			Email:            sysUser.Email,
+			CompanyId:        sysUser.CompanyId,
+			CompanyName:      sysUser.CompanyName,
+			RealName:         sysUser.RealName,
+			SellerName:       sellerName,
+			CreateTime:       time.Now(),
+			ModifyTime:       time.Now(),
+			RegisterPlatform: utils.REGISTER_PLATFORM,
+			YanxuanSpecialId: req.SpecialId,
+		}
+		err = models.AddCygxYanxuanSpecialFollow(&item)
+		if err != nil {
+			br.Msg = "新增失败"
+			br.ErrMsg = "新增失败,Err:" + err.Error()
+			return
+		}
+		br.Msg = "关注成功"
+	} else {
+		err = models.DelCygxYanxuanSpecialFollow(sysUser.UserId, req.FollowUserId)
+		if err != nil {
+			br.Msg = "删除失败"
+			br.ErrMsg = "删除失败,Err:" + err.Error()
+			return
+		}
+		br.Msg = "取消关注成功"
+	}
+
+	br.Ret = 200
+	br.Success = true
+}
+
+// @Title 行业标签搜索
+// @Description 行业标签搜索
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /industrySearch [get]
+func (this *YanxuanSpecialController) IndustrySearch() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	keyword := this.GetString("Keyword")
+
+	list, tmpErr := models.GetYanxuanSpecialIndustry(keyword)
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Data = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 公司标签搜索
+// @Description 公司标签搜索
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /companySearch [get]
+func (this *YanxuanSpecialController) CompanySearch() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	keyword := this.GetString("Keyword")
+
+	if keyword == "" {
+		br.Ret = 200
+		return
+	}
+
+	list, tmpErr := models.GetYanxuanSpecialCompany(keyword)
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Data = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 专栏取消发布
+// @Description 专栏取消发布
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /cancel [post]
+func (this *YanxuanSpecialController) Cancel() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.CancelPublishCygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Id <= 0 {
+		br.Msg = "文章id错误"
+		return
+	}
+
+	if tmpErr := models.CancelPublishYanxuanSpecial(req.Id); tmpErr != nil {
+		br.Msg = "取消发布失败"
+		br.ErrMsg = "取消发布失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Msg = "取消发布成功"
+	br.Ret = 200
+	br.Success = true
+}
+
+// @Title 作者列表
+// @Description 作者列表
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /author/list [get]
+func (this *YanxuanSpecialController) AuthorList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var specialUser *models.CygxYanxuanSpecialAuthorItem
+	var err error
+
+	specialUser, err = models.GetYanxuanSpecialAuthor(sysUser.UserId, sysUser.UserId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + err.Error()
+		return
+	}
+
+	list, tmpErr := models.GetYanxuanSpecialAuthorList()
+	if tmpErr != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	for _, v := range list {
+		if !v.LatestPublishTime.IsZero() {
+			v.LatestPublishDate = v.LatestPublishTime.Format(utils.FormatDate) + "更新"
+		} else {
+			v.LatestPublishDate = v.ModifyTime.Format(utils.FormatDate) + "更新"
+		}
+	}
+	resp := new(models.SpecialAuthorListResp)
+
+	if specialUser != nil {
+		resp.IsAuthor = true
+	}
+	resp.List = list
+
+	br.Data = resp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// @Title 更新作者头像
+// @Description 更新作者头像
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /author/head_img [post]
+func (this *YanxuanSpecialController) AuthorHeadImg() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req models.SaveCygxYanxuanSpecialAuthoHeadImgrReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.UserId <= 0 {
+		br.Msg = "用户id有误"
+		return
+	}
+	if req.HeadImg == "" {
+		br.Msg = "头像图片错误"
+		return
+	}
+
+	item := models.CygxYanxuanSpecialAuthor{
+		UserId: req.UserId,
+		HeadImg:    req.HeadImg,
+	}
+
+	err = models.UpdateYanxuanSpecialAuthorHeadImg(&item)
+	if err != nil {
+		br.Msg = "保存失败"
+		br.ErrMsg = "保存失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "保存成功"
+}
+
+// @Title 删除专栏
+// @Description 删除专栏
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /del [post]
+func (this *YanxuanSpecialController) Delete() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.EnableCygxYanxuanSpecialReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.Id <= 0 {
+		br.Msg = "文章id错误"
+		return
+	}
+
+	if tmpErr := models.DelYanxuanSpecial(req.Id); tmpErr != nil {
+		br.Msg = "删除失败"
+		br.ErrMsg = "删除失败, Err:" + tmpErr.Error()
+		return
+	}
+
+	br.Msg = "删除成功"
+	br.Ret = 200
+	br.Success = true
+}
+
+// @Title 专栏文章敏感词检测
+// @Description 专栏文章敏感词检测
+// @Param	request	body help_doc.AddHelpDocReq true "type json string"
+// @Success 200 {object} models.AddEnglishReportResp
+// @router /check [post]
+func (this *YanxuanSpecialController) Check() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.User
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req models.CygxYanxuanSpecialCheckReq
+	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
+	}
+	itemToken, err := services.WxGetToken()
+	if err != nil {
+		br.Msg = "GetWxAccessToken Err:" + err.Error()
+		return
+	}
+	if itemToken.AccessToken == "" {
+		br.Msg = "accessToken is empty"
+		return
+	}
+
+	suggest := models.WxCheckContent(itemToken.AccessToken,sysUser.OpenId, req.Content)
+	if suggest == "risky" {
+		br.Msg = "文章内容含有违法违规内容"
+		br.ErrMsg = "文章内容含有违法违规内容"
+		return
+	}
+	if len(req.ImgUrl) > 0 {
+		for _, imgUrl := range req.ImgUrl {
+			imgBody, err := http.Get(imgUrl)
+			if err != nil {
+				br.Msg = "图片链接有误"
+				br.ErrMsg = "图片链接有误"
+				return
+			}
+			rnStr := utils.GetRandStringNoSpecialChar(5)
+			savePath := time.Now().Format(utils.FormatDateTimeUnSpace) + rnStr + ".jpg"
+			err = file.SaveFile(imgBody, savePath)
+			if err != nil {
+				br.Msg = "保存图片错误"
+				br.ErrMsg = "保存图片错误"
+				return
+			}
+			res, err := weapp.IMGSecCheck(itemToken.AccessToken, savePath)
+			if err != nil {
+				// 处理一般错误信息
+				br.Msg = "图片内容含有违法违规内容"
+				br.ErrMsg = "图片内容含有违法违规内容"
+				return
+			}
+			if err := res.GetResponseError(); err !=nil {
+				// 处理微信返回错误信息
+				return
+			}
+			err = os.RemoveAll(savePath)
+			if err != nil {
+				return
+			}
+		}
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "校验成功"
+}

+ 18 - 20
models/article.go

@@ -173,6 +173,10 @@ type ArticleCollectionResp struct {
 	IsNeedJump      bool                        `description:"是否需要跳转链接地址"`
 	MyCollectNum    int                         `description:"本人是否收藏数量"`
 	ArticleTypeId   int                         `description:"文章类型ID"`
+	IsSpecial       int                         `description:"是否为研选专栏"`
+	SpecialTags     string                      `description:"研选专栏标签"`
+	UserId          int                         `description:"作者id"`
+	SpecialType     int                         `description:"专栏类型 1:笔记,2:观点"`
 }
 
 // 列表
@@ -364,12 +368,11 @@ func GetCygxCygxArticleListByCondition(articleTypesCond, activityTypesCond, indu
 			artSql += articleTypesCond
 		}
 		err = o.Raw(artSql).QueryRow(&artIds)
-		if err != nil{
+		if err != nil {
 			return
 		}
 	}
 
-
 	actSql += ` WHERE 1=1 `
 	if activityTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
 		if industryStr != "" && subjectNameStr != "" {
@@ -382,7 +385,7 @@ func GetCygxCygxArticleListByCondition(articleTypesCond, activityTypesCond, indu
 			actSql += activityTypesCond
 		}
 		err = o.Raw(actSql).QueryRow(&actIds)
-		if err != nil{
+		if err != nil {
 			return
 		}
 	}
@@ -390,14 +393,14 @@ func GetCygxCygxArticleListByCondition(articleTypesCond, activityTypesCond, indu
 	if strings.Contains(articleTypeStr, "晨会精华") {
 		mmSql += ` WHERE 1=1 `
 		if industryStr != "" && subjectNameStr != "" {
-			mmSql +=  ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
+			mmSql += ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
 		} else if industryStr == "" && subjectNameStr != "" {
 			mmSql += ` AND  cis.subject_name In (` + subjectNameStr + `) `
 		} else if industryStr != "" && subjectNameStr == "" {
 			mmSql += ` AND im.industry_name In (` + industryStr + `) `
 		}
 		err = o.Raw(mmSql).QueryRow(&mmIds)
-		if err != nil{
+		if err != nil {
 			return
 		}
 	}
@@ -405,7 +408,6 @@ func GetCygxCygxArticleListByCondition(articleTypesCond, activityTypesCond, indu
 	return
 }
 
-
 // 单个tag时用,取合集
 func GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityTypesCondSlice, industriesCondSlice, subjectNamesSlice, articleTypeSlice []string) (artIds, actIds, mmIds string, err error) {
 	o := orm.NewOrm()
@@ -416,7 +418,7 @@ func GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityType
 	mmSql := ` SELECT GROUP_CONCAT(DISTINCT mmc.id SEPARATOR ',') AS mm_ids FROM cygx_morning_meeting_review_chapter as mmc `
 
 	for _, s := range industriesCondSlice {
-		if s != ""{
+		if s != "" {
 			artSql += ` INNER JOIN cygx_industrial_article_group_management  AS iam ON iam.article_id = art.article_id 
 				INNER JOIN cygx_industrial_management AS im ON im.industrial_management_id=iam.industrial_management_id  `
 			actSql += ` INNER JOIN cygx_industrial_activity_group_management  AS iam ON iam.activity_id = act.activity_id 
@@ -428,7 +430,7 @@ func GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityType
 		}
 	}
 	for _, s := range subjectNamesSlice {
-		if s != ""{
+		if s != "" {
 			artSql += ` INNER JOIN cygx_industrial_article_group_subject  AS ias ON ias.article_id = art.article_id 
 				INNER JOIN cygx_industrial_subject AS cis ON cis.industrial_subject_id=ias.industrial_subject_id  `
 			actSql += ` INNER JOIN cygx_industrial_activity_group_subject  AS ias ON ias.activity_id = act.activity_id 
@@ -450,7 +452,6 @@ func GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityType
 		subjectNameStr := subjectNamesSlice[i]
 		articleTypeStr := articleTypeSlice[i]
 
-
 		if articleTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
 			if industryStr != "" && subjectNameStr != "" {
 				artSql += articleTypesCond + ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
@@ -462,7 +463,7 @@ func GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityType
 				artSql += articleTypesCond
 			}
 
-			if i == len(articleTypeCondSlice) -1 {
+			if i == len(articleTypeCondSlice)-1 {
 				artSql += `)) `
 			} else {
 				artSql += `) OR (1=1 `
@@ -471,8 +472,6 @@ func GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityType
 			isNeedArt = true
 		}
 
-
-
 		if activityTypesCond != "" || (articleTypesCond == "" && activityTypesCond == "") {
 			if industryStr != "" && subjectNameStr != "" {
 				actSql += activityTypesCond + ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
@@ -484,7 +483,7 @@ func GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityType
 				actSql += activityTypesCond
 			}
 
-			if i == len(articleTypeCondSlice) -1 {
+			if i == len(articleTypeCondSlice)-1 {
 				actSql += `)) `
 			} else {
 				actSql += `) OR (1=1 `
@@ -495,14 +494,14 @@ func GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityType
 
 		if strings.Contains(articleTypeStr, "晨会精华") {
 			if industryStr != "" && subjectNameStr != "" {
-				mmSql +=  ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
+				mmSql += ` AND (im.industry_name In (` + industryStr + `) OR cis.subject_name In (` + subjectNameStr + `) )`
 			} else if industryStr == "" && subjectNameStr != "" {
 				mmSql += ` AND  cis.subject_name In (` + subjectNameStr + `) `
 			} else if industryStr != "" && subjectNameStr == "" {
 				mmSql += ` AND im.industry_name In (` + industryStr + `) `
 			}
 
-			if i == len(articleTypeCondSlice) -1 {
+			if i == len(articleTypeCondSlice)-1 {
 				mmSql += `)) `
 			} else {
 				mmSql += `) OR (1=1 `
@@ -514,23 +513,22 @@ func GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityType
 
 	if isNeedArt {
 		err = o.Raw(artSql).QueryRow(&artIds)
-		if err != nil{
+		if err != nil {
 			return
 		}
 	}
-	if isNeedAct{
+	if isNeedAct {
 		err = o.Raw(actSql).QueryRow(&actIds)
-		if err != nil{
+		if err != nil {
 			return
 		}
 	}
 	if isNeedMm {
 		err = o.Raw(mmSql).QueryRow(&mmIds)
-		if err != nil{
+		if err != nil {
 			return
 		}
 	}
 
-
 	return
 }

+ 180 - 0
models/cygx_yanxuan_special.go

@@ -0,0 +1,180 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecial struct {
+	Id          int       `orm:"column(id);pk"`
+	UserId      int       // 用户ID
+	CreateTime  time.Time // 创建时间
+	ModifyTime  time.Time // 修改时间
+	PublishTime time.Time // 提审过审或驳回时间
+	Content     string    // 内容
+	Tags        string    // 标签
+	Status      int       // 1:未发布,2:审核中 3:已发布 4:驳回
+	ImgUrl      string    // 图片链接
+	DocUrl      string    // 文档链接
+	Reason      string    // 理由
+	Title       string    // 标题
+	Type        int       // 类型1:笔记,2:观点
+}
+
+type CygxYanxuanSpecialItem struct {
+	Id            int    `orm:"column(id);pk"`
+	UserId        int    // 用户ID
+	CreateTime    string // 创建时间
+	ModifyTime    string // 修改时间
+	PublishTime   string // 提审过审或驳回时间
+	Content       string // 内容
+	Tags          string // 标签
+	Status        int    // 1:未发布,2:审核中 3:已发布 4:驳回
+	ImgUrl        string // 图片链接
+	DocUrl        string // 文档链接
+	SpecialName   string // 专栏名称
+	Introduction  string // 介绍
+	Label         string // 标签
+	NickName      string // 昵称
+	RealName      string // 姓名
+	Mobile        string // 手机号
+	HeadImg       string // 头像
+	BgImg         string // 背景图
+	Reason        string // 理由
+	Title         string // 标题
+	Type          int    // 类型1:笔记,2:观点
+	CollectNum    int
+	MyCollectNum  int
+	IsCollect     int
+	ContentHasImg int //正文是否包含图片 1包含 0不包含
+	Docs          []Doc
+}
+
+type CygxYanxuanSpecialResp struct {
+	CygxYanxuanSpecialItem
+	Docs []Doc
+}
+
+type Doc struct {
+	DocName   string
+	DocSuffix string
+	DocUrl    string
+	DocIcon   string
+}
+
+func GetYanxuanSpecialList(userId int, condition string, pars []interface{}) (items []*CygxYanxuanSpecialItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,b.nick_name,b.real_name,b.special_name,
+( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.yanxuan_special_id = a.id  ) AS collect_num,
+( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  AND user_id = ? ) AS my_collect_num 
+FROM cygx_yanxuan_special AS a
+JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id 
+ WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `ORDER BY a.publish_time DESC `
+	_, err = o.Raw(sql, userId, pars).QueryRows(&items)
+	return
+}
+
+type EnableCygxYanxuanSpecialReq struct {
+	Id     int    // 文章id
+	Status int    // 1通过2驳回
+	Reason string //理由
+}
+
+func EnableYanxuanSpecial(id, status int, reason string) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,publish_time=NOW() WHERE id = ? `
+	_, err = o.Raw(sql, status, reason, id).Exec()
+	return
+}
+
+type SpecialListResp struct {
+	List     []*CygxYanxuanSpecialItem
+	IsAuthor bool
+}
+
+func GetYanxuanSpecialById(specialId, userId int) (item *CygxYanxuanSpecialItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,
+b.nick_name,b.real_name,b.special_name,
+( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.yanxuan_special_id = a.id  ) AS collect_num,
+( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  AND user_id = ? ) AS my_collect_num
+FROM cygx_yanxuan_special AS a
+JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id 
+ WHERE a.id=? `
+	err = o.Raw(sql, userId, specialId).QueryRow(&item)
+	return
+}
+
+type CygxYanxuanSpecialReq struct {
+	Id      int    `orm:"column(id);pk"`
+	Content string // 内容
+	Tags    string // 标签
+	DoType  int    // 1保存 2发布
+	ImgUrl  string // 图片链接
+	DocUrl  string // 文档链接
+	Title   string // 标题
+	Type    int    // 类型1:笔记,2:观点
+}
+
+func AddCygxYanxuanSpecial(item *CygxYanxuanSpecial) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+func UpdateYanxuanSpecial(item *CygxYanxuanSpecial) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET title=?,content=?,tags=?,img_url=?,doc_url=?,type=?,status=?,
+	modify_time=NOW(),publish_time=NOW() WHERE id = ? `
+	_, err = o.Raw(sql, item.Title, item.Content, item.Tags, item.ImgUrl, item.DocUrl, item.Type, item.Status, item.Id).Exec()
+	return
+}
+
+func GetYanxuanSpecialIndustry(keyword string) (IndustryNames []string, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	if keyword == "" {
+		sql = `SELECT industry_name FROM cygx_yanxuan_special_industry `
+	} else {
+		sql = `SELECT industry_name FROM cygx_yanxuan_special_industry WHERE industry_name LIKE '%` + keyword + `%' `
+	}
+	_, err = o.Raw(sql).QueryRows(&IndustryNames)
+	return
+}
+
+type CancelPublishCygxYanxuanSpecialReq struct {
+	Id int // 文章id
+}
+
+func CancelPublishYanxuanSpecial(id int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET status=1,publish_time=NOW() WHERE id = ? `
+	_, err = o.Raw(sql, id).Exec()
+	return
+}
+
+type DelCygxYanxuanSpecialReq struct {
+	Id int // 文章id
+}
+
+func DelYanxuanSpecial(id int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `DELETE FROM cygx_yanxuan_special WHERE id = ? `
+	_, err = o.Raw(sql, id).Exec()
+	return
+}
+
+type CygxYanxuanSpecialCheckReq struct {
+	Content string // 内容
+	ImgUrl  []string // 图片
+}

+ 39 - 0
models/cygx_yanxuan_special_collect.go

@@ -0,0 +1,39 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecialCollect struct {
+	CygxYanxuanSpecialCollectId int       `orm:"column(cygx_yanxuan_special_collect_id);pk"`
+	UserId                      int        // 用户ID
+	Mobile                      string     // 手机号
+	Email                       string     // 邮箱
+	CompanyId                   int        // 公司ID
+	CompanyName                 string     // 公司名称
+	RealName                    string     // 用户实际名称
+	SellerName                  string     // 所属销售
+	CreateTime                  time.Time  // 创建时间
+	ModifyTime                  time.Time  // 修改时间
+	RegisterPlatform            int        // 来源 1小程序,2:网页
+	YanxuanSpecialId            int        // cygx_yanxuan_special 表主键ID
+}
+
+func AddCygxYanxuanSpecialCollect(item *CygxYanxuanSpecialCollect) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type CollectCygxYanxuanSpecialReq struct {
+	Id     int    // 文章id
+	Status int    // 1收藏2取消收藏
+}
+
+func DelCygxYanxuanSpecialCollect(userId, articleId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_yanxuan_special_collect WHERE user_id=? AND yanxuan_special_id=? `
+	_, err = o.Raw(sql, userId, articleId).Exec()
+	return
+}

+ 43 - 0
models/cygx_yanxuan_special_company.go

@@ -0,0 +1,43 @@
+package models
+
+import "github.com/beego/beego/v2/client/orm"
+
+type CygxYanxuanSpecialCompany struct {
+	Id        int    `orm:"column(id);pk"`
+	TradeCode string `json:"trade_code"` // 交易代码
+	SecName   string `json:"sec_name"`   // 公司名
+	PyName    string `json:"py_name"`    // 拼音名
+	Region    string `json:"region"`     // 地区
+}
+
+type VmpStocks struct {
+	Code int
+	Msg  string
+	Data []CygxYanxuanSpecialCompany
+}
+
+// 批量添加
+func AddCygxYanxuanSpecialCompanyMulti(items []*CygxYanxuanSpecialCompany) (err error) {
+	o := orm.NewOrm()
+	if len(items) > 0 {
+		//批量添加
+		_, err = o.InsertMulti(len(items), items)
+	}
+	return
+}
+
+func GetYanxuanSpecialCompany(keyword string) (IndustryNames []string, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT sec_name FROM cygx_yanxuan_special_company WHERE sec_name LIKE '%` + keyword + `%' `
+	_, err = o.Raw(sql).QueryRows(&IndustryNames)
+	return
+}
+
+func DelYanxuanSpecialCompany() (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `DELETE FROM cygx_yanxuan_special_company `
+	_, err = o.Raw(sql).Exec()
+	return
+}

+ 57 - 0
models/cygx_yanxuan_special_follow.go

@@ -0,0 +1,57 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecialFollow struct {
+	CygxYanxuanSpecialFollowId int        `orm:"column(cygx_yanxuan_special_follow_id);pk"`
+	UserId                     int        // 用户ID
+	FollowUserId               int        // 被关注用户ID
+	Mobile                     string     // 手机号
+	Email                      string     // 邮箱
+	CompanyId                  int        // 公司ID
+	CompanyName                string     // 公司名称
+	RealName                   string     // 用户实际名称
+	SellerName                 string     // 所属销售
+	CreateTime                 time.Time  // 创建时间
+	ModifyTime                 time.Time  // 修改时间
+	RegisterPlatform           int        // 来源 1小程序,2:网页
+	YanxuanSpecialId           int        // cygx_yanxuan_special 表主键ID
+}
+
+type FollowCygxYanxuanSpecialReq struct {
+	FollowUserId int // 被关注的用户id
+	Status       int // 1关注2取消关注
+	SpecialId    int // 研选专栏Id
+}
+
+func AddCygxYanxuanSpecialFollow(item *CygxYanxuanSpecialFollow) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+func DelCygxYanxuanSpecialFollow(userId, followUserId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_yanxuan_special_follow WHERE user_id=? AND follow_user_id=? `
+	_, err = o.Raw(sql, userId, followUserId).Exec()
+	return
+}
+
+func GetCygxYanxuanSpecialFollowOpenIdList(followUserId int) (items []*OpenIdList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	cr.*,
+	c.user_id 
+FROM
+	user_record AS c
+	INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
+	INNER JOIN cygx_yanxuan_special_follow AS cf ON cf.user_id = c.user_id 
+	AND cf.follow_user_id = ? 
+WHERE
+	create_platform = 4 `
+	_, err = o.Raw(sql, followUserId).QueryRows(&items)
+	return
+}

+ 32 - 0
models/cygx_yanxuan_special_record.go

@@ -0,0 +1,32 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecialRecord struct {
+	CygxYanxuanSpecialRecordId int       `orm:"column(cygx_yanxuan_special_record_id);pk"`
+	UserId                     int       // 用户ID
+	Mobile                     string    // 手机号
+	Email                      string    // 邮箱
+	CompanyId                  int       // 公司ID
+	CompanyName                string    // 公司名称
+	RealName                   string    // 用户实际名称
+	SellerName                 string    // 所属销售
+	CreateTime                 time.Time // 创建时间
+	ModifyTime                 time.Time // 修改时间
+	RegisterPlatform           int       // 来源 1小程序,2:网页
+	YanxuanSpecialId           int       // cygx_yanxuan_special 表主键ID
+	StopTime                   int       // 停留时间
+}
+
+func AddCygxYanxuanSpecialRecord(item *CygxYanxuanSpecialRecord) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type AddCygxYanxuanSpecialRecordReq struct {
+	SpecialId           int `description:"专栏文章id"`
+}

+ 138 - 0
models/cygx_yanxuan_special_user.go

@@ -0,0 +1,138 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxYanxuanSpecialAuthor struct {
+	Id           int       `orm:"column(id);pk"`
+	UserId       int       // 用户ID
+	SpecialName  string    // 专栏名称
+	Introduction string    // 介绍
+	Label        string    // 标签
+	NickName     string    // 昵称
+	RealName     string    // 姓名
+	Mobile       string    // 手机号
+	CreateTime   time.Time // 创建时间
+	ModifyTime   time.Time // 修改时间
+	HeadImg      string    // 头像
+	BgImg        string    // 背景图
+	Status       int       // 1启用2禁用
+}
+
+type CygxYanxuanSpecialAuthorItem struct {
+	Id                int       `orm:"column(id);pk"`
+	UserId            int       // 用户ID
+	SpecialName       string    // 专栏名称
+	Introduction      string    // 介绍
+	Label             string    // 标签
+	NickName          string    // 昵称
+	RealName          string    // 姓名
+	CompanyName       string    // 公司名
+	Mobile            string    // 手机号
+	CreateTime        string    // 创建时间
+	ModifyTime        time.Time    // 修改时间
+	HeadImg           string    // 头像
+	BgImg             string    // 背景图
+	Status            int       // 1启用2禁用
+	CollectNum        int       // 被收藏数
+	FollowNum         int       // 被关注数
+	SpecialArticleNum int       // 文章数
+	LatestPublishTime time.Time // 最近更新时间
+	LatestPublishDate string    // 最近更新时间
+	IsFollow          int       // 是否已关注 1已关注 0 未关注
+}
+
+func AddCygxYanxuanSpecialAuthor(item *CygxYanxuanSpecialAuthor) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type EnableCygxYanxuanSpecialAuthorReq struct {
+	UserId int // 用户ID
+	Status int // 1启用2禁用
+}
+
+// 启用禁用作者
+func EnableYanxuanSpecialAuthor(userId, status int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET status=?,modify_time=NOW() WHERE user_id = ? `
+	_, err = o.Raw(sql, status, userId).Exec()
+	return
+}
+
+func GetYanxuanSpecialAuthor(reqUserId, sysUserId int) (item *CygxYanxuanSpecialAuthorItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT
+	a.*,c.company_name,
+	( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac  INNER JOIN cygx_yanxuan_special as cs ON  ac.yanxuan_special_id = cs.id  WHERE cs.user_id = a.user_id  ) AS collect_num,
+	( SELECT count( 1 ) FROM cygx_yanxuan_special_follow AS cf  WHERE cf.follow_user_id = a.user_id  ) AS follow_num,
+	( SELECT count( 1 ) FROM cygx_yanxuan_special AS ca  WHERE ca.user_id = a.user_id AND ca.status = 3 ) AS special_article_num,
+	( SELECT count( 1 ) FROM cygx_yanxuan_special_follow AS cf  WHERE cf.follow_user_id =? AND cf.user_id = ?  ) AS is_follow 
+FROM
+	cygx_yanxuan_special_author as a
+	INNER JOIN wx_user AS u ON u.user_id = a.user_id
+	INNER JOIN company AS c ON c.company_id = u.company_id WHERE a.user_id=? `
+	err = o.Raw(sql, reqUserId, sysUserId, reqUserId).QueryRow(&item)
+	return
+}
+
+type SaveCygxYanxuanSpecialAuthorReq struct {
+	UserId       int    // 用户ID
+	SpecialName  string // 专栏名称
+	Introduction string // 介绍
+	Label        string // 标签
+	NickName     string // 昵称
+	BgImg        string // 背景图
+}
+
+func UpdateYanxuanSpecialAuthor(item *CygxYanxuanSpecialAuthor) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET special_name=?,introduction=?,label=?,nick_name=?
+	,modify_time=NOW() WHERE user_id = ? `
+	_, err = o.Raw(sql, item.SpecialName, item.Introduction, item.Label, item.NickName, item.UserId).Exec()
+	return
+}
+
+func GetYanxuanSpecialAuthorList() (items []*CygxYanxuanSpecialAuthorItem, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `SELECT
+	a.*,
+	c.company_name,
+	( SELECT publish_time FROM cygx_yanxuan_special WHERE user_id = a.user_id AND STATUS = 3 ORDER BY publish_time DESC LIMIT 1 ) AS latest_publish_time 
+FROM
+	cygx_yanxuan_special_author AS a
+	INNER JOIN wx_user AS u ON u.user_id = a.user_id
+	INNER JOIN company AS c ON c.company_id = u.company_id 
+WHERE
+	a.nick_name <> '' 
+	AND a.STATUS = 1 
+ORDER BY
+	latest_publish_time DESC `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+type SpecialAuthorListResp struct {
+	List     []*CygxYanxuanSpecialAuthorItem
+	IsAuthor bool
+}
+
+type SaveCygxYanxuanSpecialAuthoHeadImgrReq struct {
+	UserId  int    // 用户ID
+	HeadImg string // 头像
+}
+
+func UpdateYanxuanSpecialAuthorHeadImg(item *CygxYanxuanSpecialAuthor) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET head_img=?,modify_time=NOW() WHERE user_id = ? `
+	_, err = o.Raw(sql, item.HeadImg, item.UserId).Exec()
+	return
+}

+ 5 - 0
models/db.go

@@ -77,6 +77,11 @@ func init() {
 		new(CygxTagHistory),
 		new(CygxActivitySpecialMeetingDetail),
 		new(CygxActivityVoiceHistory),
+		new(CygxYanxuanSpecialRecord),
+		new(CygxYanxuanSpecialCollect),
+		new(CygxYanxuanSpecial),
+		new(CygxYanxuanSpecialFollow),
+		new(CygxYanxuanSpecialCompany),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 4 - 0
models/home.go

@@ -75,6 +75,10 @@ type ArticleListResp struct {
 	Resource            int      `description:"来源类型,1:文章、2:产品内测"`
 	Cover               string   `description:"封面图片"`
 	BodyHighlight       []string `description:"搜索高亮展示结果"`
+	IsSpecial           int      `description:"是否为研选专栏"`
+	SpecialTags         string   `description:"研选专栏标签"`
+	UserId              int      `description:"作者id"`
+	SpecialType         int      `description:"专栏类型 1:笔记,2:观点"`
 	List                []*IndustrialManagementIdInt
 }
 

+ 47 - 4
models/report.go

@@ -792,6 +792,13 @@ type ArticleReportBillboardResp struct {
 	Pv             int    `description:"PV"`
 	CollectNum     int    `description:"收藏人数"`
 	Source         int    `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
+	ArticleTypeId   int    `description:"文章类型ID"`
+	ArticleTypeName string `description:"文章类型名称"`
+	IsSpecial       int    `description:"是否为研选专栏"`
+	SpecialTags     string `description:"研选专栏标签"`
+	MyCollectNum    int    `description:"本人是否收藏"`
+	SpecialType     int    `description:"专栏类型 1:笔记,2:观点"`
+	UserId          int    `description:"作者id"`
 	List           []*IndustrialManagementIdInt
 }
 
@@ -823,20 +830,30 @@ type ArticleResearchResp struct {
 	ImgUrlPc        string                       `description:"图片链接"`
 	List            []*IndustrialManagementIdInt `description:"产业列表"`
 	ListSubject     []*IndustrialSubject         `description:"标的列表"`
+	IsSpecial       int                         `description:"是否为研选专栏"`
+	SpecialTags     string                      `description:"研选专栏标签"`
+	UserId          int                         `description:"作者id"`
 }
 
 // 获取数量
-func GetArticleResearchCount(condition string, pars []interface{}) (count int, err error) {
+func GetArticleResearchCount(condition string, pars []interface{},needYanxuanSpecial bool) (count int, err error) {
 	o := orm.NewOrm()
 	sqlCount := `SELECT COUNT( 1 ) AS count FROM
 			cygx_article AS a
 		WHERE
 			1 = 1  AND a.publish_status = 1` + condition
+	if needYanxuanSpecial{
+		sqlCount = `SELECT SUM(count) AS count FROM (`+sqlCount+`
+		UNION ALL
+	SELECT COUNT( 1 ) AS count FROM
+		cygx_yanxuan_special AS a WHERE
+	1 = 1  AND a.status = 3) AS c`
+	}
 	err = o.Raw(sqlCount, pars).QueryRow(&count)
 	return
 }
 
-func GetArticleResearchList(condition string, pars []interface{}, startSize, pageSize, userId int) (items []*ArticleListResp, err error) {
+func GetArticleResearchList(condition string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (items []*ArticleListResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			a.article_id,
@@ -862,8 +879,34 @@ func GetArticleResearchList(condition string, pars []interface{}, startSize, pag
 	if condition != "" {
 		sql += condition
 	}
-	sql += ` GROUP BY a.article_id ORDER  BY   a.publish_date DESC  LIMIT ?,? `
-	_, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
+	if needYanxuanSpecial {
+		sql += `UNION ALL
+	SELECT
+		a.id AS article_id,
+		a.title AS title,
+		date_format( a.publish_time, '%Y-%m-%d' ) AS publish_date,
+		-1 AS article_type_id,
+		b.nick_name AS nick_name,
+		0 AS department_id,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.yanxuan_special_id = a.id  ) AS collect_num,
+		0 AS collect_num_order,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  AND user_id = ? ) AS my_collect_num,
+		1 AS is_special,
+		a.type AS special_type,
+		a.user_id AS user_id,
+		a.tags AS special_tags 
+	FROM
+	cygx_yanxuan_special AS a
+	JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
+	WHERE
+	1 = 1  AND a.status = 3 `
+		sql += ` ORDER  BY publish_date DESC  LIMIT ?,? `
+		_, err = o.Raw(sql, userId, userId, pars, startSize, pageSize).QueryRows(&items)
+	} else {
+		sql += ` ORDER  BY publish_date DESC  LIMIT ?,? `
+		_, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
+	}
 	return
 }
 

+ 54 - 5
models/user.go

@@ -361,16 +361,65 @@ func UpdateUserEmail(email string, userId int) (err error) {
 }
 
 func GetArticleUserCollectCount(userId int) (count int, err error) {
-	sql := `SELECT COUNT(1) AS count FROM cygx_article_collect AS a INNER JOIN cygx_article as art ON art.article_id = a.article_id WHERE a.user_id=? AND art.publish_status = 1  `
-	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
+	sql := `SELECT SUM(count) AS count FROM (
+			SELECT COUNT(1) AS count FROM cygx_article_collect AS a 
+			INNER JOIN cygx_article as art ON art.article_id = a.article_id 
+			WHERE a.user_id=? AND art.publish_status = 1  
+			UNION ALL
+			SELECT COUNT(1) AS count FROM cygx_yanxuan_special_collect AS a
+			INNER JOIN cygx_yanxuan_special as b ON b.id = a.yanxuan_special_id 
+			WHERE a.user_id=? AND b.status = 3) AS c 
+			 `
+	err = orm.NewOrm().Raw(sql, userId, userId).QueryRow(&count)
 	return
 }
 
 func GetArticleUserCollectList(startSize, pageSize, userId int) (items []*ArticleReportBillboardResp, err error) {
-	sql := `SELECT a.* FROM cygx_article_collect AS a INNER JOIN cygx_article as art ON art.article_id = a.article_id
+	sql := `SELECT 
+		a.article_id,
+		art.category_id,
+		'' AS title,
+		'' AS publish_date,
+		'' AS nick_name,
+		0 AS article_type_id,
+		'' AS article_type_name,
+		0 AS is_special,
+		'' AS special_tags,
+		0 AS pv,
+		0 AS collect_num,
+		0 AS my_collect_num,
+		0 AS special_type,
+		a.user_id AS user_id,
+		a.create_time AS create_time 
+			FROM cygx_article_collect AS a 
+			INNER JOIN cygx_article as art ON art.article_id = a.article_id
 			WHERE a.user_id=? 
-           ORDER BY a.create_time DESC LIMIT ?,? `
-	_, err = orm.NewOrm().Raw(sql, userId, startSize, pageSize).QueryRows(&items)
+			UNION ALL
+	SELECT
+		a.id AS article_id,
+		0 AS category_id,
+		a.title AS title,
+		date_format( a.publish_time, '%Y-%m-%d' ) AS publish_date,
+		b.nick_name AS nick_name,
+		-1 AS article_type_id,
+		'' AS article_type_name,
+		1 AS is_special,
+		a.tags AS special_tags,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.yanxuan_special_id = a.id  ) AS collect_num,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  AND user_id = ? ) AS my_collect_num,
+		a.type AS special_type,
+		a.user_id AS user_id,
+		c.create_time AS create_time 
+	FROM
+	cygx_yanxuan_special AS a
+	JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
+	JOIN cygx_yanxuan_special_collect AS c ON a.id = c.yanxuan_special_id
+	WHERE
+	1 = 1  AND a.status = 3	AND c.user_id=? 		
+	ORDER BY create_time DESC 
+LIMIT ?,? `
+	_, err = orm.NewOrm().Raw(sql, userId, userId,userId, startSize, pageSize).QueryRows(&items)
 	return
 }
 

+ 68 - 11
models/wechat.go

@@ -6,6 +6,10 @@ import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/http"
 	"hongze/hongze_clpt/utils"
+	"io/ioutil"
+	netHttp "net/http"
+	"strconv"
+	"strings"
 	"time"
 )
 
@@ -54,17 +58,6 @@ type WxUsers struct {
 	NextOpenid string
 }
 
-type WxCheckContentJson struct {
-	AccessToken  string `json:"access_token"`
-	ExpiresIn    int    `json:"expires_in"`
-	RefreshToken string `json:"refresh_token"`
-	Openid       string `json:"openid"`
-	Unionid      string `json:"unionid"`
-	Scope        string `json:"scope"`
-	Errcode      int    `json:"errcode"`
-	Errmsg       string `json:"errmsg"`
-}
-
 func GetWxAccessToken() (accessTokenStr string, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM wx_token LIMIT 1`
@@ -173,3 +166,67 @@ func GetWxTokenByXzs() (item *WxAccessToken, err error) {
 	}
 	return
 }
+
+type WxCheckContentJson struct {
+	Detail  []WxCheckContentJsonDetail `json:"detail"`
+	Errcode int                        `json:"errcode"`
+	Errmsg  string                     `json:"errmsg"`
+	Result  WxCheckContentJsonResult   `json:"result"`
+}
+
+type WxCheckContentJsonDetail struct {
+	Label    int
+	KeyWord  string
+	Prob     int
+	Strategy string
+	Errcode  int
+}
+type WxCheckContentJsonResult struct {
+	Suggest string
+	Label   int
+}
+
+func WxCheckContent(token, openId, content string) (suggest string) {
+	url := "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" + token
+	fmt.Println(url)
+	//result, err := http.Post(url, content)
+	//if err != nil {
+	//	utils.FileLog.Info("GetUser Err:", err.Error())
+	//	return
+	//}
+	method := "POST"
+	payload := strings.NewReader(`{
+		"openid":"` + openId + `",
+		"scene":` + strconv.Itoa(2) + `,
+		"version":` + strconv.Itoa(2) + `,
+		"content":"` + content + `"
+				}`)
+	client := &netHttp.Client{}
+	req, err := netHttp.NewRequest(method, url, payload)
+	if err != nil {
+		return
+	}
+	req.Header.Add("Content-Type", "application/json")
+	postBody, err := client.Do(req)
+	if err != nil {
+		return
+	}
+	defer postBody.Body.Close()
+	body, err := ioutil.ReadAll(postBody.Body)
+	if err != nil {
+		fmt.Println(err)
+		utils.FileLog.Info(err.Error())
+		return
+	}
+	item := new(WxCheckContentJson)
+	err = json.Unmarshal(body, &item)
+	if err != nil {
+		fmt.Println("Unmarshal Err:", err.Error())
+		return
+	}
+	fmt.Println(item.Result.Label)
+	fmt.Println(item.Result.Suggest)
+	suggest = item.Result.Suggest
+	return
+}
+

+ 162 - 0
routers/commentsRouter.go

@@ -781,6 +781,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ResourceController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ResourceController"],
+        beego.ControllerComments{
+            Method: "FileUpload",
+            Router: `/file/upload`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ResourceController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ResourceController"],
         beego.ControllerComments{
             Method: "Upload",
@@ -916,4 +925,157 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "AuthorDetail",
+            Router: `/author/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "AuthorHeadImg",
+            Router: `/author/head_img`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "AuthorList",
+            Router: `/author/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "AuthorSave",
+            Router: `/author/save`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Cancel",
+            Router: `/cancel`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Center",
+            Router: `/center`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Check",
+            Router: `/check`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Collect",
+            Router: `/collect`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "CompanySearch",
+            Router: `/companySearch`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Delete",
+            Router: `/del`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Detail",
+            Router: `/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Enable",
+            Router: `/enable`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Follow",
+            Router: `/follow`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "IndustrySearch",
+            Router: `/industrySearch`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Record",
+            Router: `/record`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:YanxuanSpecialController"],
+        beego.ControllerComments{
+            Method: "Save",
+            Router: `/save`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
 }

+ 5 - 0
routers/router.go

@@ -144,6 +144,11 @@ func init() {
 				&controllers.TagController{},
 			),
 		),
+		web.NSNamespace("/yanxuan_special",
+			web.NSInclude(
+				&controllers.YanxuanSpecialController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 68 - 0
services/cygx_yanxuan_special.go

@@ -0,0 +1,68 @@
+package services
+
+// 选专栏有新内容审核通过时,给关注此专栏的客户发送模板消息
+func SendWxMsgSpecialFollow(specialId int) (err error) {
+	//var msg string
+	//defer func() {
+	//	if err != nil {
+	//		go utils.SendEmail("发送模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
+	//		go utils.SendAlarmMsg(fmt.Sprint("预报名活动,感兴趣人数满10人时,推送给活动负责人和王芳消息发送失败", activityInfo.ResearchTheme, ", activityId"), 2)
+	//		utils.FileLog.Info("发送模版消息失败,Err:%s", err.Error())
+	//	}
+	//}()
+	//var first string
+	//var keyword1 string
+	//var keyword2 string
+	//var keyword3 string
+	//var keyword4 string
+	//var remark string
+	//
+	//adminUser, e := models.GetSellerByAdminId(activityInfo.AdminId)
+	//if e != nil {
+	//	err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+	//	return
+	//}
+	//cnf, _ := models.GetConfigByCode("tpl_msg")
+	//mobile := adminUser.Mobile + "," + cnf.ConfigValue
+	//
+	//specialSignupList, e := models.GetActivityListSpecialByActivityId(activityId)
+	//if e != nil {
+	//	err = errors.New("GetActivityListSpecialAll, Err: " + e.Error())
+	//	return
+	//}
+	//for _, v := range specialSignupList {
+	//	keyword1 += "【" + v.RealName + "--" + v.CompanyName + "】"
+	//}
+	//openIdList, e := models.GetWxOpenIdByMobileList(mobile)
+	//if e != nil {
+	//	err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+	//	return
+	//}
+	//first = "【" + activityInfo.ResearchTheme + "】已有10人预报名"
+	//keyword3 = "-"
+	//keyword2 = "-"
+	//keyword4 = "【" + activityInfo.ResearchTheme + "】已有10人预报名"
+	//openIdArr := make([]string, 0)
+	//for _, v := range openIdList {
+	//	openIdArr = append(openIdArr, v.OpenId)
+	//}
+	//redirectUrl := utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(activityId)
+	//sendInfo := new(SendWxTemplate)
+	//sendInfo.First = first
+	//sendInfo.Keyword1 = keyword1
+	//sendInfo.Keyword2 = keyword2
+	//sendInfo.Keyword3 = keyword3
+	//sendInfo.Keyword4 = keyword4
+	//sendInfo.Remark = remark
+	//sendInfo.TemplateId = utils.WxMsgTemplateIdAskMsgXzs
+	//sendInfo.RedirectUrl = redirectUrl
+	//sendInfo.RedirectTarget = 3
+	//sendInfo.Resource = strconv.Itoa(activityId)
+	//sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	//sendInfo.OpenIdArr = openIdArr
+	//err = PublicSendTemplateMsg(sendInfo)
+	//if err != nil {
+	//	return
+	//}
+	return
+}

+ 91 - 0
services/cygx_yanxuan_special_company.go

@@ -0,0 +1,91 @@
+package services
+
+import (
+	"context"
+	"encoding/json"
+	"fmt"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+	"io/ioutil"
+	"net/http"
+	"time"
+)
+
+func GetStocksFromVmp(cont context.Context) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go utils.SendAlarmMsg("更新上市公司表失败"+err.Error(), 2)
+		}
+	}()
+	err = models.DelYanxuanSpecialCompany()
+	if err != nil {
+		fmt.Println("获取上市公司信息失败 Err:%s", err.Error())
+		return
+	}
+	getUrl := "https://vmp.hzinsights.com/v2api/articles/stock"
+	result, err := http.Get(getUrl)
+	if err != nil {
+		return
+	}
+	defer result.Body.Close()
+	body, err := ioutil.ReadAll(result.Body)
+	if err != nil {
+		fmt.Println("err:" + err.Error())
+		return
+	}
+	fmt.Println(body)
+	var resp models.VmpStocks
+	err = json.Unmarshal(body, &resp)
+	if err != nil {
+		fmt.Println("获取上市公司信息失败 Err:%s", err.Error())
+		return
+	}
+
+	items := make([]*models.CygxYanxuanSpecialCompany, 0)
+
+
+	for i, _ := range resp.Data {
+		items = append(items, &resp.Data[i])
+		if len(items) > 5000 {
+			err  = models.AddCygxYanxuanSpecialCompanyMulti(items)
+			if err != nil {
+				fmt.Println("AddCygxYanxuanSpecialCompanyMulti Err:%s", err.Error())
+				return
+			}
+			items = []*models.CygxYanxuanSpecialCompany{}
+		}
+	}
+
+	err  = models.AddCygxYanxuanSpecialCompanyMulti(items)
+	if err != nil {
+		fmt.Println("AddCygxYanxuanSpecialCompanyMulti Err:%s", err.Error())
+		return
+	}
+	return
+}
+
+func AddSpecialRecord(user *models.WxUserItem, specialId int) {
+	var sellerName string
+	sellerName, err := models.GetCompanySellerName(user.CompanyId)
+	if err != nil {
+		return
+	}
+	item := models.CygxYanxuanSpecialRecord{
+		UserId:           user.UserId,
+		Mobile:           user.Mobile,
+		Email:            user.Email,
+		CompanyId:        user.CompanyId,
+		CompanyName:      user.CompanyName,
+		RealName:         user.RealName,
+		SellerName:       sellerName,
+		CreateTime:       time.Now(),
+		ModifyTime:       time.Now(),
+		RegisterPlatform: utils.REGISTER_PLATFORM,
+		YanxuanSpecialId: specialId,
+	}
+	_, err = models.AddCygxYanxuanSpecialRecord(&item)
+	if err != nil {
+		return
+	}
+}

+ 35 - 0
services/oss.go

@@ -120,3 +120,38 @@ func UploadFileToAliyun(filename, filepath, savePath string) error {
 	//return path,err
 	return err
 }
+
+// GetCloudDiskResourceFileTypeExtMap 常见文件类型图标
+func GetCloudDiskResourceFileTypeExtMap() map[string]string {
+	return map[string]string{
+		".doc":  "https://hzstatic.hzinsights.com/static/icon/file_type_docx.png",
+		".docx": "https://hzstatic.hzinsights.com/static/icon/file_type_docx.png",
+
+		".pdf": "https://hzstatic.hzinsights.com/static/icon/file_type_pdf.png",
+
+		".ppt":  "https://hzstatic.hzinsights.com/static/icon/file_type_ppt.png",
+		".pptx": "https://hzstatic.hzinsights.com/static/icon/file_type_ppt.png",
+
+		".xls":  "https://hzstatic.hzinsights.com/static/icon/file_type_xlsx.png",
+		".xlsx": "https://hzstatic.hzinsights.com/static/icon/file_type_xlsx.png",
+
+		".jpg":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".jpeg": "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".png":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".bmp":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".svg":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+		".gif":  "https://hzstatic.hzinsights.com/static/icon/file_type_pic.png",
+
+		".mp4":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".wmv":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".mov":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".mpeg": "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".avi":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".flv":  "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".rm":   "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+		".rmvb": "https://hzstatic.hzinsights.com/static/icon/file_type_video.png",
+
+		".mp3": "https://hzstatic.hzinsights.com/static/icon/file_type_audio.png",
+		".wma": "https://hzstatic.hzinsights.com/static/icon/file_type_audio.png",
+	}
+}

+ 13 - 0
utils/common.go

@@ -7,6 +7,7 @@ import (
 	"encoding/hex"
 	"encoding/json"
 	"fmt"
+	"github.com/PuerkitoBio/goquery"
 	"image"
 	"image/png"
 	"math"
@@ -773,3 +774,15 @@ func GetTimeDateRemoveYearAndSecond(strTime string) (dataStr string) {
 	dataStr = dataStr[:len(dataStr)-3]
 	return
 }
+
+func ArticleHasImgUrl(body string) (hasImg bool, err error) {
+	r := strings.NewReader(string(body))
+	doc, err := goquery.NewDocumentFromReader(r)
+	if err != nil {
+		fmt.Println(err)
+	}
+	doc.Find("img").Each(func(i int, s *goquery.Selection) {
+		hasImg = true
+	})
+	return
+}

+ 4 - 0
utils/constants.go

@@ -209,3 +209,7 @@ const (
 	TPL_MSG                     = "tpl_msg"                     //王芳手机号地址参数
 	TPL_MSG_NEI_RONG_ZU         = "tpl_msg_nei_rong_zu"         //内容组四人
 )
+
+const (
+	CYGX_YANXUAN_SPECIAL           = "研选专栏"           //用户阅读数据
+)