From 5600a2c0f7b6107f13396cd531e47e30a823b321 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Thu, 14 Sep 2023 11:14:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97=E7=9A=84IP?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=AE=A2=E6=88=B7=E7=AB=AF=E7=9A=84=E8=AF=B7?= =?UTF-8?q?=E6=B1=82IP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- features/dbrest/dbrest.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/features/dbrest/dbrest.go b/features/dbrest/dbrest.go index 6ea7680a..a5297946 100644 --- a/features/dbrest/dbrest.go +++ b/features/dbrest/dbrest.go @@ -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()