refactor(report): update import paths and enhance logging functionality
Some checks failed
Build Backend / build (push) Failing after 7m21s
Build Backend / build-docker (push) Has been skipped

- Removed unused time imports from report DTO and service files.
- Updated import paths for response handling in admin and general report handlers.
- Refactored logging methods in admin and report services to use a unified operation logging approach.
- Introduced helper functions for extracting text from message segments and converting user models to brief report information.
This commit is contained in:
lafay
2026-03-30 02:11:12 +08:00
parent 5f7b02ee8e
commit 7fa49155dd
5 changed files with 66 additions and 28 deletions

View File

@@ -6,7 +6,6 @@ import (
"fmt"
"carrot_bbs/internal/config"
"carrot_bbs/internal/dto"
"carrot_bbs/internal/model"
"carrot_bbs/internal/repository"
@@ -28,9 +27,10 @@ type reportServiceImpl struct {
commentRepo repository.CommentRepository
messageRepo repository.MessageRepository
userRepo repository.UserRepository
systemNotify SystemNotificationService
notifyRepo repository.SystemNotificationRepository
pushService PushService
txManager repository.TransactionManager
logService *LogService
logService OperationLogService
config *config.ReportConfig
}
@@ -41,9 +41,10 @@ func NewReportService(
commentRepo repository.CommentRepository,
messageRepo repository.MessageRepository,
userRepo repository.UserRepository,
systemNotify SystemNotificationService,
notifyRepo repository.SystemNotificationRepository,
pushService PushService,
txManager repository.TransactionManager,
logService *LogService,
logService OperationLogService,
cfg *config.Config,
) ReportService {
reportConfig := &cfg.Report
@@ -56,7 +57,8 @@ func NewReportService(
commentRepo: commentRepo,
messageRepo: messageRepo,
userRepo: userRepo,
systemNotify: systemNotify,
notifyRepo: notifyRepo,
pushService: pushService,
txManager: txManager,
logService: logService,
config: reportConfig,
@@ -147,10 +149,12 @@ func (s *reportServiceImpl) CreateReport(ctx context.Context, reporterID, target
// 记录操作日志
if s.logService != nil {
s.logService.LogOperation(ctx, "create_report", "report", report.ID, reporterID, map[string]interface{}{
"target_type": targetType,
"target_id": targetID,
"reason": reason,
s.logService.RecordOperation(&model.OperationLog{
UserID: reporterID,
Operation: "create_report",
TargetType: "report",
TargetID: report.ID,
Module: "report",
})
}