From 9bc2791b26e88cae004018ee0e6cb7c116495cd6 Mon Sep 17 00:00:00 2001 From: wenjianzhang Date: Sat, 8 May 2021 17:02:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix=F0=9F=90=9B=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86\=E5=86=85=E5=AE=B9=E7=AE=A1=E7=90=86\?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=A8=8B=E5=BA=8F\=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=E5=B7=B2=E7=9F=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/dto/generate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 6a2557064ccc1e8ec6370b306e305a89fd3f9ea6 Mon Sep 17 00:00:00 2001 From: wenjianzhang Date: Sat, 8 May 2021 17:16:52 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=F0=9F=90=9B=20gen=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/apis/sys_file/sys_file_dir.go | 8 ++++---- app/admin/apis/sys_job/sys_job.go | 3 ++- app/admin/apis/tools/gen.go | 5 +++-- common/apis/api.go | 5 ++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/admin/apis/sys_file/sys_file_dir.go b/app/admin/apis/sys_file/sys_file_dir.go index 8d8f349a..d275638c 100644 --- a/app/admin/apis/sys_file/sys_file_dir.go +++ b/app/admin/apis/sys_file/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/app/admin/apis/sys_job/sys_job.go b/app/admin/apis/sys_job/sys_job.go index 95b65b8c..c0667ddd 100644 --- a/app/admin/apis/sys_job/sys_job.go +++ b/app/admin/apis/sys_job/sys_job.go @@ -16,6 +16,7 @@ type SysJob struct { // RemoveJobForService 调用service实现 func (e SysJob) RemoveJobForService(c *gin.Context) { + e.Context = c log := e.GetLogger() db, err := e.GetOrm() if err != nil { @@ -23,7 +24,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/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/common/apis/api.go b/common/apis/api.go index c85ef686..0bc6567a 100644 --- a/common/apis/api.go +++ b/common/apis/api.go @@ -19,12 +19,11 @@ type Api struct { func (e Api) SetContext(c *gin.Context) { e.Context = c - e.Logger = api.GetRequestLogger(c) } // GetLogger 获取上下文提供的日志 func (e Api) GetLogger() *logger.Logger { - return e.Logger + return api.GetRequestLogger(e.Context) } func (e Api) Bind(d interface{}, bindings ...binding.Binding) error { @@ -71,4 +70,4 @@ func (e Api) PageOK(result interface{}, count int, pageIndex int, pageSize int, // Custom 兼容函数 func (e Api) Custom(data gin.H) { response.Custum(e.Context, data) -} \ No newline at end of file +}