Files
jx-callback/globals/globals.go

59 lines
1.4 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"
"go.uber.org/zap"
)
const (
ErrStrAccessDB = "Error when access DB"
)
var (
CallLegacyMsgHandler bool
CallNewMsgHandler bool
GenerateLegacyJxOrder bool
ReallyCallPlatformAPI bool
SugarLogger *zap.SugaredLogger
JxorderTableName string
JxorderskuTableName string
ElemeorderTableName string
JdorderTableName 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() {
CallLegacyMsgHandler = beego.AppConfig.DefaultBool("callLegacyMsgHandler", true)
CallNewMsgHandler = beego.AppConfig.DefaultBool("callNewMsgHandler", false)
GenerateLegacyJxOrder = beego.AppConfig.DefaultBool("generateLegacyJxOrder", false)
ReallyCallPlatformAPI = !CallLegacyMsgHandler
if ReallyCallPlatformAPI {
JxorderTableName = "jxorder"
JxorderskuTableName = "jxordersku"
ElemeorderTableName = "elemeorder"
JdorderTableName = "jdorder"
} else {
JxorderTableName = "jxorder2"
JxorderskuTableName = "jxordersku2"
ElemeorderTableName = "elemeorder2"
JdorderTableName = "jdorder2"
}
}