refactor🎨: 调整客户端ip获取方法以及日志中对应位置更新

This commit is contained in:
zhangwenjian committed 2021-06-13 21:20:07 +08:00
1 parent ed52efaa44
commit e0cf7af7a9
4 files changed
+28 -10

No files matched your search

+5 -2
View File
@@ -1,7 +1,9 @@
package handler
import (
"fmt"
"go-admin/app/admin/models"
"go-admin/common"
"net/http"
"github.com/gin-gonic/gin"
@@ -115,8 +117,9 @@ func LoginLogToDB(c *gin.Context, status string, msg string, username string) {
l := make(map[string]interface{})
ua := user_agent.New(c.Request.UserAgent())
l["ipaddr"] = c.ClientIP()
l["loginLocation"] = pkg.GetLocation(c.ClientIP(),gaConfig.ExtConfig.AMap.Key)
l["ipaddr"] = common.GetClientIP(c)
fmt.Println("gaConfig.ExtConfig.AMap.Key", gaConfig.ExtConfig.AMap.Key)
l["loginLocation"] = pkg.GetLocation(common.GetClientIP(c),gaConfig.ExtConfig.AMap.Key)
l["loginTime"] = pkg.GetCurrentTime()
l["status"] = status
l["remark"] = c.Request.UserAgent()