From dae70e08d5b1973de7c987a6b9370650a1267823 Mon Sep 17 00:00:00 2001 From: wilgx0 <396861557@qq.com> Date: Mon, 25 Apr 2022 09:29:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/v1/system/sys_init.go | 51 ++++----------------------- internal/app/system/model/sys_init.go | 39 ++++++++++++++++++++ 2 files changed, 46 insertions(+), 44 deletions(-) create mode 100644 internal/app/system/model/sys_init.go diff --git a/api/v1/system/sys_init.go b/api/v1/system/sys_init.go index b4ae1d7..e9255bd 100644 --- a/api/v1/system/sys_init.go +++ b/api/v1/system/sys_init.go @@ -3,6 +3,7 @@ package system import ( "fmt" "github.com/gogf/gf/v2/frame/g" + "github.com/tiger1103/gfast/v3/internal/app/system/model" ) type DbInitIsInitReq struct { @@ -33,10 +34,10 @@ type DbInitCreateDbReq struct { type DbInitCreateDbRes bool -func (req *DbInitCreateDbReq) ToDbInitConfig() *DbInitConfig { - return &DbInitConfig{ - Database: Database{ - Default: DbDefault{ +func (req *DbInitCreateDbReq) ToDbInitConfig() *model.DbInitConfig { + return &model.DbInitConfig{ + Database: model.Database{ + Default: model.DbDefault{ Host: req.DbHost, Port: req.DbPort, User: req.DbUser, @@ -52,8 +53,8 @@ func (req *DbInitCreateDbReq) ToDbInitConfig() *DbInitConfig { MaxLifetime: 10, }, }, - Redis: Redis{ - Default: RedisDefault{ + Redis: model.Redis{ + Default: model.RedisDefault{ Address: fmt.Sprintf("%s:%d", req.RedisAddress, req.RedisPort), Db: req.RedisDb, Pass: req.RedisPass, @@ -63,41 +64,3 @@ func (req *DbInitCreateDbReq) ToDbInitConfig() *DbInitConfig { }, } } - -// 程序初始化yaml配置文件 -type DbInitConfig struct { - Database Database `json:"database" yaml:"database"` - Redis Redis `json:"redis" yaml:"redis"` -} - -type Database struct { - Default DbDefault `json:"default" yaml:"default"` -} - -type DbDefault struct { - Host string `json:"host" yaml:"host"` - Port int `json:"port" yaml:"port"` - User string `json:"user" yaml:"user"` - Pass string `json:"pass" yaml:"pass"` - Name string `json:"name" yaml:"name"` - Type string `json:"type" yaml:"type"` - Role string `json:"role" yaml:"role"` - Debug bool `json:"debug" yaml:"debug"` - Charset string `json:"charset" yaml:"charset"` - DryRun bool `json:"dryRun" yaml:"dryRun"` - MaxIdle int `json:"maxIdle" yaml:"maxIdle"` - MaxOpen int `json:"maxOpen" yaml:"maxOpen"` - MaxLifetime int `json:"maxLifetime" yaml:"maxLifetime"` -} - -type Redis struct { - Default RedisDefault `json:"default" yaml:"default"` -} - -type RedisDefault struct { - Address string `json:"address" yaml:"address"` - Db int `json:"db" yaml:"db"` - Pass string `json:"pass" yaml:"pass"` - IdleTimeout int `json:"idleTimeout" yaml:"idleTimeout"` - MaxActive int `json:"maxActive" yaml:"maxActive"` -} diff --git a/internal/app/system/model/sys_init.go b/internal/app/system/model/sys_init.go new file mode 100644 index 0000000..91cb6ff --- /dev/null +++ b/internal/app/system/model/sys_init.go @@ -0,0 +1,39 @@ +package model + +// 程序初始化yaml配置文件 +type DbInitConfig struct { + Database Database `json:"database" yaml:"database"` + Redis Redis `json:"redis" yaml:"redis"` +} + +type Database struct { + Default DbDefault `json:"default" yaml:"default"` +} + +type DbDefault struct { + Host string `json:"host" yaml:"host"` + Port int `json:"port" yaml:"port"` + User string `json:"user" yaml:"user"` + Pass string `json:"pass" yaml:"pass"` + Name string `json:"name" yaml:"name"` + Type string `json:"type" yaml:"type"` + Role string `json:"role" yaml:"role"` + Debug bool `json:"debug" yaml:"debug"` + Charset string `json:"charset" yaml:"charset"` + DryRun bool `json:"dryRun" yaml:"dryRun"` + MaxIdle int `json:"maxIdle" yaml:"maxIdle"` + MaxOpen int `json:"maxOpen" yaml:"maxOpen"` + MaxLifetime int `json:"maxLifetime" yaml:"maxLifetime"` +} + +type Redis struct { + Default RedisDefault `json:"default" yaml:"default"` +} + +type RedisDefault struct { + Address string `json:"address" yaml:"address"` + Db int `json:"db" yaml:"db"` + Pass string `json:"pass" yaml:"pass"` + IdleTimeout int `json:"idleTimeout" yaml:"idleTimeout"` + MaxActive int `json:"maxActive" yaml:"maxActive"` +}