Merge pull request #178 from wenjianzhang/dev
1. 代码生成添加操作按钮确认提示; 2. 代码生成添加时间类型支持; 3. 代码生成添加时间控件、下拉控件、文本域的支持; 4. 修复代码生成无需权限的问题; 5. 修改了部分格式问题; 6. 默认开启log; 7. 修复了已知bug;
This commit is contained in:
18 files changed
+154
-39
No files matched your search
@@ -90,6 +90,8 @@
|
|||||||
|
|
||||||
[使用生成工具轻松实现业务](https://www.bilibili.com/video/BV1Dg4y1i79D)
|
[使用生成工具轻松实现业务](https://www.bilibili.com/video/BV1Dg4y1i79D)
|
||||||
|
|
||||||
|
[v1.1.0版本代码生成工具-释放双手](https://www.bilibili.com/video/BV1N54y1i71P) [进阶]
|
||||||
|
|
||||||
[多命令启动方式讲解以及IDE配置](https://www.bilibili.com/video/BV1Fg4y1q7ph)
|
[多命令启动方式讲解以及IDE配置](https://www.bilibili.com/video/BV1Fg4y1q7ph)
|
||||||
|
|
||||||
[go-admin菜单的配置说明](https://www.bilibili.com/video/BV1Wp4y1D715) [必看]
|
[go-admin菜单的配置说明](https://www.bilibili.com/video/BV1Wp4y1D715) [必看]
|
||||||
|
|||||||
+5
-5
@@ -60,10 +60,10 @@ func GenCode(c *gin.Context) {
|
|||||||
tab, _ := table.Get()
|
tab, _ := table.Get()
|
||||||
ischeckrole := true
|
ischeckrole := true
|
||||||
|
|
||||||
rouyerfile := "template/routercheckrole.go.template"
|
routerfile := "template/routercheckrole.go.template"
|
||||||
|
|
||||||
if c.Param("ischeckrole") != "" {
|
if c.Request.FormValue("ischeckrole") != "" {
|
||||||
ischeckrole, err = tools2.StringToBool(c.Query("ischeckrole"))
|
ischeckrole, err = tools2.StringToBool(c.Request.FormValue("ischeckrole"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ischeckrole = true
|
ischeckrole = true
|
||||||
}
|
}
|
||||||
@@ -75,14 +75,14 @@ func GenCode(c *gin.Context) {
|
|||||||
if !ischeckrole {
|
if !ischeckrole {
|
||||||
oldTest = "// {{无需认证路由自动补充在此处请勿删除}}"
|
oldTest = "// {{无需认证路由自动补充在此处请勿删除}}"
|
||||||
newText = "// {{无需认证路由自动补充在此处请勿删除}} \r\n register" + tab.ClassName + "Router(v1)"
|
newText = "// {{无需认证路由自动补充在此处请勿删除}} \r\n register" + tab.ClassName + "Router(v1)"
|
||||||
rouyerfile = "template/routernocheckrole.go.template"
|
routerfile = "template/routernocheckrole.go.template"
|
||||||
}
|
}
|
||||||
|
|
||||||
t1, err := template.ParseFiles("template/model.go.template")
|
t1, err := template.ParseFiles("template/model.go.template")
|
||||||
tools2.HasError(err, "", -1)
|
tools2.HasError(err, "", -1)
|
||||||
t2, err := template.ParseFiles("template/api.go.template")
|
t2, err := template.ParseFiles("template/api.go.template")
|
||||||
tools2.HasError(err, "", -1)
|
tools2.HasError(err, "", -1)
|
||||||
t3, err := template.ParseFiles(rouyerfile)
|
t3, err := template.ParseFiles(routerfile)
|
||||||
tools2.HasError(err, "", -1)
|
tools2.HasError(err, "", -1)
|
||||||
t4, err := template.ParseFiles("template/js.go.template")
|
t4, err := template.ParseFiles("template/js.go.template")
|
||||||
tools2.HasError(err, "", -1)
|
tools2.HasError(err, "", -1)
|
||||||
|
|||||||
@@ -168,8 +168,15 @@ func genTableInit(tablesList []string, i int, c *gin.Context) (tools.SysTables,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(dbcolumn[i].ColumnType, "int") {
|
if strings.Contains(dbcolumn[i].ColumnType, "int") {
|
||||||
|
if strings.Contains(dbcolumn[i].ColumnKey, "PR") {
|
||||||
column.GoType = "int"
|
column.GoType = "int"
|
||||||
|
} else {
|
||||||
|
column.GoType = "string"
|
||||||
|
}
|
||||||
column.HtmlType = "input"
|
column.HtmlType = "input"
|
||||||
|
} else if strings.Contains(dbcolumn[i].ColumnType, "timestamp") {
|
||||||
|
column.GoType = "time.Time"
|
||||||
|
column.HtmlType = "datetime"
|
||||||
} else {
|
} else {
|
||||||
column.GoType = "string"
|
column.GoType = "string"
|
||||||
column.HtmlType = "input"
|
column.HtmlType = "input"
|
||||||
|
|||||||
+5
-1
@@ -27,7 +27,8 @@ var (
|
|||||||
StartCmd = &cobra.Command{
|
StartCmd = &cobra.Command{
|
||||||
Use: "server",
|
Use: "server",
|
||||||
Short: "Start API server",
|
Short: "Start API server",
|
||||||
Example: "go-admin server config/settings.yml",
|
Example: "go-admin server -c config/settings.yml",
|
||||||
|
SilenceUsage: true,
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
setup()
|
setup()
|
||||||
},
|
},
|
||||||
@@ -35,8 +36,11 @@ var (
|
|||||||
return run()
|
return run()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var echoTimes int
|
||||||
func init() {
|
func init() {
|
||||||
StartCmd.PersistentFlags().StringVarP(&configYml, "config", "c", "config/settings.yml", "Start server with provided configuration file")
|
StartCmd.PersistentFlags().StringVarP(&configYml, "config", "c", "config/settings.yml", "Start server with provided configuration file")
|
||||||
StartCmd.PersistentFlags().StringVarP(&port, "port", "p", "8000", "Tcp port server listening on")
|
StartCmd.PersistentFlags().StringVarP(&port, "port", "p", "8000", "Tcp port server listening on")
|
||||||
|
|||||||
+5
-2
@@ -5,7 +5,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go-admin/cmd/api"
|
"go-admin/cmd/api"
|
||||||
|
"go-admin/cmd/config"
|
||||||
"go-admin/cmd/migrate"
|
"go-admin/cmd/migrate"
|
||||||
|
"go-admin/cmd/version"
|
||||||
"go-admin/global"
|
"go-admin/global"
|
||||||
"go-admin/tools"
|
"go-admin/tools"
|
||||||
"os"
|
"os"
|
||||||
@@ -13,9 +15,8 @@ import (
|
|||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "go-admin",
|
Use: "go-admin",
|
||||||
Short: "-v",
|
Short: "go-admin",
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
DisableAutoGenTag: true,
|
|
||||||
Long: `go-admin`,
|
Long: `go-admin`,
|
||||||
Args: func(cmd *cobra.Command, args []string) error {
|
Args: func(cmd *cobra.Command, args []string) error {
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
@@ -40,6 +41,8 @@ func tip() {
|
|||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(api.StartCmd)
|
rootCmd.AddCommand(api.StartCmd)
|
||||||
rootCmd.AddCommand(migrate.StartCmd)
|
rootCmd.AddCommand(migrate.StartCmd)
|
||||||
|
rootCmd.AddCommand(version.StartCmd)
|
||||||
|
rootCmd.AddCommand(config.StartCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Execute : apply commands
|
//Execute : apply commands
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"go-admin/tools/config"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
configYml string
|
||||||
|
mode string
|
||||||
|
StartCmd = &cobra.Command{
|
||||||
|
Use: "config",
|
||||||
|
Short: "Get Application config info",
|
||||||
|
Example: "go-admin config -c config/settings.yml",
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
run()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
StartCmd.PersistentFlags().StringVarP(&configYml, "config", "c", "config/settings.yml", "Start server with provided configuration file")
|
||||||
|
}
|
||||||
|
|
||||||
|
func run() {
|
||||||
|
config.Setup(configYml)
|
||||||
|
|
||||||
|
application, errs := json.MarshalIndent(config.ApplicationConfig, "", " ") //转换成JSON返回的是byte[]
|
||||||
|
if errs != nil {
|
||||||
|
fmt.Println(errs.Error())
|
||||||
|
}
|
||||||
|
fmt.Println("application:", string(application))
|
||||||
|
|
||||||
|
jwt, errs := json.MarshalIndent(config.JwtConfig, "", " ") //转换成JSON返回的是byte[]
|
||||||
|
if errs != nil {
|
||||||
|
fmt.Println(errs.Error())
|
||||||
|
}
|
||||||
|
fmt.Println("jwt:", string(jwt))
|
||||||
|
|
||||||
|
database, errs := json.MarshalIndent(config.DatabaseConfig, "", " ") //转换成JSON返回的是byte[]
|
||||||
|
if errs != nil {
|
||||||
|
fmt.Println(errs.Error())
|
||||||
|
}
|
||||||
|
fmt.Println("database:", string(database))
|
||||||
|
|
||||||
|
gen, errs := json.MarshalIndent(config.GenConfig, "", " ") //转换成JSON返回的是byte[]
|
||||||
|
if errs != nil {
|
||||||
|
fmt.Println(errs.Error())
|
||||||
|
}
|
||||||
|
fmt.Println("gen:", string(gen))
|
||||||
|
|
||||||
|
loggerConfig, errs := json.MarshalIndent(config.LoggerConfig, "", " ") //转换成JSON返回的是byte[]
|
||||||
|
if errs != nil {
|
||||||
|
fmt.Println(errs.Error())
|
||||||
|
}
|
||||||
|
fmt.Println("logger:", string(loggerConfig))
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,7 +17,8 @@ var (
|
|||||||
mode string
|
mode string
|
||||||
StartCmd = &cobra.Command{
|
StartCmd = &cobra.Command{
|
||||||
Use: "init",
|
Use: "init",
|
||||||
Short: "initialize the database",
|
Short: "Initialize the database",
|
||||||
|
Example: "go-admin init -c config/settings.yml",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
run()
|
run()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package version
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"go-admin/global"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
configYml string
|
||||||
|
port string
|
||||||
|
mode string
|
||||||
|
StartCmd = &cobra.Command{
|
||||||
|
Use: "version",
|
||||||
|
Short: "Get version info",
|
||||||
|
Example: "go-admin version",
|
||||||
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
|
},
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
return run()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func run() error {
|
||||||
|
fmt.Println(global.Version)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
@@ -267,7 +267,6 @@ INSERT INTO sys_dict_type VALUES (11, '1', '1', 1, '1', '1', '1', '2020-04-11 15
|
|||||||
|
|
||||||
INSERT INTO `sys_menu` VALUES (2, 'Upms', '系统管理', 'example', '/upms', '/0/2', 'M', '无', '', 0, 1, '', 'Layout', 1, '0', '1', '1', '0', '2020-04-11 15:52:48', NULL, NULL);
|
INSERT INTO `sys_menu` VALUES (2, 'Upms', '系统管理', 'example', '/upms', '/0/2', 'M', '无', '', 0, 1, '', 'Layout', 1, '0', '1', '1', '0', '2020-04-11 15:52:48', NULL, NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (3, 'Sysuser', '用户管理', 'user', 'sysuser', '/0/2/3', 'C', '无', 'system:sysuser:list', 2, NULL, NULL, '/sysuser/index', 1, '0', '1', '1', '0', '2020-04-11 15:52:48', '2020-04-12 11:10:42', NULL);
|
INSERT INTO `sys_menu` VALUES (3, 'Sysuser', '用户管理', 'user', 'sysuser', '/0/2/3', 'C', '无', 'system:sysuser:list', 2, NULL, NULL, '/sysuser/index', 1, '0', '1', '1', '0', '2020-04-11 15:52:48', '2020-04-12 11:10:42', NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (4, 'GenCode', '新功能', 'example', '/gencode', '/0/4', 'M', '无', '', 0, 1, '', 'Layout', 1, '0', '1', '1', '0', '2020-04-11 15:52:48', NULL, NULL);
|
|
||||||
INSERT INTO `sys_menu` VALUES (43, NULL, '新增用户', NULL, '/api/v1/sysuser', '/0/2/3/43', 'F', 'POST', 'system:sysuser:add', 3, NULL, NULL, NULL, 0, '0', '1', '1', '0', '2020-04-11 15:52:48', NULL, NULL);
|
INSERT INTO `sys_menu` VALUES (43, NULL, '新增用户', NULL, '/api/v1/sysuser', '/0/2/3/43', 'F', 'POST', 'system:sysuser:add', 3, NULL, NULL, NULL, 0, '0', '1', '1', '0', '2020-04-11 15:52:48', NULL, NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (44, NULL, '查询用户', NULL, '/api/v1/sysuser', '/0/2/3/44', 'F', 'GET', 'system:sysuser:query', 3, NULL, NULL, NULL, 0, '0', '1', '1', '0', '2020-04-11 15:52:48', NULL, NULL);
|
INSERT INTO `sys_menu` VALUES (44, NULL, '查询用户', NULL, '/api/v1/sysuser', '/0/2/3/44', 'F', 'GET', 'system:sysuser:query', 3, NULL, NULL, NULL, 0, '0', '1', '1', '0', '2020-04-11 15:52:48', NULL, NULL);
|
||||||
INSERT INTO `sys_menu` VALUES (45, NULL, '修改用户', NULL, '/api/v1/sysuser/', '/0/2/3/45', 'F', 'PUT', 'system:sysuser:edit', 3, NULL, NULL, NULL, 0, '0', '1', '1', '0', '2020-04-11 15:52:48', NULL, NULL);
|
INSERT INTO `sys_menu` VALUES (45, NULL, '修改用户', NULL, '/api/v1/sysuser/', '/0/2/3/45', 'F', 'PUT', 'system:sysuser:edit', 3, NULL, NULL, NULL, 0, '0', '1', '1', '0', '2020-04-11 15:52:48', NULL, NULL);
|
||||||
|
|||||||
+1
-3
@@ -20,7 +20,7 @@ settings:
|
|||||||
# 日志等级
|
# 日志等级
|
||||||
level: all
|
level: all
|
||||||
# 业务日志开关
|
# 业务日志开关
|
||||||
enabledbus: false
|
enabledbus: true
|
||||||
# 请求日志开关
|
# 请求日志开关
|
||||||
enabledreq: false
|
enabledreq: false
|
||||||
# 数据库日志开关 dev模式,将自动开启
|
# 数据库日志开关 dev模式,将自动开启
|
||||||
@@ -35,8 +35,6 @@ settings:
|
|||||||
driver: mysql
|
driver: mysql
|
||||||
# 数据库连接字符串 mysql 缺省信息 charset=utf8&parseTime=True&loc=Local&timeout=1000ms
|
# 数据库连接字符串 mysql 缺省信息 charset=utf8&parseTime=True&loc=Local&timeout=1000ms
|
||||||
source: user:password@tcp(127.0.0.1:3306)/dbname?charset=utf8&parseTime=True&loc=Local&timeout=1000ms
|
source: user:password@tcp(127.0.0.1:3306)/dbname?charset=utf8&parseTime=True&loc=Local&timeout=1000ms
|
||||||
# source: sqlite3.db
|
|
||||||
# source: host=myhost port=myport user=gorm dbname=gorm password=mypassword
|
|
||||||
gen:
|
gen:
|
||||||
# 代码生成读取的数据库名称
|
# 代码生成读取的数据库名称
|
||||||
dbname: dbname
|
dbname: dbname
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ func (e *Mysql) Setup() {
|
|||||||
global.Logger.Info(tools.Green(global.Source))
|
global.Logger.Info(tools.Green(global.Source))
|
||||||
global.Eloquent, err = db.Open(db.GetDriver(), db.GetConnect())
|
global.Eloquent, err = db.Open(db.GetDriver(), db.GetConnect())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
global.Logger.Error(tools.Red(db.GetDriver()+" connect error :"), err)
|
global.Logger.Fatal(tools.Red(db.GetDriver()+" connect error :"), err)
|
||||||
} else {
|
} else {
|
||||||
global.Logger.Info(tools.Green(db.GetDriver() + " connect success !"))
|
global.Logger.Info(tools.Green(db.GetDriver() + " connect success !"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if global.Eloquent.Error != nil {
|
if global.Eloquent.Error != nil {
|
||||||
global.Logger.Error(tools.Red(" database error :"), global.Eloquent.Error)
|
global.Logger.Fatal(tools.Red(" database error :"), global.Eloquent.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
global.Eloquent.LogMode(config.LoggerConfig.EnabledDB)
|
global.Eloquent.LogMode(config.LoggerConfig.EnabledDB)
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ var (
|
|||||||
var Version string
|
var Version string
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Version = "1.1.0"
|
Version = "1.1.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func CustomError(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
c.Status(statusCode)
|
c.Status(statusCode)
|
||||||
fmt.Println(
|
fmt.Println(
|
||||||
time.Now().Format("\n 2006-01-02 15:04:05.9999"),
|
time.Now().Format("2006-01-02 15:04:05.9999"),
|
||||||
"[ERROR]",
|
"[ERROR]",
|
||||||
c.Request.Method,
|
c.Request.Method,
|
||||||
c.Request.URL,
|
c.Request.URL,
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ import (
|
|||||||
type Menu struct {
|
type Menu struct {
|
||||||
MenuId int `json:"menuId" gorm:"primary_key;AUTO_INCREMENT"`
|
MenuId int `json:"menuId" gorm:"primary_key;AUTO_INCREMENT"`
|
||||||
MenuName string `json:"menuName" gorm:"size:128;"`
|
MenuName string `json:"menuName" gorm:"size:128;"`
|
||||||
Title string `json:"title" gorm:"size:64;"`
|
Title string `json:"title" gorm:"size:128;"`
|
||||||
Icon string `json:"icon" gorm:"size:128;"`
|
Icon string `json:"icon" gorm:"size:128;"`
|
||||||
Path string `json:"path" gorm:"size:128;"`
|
Path string `json:"path" gorm:"size:128;"`
|
||||||
Paths string `json:"paths" gorm:"size:128;"`
|
Paths string `json:"paths" gorm:"size:128;"`
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ package models
|
|||||||
import (
|
import (
|
||||||
orm "go-admin/global"
|
orm "go-admin/global"
|
||||||
"go-admin/tools"
|
"go-admin/tools"
|
||||||
_ "time"
|
{{$ii := 1}}
|
||||||
|
{{ range .Columns }}
|
||||||
|
{{- if eq .GoType "time.Time" -}}{{- if eq $ii 1 -}} "time" {{$ii = 2}}{{- end}}{{- end}}
|
||||||
|
{{- end }}
|
||||||
)
|
)
|
||||||
|
|
||||||
type {{.ClassName}} struct {
|
type {{.ClassName}} struct {
|
||||||
|
|||||||
@@ -132,10 +132,14 @@
|
|||||||
<el-input v-model="form.{{.JsonField}}" placeholder="{{.ColumnComment}}"
|
<el-input v-model="form.{{.JsonField}}" placeholder="{{.ColumnComment}}"
|
||||||
{{if eq .IsEdit "false" -}}:disabled="isEdit" {{- end}}/>
|
{{if eq .IsEdit "false" -}}:disabled="isEdit" {{- end}}/>
|
||||||
{{- else if eq "select" .HtmlType -}}
|
{{- else if eq "select" .HtmlType -}}
|
||||||
<el-select
|
<el-select v-model="form.{{.JsonField}}"
|
||||||
v-model="form.{{.JsonField}}" {{if eq .IsEdit "false" -}} :disabled="isEdit" {{- end }}>
|
placeholder="请选择" {{if eq .IsEdit "false" -}} :disabled="isEdit" {{- end }}>
|
||||||
<el-option label="demo1" value="demo1"/>
|
<el-option
|
||||||
<el-option label="demo2" value="demo2"/>
|
v-for="dict in {{.JsonField}}Options"
|
||||||
|
:key="dict.dictValue"
|
||||||
|
:label="dict.dictLabel"
|
||||||
|
:value="dict.dictValue"
|
||||||
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
{{- else if eq "radio" .HtmlType -}}
|
{{- else if eq "radio" .HtmlType -}}
|
||||||
<el-radio-group v-model="form.{{.JsonField}}">
|
<el-radio-group v-model="form.{{.JsonField}}">
|
||||||
@@ -145,6 +149,19 @@
|
|||||||
:label="dict.dictValue"
|
:label="dict.dictValue"
|
||||||
>{{"{{"}} dict.dictLabel {{"}}"}}</el-radio>
|
>{{"{{"}} dict.dictLabel {{"}}"}}</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
|
{{- else if eq "datetime" .HtmlType -}}
|
||||||
|
<el-date-picker
|
||||||
|
v-model="form.{{.JsonField}}"
|
||||||
|
type="datetime"
|
||||||
|
placeholder="选择日期">
|
||||||
|
</el-date-picker>
|
||||||
|
{{- else if eq "textarea" .HtmlType -}}
|
||||||
|
<el-input
|
||||||
|
v-model="form.{{.JsonField}}"
|
||||||
|
type="textarea"
|
||||||
|
:rows="2"
|
||||||
|
placeholder="请输入内容">
|
||||||
|
</el-input>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func InitApplication(cfg *viper.Viper) *Application {
|
|||||||
ReadTimeout: cfg.GetInt("readTimeout"),
|
ReadTimeout: cfg.GetInt("readTimeout"),
|
||||||
WriterTimeout: cfg.GetInt("writerTimeout"),
|
WriterTimeout: cfg.GetInt("writerTimeout"),
|
||||||
Host: cfg.GetString("host"),
|
Host: cfg.GetString("host"),
|
||||||
Port: portDefault(cfg),
|
Port: cfg.GetString("port"),
|
||||||
Name: cfg.GetString("name"),
|
Name: cfg.GetString("name"),
|
||||||
JwtSecret: cfg.GetString("jwtSecret"),
|
JwtSecret: cfg.GetString("jwtSecret"),
|
||||||
Mode: cfg.GetString("mode"),
|
Mode: cfg.GetString("mode"),
|
||||||
@@ -29,12 +29,3 @@ func InitApplication(cfg *viper.Viper) *Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ApplicationConfig = new(Application)
|
var ApplicationConfig = new(Application)
|
||||||
|
|
||||||
func portDefault(cfg *viper.Viper) string {
|
|
||||||
if cfg.GetString("port") == "" {
|
|
||||||
return "8000"
|
|
||||||
} else {
|
|
||||||
return cfg.GetString("port")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+5
-6
@@ -3,7 +3,6 @@ package tools
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"log"
|
|
||||||
jwt "go-admin/pkg/jwtauth"
|
jwt "go-admin/pkg/jwtauth"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,7 +20,7 @@ func GetUserId(c *gin.Context) int {
|
|||||||
if data["identity"] != nil {
|
if data["identity"] != nil {
|
||||||
return int((data["identity"]).(float64))
|
return int((data["identity"]).(float64))
|
||||||
}
|
}
|
||||||
log.Println("****************************** 路径:" + c.Request.URL.Path + " 请求方法:" + c.Request.Method + " 说明:缺少identity")
|
fmt.Println(GetCurrentTimeStr()+" [WARING] " + c.Request.Method + " " + c.Request.URL.Path + " GetUserId 缺少identity")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ func GetUserIdStr(c *gin.Context) string {
|
|||||||
if data["identity"] != nil {
|
if data["identity"] != nil {
|
||||||
return Int64ToString(int64((data["identity"]).(float64)))
|
return Int64ToString(int64((data["identity"]).(float64)))
|
||||||
}
|
}
|
||||||
log.Println("****************************** 路径:" + c.Request.URL.Path + " 请求方法:" + c.Request.Method + " 缺少identity")
|
fmt.Println(GetCurrentTimeStr()+" [WARING] " + c.Request.Method + " " + c.Request.URL.Path + " GetUserIdStr 缺少identity")
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +38,7 @@ func GetUserName(c *gin.Context) string {
|
|||||||
if data["nice"] != nil {
|
if data["nice"] != nil {
|
||||||
return (data["nice"]).(string)
|
return (data["nice"]).(string)
|
||||||
}
|
}
|
||||||
fmt.Println("****************************** 路径:" + c.Request.URL.Path + " 请求方法:" + c.Request.Method + " 缺少nice")
|
fmt.Println(GetCurrentTimeStr()+" [WARING] "+ c.Request.Method +" " + c.Request.URL.Path + " GetUserName 缺少nice")
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +47,7 @@ func GetRoleName(c *gin.Context) string {
|
|||||||
if data["rolekey"] != nil {
|
if data["rolekey"] != nil {
|
||||||
return (data["rolekey"]).(string)
|
return (data["rolekey"]).(string)
|
||||||
}
|
}
|
||||||
fmt.Println("****************************** 路径:" + c.Request.URL.Path + " 请求方法:" + c.Request.Method + " 缺少rolekey")
|
fmt.Println(GetCurrentTimeStr()+" [WARING] "+ c.Request.Method +" " + c.Request.URL.Path + " GetRoleName 缺少rolekey")
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +57,6 @@ func GetRoleId(c *gin.Context) int {
|
|||||||
i := int((data["roleid"]).(float64))
|
i := int((data["roleid"]).(float64))
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
fmt.Println("****************************** 路径:" + c.Request.URL.Path + " 请求方法:" + c.Request.Method + " 缺少roleid")
|
fmt.Println(GetCurrentTimeStr()+" [WARING] " + c.Request.Method + " " + c.Request.URL.Path + " GetRoleId 缺少roleid")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user