Entity를 먼저 같이 설계한 후 API를 나눠서 작성하기로 했다.
필요한 Entity는 개발자, 기업, 좋아요, 쪽지, 라고 생각했다.
대충 생각하기로는 좋아요와 쪽지는 개발자id, 기업의 id를 가지고만 있으면 된다 생각해서, 1:N관계 그 이상도, 그 이하도 아니라고 생각했다. 그래서 나온 엔티티는 아래와 같다.
<개발자>
기본 아이디 (id)
회원 아이디 (userId)
비밀 번호 (password)
이름 (name)
나이 (age)
이메일 (email)
경력 (personalHistory)
분야 (field)
자기소개 (selfIntroduction
자격증 (certificate)
좋아요 개수 (likeCount)
<기업>
id
userId
password
기업 이름
업종(businessType)
분야(field)
홈페이지(website)
지역(address)
사원수(employeeCount)
기업 소개(introduction)
설립 연도(established)
좋아요 개수(likeCount)
<좋아요>
id
개발자id (programmer_id)
기업id (company_id)
<쪽지>
id
개발자id (programmer_id)
기업id (company_id)
열람여부 (isOpened)
이정도로 나눠보고 생각이 들었던 건, 분야를 기업과 개발자 둘다 가지고 있고, 또 분야는 여러개를 선택할 수 있게 하자는 의견이 나와서 Enum으로 빼자고 했다. Enum은 같은 데이터에 이름만 다르기 때문에 쉽고 편하게 쓸 수 있다.
<분야>
프론트
백
풀스택
db관리자
서버관리자
이렇게 정리했다.
내가 맡은 부분은 쪽지 부분이다.
쪽지생성 = 쪽지를 보내는 건 쪽지를 만들어서 보낸다는 거니까 쪽지를 만드는것이다.
## ➡️ **생성**
- **Method**: `POST`
- **Path**: `/messages`
- **Example Endpoint**: https://localhost:8080/messages
- **Request Parameters**:
- **RequestHeader**:
- (String) `authorization`: 토큰
- **Body Parameters**:
- (Long) `기업 ID`: 기업 고유ID(아이디x)
- **Response**:
- (Long) `쪽지 ID`: 쪽지 고유ID
- (Long) `기업 ID`: 기업 고유ID
쪽지 조회 = 내가 보낸 쪽지 / 내가 받은 쪽지 2가지로 나뉜다.
## 🔍 **조회(내가 보낸 쪽지)**
- **Method** : `GET`
- **path**: `/messages/senders`
- **Example Endpoint** : https://localhost:8080/messages/senders
- **Request Parameters**:
- **RequestHeader**
- String `authorization`: 토큰
- **Response Parameters**
- List<기업> `companyName`: 기업명들
- String message : "000기업에서 쪽지를 보냈습니다."
---
## 🔍 **조회(내가 받은 쪽지)**
- **Method** : `GET`
- **path**: `/messages/receptions`
- **Example Endpoint** : https://localhost:8080/messages/receptions
- **Request Parameters**
- **RequestHeader**
- (String) `authorization`: 토큰
- **Response Parameters**
- List<기업> `companyName`: 기업명들
쪽지는 수정할 일이 없으니까 삭제로 넘어간다.
쪽지 삭제 = 내가 보낸 쪽지 삭제 / 내가 받은 쪽지 삭제
## ❌ **삭제(내가 보낸 쪽지)**
- **Method** : `Delete`
- **Path** : `/messages/senders/{messageId}`
- **Example Endpoint** : https://localhost:8080/messages/senders/1
- **Request Parameters**
- **Path**:
- (Long) `alarmId`: 알람 고유ID
- **RequestHeader**:
- (String) `authorization`: 토큰
- **RequestBody**:
- (기업) `companyName`: 기업명
---
## ❌ **삭제(내가 받은 쪽지)**
- **Method** : `Delete`
- **Path** : `/messages/receptions/{messageId}`
- **Example Endpoint** : https://localhost:8080/alarms/receptions/1
- **Request Parameters**
- **Path**:
- (Long) `alarmId`: 알람 고유ID
- **RequestHeader**:
- (String) `authorization`: 토큰
- **RequestBody**:
- (기업) `companyName`: 기업명
이렇게 설계를 해놨다.
지금 조금 더 구체화하게 된다면,
1. Api 설계할 때 json데이터의 예시도 같이 설계를 해놓으면 프론트에서 알아듣기 편하다. 따라서 예시데이터까지 있으면 좋을 것 같다.
2. request이름, response이름까지 같이 하면 좋을 것 같다.
3. valid같이 제한을 걸어두는 요소들도 미리 설정하면 좋을 것 같다.
내가 개발하는 부분은 쪽지&개발자부분이다. 따라서 개발자 부분도 API Spec을 살펴보자
## ➡️ **생성**
- **Method**: `POST`
- **Path**: `/programmers`
- **Example Endpoint**: `https://localhost:8080/programmers`
- **Request Parameters**:
- **Body Parameters**:
- `userId` (String): 회원 아이디
- `password` (String): 비밀번호
- `name` (String): 이름
- `age` (Number): 나이
- `email` (String): 이메일
- `personalHistory` (Number): 경력
- **field** (Array):
- `fieldName` (String): 분야 이름
- `selfIntroduction` (String): 자기 소개
- `certificate` (String): 자격증
---
## 🔍 **간단한 조회**
- **Method**: `GET`
- **Path**: `/programmers`
- **Example Endpoint**: `https://localhost:8080/programmers?order=like`
- **Request Parameters**:
- **Query String Parameter**:
- `order` (String): 정렬 방법
- `field` (Array): 분야
- `personalHistory` (Number): 경력
- **Response Message**:
- `message` (String)
- `data`:
- `id` (Number): 아이디 (회원 아이디 X)
- `name` (String): 이름
- `age` (Number): 나이
- `personalHistory` (Number): 경력
- **field** (Array):
- `fieldName` (String): 분야 이름
---
## 🔍 **상세 조회 (더보기 용)**
- **Method**: `GET`
- **Path**: `/programmers/{id}`
- **Example Endpoint**: `https://localhost:8080/programmers/1`
- **Request Parameters**:
- **Path Segment Parameter**:
- `id` (Number): 아이디 (회원 아이디 X)
- **Response Message**:
- `message` (String)
- `data`:
- `name` (String): 이름
- `age` (Number): 나이
- `email` (String): 이메일
- `personalHistory` (Number): 경력
- **field** (Array):
- `fieldName` (String): 분야 이름
- `selfIntroduction` (String): 자기 소개
- `certificate` (String): 자격증
---
## 🔍 **상세 조회 (내정보 용)**
- **Method**: `GET`
- **Path**: `/programmers/my`
- **Example Endpoint**: `https://localhost:8080/programmers/my`
- **Request Parameters**:
- **Headers**:
- `Authorization` (String, Required): Bearer 토큰 형태의 인증 토큰
- **Response Message**
- `message` (String)
- `data`:
- `userId` (String): 회원 아이디
- `name` (String): 이름
- `age` (Number): 나이
- `email` (String): 이메일
- `personalHistory` (Number): 경력
- **field** (Array):
- `fieldName` (String): 분야 이름
- `selfIntroduction` (String): 자기 소개
- `certificate` (String): 자격증
---
## ✏️ **수정**
- **Method**: `PUT`
- **Path**: `/programmers/my`
- **Example Endpoint**: `https://localhost:8080/programmers/my`
- **Request Parameters**:
- **Headers**:
- `Authorization` (String, Required): Bearer 토큰 형태의 인증 토큰
- **Body Parameters**:
- `name` (String): 이름
- `age` (Number): 나이
- `email` (String): 이메일
- `personalHistory` (Number): 경력
- **field** (Array):
- `fieldName` (String): 분야 이름
- `selfIntroduction` (String): 자기 소개
- `certificate` (String): 자격증
---
## ✏️ **수정 (비밀번호)**
- **Method**: `PATCH`
- **Path**: `/programmers/my`
- **Example Endpoint**: `https://localhost:8080/programmers/my`
- **Request Parameters**:
- **Headers**:
- `Authorization` (String, Required): Bearer 토큰 형태의 인증 토큰
- **Body Parameters**:
- `password` (String): 비밀번호
---
## ❌ **삭제**
- **Method**: `DELETE`
- **Path**: `/programmers/my`
- **Example Endpoint**: `https://localhost:8080/programmers/my`
- **Request Parameters**:
- **Headers**:
- `Authorization` (String, Required): Bearer 토큰 형태의 인증 토큰
- **Response Message**:
- `message` (String)