Skip to content

Commit

Permalink
Fix: 푸드트럭 이미지 등록 시 에러 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsong111 committed May 30, 2024
1 parent 1b870e8 commit a7a4648
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ public FoodTruckDetailResponse saveFoodTruck(Long foodTruckId, FoodTruckRequestV
foodTruck.setDescription(foodTruckRequest.getDescription());
foodTruck.setFoodType(foodTruckRequest.getFoodType());

if (!foodTruckRequest.getImage().isEmpty()) {
foodTruck.setImageUrl(imageUploader.uploadImage(foodTruckRequest.getImage()).getData().getUrl());
try {
if (foodTruckRequest.getImage() != null) {
foodTruck.setImageUrl(imageUploader.uploadImage(foodTruckRequest.getImage()).getData().getUrl());
}
} catch (Exception e) {
log.error("Failed to upload image", e);
}

// 수정된 푸드트럭 정보 저장
Expand All @@ -141,18 +145,4 @@ public List<FoodTruckDetailResponse> getMyFoodTrucksForApi(String userEmail) {
.map(foodTruckMapper::toFoodTruckDetailResponse)
.toList();
}

/**
* 푸드트럭 매니저인지 확인합니다.
* 푸드트럭 매니저가 아닌 경우 예외를 발생시킵니다.
* 푸드트럭 매니저이지만 해당 푸드트럭의 매니저가 아닌 경우 예외를 발생시킵니다.
*
* @param userEmail 사용자 Email
* @param foodTruck 푸드트럭
*/
protected void isManager(String userEmail, FoodTruck foodTruck) {
if (!foodTruck.getManager().getEmail().equals(userEmail)) {
throw new CustomException(CustomErrorCode.FOOD_TRUCK_IS_NOT_YOURS);
}
}
}
1 change: 0 additions & 1 deletion src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ VALUES (1, 'USER'),
(2, 'USER'),
(3, 'USER'),
(4, 'USER'),
(4, 'USER'),
(5, 'USER'),
(6, 'USER'),
(7, 'USER'),
Expand Down

0 comments on commit a7a4648

Please sign in to comment.