[Spring] 인터넷 강의 구현 1 - API Spec 설계

춤인형의 개발일지·2025년 2월 20일

Spring실습

목록 보기
28/40

도메인 제약(요구) 사항

  • 강의강사는 딱 한 명
  • 강사는 여러 개의 강의를 진행할 수 있음
  • 강의는 하나의 카테고리에만 속함 (카테고리: 국어, 수학, 영어, 과학, 사회)
  • 강의수강생은 여러 명
  • 수강생도 여러 강의를 수강할 수 있음. 단, 같은 강의를 여러 번 신청할 수는 없음

내가 짠 API Spec이다.

관계

  • 강의 : 강사 한명 / 여러 수강생
  • 강사 : 여러 강의
  • 수강생 : 여러 강의
  • 강사 N:1 강의 | 수강생 : N:M

📚 강의

➡️ 강의 목록 조회

  • Method: GET
  • Path: /lectures
  • Example Endpoint: https://localhost:8080/lectures
  • Response:
    • id (Long): 강의 ID
    • title (String): 강의 제목
    • teacherName (String): 강사 이름
    • price (Number): 강의 가격
    • count (Number): 수강생 수
    • category (Category): 강의 카테고리
    • createTime (LocalDateTime): 강의 등록 일시

➡️ 강의 상세 조회

  • Method: GET
  • Path: /lectures/{lectureId}
  • Example Endpoint: https://localhost:8080/lectures/1
  • Request Parameters:
    • Path Parameters:
      • lectureId (Long): 강의 ID
  • Response:
    • id (Long): 강의 ID
    • title (String): 강의 제목
    • introduce (String): 강의 소개
    • price (Number): 강의 가격
    • studentCount (Number): 수강생 수
    • StudentResponse (List):
      • nickName (String): 수강생 닉네임
      • enrollmentTime (LocalDateTime): 수강 신청 일시
    • category (Category): 강의 카테고리
    • createTime (LocalDateTime): 강의 등록 일시
    • updateTime (LocalDateTime): 마지막 업데이트 일시

➡️ 강의 등록

  • Method: POST
  • Path: /lectures
  • Example Endpoint: https://localhost:8080/lectures
  • Request Parameters:
    • Body Parameters:
      • title (String): 강의 제목
      • introduce (String): 강의 소개
      • price (Number): 강의 가격
      • category (Category): 강의 카테고리
      • teacherName (String): 강사 이름
      • createTime (LocalDateTime): 강의 등록 일시
  • Response:
    • id (Long): 강의 ID
    • title (String): 강의 제목
    • introduce (String): 강의 소개
    • price (Number): 강의 가격
    • category (Category): 강의 카테고리
    • teacherName (String): 강사 이름
    • createTime (LocalDateTime): 강의 등록 일시

➡️ 강의 삭제

  • Method: DELETE
  • Path: /lectures/{lectureId}
  • Example Endpoint: https://localhost:8080/lectures/1
  • Request Parameters:
    • Path Parameters:
      • lectureId (Long): 강의 ID
  • Response:
    • id (Long): 삭제된 강의 ID

➡️ 강의 수정

  • Method: PUT
  • Path: /lectures/{lectureId}
  • Example Endpoint: https://localhost:8080/lectures/1
  • Request Parameters:
    • Path Parameters:
      • lectureId (Long): 강의 ID
    • Body Parameters: (수정할 필드만 포함)
      • title (String): 강의 제목
      • introduce (String): 강의 소개
      • price (Number): 강의 가격
  • Response:
    • id (Long): 수정된 강의 ID
    • title (String): 수정된 강의 제목
    • introduce (String): 수정된 강의 소개
    • price (Number): 수정된 강의 가격
    • category (Category): 수정된 강의 카테고리
    • updateTime (LocalDateTime): 수정 일시

👥회원

➡️ 회원가입

  • Method: POST
  • Path: /members/signup
  • Example Endpoint: https://localhost:8080/members/signup
  • Request Parameters:
    • Body Parameters:
      • email (String): 이메일
      • nickName (String): 닉네임
  • Response:
    • id (Long): 회원 ID
    • email (String): 이메일
    • nickName (String): 닉네임

➡️ 회원탈퇴

  • Method: Delete
  • Path: /members/{memberId}
  • Example Endpoint: https://localhost:8080/members/1
  • Request Parameters:
    • Path Parameters:
      • id (Long): 회원 ID
  • Response:
    • id (Long): 회원 ID

수강신청

  • Method: POST
  • Path: /lectures/{lectureId}
  • Example Endpoint: https://localhost:8080/lectures/1
  • Request Parameters:
    • Path Parameters:
      • id (Long): 강의 ID
      • id (Long): 회원 ID
  • Response:
    • id (Long): 강의 ID
    • id (Long): 회원 ID

이렇게 나눠봤다. 일단, 1차적인 CRUD를 작성해보고, 그 추가적인 기능을 작성해봐야겠다

0개의 댓글