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. 15
      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;
import java.util.HashMap;
import java.util.Map;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
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.CompotentAuthorityRS;
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.extern.slf4j.Slf4j;
@ -16,17 +26,39 @@ import lombok.extern.slf4j.Slf4j;
@RequiredArgsConstructor
@RequestMapping("/api/comn/coordinate")
@Slf4j
@Tag(name = "공통 API", description = "공통 API")
public class ComnCoordinateController {
private final ComnCoordinateService comnCoordinateService;
/**
* 좌표로 관할기관 가져오기
* @param rq
* @return
*/
@GetMapping("/comptent-authority")
public ResponseEntity<CompotentAuthorityRS> getCompetentAuthority(CompotentAuthorityRQ rq){
log.warn("ComnCoordinateController - getCompetentAuthority()");
log.warn("RQ => {}", rq);
@ApiOperation(value = "좌표로 관할 기관청 가져오기")
@Tag(name = "공통 API", description = "공통 API")
public ResponseEntity<? extends BasicResponse> getCompetentAuthority(CompotentAuthorityRQ rq){
CompotentAuthorityRS result = new CompotentAuthorityRS();
CompotentAuthorityRS result = comnCoordinateService.getCompetentAuthority(rq);
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"));
}
return ResponseEntity.ok().body(result);
return ResponseEntity.ok().body(new SuccessResponse<>(result));
}
}

15
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 lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Service
@RequiredArgsConstructor
@Slf4j
public class ComnCoordinateService {
private final FltCptAuthAdminDistrictBasQueryRepository ffFltCptAuthAdminDistrictBasQueryRepository;
@ -49,10 +47,7 @@ public class ComnCoordinateService {
Set<FltCptAuthBas> fltCptAuthBas = new HashSet<FltCptAuthBas>();
for(int i = 0; i < scope.length; i++){
String cdParam = this.codeParsing(cd, scope[i]);
log.warn("cdParam => {}", cdParam);
List<FltCptAuthBas> authList = ffFltCptAuthAdminDistrictBasQueryRepository.geFltCptAuthBas(cdParam);
fltCptAuthBas.addAll(new HashSet<FltCptAuthBas>(authList));
@ -61,13 +56,10 @@ public class ComnCoordinateService {
CompotentAuthorityRS result = new CompotentAuthorityRS();
result.setFltCptpAuthBasList(new ArrayList<>(fltCptAuthBas));
log.warn("result => {}", result);
return result;
}
private String codeParsing(String cd, String scope){
switch (scope) {
case "ctprvn":
@ -100,11 +92,14 @@ public class ComnCoordinateService {
int difference = maxLength - length;
StringBuilder sb = new StringBuilder();
sb.append(cd);
for(int i = 0; i < difference; i++){
cd += "0";
sb.append("0");
}
return cd;
return sb.toString();
}
}

Loading…
Cancel
Save