瀏覽代碼

新增微信分享接口

hongze 7 月之前
父節點
當前提交
7993b9d74b
共有 2 個文件被更改,包括 79 次插入10 次删除
  1. 64 0
      controllers/smart_report.go
  2. 15 10
      models/smart_report.go

+ 64 - 0
controllers/smart_report.go

@@ -4,6 +4,7 @@ import (
 	"eta/eta_report/models"
 	"eta/eta_report/utils"
 	"fmt"
+	"strconv"
 )
 
 // SmartReportController 智能研报
@@ -100,3 +101,66 @@ func (this *SmartReportController) Detail() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// Detail
+// @Title 微信分享详情
+// @Description 微信分享详情
+// @Param   ReportCode	query	string	true	"报告唯一编码"
+// @Success 200 {object} models.SmartReportWechatShareDetailResp
+// @router /wechat_share/detail [get]
+func (this *SmartReportController) WechatShareDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	reportCode := this.GetString("ReportCode")
+	if reportCode == "" {
+		br.Msg = "获取失败"
+		br.ErrMsg = fmt.Sprintf("参数有误, ReportCode: %s", reportCode)
+		return
+	}
+	resp := new(models.SmartReportWechatShareDetailResp)
+
+	reportOB := new(models.SmartReport)
+	cond := ` AND report_code = ?`
+	pars := make([]interface{}, 0)
+	pars = append(pars, reportCode)
+	item, e := reportOB.GetItemByCondition(cond, pars)
+	if e != nil {
+		if e.Error() == utils.ErrNoRow() {
+			br.Msg = "报告不存在, 请刷新页面"
+			return
+		}
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取报告失败, Err: " + e.Error()
+		return
+	}
+	// 免责声明
+	conf, e := models.GetBusinessConf()
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取免责声明失败, Err: " + e.Error()
+		return
+	}
+
+	var shareTitle string
+	// 研报分享抬头
+	if utils.BusinessCode == "E2023080700" || utils.BusinessCode == "E2023080900" || utils.BusinessCode == "E2023080901" {
+		shareTitle = "【第" + strconv.Itoa(item.Stage) + "期|FICC】" + "(" + item.Title + item.CreateTime.Format("0102") + ")"
+	} else {
+		shareTitle = "【第" + strconv.Itoa(item.Stage) + "期】" + "(" + item.Title + item.CreateTime.Format("0102") + ")"
+	}
+	if v, ok := conf[models.BusinessConfH5ReportShareImg]; ok {
+		resp.H5ReportShareImg = v
+	}
+
+	resp.H5ShareTitle = shareTitle
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 15 - 10
models/smart_report.go

@@ -49,11 +49,11 @@ type SmartReport struct {
 	HeadImg             string    `description:"报告头图地址"`
 	EndImg              string    `description:"报告尾图地址"`
 	CanvasColor         string    `description:"画布颜色"`
-	NeedSplice          int     `description:"0-不需要 1-需要"`
-	HeadResourceId      int     `description:"版头资源ID"`
-	EndResourceId       int     `description:"版尾资源ID"`
-	HeadStyle           string  `description:"版头样式"`
-	EndStyle            string  `description:"版尾样式"`
+	NeedSplice          int       `description:"0-不需要 1-需要"`
+	HeadResourceId      int       `description:"版头资源ID"`
+	EndResourceId       int       `description:"版尾资源ID"`
+	HeadStyle           string    `description:"版头样式"`
+	EndStyle            string    `description:"版尾样式"`
 }
 
 func (m *SmartReport) TableName() string {
@@ -132,11 +132,11 @@ type SmartReportItem struct {
 	HeadImg            string  `description:"报告头图地址"`
 	EndImg             string  `description:"报告尾图地址"`
 	CanvasColor        string  `description:"画布颜色"`
-	NeedSplice          int     `description:"0-不需要 1-需要"`
-	HeadResourceId      int     `description:"版头资源ID"`
-	EndResourceId       int     `description:"版尾资源ID"`
-	HeadStyle           string  `description:"版头样式"`
-	EndStyle            string  `description:"版尾样式"`
+	NeedSplice         int     `description:"0-不需要 1-需要"`
+	HeadResourceId     int     `description:"版头资源ID"`
+	EndResourceId      int     `description:"版尾资源ID"`
+	HeadStyle          string  `description:"版头样式"`
+	EndStyle           string  `description:"版尾样式"`
 }
 
 // FormatSmartReport2Item 格式化智能研报数据格式
@@ -217,3 +217,8 @@ func GetResourceItemById(id int) (item *SmartReportResource, err error) {
 	err = o.Raw(sql, id).QueryRow(&item)
 	return
 }
+
+type SmartReportWechatShareDetailResp struct {
+	H5ShareTitle     string `description:"研报分享抬头"`
+	H5ReportShareImg string `description:"研报分享图片"`
+}