Skip to content

Commit

Permalink
Fix: api경로 수정-버전추가 및 admin 구분(#21 #22)
Browse files Browse the repository at this point in the history
close: #21 #22
  • Loading branch information
mummhy0811 committed May 2, 2024
1 parent 604e4f6 commit 9eb40f4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

import java.util.List;

import static com.hanaro.starbucks.util.APIConstant.API_VERSION;

@RestController
@RequestMapping("/products")
@RequestMapping(API_VERSION + "/products")
@RequiredArgsConstructor
public class MenuController {
private final MenuService menuService;
Expand All @@ -31,12 +33,12 @@ public MenuResDto getMenuByMenuIdx(@PathVariable int menuIdx) throws Exception{
return menuService.getMenuByMenuIdx(menuIdx);
}

@DeleteMapping("/{menuIdx}")
@DeleteMapping("/admin/{menuIdx}")
public void deleteMenuByMenuIdx(@PathVariable int menuIdx) throws Exception{
menuService.deleteMenuByMenuIdx(menuIdx);
}

@PutMapping(value = "/{menuIdx}", consumes = {MediaType.APPLICATION_JSON_VALUE, "multipart/form-data"})
@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") MultipartFile img) throws Exception{
menuService.updateMenu(menuIdx, menuReqDto, img);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

import java.util.List;

import static com.hanaro.starbucks.util.APIConstant.API_VERSION;

@RestController
@RequiredArgsConstructor
@RequestMapping("/orders")
@RequestMapping(API_VERSION + "/orders")
public class OrderController {
private final OrderService orderService;

Expand All @@ -23,12 +25,12 @@ public OrderResDto getOrder(@PathVariable int orderIdx) {
return orderService.getOrder(orderIdx);
}

@PutMapping("/{orderIdx}")
@PutMapping("/admin/{orderIdx}")
public void updateOrder(@PathVariable int orderIdx, @RequestBody OrderEditReqDto orderEditReqDto) {
orderService.updateOrder(orderIdx, orderEditReqDto);
}

@DeleteMapping("/{orderIdx}")
@DeleteMapping("/admin/{orderIdx}")
public void deleteOrder(@PathVariable int orderIdx) {
orderService.deleteOrder(orderIdx);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/hanaro/starbucks/util/APIConstant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.hanaro.starbucks.util;

public class APIConstant {
public static final String API_VERSION="api/v1";
}

0 comments on commit 9eb40f4

Please sign in to comment.