mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-20 17:57:54 +00:00
结构调整添加cmd
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
package config
|
||||
|
||||
import "github.com/spf13/viper"
|
||||
|
||||
type Application struct {
|
||||
IsInit bool
|
||||
ReadTimeout int
|
||||
WriterTimeout int
|
||||
Host string
|
||||
Port string
|
||||
Name string
|
||||
JwtSecret string
|
||||
LogPath string
|
||||
Env string
|
||||
EnvMsg string
|
||||
}
|
||||
|
||||
func InitApplication(cfg *viper.Viper) *Application {
|
||||
return &Application{
|
||||
IsInit: cfg.GetBool("isInit"),
|
||||
ReadTimeout: cfg.GetInt("readTimeout"),
|
||||
WriterTimeout: cfg.GetInt("writerTimeout"),
|
||||
Host: cfg.GetString("host"),
|
||||
Port: cfg.GetString("port"),
|
||||
Name: cfg.GetString("name"),
|
||||
JwtSecret: cfg.GetString("jwtSecret"),
|
||||
LogPath: cfg.GetString("logPath"),
|
||||
Env: cfg.GetString("env"),
|
||||
EnvMsg: cfg.GetString("envMsg"),
|
||||
}
|
||||
}
|
||||
|
||||
var ApplicationConfig = new(Application)
|
||||
@@ -1,47 +0,0 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/spf13/viper"
|
||||
"log"
|
||||
)
|
||||
|
||||
var cfgDatabase *viper.Viper
|
||||
var cfgApplication *viper.Viper
|
||||
var cfgJwt *viper.Viper
|
||||
|
||||
func init() {
|
||||
viper.SetConfigName("settings")
|
||||
viper.AddConfigPath("./config")
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
cfgDatabase = viper.Sub("settings.database")
|
||||
if cfgDatabase == nil {
|
||||
panic("config not found settings.database")
|
||||
}
|
||||
DatabaseConfig = InitDatabase(cfgDatabase)
|
||||
|
||||
cfgApplication = viper.Sub("settings.application")
|
||||
if cfgApplication == nil {
|
||||
panic("config not found settings.application")
|
||||
}
|
||||
ApplicationConfig = InitApplication(cfgApplication)
|
||||
|
||||
cfgJwt = viper.Sub("settings.jwt")
|
||||
if cfgJwt == nil {
|
||||
panic("config not found settings.jwt")
|
||||
}
|
||||
JwtConfig = InitJwt(cfgJwt)
|
||||
}
|
||||
|
||||
func SetApplicationIsInit() {
|
||||
SetConfig("./config","settings.application.isInit", false)
|
||||
}
|
||||
|
||||
func SetConfig(configPath string,key string,value interface{}){
|
||||
viper.AddConfigPath(configPath)
|
||||
viper.Set(key, value)
|
||||
viper.WriteConfig()
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package config
|
||||
|
||||
import "github.com/spf13/viper"
|
||||
|
||||
type Database struct {
|
||||
Dbtype string
|
||||
Host string
|
||||
Port int
|
||||
Database string
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
|
||||
func InitDatabase(cfg *viper.Viper) *Database {
|
||||
return &Database{
|
||||
Port: cfg.GetInt("port"),
|
||||
Dbtype: cfg.GetString("dbType"),
|
||||
Host: cfg.GetString("host"),
|
||||
Database: cfg.GetString("database"),
|
||||
Username: cfg.GetString("username"),
|
||||
Password: cfg.GetString("password"),
|
||||
}
|
||||
}
|
||||
|
||||
var DatabaseConfig = new(Database)
|
||||
@@ -1,19 +0,0 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
type Jwt struct {
|
||||
Secret string
|
||||
Timeout int64
|
||||
}
|
||||
|
||||
func InitJwt(cfg *viper.Viper) *Jwt {
|
||||
return &Jwt{
|
||||
Secret: cfg.GetString("secret"),
|
||||
Timeout: cfg.GetInt64("timeout"),
|
||||
}
|
||||
}
|
||||
|
||||
var JwtConfig = new(Jwt)
|
||||
@@ -1,75 +0,0 @@
|
||||
p, admin, /api/v1/menulist, GET
|
||||
p, admin, /api/v1/menu, POST
|
||||
p, admin, /api/v1/dict/databytype/, GET
|
||||
p, admin, /api/v1/menu/, PUT
|
||||
p, admin, /api/v1/menu/, DELETE
|
||||
p, admin, /api/v1/sysUserList, GET
|
||||
p, admin, /api/v1/sysUser/:id, GET
|
||||
p, admin, /api/v1/sysUser/, GET
|
||||
p, admin, /api/v1/sysUser, POST
|
||||
p, admin, /api/v1/sysUser, PUT
|
||||
p, admin, /api/v1/sysUser/:id, DELETE
|
||||
p, admin, /api/v1/user/profile, GET
|
||||
p, admin, /api/v1/rolelist, GET
|
||||
p, admin, /api/v1/role/:id, GET
|
||||
p, admin, /api/v1/role, POST
|
||||
p, admin, /api/v1/role, PUT
|
||||
p, admin, /api/v1/role/:id, DELETE
|
||||
p, admin, /api/v1/configList, GET
|
||||
p, admin, /api/v1/config/:id, GET
|
||||
p, admin, /api/v1/configKey/:id, GET
|
||||
p, admin, /api/v1/config, POST
|
||||
p, admin, /api/v1/config/, PUT
|
||||
p, admin, /api/v1/config/:id, DELETE
|
||||
p, admin, /api/v1/menurole, GET
|
||||
p, admin, /api/v1/roleMenuTreeselect/:id, GET
|
||||
p, admin, /api/v1/menuTreeselect, GET
|
||||
p, admin, /api/v1/rolemenu, GET
|
||||
p, admin, /api/v1/rolemenu, POST
|
||||
p, admin, /api/v1/rolemenu/:id, DELETE
|
||||
p, admin, /api/v1/doctor, GET
|
||||
p, admin, /api/v1/doctor, POST
|
||||
p, admin, /api/v1/doctor/:id, PUT
|
||||
p, admin, /api/v1/doctor/:id, DELETE
|
||||
p, admin, /api/v1/doctor/pic/, POST
|
||||
p, admin, /api/v1/deptList, GET
|
||||
p, admin, /api/v1/dept/:id, GET
|
||||
p, admin, /api/v1/dept, POST
|
||||
p, admin, /api/v1/dept, PUT
|
||||
p, admin, /api/v1/dept/:id, DELETE
|
||||
p, admin, /api/v1/dict/datalist, GET
|
||||
p, admin, /api/v1/dict/data/:id, GET
|
||||
p, admin, /api/v1/dict/databytype/:id, GET
|
||||
p, admin, /api/v1/dict/data, POST
|
||||
p, admin, /api/v1/dict/data/, PUT
|
||||
p, admin, /api/v1/dict/data/:id, DELETE
|
||||
p, admin, /api/v1/dict/typelist, GET
|
||||
p, admin, /api/v1/dict/type/:id, GET
|
||||
p, admin, /api/v1/dict/type, POST
|
||||
p, admin, /api/v1/dict/type, PUT
|
||||
p, admin, /api/v1/dict/type/:id, DELETE
|
||||
p, admin, /api/v1/postlist, GET
|
||||
p, admin, /api/v1/post/:id, GET
|
||||
p, admin, /api/v1/post, POST
|
||||
p, admin, /api/v1/post, PUT
|
||||
p, admin, /api/v1/post/:id, DELETE
|
||||
p, admin, /api/v1/calendar, GET
|
||||
p, admin, /api/v1/calendar, POST
|
||||
p, admin, /api/v1/calendar/:id, PUT
|
||||
p, admin, /api/v1/calendar/:id, DELETE
|
||||
p, admin, /api/v1/member, GET
|
||||
p, admin, /api/v1/member, POST
|
||||
p, admin, /api/v1/member/:id, PUT
|
||||
p, admin, /api/v1/member/:id, DELETE
|
||||
p, admin, /api/v1/orders, GET
|
||||
p, admin, /api/v1/orders/:id, GET
|
||||
p, admin, /api/v1/orders, POST
|
||||
p, admin, /api/v1/orders/:id, PUT
|
||||
p, admin, /api/v1/orders/:id, DELETE
|
||||
p, admin, /api/v1/menu/:id, GET
|
||||
p, admin, /api/v1/menu/:id, PUT
|
||||
p, admin, /api/v1/menuids, GET
|
||||
p, admin, /api/v1/loginloglist, GET
|
||||
p, admin, /api/v1/loginlog/:id, DELETE
|
||||
p, admin, /api/v1/operloglist, GET
|
||||
p, admin, /api/v1/getinfo, GET
|
||||
|
+7
-6
@@ -1,21 +1,22 @@
|
||||
settings:
|
||||
application:
|
||||
env: dev
|
||||
envmsg: "谢谢您的参与,但为了大家更好的体验,所以本次提交就算了吧!\U0001F600\U0001F600\U0001F600"
|
||||
mode: dev # dev开发环境 test测试环境 prod线上环境
|
||||
demomsg: "谢谢您的参与,但为了大家更好的体验,所以本次提交就算了吧!\U0001F600\U0001F600\U0001F600"
|
||||
host: 0.0.0.0
|
||||
isinit: false
|
||||
logpath: temp/logs/log.txt
|
||||
name: testApp
|
||||
port: 8000
|
||||
readtimeout: 1
|
||||
writertimeout: 2
|
||||
log:
|
||||
dir: temp/logs
|
||||
jwt:
|
||||
secret: go-admin
|
||||
timeout: 3600
|
||||
database:
|
||||
database: goadmin
|
||||
dbtype: mysql # sqlite3
|
||||
host: 127.0.0.1 # sqlite3.db
|
||||
name: goadmindb
|
||||
dbtype: mysql
|
||||
host: 127.0.0.1
|
||||
password: 123456
|
||||
port: 3306
|
||||
username: root
|
||||
|
||||
Reference in New Issue
Block a user