63 lines
2.4 KiB
Java
63 lines
2.4 KiB
Java
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("메뉴관리 캐시가 초기화되었습니다.");
|
|
}
|
|
}
|