diff --git a/pav-server/src/main/java/com/palnet/biz/api/bas/group/controller/BasGroupController.java b/pav-server/src/main/java/com/palnet/biz/api/bas/group/controller/BasGroupController.java index 076ffb31..18b7907e 100644 --- a/pav-server/src/main/java/com/palnet/biz/api/bas/group/controller/BasGroupController.java +++ b/pav-server/src/main/java/com/palnet/biz/api/bas/group/controller/BasGroupController.java @@ -44,6 +44,10 @@ public class BasGroupController { @Autowired private final BasGroupService service; + /** + * 그룹코드 생성 + * @return + */ @GetMapping(value = "/createid") @ApiOperation(value = "그룹코드 생성") @Tag(name = "그룹 컨트롤러", description = "그룹 관련 API") @@ -51,11 +55,18 @@ public class BasGroupController { Map resultMap = new HashMap(); try { - String result = service.createid(); + String result = service.createid(); // 그룹코드를 생성하는 기능 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")); @@ -66,7 +77,8 @@ public class BasGroupController { } /** - * 나의 그룹 목록 조회 + * 내가 만든 그룹 목록조회하는 기능. + * 고객고유번호[cstmrSno]로 내가 만든 그룹을 조회함. * @param rq * @return */ @@ -77,19 +89,27 @@ public class BasGroupController { public ResponseEntity mylist(Integer cstmrSno) { List result = null; - log.debug("Param : " + cstmrSno); - - //입력값 검증 + log.debug("Param : {}", cstmrSno); + + // 고객고유번호[cstmrSno]값 입력값 검증처리 if(StringUtils.isEmpty(cstmrSno)) { - return ResponseEntity.status(HttpStatus.OK) + // 검증통과하지 못할 시 서버에서 "의도적인" 에러 반환 + return ResponseEntity.status(HttpStatus.OK) // "의도적인" 에러 반환코드 .body(new ErrorResponse(RSErrorCode.ER_PARAM)); } try { - result = service.mylist(cstmrSno); + result = service.mylist(cstmrSno); // 나의 그룹 목록조회하는 기능. } 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")); @@ -100,7 +120,8 @@ public class BasGroupController { } /** - * 나의 그룹 - 참여 그룹 목록 조회 + * 나의 그룹 - 참여 그룹 목록 조회하는 기능, + * 고객고유번호[cstmrSno]로 나의 그룹을 조회함. * @param rq * @return */ @@ -112,17 +133,25 @@ public class BasGroupController { List result = null; - //입력값 검증 + // 고객고유번호[cstmrSno]값 입력값 검증처리 if(StringUtils.isEmpty(cstmrSno)) { - return ResponseEntity.status(HttpStatus.OK) + // 검증통과하지 못할 시 서버에서 "의도적인" 에러 반환 + return ResponseEntity.status(HttpStatus.OK) // "의도적인" 에러 반환코드 .body(new ErrorResponse(RSErrorCode.ER_PARAM)); } try { - result = service.joinList(cstmrSno); + result = service.joinList(cstmrSno); // 나의 그룹 - 참여 그룹 목록을 조회하는 기능. } 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")); @@ -133,7 +162,7 @@ public class BasGroupController { } /** - * 그룹 목록 조회 + * 그룹 목록 조회하는 기능 * @param rq * @return */ @@ -145,17 +174,25 @@ public class BasGroupController { List result = null; - //입력값 검증 + // 고객고유번호[cstmrSno]값 입력값 검증처리 if(StringUtils.isEmpty(cstmrSno)) { - return ResponseEntity.status(HttpStatus.OK) + // 검증통과하지 못할 시 서버에서 "의도적인" 에러 반환 + return ResponseEntity.status(HttpStatus.OK) // "의도적인" 에러 반환코드 .body(new ErrorResponse(RSErrorCode.ER_PARAM)); } try { - result = service.groupList(cstmrSno); + result = service.groupList(cstmrSno); // 그룹 목록조회하는 기능 } 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")); @@ -166,7 +203,8 @@ public class BasGroupController { } /** - * 전체 그룹 목록 조회 + * 전체 그룹 목록 조회하는 기능, + * BasGroupRqModel 모델 값에 따라 조회하는 기능. * @param rq * @return */ @@ -177,10 +215,17 @@ public class BasGroupController { List result = null; 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")); @@ -191,7 +236,8 @@ public class BasGroupController { } /** - * 그룹 상세 조회 + * 그룹 상세 조회하는 기능, + * 그룹아이디[groupId]로 조회함. * @param id * @return */ @@ -203,9 +249,16 @@ public class BasGroupController { BasGroupModel result = null; try { - result = service.detail(id); + result = service.detail(id); // 그룹아이디[groupId]로 상세 조회하는 기능 } 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")); @@ -217,7 +270,8 @@ public class BasGroupController { /** - * 그룹 생성 + * 그룹 생성하는 기능, + * BasGroupModel 모델에 입력받은 값으로 그룹 생성. * @return * @throws Exception */ @@ -228,11 +282,19 @@ public class BasGroupController { Map resultMap = new HashMap(); try { - boolean result = service.create(rq); + boolean result = service.create(rq); // 그룹 생성하는 기능 resultMap.put("result", result); } catch (CustomException e) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * CustomException은 개발자가 "의도적으로" 낸 예외처리, + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ log.error("IGNORE : {}", e); resultMap.put("result", false); resultMap.put("errorCode", e.getErrorCode()); @@ -244,7 +306,8 @@ public class BasGroupController { } /** - * 그룹 수정 + * 그룹 수정하는 기능, + * BasGroupModel 모델에 입력받은 값으로 그룹 수정. * @return * @throws Exception */ @@ -255,7 +318,7 @@ public class BasGroupController { Map resultMap = new HashMap(); try { - boolean result = service.update(rq); + boolean result = service.update(rq); // 그룹 수정하는 기능 resultMap.put("result", result); @@ -266,6 +329,14 @@ public class BasGroupController { // // } } catch (CustomException e) { + /** + * try{ + ... + } + * try 영역 안 코드들중 문제가 생기면 오는 곳. + * CustomException은 개발자가 "의도적으로" 낸 예외처리, + * log.error 로그로 원인 파악과 함께 API를 호출한 곳에 서버에러 내려줌 + */ log.error("IGNORE : {}", e); resultMap.put("result", false); resultMap.put("errorCode", e.getErrorCode()); @@ -277,7 +348,8 @@ public class BasGroupController { } /** - * 그룹 삭제 + * 그룹 삭제하는 기능, + * 그룹아이디[groupId]로 삭제함. * @param id * @return */ @@ -289,11 +361,18 @@ public class BasGroupController { Map resultMap = new HashMap(); try { - boolean result = service.delete(id); + boolean result = service.delete(id); // 그룹아이디[groupId]로 삭제하는 기능 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/group/service/BasGroupService.java b/pav-server/src/main/java/com/palnet/biz/api/bas/group/service/BasGroupService.java index 011ff78d..c01c9022 100644 --- a/pav-server/src/main/java/com/palnet/biz/api/bas/group/service/BasGroupService.java +++ b/pav-server/src/main/java/com/palnet/biz/api/bas/group/service/BasGroupService.java @@ -42,7 +42,10 @@ public class BasGroupService { @Autowired private JwtTokenUtil jwtTokenUtil; - + /** + * 그룹코드를 생성하는 기능. + * @return + */ public String createid() { String groupId = ""; @@ -59,20 +62,19 @@ public class BasGroupService { } /** - * 나의 그룹 목록 + * 내가 만든 그룹 목록조회하는 기능. * @param cstmrSno * @return */ - public List mylist(int cstmrSno){ - + public List mylist(int cstmrSno){ - List resultList = query.mylist(cstmrSno); + List resultList = query.mylist(cstmrSno); // 데이터베이스에서 cstmrSno에 맞춰 내가 만든 그룹을 조회하는 기능. return resultList; } /** - * 그룹 목록 + * 그룹 목록조회하는 기능. * @param cstmrSno * @return */ @@ -81,7 +83,7 @@ public class BasGroupService { String appAuth = jwtTokenUtil.getUserAuthByToken(); List resultList = new ArrayList<>(); if("SUPER".equals(appAuth)||"ADMIN".equals(appAuth)) { - resultList = query.groupAdminList(cstmrSno); + resultList = query.groupAdminList(cstmrSno); // Super, Admin권한으로 그룹을 조회하는 SQL 기능. } else { resultList = query.groupUserList(cstmrSno); } @@ -90,7 +92,7 @@ public class BasGroupService { } /** - * 나의 그룹 - 참여 그룹 목록 + * 나의 그룹 - 참여 그룹 목록을 조회하는 기능. * @param cstmrSno * @return */ @@ -102,20 +104,20 @@ public class BasGroupService { } /** - * 전체 그룹 목록 + * 전체 그룹 목록하는 기능. * @param rq * @return */ public List list(BasGroupRqModel rq){ - List resultList = query.list(rq); + List resultList = query.list(rq); // 전체 그룹을 조회하는 SQL기능 return resultList; } /** - * 그룹 상세 조회 + * 그룹아이디[groupId]로 상세 조회하는 기능. * @param groupId * @return * @throws Exception @@ -134,13 +136,12 @@ public class BasGroupService { BeanUtils.copyProperties(entity , model); - return model; } /** - * 그룹 생성 + * 그룹 생성하는 기능. * @param rq * @return * @throws Exception @@ -188,7 +189,7 @@ public class BasGroupService { } /** - * 그룹 수정 + * 그룹 수정하는 기능. * @param rq * @return * @throws Exception @@ -222,7 +223,7 @@ public class BasGroupService { } /** - * 그룹 삭제 + * 그룹아이디[groupId]로 삭제하는 기능. * @param groupId * @return * @throws Exception diff --git a/pav-server/src/main/java/com/palnet/biz/jpa/repository/pty/PtyGroupQueryRepository.java b/pav-server/src/main/java/com/palnet/biz/jpa/repository/pty/PtyGroupQueryRepository.java index 82e1000d..07a5c721 100644 --- a/pav-server/src/main/java/com/palnet/biz/jpa/repository/pty/PtyGroupQueryRepository.java +++ b/pav-server/src/main/java/com/palnet/biz/jpa/repository/pty/PtyGroupQueryRepository.java @@ -49,6 +49,11 @@ public class PtyGroupQueryRepository{ @Autowired private JwtTokenUtil jwtTokenUtil; + /** + * 전체 그룹을 조회하는 SQL기능. + * @param rq + * @return + */ public List list(BasGroupRqModel rq){ QPtyGroupBas bas = QPtyGroupBas.ptyGroupBas; @@ -63,6 +68,23 @@ public class PtyGroupQueryRepository{ builder.and(bas.groupNm.like(rq.getGroupNm())); } + /** + * 사용여부[useYn] 조건, + * 그룹아이디[groupId] 조건, + * 그룹이름[groupNm] 조건으로 조회하는 SQL입니다. + * + * SELECT + * PGB.GROUP_ID , + * PGB.GROUP_NM , + * PGB.GROUP_TYPE_CD , + * PGB.UPDATE_DT , + * PGB.CREATE_DT + * FROM PTY_GROUP_BAS PGB + * WHERE PGB.USE_YN = 'Y' + * AND PGB.GROUP_ID = #{groupId} -- 입력받았으면 조건 추가 + * AND PGB.GROUP_NM LIKE #{groupNm} -- 입력받았으면 조건 추가 + * ORDER BY PGB.CREATE_DT DESC + */ List result = query.select(Projections.bean(BasGroupModel.class , bas.groupId, @@ -75,12 +97,11 @@ public class PtyGroupQueryRepository{ .orderBy(bas.createDt.desc()) .fetch(); - return result; - + return result; } /** - * 내가 생성한 그룹 목록 + * 내가 생성한 그룹 목록을 조회하는 SQL 기능. * @param cstmrSno * @return */ @@ -97,6 +118,24 @@ public class PtyGroupQueryRepository{ builder.and(dtl.groupAuthCd.eq("MASTER")); + /** + * 고객고유번호[cstmrSno]값 조건, + * 그룹내애 권한[groupAuthCd]값 조건 , + * 사용여부 [useYn]값 조건으로 조회하는 SQL 입니다. + * + * SELECT + * PGB.GROUP_ID , + * PGB.GROUP_NM , + * PGB.GROUP_TYPE_CD , + * PGB.UPDATE_DT , + * PGB.CREATE_DT + * FROM PTY_GROUP_BAS PGB + * LEFT OUTER JOIN PTY_CSTMR_GROUP PCG + * ON PGB.GROUP_ID = PCG.GROUP_ID + * WHERE PGB.USE_YN = 'Y' + * AND PCG.CSTMR_SNO = #{cstmrSno} + * AND PCG.GROUP_AUTH_CD = 'MASTER' + */ List result = query.select(Projections.bean(BasGroupModel.class , bas.groupId, @@ -116,7 +155,7 @@ public class PtyGroupQueryRepository{ } /** - * 그룹 목록 + * Super, Admin권한으로 그룹을 조회하는 SQL 기능. * @param cstmrSno * @return */ @@ -127,7 +166,25 @@ public class PtyGroupQueryRepository{ BooleanBuilder builder = new BooleanBuilder(); builder.and(bas.useYn.eq("Y")); builder.and(group.groupAuthCd.eq("MASTER")); - + + /** + * 사용여부[useYn] 조건, + * 그룹권한[groupAuthCd] 조건 으로 조회하는 SQL입니다. + * + * SELECT + * PGB.GROUP_ID , + * PGB.GROUP_NM , + * PCG.GROUP_AUTH_CD , + * PGB.CREATE_DT , + * PCG.CSTMR_GROUP_SNO + * FROM PTY_GROUP_BAS PGB + * LEFT OUTER JOIN PTY_CSTMR_GROUP PCG + * ON PGB.GROUP_ID = PCG.GROUP_ID + * WHERE PGB.USE_YN = 'Y' + * AND PCG.GROUP_AUTH_CD = 'MASTER' + * GROUP BY PGB.GROUP_ID + * ORDER BY PGB.CREATE_DT DESC, PGB.GROUP_ID ASC + */ List result = query.select(Projections.bean(BasGroupJoinModel.class , bas.groupId, bas.groupNm, @@ -147,7 +204,24 @@ public class PtyGroupQueryRepository{ BooleanBuilder builder2 = new BooleanBuilder(); builder2.and(bas.useYn.eq("Y")); builder2.and(group.cstmrGroupSno.isNotNull()); - + + /** + * 사용여부[useYn] 조건, + * 그룹권한[groupAuthCd]이 NULL이 아닌 조건으로 조회하는 SQL입니다. + * + * SELECT + * PGB.GROUP_ID , + * PGB.GROUP_NM , + * PCG.CSTMR_GROUP_SNO , + * PCG.CSTMR_SNO , + * PCG.GROUP_AUTH_CD + * FROM PTY_GROUP_BAS PGB + * LEFT OUTER JOIN PTY_CSTMR_GROUP PCG + * ON PGB.GROUP_ID = PCG.GROUP_ID + * ON PCG.CSTMR_SNO = #{cstmrSno} + * WHERE PGB.USE_YN = 'Y' + * AND PCG.GROUP_AUTH_CD IS NOT NULL + */ List my = query.select(Projections.bean(BasGroupUserModel.class , bas.groupId, bas.groupNm, @@ -175,6 +249,11 @@ public class PtyGroupQueryRepository{ return result; } + /** + * User 권한으로 그룹을 조회하는 SQL 기능. + * @param cstmrSno + * @return + */ public List groupUserList(int cstmrSno){ QPtyGroupBas bas = QPtyGroupBas.ptyGroupBas; QPtyCstmrGroup group = QPtyCstmrGroup.ptyCstmrGroup; @@ -184,7 +263,26 @@ public class PtyGroupQueryRepository{ builder.and(group.joinYn.eq("Y")); builder.and(group.cstmrSno.eq(cstmrSno)); - + + /** + * 사용여부[useYn] 조건, + * 참여여부[joinYn] 조건, + * 유저고유번호[cstmrSno] 조건으로 조회하는 SQL입니다. + * + * SELECT + * PGB.GROUP_ID , + * PGB.GROUP_NM , + * PGB.CREATE_DT , + * PCG.CSTMR_GROUP_SNO + * FROM PTY_GROUP_BAS PGB + * LEFT OUTER JOIN PTY_CSTMR_GROUP PCG + * ON PGB.GROUP_ID = PCG.GROUP_ID + * WHERE PGB.USE_YN = 'Y' + * AND PCG.JOIN_YN = 'Y' + * AND PCG.CSTMR_SNO = #{cstmrSno} + * GROUP BY PGB.GROUP_ID + * ORDER BY PGB.CREATE_DT DESC, PGB.GROUP_NM ASC + */ List result = query.select(Projections.bean(BasGroupJoinModel.class , bas.groupId, bas.groupNm, @@ -203,7 +301,7 @@ public class PtyGroupQueryRepository{ } /** - * 나의 그룹 - 참여 그룹 목록 + * 나의 그룹 - 참여 그룹 목록을 조회하는 SQL기능. * @param cstmrSno * @return */ @@ -216,6 +314,31 @@ public class PtyGroupQueryRepository{ builder.and(dtl.joinYn.eq("Y")); builder.and(dtl.cstmrSno.eq(cstmrSno)); + /** + * 고객고유번호[cstmrSno] 조건, + * 참여여부[joinYn] 조건, + * 사용여부[useYn] 조건으로 참여그룹을 조회하는 SQL입니다. + * + * SELECT + * PGB.GROUP_ID , + * PGB.GROUP_NM , + * PGB.GROUP_TYPE_CD , + * PGB.TRMNL_ID , + * PCG.CSTMR_SNO , + * PCG.CSTMR_GROUP_SNO , + * PGB.UPDATE_DT , + * PGB.CREATE_DT , + * PCG.APRVL_YN , + * PCG.JOIN_DT , + * PCG.APRVL_DT , + * PCG.GROUP_AUTH_CD + * FROM PTY_GROUP_BAS PGB + * LEFT OUTER JOIN PTY_CSTMR_GROUP PCG + * ON PGB.GROUP_ID = PCG.GROUP_ID + * WHERE PGB.USE_YN = 'Y' + * AND PCG.JOIN_YN = 'Y' + * AND PCG.CSTMR_SNO = #{cstmrSno} + */ List result = query.select(Projections.bean(BasGroupJoinModel.class , bas.groupId,