Browse Source

그룹명 수정시 중복네임 막기

feature/auth
junh_eee(이준희) 2 years ago
parent
commit
ae50d78e7d
  1. 20
      src/main/java/com/palnet/biz/api/bas/group/controller/BasGroupController.java
  2. 6
      src/main/java/com/palnet/biz/api/bas/group/service/BasGroupService.java

20
src/main/java/com/palnet/biz/api/bas/group/controller/BasGroupController.java

@ -194,9 +194,10 @@ public class BasGroupController {
/** /**
* 그룹 수정 * 그룹 수정
* @return * @return
* @throws Exception
*/ */
@PutMapping(value = "/update") @PutMapping(value = "/update")
public ResponseEntity<? extends BasicResponse> update(@RequestBody BasGroupModel rq) { public ResponseEntity<? extends BasicResponse> update(@RequestBody BasGroupModel rq) throws Exception {
Map<String , Object> resultMap = new HashMap<String,Object>(); Map<String , Object> resultMap = new HashMap<String,Object>();
try { try {
@ -204,11 +205,18 @@ public class BasGroupController {
resultMap.put("result", result); resultMap.put("result", result);
} catch (Exception e) { // } catch (Exception e) {
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"));
//
// }
} catch (CustomException e) {
log.error("IGNORE : {}", e);
resultMap.put("result", false);
resultMap.put("errorCode", e.getErrorCode());
resultMap.put("errorMessage", e.getMessage());
return ResponseEntity.ok().body(new SuccessResponse<Map>(resultMap));
} }
return ResponseEntity.ok().body(new SuccessResponse<Map>(resultMap)); return ResponseEntity.ok().body(new SuccessResponse<Map>(resultMap));

6
src/main/java/com/palnet/biz/api/bas/group/service/BasGroupService.java

@ -175,6 +175,12 @@ public class BasGroupService {
public boolean update(BasGroupModel rq) throws Exception{ public boolean update(BasGroupModel rq) throws Exception{
Optional<PtyGroupBas> optional = ptyGroupBasRepository.findById(rq.getGroupId()); Optional<PtyGroupBas> optional = ptyGroupBasRepository.findById(rq.getGroupId());
List<PtyGroupBas> groupNm = ptyGroupBasRepository.findByGroupNm(rq.getGroupNm());
for(PtyGroupBas name : groupNm) {
if(rq.getGroupNm().equals(name.getGroupNm())) {
throw new CustomException(ErrorCode.DATA_DUPLICATE);
}
}
if (!optional.isPresent()) { if (!optional.isPresent()) {
throw new CustomException(ErrorCode.DATA_NOTFIND); throw new CustomException(ErrorCode.DATA_NOTFIND);

Loading…
Cancel
Save