|
@@ -0,0 +1,107 @@
|
|
|
+package business_conf
|
|
|
+
|
|
|
+import (
|
|
|
+ "fmt"
|
|
|
+ "github.com/beego/beego/v2/client/orm"
|
|
|
+ "hongze/hongze_open_api/utils"
|
|
|
+ "html"
|
|
|
+ "strconv"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+var (
|
|
|
+ BusinessConfMap map[string]string
|
|
|
+)
|
|
|
+
|
|
|
+const (
|
|
|
+ BusinessConfIsOpenChartExpired = "IsOpenChartExpired"
|
|
|
+ BusinessConfReportChartExpiredTime = "ReportChartExpiredTime"
|
|
|
+ BusinessConfOssUrlReplace = "OssUrlReplace"
|
|
|
+)
|
|
|
+
|
|
|
+const (
|
|
|
+ BusinessConfReportApproveTypeEta = "eta"
|
|
|
+ BusinessConfReportApproveTypeOther = "other"
|
|
|
+ BusinessConfClientFlagNanHua = "nhqh"
|
|
|
+ BusinessConfEmailClientSmtp = "smtp"
|
|
|
+
|
|
|
+)
|
|
|
+
|
|
|
+
|
|
|
+var FromSceneMap = map[int]string{
|
|
|
+ 1: "SmartReportSheetSize",
|
|
|
+ 2: "ReportSheetSize",
|
|
|
+ 3: "EnReportSheetSize",
|
|
|
+ 4: "CnPptSheetSize",
|
|
|
+ 5: "EnPptSheetSize",
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+type BusinessConf struct {
|
|
|
+ Id int `gorm:"column:id;primaryKey;autoIncrement"`
|
|
|
+ ConfKey string `gorm:"column:conf_key"`
|
|
|
+ ConfVal string `gorm:"column:conf_val"`
|
|
|
+ ValType int `gorm:"column:val_type"`
|
|
|
+ Necessary int `gorm:"column:necessary"`
|
|
|
+ Remark string `gorm:"column:remark"`
|
|
|
+ CreateTime time.Time `gorm:"column:create_time"`
|
|
|
+}
|
|
|
+
|
|
|
+func (m *BusinessConf) TableName() string {
|
|
|
+ return "business_conf"
|
|
|
+}
|
|
|
+
|
|
|
+func (m *BusinessConf) PrimaryId() string {
|
|
|
+ return "id"
|
|
|
+}
|
|
|
+
|
|
|
+func GetBusinessConfByKey(key string) (item *BusinessConf, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("eta")
|
|
|
+ sql := fmt.Sprintf(`SELECT * FROM business_conf WHERE conf_key = ? LIMIT 1`)
|
|
|
+
|
|
|
+ err = o.Raw(sql, key).QueryRow(&item)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func GetBusinessConf() (list map[string]string, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("eta")
|
|
|
+ list = make(map[string]string)
|
|
|
+
|
|
|
+ var items []*BusinessConf
|
|
|
+ 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
|
|
|
+}
|
|
|
+
|
|
|
+func InitBusinessConf() {
|
|
|
+ var e error
|
|
|
+ BusinessConfMap, e = GetBusinessConf()
|
|
|
+ if e != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if BusinessConfMap[BusinessConfReportChartExpiredTime] != "" {
|
|
|
+ reportChartExpiredTime, _ := strconv.Atoi(BusinessConfMap[BusinessConfReportChartExpiredTime])
|
|
|
+ if reportChartExpiredTime <= 0 {
|
|
|
+ reportChartExpiredTime = 30
|
|
|
+ }
|
|
|
+ utils.BusinessConfReportChartExpiredTime = time.Duration(reportChartExpiredTime) * time.Minute
|
|
|
+ } else {
|
|
|
+ utils.BusinessConfReportChartExpiredTime = 30 * time.Minute
|
|
|
+ }
|
|
|
+
|
|
|
+}
|