-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into i18n-dev-new
- Loading branch information
Showing
43 changed files
with
610 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package config | ||
|
||
import ( | ||
"path/filepath" | ||
) | ||
|
||
type Sqlite struct { | ||
GeneralDB `yaml:",inline" mapstructure:",squash"` | ||
} | ||
|
||
func (s *Sqlite) Dsn() string { | ||
return filepath.Join(s.Path, s.Dbname+".db") | ||
} | ||
|
||
func (s *Sqlite) GetLogMode() string { | ||
return s.LogMode | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package initialize | ||
|
||
import ( | ||
"github.com/flipped-aurora/gin-vue-admin/server/config" | ||
"github.com/flipped-aurora/gin-vue-admin/server/global" | ||
"github.com/flipped-aurora/gin-vue-admin/server/initialize/internal" | ||
"github.com/glebarez/sqlite" | ||
"gorm.io/gorm" | ||
) | ||
|
||
// GormSqlite 初始化Sqlite数据库 | ||
func GormSqlite() *gorm.DB { | ||
s := global.GVA_CONFIG.Sqlite | ||
if s.Dbname == "" { | ||
return nil | ||
} | ||
|
||
if db, err := gorm.Open(sqlite.Open(s.Dsn()), internal.Gorm.Config(s.Prefix, s.Singular)); err != nil { | ||
panic(err) | ||
} else { | ||
sqlDB, _ := db.DB() | ||
sqlDB.SetMaxIdleConns(s.MaxIdleConns) | ||
sqlDB.SetMaxOpenConns(s.MaxOpenConns) | ||
return db | ||
} | ||
} | ||
|
||
// GormSqliteByConfig 初始化Sqlite数据库用过传入配置 | ||
func GormSqliteByConfig(s config.Sqlite) *gorm.DB { | ||
if s.Dbname == "" { | ||
return nil | ||
} | ||
|
||
if db, err := gorm.Open(sqlite.Open(s.Dsn()), internal.Gorm.Config(s.Prefix, s.Singular)); err != nil { | ||
panic(err) | ||
} else { | ||
sqlDB, _ := db.DB() | ||
sqlDB.SetMaxIdleConns(s.MaxIdleConns) | ||
sqlDB.SetMaxOpenConns(s.MaxOpenConns) | ||
return db | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.