로그에 메뉴코드 매핑하여 insert 하기
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.kamco.cd.kamcoback.menu;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiLogFunction;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.menu.dto.MenuDto;
|
||||
import com.kamco.cd.kamcoback.menu.service.MenuService;
|
||||
@@ -9,13 +11,15 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "메뉴 관리", description = "메뉴 관리 API")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -24,21 +28,44 @@ public class MenuApiController {
|
||||
|
||||
private final MenuService menuService;
|
||||
|
||||
@Autowired private ObjectMapper objectMapper;
|
||||
|
||||
@Operation(summary = "목록 조회", description = "모든 메뉴 조회")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "조회 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = MenuDto.Basic.class))),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "조회 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = MenuDto.Basic.class))),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping
|
||||
public ApiResponseDto<List<MenuDto.Basic>> getFindAll() {
|
||||
return ApiResponseDto.ok(menuService.getFindAll());
|
||||
}
|
||||
|
||||
@GetMapping("/find-uri")
|
||||
public ApiResponseDto<String> getFindAllByUid(@RequestParam String apiUri) {
|
||||
List<?> list = menuService.getFindAll();
|
||||
|
||||
List<MenuDto.Basic> result =
|
||||
list.stream()
|
||||
.map(
|
||||
item -> {
|
||||
if (item instanceof LinkedHashMap<?, ?> map) {
|
||||
return objectMapper.convertValue(map, MenuDto.Basic.class);
|
||||
} else if (item instanceof MenuDto.Basic dto) {
|
||||
return dto;
|
||||
} else {
|
||||
throw new IllegalStateException("Unsupported cache type: " + item.getClass());
|
||||
}
|
||||
})
|
||||
.toList();
|
||||
|
||||
return ApiResponseDto.ok(ApiLogFunction.getUriMenuInfo(result, apiUri));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@ package com.kamco.cd.kamcoback.menu.dto;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
public class MenuDto {
|
||||
|
||||
@@ -27,28 +26,26 @@ public class MenuDto {
|
||||
|
||||
private List<MenuDto.Basic> children;
|
||||
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime createdDttm;
|
||||
@JsonFormatDttm private ZonedDateTime createdDttm;
|
||||
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime updatedDttm;
|
||||
@JsonFormatDttm private ZonedDateTime updatedDttm;
|
||||
|
||||
private String menuApiUrl;
|
||||
|
||||
public Basic(
|
||||
String menuUid,
|
||||
String menuNm,
|
||||
String menuUrl,
|
||||
String description,
|
||||
Long menuOrder,
|
||||
Boolean isUse,
|
||||
Boolean deleted,
|
||||
Long createdUid,
|
||||
Long updatedUid,
|
||||
List<MenuDto.Basic> children,
|
||||
ZonedDateTime createdDttm,
|
||||
ZonedDateTime updatedDttm,
|
||||
String menuApiUrl) {
|
||||
String menuUid,
|
||||
String menuNm,
|
||||
String menuUrl,
|
||||
String description,
|
||||
Long menuOrder,
|
||||
Boolean isUse,
|
||||
Boolean deleted,
|
||||
Long createdUid,
|
||||
Long updatedUid,
|
||||
List<MenuDto.Basic> children,
|
||||
ZonedDateTime createdDttm,
|
||||
ZonedDateTime updatedDttm,
|
||||
String menuApiUrl) {
|
||||
this.menuUid = menuUid;
|
||||
this.menuNm = menuNm;
|
||||
this.menuUrl = menuUrl;
|
||||
|
||||
@@ -2,19 +2,18 @@ package com.kamco.cd.kamcoback.menu.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.menu.dto.MenuDto;
|
||||
import com.kamco.cd.kamcoback.postgres.core.MenuCoreService;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MenuService {
|
||||
private final MenuCoreService menuCoreService;
|
||||
|
||||
@Cacheable(value = "menuFindAll")
|
||||
public List<MenuDto.Basic> getFindAll(){
|
||||
public List<MenuDto.Basic> getFindAll() {
|
||||
return menuCoreService.getFindAll();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user