Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 관리자 메뉴 수정 카테고리 누락 추가 #37

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,6 +16,7 @@
import static com.hanaro.starbucks.util.APIConstant.API_VERSION;

@RestController
@Slf4j
@RequestMapping(API_VERSION + "/products")
@RequiredArgsConstructor
@CrossOrigin("http://localhost:5173")
Expand Down Expand Up @@ -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);
}

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

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

Expand Down
Loading