-
Notifications
You must be signed in to change notification settings - Fork 0
API 문서
chasw0326 edited this page May 2, 2022
·
60 revisions
| 대분류 | 기능 | method | URI |
|---|---|---|---|
| User | 회원가입 | POST | /auth/user |
| 로그인 | POST | /auth/login | |
| 토큰 확인 | POST | /api/token | |
| 이름 수정 | PUT | /api/user | |
| 비밀번호 변경 | PUT | /api/user/password | |
| Course | 코스 개설 | POST | /api/course |
| 코스 조회(학생) | GET | /api/course/student | |
| 코스 조회(선생) | GET | /api/course/teacher | |
| 코스 정보 | GET | /api/course/{courseId} | |
| 코스 수정 | PUT | /api/course/{courseId} | |
| 코스 삭제 | DELETE | /api/course/{courseId} | |
| 코스 비밀번호 변경 | PUT | /api/course/password | |
| 코스 수강생 추가 | PUT | /api/course/participant | |
| Lesson | 레슨 목록 | GET | /api/lesson/{courseId} |
| 레슨 개설 | POST | /api/lesson | |
| 레슨명 수정 | PUT | /api/lesson/name/{lessonId} | |
| 레슨 설명 수정 | PUT | /api/lesson/description/{lessonId} | |
| 레슨 삭제 | DELETE | /api/lesson |
- 회원가입
POST /auth/user
| param | type | required | description |
|---|---|---|---|
| body | true | 이메일 | |
| password | body | true | 비밀번호(영어, 숫자 포함 8~20자리 |
| name | body | true | 이름 |
{
"email": "testing@gmail.com",
"password": "abcABC123!@#",
"name": "홍길동"
}- 성공(200)
- 실패(409 Conflict) : 중복된 이메일이 존재하는 경우
- 실패(400 Bad Request)
{ "exception": "MethodArgumentNotValidException", "errors": { "password": "비밀번호는 영어와 숫자로 포함해서 8~20자리 이내로 입력해주세요." } }
- 사용자의 정보로 로그인한다.
POST /auth/login
{
"email" : "test@gmail.com",
"password" : "1q2w3eQWE!@#"
}- 성공
200 OKtext/plaineyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2NDg1NDA3NjYsImV4cCI6MTY1MTEzMjc2Niwic3ViIjoiMzI5QG5hdmVyLmNvbSJ9.nN_yyOcOwLncc-OHPMRBXdngtTHaOdEJulG5_HHKRq0 - 실패
401 Unauthorizedapplication/json{ "code": "401", "message": "자격 증명에 실패하였습니다." }
- localStorage에 담아서 다음 요청부터 Authorization에 Bearer Token으로 보내주세요.
const accessToken = localStorage.getItem("ACCESS_TOKEN");
if (accessToken && accessToken !== null) {
headers.append("Authorization", "Bearer " + accessToken);
}
- 토큰의 정보들을 확인한다.
POST /auth/token
{
"token":"eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2NDkwNzAxMjgsImV4cCI6MTY1MTY2MjEyOCwic3ViIjoic3R1ZGVudDFAbmF2ZXIuY29tIn0.rZID5ekTVeitq7Azql8xffGqjL_LXHzORndLuIbT45o"
}{
"userId": 1,
"email": "student1@naver.com",
"issuedAt": "2022-04-04T11:02:08.000+00:00",
"expiredAt": "2022-05-04T11:02:08.000+00:00",
"valid": true
}- 성공(200)
- 이름을 변경한다.
PUT /api/user
{
"name" : "로니콜먼"
}- 성공(200)
- 비밀번호를 변경한다.
PUT /api/user/password
{
"currentPassword" : "aaaAAA!@#",
"newPassword" : "bbbBBB!@#",
"checkPassword" : "bbbBBB!@#",
}- 성공(200)
- 수업 개설
POST /api/course
| param | type | required | description |
|---|---|---|---|
| name | body | true | 코스 이름 |
| password | body | true | 코스 비밀번호 |
| teacherName | body | true | 코스 강사메일 |
| description | body | true | 코스 설명 |
| participants | body | true | 참여자 이메일 배열 |
{
"name": "컴퓨터 공학 종합 설계",
"password": "1234",
"teacherName": "teacher@naver.com",
"description": "컴퓨터 공학과 졸업작품",
"participant": ["student1@naver.com", "student2@naver.com", "student3@naver.com"]
}- 성공(200)
- 내가 학생인 코스 리스트 가져오기
GET /api/course/student
- None
[
{
"courseId": 5,
"name": "컴퓨터 공학 종합 설계",
"description": "팀플과목."
},
{
"courseId": 4,
"name": "컴퓨터보안",
"description": "보안어려워"
},
{
"courseId": 1,
"name": "컴퓨터 공학 종합 설계",
"description": "팀플과목."
}
]- 내가 강사인 코스 리스트 가져오기
GET /api/course/teacher
- None
[
{
"courseId": 5,
"name": "컴퓨터 공학 종합 설계",
"description": "팀플과목."
},
{
"courseId": 4,
"name": "컴퓨터보안",
"description": "보안어려워"
},
{
"courseId": 1,
"name": "컴퓨터 공학 종합 설계",
"description": "팀플과목."
}
]- 수업정보와 참여자 정보 가져오기
GET /api/course/{courseId}
- None
{
"courseId": 2,
"name": "마이크로 프로세서 응용",
"description": "어려운 과목",
"participants": [
{
"userId": 102,
"email": "teacher2@naver.com",
"name": "teacher2"
},
{
"userId": 11,
"email": "student11@naver.com",
"name": "student11"
},
{
"userId": 12,
"email": "student12@naver.com",
"name": "student12"
},
{
"userId": 13,
"email": "student13@naver.com",
"name": "student13"
},
{
"userId": 14,
"email": "student14@naver.com",
"name": "student14"
},
{
"userId": 15,
"email": "student15@naver.com",
"name": "student15"
}
]
}- 코스를 수정한다.
PUT /api/course/{courseId}
- None
- 성공(200)
- 코스를 삭제한다.
DELETE /api/course/{courseId}
- None
- 성공(200)
- 코스에 수강생을 추가한다.
POST /api/course/student
{
"email": "newbie@korea.kr",
"courseId": 3
}- 성공(200)
- 레슨 목록 가져오기
GET /api/lesson/{courseId}
- None
{
[
{
"id": 102,
"name": "모두를 위한 프로그래밍: 파이썬",
"description": "Getting Started with Python"
},
{
"id": 104,
"name": "파이썬 자료구조",
"description": "Python Data Structures"
},
{
"id": 105,
"name": "파이썬을 이용한 웹 스크래핑",
"description": "Using Python to Access Web Data"
},
{
"id": 106,
"name": "파이썬을 이용한 데이터베이스 처리",
"description": "Using Databases With Python"
}
]
}- 레슨 개설하기
POST /api/lesson/{courseId}
{
"name" : "함수와 문자열",
"description" : "함수와 문자열에 대해 알아봅시다.",
"courseId" : "99"
}- 성공(200)
- 레슨명 수정하기
PUT /api/lesson/name/{lessonId}
{
"name" : "메서드와 문자열"
}- 성공(200)
- 레슨 설명 수정하기
PUT /api/lesson/description/{lessonId}
{
"description" : "이번주는 휴강합니다."
}- 성공(200)
- 레슨 삭제하기
DELETE /api/lesson/{lessonId}
- none
- 성공(200)