From 16775cee456afa4b433e825c9c4de3c77ea87892 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Tue, 27 Oct 2020 13:13:44 +0800 Subject: [PATCH] =?UTF-8?q?refactor=F0=9F=8E=A8=20:=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E9=92=88=E5=AF=B9=E4=BB=A3=E7=A0=81=E8=BF=9B=E8=A1=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/sys_login_log/sys_login_log.go | 20 ++++++++--------- app/admin/middleware/handler/auth.go | 8 +++---- app/admin/service/dto/sys_login_log.go | 10 ++++----- app/admin/service/dto/sys_opera_log.go | 10 ++++----- app/admin/service/sys_login_log.go | 22 +++++++++---------- 5 files changed, 34 insertions(+), 36 deletions(-) diff --git a/app/admin/apis/system/sys_login_log/sys_login_log.go b/app/admin/apis/system/sys_login_log/sys_login_log.go index bdd30bf..253dbc1 100644 --- a/app/admin/apis/system/sys_login_log/sys_login_log.go +++ b/app/admin/apis/system/sys_login_log/sys_login_log.go @@ -38,10 +38,10 @@ func (e *SysLoginLog) GetSysLoginLogList(c *gin.Context) { list := make([]system.SysLoginLog, 0) var count int64 - serviceStudent := service.SysLoginlog{} + serviceStudent := service.SysLoginLog{} serviceStudent.MsgID = msgID serviceStudent.Orm = db - err = serviceStudent.GetSysLoginlogPage(req, &list, &count) + err = serviceStudent.GetSysLoginLogPage(req, &list, &count) if err != nil { e.Error(c, http.StatusUnprocessableEntity, err, "查询失败") return @@ -68,10 +68,10 @@ func (e *SysLoginLog) GetSysLoginLog(c *gin.Context) { } var object system.SysLoginLog - serviceSysLoginLog := service.SysLoginlog{} + serviceSysLoginLog := service.SysLoginLog{} serviceSysLoginLog.MsgID = msgID serviceSysLoginLog.Orm = db - err = serviceSysLoginLog.GetSysLoginlog(req, &object) + err = serviceSysLoginLog.GetSysLoginLog(req, &object) if err != nil { e.Error(c, http.StatusUnprocessableEntity, err, "查询失败") return @@ -105,10 +105,10 @@ func (e *SysLoginLog) InsertSysLoginLog(c *gin.Context) { // 设置创建人 object.SetCreateBy(tools.GetUserIdUint(c)) - serviceSysLoginLog := service.SysLoginlog{} + serviceSysLoginLog := service.SysLoginLog{} serviceSysLoginLog.Orm = db serviceSysLoginLog.MsgID = msgID - err = serviceSysLoginLog.InsertSysLoginlog(object) + err = serviceSysLoginLog.InsertSysLoginLog(object) if err != nil { log.Error(err) e.Error(c, http.StatusInternalServerError, err, "创建失败") @@ -142,10 +142,10 @@ func (e *SysLoginLog) UpdateSysLoginLog(c *gin.Context) { } object.SetUpdateBy(tools.GetUserIdUint(c)) - serviceSysLoginLog := service.SysLoginlog{} + serviceSysLoginLog := service.SysLoginLog{} serviceSysLoginLog.Orm = db serviceSysLoginLog.MsgID = msgID - err = serviceSysLoginLog.UpdateSysLoginlog(object) + err = serviceSysLoginLog.UpdateSysLoginLog(object) if err != nil { log.Error(err) return @@ -180,10 +180,10 @@ func (e *SysLoginLog) DeleteSysLoginLog(c *gin.Context) { // 设置编辑人 object.SetUpdateBy(tools.GetUserIdUint(c)) - serviceSysLoginLog := service.SysLoginlog{} + serviceSysLoginLog := service.SysLoginLog{} serviceSysLoginLog.Orm = db serviceSysLoginLog.MsgID = msgID - err = serviceSysLoginLog.RemoveSysLoginlog(req, object) + err = serviceSysLoginLog.RemoveSysLoginLog(req, object) if err != nil { log.Error(err) return diff --git a/app/admin/middleware/handler/auth.go b/app/admin/middleware/handler/auth.go index d0b5e27..f32908d 100644 --- a/app/admin/middleware/handler/auth.go +++ b/app/admin/middleware/handler/auth.go @@ -101,7 +101,7 @@ func Authenticator(c *gin.Context) (interface{}, error) { func LoginLogToDB(c *gin.Context, status string, msg string, username string) { if config.LoggerConfig.EnabledDB { var loginlog system.SysLoginLog - serviceLoginLog :=service.SysLoginlog{} + serviceLoginLog :=service.SysLoginLog{} ua := user_agent.New(c.Request.UserAgent()) loginlog.Ipaddr = c.ClientIP() loginlog.Username = username @@ -115,7 +115,7 @@ func LoginLogToDB(c *gin.Context, status string, msg string, username string) { loginlog.Os = ua.OS() loginlog.Msg = msg loginlog.Platform = ua.Platform() - _ = serviceLoginLog.InsertSysLoginlog(loginlog.Generate()) + _ = serviceLoginLog.InsertSysLoginLog(loginlog.Generate()) } } @@ -143,8 +143,8 @@ func LogOut(c *gin.Context) { loginlog.Platform = ua.Platform() loginlog.Username = tools.GetUserName(c) loginlog.Msg = "退出成功" - serviceLoginLog:=service.SysLoginlog{} - _ = serviceLoginLog.InsertSysLoginlog(loginlog.Generate()) + serviceLoginLog:=service.SysLoginLog{} + _ = serviceLoginLog.InsertSysLoginLog(loginlog.Generate()) c.JSON(http.StatusOK, gin.H{ "code": 200, diff --git a/app/admin/service/dto/sys_login_log.go b/app/admin/service/dto/sys_login_log.go index 0c382a6..ae65f75 100644 --- a/app/admin/service/dto/sys_login_log.go +++ b/app/admin/service/dto/sys_login_log.go @@ -15,13 +15,11 @@ import ( type SysLoginLogSearch struct { dto.Pagination `search:"-"` - Username string `form:"username" search:"type:exact;column:username;table:sys_loginlog" comment:"用户名"` - Status string `form:"status" search:"type:exact;column:status;table:sys_loginlog" comment:"状态"` - - Ipaddr string `form:"ipaddr" search:"type:exact;column:ipaddr;table:sys_loginlog" comment:"ip地址"` - - LoginLocation string `form:"loginLocation" search:"type:exact;column:login_location;table:sys_loginlog" comment:"归属地"` + Username string `form:"username" search:"type:exact;column:username;table:sys_login_log" comment:"用户名"` + Status string `form:"status" search:"type:exact;column:status;table:sys_login_log" comment:"状态"` + Ipaddr string `form:"ipaddr" search:"type:exact;column:ipaddr;table:sys_login_log" comment:"ip地址"` + LoginLocation string `form:"loginLocation" search:"type:exact;column:login_location;table:sys_login_log" comment:"归属地"` } func (m *SysLoginLogSearch) GetNeedSearch() interface{} { diff --git a/app/admin/service/dto/sys_opera_log.go b/app/admin/service/dto/sys_opera_log.go index a937172..f457522 100644 --- a/app/admin/service/dto/sys_opera_log.go +++ b/app/admin/service/dto/sys_opera_log.go @@ -16,11 +16,11 @@ import ( type SysOperaLogSearch struct { dto.Pagination `search:"-"` - Title string `form:"title" search:"type:contains;column:title;table:sys_operlog" comment:"操作模块"` - Method string `form:"method" search:"type:contains;column:method;table:sys_operlog" comment:"函数"` - RequestMethod string `form:"requestMethod" search:"type:contains;column:request_method;table:sys_operlog" comment:"请求方式"` - OperUrl string `form:"operUrl" search:"type:contains;column:oper_url;table:sys_operlog" comment:"访问地址"` - OperIp string `form:"operIp" search:"type:exact;column:oper_ip;table:sys_operlog" comment:"客户端ip"` + 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:"函数"` + 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:"访问地址"` + OperIp string `form:"operIp" search:"type:exact;column:oper_ip;table:sys_opera_log" comment:"客户端ip"` } func (m *SysOperaLogSearch) GetNeedSearch() interface{} { diff --git a/app/admin/service/sys_login_log.go b/app/admin/service/sys_login_log.go index 310d2b6..c3ba5fe 100644 --- a/app/admin/service/sys_login_log.go +++ b/app/admin/service/sys_login_log.go @@ -10,12 +10,12 @@ import ( "gorm.io/gorm" ) -type SysLoginlog struct { +type SysLoginLog struct { service.Service } -// GetSysLoginlogPage 获取SysLoginlog列表 -func (e *SysLoginlog) GetSysLoginlogPage(c cDto.Index, list *[]system.SysLoginLog, count *int64) error { +// GetSysLoginLogPage 获取SysLoginLog列表 +func (e *SysLoginLog) GetSysLoginLogPage(c cDto.Index, list *[]system.SysLoginLog, count *int64) error { var err error var data system.SysLoginLog msgID := e.MsgID @@ -34,8 +34,8 @@ func (e *SysLoginlog) GetSysLoginlogPage(c cDto.Index, list *[]system.SysLoginLo return nil } -// GetSysLoginlog 获取SysLoginlog对象 -func (e *SysLoginlog) GetSysLoginlog(d cDto.Control, model *system.SysLoginLog) error { +// GetSysLoginLog 获取SysLoginLog对象 +func (e *SysLoginLog) GetSysLoginLog(d cDto.Control, model *system.SysLoginLog) error { var err error var data system.SysLoginLog msgID := e.MsgID @@ -55,8 +55,8 @@ func (e *SysLoginlog) GetSysLoginlog(d cDto.Control, model *system.SysLoginLog) return nil } -// InsertSysLoginlog 创建SysLoginlog对象 -func (e *SysLoginlog) InsertSysLoginlog(model common.ActiveRecord) error { +// InsertSysLoginLog 创建SysLoginLog对象 +func (e *SysLoginLog) InsertSysLoginLog(model common.ActiveRecord) error { var err error var data system.SysLoginLog msgID := e.MsgID @@ -70,8 +70,8 @@ func (e *SysLoginlog) InsertSysLoginlog(model common.ActiveRecord) error { return nil } -// UpdateSysLoginlog 修改SysLoginlog对象 -func (e *SysLoginlog) UpdateSysLoginlog(c common.ActiveRecord) error { +// UpdateSysLoginLog 修改SysLoginLog对象 +func (e *SysLoginLog) UpdateSysLoginLog(c common.ActiveRecord) error { var err error var data system.SysLoginLog msgID := e.MsgID @@ -89,8 +89,8 @@ func (e *SysLoginlog) UpdateSysLoginlog(c common.ActiveRecord) error { return nil } -// RemoveSysLoginlog 删除SysLoginlog -func (e *SysLoginlog) RemoveSysLoginlog(d cDto.Control, c common.ActiveRecord) error { +// RemoveSysLoginLog 删除SysLoginLog +func (e *SysLoginLog) RemoveSysLoginLog(d cDto.Control, c common.ActiveRecord) error { var err error var data system.SysLoginLog msgID := e.MsgID