package com.kamco.cd.kamcoback.Innopam; import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto; import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.Basic; import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastReq; import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.DetectMastSearch; import com.kamco.cd.kamcoback.Innopam.dto.DetectMastDto.FeaturePnuDto; import com.kamco.cd.kamcoback.Innopam.service.DetectMastService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; 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 jakarta.validation.Valid; import java.util.List; import java.util.UUID; import lombok.RequiredArgsConstructor; 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 = "이노펨 mockup API", description = "이노펨 mockup API") @RestController @RequiredArgsConstructor @RequestMapping("/api/kcd/cdi/detect") public class InnopamApiController { private final DetectMastService detectMastService; /** 탐지결과 등록 */ @Operation(summary = "탐지결과 등록", description = "탐지결과 등록") @ApiResponses( value = { @ApiResponse( responseCode = "201", description = "등록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = DetectMastReq.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @PostMapping("/mast/regist") public DetectMastReq setChangeDetection( @RequestBody @Valid DetectMastDto.DetectMastReq detectMast) { detectMastService.saveDetectMast(detectMast); return detectMast; } @Operation(summary = "탐지결과 삭제", description = "탐지결과 삭제") @ApiResponses( value = { @ApiResponse( responseCode = "201", description = "등록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = DetectMastReq.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @PostMapping("/mast/remove") public String deleteChangeDetection(@RequestBody DetectMastReq detectMast) { return "OK"; } @Operation(summary = "탐지결과 등록목록 조회", description = "탐지결과 등록목록 조회") @GetMapping("/mast/list") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "목록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Basic.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) public List selectChangeDetectionList( @RequestParam(required = false) String cprsBfYr, @RequestParam(required = false) String cprsAdYr, @RequestParam(required = false) Integer dtctSno) { DetectMastSearch detectMastSearch = new DetectMastSearch(); detectMastSearch.setCprsAdYr(cprsAdYr); detectMastSearch.setCprsBfYr(cprsBfYr); detectMastSearch.setDtctSno(dtctSno); return detectMastService.selectDetectMast(detectMastSearch); } @Operation(summary = "탐지결과 등록목록 상세 조회", description = "탐지결과 등록목록 상세 조회") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "목록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Basic.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @GetMapping("/mast/list/{dtctMstId}") public Basic selectChangeDetectionDetail(@PathVariable Long dtctMstId) { return detectMastService.selectDetectMast(dtctMstId); } @Operation(summary = "탐지객체 랜덤 PNU 리스트 조회", description = "탐지객체 PNU 랜덤값을 생성해서 보여준다") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "목록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = FeaturePnuDto.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @GetMapping("/pnu/{cprsBfYr}/{cprsAfYr}/{dtctSno}") public List selectPnuList( @PathVariable String cprsBfYr, @PathVariable String cprsAfYr, @PathVariable Integer dtctSno) { DetectMastSearch detectMastSearch = new DetectMastSearch(); detectMastSearch.setCprsAdYr(cprsAfYr); detectMastSearch.setCprsBfYr(cprsBfYr); detectMastSearch.setDtctSno(dtctSno); return detectMastService.findPnuData(detectMastSearch); } @Operation(summary = "탐지객체 랜덤 PNU 상세 조회", description = "탐지객체 PNU 랜덤값을 생성해서 보여준다") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "목록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = FeaturePnuDto.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @GetMapping("/pnu/{cprsBfYr}/{cprsAfYr}/{dtctSno}/{featureId}") public FeaturePnuDto selectPnuDetail( @Parameter(description = "이전년도", example = "2022") @PathVariable String cprsBfYr, @Parameter(description = "기준년도", example = "2024") @PathVariable String cprsAfYr, @Parameter(description = "회차", example = "4") @PathVariable Integer dtctSno, @Parameter(description = "featureId", example = "000e161b-1955-4c89-ad87-0b3b4a91d00f") @PathVariable UUID featureId) { return detectMastService.selectPnuDetail(featureId); } @Operation( summary = "탐지객체 랜덤 PNU GEOM 업데이트(이노펨에 없는 API)", description = "탐지객체 랜덤 PNU GEOM 업데이트(이노펨에 없는 API)") @ApiResponses( value = { @ApiResponse( responseCode = "201", description = "pnu 업데이트 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Integer.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @PutMapping("/pnu/{cprsBfYr}/{cprsAfYr}/{dtctSno}") public Integer updatePnuList( @PathVariable String cprsBfYr, @PathVariable String cprsAfYr, @PathVariable Integer dtctSno) { DetectMastSearch detectMastSearch = new DetectMastSearch(); detectMastSearch.setCprsAdYr(cprsAfYr); detectMastSearch.setCprsBfYr(cprsBfYr); detectMastSearch.setDtctSno(dtctSno); return detectMastService.updatePnuData(detectMastSearch); } }