日志记录不全
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m48s

This commit is contained in:
2026-04-27 15:32:17 +08:00
parent c3ae7fcfbc
commit bb33232b1b
7 changed files with 325 additions and 18 deletions

View File

@@ -3,7 +3,6 @@ package asset_audit
import (
"context"
stderrors "errors"
"fmt"
"strconv"
"strings"
@@ -100,6 +99,7 @@ func BuildLog(ctx context.Context, p BuildLogParams) *model.AssetOperationLog {
func OperatorFromContext(ctx context.Context) OperatorInfo {
uid := middleware.GetUserIDFromContext(ctx)
ut := middleware.GetUserTypeFromContext(ctx)
username := strings.TrimSpace(middleware.GetUsernameFromContext(ctx))
if uid == 0 {
return SystemOperator("系统任务")
@@ -109,19 +109,19 @@ func OperatorFromContext(ctx context.Context) OperatorInfo {
switch ut {
case constants.UserTypeSuperAdmin, constants.UserTypePlatform:
op.Type = constants.AssetAuditOperatorTypeAdmin
op.Name = fmt.Sprintf("台用户#%d", uid)
op.Name = fallbackOperatorName(username, "台用户")
case constants.UserTypeAgent:
op.Type = constants.AssetAuditOperatorTypeAgent
op.Name = fmt.Sprintf("代理用户#%d", uid)
op.Name = fallbackOperatorName(username, "代理账号")
case constants.UserTypeEnterprise:
op.Type = constants.AssetAuditOperatorTypeEnterprise
op.Name = fmt.Sprintf("企业用户#%d", uid)
op.Name = fallbackOperatorName(username, "企业账号")
case constants.UserTypePersonalCustomer:
op.Type = constants.AssetAuditOperatorTypePersonal
op.Name = fmt.Sprintf("个人客户#%d", uid)
op.Name = fallbackOperatorName(username, "个人客户")
default:
op.Type = constants.AssetAuditOperatorTypeAdmin
op.Name = fmt.Sprintf("用户#%d", uid)
op.Name = fallbackOperatorName(username, "平台用户")
}
return op
}
@@ -267,3 +267,10 @@ func strPtr(v string) *string {
func uintPtr(v uint) *uint {
return &v
}
func fallbackOperatorName(name string, fallback string) string {
if strings.TrimSpace(name) != "" {
return name
}
return fallback
}