hsun 1 год назад
Родитель
Сommit
5d903264a9
5 измененных файлов с 57 добавлено и 1 удалено
  1. 12 0
      controllers/report_share.go
  2. 33 0
      models/business_conf.go
  3. 8 0
      models/db.go
  4. 2 1
      models/report.go
  5. 2 0
      utils/config.go

+ 12 - 0
controllers/report_share.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"hongze/hongze_api/models"
+	"hongze/hongze_api/utils"
 	"html"
 )
 
@@ -39,6 +40,17 @@ func (this *ReportShareController) Detail() {
 	report.Content = html.UnescapeString(report.Content)
 
 	resp := new(models.ReportShareDetailResp)
+	// 免责声明
+	conf, e := models.GetBusinessConf()
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取免责声明失败, Err: " + e.Error()
+		return
+	}
+	if conf != nil {
+		resp.Disclaimer = html.UnescapeString(conf.Disclaimer)
+	}
+
 	resp.Report = report
 	br.Ret = 200
 	br.Success = true

+ 33 - 0
models/business_conf.go

@@ -0,0 +1,33 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+// BusinessConf 商户配置表
+type BusinessConf struct {
+	Id                 int    `orm:"column(id);pk"`
+	CompanyName        string `description:"公司名称"`
+	CompanyWatermark   string `description:"公司水印"`
+	WatermarkChart     int    `description:"是否在研报图表使用水印"`
+	CnPptCoverImgs     string `description:"中文PPT封面图(多图)"`
+	CnPptBackgroundImg string `description:"中文PPT背景图"`
+	CnPptBottomImg     string `description:"中文PPT封底图"`
+	Disclaimer         string `description:"免责声明"`
+	EnPptCoverImgs     string `description:"英文PPT封面图(多图)"`
+	EnPptBackgroundImg string `description:"英文PPT背景图"`
+	EnPptBottomImg     string `description:"英文PPT封底图"`
+	UseXf              int    `description:"是否使用科大讯飞:0-否;1-是"`
+	XfAppid            string `description:"科大讯飞Appid"`
+	XfApiKey           string `description:"科大讯飞ApiKey"`
+	XfApiSecret        string `description:"科大讯飞ApiSecret"`
+	XfVcn              string `description:"科大讯飞Vcn"`
+}
+
+// GetBusinessConf 获取商家配置
+func GetBusinessConf() (item *BusinessConf, err error) {
+	o := orm.NewOrmUsingDB("eta")
+	sql := `SELECT * FROM business_conf LIMIT 1`
+	err = o.Raw(sql).QueryRow(&item)
+	return
+}

+ 8 - 0
models/db.go

@@ -38,6 +38,14 @@ func init() {
 	rddpTrial, _ := orm.GetDB("rddp_trial")
 	rddpTrial.SetConnMaxLifetime(10 * time.Minute)
 
+	// ETA默认库
+	_ = orm.RegisterDataBase("eta", "mysql", utils.MYSQL_URL_ETA)
+	orm.SetMaxIdleConns("eta", 50)
+	orm.SetMaxOpenConns("eta", 100)
+
+	etaDb, _ := orm.GetDB("rddp")
+	etaDb.SetConnMaxLifetime(10 * time.Minute)
+
 	orm.Debug = true
 	orm.DebugLog = orm.NewLog(utils.Binlog)
 

+ 2 - 1
models/report.go

@@ -227,7 +227,8 @@ func GetReportByCode(reportCode string) (item *Report, err error) {
 }
 
 type ReportShareDetailResp struct {
-	Report *Report `description:"报告"`
+	Report     *Report `description:"报告"`
+	Disclaimer string  `description:"免责声明"`
 }
 
 type PcReport struct {

+ 2 - 0
utils/config.go

@@ -15,6 +15,7 @@ var (
 	RunMode        string //运行模式
 	MYSQL_URL      string //数据库连接
 	MYSQL_URL_RDDP string //数据库连接
+	MYSQL_URL_ETA  string
 	//MYSQL_URL_EDB        string
 	MYSQL_URL_RDDP_TRIAL string // ETA试用rddp库
 
@@ -88,6 +89,7 @@ func init() {
 	logs.Info(RunMode + " 模式")
 	MYSQL_URL = config["mysql_url"]
 	MYSQL_URL_RDDP = config["mysql_url_rddp"]
+	MYSQL_URL_ETA = config["mysql_url_eta"]
 	//MYSQL_URL_EDB = config["mysql_url_edb"]
 	MYSQL_URL_RDDP_TRIAL = config["mysql_url_rddp_trial"]