From 60c93dd71db9905ee6d4621a9fe6e7e1df13daa2 Mon Sep 17 00:00:00 2001 From: mummhy0811 Date: Wed, 8 May 2024 11:28:17 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=EA=B4=80=EB=A6=AC=EC=9E=90=20=EB=A9=94?= =?UTF-8?q?=EB=89=B4=20=EC=88=98=EC=A0=95=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20=EB=88=84=EB=9D=BD=20=EC=B6=94=EA=B0=80"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hanaro/starbucks/controller/MenuController.java | 3 +++ .../java/com/hanaro/starbucks/dto/member/MemberResDto.java | 1 + src/main/java/com/hanaro/starbucks/entity/Menu.java | 3 ++- src/main/java/com/hanaro/starbucks/service/MenuService.java | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/hanaro/starbucks/controller/MenuController.java b/src/main/java/com/hanaro/starbucks/controller/MenuController.java index ce6343b..a6d79aa 100644 --- a/src/main/java/com/hanaro/starbucks/controller/MenuController.java +++ b/src/main/java/com/hanaro/starbucks/controller/MenuController.java @@ -6,6 +6,7 @@ import com.hanaro.starbucks.service.CategoryService; import com.hanaro.starbucks.service.MenuService; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -15,6 +16,7 @@ import static com.hanaro.starbucks.util.APIConstant.API_VERSION; @RestController +@Slf4j @RequestMapping(API_VERSION + "/products") @RequiredArgsConstructor @CrossOrigin("http://localhost:5173") @@ -44,6 +46,7 @@ public void deleteMenuByMenuIdx(@PathVariable int menuIdx) throws Exception{ @PutMapping(value = "/admin/{menuIdx}", consumes = {MediaType.APPLICATION_JSON_VALUE, "multipart/form-data"}) public void updateMenu(@PathVariable int menuIdx, @RequestPart(value = "dto") MenuReqDto menuReqDto, @RequestPart(value = "menuImg", required = false) MultipartFile img) throws Exception{ + log.info("~~~~~~menuReqDto = {}", menuReqDto.getCategoryIdx()); menuService.updateMenu(menuIdx, menuReqDto, img); } diff --git a/src/main/java/com/hanaro/starbucks/dto/member/MemberResDto.java b/src/main/java/com/hanaro/starbucks/dto/member/MemberResDto.java index 6b54e55..32fc0ad 100644 --- a/src/main/java/com/hanaro/starbucks/dto/member/MemberResDto.java +++ b/src/main/java/com/hanaro/starbucks/dto/member/MemberResDto.java @@ -26,6 +26,7 @@ public class MemberResDto { @Builder public MemberResDto(Member user){ + this.userIdx = user.getUserIdx(); this.userId = user.getUserId(); this.userPw = user.getUserPw(); this.userNickname = user.getUserNickname(); diff --git a/src/main/java/com/hanaro/starbucks/entity/Menu.java b/src/main/java/com/hanaro/starbucks/entity/Menu.java index e920549..3c6095c 100644 --- a/src/main/java/com/hanaro/starbucks/entity/Menu.java +++ b/src/main/java/com/hanaro/starbucks/entity/Menu.java @@ -36,10 +36,11 @@ public class Menu { private Category category; - public void update(MenuReqDto dto, String img) { + public void update(MenuReqDto dto, Category category, String img) { this.menuName = dto.getMenuName(); this.menuPrice = dto.getMenuPrice(); this.menuImage = img; + this.category = category; this.menuDate = LocalDate.now(); } diff --git a/src/main/java/com/hanaro/starbucks/service/MenuService.java b/src/main/java/com/hanaro/starbucks/service/MenuService.java index 17cbc47..6168d18 100644 --- a/src/main/java/com/hanaro/starbucks/service/MenuService.java +++ b/src/main/java/com/hanaro/starbucks/service/MenuService.java @@ -69,7 +69,7 @@ public void updateMenu(int menuIdx, MenuReqDto menuReqDto, MultipartFile img) th if(img==null || img.isEmpty()) url=menu.getMenuImage(); else url = s3Uploader.updateFile(img, menu.getMenuImage(), optionalCategory.get().getCategoryName()); - menu.update(menuReqDto, url); + menu.update(menuReqDto, optionalCategory.get(), url); menuRepository.save(menu); }