Files
jx-callback/globals/globals.go
2018-09-05 18:03:53 +08:00

63 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"
"git.rosy.net.cn/jx-callback/business/jxutils/cache"
"git.rosy.net.cn/jx-callback/business/jxutils/cache/redis"
"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"
)
var (
GenerateLegacyJxOrder bool
ReallyCallPlatformAPI bool
ReallySendWeixinMsg bool
SugarLogger *zap.SugaredLogger
JxorderTableName string
JxorderskuTableName string
ElemeorderTableName string
JdorderTableName string
Cacher cache.ICacher
AliKey string
AliSecret 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
GenerateLegacyJxOrder = beego.AppConfig.DefaultBool("generateLegacyJxOrder", false)
JxorderTableName = "jxorder"
JxorderskuTableName = "jxordersku"
ElemeorderTableName = "elemeorder"
JdorderTableName = "jdorder"
Cacher = redis.New(beego.AppConfig.DefaultString("redisHost", "localhost"), beego.AppConfig.DefaultInt("redisPort", 0), beego.AppConfig.DefaultString("redisPassword", ""))
AliKey = beego.AppConfig.DefaultString("aliKey", "")
AliSecret = beego.AppConfig.DefaultString("aliSecret", "")
}