Finish the Abstract of Config.

This commit is contained in:
zicla
2019-04-28 01:25:31 +08:00
parent cd3b487fa8
commit aaf7578290
24 changed files with 371 additions and 339 deletions

27
code/core/config.go Normal file
View File

@ -0,0 +1,27 @@
package core
const (
//用户身份的cookie字段名
COOKIE_AUTH_KEY = "_ak"
//数据库表前缀 tank200表示当前应用版本是tank:2.0.x版数据库结构发生变化必然是中型升级
TABLE_PREFIX = "tank20_"
//当前版本
VERSION = "2.0.0"
)
type Config interface {
//是否已经安装
IsInstalled() bool
//启动端口
GetServerPort() int
//获取mysql链接
GetMysqlUrl() string
//文件存放路径
GetMatterPath() string
//完成安装过程,主要是要将配置写入到文件中
FinishInstall(mysqlPort int, mysqlHost string, mysqlSchema string, mysqlUsername string, mysqlPassword string)
}

View File

@ -7,6 +7,9 @@ import (
)
type Context interface {
//具备响应http请求的能力
http.Handler
//获取数据库链接
GetDB() *gorm.DB
@ -19,9 +22,6 @@ type Context interface {
//获取全局的ControllerMap
GetControllerMap() map[string]IController
//响应http的能力
ServeHTTP(writer http.ResponseWriter, request *http.Request)
//系统安装成功
InstallOk()

View File

@ -6,5 +6,8 @@ package core
//全局唯一的日志对象(在main函数中初始化)
var LOGGER Logger
//全局唯一配置
var CONFIG Config
//全局唯一的上下文(在main函数中初始化)
var CONTEXT Context