refactor: Controller 不直接读 Session Exp,新增 CanCreatePost 方法

- 新增 userExpReader 最小接口(ISP),PostService 通过它读取用户经验值
- PostService 新增 CanCreatePost(userID uint) bool,封装 LV0 投稿权限判断
- StudioController 替换内联 c.Get("exp") 检查为调用 ctrl.postService.CanCreatePost(uid)
- 更新 DI 注入链:NewPostService 增加 userRepo 参数
This commit is contained in:
2026-06-02 16:52:44 +08:00
parent 3df7b2e672
commit 3e0fed80ce
5 changed files with 23 additions and 8 deletions

View File

@ -51,7 +51,7 @@ func buildDeps(db *gorm.DB, cfg *config.Config, siteSettings *config.SiteSetting
)
postRepo := repository.NewPostRepo(db)
postService := service.NewPostService(postRepo, siteSettings, notificationService)
postService := service.NewPostService(postRepo, siteSettings, notificationService, userRepo)
shortcodeSvc := service.NewShortcodeService()
postCtrl := controller.NewPostController(postService, shortcodeSvc)
adminPostCtrl := adminCtrl.NewAdminPostController(postService)