feat: 管理首页帖子总数统计(总数/已发布/待审核)
- PostRepo 新增 CountPostsByStatus 和 CountPending 方法 - Service 层定义 postAdminStatStore 接口 (ISP) - AdminService 注入 postRepo,新增 PostStats 结构体和 GetPostStats 方法 - AdminController.Dashboard 调用 GetPostStats 并传参到模板 - Dashboard 帖子卡片显示总数 + 已发布 + 待审核(橙色徽章) - DI 层将 AdminController 创建从 buildDepsCore 移至 buildDeps,以便注入 postRepo
This commit is contained in:
@ -34,7 +34,7 @@ type dependencies struct {
|
||||
func buildDepsCore(db *gorm.DB, cfg *config.Config, siteSettings *config.SiteSettings, redisClient *redis.Client) (
|
||||
*repository.UserRepo, *session.Manager, *service.AuthService,
|
||||
*middleware.RateLimiter, *controller.AuthController,
|
||||
*service.AvatarService, *middleware.AuthMiddleware, *adminCtrl.AdminController,
|
||||
*service.AvatarService, *middleware.AuthMiddleware,
|
||||
) {
|
||||
userRepo := repository.NewUserRepo(db)
|
||||
|
||||
@ -65,6 +65,5 @@ func buildDepsCore(db *gorm.DB, cfg *config.Config, siteSettings *config.SiteSet
|
||||
authCtrl := controller.NewAuthController(authService, sessionMgr, rateLimiter, cfg)
|
||||
avatarSvc := service.NewAvatarService(userRepo)
|
||||
authMdw := middleware.NewAuthMiddleware(cfg, sessionMgr)
|
||||
adminController := adminCtrl.NewAdminController(service.NewAdminService(userRepo, sessionMgr))
|
||||
return userRepo, sessionMgr, authService, rateLimiter, authCtrl, avatarSvc, authMdw, adminController
|
||||
return userRepo, sessionMgr, authService, rateLimiter, authCtrl, avatarSvc, authMdw
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func buildDeps(db *gorm.DB, cfg *config.Config, siteSettings *config.SiteSettings, redisClient *redis.Client) *dependencies {
|
||||
userRepo, sessionMgr, authService, _, authCtrl, avatarSvc, authMdw, adminController := buildDepsCore(db, cfg, siteSettings, redisClient)
|
||||
userRepo, sessionMgr, authService, _, authCtrl, avatarSvc, authMdw := buildDepsCore(db, cfg, siteSettings, redisClient)
|
||||
|
||||
auditRepo := repository.NewAuditRepo(db)
|
||||
notificationRepo := repository.NewNotificationRepo(db)
|
||||
@ -37,6 +37,7 @@ func buildDeps(db *gorm.DB, cfg *config.Config, siteSettings *config.SiteSetting
|
||||
shortcodeSvc := service.NewShortcodeService()
|
||||
postCtrl := controller.NewPostController(postService, shortcodeSvc)
|
||||
adminPostCtrl := adminCtrl.NewAdminPostController(postService)
|
||||
adminController := adminCtrl.NewAdminController(service.NewAdminService(userRepo, postRepo, sessionMgr))
|
||||
studioCtrl := controller.NewStudioController(postService)
|
||||
|
||||
// 用户空间
|
||||
|
||||
Reference in New Issue
Block a user