Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[새로운 기능 제안] 게시글 북마크 기능 추가 #28

Open
kakasoo opened this issue Sep 11, 2024 · 0 comments
Open

[새로운 기능 제안] 게시글 북마크 기능 추가 #28

kakasoo opened this issue Sep 11, 2024 · 0 comments

Comments

@kakasoo
Copy link
Contributor

kakasoo commented Sep 11, 2024

새로운 API 제안: 게시글 북마크 기능 추가

게시글을 북마크할 수 있는 API를 제안합니다. 이 기능을 통해 사용자는 나중에 다시 보고 싶은 게시글을 북마크하고 목록으로 조회할 수 있습니다.

제안된 API

  1. 게시글 북마크 추가

    • URL: POST /api/v1/articles/:id/bookmark
    • 설명: 특정 게시글을 북마크합니다.
    • 요청 본문: 없음
    • 응답: 북마크 추가 성공 여부
  2. 북마크된 게시글 목록 조회

    • URL: GET /api/v1/articles/bookmarks
    • 설명: 사용자가 북마크한 게시글 목록을 조회합니다.
    • 요청 매개변수: PaginationDto (페이지 정보)
    • 응답: 북마크된 게시글 목록

API 구현 예시

@UseGuards(JwtGuard)
@Controller('api/v1/articles')
export class ArticlesController {
  constructor(private readonly articlesService: ArticlesService) {}

  @TypedRoute.Post(':id/bookmark')
  public async bookmarkArticle(
    @UserId() userId: number,
    @TypedParam('id', 'number') articleId: number
  ): Promise<TryCatch<true, CANNOT_FINDONE_ARTICLE>> {
    const article = await this.articlesService.getOneDetailArticle(userId, articleId);
    if (!article) {
      return typia.random<CANNOT_FINDONE_ARTICLE>();
    }

    await this.articlesService.bookmark(userId, articleId);
    return createResponseForm(true);
  }

  @TypedRoute.Get('bookmarks')
  public async getBookmarkedArticles(
    @UserId() userId: number,
    @TypedQuery() paginationDto: PaginationDto
  ): Promise<TryPagination<ArticleType.GetAllArticlesReponse>> {
    const articlesToRead = await this.articlesService.getBookmarkedByUser(userId, paginationDto);
    const response = createPaginationForm(articlesToRead, paginationDto);
    return response;
  }
}

이 기능이 추가되면 사용자 경험이 향상될 것으로 기대됩니다. 검토 부탁드립니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant