操作日志的IP获取客户端的请求IP
This commit is contained in:
1 parent
5c2aa9d6fa
commit
5600a2c0f7
1 file changed
+13
@@ -593,6 +593,19 @@ func DatabaseInsertData(w http.ResponseWriter, r *http.Request) {
|
||||
insertData := make(map[string]interface{})
|
||||
_ = json.Unmarshal(body, &insertData)
|
||||
|
||||
// 操作日志的IP
|
||||
if tableName == "operation_log" || tableName == "security_log" {
|
||||
ipAddr := strings.Split(r.RemoteAddr, ":")[0]
|
||||
s := insertData["data"].([]any)
|
||||
a := s[0].(map[string]any)
|
||||
a["op_ip"] = ipAddr
|
||||
} else if tableName == "mml_log" {
|
||||
ipAddr := strings.Split(r.RemoteAddr, ":")[0]
|
||||
s := insertData["data"].([]any)
|
||||
a := s[0].(map[string]any)
|
||||
a["ip"] = ipAddr
|
||||
}
|
||||
|
||||
tn, sql := dborm.ConstructInsertSQL(tableName, insertData)
|
||||
log.Tracef("tn: %s sql :%s", tn, sql)
|
||||
xSession := DbClient.XEngine.NewSession()
|
||||
|
||||
Reference in new issue
Block a user