refactor: remove Gorse integration and implement HotRank feature
Some checks failed
Build Backend / build-docker (push) Has been cancelled
Build Backend / build (push) Has been cancelled

- Removed Gorse-related configurations, handlers, and dependencies from the codebase.
- Introduced HotRank feature with configuration options for ranking posts based on recent activity.
- Updated application structure to support HotRank processing, including new caching mechanisms and database interactions.
- Cleaned up related DTOs and repository methods to reflect the removal of Gorse and the addition of HotRank functionality.
This commit is contained in:
lafay
2026-03-24 05:18:30 +08:00
parent b41567a39a
commit 176cd20847
32 changed files with 735 additions and 1128 deletions

View File

@@ -2,14 +2,12 @@ package wire
import (
"carrot_bbs/internal/cache"
"carrot_bbs/internal/config"
"carrot_bbs/internal/handler"
"carrot_bbs/internal/pkg/sse"
"carrot_bbs/internal/repository"
"carrot_bbs/internal/service"
"github.com/google/wire"
"gorm.io/gorm"
)
// HandlerSet Handler 层 Provider Set
@@ -36,7 +34,6 @@ var HandlerSet = wire.NewSet(
ProvideMessageHandler,
ProvideSystemMessageHandler,
ProvideGroupHandler,
ProvideGorseHandler,
ProvideScheduleHandler,
)
@@ -115,11 +112,6 @@ func ProvideGroupHandler(
return handler.NewGroupHandler(groupService, userService)
}
// ProvideGorseHandler 提供 Gorse 处理器
func ProvideGorseHandler(cfg *config.Config, db *gorm.DB) *handler.GorseHandler {
return handler.NewGorseHandler(cfg.Gorse, db)
}
// ProvideScheduleHandler 提供课表处理器
func ProvideScheduleHandler(
scheduleService service.ScheduleService,

View File

@@ -8,7 +8,6 @@ import (
"carrot_bbs/internal/model"
"carrot_bbs/internal/pkg/crypto"
"carrot_bbs/internal/pkg/email"
"carrot_bbs/internal/pkg/gorse"
"carrot_bbs/internal/pkg/hook"
"carrot_bbs/internal/pkg/openai"
"carrot_bbs/internal/pkg/redis"
@@ -49,7 +48,6 @@ var InfrastructureSet = wire.NewSet(
ProvideSSEHub,
// 外部服务客户端
ProvideGorseClient,
ProvideOpenAIClient,
ProvideEmailClient,
ProvideS3Client,
@@ -163,11 +161,6 @@ func ProvideSSEHub() *sse.Hub {
return sse.NewHub()
}
// ProvideGorseClient 提供 Gorse 客户端
func ProvideGorseClient(cfg *config.Config) gorse.Client {
return gorse.NewClient(gorse.ConfigFromAppConfig(&cfg.Gorse))
}
// ProvideOpenAIClient 提供 OpenAI 客户端
func ProvideOpenAIClient(cfg *config.Config) openai.Client {
return openai.NewClient(openai.ConfigFromAppConfig(&cfg.OpenAI))

View File

@@ -7,7 +7,6 @@ import (
"carrot_bbs/internal/config"
"carrot_bbs/internal/grpc/runner"
"carrot_bbs/internal/pkg/email"
"carrot_bbs/internal/pkg/gorse"
"carrot_bbs/internal/pkg/hook"
"carrot_bbs/internal/pkg/openai"
"carrot_bbs/internal/pkg/redis"
@@ -53,6 +52,7 @@ var ServiceSet = wire.NewSet(
ProvideAdminGroupService,
ProvideAdminDashboardService,
ProvideQRCodeLoginService,
ProvideHotRankWorker,
// 日志服务
ProvideAsyncLogManager,
@@ -106,7 +106,6 @@ func ProvideSystemMessageService(
func ProvidePostService(
postRepo *repository.PostRepository,
systemMessageService service.SystemMessageService,
gorseClient gorse.Client,
postAIService *service.PostAIService,
cacheBackend cache.Cache,
txManager repository.TransactionManager,
@@ -114,19 +113,18 @@ func ProvidePostService(
_ *hook.ModerationHooks,
_ *hook.BuiltinHooks,
) service.PostService {
return service.NewPostService(postRepo, systemMessageService, gorseClient, postAIService, cacheBackend, txManager, hookManager)
return service.NewPostService(postRepo, systemMessageService, postAIService, cacheBackend, txManager, hookManager)
}
func ProvideCommentService(
commentRepo *repository.CommentRepository,
postRepo *repository.PostRepository,
systemMessageService service.SystemMessageService,
gorseClient gorse.Client,
postAIService *service.PostAIService,
cacheBackend cache.Cache,
hookManager *hook.Manager,
) *service.CommentService {
return service.NewCommentService(commentRepo, postRepo, systemMessageService, gorseClient, postAIService, cacheBackend, hookManager)
return service.NewCommentService(commentRepo, postRepo, systemMessageService, postAIService, cacheBackend, hookManager)
}
// ProvideMessageService 提供消息服务
@@ -349,6 +347,10 @@ func ProvideLogService(
}
// ProvideQRCodeLoginService 提供二维码登录服务
func ProvideHotRankWorker(cfg *config.Config, postRepo *repository.PostRepository, cacheBackend cache.Cache) *service.HotRankWorker {
return service.NewHotRankWorker(cfg, postRepo, cacheBackend)
}
func ProvideQRCodeLoginService(
redisClient *redis.Client,
sseHub *sse.Hub,