File tree Expand file tree Collapse file tree 3 files changed +7
-1
lines changed Expand file tree Collapse file tree 3 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ system:
5252 env : ' public' # Change to "develop" to skip authentication for development mode
5353 addr : 8888
5454 db-type : " mysql" # support mysql/sqlite
55+ need-init-data : false
5556
5657# captcha configuration
5758captcha :
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ type System struct {
1818 Env string `mapstructure:"env" json:"env" yaml:"env"`
1919 Addr int `mapstructure:"addr" json:"addr" yaml:"addr"`
2020 DbType string `mapstructure:"db-type" json:"dbType" yaml:"db-type"`
21+ NeedInitData bool `mapstructure:"need-init-data" json:"needInitData" yaml:"need-init-data"`
2122}
2223
2324type JWT struct {
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ package main
33import (
44 "gin-vue-admin/core"
55 "gin-vue-admin/global"
6+ "gin-vue-admin/gva/init_data"
7+
68 //"gin-vue-admin/gva/init_data"
79 "gin-vue-admin/initialize"
810 //"runtime"
@@ -25,7 +27,9 @@ func main() {
2527 initialize .Mysql ()
2628 }
2729 initialize .DBTables ()
28- //init_data.InitData() // 打开注释即可初始化数据 使用过后一定要再次注释或删除
30+ if global .GVA_CONFIG .System .NeedInitData {
31+ init_data .InitData () // 通过配置文件初始化数据 默认为 false 首次运行需要将 ./config.yaml中 system下的 need-init-data 修改为true
32+ }
2933 // 程序结束前关闭数据库链接
3034 db , _ := global .GVA_DB .DB ()
3135 defer db .Close ()
You can’t perform that action at this time.
0 commit comments