diff --git a/app/admin/apis/tools/gen.go b/app/admin/apis/tools/gen.go index 06063438..b96c1a36 100644 --- a/app/admin/apis/tools/gen.go +++ b/app/admin/apis/tools/gen.go @@ -273,6 +273,7 @@ func (e Gen) genApiToFile(c *gin.Context, tab tools.SysTables) { } func (e Gen) ActionsGen(c *gin.Context, tab tools.SysTables) { + e.Context = c log := api.GetRequestLogger(c) basePath := "template/v4/" routerFile := basePath + "actions/router_check_role.go.template" @@ -338,7 +339,7 @@ func (e Gen) ActionsGen(c *gin.Context, tab tools.SysTables) { func (e Gen) GenMenuAndApi(c *gin.Context) { log := api.GetRequestLogger(c) - + e.Context = c table := tools.SysTables{} timeNow := pkg.GetCurrentTime() id, err := pkg.StringToInt(c.Param("tableId")) @@ -578,4 +579,4 @@ func (e Gen) GenMenuAndApi(c *gin.Context) { ADelete.MenuId, err = ADelete.Create(db) e.OK("", "数据生成成功!") -} \ No newline at end of file +} diff --git a/app/jobs/apis/sys_job.go b/app/jobs/apis/sys_job.go index 5e1a27ca..6f22db3d 100644 --- a/app/jobs/apis/sys_job.go +++ b/app/jobs/apis/sys_job.go @@ -4,10 +4,11 @@ import ( "go-admin/app/jobs/service" "net/http" - "github.com/gin-gonic/gin" - "github.com/go-admin-team/go-admin-core/sdk" "go-admin/common/apis" "go-admin/common/dto" + + "github.com/gin-gonic/gin" + "github.com/go-admin-team/go-admin-core/sdk" ) type SysJob struct { @@ -16,7 +17,7 @@ type SysJob struct { // RemoveJobForService 调用service实现 func (e SysJob) RemoveJobForService(c *gin.Context) { - e.SetContext(c) + e.Context = c log := e.GetLogger() db, err := e.GetOrm() if err != nil { @@ -24,7 +25,7 @@ func (e SysJob) RemoveJobForService(c *gin.Context) { return } var v dto.GeneralDelDto - err = c.BindUri(&v) + err = c.Bind(&v) if err != nil { log.Warnf("参数验证错误, error: %s", err) e.Error(http.StatusUnprocessableEntity, err, "参数验证失败") diff --git a/app/other/apis/sys_file_dir.go b/app/other/apis/sys_file_dir.go index 8723bec8..3d1a38db 100644 --- a/app/other/apis/sys_file_dir.go +++ b/app/other/apis/sys_file_dir.go @@ -19,7 +19,7 @@ type SysFileDir struct { } func (e SysFileDir) GetSysFileDirList(c *gin.Context) { - e.SetContext(c) + e.Context = c log := e.GetLogger() search := new(dto.SysFileDirSearch) db, err := e.GetOrm() @@ -49,7 +49,7 @@ func (e SysFileDir) GetSysFileDirList(c *gin.Context) { func (e SysFileDir) GetSysFileDir(c *gin.Context) { control := new(dto.SysFileDirById) - e.SetContext(c) + e.Context = c log := e.GetLogger() db, err := e.GetOrm() if err != nil { @@ -81,7 +81,7 @@ func (e SysFileDir) GetSysFileDir(c *gin.Context) { func (e SysFileDir) InsertSysFileDir(c *gin.Context) { control := new(dto.SysFileDirControl) - e.SetContext(c) + e.Context = c log := e.GetLogger() db, err := e.GetOrm() if err != nil { @@ -195,4 +195,4 @@ func (e SysFileDir) DeleteSysFileDir(c *gin.Context) { return } e.OK(control.Id, "删除成功") -} \ No newline at end of file +} diff --git a/common/apis/api.go b/common/apis/api.go index 055433ad..d4aa0767 100644 --- a/common/apis/api.go +++ b/common/apis/api.go @@ -1,9 +1,10 @@ package apis import ( + "net/http" + "github.com/gin-gonic/gin/binding" "github.com/go-admin-team/go-admin-core/sdk/api" - "net/http" "github.com/gin-gonic/gin" "github.com/go-admin-team/go-admin-core/sdk/pkg" @@ -19,13 +20,11 @@ type Api struct { func (e Api) SetContext(c *gin.Context) { e.Context = c - } // GetLogger 获取上下文提供的日志 func (e Api) GetLogger() *logger.Logger { - e.Logger = api.GetRequestLogger(e.Context) - return e.Logger + return api.GetRequestLogger(e.Context) } func (e Api) Bind(d interface{}, bindings ...binding.Binding) error { diff --git a/common/dto/generate.go b/common/dto/generate.go index 74c976b5..c5ed7fae 100644 --- a/common/dto/generate.go +++ b/common/dto/generate.go @@ -22,7 +22,7 @@ func (s *ObjectById) Bind(ctx *gin.Context) error { return err } if ctx.Request.Method == http.MethodDelete { - err = ctx.ShouldBind(&s.Ids) + err = ctx.ShouldBind(&s) if err != nil { log.Warnf("ShouldBind error: %s", err.Error()) return err