메뉴 API 영문명 로직 추가
This commit is contained in:
@@ -14,6 +14,7 @@ import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "메뉴 조회", description = "메뉴 조회 API")
|
||||
@@ -68,9 +69,10 @@ public class MyMenuApiController {
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping
|
||||
public ApiResponseDto<List<MyMenuDto.Basic>> getFindAllByRole() {
|
||||
public ApiResponseDto<List<MyMenuDto.Basic>> getFindAllByRole(
|
||||
@RequestParam(required = false) String locale) {
|
||||
UserUtil userUtil = new UserUtil();
|
||||
String role = userUtil.getRole();
|
||||
return ApiResponseDto.ok(myMenuService.getFindByRole(role));
|
||||
return ApiResponseDto.ok(myMenuService.getFindByRole(role, locale));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class MenuDto {
|
||||
|
||||
@JsonFormatDttm private ZonedDateTime updatedDttm;
|
||||
|
||||
private String menuApiUrl;
|
||||
private String menuNmEn;
|
||||
|
||||
public Basic(
|
||||
String menuUid,
|
||||
@@ -45,7 +45,8 @@ public class MenuDto {
|
||||
Long updatedUid,
|
||||
List<MenuDto.Basic> children,
|
||||
ZonedDateTime createdDttm,
|
||||
ZonedDateTime updatedDttm) {
|
||||
ZonedDateTime updatedDttm,
|
||||
String menuNmEn) {
|
||||
this.menuUid = menuUid;
|
||||
this.menuNm = menuNm;
|
||||
this.menuUrl = menuUrl;
|
||||
@@ -58,6 +59,7 @@ public class MenuDto {
|
||||
this.children = children;
|
||||
this.createdDttm = createdDttm;
|
||||
this.updatedDttm = updatedDttm;
|
||||
this.menuNmEn = menuNmEn;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class MyMenuService {
|
||||
* @param role
|
||||
* @return
|
||||
*/
|
||||
public List<MyMenuDto.Basic> getFindByRole(String role) {
|
||||
return menuCoreService.getFindByRole(role);
|
||||
public List<MyMenuDto.Basic> getFindByRole(String role, String locale) {
|
||||
return menuCoreService.getFindByRole(role, locale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,16 +25,16 @@ public class MenuCoreService {
|
||||
* @param role
|
||||
* @return
|
||||
*/
|
||||
public List<MyMenuDto.Basic> getFindByRole(String role) {
|
||||
public List<MyMenuDto.Basic> getFindByRole(String role, String locale) {
|
||||
List<MenuEntity> entities = menuRepository.getFindByRole(role);
|
||||
|
||||
boolean english = locale != null && locale.equals("en");
|
||||
return entities.stream()
|
||||
.map(
|
||||
parent -> {
|
||||
MyMenuDto.Basic p =
|
||||
new MyMenuDto.Basic(
|
||||
parent.getMenuUid(),
|
||||
parent.getMenuNm(),
|
||||
english ? parent.getMenuNmEn() : parent.getMenuNm(),
|
||||
parent.getMenuUrl(),
|
||||
parent.getMenuOrder());
|
||||
|
||||
@@ -48,7 +48,10 @@ public class MenuCoreService {
|
||||
.map(
|
||||
c ->
|
||||
new MyMenuDto.Basic(
|
||||
c.getMenuUid(), c.getMenuNm(), c.getMenuUrl(), c.getMenuOrder()))
|
||||
c.getMenuUid(),
|
||||
english ? c.getMenuNmEn() : c.getMenuNm(),
|
||||
c.getMenuUrl(),
|
||||
c.getMenuOrder()))
|
||||
.forEach(childDto -> p.getChildren().add(childDto));
|
||||
|
||||
return p;
|
||||
|
||||
@@ -58,6 +58,9 @@ public class MenuEntity extends CommonDateEntity {
|
||||
@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
private List<MenuEntity> children = new ArrayList<>();
|
||||
|
||||
@Column(name = "menu_nm_en")
|
||||
private String menuNmEn; // 영문 메뉴명
|
||||
|
||||
public MenuDto.Basic toDto() {
|
||||
return new MenuDto.Basic(
|
||||
this.menuUid,
|
||||
@@ -71,6 +74,7 @@ public class MenuEntity extends CommonDateEntity {
|
||||
this.updatedUid,
|
||||
this.children.stream().map(MenuEntity::toDto).toList(),
|
||||
this.getCreatedDate(),
|
||||
this.getModifiedDate());
|
||||
this.getModifiedDate(),
|
||||
this.menuNmEn);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user