优化代码位置

This commit is contained in:
2025-09-28 01:10:04 +08:00
parent d995498199
commit fdbea5b7e9
6 changed files with 39 additions and 31 deletions

View File

@@ -19,7 +19,7 @@ type RequestContext struct {
// Service 定义了审计服务的接口
type Service interface {
LogAction(user *models.User, reqCtx RequestContext, actionType, description string, targetResource interface{}, status string, resultDetails string)
LogAction(user *models.User, reqCtx RequestContext, actionType, description string, targetResource interface{}, status models.AuditStatus, resultDetails string)
}
// service 是 Service 接口的实现
@@ -34,7 +34,7 @@ func NewService(repo repository.UserActionLogRepository, logger *logs.Logger) Se
}
// LogAction 记录一个用户操作。它在一个新的 goroutine 中异步执行,以避免阻塞主请求。
func (s *service) LogAction(user *models.User, reqCtx RequestContext, actionType, description string, targetResource interface{}, status string, resultDetails string) {
func (s *service) LogAction(user *models.User, reqCtx RequestContext, actionType, description string, targetResource interface{}, status models.AuditStatus, resultDetails string) {
// 不再从 context 中获取用户信息,直接使用传入的 user 对象
if user == nil {
s.logger.Warnw("无法记录审计日志:传入的用户对象为 nil")