refactor(di): migrate from setter to constructor injection for logService
- Remove SetLogService methods from user, post, comment, and admin post services - Add logService as constructor parameter to all dependent services - Centralize call-related and message error definitions in app_errors.go - Add ConversationID field to WSEventResponse for improved message tracking - Simplify wire provider functions by removing manual setter calls
This commit is contained in:
@@ -67,9 +67,7 @@ type PostService interface {
|
||||
// RecordShare 记录分享(仅已发布帖子计数 +1),返回最新 shares_count
|
||||
RecordShare(ctx context.Context, postID, userID string) (sharesCount int, err error)
|
||||
|
||||
// 日志服务设置
|
||||
SetLogService(logService *LogService)
|
||||
}
|
||||
}
|
||||
|
||||
// postServiceImpl 帖子服务实现
|
||||
type postServiceImpl struct {
|
||||
@@ -82,23 +80,18 @@ type postServiceImpl struct {
|
||||
hookManager *hook.Manager
|
||||
}
|
||||
|
||||
func NewPostService(postRepo repository.PostRepository, systemMessageService SystemMessageService, postAIService *PostAIService, cacheBackend cache.Cache, txManager repository.TransactionManager, hookManager *hook.Manager) PostService {
|
||||
func NewPostService(postRepo repository.PostRepository, systemMessageService SystemMessageService, postAIService *PostAIService, cacheBackend cache.Cache, txManager repository.TransactionManager, hookManager *hook.Manager, logService *LogService) PostService {
|
||||
return &postServiceImpl{
|
||||
postRepo: postRepo,
|
||||
systemMessageService: systemMessageService,
|
||||
cache: cacheBackend,
|
||||
postAIService: postAIService,
|
||||
txManager: txManager,
|
||||
logService: nil,
|
||||
logService: logService,
|
||||
hookManager: hookManager,
|
||||
}
|
||||
}
|
||||
|
||||
// SetLogService 设置日志服务
|
||||
func (s *postServiceImpl) SetLogService(logService *LogService) {
|
||||
s.logService = logService
|
||||
}
|
||||
|
||||
// PostListResult 帖子列表缓存结果
|
||||
type PostListResult struct {
|
||||
Posts []*model.Post
|
||||
|
||||
Reference in New Issue
Block a user