Skip to content

Commit

Permalink
[#24] refactor: dto 네이밍 command로 변경
Browse files Browse the repository at this point in the history
-  특정한 행위를 트리거하는 역할이라는 것을 강조하기 위한 네이밍
  • Loading branch information
NaMinhyeok committed Feb 5, 2025
1 parent 5bb762d commit 5374e48
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.nexters.jaknaesocore.domain.survey.dto;

public record SurveySubmissionCommand(Long optionId, String comment) {}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.nexters.jaknaesocore.domain.survey.dto.SurveyHistoryDetailResponse;
import org.nexters.jaknaesocore.domain.survey.dto.SurveyHistoryResponse;
import org.nexters.jaknaesocore.domain.survey.dto.SurveyResponse;
import org.nexters.jaknaesocore.domain.survey.dto.SurveySubmissionServiceRequest;
import org.nexters.jaknaesocore.domain.survey.dto.SurveySubmissionCommand;
import org.nexters.jaknaesocore.domain.survey.model.*;
import org.nexters.jaknaesocore.domain.survey.repository.SurveyBundleRepository;
import org.nexters.jaknaesocore.domain.survey.repository.SurveyRepository;
Expand Down Expand Up @@ -94,7 +94,7 @@ private SurveyHistoryResponse createCurrentBundleSurveyHistory(
}

@Transactional
public void submitSurvey(Long surveyId, Long memberId, SurveySubmissionServiceRequest request) {
public void submitSurvey(Long surveyId, Long memberId, SurveySubmissionCommand request) {
Survey survey =
surveyRepository.findById(surveyId).orElseThrow(() -> CustomException.SURVEY_NOT_FOUND);
SurveyOption surveyOption = survey.getOptionById(request.optionId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.nexters.jaknaesocore.domain.member.repository.MemberRepository;
import org.nexters.jaknaesocore.domain.survey.dto.SurveyHistoryResponse;
import org.nexters.jaknaesocore.domain.survey.dto.SurveyResponse;
import org.nexters.jaknaesocore.domain.survey.dto.SurveySubmissionServiceRequest;
import org.nexters.jaknaesocore.domain.survey.dto.SurveySubmissionCommand;
import org.nexters.jaknaesocore.domain.survey.model.*;
import org.nexters.jaknaesocore.domain.survey.model.BalanceSurvey;
import org.nexters.jaknaesocore.domain.survey.model.Keyword;
Expand Down Expand Up @@ -100,8 +100,8 @@ void throwMemberNotFoundException() {
SurveyOption.builder().survey(balanceSurvey).scores(scores).content("질문 옵션 내용").build();
surveyOptionRepository.save(option);

SurveySubmissionServiceRequest request =
new SurveySubmissionServiceRequest(option.getId(), "나는 행복한게 좋으니까");
SurveySubmissionCommand request =
new SurveySubmissionCommand(option.getId(), "나는 행복한게 좋으니까");

// when
// then
Expand Down Expand Up @@ -130,8 +130,8 @@ class shouldSubmitted {
SurveyOption.builder().survey(balanceSurvey).scores(scores).content("질문 옵션 내용").build();
surveyOptionRepository.save(option);

SurveySubmissionServiceRequest request =
new SurveySubmissionServiceRequest(option.getId(), "나는 행복한게 좋으니까");
SurveySubmissionCommand request =
new SurveySubmissionCommand(option.getId(), "나는 행복한게 좋으니까");

// when
surveyService.submitSurvey(balanceSurvey.getId(), member.getId(), request);
Expand Down Expand Up @@ -165,8 +165,8 @@ void throwSurveyNotFoundException() {
SurveyOption.builder().survey(balanceSurvey).scores(scores).content("질문 옵션 내용").build();
surveyOptionRepository.save(option);

SurveySubmissionServiceRequest request =
new SurveySubmissionServiceRequest(option.getId(), "나는 행복한게 좋으니까");
SurveySubmissionCommand request =
new SurveySubmissionCommand(option.getId(), "나는 행복한게 좋으니까");

// when
// then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.nexters.jaknaesoserver.domain.survey.controller.dto;

import jakarta.validation.constraints.NotNull;
import org.nexters.jaknaesocore.domain.survey.dto.SurveySubmissionServiceRequest;
import org.nexters.jaknaesocore.domain.survey.dto.SurveySubmissionCommand;

public record SurveySubmissionRequest(@NotNull Long optionId, String comment) {
public SurveySubmissionServiceRequest toServiceRequest() {
return new SurveySubmissionServiceRequest(optionId(), comment());
public SurveySubmissionCommand toServiceRequest() {
return new SurveySubmissionCommand(optionId(), comment());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.nexters.jaknaesocore.domain.survey.dto.SurveyHistoryResponse;
import org.nexters.jaknaesocore.domain.survey.dto.SurveyOptionsResponse;
import org.nexters.jaknaesocore.domain.survey.dto.SurveyResponse;
import org.nexters.jaknaesocore.domain.survey.dto.SurveySubmissionServiceRequest;
import org.nexters.jaknaesocore.domain.survey.dto.SurveySubmissionCommand;
import org.nexters.jaknaesoserver.common.support.ControllerTest;
import org.nexters.jaknaesoserver.common.support.WithMockCustomUser;
import org.nexters.jaknaesoserver.domain.survey.controller.dto.SurveySubmissionRequest;
Expand Down Expand Up @@ -128,7 +128,7 @@ void getSurveyHistory() throws Exception {
SurveySubmissionRequest request = new SurveySubmissionRequest(1L, "나는 행복해요");
willDoNothing()
.given(surveyService)
.submitSurvey(anyLong(), anyLong(), any(SurveySubmissionServiceRequest.class));
.submitSurvey(anyLong(), anyLong(), any(SurveySubmissionCommand.class));

mockMvc
.perform(
Expand Down

0 comments on commit 5374e48

Please sign in to comment.