refactor: 重构 Space 页面为统一多 Tab 布局 + 移除独立关注/粉丝子页面
- 后端:SpaceController 支持 5 个 Tab(文章/关注/粉丝/收藏/设置),统一处理本人与访客视图 - 后端:注入 FavoriteService 支持收藏夹 Tab,新增用户统计数据查询 - 后端:新增 PUT /api/space/privacy 隐私设置 API 端点 - 后端:移除 FollowPageController 及 /space/:uid/followers|following 路由 - 前端:完全重写 space/index.html,顶部信息栏 + Tab 导航 + 左侧栏 + 主内容区 - 前端:重写 space.css 适配新布局(Profile Header/Tab Bar/文章/收藏/设置) - 清理:删除独立的 follow HTML 模板和 CSS 文件 - 模型:User 表新增 follower_list_public 隐私字段
This commit is contained in:
@ -46,11 +46,14 @@ type postStore interface {
|
||||
// spaceUserStore SpaceService 所需的最小用户仓储接口
|
||||
type spaceUserStore interface {
|
||||
FindByID(id uint) (*model.User, error)
|
||||
Update(user *model.User) error
|
||||
}
|
||||
|
||||
// spacePostStore SpaceService 所需的最小帖子仓储接口
|
||||
type spacePostStore interface {
|
||||
FindByUserID(userID uint, offset, limit int) ([]model.Post, int64, error)
|
||||
CountUserPosts(userID uint) (int64, error)
|
||||
GetUserStats(userID uint) (likes, favorites int64, err error)
|
||||
}
|
||||
|
||||
// postAdminStatStore AdminService 所需的帖子统计接口(ISP:2 个方法)
|
||||
|
||||
@ -23,3 +23,18 @@ func (s *SpaceService) GetPostsByUser(uid uint, page, pageSize int) ([]model.Pos
|
||||
offset := (page - 1) * pageSize
|
||||
return s.postRepo.FindByUserID(uid, offset, pageSize)
|
||||
}
|
||||
|
||||
// CountUserPosts 统计用户已发布文章数
|
||||
func (s *SpaceService) CountUserPosts(uid uint) (int64, error) {
|
||||
return s.postRepo.CountUserPosts(uid)
|
||||
}
|
||||
|
||||
// GetUserStats 获取用户文章统计数据(总获赞、总收藏)
|
||||
func (s *SpaceService) GetUserStats(uid uint) (likes, favorites int64, err error) {
|
||||
return s.postRepo.GetUserStats(uid)
|
||||
}
|
||||
|
||||
// UpdateUser 更新用户信息(用于隐私设置等)
|
||||
func (s *SpaceService) UpdateUser(user *model.User) error {
|
||||
return s.userRepo.Update(user)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user