refactor(report): update import paths and enhance logging functionality
- 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:
@@ -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",
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user