Browse Source

스웨거 어노테이션 추가

pull/16/head
lkd9125(이경도) 10 months ago
parent
commit
6301df3673
  1. 42
      pav-server/src/main/java/com/palnet/biz/api/comn/coordinate/controller/ComnCoordinateController.java
  2. 21
      pav-server/src/main/java/com/palnet/biz/api/comn/coordinate/service/ComnCoordinateService.java

42
pav-server/src/main/java/com/palnet/biz/api/comn/coordinate/controller/ComnCoordinateController.java

@ -1,5 +1,9 @@
package com.palnet.biz.api.comn.coordinate.controller; package com.palnet.biz.api.comn.coordinate.controller;
import java.util.HashMap;
import java.util.Map;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -8,7 +12,13 @@ import org.springframework.web.bind.annotation.RestController;
import com.palnet.biz.api.comn.coordinate.model.CompotentAuthorityRQ; import com.palnet.biz.api.comn.coordinate.model.CompotentAuthorityRQ;
import com.palnet.biz.api.comn.coordinate.model.CompotentAuthorityRS; import com.palnet.biz.api.comn.coordinate.model.CompotentAuthorityRS;
import com.palnet.biz.api.comn.coordinate.service.ComnCoordinateService; import com.palnet.biz.api.comn.coordinate.service.ComnCoordinateService;
import com.palnet.biz.api.comn.response.BasicResponse;
import com.palnet.biz.api.comn.response.ErrorResponse;
import com.palnet.biz.api.comn.response.SuccessResponse;
import com.palnet.comn.exception.CustomException;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -16,17 +26,39 @@ import lombok.extern.slf4j.Slf4j;
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/api/comn/coordinate") @RequestMapping("/api/comn/coordinate")
@Slf4j @Slf4j
@Tag(name = "공통 API", description = "공통 API")
public class ComnCoordinateController { public class ComnCoordinateController {
private final ComnCoordinateService comnCoordinateService; private final ComnCoordinateService comnCoordinateService;
/**
* 좌표로 관할기관 가져오기
* @param rq
* @return
*/
@GetMapping("/comptent-authority") @GetMapping("/comptent-authority")
public ResponseEntity<CompotentAuthorityRS> getCompetentAuthority(CompotentAuthorityRQ rq){ @ApiOperation(value = "좌표로 관할 기관청 가져오기")
log.warn("ComnCoordinateController - getCompetentAuthority()"); @Tag(name = "공통 API", description = "공통 API")
log.warn("RQ => {}", rq); public ResponseEntity<? extends BasicResponse> getCompetentAuthority(CompotentAuthorityRQ rq){
CompotentAuthorityRS result = new CompotentAuthorityRS();
try {
result = comnCoordinateService.getCompetentAuthority(rq);
} catch (CustomException e) {
Map<String, Object> resultMap = new HashMap<>();
log.error("IGNORE : ", e);
resultMap.put("result", false);
resultMap.put("errorCode", e.getErrorCode());
resultMap.put("errorMessage", e.getMessage());
return ResponseEntity.ok().body(new SuccessResponse<>(resultMap));
} catch (Exception e) {
log.error("IGNORE : ", e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(new ErrorResponse("Server Error", "-1"));
CompotentAuthorityRS result = comnCoordinateService.getCompetentAuthority(rq); }
return ResponseEntity.ok().body(result); return ResponseEntity.ok().body(new SuccessResponse<>(result));
} }
} }

21
pav-server/src/main/java/com/palnet/biz/api/comn/coordinate/service/ComnCoordinateService.java

@ -18,11 +18,9 @@ import com.palnet.biz.jpa.repository.flt.FltCptAuthAdminDistrictBasQueryReposito
import com.palnet.comn.utils.FlightUtils; import com.palnet.comn.utils.FlightUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j
public class ComnCoordinateService { public class ComnCoordinateService {
private final FltCptAuthAdminDistrictBasQueryRepository ffFltCptAuthAdminDistrictBasQueryRepository; private final FltCptAuthAdminDistrictBasQueryRepository ffFltCptAuthAdminDistrictBasQueryRepository;
@ -49,25 +47,19 @@ public class ComnCoordinateService {
Set<FltCptAuthBas> fltCptAuthBas = new HashSet<FltCptAuthBas>(); Set<FltCptAuthBas> fltCptAuthBas = new HashSet<FltCptAuthBas>();
for(int i = 0; i < scope.length; i++){ for(int i = 0; i < scope.length; i++){
String cdParam = this.codeParsing(cd, scope[i]);
String cdParam = this.codeParsing(cd, scope[i]);
log.warn("cdParam => {}", cdParam);
List<FltCptAuthBas> authList = ffFltCptAuthAdminDistrictBasQueryRepository.geFltCptAuthBas(cdParam); List<FltCptAuthBas> authList = ffFltCptAuthAdminDistrictBasQueryRepository.geFltCptAuthBas(cdParam);
fltCptAuthBas.addAll(new HashSet<FltCptAuthBas>(authList)); fltCptAuthBas.addAll(new HashSet<FltCptAuthBas>(authList));
} }
CompotentAuthorityRS result = new CompotentAuthorityRS(); CompotentAuthorityRS result = new CompotentAuthorityRS();
result.setFltCptpAuthBasList(new ArrayList<>(fltCptAuthBas)); result.setFltCptpAuthBasList(new ArrayList<>(fltCptAuthBas));
log.warn("result => {}", result);
return result; return result;
} }
private String codeParsing(String cd, String scope){ private String codeParsing(String cd, String scope){
switch (scope) { switch (scope) {
case "ctprvn": case "ctprvn":
@ -100,11 +92,14 @@ public class ComnCoordinateService {
int difference = maxLength - length; int difference = maxLength - length;
for(int i = 0; i < difference; i++){ StringBuilder sb = new StringBuilder();
cd += "0"; sb.append(cd);
for(int i = 0; i < difference; i++){
sb.append("0");
} }
return cd; return sb.toString();
} }
} }

Loading…
Cancel
Save