package com.kamco.cd.kamcoback.layer; import com.kamco.cd.kamcoback.config.api.ApiResponseDto; import com.kamco.cd.kamcoback.layer.dto.LayerDto; import com.kamco.cd.kamcoback.layer.dto.LayerDto.IsMapYn; import com.kamco.cd.kamcoback.layer.dto.LayerDto.LayerMapDto; import com.kamco.cd.kamcoback.layer.dto.LayerDto.OrderReq; import com.kamco.cd.kamcoback.layer.dto.LayerDto.SearchReq; import com.kamco.cd.kamcoback.layer.service.LayerService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.ArraySchema; 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 java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; 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") @RestController @RequiredArgsConstructor @RequestMapping("/api/layer") public class LayerApiController { private final LayerService layerService; @Operation(summary = "지도 레이어 관리 목록", description = "지도 레이어 관리 목록 api") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "검색 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = LayerDto.Basic.class))), @ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @GetMapping("/list") public ApiResponseDto> getLayers( @RequestParam(required = false) String tag) { LayerDto.SearchReq searchReq = new SearchReq(); searchReq.setTag(tag); List layers = layerService.getLayers(searchReq); return ApiResponseDto.ok(layers); } /** * 레이어 등록 * * @param layerType * @param dto * @return */ @Operation(summary = "레이어 등록", description = "레이어 등록 api") @ApiResponses( value = { @ApiResponse( responseCode = "201", description = "등록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = UUID.class))), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @PostMapping("/save/{layerType}") public ApiResponseDto save( @Schema(description = "TILE,GEOJSON,WMS,WMTS", example = "GEOJSON") @PathVariable String layerType, @RequestBody LayerDto.AddReq dto) { return ApiResponseDto.ok(layerService.saveLayers(layerType, dto)); } @Operation(summary = "순서 변경", description = "순서 변경 api") @ApiResponses( value = { @ApiResponse( responseCode = "201", description = "등록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Void.class))), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @PutMapping("/order") public ApiResponseDto updateOrder(@RequestBody List dto) { layerService.orderUpdate(dto); return ApiResponseDto.ok(null); } @Operation(summary = "상세 조회", description = "상세 조회 api") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "검색 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = LayerDto.Detail.class))), @ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @GetMapping("/detail/{uuid}") public ApiResponseDto getDetail(@PathVariable UUID uuid) { return ApiResponseDto.ok(layerService.getDetail(uuid)); } /** * 레이어 삭제 * * @param uuid * @return */ @Operation(summary = "레이어 삭제", description = "레이어 삭제 api") @ApiResponses( value = { @ApiResponse( responseCode = "201", description = "삭제 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Void.class))), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @DeleteMapping("/delete/{uuid}") public ApiResponseDto delete(@PathVariable UUID uuid) { layerService.delete(uuid); return ApiResponseDto.ok(null); } /** * 레이어 수정 * * @param uuid * @return */ @Operation(summary = "레이어 수정", description = "레이어 수정 api") @ApiResponses( value = { @ApiResponse( responseCode = "201", description = "수정 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Void.class))), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @PutMapping("/update/{uuid}") public ApiResponseDto update(@PathVariable UUID uuid, @RequestBody LayerDto.Detail dto) { layerService.update(uuid, dto); return ApiResponseDto.ok(null); } @Operation(summary = "맵 노출여부 수정", description = "맵 노출여부 수정 api") @ApiResponses( value = { @ApiResponse( responseCode = "201", description = "수정 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Void.class))), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @PutMapping("/update-map/{uuid}") public ApiResponseDto updateIsMap(@PathVariable UUID uuid, @RequestBody IsMapYn isMapYn) { layerService.updateIsMap(uuid, isMapYn); return ApiResponseDto.ok(null); } @Operation(summary = "wmts tile 조회", description = "wmts tile 조회 api") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "검색 성공", content = @Content( mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = String.class)))), @ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @GetMapping("/wmts/tile") public ApiResponseDto> getWmtsTile() { return ApiResponseDto.ok(layerService.getWmtsTile()); } @Operation(summary = "wms tile 조회", description = "wms tile 조회 api") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "검색 성공", content = @Content( mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = String.class)))), @ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @GetMapping("/wms/tile") public ApiResponseDto> getWmsTile() { return ApiResponseDto.ok(layerService.getWmsTitle()); } @Operation(summary = "변화지도 레이어 조회", description = "변화지도 레이어 조회") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "검색 성공", content = @Content( mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = String.class)))), @ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @GetMapping("/map/change-detection") public ApiResponseDto> changeDetectionMap() { return ApiResponseDto.ok(layerService.findLayerMapList("change-detection")); } @Operation(summary = "라벨링 툴 레이어 조회", description = "라벨링 툴 레이어 조회") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "검색 성공", content = @Content( mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = String.class)))), @ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @GetMapping("/map/labeling") public ApiResponseDto> labelingMap() { return ApiResponseDto.ok(layerService.findLayerMapList("labeling")); } @Operation(summary = "년도별 tile Url(before,after 모두 조회)", description = "년도별 tile Url") @GetMapping("/tile-url") public ApiResponseDto getChangeDetectionTileUrl( @Parameter(description = "이전 년도", example = "2023") @RequestParam Integer beforeYear, @Parameter(description = "이후 년도", example = "2024") @RequestParam Integer afterYear) { return ApiResponseDto.ok(layerService.getChangeDetectionTileUrl(beforeYear, afterYear)); } @Operation(summary = "년도별 tile Url(년도 1개만 조회)", description = "년도별 tile Url") @GetMapping("/tile-url-year") public ApiResponseDto getChangeDetectionTileOneYearUrl( @Parameter(description = "년도", example = "2023") @RequestParam Integer year) { return ApiResponseDto.ok(layerService.getChangeDetectionTileOneYearUrl(year)); } }