refactor🎨 : 修改日志相关功能,针对代码进行优化

This commit is contained in:
zhangwenjian committed 2020-10-27 13:13:44 +08:00
1 parent 2195c89099
commit 16775cee45
5 files changed
+34 -36

No files matched your search

+4 -4
View File
@@ -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,