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:
@ -66,6 +66,11 @@ type postAdminStatStore interface {
|
||||
CountPending() (int64, error)
|
||||
}
|
||||
|
||||
// userExpReader PostService 读取用户经验值的最小接口(ISP)
|
||||
type userExpReader interface {
|
||||
FindByID(id uint) (*model.User, error)
|
||||
}
|
||||
|
||||
// postNotifier PostService 所需的通知服务接口
|
||||
type postNotifier interface {
|
||||
NotifyPostApproved(userID uint, postTitle string, postID uint)
|
||||
|
||||
Reference in New Issue
Block a user