1. API 목록
2. PUT: 팀 투표 토글
해당 팀에 대해 투표 상태를 토글합니다.
-
isVoted: true→ 투표 등록 -
isVoted: false→ 투표 취소
| 대회 기간 중에는 투표만 보이고, 대회 기간이 아니라면 좋아요가 보입니다. |
| 해당 대회의 최대 투표 개수 이상으로 투표를 등록할 수 없습니다. |
| Parameter | Description |
|---|---|
|
투표할 팀의 ID |
| Name | Description |
|---|---|
|
Bearer {accessToken} |
| Path | Type | Description |
|---|---|---|
|
|
투표 여부 (true: 등록, false: 취소) |
| Path | Type | Description |
|---|---|---|
|
|
팀 ID |
|
|
투표 상태 |
|
|
응답 메시지 |
|
|
남은 투표 가능 횟수 |
|
|
대회 최대 투표 허용 개수 |
2.1. 시나리오 1: TeamVote 데이터가 없는 경우
특정 멤버가 특정 팀에 대해 투표 API를 처음 호출하면, TeamVote 테이블에 데이터가 새로 생성됩니다.
| Request isVoted | 응답 메시지 | HTTP 상태 코드 |
|---|---|---|
true |
투표가 등록되었습니다. |
200 OK |
false |
아직 투표하지 않은 팀입니다. |
400 Bad Request |
isVoted: true → 투표 등록
PUT /teams/1/votes HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer member.access.token
Content-Length: 22
Host: localhost:8080
{
"isVoted" : true
}
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
Content-Length: 140
{
"teamId" : 1,
"isVoted" : true,
"message" : "투표가 등록되었습니다.",
"remainingVotesCount" : 1,
"maxVotesLimit" : 2
}
2.2. 시나리오 2: TeamVote 데이터가 있는 경우
이미 해당 팀에 대한 투표 기록이 있는 경우, 상태에 따라 토글됩니다.
| 현재 isVoted | Request isVoted | 응답 메시지 | HTTP 상태 코드 |
|---|---|---|---|
true |
true |
이미 투표한 팀입니다. |
400 Bad Request |
true |
false |
투표가 취소되었습니다. |
200 OK |
false |
true |
투표가 등록되었습니다. |
200 OK |
false |
false |
이미 투표를 취소한 팀입니다. |
400 Bad Request |
투표 취소 (isVoted: true → false)
PUT /teams/1/votes HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer member.access.token
Content-Length: 23
Host: localhost:8080
{
"isVoted" : false
}
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
Content-Length: 141
{
"teamId" : 1,
"isVoted" : false,
"message" : "투표가 취소되었습니다.",
"remainingVotesCount" : 2,
"maxVotesLimit" : 2
}
2.3. ⚠️ 실패 케이스
❌ Case 1: 존재하지 않는 팀
PUT /teams/999/votes HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer member.access.token
Content-Length: 22
Host: localhost:8080
{
"isVoted" : true
}
HTTP/1.1 404 Not Found
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
Content-Length: 53
{
"message" : "팀이 존재하지 않습니다."
}
❌ Case 2: 이미 투표한 팀
PUT /teams/1/votes HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer member.access.token
Content-Length: 22
Host: localhost:8080
{
"isVoted" : true
}
HTTP/1.1 400 Bad Request
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
Content-Length: 50
{
"message" : "이미 투표한 팀입니다."
}
❌ Case 3: 이미 투표 취소한 팀
PUT /teams/1/votes HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer member.access.token
Content-Length: 23
Host: localhost:8080
{
"isVoted" : false
}
HTTP/1.1 400 Bad Request
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
Content-Length: 60
{
"message" : "이미 투표를 취소한 팀입니다."
}
❌ Case 4: 투표한 적 없는 팀에 취소 요청
PUT /teams/1/votes HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer member.access.token
Content-Length: 23
Host: localhost:8080
{
"isVoted" : false
}
HTTP/1.1 400 Bad Request
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
Content-Length: 60
{
"message" : "아직 투표하지 않은 팀입니다."
}
❌ Case 5: 최대 투표 수 초과
PUT /teams/3/votes HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer member.access.token
Content-Length: 22
Host: localhost:8080
{
"isVoted" : true
}
HTTP/1.1 400 Bad Request
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
Content-Length: 76
{
"message" : "대회당 최대 2개 팀만 투표할 수 있습니다."
}
❌ Case 6: 투표 기간이 아님
PUT /teams/1/votes HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer member.access.token
Content-Length: 22
Host: localhost:8080
{
"isVoted" : true
}
HTTP/1.1 400 Bad Request
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
Content-Length: 60
{
"message" : "지금은 투표 기간이 아닙니다."
}
3. GET: 사용자 투표 개수 조회
현재 사용자가 특정 대회에서 남은 투표 가능 횟수와 최대 투표 허용 개수를 조회합니다.
Unresolved directive in team-vote.adoc - include::./build/generated-snippets/get-member-vote-count/query-parameters.adoc[]
| Name | Description |
|---|---|
|
Bearer {accessToken} |
GET /contests/1/votes/me HTTP/1.1
Authorization: Bearer member.access.token
Host: localhost:8080
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
Content-Length: 54
{
"remainingVotesCount" : 1,
"maxVotesLimit" : 2
}
| Path | Type | Description |
|---|---|---|
|
|
남은 투표 가능 횟수 |
|
|
대회 최대 투표 허용 개수 |
3.1. ⚠️ 실패 케이스
❌ Case 1: 존재하지 않는 대회
GET /contests/999/votes/me HTTP/1.1
Authorization: Bearer member.access.token
Host: localhost:8080
HTTP/1.1 404 Not Found
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
Content-Length: 56
{
"message" : "존재하지 않는 대회입니다."
}