-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,4 +89,4 @@ tasks.register('copyYml', Copy) { | |
include "*.yml" | ||
into 'src/main/resources' | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/hankki/hankkiserver/api/menu/controller/MenuController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.hankki.hankkiserver.api.menu.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.hankki.hankkiserver.api.dto.HankkiResponse; | ||
import org.hankki.hankkiserver.api.menu.service.MenuCommandService; | ||
import org.hankki.hankkiserver.common.code.CommonSuccessCode; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1") | ||
public class MenuController { | ||
|
||
private final MenuCommandService menuCommandService; | ||
|
||
@DeleteMapping("/menus/{id}") | ||
public HankkiResponse<Void> deleteMenu(@PathVariable final Long id) { | ||
menuCommandService.deleteMenu(id); | ||
return HankkiResponse.success(CommonSuccessCode.NO_CONTENT); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/org/hankki/hankkiserver/api/menu/service/MenuCommandService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.hankki.hankkiserver.api.menu.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class MenuCommandService { | ||
|
||
private final MenuDeleter menuDeleter; | ||
private final MenuFinder menuFinder; | ||
|
||
@Transactional | ||
public void deleteMenu(final long menuId) { | ||
menuDeleter.deleteMenu(menuFinder.findById(menuId)); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/org/hankki/hankkiserver/api/menu/service/MenuDeleter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.hankki.hankkiserver.api.menu.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.hankki.hankkiserver.domain.menu.model.Menu; | ||
import org.hankki.hankkiserver.domain.menu.repository.MenuRepository; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class MenuDeleter { | ||
|
||
private final MenuRepository menuRepository; | ||
|
||
protected void deleteMenu(final Menu menu) { | ||
menuRepository.delete(menu); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/org/hankki/hankkiserver/common/code/MenuErrorCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.hankki.hankkiserver.common.code; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum MenuErrorCode implements ErrorCode { | ||
|
||
MENU_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 메뉴입니다."); | ||
|
||
private final HttpStatus httpStatus; | ||
private final String message; | ||
} |