Skip to content

Commit

Permalink
chore: 여행 성향 테스트 수정 로직 이동 (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
gardening-y committed Mar 2, 2024
1 parent 80e90c3 commit a65e852
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public ResponseEntity<BaseResponse<?>> updateTrip(@PathVariable final Long tripI
public ResponseEntity<BaseResponse<?>> updateParticipant(@PathVariable final Long tripId,
@UserId final Long userId,
@RequestBody final ParticipantUpdateRequest request) {
tripService.updateParticipant(userId, tripId, request);
tripDetailService.updateParticipant(userId, tripId, request);
return ApiResponseUtil.success(SuccessMessage.OK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.doorip.exception.EntityNotFoundException;
import org.doorip.message.ErrorMessage;
import org.doorip.trip.domain.*;
import org.doorip.trip.dto.request.ParticipantUpdateRequest;
import org.doorip.trip.dto.response.MyTodoResponse;
import org.doorip.trip.dto.response.OurTodoResponse;
import org.doorip.trip.dto.response.TripParticipantGetResponse;
Expand Down Expand Up @@ -72,6 +73,14 @@ public void leaveTrip(Long userId, Long tripId) {
deleteTripIfLastParticipant(size, findTrip);
}

@Transactional
public void updateParticipant(Long userId, Long tripId, ParticipantUpdateRequest request) {
User findUser = getUser(userId);
Trip findTrip = getTrip(tripId);
Participant findParticipant = getParticipant(findUser, findTrip);
findParticipant.updateStyles(request.styleA(), request.styleB(), request.styleC(), request.styleD(), request.styleE());
}

private Map<String, Integer> createDefaultPropensity() {
return new HashMap<>(Map.of(STYLE_A, MIN_STYLE_RATE, STYLE_B, MIN_STYLE_RATE,
STYLE_C, MIN_STYLE_RATE, STYLE_D, MIN_STYLE_RATE, STYLE_E, MIN_STYLE_RATE)) {
Expand Down
14 changes: 0 additions & 14 deletions doorip-api/src/main/java/org/doorip/trip/service/TripService.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.doorip.trip.dto.request.TripEntryRequest;
import org.doorip.trip.dto.request.TripUpdateRequest;
import org.doorip.trip.dto.request.TripVerifyRequest;
import org.doorip.trip.dto.request.ParticipantUpdateRequest;
import org.doorip.trip.dto.response.TripCreateResponse;
import org.doorip.trip.dto.response.TripEntryResponse;
import org.doorip.trip.dto.response.TripGetResponse;
Expand Down Expand Up @@ -78,14 +77,6 @@ public void updateTrip(Long userId, Long tripId, TripUpdateRequest request) {
findTrip.updateDate(request.startDate(), request.endDate());
}

@Transactional
public void updateParticipant(Long userId, Long tripId, ParticipantUpdateRequest request) {
User findUser = getUser(userId);
Trip findTrip = getTrip(tripId);
Participant findParticipant = getParticipant(findUser, findTrip);
findParticipant.updateStyles(request.styleA(), request.styleB(), request.styleC(), request.styleD(), request.styleE());
}

private void validateDate(LocalDate startDate, LocalDate endDate) {
if (endDate.isBefore(LocalDate.now()) || endDate.isBefore(startDate)) {
throw new InvalidValueException(ErrorMessage.INVALID_DATE_TYPE);
Expand Down Expand Up @@ -160,9 +151,4 @@ private void validateParticipant(User user, Trip trip) {
throw new ConflictException(ErrorMessage.PARTICIPANT_NOT_FOUND);
}
}

private Participant getParticipant(User findUser, Trip findTrip) {
return participantRepository.findByUserAndTrip(findUser, findTrip)
.orElseThrow(() -> new EntityNotFoundException(ErrorMessage.PARTICIPANT_NOT_FOUND));
}
}

0 comments on commit a65e852

Please sign in to comment.