Browse Source

Merge branch 'refs/heads/eta_2.2.0_document_manage_0919@guomengyuan' into custom

gmy 2 months ago
parent
commit
f267c664e5

+ 88 - 0
controllers/report_share.go

@@ -131,3 +131,91 @@ func (this *ReportShareController) Detail() {
 	br.Msg = "获取成功"
 	br.Msg = "获取成功"
 	br.Data = resp
 	br.Data = resp
 }
 }
+
+// OutSideReportDetail
+// @Title 日评详情
+// @Description 日评详情接口
+// @Param   ReportCode   query   string  true       "报告唯一编码"
+// @Success 200 {object} models.ReportShareDetailResp
+// @router /share/outside/report/detail [get]
+func (this *ReportShareController) OutSideReportDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	reportCode := this.GetString("ReportCode")
+	if reportCode == "" {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,reportCode 为空"
+		return
+	}
+	report, err := models.GetOutsideReportByReportCode(reportCode)
+	if err != nil {
+		br.Msg = "该报告已删除"
+		br.ErrMsg = "获取报告详情失败,Err:" + err.Error()
+		return
+	}
+	report.Content = html.UnescapeString(report.Content)
+
+	attachmentList, err := models.GetOutsideReportAttachmentListByReportId(report.OutsideReportId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取附件列表失败, Err: " + err.Error()
+		return
+	}
+
+	outsideReportBO := models.OutsideReportBO{
+		OutsideReportId: report.OutsideReportId,
+		Source:          report.Source,
+		Title:           report.Title,
+		Abstract:        report.Abstract,
+		ClassifyId:      report.ClassifyId,
+		ClassifyName:    report.ClassifyName,
+		Content:         report.Content,
+		SysUserId:       report.SysUserId,
+		SysUserName:     report.SysUserName,
+		AttachmentList:  attachmentList,
+	}
+
+	resp := new(models.OutsideReportResp)
+	// 免责声明
+	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
+	}
+	if v, ok := conf[models.BusinessConfWatermarkChart]; ok {
+		resp.WatermarkChart = v
+	}
+	if v, ok := conf[models.BusinessConfWatermarkReport]; ok {
+		resp.WatermarkReport = v
+	}
+	// 报告Logo
+	if v, ok := conf[models.BusinessConfReportCenterLogoShow]; ok {
+		if v == `true` {
+			if reportLogo, ok := conf[models.BusinessConfReportLogo]; ok {
+				resp.ReportLogo = reportLogo
+			}
+		}
+	}
+
+	resp.OutsideReportBO = &outsideReportBO
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 65 - 0
controllers/smart_report.go

@@ -167,3 +167,68 @@ func (this *SmartReportController) WechatShareDetail() {
 	br.Msg = "获取成功"
 	br.Msg = "获取成功"
 	br.Data = resp
 	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
+}

+ 75 - 0
models/outside_report.go

@@ -0,0 +1,75 @@
+// @Author gmy 2024/9/19 14:53:00
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type OutsideReport struct {
+	OutsideReportId  int    `orm:"column(outside_report_id);pk" description:"外部报告ID"`
+	Source           int    `orm:"column(source)" description:"来源,1:ETA系统录入;2:API接口录入;3:邮件监听录入"`
+	Title            string `orm:"column(title)" description:"报告标题"`
+	Abstract         string `orm:"column(abstract)" description:"摘要"`
+	ClassifyId       int    `orm:"column(classify_id)" description:"所属分类id"`
+	ClassifyName     string `orm:"column(classify_name)" description:"所属分类名称(整个分类链条)"`
+	Content          string `orm:"column(content)" description:"报告富文本内容"`
+	SysUserId        int    `orm:"column(sys_user_id)" description:"创建人id"`
+	SysUserName      string `orm:"column(sys_user_name)" description:"创建人姓名"`
+	EmailMessageUid  int    `orm:"column(email_message_uid)" description:"该邮件在邮箱中的唯一id"`
+	ReportUpdateTime string `orm:"column(report_update_time)" description:"报告更新时间,如果来源于邮件,那么取邮件的收件时间"`
+	ModifyTime       string `orm:"column(modify_time)" description:"最近一次修改时间"`
+	CreateTime       string `orm:"column(create_time)" description:"创建时间"`
+	ReportCode       string `orm:"column(report_code)" description:"报告唯一编码"`
+}
+
+type OutsideReportBO struct {
+	OutsideReportId int    `orm:"column(outside_report_id);pk" description:"外部报告ID"`
+	Source          int    `orm:"column(source)" description:"来源,1:ETA系统录入;2:API接口录入;3:邮件监听录入"`
+	Title           string `orm:"column(title)" description:"报告标题"`
+	Abstract        string `orm:"column(abstract)" description:"摘要"`
+	ClassifyId      int    `orm:"column(classify_id)" description:"所属分类id"`
+	ClassifyName    string `orm:"column(classify_name)" description:"所属分类名称(整个分类链条)"`
+	Content         string `orm:"column(content)" description:"报告富文本内容"`
+	SysUserId       int    `orm:"column(sys_user_id)" description:"创建人id"`
+	SysUserName     string `orm:"column(sys_user_name)" description:"创建人姓名"`
+	ReportCode      string `orm:"column(report_code)" description:"报告唯一编码"`
+	AttachmentList  []*OutsideReportAttachment
+}
+
+type OutsideReportResp struct {
+	OutsideReportBO  *OutsideReportBO `description:"报告"`
+	Disclaimer       string           `description:"免责声明"`
+	H5ShareName      string           `description:"研报分享抬头"`
+	H5ReportShareImg string           `description:"研报分享图片"`
+	WatermarkChart   string           `description:"图表是否需要水印"`
+	WatermarkReport  string           `description:"报告是否需要水印"`
+	Hz               int
+	ReportLogo       string `description:"报告logo"`
+}
+
+// 在 init 函数中注册模型
+func init() {
+	orm.RegisterModel(new(OutsideReport))
+}
+
+// GetOutsideReportListByConditionCount 根据条件查询列表条数
+func GetOutsideReportListByConditionCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `select count(distinct t1.outside_report_id) from outside_report t1 left join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id  where 1 = 1 `
+	sql += condition
+	err = o.Raw(sql, pars).QueryRow(&count)
+	if err != nil {
+		return 0, err
+	}
+
+	return count, err
+}
+
+// GetOutsideReportByReportCode 根据Code获取报告
+func GetOutsideReportByReportCode(reportCode string) (outsideReport *OutsideReport, err error) {
+	o := orm.NewOrm()
+	
+	sql := `SELECT * FROM outside_report WHERE report_code=?`
+	err = o.Raw(sql, reportCode).QueryRow(&outsideReport)
+	return outsideReport, err
+}

+ 32 - 0
models/outside_report_attachment.go

@@ -0,0 +1,32 @@
+// @Author gmy 2024/9/19 15:13:00
+package models
+
+import "github.com/beego/beego/v2/client/orm"
+
+type OutsideReportAttachment struct {
+	OutsideReportAttachmentId int    `orm:"column(outside_report_attachment_id);pk" description:"外部报告附件ID"`
+	OutsideReportId           int    `orm:"column(outside_report_id)" description:"报告id"`
+	Title                     string `orm:"column(title)" description:"附件名称"`
+	Url                       string `orm:"column(url)" description:"附件地址"`
+	CreateTime                string `orm:"column(create_time)" description:"附件新增时间"`
+	FileSize                  int64  `orm:"column(file_size)" description:"附件大小"`
+}
+
+// 在 init 函数中注册模型
+func init() {
+	orm.RegisterModel(new(OutsideReportAttachment))
+}
+
+// GetOutsideReportAttachmentListByReportId 根据报告id获取附件列表
+func GetOutsideReportAttachmentListByReportId(outsideReportId int) (attachmentList []*OutsideReportAttachment, err error) {
+	o := orm.NewOrm()
+	// 改写成通过ql查询
+	sql := `select * from outside_report_attachment where outside_report_id = ?`
+
+	_, err = o.Raw(sql, outsideReportId).QueryRows(&attachmentList)
+	if err != nil {
+		return nil, err
+	}
+
+	return attachmentList, nil
+}

+ 18 - 0
routers/commentsRouter.go

@@ -52,6 +52,15 @@ func init() {
             Filters: nil,
             Filters: nil,
             Params: nil})
             Params: nil})
 
 
+    beego.GlobalControllerRouter["eta/eta_report/controllers:ReportShareController"] = append(beego.GlobalControllerRouter["eta/eta_report/controllers:ReportShareController"],
+        beego.ControllerComments{
+            Method: "OutSideReportDetail",
+            Router: `/share/outside/report/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_report/controllers:SmartReportController"] = append(beego.GlobalControllerRouter["eta/eta_report/controllers:SmartReportController"],
     beego.GlobalControllerRouter["eta/eta_report/controllers:SmartReportController"] = append(beego.GlobalControllerRouter["eta/eta_report/controllers:SmartReportController"],
         beego.ControllerComments{
         beego.ControllerComments{
             Method: "Detail",
             Method: "Detail",
@@ -70,6 +79,15 @@ func init() {
             Filters: nil,
             Filters: nil,
             Params: nil})
             Params: nil})
 
 
+    beego.GlobalControllerRouter["eta/eta_report/controllers:SmartReportController"] = append(beego.GlobalControllerRouter["eta/eta_report/controllers:SmartReportController"],
+        beego.ControllerComments{
+            Method: "WechatShareOutsideReportDetail",
+            Router: `/wechat_share/outside/report/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_report/controllers:WechatCommonController"] = append(beego.GlobalControllerRouter["eta/eta_report/controllers:WechatCommonController"],
     beego.GlobalControllerRouter["eta/eta_report/controllers:WechatCommonController"] = append(beego.GlobalControllerRouter["eta/eta_report/controllers:WechatCommonController"],
         beego.ControllerComments{
         beego.ControllerComments{
             Method: "GetWxSign",
             Method: "GetWxSign",