Skip to content

Commit

Permalink
Merge pull request #37 from Digital-Hana-Starbucks/feature/admin
Browse files Browse the repository at this point in the history
Fix: 관리자 메뉴 수정 카테고리 누락 추가
mummhy0811 authored May 8, 2024
2 parents 40a2d6b + 60c93dd commit a06c5d2
Showing 4 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}

Original file line number Diff line number Diff line change
@@ -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();
3 changes: 2 additions & 1 deletion src/main/java/com/hanaro/starbucks/entity/Menu.java
Original file line number Diff line number Diff line change
@@ -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();
}

Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit a06c5d2

Please sign in to comment.