Skip to content

Commit

Permalink
YEL-193 [feat] type 유형 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeonjeongs committed Jan 29, 2024
1 parent 78f3e8d commit 717b91c
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 46 deletions.
13 changes: 13 additions & 0 deletions src/docs/asciidoc/find-friend-votes-v2.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ include::{snippets}/api/v2/vote/friend/http-response.adoc[]
* "keyword": String
* "keywordFoot": String


=== Excpetion

- 잘못된 type을 queryString에 보내는 경우

[http,json]
----
{
"status": 403,
"message": "[VoteForbiddenException] 잘못된 투표 유형입니다."
}
----

=== NOTE

- 모든 종류의 쪽지를 조회할 때 `/api/v1/vote/friend?page=0&type=null` 으로 요청해주세요
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import static com.yello.server.global.common.ErrorCode.LACK_TICKET_COUNT_EXCEPTION;
import static com.yello.server.global.common.ErrorCode.LACK_USER_EXCEPTION;
import static com.yello.server.global.common.ErrorCode.REVEAL_FULL_NAME_VOTE_EXCEPTION;
import static com.yello.server.global.common.ErrorCode.WRONG_VOTE_TYPE_FORBIDDEN;
import static com.yello.server.global.common.factory.TimeFactory.minusTime;
import static com.yello.server.global.common.util.ConstantUtil.ALL_VOTE_TYPE;
import static com.yello.server.global.common.util.ConstantUtil.CHECK_FULL_NAME;
import static com.yello.server.global.common.util.ConstantUtil.COOL_DOWN_TIME;
import static com.yello.server.global.common.util.ConstantUtil.MINUS_TICKET_COUNT;
Expand Down Expand Up @@ -44,6 +46,7 @@
import com.yello.server.domain.vote.exception.VoteForbiddenException;
import com.yello.server.domain.vote.exception.VoteNotFoundException;
import com.yello.server.domain.vote.repository.VoteRepository;
import com.yello.server.global.common.ErrorCode;
import com.yello.server.infrastructure.rabbitmq.service.ProducerService;
import java.time.LocalDateTime;
import java.util.List;
Expand Down Expand Up @@ -129,14 +132,17 @@ public VoteFriendAndUserResponse findAllFriendVotesWithType(Long userId, Pageabl
.toList();
return VoteFriendAndUserResponse.of(totalCount,list);
}
if(type.equals(ALL_VOTE_TYPE)) {
final Long totalCount = Long.valueOf(voteRepository.countAllReceivedByFriends(userId));
final List<VoteFriendAndUserVO> list = voteRepository.findAllReceivedByFriends(userId, pageable)
.stream()
.filter(vote -> vote.getNameHint()!=-3)
.map(vote -> VoteFriendAndUserVO.of(vote, vote.getSender().getId().equals(userId)))
.toList();
return VoteFriendAndUserResponse.of(totalCount, list);
}

final Long totalCount = Long.valueOf(voteRepository.countAllReceivedByFriends(userId));
final List<VoteFriendAndUserVO> list = voteRepository.findAllReceivedByFriends(userId, pageable)
.stream()
.filter(vote -> vote.getNameHint()!=-3)
.map(vote -> VoteFriendAndUserVO.of(vote, vote.getSender().getId().equals(userId)))
.toList();
return VoteFriendAndUserResponse.of(totalCount, list);
throw new VoteForbiddenException(WRONG_VOTE_TYPE_FORBIDDEN);
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public enum ErrorCode {
"유효하지 않는 Google OAuth 2.0 refreshToken입니다. DBA에게 문의해주세요."),
GOOGLE_SUBSCRIPTIONS_FORBIDDEN_EXCEPTION(FORBIDDEN, "이미 YELLO: PLUS를 구독한 상태입니다."),
GOOGLE_SUBSCRIPTION_TRANSACTION_EXPIRED_EXCEPTION(FORBIDDEN, "이미 만료된 결제 내역의 영수증입니다."),
WRONG_VOTE_TYPE_FORBIDDEN(FORBIDDEN, "잘못된 투표 유형입니다."),

/**
* 404 NOT FOUND
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class ConstantUtil {
public static final int SUBSCRIBE_DAYS = 7;
public static final int PLUS_BASIC_TIME = 0;
public static final String USER_VOTE_TYPE = "send";
public static final String ALL_VOTE_TYPE = "all";


private ConstantUtil() {
Expand Down
98 changes: 60 additions & 38 deletions src/main/resources/static/docs/find-friend-votes-v2.html
Original file line number Diff line number Diff line change
Expand Up @@ -447,24 +447,32 @@ <h2 id="_친구_투표_전체_조회_명세">친구 투표 전체 조회 (명세
<h3 id="_요청">요청</h3>
<div class="listingblock">
<div class="content">
<pre>GET /v2/vote/friend?page={}&amp;type={} HTTP/1.1
Authorization: Bearer your-access-token
Content-Type: application-json</pre>
<pre class="highlight nowrap"><code class="language-http" data-lang="http">GET /api/v2/vote/friend?page=0&amp;type=send HTTP/1.1
Authorization: Bearer your-access-token</code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>업데이트 예정</strong>
- "type": "send" | null</p>
</div>
<div class="sect2">
<h3 id="_요청_파라미터">요청 파라미터</h3>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Parameter</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>page</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">페이지네이션 페이지 번호</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>type</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">조회할 쪽지 종류 (null &#8594; 모든쪽지, send&#8594; 보낸쪽지)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">쪽지 유형 선택</p></td>
</tr>
</tbody>
</table>
Expand All @@ -473,38 +481,56 @@ <h3 id="_요청">요청</h3>
<h3 id="_응답">응답</h3>
<div class="listingblock">
<div class="content">
<pre>{
<pre class="highlight nowrap"><code class="language-http" data-lang="http">HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json

{
"status" : 200,
"message" : "투표 조회에 성공했습니다.",
"data" : {
"totalCount" : 1,
"friendVotes" : [ {
"id" : 1,
"senderId" : 1,
"senderName" : "name1",
"senderGender" : "MALE",
"senderYelloId" : "MALE",
"senderProfileImage": "imageUrl",
"receiverId" : 2,
"receiverName" : "name2",
"receiverGender" : "MALE",
"receiverYelloId" : "MALE",
"receiverProfileImage" : "test image",
"vote" : {
"nameHead" : "나는",
"nameFoot" : "와",
"keywordHead" : "멋진",
"keyword" : "test",
"keywordFoot" : "에서 놀고싶어"
},
"isHintUsed" : false,
"createdAt" : "0초 전"
"isUserSenderVote" : true
"id" : 1,
"senderId" : 1,
"senderName" : "name1",
"senderGender" : "MALE",
"senderYelloId" : "yelloId1",
"senderProfileImage" : "test image",
"receiverId" : 2,
"receiverName" : "name2",
"receiverGender" : "MALE",
"receiverYelloId" : "yelloId2",
"receiverProfileImage" : "test image",
"vote" : {
"nameHead" : "나는",
"nameFoot" : "와",
"keywordHead" : "멋진",
"keyword" : "test",
"keywordFoot" : "에서 놀고싶어"
},
"isHintUsed" : false,
"createdAt" : "0초 전",
"isUserSenderVote" : true
} ]
}
}</pre>
}</code></pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>type</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">조회할 쪽지 종류 (null &#8594; 모든쪽지, send&#8594; 보낸쪽지)</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p><strong>필드 타입</strong></p>
</div>
Expand Down Expand Up @@ -598,14 +624,7 @@ <h3 id="_note">NOTE</h3>
<div class="ulist">
<ul>
<li>
<p>모든 종류의 쪽지를 조회할 때 <code>/api/v1/vote/friend?page=0</code> 으로 요청해주세요</p>
<div class="ulist">
<ul>
<li>
<p><code>type=</code> 을 명시하지 마세요</p>
</li>
</ul>
</div>
<p>모든 종류의 쪽지를 조회할 때 <code>/api/v1/vote/friend?page=0&amp;type=null</code> 으로 요청해주세요</p>
</li>
<li>
<p>내가 보낸 쪽지를 조회할 때 <code>/api/v1/vote/friend?page=0&amp;type=send</code> 으로 요청해주세요</p>
Expand All @@ -621,6 +640,9 @@ <h3 id="_changelog">CHANGELOG</h3>
<div class="ulist">
<ul>
<li>
<p>2924.01.30 API 릴리즈</p>
</li>
<li>
<p>2024.01.26 필드 명세 업데이트</p>
</li>
<li>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/static/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ <h3 id="_notice_api"><a class="link" href="#_notice_api">Notice API</a></h3>
<div class="ulist">
<ul>
<li>
<p>🆕 <a href="find-notice.html">공지 조회, 2024-01-26</a></p>
<p>🆕 <a href="find-notice.html">공지 조회, 2024-01-29</a></p>
</li>
</ul>
</div>
Expand Down

0 comments on commit 717b91c

Please sign in to comment.