- 新增 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 函数,分页模板中直接使用
55 lines
2.1 KiB
Go
55 lines
2.1 KiB
Go
package service
|
||
|
||
import "metazone.cc/metalab/internal/model"
|
||
|
||
// userAuthStore AuthService 所需的最小仓储接口(ISP:7 个方法)
|
||
// 同时满足 common.UsernameChecker(ExistsByUsername),可传入 GenerateUsername
|
||
type userAuthStore interface {
|
||
ExistsByEmail(email string) (bool, error)
|
||
Create(user *model.User) error
|
||
FindByEmail(email string) (*model.User, error)
|
||
FindByID(id uint) (*model.User, error)
|
||
Update(user *model.User) error
|
||
IncrementTokenVersion(userID uint) error
|
||
ExistsByUsername(username string) (bool, error)
|
||
}
|
||
|
||
// userTokenStore TokenService 所需的最小仓储接口(ISP:1 个方法)
|
||
type userTokenStore interface {
|
||
FindByIDForAuth(userID uint) (*model.User, error)
|
||
}
|
||
|
||
// userAdminStore AdminService 所需的最小仓储接口(ISP:8 个方法)
|
||
type userAdminStore interface {
|
||
CountSearchUsers(keyword, role, status string) (int64, error)
|
||
SearchUsers(keyword, role, status string, offset, limit int) ([]model.User, error)
|
||
FindByIDUnscoped(userID uint) (*model.User, error)
|
||
UpdateStatus(uid uint, status string) error
|
||
SoftDelete(uid uint) error
|
||
Restore(uid uint) error
|
||
ExistsByEmailExclude(email string, excludeUID uint) (bool, error)
|
||
IncrementTokenVersion(userID uint) error
|
||
}
|
||
|
||
// postStore PostService 所需的最小仓储接口(ISP:9 个方法)
|
||
type postStore interface {
|
||
Create(post *model.Post) error
|
||
FindByID(id uint) (*model.Post, error)
|
||
FindByIDWithAuthor(id uint) (*model.Post, error)
|
||
FindPageable(keyword string, offset, limit int) ([]model.Post, int64, error)
|
||
FindAdminPageable(keyword, status string, offset, limit int) ([]model.Post, int64, error)
|
||
FindByUserIDAndStatus(userID uint, status string, offset, limit int) ([]model.Post, int64, error)
|
||
Update(post *model.Post) error
|
||
SoftDelete(id uint) error
|
||
Restore(id uint) error
|
||
}
|
||
|
||
// spaceUserStore SpaceService 所需的最小用户仓储接口(ISP:1 个方法)
|
||
type spaceUserStore interface {
|
||
FindByID(id uint) (*model.User, error)
|
||
}
|
||
|
||
// spacePostStore SpaceService 所需的最小帖子仓储接口(ISP:1 个方法)
|
||
type spacePostStore interface {
|
||
FindByUserID(userID uint, offset, limit int) ([]model.Post, int64, error)
|
||
} |