- 编辑器投稿页布局优化:标题与编辑器高度动态适配,工具栏与内容区视觉对齐 - 稿件展示页布局优化:MD 渲染区与评论区视觉分离,代码块主题微调 - CSRF 中间件:图像上传端点豁免,解决 Vditor 拖拽/粘贴上传 403 - Post 状态映射、GetGinUser、SaveUploadedFile 提取至 common 包,遵循审计建议 - 新增个人空间功能:/space(需登录)重定向到 /space/:uid,/space/:uid 公开访问 - 空间页模板:参考 B 站布局,展示头像、用户名、个性签名、UID、加入时间及稿件列表 - 导航栏:用户名链接指向 /space,新增「设置」入口 - 分层实现:SpaceController → SpaceService → PostRepo.FindByUserID,严格 ISP 接口隔离
44 lines
1.7 KiB
Go
44 lines
1.7 KiB
Go
package controller
|
||
|
||
import (
|
||
"metazone.cc/metalab/internal/middleware"
|
||
"metazone.cc/metalab/internal/model"
|
||
)
|
||
|
||
// authUseCase AuthController 对 AuthService 的最小依赖(ISP:4 个方法)
|
||
type authUseCase interface {
|
||
Register(req model.RegisterRequest, regIP string) (string, string, *model.User, error)
|
||
Login(req model.LoginRequest, loginIP string) (string, string, *model.User, error)
|
||
ConfirmRestore(req model.LoginRequest, loginIP string) (string, string, *model.User, error)
|
||
CheckEmail(email string) (bool, error)
|
||
}
|
||
|
||
// tokenRefresher AuthController 对 TokenService 的最小依赖(ISP:1 个方法)
|
||
type tokenRefresher interface {
|
||
RefreshAccessToken(refreshTokenStr string) (string, *model.User, error)
|
||
}
|
||
|
||
// rateLimiter AuthController 对 RateLimiter 的最小依赖(ISP:3 个方法)
|
||
type rateLimiter interface {
|
||
AllowAccount(email string) (middleware.RateLimitResult, func())
|
||
AllowIP(ip string) (middleware.RateLimitResult, func())
|
||
Clear(email, ip string)
|
||
}
|
||
|
||
// postUseCase PostController 对 PostService 的最小依赖(ISP:7 个方法)
|
||
type postUseCase interface {
|
||
Create(userID uint, title, body string) (*model.Post, error)
|
||
GetByID(id uint) (*model.Post, error)
|
||
List(keyword string, page, pageSize int) ([]model.Post, int64, error)
|
||
Update(postID uint, title, body string) error
|
||
Delete(postID uint) error
|
||
SubmitForAudit(postID uint) error
|
||
IsPostAccessible(userID uint, role string, postUserID uint) bool
|
||
}
|
||
|
||
// spaceUseCase SpaceController 对 SpaceService 的最小依赖(ISP:2 个方法)
|
||
type spaceUseCase interface {
|
||
GetSpaceUser(uid uint) (*model.User, error)
|
||
GetPostsByUser(uid uint, page, pageSize int) ([]model.Post, int64, error)
|
||
}
|