Skip to content

Commit

Permalink
Merge pull request #132 from Team-Going/feature/131
Browse files Browse the repository at this point in the history
[feat] 여행 성향 테스트 수정 API 구현
  • Loading branch information
gardening-y authored Mar 3, 2024
2 parents 4c1912f + a65e852 commit 136570f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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.*;
import org.doorip.trip.service.TripDetailService;
import org.doorip.trip.service.TripService;
Expand Down Expand Up @@ -93,4 +94,12 @@ public ResponseEntity<BaseResponse<?>> updateTrip(@PathVariable final Long tripI
tripService.updateTrip(userId, tripId, request);
return ApiResponseUtil.success(SuccessMessage.OK);
}

@PatchMapping("/{tripId}/participant")
public ResponseEntity<BaseResponse<?>> updateParticipant(@PathVariable final Long tripId,
@UserId final Long userId,
@RequestBody final ParticipantUpdateRequest request) {
tripDetailService.updateParticipant(userId, tripId, request);
return ApiResponseUtil.success(SuccessMessage.OK);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.doorip.trip.dto.request;

public record ParticipantUpdateRequest(
int styleA,
int styleB,
int styleC,
int styleD,
int styleE
) {
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,12 @@ public void addAllocator(Allocator allocator) {
public void removeAllocator(Allocator allocator) {
allocators.remove(allocator);
}

public void updateStyles(int styleA, int styleB, int styleC, int styleD, int styleE) {
this.styleA = styleA;
this.styleB = styleB;
this.styleC = styleC;
this.styleD = styleD;
this.styleE = styleE;
}
}

0 comments on commit 136570f

Please sign in to comment.