/**
 * BlogQueryHandler
 * Blog query-k kezelése
 */
export class BlogQueryHandler {
  constructor(blogRepository) {
    this.blogRepository = blogRepository;
  }

  async handleGetBlog(query) {
    const blog = await this.blogRepository.findById(query.id);
    if (!blog) {
      throw new Error('Blog not found');
    }
    return blog;
  }

  async handleGetAllBlogs(query) {
    const blogs = await this.blogRepository.findAll({
      publishedOnly: query.publishedOnly,
      limit: query.limit,
      offset: query.offset
    });
    return blogs;
  }

  async handleGetUserBlogs(query) {
    const blogs = await this.blogRepository.findByAuthorId(query.authorId);
    return blogs;
  }
}
