wilgx0 hace 4 años
padre
commit
dae70e08d5
Se han modificado 2 ficheros con 46 adiciones y 44 borrados
  1. 7 44
      api/v1/system/sys_init.go
  2. 39 0
      internal/app/system/model/sys_init.go

+ 7 - 44
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"`
-}

+ 39 - 0
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"`
+}