瀏覽代碼

Merge branch 'eta/1.2'

hsun 1 年之前
父節點
當前提交
669f1497cc
共有 5 個文件被更改,包括 67 次插入1 次删除
  1. 11 0
      controllers/report_share.go
  2. 44 0
      models/business_conf.go
  3. 8 0
      models/db.go
  4. 2 1
      models/report.go
  5. 2 0
      utils/config.go

+ 11 - 0
controllers/report_share.go

@@ -39,6 +39,17 @@ func (this *ReportShareController) Detail() {
 	report.Content = html.UnescapeString(report.Content)
 
 	resp := new(models.ReportShareDetailResp)
+	// 免责声明
+	conf, e := models.GetBusinessConf()
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取免责声明失败, Err: " + e.Error()
+		return
+	}
+	if conf[models.BusinessConfDisclaimer] != "" {
+		resp.Disclaimer = conf[models.BusinessConfDisclaimer]
+	}
+
 	resp.Report = report
 	br.Ret = 200
 	br.Success = true

+ 44 - 0
models/business_conf.go

@@ -0,0 +1,44 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"html"
+	"time"
+)
+
+const (
+	BusinessConfDisclaimer = "Disclaimer"
+)
+
+// BusinessConf 商户配置表
+type BusinessConf struct {
+	Id         int    `orm:"column(id);pk"`
+	ConfKey    string `description:"配置Key"`
+	ConfVal    string `description:"配置值"`
+	ValType    int    `description:"1-字符串;2-数值;3-字符串数组;4-富文本;"`
+	Necessary  int    `description:"是否必填:0-否;1-是"`
+	Remark     string `description:"备注"`
+	CreateTime time.Time
+}
+
+// GetBusinessConf 获取商家配置
+func GetBusinessConf() (list map[string]string, err error) {
+	list = make(map[string]string)
+
+	var items []*BusinessConf
+	o := orm.NewOrmUsingDB("eta")
+	sql := `SELECT * FROM business_conf`
+	_, err = o.Raw(sql).QueryRows(&items)
+	if err != nil {
+		return
+	}
+
+	for _, v := range items {
+		if v.ValType == 4 {
+			list[v.ConfKey] = html.UnescapeString(v.ConfVal)
+			continue
+		}
+		list[v.ConfKey] = v.ConfVal
+	}
+	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("eta")
+	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"]