数据模型使用指针类型字段以避免空值自动更新的问题
This commit is contained in:
13
web/web.go
13
web/web.go
@@ -10,6 +10,7 @@ import (
|
||||
"log/slog"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"platform/pkg/u"
|
||||
"platform/web/auth"
|
||||
g "platform/web/globals"
|
||||
"platform/web/globals/orm"
|
||||
@@ -149,19 +150,19 @@ func newLogger() fiber.Handler {
|
||||
|
||||
var item = &m.LogsRequest{
|
||||
IP: c.IP(),
|
||||
Ua: c.Get("User-Agent"),
|
||||
Ua: u.P(c.Get("User-Agent")),
|
||||
Method: c.Method(),
|
||||
Path: c.Path(),
|
||||
Latency: latency,
|
||||
Latency: &latency,
|
||||
Status: int32(c.Response().StatusCode()),
|
||||
Error: errStr,
|
||||
Time: orm.LocalDateTime(reqTime),
|
||||
Error: &errStr,
|
||||
Time: u.P(orm.LocalDateTime(reqTime)),
|
||||
}
|
||||
if authType != auth.PayloadNone {
|
||||
item.Identity = int32(authType)
|
||||
item.Identity = u.P(int32(authType))
|
||||
}
|
||||
if authID != 0 {
|
||||
item.Visitor = int32(authID)
|
||||
item.Visitor = u.P(int32(authID))
|
||||
}
|
||||
|
||||
err = q.LogsRequest.Create(item)
|
||||
|
||||
Reference in New Issue
Block a user