package service

import "metazone.cc/metalab/internal/model"

// SpaceService 用户空间服务
type SpaceService struct {
	userRepo spaceUserStore
	postRepo spacePostStore
}

// NewSpaceService 构造函数
func NewSpaceService(userRepo spaceUserStore, postRepo spacePostStore) *SpaceService {
	return &SpaceService{userRepo: userRepo, postRepo: postRepo}
}

// GetSpaceUser 获取用户信息
func (s *SpaceService) GetSpaceUser(uid uint) (*model.User, error) {
	return s.userRepo.FindByID(uid)
}

// GetPostsByUser 获取用户发布的帖子（分页）
func (s *SpaceService) GetPostsByUser(uid uint, page, pageSize int) ([]model.Post, int64, error) {
	offset := (page - 1) * pageSize
	return s.postRepo.FindByUserID(uid, offset, pageSize)
}
