Skip to content

Commit

Permalink
refactor: 북마크 취소 응답으로 필요없는 필드를 삭제한다
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb committed Mar 7, 2024
1 parent b9c9e1a commit e5bc334
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
2 changes: 0 additions & 2 deletions support/e2e/v1_11_cancel_bookmark_survey.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,4 @@ HTTP 200
[Asserts]
header "Content-type" == "application/json"

jsonpath "$.target_id" == {{ target_id }}
jsonpath "$.survey_id" == {{ survey_id }}
jsonpath "$.nickname" == "cancel_bookmark_survey"
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ public interface SurveyBookmarkUseCase {

/**
* targetId에 해당하는 유저에게 survey를 북마크합니다.
* 이미 북마크되어있다면 북마크를 취소합니다.
*/
SurveyBookmarkDto bookmark(Long targetId, Long surveyId);

/**
* targetId에 해당하는 유저에게 survey를 북마크 취소합니다.
* 북마크 되어있지 않다면, 아무동작도 하지 않습니다.
* targetId에 해당하는 유저에게 survey를 북마크 취소합니다. 북마크 되어있지 않다면, 아무동작도 하지 않습니다.
*/
SurveyBookmarkDto cancelBookmark(Long targetId, Long surveyId);
Long cancelBookmark(Long targetId, Long surveyId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public SurveyBookmarkDto bookmark(Long targetId, Long surveyId) {

@Override
@Transactional
public SurveyBookmarkDto cancelBookmark(Long targetId, Long surveyId) {
public Long cancelBookmark(Long targetId, Long surveyId) {
var target = targetFindPort.getTargetById(targetId);

if (!surveyExistCheckPort.isExistSurveyBySurveyId(surveyId)) {
Expand All @@ -52,6 +52,6 @@ public SurveyBookmarkDto cancelBookmark(Long targetId, Long surveyId) {

surveyBookmarkListener.listenBookmarked(TargetDtoMapper.toTargetDto(target));

return SurveyBookmarkDto.from(surveyId, target);
return surveyId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.RequiredArgsConstructor;
import me.nalab.survey.application.port.in.web.bookmark.SurveyBookmarkUseCase;
import me.nalab.survey.web.adaptor.bookmark.response.SurveyBookmarkResponse;
import me.nalab.survey.web.adaptor.bookmark.response.SurveyBookmarkedResponse;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -29,10 +30,10 @@ public SurveyBookmarkResponse bookmark(@RequestAttribute("logined") Long targetI

@ResponseStatus(HttpStatus.OK)
@PostMapping("/surveys/{survey_id}/bookmarks/cancels")
public SurveyBookmarkResponse cancelBookmark(@RequestAttribute("logined") Long targetId,
public SurveyBookmarkedResponse cancelBookmark(@RequestAttribute("logined") Long targetId,
@PathVariable("survey_id") Long surveyId) {
var surveyBookmarked = surveyBookmarkReplaceUseCase.cancelBookmark(targetId, surveyId);
var bookmarkedSurveyId = surveyBookmarkReplaceUseCase.cancelBookmark(targetId, surveyId);

return SurveyBookmarkResponse.of(surveyBookmarked);
return SurveyBookmarkedResponse.of(bookmarkedSurveyId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package me.nalab.survey.web.adaptor.bookmark.response;

import com.fasterxml.jackson.annotation.JsonProperty;

public record SurveyBookmarkedResponse(
@JsonProperty("survey_id")
Long surveyId
) {

public static SurveyBookmarkedResponse of(Long surveyId) {
return new SurveyBookmarkedResponse(surveyId);
}
}

0 comments on commit e5bc334

Please sign in to comment.