数据模型使用指针类型字段以避免空值自动更新的问题

This commit is contained in:
2025-05-26 10:57:39 +08:00
parent 1e7b5777a2
commit c08d625975
43 changed files with 457 additions and 397 deletions

View File

@@ -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)