diff --git a/pav-server/src/main/java/com/palnet/biz/api/cns/faq/controller/CnsFaqController.java b/pav-server/src/main/java/com/palnet/biz/api/cns/faq/controller/CnsFaqController.java index 5ff5e8ef..e209e336 100644 --- a/pav-server/src/main/java/com/palnet/biz/api/cns/faq/controller/CnsFaqController.java +++ b/pav-server/src/main/java/com/palnet/biz/api/cns/faq/controller/CnsFaqController.java @@ -31,14 +31,27 @@ public class CnsFaqController { private final CnsFaqService service; - /*FAQ 목록 조회*/ + /** + * FAQ 목록 조회하는 기능, + * FaqListRQModel 값에 있는 조건값으로 조회함. + * @param model + * @return + */ @Tag(name = "FAQ API", description = "FAQ 관련 API") @GetMapping public ResponseEntity getFaqList(FaqListRQModel model) { List result = null; try { - result = service.getFaqList(model); + result = service.getFaqList(model); // FaQ 항목들 조회하는 기능 } catch (CustomException e) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * CustomException은 개발자가 "의도적으로" 낸 예외처리, + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ Map resultMap = new HashMap<>(); log.error("IGNORE : ", e); resultMap.put("result", false); @@ -46,6 +59,13 @@ public class CnsFaqController { resultMap.put("errorMessage", e.getMessage()); 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")); @@ -54,14 +74,27 @@ public class CnsFaqController { return ResponseEntity.ok().body(new SuccessResponse<>(result)); } - /*FAQ 상세 조회*/ + /** + * FAQ 상세 조회하는 기능, + * 일련번호[sno]로 조회함. + * @param sno + * @return + */ @Tag(name = "FAQ API", description = "FAQ 관련 API") @GetMapping("/{sno}") public ResponseEntity getFaqDetail(@PathVariable("sno") int sno) { FaqListModel result = null; try { - result = service.getFaqDetail(sno); + result = service.getFaqDetail(sno); // 일련번호[sno]로 상세정보를 조회하는 기능 } catch (CustomException e) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * CustomException은 개발자가 "의도적으로" 낸 예외처리, + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ Map resultMap = new HashMap<>(); log.error("IGNORE : ", e); resultMap.put("result", false); @@ -69,6 +102,13 @@ public class CnsFaqController { resultMap.put("errorMessage", e.getMessage()); 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")); @@ -77,14 +117,27 @@ public class CnsFaqController { return ResponseEntity.ok().body(new SuccessResponse<>(result)); } - /*FAQ 작성*/ + /** + * FAQ 작성하는 기능, + * FaqListModel모델에 있는 값으로 작성하는 기능. + * @param model + * @return + */ @Tag(name = "FAQ API", description = "FAQ 관련 API") @PostMapping public ResponseEntity insertFaq(@RequestBody FaqListModel model) { boolean result = false; try { - result = service.insertFaq(model); + result = service.insertFaq(model); // FaQ 추가하는 기능 } catch (CustomException e) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * CustomException은 개발자가 "의도적으로" 낸 예외처리, + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ Map resultMap = new HashMap<>(); log.error("IGNORE : ", e); resultMap.put("result", false); @@ -92,6 +145,13 @@ public class CnsFaqController { resultMap.put("errorMessage", e.getMessage()); 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")); @@ -102,14 +162,27 @@ public class CnsFaqController { } - /*FAQ 업데이트*/ + /** + * FAQ 업데이트 기능, + * FaqListModel 모델에 있는 값으로 업데이트함. + * @param model + * @return + */ @Tag(name = "FAQ API", description = "FAQ 관련 API") @PutMapping public ResponseEntity updateFaq(@RequestBody FaqListModel model) { boolean result = false; try { - result = service.updateFaq(model); + result = service.updateFaq(model); // FaQ 수정하는 기능 } catch (CustomException e) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * CustomException은 개발자가 "의도적으로" 낸 예외처리, + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ Map resultMap = new HashMap<>(); log.error("IGNORE : ", e); resultMap.put("result", false); @@ -117,6 +190,13 @@ public class CnsFaqController { resultMap.put("errorMessage", e.getMessage()); 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")); @@ -126,14 +206,26 @@ public class CnsFaqController { } - /*FAQ 논리 삭제*/ + /** + * FAQ 삭제하는 기능, + * 일련번호[sno]로 삭제하는 기능. + * @param sno + * @return + */ @Tag(name = "FAQ API", description = "FAQ 관련 API") @DeleteMapping("/{sno}") public ResponseEntity deleteFaq(@PathVariable("sno") int sno) { // TODO 성공/실패 상태값 전송 try { - service.deleteFaq(sno); + service.deleteFaq(sno); // 일련번호[sno]로 삭제하는 기능 } catch (CustomException e) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ Map resultMap = new HashMap<>(); log.error("IGNORE : ", e); resultMap.put("result", false); @@ -141,6 +233,13 @@ public class CnsFaqController { resultMap.put("errorMessage", e.getMessage()); 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")); diff --git a/pav-server/src/main/java/com/palnet/biz/api/cns/faq/service/CnsFaqService.java b/pav-server/src/main/java/com/palnet/biz/api/cns/faq/service/CnsFaqService.java index 5c0e8d17..493ef774 100644 --- a/pav-server/src/main/java/com/palnet/biz/api/cns/faq/service/CnsFaqService.java +++ b/pav-server/src/main/java/com/palnet/biz/api/cns/faq/service/CnsFaqService.java @@ -25,6 +25,11 @@ public class CnsFaqService { private final CnsFaqBasRepository cnsFaqBasRepository; private final JwtTokenUtil jwtTokenUtil; + /** + * FaQ 항목들 조회하는 기능. + * @param model + * @return + */ public List getFaqList(FaqListRQModel model){ List result = query.getFaqList(model.getCategory(), model.getWord()); @@ -34,7 +39,12 @@ public class CnsFaqService { return result; } - + + /** + * 일련번호[sno]로 상세정보를 조회하는 기능. + * @param sno + * @return + */ public FaqListModel getFaqDetail(int sno){ cnsFaqBasRepository.updateViewCnt(sno); FaqListModel result = query.getFaqDetail(sno); @@ -42,6 +52,11 @@ public class CnsFaqService { return result; } + /** + * FaQ 추가하는 기능. + * @param model + * @return + */ @Transactional public boolean insertFaq(FaqListModel model){ String userId = jwtTokenUtil.getUserIdByToken(); @@ -69,6 +84,11 @@ public class CnsFaqService { } } + /** + * FaQ 수정하는 기능. + * @param model + * @return + */ @Transactional public boolean updateFaq(FaqListModel model) { String userId = jwtTokenUtil.getUserIdByToken(); @@ -92,6 +112,10 @@ public class CnsFaqService { } } + /** + * 일련번호[sno]로 삭제하는 기능. + * @param sno + */ public void deleteFaq(int sno) { // TODO 반환값이 실행한 갯수인지 확인 필요 diff --git a/pav-server/src/main/java/com/palnet/biz/jpa/repository/cns/CnsFaqQueryRepository.java b/pav-server/src/main/java/com/palnet/biz/jpa/repository/cns/CnsFaqQueryRepository.java index ead1ace9..1fa9fe91 100644 --- a/pav-server/src/main/java/com/palnet/biz/jpa/repository/cns/CnsFaqQueryRepository.java +++ b/pav-server/src/main/java/com/palnet/biz/jpa/repository/cns/CnsFaqQueryRepository.java @@ -18,6 +18,12 @@ public class CnsFaqQueryRepository { private final JPAQueryFactory query; + /** + * 조건값으로 FaQ리스트를 조회하는 SQL기능. + * @param category + * @param word + * @return + */ public List getFaqList(String category, String word) { QCnsFaqBas bas = QCnsFaqBas.cnsFaqBas; @@ -34,6 +40,30 @@ public class CnsFaqQueryRepository { builder.and(bas.title.contains(word)); } + /** + * 삭제여부[delYn]값이 'N' 조건, + * 표출여부[expsrYn]값이 'Y' 조건, + * 카테고리값[category]값 조건, + * 제목[title] 값이 word와의 조건 값으로 조회하는 SQL 입니다. + * + * SELECT + * CFB.FAQ_SNO , + * CFB.CATEGORY , + * CFB.TITLE , + * CFB.CONTENT , + * CFB.VIEW_CNT , + * CFB.EXPSR_YN , + * CFB.CREATE_USER_ID , + * CFB.CREATE_DT , + * CFB.UPDATE_USER_ID , + * CFB.UPDATE_DT + * FROM CNS_FAQ_BAS CFB + * WHERE CFB.DEL_YN = 'N' + * AND CFB.EXPSR_YN = 'Y' + * AND CFB.CATEGORY = #{category} + * AND CFB.TITLE = #{word} + * ORDER BY CFB.CREATE_DT DESC + */ List r = query .select(Projections.bean( FaqListModel.class, @@ -57,6 +87,11 @@ public class CnsFaqQueryRepository { return r; } + /** + * 일련번호[sno]로 상세정보를 조회하는 SQL 기능. + * @param sno + * @return + */ public FaqListModel getFaqDetail(int sno) { QCnsFaqBas bas = QCnsFaqBas.cnsFaqBas; @@ -66,6 +101,27 @@ public class CnsFaqQueryRepository { builder.and(bas.expsrYn.eq("Y")); builder.and(bas.delYn.eq("N")); + /** + * 일련번호[faqSno] 조건, + * 표출여부[expsrYn]가 'Y' 인지 조건, + * 삭제여부[delYn]가 'N' 인지 조건으로 조회하는 SQL 입니다. + * + * SELECT + * CFB.FAQ_SNO , + * CFB.CATEGORY , + * CFB.TITLE , + * CFB.CONTENT , + * CFB.VIEW_CNT , + * CFB.EXPSR_YN , + * CFB.CREATE_USER_ID , + * CFB.CREATE_DT , + * CFB.UPDATE_USER_ID , + * CFB.UPDATE_DT + * FROM CNS_FAQ_BAS CFB + * WHERE CFB.FAQ_SNO = #{sno} + * AND CFB.EXPSR_YN = 'Y' + * AND CFB.DEL_YN = 'N' + */ FaqListModel r = query .select(Projections.bean( FaqListModel.class,