init
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package com.kamco.cd.training.menu;
|
||||
|
||||
import com.kamco.cd.training.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.training.menu.dto.MenuDto;
|
||||
import com.kamco.cd.training.menu.service.MenuService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
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.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "메뉴 관리", description = "메뉴 관리 API")
|
||||
@RestController
|
||||
@RequestMapping("/api/menu")
|
||||
@RequiredArgsConstructor
|
||||
public class MenuApiController {
|
||||
|
||||
private final MenuService menuService;
|
||||
|
||||
@Operation(summary = "메뉴 목록", description = "메뉴 목록 조회")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "검색 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = Page.class))),
|
||||
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping
|
||||
public ApiResponseDto<List<MenuDto.Basic>> getFindAll() {
|
||||
return ApiResponseDto.ok(menuService.getFindAll());
|
||||
}
|
||||
|
||||
@Operation(summary = "캐시 초기화", description = "메뉴관리 캐시를 초기화합니다.")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "캐시 초기화 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = String.class))),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/cache/refresh")
|
||||
public ApiResponseDto<String> refreshCommonCodeCache() {
|
||||
menuService.refresh();
|
||||
return ApiResponseDto.ok("메뉴관리 캐시가 초기화되었습니다.");
|
||||
}
|
||||
}
|
||||
64
src/main/java/com/kamco/cd/training/menu/dto/MenuDto.java
Normal file
64
src/main/java/com/kamco/cd/training/menu/dto/MenuDto.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package com.kamco.cd.training.menu.dto;
|
||||
|
||||
import com.kamco.cd.training.common.utils.interfaces.JsonFormatDttm;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
public class MenuDto {
|
||||
|
||||
@Schema(name = "Menu Basic", description = "메뉴 기본 정보")
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
public static class Basic {
|
||||
|
||||
private String menuUid;
|
||||
private String menuNm;
|
||||
private String menuUrl;
|
||||
private String description;
|
||||
private Long menuOrder;
|
||||
private Boolean isUse;
|
||||
private Boolean deleted;
|
||||
private Long createdUid;
|
||||
private Long updatedUid;
|
||||
|
||||
private List<Basic> children;
|
||||
|
||||
@JsonFormatDttm private ZonedDateTime createdDttm;
|
||||
|
||||
@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<Basic> children,
|
||||
ZonedDateTime createdDttm,
|
||||
ZonedDateTime updatedDttm,
|
||||
String menuApiUrl) {
|
||||
this.menuUid = menuUid;
|
||||
this.menuNm = menuNm;
|
||||
this.menuUrl = menuUrl;
|
||||
this.description = description;
|
||||
this.menuOrder = menuOrder;
|
||||
this.isUse = isUse;
|
||||
this.deleted = deleted;
|
||||
this.createdUid = createdUid;
|
||||
this.updatedUid = updatedUid;
|
||||
this.children = children;
|
||||
this.createdDttm = createdDttm;
|
||||
this.updatedDttm = updatedDttm;
|
||||
this.menuApiUrl = menuApiUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.kamco.cd.training.menu.service;
|
||||
|
||||
import com.kamco.cd.training.menu.dto.MenuDto;
|
||||
import com.kamco.cd.training.postgres.core.MenuCoreService;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
// training 서버는 Redis 사용하지 않고 Spring Boot 메모리 캐시를 사용함
|
||||
// => org.springframework.cache.annotation.Cacheable
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MenuService {
|
||||
private final MenuCoreService menuCoreService;
|
||||
|
||||
@Cacheable("trainMenuFindAll")
|
||||
public List<MenuDto.Basic> getFindAll() {
|
||||
return menuCoreService.getFindAll();
|
||||
}
|
||||
|
||||
/** 메모리 캐시 초기화 */
|
||||
@CacheEvict(value = "trainMenuFindAll", allEntries = true)
|
||||
public void refresh() {}
|
||||
}
|
||||
Reference in New Issue
Block a user