feat 操作日志功能更换bind方式

This commit is contained in:
wenjianzhang
2021-05-25 19:36:20 +08:00
parent 623e796c92
commit dd7b50e0fa
2 changed files with 11 additions and 17 deletions
+3 -2
View File
@@ -1,6 +1,7 @@
package apis package apis
import ( import (
"github.com/gin-gonic/gin/binding"
"go-admin/app/admin/models" "go-admin/app/admin/models"
"net/http" "net/http"
@@ -20,7 +21,7 @@ func (e SysOperaLog) GetSysOperaLogList(c *gin.Context) {
req := new(dto.SysOperaLogSearch) req := new(dto.SysOperaLogSearch)
err := e.MakeContext(c). err := e.MakeContext(c).
MakeOrm(). MakeOrm().
Bind(req). Bind(req, binding.Form).
MakeService(&s.Service). MakeService(&s.Service).
Errors Errors
if err != nil { if err != nil {
@@ -88,4 +89,4 @@ func (e SysOperaLog) DeleteSysOperaLog(c *gin.Context) {
return return
} }
e.OK(req.GetId(), "删除成功") e.OK(req.GetId(), "删除成功")
} }
+8 -15
View File
@@ -13,27 +13,20 @@ import (
type SysOperaLogSearch struct { type SysOperaLogSearch struct {
dto.Pagination `search:"-"` dto.Pagination `search:"-"`
Title string `form:"title" search:"type:contains;column:title;table:sys_opera_log" comment:"操作模块"`
Title string `form:"title" search:"type:contains;column:title;table:sys_opera_log" comment:"操作模块"` Method string `form:"method" search:"type:contains;column:method;table:sys_opera_log" comment:"函数"`
Method string `form:"method" search:"type:contains;column:method;table:sys_opera_log" comment:"函数"` RequestMethod string `form:"requestMethod" search:"type:contains;column:request_method;table:sys_opera_log" comment:"请求方式"`
RequestMethod string `form:"requestMethod" search:"type:contains;column:request_method;table:sys_opera_log" comment:"请求方式"` OperUrl string `form:"operUrl" search:"type:contains;column:oper_url;table:sys_opera_log" comment:"访问地址"`
OperUrl string `form:"operUrl" search:"type:contains;column:oper_url;table:sys_opera_log" comment:"访问地址"` OperIp string `form:"operIp" search:"type:exact;column:oper_ip;table:sys_opera_log" comment:"客户端ip"`
OperIp string `form:"operIp" search:"type:exact;column:oper_ip;table:sys_opera_log" comment:"客户端ip"` Status int `form:"status" search:"type:exact;column:status;table:sys_opera_log" comment:"状态"`
BeginTime string `form:"beginTime" search:"type:gte;column:ctime;table:sys_opera_log" comment:"创建时间"`
EndTime string `form:"endTime" search:"type:lte;column:ctime;table:sys_opera_log" comment:"创建时间"`
} }
func (m *SysOperaLogSearch) GetNeedSearch() interface{} { func (m *SysOperaLogSearch) GetNeedSearch() interface{} {
return *m return *m
} }
func (m *SysOperaLogSearch) Bind(ctx *gin.Context) error {
log := api.GetRequestLogger(ctx)
err := ctx.ShouldBind(m)
if err != nil {
log.Debugf("ShouldBind error: %s", err.Error())
}
return err
}
type SysOperaLogControl struct { type SysOperaLogControl struct {
ID int `uri:"Id" comment:"编码"` // 编码 ID int `uri:"Id" comment:"编码"` // 编码
Title string `json:"title" comment:"操作模块"` Title string `json:"title" comment:"操作模块"`