Browse Source

cns/faq 패키지 주석추가

pull/18/head
lkd9125(이경도) 9 months ago
parent
commit
0c44929d81
  1. 119
      pav-server/src/main/java/com/palnet/biz/api/cns/faq/controller/CnsFaqController.java
  2. 26
      pav-server/src/main/java/com/palnet/biz/api/cns/faq/service/CnsFaqService.java
  3. 56
      pav-server/src/main/java/com/palnet/biz/jpa/repository/cns/CnsFaqQueryRepository.java

119
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; private final CnsFaqService service;
/*FAQ 목록 조회*/ /**
* FAQ 목록 조회하는 기능,
* FaqListRQModel 값에 있는 조건값으로 조회함.
* @param model
* @return
*/
@Tag(name = "FAQ API", description = "FAQ 관련 API") @Tag(name = "FAQ API", description = "FAQ 관련 API")
@GetMapping @GetMapping
public ResponseEntity<? extends BasicResponse> getFaqList(FaqListRQModel model) { public ResponseEntity<? extends BasicResponse> getFaqList(FaqListRQModel model) {
List<FaqListModel> result = null; List<FaqListModel> result = null;
try { try {
result = service.getFaqList(model); result = service.getFaqList(model); // FaQ 항목들 조회하는 기능
} catch (CustomException e) { } catch (CustomException e) {
/**
* try{
...
}
* try 영역 코드들중 문제가 생기면 오는 .
* CustomException은 개발자가 "의도적으로" 예외처리,
* log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
*/
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
log.error("IGNORE : ", e); log.error("IGNORE : ", e);
resultMap.put("result", false); resultMap.put("result", false);
@ -46,6 +59,13 @@ public class CnsFaqController {
resultMap.put("errorMessage", e.getMessage()); resultMap.put("errorMessage", e.getMessage());
return ResponseEntity.ok().body(new SuccessResponse<>(resultMap)); return ResponseEntity.ok().body(new SuccessResponse<>(resultMap));
} catch (Exception e) { } catch (Exception e) {
/**
* try{
...
}
* try 영역 코드들중 문제가 생기면 오는 .
* log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
*/
log.error("IGNORE : ", e); log.error("IGNORE : ", e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(new ErrorResponse("Server Error", "-1")); .body(new ErrorResponse("Server Error", "-1"));
@ -54,14 +74,27 @@ public class CnsFaqController {
return ResponseEntity.ok().body(new SuccessResponse<>(result)); return ResponseEntity.ok().body(new SuccessResponse<>(result));
} }
/*FAQ 상세 조회*/ /**
* FAQ 상세 조회하는 기능,
* 일련번호[sno] 조회함.
* @param sno
* @return
*/
@Tag(name = "FAQ API", description = "FAQ 관련 API") @Tag(name = "FAQ API", description = "FAQ 관련 API")
@GetMapping("/{sno}") @GetMapping("/{sno}")
public ResponseEntity<? extends BasicResponse> getFaqDetail(@PathVariable("sno") int sno) { public ResponseEntity<? extends BasicResponse> getFaqDetail(@PathVariable("sno") int sno) {
FaqListModel result = null; FaqListModel result = null;
try { try {
result = service.getFaqDetail(sno); result = service.getFaqDetail(sno); // 일련번호[sno]로 상세정보를 조회하는 기능
} catch (CustomException e) { } catch (CustomException e) {
/**
* try{
...
}
* try 영역 코드들중 문제가 생기면 오는 .
* CustomException은 개발자가 "의도적으로" 예외처리,
* log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
*/
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
log.error("IGNORE : ", e); log.error("IGNORE : ", e);
resultMap.put("result", false); resultMap.put("result", false);
@ -69,6 +102,13 @@ public class CnsFaqController {
resultMap.put("errorMessage", e.getMessage()); resultMap.put("errorMessage", e.getMessage());
return ResponseEntity.ok().body(new SuccessResponse<>(resultMap)); return ResponseEntity.ok().body(new SuccessResponse<>(resultMap));
} catch (Exception e) { } catch (Exception e) {
/**
* try{
...
}
* try 영역 코드들중 문제가 생기면 오는 .
* log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
*/
log.error("IGNORE : ", e); log.error("IGNORE : ", e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(new ErrorResponse("Server Error", "-1")); .body(new ErrorResponse("Server Error", "-1"));
@ -77,14 +117,27 @@ public class CnsFaqController {
return ResponseEntity.ok().body(new SuccessResponse<>(result)); return ResponseEntity.ok().body(new SuccessResponse<>(result));
} }
/*FAQ 작성*/ /**
* FAQ 작성하는 기능,
* FaqListModel모델에 있는 값으로 작성하는 기능.
* @param model
* @return
*/
@Tag(name = "FAQ API", description = "FAQ 관련 API") @Tag(name = "FAQ API", description = "FAQ 관련 API")
@PostMapping @PostMapping
public ResponseEntity<? extends BasicResponse> insertFaq(@RequestBody FaqListModel model) { public ResponseEntity<? extends BasicResponse> insertFaq(@RequestBody FaqListModel model) {
boolean result = false; boolean result = false;
try { try {
result = service.insertFaq(model); result = service.insertFaq(model); // FaQ 추가하는 기능
} catch (CustomException e) { } catch (CustomException e) {
/**
* try{
...
}
* try 영역 코드들중 문제가 생기면 오는 .
* CustomException은 개발자가 "의도적으로" 예외처리,
* log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
*/
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
log.error("IGNORE : ", e); log.error("IGNORE : ", e);
resultMap.put("result", false); resultMap.put("result", false);
@ -92,6 +145,13 @@ public class CnsFaqController {
resultMap.put("errorMessage", e.getMessage()); resultMap.put("errorMessage", e.getMessage());
return ResponseEntity.ok().body(new SuccessResponse<>(resultMap)); return ResponseEntity.ok().body(new SuccessResponse<>(resultMap));
} catch (Exception e) { } catch (Exception e) {
/**
* try{
...
}
* try 영역 코드들중 문제가 생기면 오는 .
* log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
*/
log.error("IGNORE : ", e); log.error("IGNORE : ", e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(new ErrorResponse("Server Error", "-1")); .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") @Tag(name = "FAQ API", description = "FAQ 관련 API")
@PutMapping @PutMapping
public ResponseEntity<? extends BasicResponse> updateFaq(@RequestBody FaqListModel model) { public ResponseEntity<? extends BasicResponse> updateFaq(@RequestBody FaqListModel model) {
boolean result = false; boolean result = false;
try { try {
result = service.updateFaq(model); result = service.updateFaq(model); // FaQ 수정하는 기능
} catch (CustomException e) { } catch (CustomException e) {
/**
* try{
...
}
* try 영역 코드들중 문제가 생기면 오는 .
* CustomException은 개발자가 "의도적으로" 예외처리,
* log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
*/
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
log.error("IGNORE : ", e); log.error("IGNORE : ", e);
resultMap.put("result", false); resultMap.put("result", false);
@ -117,6 +190,13 @@ public class CnsFaqController {
resultMap.put("errorMessage", e.getMessage()); resultMap.put("errorMessage", e.getMessage());
return ResponseEntity.ok().body(new SuccessResponse<>(resultMap)); return ResponseEntity.ok().body(new SuccessResponse<>(resultMap));
} catch (Exception e) { } catch (Exception e) {
/**
* try{
...
}
* try 영역 코드들중 문제가 생기면 오는 .
* log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
*/
log.error("IGNORE : ", e); log.error("IGNORE : ", e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(new ErrorResponse("Server Error", "-1")); .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") @Tag(name = "FAQ API", description = "FAQ 관련 API")
@DeleteMapping("/{sno}") @DeleteMapping("/{sno}")
public ResponseEntity<? extends BasicResponse> deleteFaq(@PathVariable("sno") int sno) { public ResponseEntity<? extends BasicResponse> deleteFaq(@PathVariable("sno") int sno) {
// TODO 성공/실패 상태값 전송 // TODO 성공/실패 상태값 전송
try { try {
service.deleteFaq(sno); service.deleteFaq(sno); // 일련번호[sno]로 삭제하는 기능
} catch (CustomException e) { } catch (CustomException e) {
/**
* try{
...
}
* try 영역 코드들중 문제가 생기면 오는 .
* log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
*/
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
log.error("IGNORE : ", e); log.error("IGNORE : ", e);
resultMap.put("result", false); resultMap.put("result", false);
@ -141,6 +233,13 @@ public class CnsFaqController {
resultMap.put("errorMessage", e.getMessage()); resultMap.put("errorMessage", e.getMessage());
return ResponseEntity.ok().body(new SuccessResponse<>(resultMap)); return ResponseEntity.ok().body(new SuccessResponse<>(resultMap));
} catch (Exception e) { } catch (Exception e) {
/**
* try{
...
}
* try 영역 코드들중 문제가 생기면 오는 .
* log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌
*/
log.error("IGNORE : ", e); log.error("IGNORE : ", e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(new ErrorResponse("Server Error", "-1")); .body(new ErrorResponse("Server Error", "-1"));

26
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 CnsFaqBasRepository cnsFaqBasRepository;
private final JwtTokenUtil jwtTokenUtil; private final JwtTokenUtil jwtTokenUtil;
/**
* FaQ 항목들 조회하는 기능.
* @param model
* @return
*/
public List<FaqListModel> getFaqList(FaqListRQModel model){ public List<FaqListModel> getFaqList(FaqListRQModel model){
List<FaqListModel> result = query.getFaqList(model.getCategory(), model.getWord()); List<FaqListModel> result = query.getFaqList(model.getCategory(), model.getWord());
@ -34,7 +39,12 @@ public class CnsFaqService {
return result; return result;
} }
/**
* 일련번호[sno] 상세정보를 조회하는 기능.
* @param sno
* @return
*/
public FaqListModel getFaqDetail(int sno){ public FaqListModel getFaqDetail(int sno){
cnsFaqBasRepository.updateViewCnt(sno); cnsFaqBasRepository.updateViewCnt(sno);
FaqListModel result = query.getFaqDetail(sno); FaqListModel result = query.getFaqDetail(sno);
@ -42,6 +52,11 @@ public class CnsFaqService {
return result; return result;
} }
/**
* FaQ 추가하는 기능.
* @param model
* @return
*/
@Transactional @Transactional
public boolean insertFaq(FaqListModel model){ public boolean insertFaq(FaqListModel model){
String userId = jwtTokenUtil.getUserIdByToken(); String userId = jwtTokenUtil.getUserIdByToken();
@ -69,6 +84,11 @@ public class CnsFaqService {
} }
} }
/**
* FaQ 수정하는 기능.
* @param model
* @return
*/
@Transactional @Transactional
public boolean updateFaq(FaqListModel model) { public boolean updateFaq(FaqListModel model) {
String userId = jwtTokenUtil.getUserIdByToken(); String userId = jwtTokenUtil.getUserIdByToken();
@ -92,6 +112,10 @@ public class CnsFaqService {
} }
} }
/**
* 일련번호[sno] 삭제하는 기능.
* @param sno
*/
public void deleteFaq(int sno) { public void deleteFaq(int sno) {
// TODO 반환값이 실행한 갯수인지 확인 필요 // TODO 반환값이 실행한 갯수인지 확인 필요

56
pav-server/src/main/java/com/palnet/biz/jpa/repository/cns/CnsFaqQueryRepository.java

@ -18,6 +18,12 @@ public class CnsFaqQueryRepository {
private final JPAQueryFactory query; private final JPAQueryFactory query;
/**
* 조건값으로 FaQ리스트를 조회하는 SQL기능.
* @param category
* @param word
* @return
*/
public List<FaqListModel> getFaqList(String category, String word) { public List<FaqListModel> getFaqList(String category, String word) {
QCnsFaqBas bas = QCnsFaqBas.cnsFaqBas; QCnsFaqBas bas = QCnsFaqBas.cnsFaqBas;
@ -34,6 +40,30 @@ public class CnsFaqQueryRepository {
builder.and(bas.title.contains(word)); 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<FaqListModel> r = query List<FaqListModel> r = query
.select(Projections.bean( .select(Projections.bean(
FaqListModel.class, FaqListModel.class,
@ -57,6 +87,11 @@ public class CnsFaqQueryRepository {
return r; return r;
} }
/**
* 일련번호[sno] 상세정보를 조회하는 SQL 기능.
* @param sno
* @return
*/
public FaqListModel getFaqDetail(int sno) { public FaqListModel getFaqDetail(int sno) {
QCnsFaqBas bas = QCnsFaqBas.cnsFaqBas; QCnsFaqBas bas = QCnsFaqBas.cnsFaqBas;
@ -66,6 +101,27 @@ public class CnsFaqQueryRepository {
builder.and(bas.expsrYn.eq("Y")); builder.and(bas.expsrYn.eq("Y"));
builder.and(bas.delYn.eq("N")); 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 FaqListModel r = query
.select(Projections.bean( .select(Projections.bean(
FaqListModel.class, FaqListModel.class,

Loading…
Cancel
Save