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 }