|
@@ -1,7 +1,6 @@
|
|
|
package report
|
|
|
|
|
|
import (
|
|
|
- "encoding/json"
|
|
|
"errors"
|
|
|
logger "eta/eta_mini_ht_api/common/component/log"
|
|
|
"eta/eta_mini_ht_api/common/exception"
|
|
@@ -149,73 +148,14 @@ func matchRiskLevel(userId int, report reportService.ReportDTO) (riskLevelMatch
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func GetReportById(reportId int, login bool, userId int) (report reportService.ReportDTO, err error) {
|
|
|
- report, err = reportService.GetReportById(reportId)
|
|
|
+func GetReportById(reportId int, login bool, userId int) (report *reportService.ReportDTO, err error) {
|
|
|
+ *report, err = reportService.GetReportById(reportId)
|
|
|
if err != nil {
|
|
|
logger.Error("获取研报失败:%v", err)
|
|
|
err = exception.New(exception.GetReportFailed)
|
|
|
return
|
|
|
}
|
|
|
- var status string
|
|
|
- status, report.RiskLevel, err = matchRiskLevel(userId, report)
|
|
|
- if err != nil {
|
|
|
- logger.Error("匹配风险等级失败:%v", err)
|
|
|
- err = exception.New(exception.ReportRiskLevelUnSet)
|
|
|
- return
|
|
|
- }
|
|
|
- var pdfUrl string
|
|
|
- switch report.Source {
|
|
|
- case SourceETA:
|
|
|
- var detail reportService.ETAReportDTO
|
|
|
- detail, err = getETAReportDetail(&report)
|
|
|
- if err != nil {
|
|
|
- logger.Error("获取研报详情失败失败:%v", err)
|
|
|
- err = exception.New(exception.GetReportFailed)
|
|
|
- return
|
|
|
- }
|
|
|
- if !login {
|
|
|
- detail.Content = ""
|
|
|
- report.RiskLevelStatus = RiskLevelUnMatch
|
|
|
- report.Login = false
|
|
|
- } else {
|
|
|
- if status != RiskLevelMatch {
|
|
|
- detail.Content = ""
|
|
|
- }
|
|
|
- report.RiskLevelStatus = status
|
|
|
- report.Login = true
|
|
|
- }
|
|
|
- var jsonStr []byte
|
|
|
- jsonStr, err = json.Marshal(detail)
|
|
|
- if err != nil {
|
|
|
- logger.Error("生成研报详情失败:%v", err)
|
|
|
- err = exception.New(exception.GetReportFailed)
|
|
|
- }
|
|
|
- report.Detail = jsonStr
|
|
|
- return
|
|
|
- case SourceHT:
|
|
|
- pdfUrl, err = getHTReportDetail(&report)
|
|
|
- if err != nil {
|
|
|
- logger.Error("获取研报详情失败失败:%v")
|
|
|
- err = exception.New(exception.GetReportFailed)
|
|
|
- return
|
|
|
- }
|
|
|
- if !login {
|
|
|
- report.PdfUrl = ""
|
|
|
- report.RiskLevelStatus = RiskLevelUnMatch
|
|
|
- report.Login = false
|
|
|
- } else {
|
|
|
- if status == RiskLevelMatch {
|
|
|
- report.PdfUrl = pdfUrl
|
|
|
- }
|
|
|
- report.RiskLevelStatus = status
|
|
|
- report.Login = true
|
|
|
- }
|
|
|
- return
|
|
|
- default:
|
|
|
- logger.Error("不支持的研报来演:%v")
|
|
|
- err = exception.New(exception.GetReportFailed)
|
|
|
- return
|
|
|
- }
|
|
|
+ return DealReportInfo(report, login, userId)
|
|
|
}
|
|
|
|
|
|
func getETAReportDetail(report *reportService.ReportDTO) (etaReport reportService.ETAReportDTO, err error) {
|