diff --git a/pav-server/src/main/java/com/palnet/biz/api/bas/dron/controller/BasDronController.java b/pav-server/src/main/java/com/palnet/biz/api/bas/dron/controller/BasDronController.java index 0e066315..ae4d2ad7 100644 --- a/pav-server/src/main/java/com/palnet/biz/api/bas/dron/controller/BasDronController.java +++ b/pav-server/src/main/java/com/palnet/biz/api/bas/dron/controller/BasDronController.java @@ -39,7 +39,8 @@ public class BasDronController { /** - * 목록 조회 + * 드론 목록 조회기능, + * BasDronRqModel에 조회할 조건 값들이 들어있음 * @param rq * @return */ @@ -49,17 +50,25 @@ public class BasDronController { public ResponseEntity list(BasDronRqModel rq) { ComnPagingRs result = null; - //입력값 검증 + // 그룹아이디[groupId] 입력값 검증 if(StringUtils.isEmpty(rq.getGroupId())) { - return ResponseEntity.status(HttpStatus.OK) + // 검증통과하지 못할 시 서버에서 "의도적인" 에러 반환 + return ResponseEntity.status(HttpStatus.OK) // "의도적인" 에러 반환코드 .body(new ErrorResponse(RSErrorCode.ER_PARAM)); } try { - result = service.list(rq); + result = service.list(rq); // 드론 목록을 조회하는 기능 } catch (Exception e) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ log.error("IGNORE : {}", e); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new ErrorResponse("Server Error", "-1")); @@ -71,7 +80,8 @@ public class BasDronController { /** - * 식별정보 조회 + * 식별정보 조회하는 기능, + * 기체 일련번호[arcrftSno]로 조회함. * @param rq * @return */ @@ -82,17 +92,25 @@ public class BasDronController { public ResponseEntity mylist(@PathVariable Integer id) { List result = null; - //입력값 검증 + // 기체일련번호확인[id] 입력값 검증처리 if(StringUtils.isEmpty(id)) { - return ResponseEntity.status(HttpStatus.OK) + // 검증통과하지 못할 시 서버에서 "의도적인" 에러 반환 + return ResponseEntity.status(HttpStatus.OK) // "의도적인" 에러 반환코드 .body(new ErrorResponse(RSErrorCode.ER_PARAM)); } try { - result = service.listIdntf(id); + result = service.listIdntf(id); // 기체 일련번호로 기체조회함 } catch (Exception e) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ log.error("IGNORE : {}", e); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new ErrorResponse("Server Error", "-1")); @@ -104,7 +122,8 @@ public class BasDronController { /** - * 상세 조회 + * 드론 상세 조회, + * 기체일련번호[arcrftSno]로 드론 상세조회하는 기능. * @param id * @return */ @@ -116,16 +135,24 @@ public class BasDronController { BasDronModel result = null; try { - //입력값 검증 + // 기체일련번호확인[id] 입력값 검증처리 if(StringUtils.isEmpty(id)) { - return ResponseEntity.status(HttpStatus.OK) - .body(new ErrorResponse(RSErrorCode.ER_PARAM)); + // 검증통과하지 못할 시 서버에서 "의도적인" 에러 반환 + return ResponseEntity.status(HttpStatus.OK) // "의도적인" 에러 반환코드 + .body(new ErrorResponse(RSErrorCode.ER_PARAM)); } - result = service.detail(id); + result = service.detail(id); // 드론 상세 조회하는 기능. } catch (Exception e) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ log.error("IGNORE : {}", e); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new ErrorResponse("Server Error", "-1")); @@ -137,7 +164,8 @@ public class BasDronController { /** - * 생성 + * 드론정보 생성하는 기능, + * BasDronModel 모델에 드론 입력정보로 드론정보 생성함. * @return */ @PostMapping(value = "/create") @@ -147,16 +175,31 @@ public class BasDronController { Map resultMap = new HashMap(); try { - boolean result = service.create(rq); + boolean result = service.create(rq); // 드론 정보 생성하는 기능. resultMap.put("result", result); }catch(CustomException e2) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * CustomException은 개발자가 "의도적으로" 낸 예외처리, + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ log.error("IGNORE : {}", e2); resultMap.put("result", false); resultMap.put("errorCode", e2.getErrorCode()); return ResponseEntity.ok().body(new SuccessResponse(resultMap)); }catch (Exception e) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ log.error("IGNORE : {}", e); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new ErrorResponse("Server Error", "-1")); @@ -167,7 +210,8 @@ public class BasDronController { } /** - * 생성 + * 식별장치 생성하는 기능, + * BasIdntfRqModel 모델에 입력받은 식별장치정보 생성함/ * @return */ @PostMapping(value = "/idntf/create") @@ -178,17 +222,32 @@ public class BasDronController { try { // boolean result = service.create(rq); - boolean result = service.createIdntf(rq); + boolean result = service.createIdntf(rq); // 식밸장치 생성하는 기능. resultMap.put("result", result); }catch(CustomException e2) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * CustomException은 개발자가 "의도적으로" 낸 예외처리, + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ log.error("IGNORE : {}", e2); resultMap.put("result", false); resultMap.put("errorCode", e2.getErrorCode()); return ResponseEntity.ok().body(new SuccessResponse(resultMap)); } catch (Exception e) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ log.error("IGNORE : {}", e); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new ErrorResponse("Server Error", "-1")); @@ -199,7 +258,8 @@ public class BasDronController { } /** - * 수정 + * 드론 정보 수정하는 기능, + * BasDronModel에 입력받은 수정할 정보를 데이터베이스에 수정함. * @return */ @PutMapping(value = "/update") @@ -209,17 +269,32 @@ public class BasDronController { Map resultMap = new HashMap(); try { - boolean result = service.update(rq); + boolean result = service.update(rq); // 드론정보 수정하는 기능. resultMap.put("result", result); } catch(CustomException e2) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * CustomException은 개발자가 "의도적으로" 낸 예외처리, + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ log.error("IGNORE : {}", e2); resultMap.put("result", false); resultMap.put("errorCode", e2.getErrorCode()); return ResponseEntity.ok().body(new SuccessResponse(resultMap)); }catch (Exception e) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ log.error("IGNORE : {}", e); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new ErrorResponse("Server Error", "-1")); @@ -230,7 +305,8 @@ public class BasDronController { } /** - * 삭제 + * 드론정보 삭제하는 기능, + * 기체일련번호[arcrftSno]로 삭제함 * @param id * @return */ @@ -277,17 +353,25 @@ public class BasDronController { try { - //입력값 검증 + // 기체일련번호확인[id] 입력값 검증처리 if(StringUtils.isEmpty(id)) { - return ResponseEntity.status(HttpStatus.OK) - .body(new ErrorResponse(RSErrorCode.ER_PARAM)); - } - - boolean result = service.deleteIdntf(id); + // 검증통과하지 못할 시 서버에서 "의도적인" 에러 반환 + return ResponseEntity.status(HttpStatus.OK) // "의도적인" 에러 반환코드 + .body(new ErrorResponse(RSErrorCode.ER_PARAM)); + } + + boolean result = service.deleteIdntf(id); // 드론정보 삭제하는 기능. resultMap.put("result", result); } catch (Exception e) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ log.error("IGNORE : {}", e); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new ErrorResponse("Server Error", "-1")); diff --git a/pav-server/src/main/java/com/palnet/biz/api/bas/dron/service/BasDronService.java b/pav-server/src/main/java/com/palnet/biz/api/bas/dron/service/BasDronService.java index b2f81aef..5be94c80 100644 --- a/pav-server/src/main/java/com/palnet/biz/api/bas/dron/service/BasDronService.java +++ b/pav-server/src/main/java/com/palnet/biz/api/bas/dron/service/BasDronService.java @@ -48,7 +48,7 @@ public class BasDronService { private JwtTokenUtil jwtTokenUtil; /** - * 드론 목록 + * 드론 목록을 조회하는 기능 * @param rq * @return */ @@ -56,10 +56,13 @@ public class BasDronService { ComnPagingRs response = new ComnPagingRs<>(); + // 페이징 처리를 위한 객체 Pageable pageable = PageRequest.of(rq.getPage()-1, rq.getRecord()); + // 데이터 베이스에서 검색조건에 맞는 값으로 드론목록 조회함. PageImpl result = query.list(rq, pageable); - + + // 데이터 베이스에서 전체 리스트 값이 몇인지 조회. long total = query.listCount(rq); long totalPage = total % rq.getRecord() > 0 ? (total/rq.getRecord()) + 1 : total/rq.getRecord(); @@ -92,7 +95,7 @@ public class BasDronService { } /** - * 상세 조회 + * 드론 상세 조회하는 기능. * @param arcrftSno * @return * @throws Exception @@ -110,7 +113,7 @@ public class BasDronService { } /** - * 생성 + * 드론 정보 생성하는 기능. * @param * @return * @throws Exception @@ -168,7 +171,7 @@ public class BasDronService { } /** - * 식밸장치 생성 + * 식밸장치 생성하는 기능. * @param * @return * @throws Exception @@ -206,6 +209,11 @@ public class BasDronService { } + /** + * 드론정보 삭제하는 기능. + * @param idntfNum + * @return + */ public boolean deleteIdntf(String idntfNum) { Optional optional = comIdntBasRepository.findById(idntfNum); @@ -218,7 +226,13 @@ public class BasDronService { return true; } - + + /** + * 입력받은 드론정보 데이터베이스에 생성함. + * @param model + * @return + * @throws Exception + */ public ComArcrftBas insertComArcrftBas(BasDronModel model) throws Exception{ @@ -261,7 +275,7 @@ public class BasDronService { /** - * 수정 + * 드론정보 수정하는 기능. * @param * @return * @throws Exception @@ -319,7 +333,13 @@ public class BasDronService { return true; } - + + /** + * 입력받은 드론 수정정보로 데이터베이스에 수정함. + * @param model + * @return + * @throws Exception + */ public ComArcrftBas updateComArcrftBas(BasDronModel model) throws Exception{ diff --git a/pav-server/src/main/java/com/palnet/biz/jpa/repository/pty/PtyDronQueryRepository.java b/pav-server/src/main/java/com/palnet/biz/jpa/repository/pty/PtyDronQueryRepository.java index 2e38fdee..de494b49 100644 --- a/pav-server/src/main/java/com/palnet/biz/jpa/repository/pty/PtyDronQueryRepository.java +++ b/pav-server/src/main/java/com/palnet/biz/jpa/repository/pty/PtyDronQueryRepository.java @@ -31,7 +31,7 @@ public class PtyDronQueryRepository{ private final JPAQueryFactory query; /** - * 목록 조회 + * 드론 목록 조회하는 SQL기능. * @param rq * @return */ @@ -55,8 +55,39 @@ public class PtyDronQueryRepository{ builder.and(bas.arcrftTypeCd.eq(rq.getArcrftTypeCd())); } - builder.and(bas.useYn.eq("Y")); + builder.and(bas.useYn.eq("Y")); // 사용여부값 + /** + * 기체이름 값[arcrftModelNm] 조건인지, + * 그룹아이디 값 [groupId] 조건인지, + * 기체타입 값 [arcrftTypeCd] 조건인지, + * 사용여부 값 [useYn] 이 "Y" 인지 조건으로 데이터베이스에서 조회하는 SQL입니다. + * SELECT + * CAB.GROUP_ID , + * CAB.ARCRFT_SNO , + * CAB.ARCRFT_HGHT , + * CAB.ARCRFT_LNGTH , + * CAB.ARCRFT_MODEL_NM , + * CAB.ARCRFT_TYPE_CD , + * CAB.ARCRFT_WDTH , + * CAB.ARCRFT_WGHT , + * CAB.CAMERA_YN , + * CAB.CREATE_DT , + * CAB.CREATE_USER_ID , + * CAB.INSRNC_YN , + * CAB.PRDCT_CMPN_NM , + * CAB.PRDCT_DATE , + * CAB.PRDCT_NUM , + * CAB.TAKEOFF_WGHT , + * CAB.UPDATE_DT , + * CAB.UPDATE_USER_ID , + * CAB.WGHT_TYPE_CD + * FROM COM_ARCRFT_BAS CAB + * WHERE CAB.USE_YN = 'Y' + * AND CAB.ARCRFT_MODEL_NM = #{arcrftModelNm} -- 조건에 있을경우 + * AND CAB.GROUP_ID = #{groupId} -- 조건에 있을경우 + * AND CAB.ARCRFT_TYPE_CD = #{arcrftTypeCd} -- 조건에 있을경우 + */ List result = query.select(Projections.bean(BasDronModel.class , bas.groupId, @@ -97,7 +128,13 @@ public class PtyDronQueryRepository{ return new PageImpl<>(result, pageable, result.size()); } - public long listCount(BasDronRqModel rq){ + + /** + * 검색조건에 맞춘 드론목록의 사이즈가 몇인지 조회하는 SQL기능 + * @param rq + * @return + */ + public long listCount(BasDronRqModel rq){ QComArcrftBas bas = QComArcrftBas.comArcrftBas; QComIdntfBas idnt = QComIdntfBas.comIdntfBas; @@ -119,6 +156,19 @@ public class PtyDronQueryRepository{ builder.and(bas.useYn.eq("Y")); + /** + * 기체이름 값[arcrftModelNm] 조건인지, + * 그룹아이디 값 [groupId] 조건인지, + * 기체타입 값 [arcrftTypeCd] 조건인지, + * 사용여부 값 [useYn] 이 "Y" 인지 조건으로 데이터베이스에서 조회하는 SQL입니다. + * SELECT + * count(*) + * FROM COM_ARCRFT_BAS CAB + * WHERE CAB.USE_YN = 'Y' + * AND CAB.ARCRFT_MODEL_NM = #{arcrftModelNm} -- 조건에 있을경우 + * AND CAB.GROUP_ID = #{groupId} -- 조건에 있을경우 + * AND CAB.ARCRFT_TYPE_CD = #{arcrftTypeCd} -- 조건에 있을경우 + */ List result = query.select(Projections.bean(BasDronModel.class , bas.groupId, @@ -161,7 +211,7 @@ public class PtyDronQueryRepository{ return cnt; } /** - * 식별번호 조회 + * 식별번호 조회하는 SQL기능. * @param arcrftSno * @return */ @@ -174,7 +224,25 @@ public class PtyDronQueryRepository{ BooleanBuilder builder = new BooleanBuilder(); builder.and(idnt.arcrftSno.eq(arcrftSno)); - + /** + * 기체일련번호[arcrftSno] 조건으로 조회하는 SQL기능입니다. + * + * SELECT + * CIB.ARCRFT_SNO , + * CIB.IDNTF_NUM , + * CIB.IDNTF_TYPE_CD , + * CIB.CREATE_DT , + * CIB.UPDATE_DT , + * CIB.OWNER_NM , + * CIB.HPNO , + * CIB.CSTMR_SNO , + * CAB.GROUP_ID + * FROM COM_IDNTF_BAS CIB + * LEFT OUTER JOIN COM_ARCRFT_BAS CAB + * ON CIB.ARCRFT_SNO = CAB.ARCRFT_SNO + * WHERE CIB.ARCRFT_SNO = #{arcrftSno} + * ORDER BY CIB.CREATE_DT ASC + */ List result = query.select(Projections.bean(BasIdntfModel.class , @@ -200,7 +268,7 @@ public class PtyDronQueryRepository{ /** - * 상세 조회 + * 드론 상세 조회하는 SQL기능. * @param arcrftSno * @return */ @@ -208,6 +276,33 @@ public class PtyDronQueryRepository{ QComArcrftBas bas = QComArcrftBas.comArcrftBas; + /** + * 기체일련번호[arcrftSno] 조건으로 드론 상세조회하는 SQL입니다. + * + * SELECT + * CAB.GROUP_ID , + * CAB.ARCRFT_SNO , + * CAB.ARCRFT_HGHT , + * CAB.ARCRFT_LNGTH , + * CAB.ARCRFT_MODEL_NM , + * CAB.ARCRFT_TYPE_CD , + * CAB.ARCRFT_WDTH , + * CAB.ARCRFT_WGHT , + * CAB.CAMERA_YN , + * CAB.CREATE_DT , + * CAB.CREATE_USER_ID , + * CAB.INSRNC_YN , + * CAB.PRDCT_CMPN_NM , + * CAB.PRDCT_DATE , + * CAB.PRDCT_NUM , + * CAB.TAKEOFF_WGHT , + * CAB.UPDATE_DT , + * CAB.UPDATE_USER_ID , + * CAB.WGHT_TYPE_CD , + * CAB.IMAGE_URL + * FROM COM_ARCRFT_BAS CAB + * WHERE CAB.ARCRFT_SNO = #{arcrftSno} + */ BasDronModel result = query.select(Projections.bean(BasDronModel.class , bas.groupId,