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

게시판 메인 기능 API #2

Open
rlawltjd8547 opened this issue Oct 25, 2024 · 2 comments
Open

게시판 메인 기능 API #2

rlawltjd8547 opened this issue Oct 25, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@rlawltjd8547
Copy link
Collaborator

rlawltjd8547 commented Oct 25, 2024

시퀀스 다이어그램

https://gitmind.com/app/docs/fxhaw428

1. 페이지 기반 API

Image

Image

2. 커서 기반 API

Image

커서기반의 경우 커서(도메인)으로 다음페이지요청시 최초요청시의 마지막 커서값을 저장해놓고 이후 요청시
값을 비교하며 조회를 진행한다 (해당다이어그램은 다음 페이지 효청 다이어그램이다)
Image

할 일

할 일을 작성해주세요.

  1. 페이징 처리는 20,50,100 개 게시글을 볼수있는 페이징 처리가 필요하고
    기본값은 20이다
  2. 커서기반방식 조회와 offset방식 2가지 모두 구현
@rlawltjd8547 rlawltjd8547 self-assigned this Oct 25, 2024
@rlawltjd8547 rlawltjd8547 added the enhancement New feature or request label Oct 25, 2024
@rlawltjd8547
Copy link
Collaborator Author

rlawltjd8547 commented Jan 11, 2025

게시판 기능(offset기반) api스펙

기본정보

메서드 URL
GET /v1/mainBoard

게시판의 메인 화면에 필요한 게시글 목록을 조회합니다. 최초 조회는 offset방식입니다

요청

쿼리파라미터

이름 타입 설명 필수
limit Long 한 번에 조회할 게시글 수(기본값:20) O
page String 조회할페이지 O
offset Long offset값 X
keyword String 검색어조회시 조회키워드 X
sort String 정렬기준(default-날짜 내림차순) X

예제

첫페이지(최초)요청

curl -X GET 
"<https://api.Board.com/v1/mainBoard/page=1&limit=20" \>" \
-H "Content-Type: application/json"

다음 페이지 요청

curl -X GET 
"<https://api.Board.com/v1/mainBoard/page=2&limit=20&offset=20" \>" \
-H "Content-Type: application/json"

검색어 포함 요청

curl -X GET 
"<https://api.Board.com/v1/mainBoard/page=1&limit=20&keyword=검색" \>" \
-H "Content-Type: application/json"

응답 성공

  • HTTP/1.1 200OK
{
  "content": [
    {
      "id": 1,
      "title": "첫 번째 게시글",
      "author": "작성자1",
      "create_date": "2025-01-10T12:34:56",
      "view_count": 120,
      "like_count": 45,
      "comment_count": 5
    },
    {
      "id": 2,
      "title": "두 번째 게시글",
      "author": "작성자2",
      "create_date": "2025-01-09T15:22:30",
      "view_count": 98,
      "like_count": 30,
      "comment_count": 1
    }
  ]
}

응답 실패

  • 잘못된 요청 파라미터시
400 Bad Request
{
  "message": "유효하지 않은 요청 파라미터입니다."
}
  • 서버오류
500 Server Error
{
  "message": "서버 오류가 발생했습니다. 잠시 후 다시 시도해주세요."
}

@rlawltjd8547
Copy link
Collaborator Author

rlawltjd8547 commented Jan 13, 2025

게시판 검색기능(cursor기) api스펙

기본정보

메서드 URL
GET /v1/mainBoard/cursor/

게시판의 메인 화면에서 커서기반 페이지 사용시
nextCursor를 기준으로 다음 데이터를 요청합니다.

요청

쿼리파라미터

이름 타입 설명 필수
limit Integer 한 번에 조회할 게시글 수(기본값:20) O
cursor String 이전 응답에서 받은 커서 (데이터 기준값) X
keyword String 검색어조회시 조회키워드 X
sort String 정렬기준(default-날짜 내림차순) X

예제

커서기반 최초요청

curl -X GET 
"<https://api.Board.com/v1/mainBoard/cursor?limit=20>" \
-H "Content-Type: application/json"

다음 페이지 요청

curl -X GET 
"<https://api.Board.com/v1/mainBoard/cursor?limit=20&cursor=2025-01-09T15:22:30&keyword=검색어>" \
-H "Content-Type: application/json"

응답 성공

  • HTTP/1.1 200OK
{
  "content": [
    {
      "id": 1,
      "title": "첫 번째 게시글",
      "author": "작성자1",
      "create_date": "2025-01-10T12:34:56",
      "view_count": 120,
      "like_count": 45,
      "comment_count": 5
    },
    {
      "id": 2,
      "title": "두 번째 게시글",
      "author": "작성자2",
      "create_date": "2025-01-09T15:22:30",
      "view_count": 98,
      "like_count": 30,
      "comment_count": 1
    }
  ],
  "nextCursor": "2025-01-09T15:22:30",
  "hasMore": true
}

응답 실패

  • 서버오류
500 Server Error
{
  "message": "서버 오류가 발생했습니다. 잠시 후 다시 시도해주세요."
}

@rlawltjd8547 rlawltjd8547 changed the title 게시판 메인(목록)화면 게시판 메인 기능 API Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant