Thanks to visit codestin.com
Credit goes to github.com

Skip to content

kungbi/wolbu-assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“‘ μ›”λΆ€ κ°•μ˜ 관리 μ‹œμŠ€ν…œ

πŸ“š λ¬Έμ„œ 링크

1. ν”„λ‘œμ νŠΈ κ°œμš”

νšŒμ›κ°€μž…, κ°•μ˜ 등둝, κ°•μ˜ λͺ©λ‘ 쑰회, μˆ˜κ°•μ‹ μ²­μ„ μ§€μ›ν•˜λŠ” RESTful API μ„œλ²„μž…λ‹ˆλ‹€.

μ£Όμš” κΈ°λŠ₯

  • νšŒμ› 관리 (μˆ˜κ°•μƒ/강사 ꡬ뢄)
  • κ°•μ˜ 등둝 및 λͺ©λ‘ 쑰회 (νŽ˜μ΄μ§•, μ •λ ¬ 지원)
  • μˆ˜κ°•μ‹ μ²­/μ·¨μ†Œ (μ„ μ°©μˆœ 정원 관리, λ™μ‹œμ„± μ œμ–΄)
  • JWT 기반 인증/인가
  • μ†Œν”„νŠΈ μ‚­μ œ λ°©μ‹μ˜ μž¬μˆ˜κ°• ν—ˆμš©

기술 μŠ€νƒ

  • Framework: Spring Boot 3.5.6
  • Language: Java 17
  • Database: H2 (in-memory)
  • Authentication: JWT (JSON Web Token)
  • Documentation: Swagger/OpenAPI 3
  • Build Tool: Gradle

2. μ‹€ν–‰ 방법

2.1 사전 μš”κ΅¬μ‚¬ν•­

  • JDK 17 이상
  • Git

2.2 ν”„λ‘œμ νŠΈ μ‹€ν–‰

  1. ν”„λ‘œμ νŠΈ 클둠

    git clone https://github.com/kungbi/wolbu-assignment.git
    cd wolbu-assignment
  2. μ• ν”Œλ¦¬μΌ€μ΄μ…˜ μ‹€ν–‰

    # Gradle Wrapper μ‚¬μš© (ꢌμž₯)
    ./gradlew bootRun
    
    # λ˜λŠ” JAR λΉŒλ“œ ν›„ μ‹€ν–‰
    ./gradlew build
    java -jar build/libs/assignment-0.0.1-SNAPSHOT.jar
  3. μ‹€ν–‰ 확인

2.3 개발 도ꡬ μ ‘κ·Ό

2.4 H2 μ½˜μ†” μ‚¬μš© (선택사항)

H2 μ½˜μ†”μ„ μ‚¬μš©ν•˜λ €λ©΄ src/main/resources/application.propertiesμ—μ„œ λ‹€μŒ μ„€μ •μ˜ 주석을 ν•΄μ œν•˜μ„Έμš”:

spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:testdb;MODE=MYSQL;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=sa
spring.datasource.password=

3. API μ‚¬μš© μ˜ˆμ‹œ

3.1 κΈ°λ³Έ API μ—”λ“œν¬μΈνŠΈ

  • νšŒμ›κ°€μž…: POST /api/auth/signup
  • 둜그인: POST /api/auth/login
  • κ°•μ˜ 등둝: POST /api/lectures (κ°•μ‚¬λ§Œ κ°€λŠ₯)
  • κ°•μ˜ λͺ©λ‘: GET /api/lectures?sort=RECENT&page=0&size=20
  • μˆ˜κ°•μ‹ μ²­: POST /api/enrollments (닀건 μ‹ μ²­ κ°€λŠ₯)
  • μˆ˜κ°•μ·¨μ†Œ: DELETE /api/enrollments/{enrollmentId}

3.2 curl μ˜ˆμ‹œ

  1. νšŒμ›κ°€μž… (μˆ˜κ°•μƒ)

    curl -X POST http://localhost:8080/api/auth/signup \
      -H "Content-Type: application/json" \
      -d '{
        "name": "홍길동",
        "email": "[email protected]",
        "phone": "010-1234-5678",
        "password": "password123",
        "role": "STUDENT"
      }'
  2. 둜그인

    curl -X POST http://localhost:8080/api/auth/login \
      -H "Content-Type: application/json" \
      -d '{
        "email": "[email protected]",
        "password": "password123"
      }'
  3. κ°•μ˜ λͺ©λ‘ 쑰회

    curl -X GET "http://localhost:8080/api/lectures?sort=RECENT&page=0&size=20"
  4. μˆ˜κ°•μ‹ μ²­

    curl -X POST http://localhost:8080/api/enrollments \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer YOUR_JWT_TOKEN" \
      -d '{
        "lectureIds": [1, 2, 3]
      }'

4. λΉ„μ¦ˆλ‹ˆμŠ€ κ·œμΉ™ μš”μ•½

  • 이메일 쀑볡 λΆˆκ°€, λΉ„λ°€λ²ˆν˜Έ κ·œμΉ™(6~10자, μ˜λŒ€μ†Œλ¬Έμž+숫자 2μ’… 이상)
  • κ°•μ‚¬λ§Œ κ°•μ˜ κ°œμ„€ κ°€λŠ₯, μˆ˜κ°•μ‹ μ²­μ€ λͺ¨λ‘ κ°€λŠ₯
  • κ°•μ˜ 정원 μ„ μ°©μˆœ 보μž₯
  • μ†Œν”„νŠΈ μ‚­μ œ + μž¬μˆ˜κ°• ν—ˆμš©: μ·¨μ†ŒλŠ” μƒνƒœ λ³€κ²½μœΌλ‘œ 처리, μž¬μˆ˜κ°• κ°€λŠ₯
  • ν™œμ„± 쀑볡 μ‹ μ²­ λΆˆκ°€(동일 κ°•μ˜μ— CONFIRMED μƒνƒœ 1건만 ν—ˆμš©)
  • 정원 계산은 ν™œμ„± 등둝(CONFIRMED)만 κΈ°μ€€

5. 인증 규격

  • νšŒμ›κ°€μž…(signup): 토큰 λ―Έλ°œκΈ‰, μ‚¬μš©μž μ •λ³΄λ§Œ λ°˜ν™˜
  • 둜그인(login): Access Token은 응닡 body(accessToken), Refresh Token은 HttpOnly μΏ ν‚€(refreshToken)
  • 토큰 μŠ€ν‚€λ§ˆ: JWT HS256, payload에 sub(userId), email, role

6. μ—λŸ¬ 응닡 규격

  • ν˜•μ‹: JSON Body {error: { "code": "COURSE_FULL", "message": "정원이 μ΄ˆκ³Όλ˜μ—ˆμŠ΅λ‹ˆλ‹€." }}

  • 곡톡 μ½”λ“œ μ˜ˆμ‹œ:

    • 400: μž…λ ₯ 검증 μ‹€νŒ¨
    • 401/403: μΈμ¦Β·κΆŒν•œ μ‹€νŒ¨
    • 404: λ¦¬μ†ŒμŠ€ μ—†μŒ
    • 409: 정원 μ΄ˆκ³ΌΒ·μ€‘λ³΅ μ‹ μ²­

7. ν…ŒμŠ€νŠΈ

  • μ‹€ν–‰: ./gradlew test

  • 컀버 λ²”μœ„:

    • νšŒμ›κ°€μž… 검증
    • κ°•μ˜ 등둝/λͺ©λ‘ μ •λ ¬
    • 정원 초과/쀑볡 μ‹ μ²­
    • λ™μ‹œμ„± ν…ŒμŠ€νŠΈ (μ—¬λŸ¬ μš”μ²­ β†’ 정원 초과 μ—†μŒ 확인)

8. ν…ŒμŠ€νŠΈ

8.1 전체 ν…ŒμŠ€νŠΈ μ‹€ν–‰

./gradlew test

8.2 ν…ŒμŠ€νŠΈ 컀버리지

  • νšŒμ›κ°€μž… 검증 (이메일 쀑볡, λΉ„λ°€λ²ˆν˜Έ μ •μ±…)
  • κ°•μ˜ 등둝/λͺ©λ‘ μ •λ ¬ κΈ°λŠ₯
  • μˆ˜κ°•μ‹ μ²­ 정원 초과/쀑볡 μ‹ μ²­ λ°©μ§€
  • λ™μ‹œμ„± ν…ŒμŠ€νŠΈ (닀쀑 μ‚¬μš©μž λ™μ‹œ μ‹ μ²­ μ‹œ 정원 보μž₯)
  • μž¬μˆ˜κ°• ν—ˆμš© μ‹œλ‚˜λ¦¬μ˜€

8.3 ν…ŒμŠ€νŠΈ λ³΄κ³ μ„œ

ν…ŒμŠ€νŠΈ μ‹€ν–‰ ν›„ build/reports/tests/test/index.htmlμ—μ„œ 상세 κ²°κ³Όλ₯Ό 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.

9. ν”„λ‘œμ νŠΈ ꡬ쑰

src/main/java/com/company/wolbu/assignment/
β”œβ”€β”€ AssignmentApplication.java          # 메인 μ• ν”Œλ¦¬μΌ€μ΄μ…˜ 클래슀
β”œβ”€β”€ auth/                              # 인증/인가 도메인
β”‚   β”œβ”€β”€ controller/                    # REST API 컨트둀러
β”‚   β”œβ”€β”€ domain/                        # 도메인 μ—”ν‹°ν‹° (Member, RefreshToken)
β”‚   β”œβ”€β”€ dto/                           # μš”μ²­/응닡 DTO
β”‚   β”œβ”€β”€ exception/                     # 도메인 μ˜ˆμ™Έ
β”‚   β”œβ”€β”€ repository/                    # 데이터 μ ‘κ·Ό 계측
β”‚   β”œβ”€β”€ security/                      # JWT, λ³΄μ•ˆ μ„€μ •
β”‚   └── service/                       # λΉ„μ¦ˆλ‹ˆμŠ€ 둜직
β”œβ”€β”€ common/                            # 곡톡 μ»΄ν¬λ„ŒνŠΈ
β”‚   β”œβ”€β”€ config/                        # Swagger λ“± μ„€μ •
β”‚   β”œβ”€β”€ dto/                           # 곡톡 응닡 DTO
β”‚   β”œβ”€β”€ exception/                     # κΈ€λ‘œλ²Œ μ˜ˆμ™Έ 처리
β”‚   └── logging/                       # λ‘œκΉ… μ„€μ •
β”œβ”€β”€ config/                            # μ „μ—­ μ„€μ •
β”œβ”€β”€ enrollment/                        # μˆ˜κ°•μ‹ μ²­ 도메인
β”‚   β”œβ”€β”€ controller/                    # μˆ˜κ°•μ‹ μ²­ API
β”‚   β”œβ”€β”€ domain/                        # μˆ˜κ°•μ‹ μ²­ μ—”ν‹°ν‹°
β”‚   β”œβ”€β”€ dto/                           # μˆ˜κ°•μ‹ μ²­ DTO
β”‚   β”œβ”€β”€ exception/                     # μˆ˜κ°•μ‹ μ²­ μ˜ˆμ™Έ
β”‚   β”œβ”€β”€ repository/                    # μˆ˜κ°•μ‹ μ²­ λ ˆν¬μ§€ν† λ¦¬
β”‚   └── service/                       # μˆ˜κ°•μ‹ μ²­ λΉ„μ¦ˆλ‹ˆμŠ€ 둜직
β”œβ”€β”€ health/                            # ν—¬μŠ€μ²΄ν¬ API
β”œβ”€β”€ lecture/                           # κ°•μ˜ 도메인
β”‚   β”œβ”€β”€ controller/                    # κ°•μ˜ API
β”‚   β”œβ”€β”€ domain/                        # κ°•μ˜ μ—”ν‹°ν‹°
β”‚   β”œβ”€β”€ dto/                           # κ°•μ˜ DTO
β”‚   β”œβ”€β”€ exception/                     # κ°•μ˜ μ˜ˆμ™Έ
β”‚   β”œβ”€β”€ repository/                    # κ°•μ˜ λ ˆν¬μ§€ν† λ¦¬
β”‚   └── service/                       # κ°•μ˜ λΉ„μ¦ˆλ‹ˆμŠ€ 둜직

10. μΆ”κ°€ 정보

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages