123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- package controllers
- import (
- "eta/eta_report/models"
- "eta/eta_report/utils"
- "fmt"
- "strconv"
- "strings"
- )
- // SmartReportController 智能研报
- type SmartReportController struct {
- BaseCommonController
- }
- // Detail
- // @Title 报告详情
- // @Description 报告详情
- // @Param ReportCode query string true "报告唯一编码"
- // @Success 200 {object} models.SmartReportShareDetailResp
- // @router /share/detail [get]
- func (this *SmartReportController) Detail() {
- 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.SmartReportShareDetailResp)
- 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
- }
- resp.Report = models.FormatSmartReport2Item(item)
- if resp.Report.HeadResourceId > 0 {
- headResource, err := models.GetResourceItemById(resp.Report.HeadResourceId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "获取资源库版头失败, Err: " + e.Error()
- return
- }
- resp.Report.HeadImg = headResource.ImgUrl
- resp.Report.HeadStyle = headResource.Style
- }
- if resp.Report.EndResourceId > 0 {
- endResource, err := models.GetResourceItemById(resp.Report.EndResourceId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "获取资源库版头失败, Err: " + e.Error()
- return
- }
- resp.Report.EndImg = endResource.ImgUrl
- resp.Report.EndStyle = endResource.Style
- }
- // 免责声明
- conf, e := models.GetBusinessConf()
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取免责声明失败, Err: " + e.Error()
- return
- }
- if conf[models.BusinessConfDisclaimer] != "" {
- resp.Disclaimer = conf[models.BusinessConfDisclaimer]
- }
- // 研报分享抬头
- if v, ok := conf[models.BusinessConfH5ShareName]; ok {
- resp.H5ShareName = v
- }
- if v, ok := conf[models.BusinessConfH5ReportShareImg]; ok {
- resp.H5ReportShareImg = v
- }
- // 更新pv
- if e = models.UpdateSmartReportPv(item.SmartReportId); e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "更新报告pv失败, Err: " + e.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- 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)
- item, e := models.GetReportByCode(reportCode)
- 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
- }
- date := strings.Replace(item.CreateTime, "-", "", -1)
- dateStr := date[4:9]
- var shareTitle string
- // 研报分享抬头
- if utils.BusinessCode == "E2023080700" || utils.BusinessCode == "E2023080900" || utils.BusinessCode == "E2023080901" {
- shareTitle = "【第" + strconv.Itoa(item.Stage) + "期|FICC】" + item.Title + "(" + dateStr + ")"
- } else {
- shareTitle = "【第" + strconv.Itoa(item.Stage) + "期】" + item.Title + "(" + dateStr + ")"
- }
- if v, ok := conf[models.BusinessConfH5ReportShareImg]; ok {
- resp.H5ReportShareImg = v
- }
- if v, ok := conf[models.BusinessConfH5ShareName]; ok {
- resp.H5ShareName = v
- }
- resp.H5ShareTitle = shareTitle
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // WechatShareOutsideReportDetail
- // @Title 微信分享外部报告详情
- // @Description 微信分享外部报告详情
- // @Param ReportCode query string true "报告唯一编码"
- // @Success 200 {object} models.SmartReportWechatShareDetailResp
- // @router /wechat_share/outside/report/detail [get]
- func (this *SmartReportController) WechatShareOutsideReportDetail() {
- 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)
- item, e := models.GetOutsideReportByReportCode(reportCode)
- 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
- }
- /*
- date := strings.Replace(item.CreateTime, "-", "", -1)
- dateStr := date[4:9]
- var shareTitle string
- // 研报分享抬头
- if utils.BusinessCode == "E2023080700" || utils.BusinessCode == "E2023080900" || utils.BusinessCode == "E2023080901" {
- shareTitle = "【第" + strconv.Itoa(item.Stage) + "期|FICC】" + item.Title + "(" + dateStr + ")"
- } else {
- shareTitle = "【第" + strconv.Itoa(item.Stage) + "期】" + item.Title + "(" + dateStr + ")"
- }*/
- if v, ok := conf[models.BusinessConfH5ReportShareImg]; ok {
- resp.H5ReportShareImg = v
- }
- if v, ok := conf[models.BusinessConfH5ShareName]; ok {
- resp.H5ShareName = v
- }
- resp.H5ShareTitle = item.Title
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|