From 305204dfb30fff786efe488cde652e00362d4a4e Mon Sep 17 00:00:00 2001 From: hagjoon Date: Fri, 2 Sep 2022 15:06:46 +0900 Subject: [PATCH] =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20-=20=EC=9D=B4=EB=A9=94=EC=9D=BC,?= =?UTF-8?q?=20=ED=9C=B4=EB=8C=80=ED=8F=B0=20=EB=B2=88=ED=98=B8=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cstmr/controller/AcntCstmrController.java | 19 +++++++++ .../acnt/cstmr/service/AcntCstmrService.java | 40 +++++++++++++++++++ .../pty/PtyCstmrQueryRepository.java | 22 ++++++++++ 3 files changed, 81 insertions(+) diff --git a/src/main/java/com/palnet/biz/api/acnt/cstmr/controller/AcntCstmrController.java b/src/main/java/com/palnet/biz/api/acnt/cstmr/controller/AcntCstmrController.java index 8c002a8..71d42ff 100644 --- a/src/main/java/com/palnet/biz/api/acnt/cstmr/controller/AcntCstmrController.java +++ b/src/main/java/com/palnet/biz/api/acnt/cstmr/controller/AcntCstmrController.java @@ -107,6 +107,25 @@ public class AcntCstmrController { return ResponseEntity.ok().body(new SuccessResponse<>(resultMap)); } + @PostMapping(value = "/profile/update") + public ResponseEntity myinfoupdate(@RequestBody AcntCstmrRqModel rq){ + + AcntCstmrRsModel result; + + try { + + result = service.update(rq); + + } catch (Exception e) { + log.error("IGNORE : {}", e); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(new ErrorResponse("Server Error", "-1")); + + } + + return ResponseEntity.ok().body(new SuccessResponse(result)); + } + diff --git a/src/main/java/com/palnet/biz/api/acnt/cstmr/service/AcntCstmrService.java b/src/main/java/com/palnet/biz/api/acnt/cstmr/service/AcntCstmrService.java index 3f04f7a..8a4d8b0 100644 --- a/src/main/java/com/palnet/biz/api/acnt/cstmr/service/AcntCstmrService.java +++ b/src/main/java/com/palnet/biz/api/acnt/cstmr/service/AcntCstmrService.java @@ -252,4 +252,44 @@ public class AcntCstmrService { return updateUserEntity; } + +public AcntCstmrRsModel update(AcntCstmrRqModel rq) { + + AcntCstmrRsModel rs = new AcntCstmrRsModel(); + boolean isUserEmailFind = false; + + try { + + //사전 체크. 동일한 E-mail 존재 여부 확인 + isUserEmailFind = query.findCstmrByUserEmail(rq.getEmail()); + if(isUserEmailFind) { + rs.setErrCode(-2); + return rs; + } + rq.setHpno(rq.getHpno().replaceAll("-", "")); + rq.setHpno(EncryptUtils.encrypt(rq.getHpno())); + rq.setEmail(EncryptUtils.encrypt(rq.getEmail())); + + this.savePtyCstmrEmailhpno(rq); + + + } catch (Exception e) { + log.error("IGNORE : {}", e); + rs.setErrCode(-2); //수정 필요.. + return rs; + + } + + return rs; + } + private PtyCstmrDtl savePtyCstmrEmailhpno(AcntCstmrRqModel rq) throws Exception{ + PtyCstmrDtl dtlEntity = new PtyCstmrDtl(); + + dtlEntity.setEmail(rq.getEmail()); + dtlEntity.setHpno(rq.getHpno()); + dtlEntity.setClncd(rq.getClncd()); + dtlEntity.setUpdateDt(DateUtils.nowDate()); + + return ptyCstmrDtlRepository.save(dtlEntity); + } } diff --git a/src/main/java/com/palnet/biz/jpa/repository/pty/PtyCstmrQueryRepository.java b/src/main/java/com/palnet/biz/jpa/repository/pty/PtyCstmrQueryRepository.java index a10ef77..03d43d4 100644 --- a/src/main/java/com/palnet/biz/jpa/repository/pty/PtyCstmrQueryRepository.java +++ b/src/main/java/com/palnet/biz/jpa/repository/pty/PtyCstmrQueryRepository.java @@ -256,6 +256,28 @@ public class PtyCstmrQueryRepository{ return null; } + +public boolean findCstmrByUserEmail(String Email){ + + boolean result = false; + + QPtyCstmrDtl dtl = QPtyCstmrDtl.ptyCstmrDtl; + + + BooleanBuilder builder = new BooleanBuilder(); + + builder.and(dtl.email.eq(Email)); + + PtyCstmrDtl entity = query.select(dtl) + .from(dtl) + .where(builder) + .fetchFirst(); + if(entity != null) { + result = true; + } + + return result; + }