Files
jx-callback/globals/globals.go
2018-11-14 15:42:58 +08:00

65 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package globals
import (
"git.rosy.net.cn/baseapi"
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
_ "github.com/go-sql-driver/mysql" // import your used driver
"go.uber.org/zap"
)
const (
ErrStrAccessDB = "Error when access DB"
DebugStoreID = 100119
DebugJdStoreID = "11738122"
)
var (
ReallyCallPlatformAPI bool
ReallySendWeixinMsg bool
SugarLogger *zap.SugaredLogger
AliKey string
AliSecret string
EnableStore bool
EnableStoreWrite bool
EnableEbaiStoreWrite bool
EnableElmStoreWrite bool
OrderUseNewTable bool
QiniuBucket string
)
func init() {
logs.SetLogFuncCallDepth(3)
beego.BConfig.Log.AccessLogs = true
logger, _ := zap.NewDevelopment()
SugarLogger = logger.Sugar()
baseapi.Init(SugarLogger)
// todo 这里只是临时把这个放这里不然在其它引用globals的地方会导致得不到正确的值
// 但放这里又会导致单元测试的配置不正确,找不到配置文件
Init()
}
func Init() {
ReallySendWeixinMsg = beego.BConfig.RunMode == "prod"
ReallyCallPlatformAPI = true
AliKey = beego.AppConfig.DefaultString("aliKey", "")
AliSecret = beego.AppConfig.DefaultString("aliSecret", "")
EnableStore = beego.AppConfig.DefaultBool("enableStore", false)
EnableStoreWrite = beego.AppConfig.DefaultBool("enableStoreWrite", false)
EnableEbaiStoreWrite = beego.AppConfig.DefaultBool("enableEbaiStoreWrite", false)
EnableElmStoreWrite = beego.AppConfig.DefaultBool("enableElmStoreWrite", false)
if EnableStore {
OrderUseNewTable = beego.AppConfig.DefaultBool("orderUseNewTable", false)
}
QiniuBucket = beego.AppConfig.String("qiniuBucket")
}