- 新增 StudioController,依赖 studioUseCase 接口,遵循 ISP 接口隔离 - PostRepo 新增 FindByUserIDAndStatus 方法,按用户+状态分页查询 - PostService 新增 ListByUser、GetOverview 及 StudioOverview 统计 - /studio 页面路由(概览/管理/草稿箱/写文章/数据分析)+ /api/studio API - 复用 Vditor 编辑器,studio-editor.js 对接 /api/studio/posts 端点 - 新增 studio.css(B站风格三栏布局+统计卡片+状态筛选tabs) - 模板引擎注册 add/subtract 函数,分页模板中直接使用
57 lines
2.2 KiB
Go
57 lines
2.2 KiB
Go
package controller
|
||
|
||
import (
|
||
"metazone.cc/metalab/internal/middleware"
|
||
"metazone.cc/metalab/internal/model"
|
||
"metazone.cc/metalab/internal/service"
|
||
)
|
||
|
||
// 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
|
||
}
|
||
|
||
// studioUseCase StudioController 对 PostService 的最小依赖(ISP:8 个方法)
|
||
type studioUseCase interface {
|
||
Create(userID uint, title, body string) (*model.Post, error)
|
||
GetByID(id uint) (*model.Post, error)
|
||
Update(postID uint, title, body string) error
|
||
Delete(postID uint) error
|
||
SubmitForAudit(postID uint) error
|
||
ListByUser(userID uint, status string, page, pageSize int) ([]model.Post, int64, error)
|
||
GetOverview(userID uint) (*service.StudioOverview, 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)
|
||
}
|