mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
iot init
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/ginx"
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
"github.com/XM-GO/PandaKit/utils"
|
||||
"net/http"
|
||||
"pandax/apps/log/entity"
|
||||
"pandax/apps/log/services"
|
||||
)
|
||||
|
||||
func OperationHandler(rc *ginx.ReqCtx) error {
|
||||
c := rc.GinCtx
|
||||
func OperationHandler(rc *restfulx.ReqCtx) error {
|
||||
c := rc.Request
|
||||
// 请求操作不做记录
|
||||
if c.Request.Method == http.MethodGet || rc.LoginAccount == nil {
|
||||
return nil
|
||||
@@ -17,25 +17,27 @@ func OperationHandler(rc *ginx.ReqCtx) error {
|
||||
if rc.RequiredPermission == nil || !rc.RequiredPermission.NeedToken {
|
||||
return nil
|
||||
}
|
||||
oper := entity.LogOper{
|
||||
Title: rc.LogInfo.Description,
|
||||
BusinessType: "0",
|
||||
Method: c.Request.Method,
|
||||
OperName: rc.LoginAccount.UserName,
|
||||
OperUrl: c.Request.URL.Path,
|
||||
OperIp: c.ClientIP(),
|
||||
OperLocation: utils.GetRealAddressByIP(c.ClientIP()),
|
||||
OperParam: "",
|
||||
Status: "0",
|
||||
}
|
||||
if c.Request.Method == "POST" {
|
||||
oper.BusinessType = "1"
|
||||
} else if c.Request.Method == "PUT" {
|
||||
oper.BusinessType = "2"
|
||||
} else if c.Request.Method == "DELETE" {
|
||||
oper.BusinessType = "3"
|
||||
}
|
||||
services.LogOperModelDao.Insert(oper)
|
||||
go func() {
|
||||
oper := entity.LogOper{
|
||||
Title: rc.LogInfo.Description,
|
||||
BusinessType: "0",
|
||||
Method: c.Request.Method,
|
||||
OperName: rc.LoginAccount.UserName,
|
||||
OperUrl: c.Request.URL.Path,
|
||||
OperIp: c.Request.RemoteAddr,
|
||||
OperLocation: utils.GetRealAddressByIP(c.Request.RemoteAddr),
|
||||
OperParam: "",
|
||||
Status: "0",
|
||||
}
|
||||
if c.Request.Method == "POST" {
|
||||
oper.BusinessType = "1"
|
||||
} else if c.Request.Method == "PUT" {
|
||||
oper.BusinessType = "2"
|
||||
} else if c.Request.Method == "DELETE" {
|
||||
oper.BusinessType = "3"
|
||||
}
|
||||
services.LogOperModelDao.Insert(oper)
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user