Browse Source

Merge branch 'master' of http://gitea.palntour.com/pav/pav-server

feature/auth
노승철 2 years ago
parent
commit
a9ec4b1703
  1. 65
      src/main/java/com/palnet/biz/api/acnt/crtfyhp/controller/AcntCrtfyhpController.java
  2. 9
      src/main/java/com/palnet/biz/api/acnt/crtfyhp/model/AcntCrtfyhpRsModel.java
  3. 31
      src/main/java/com/palnet/biz/api/acnt/crtfyhp/service/AcntCrtfyhpService.java
  4. 18
      src/main/java/com/palnet/biz/jpa/repository/pty/PtyCstmrQueryRepository.java

65
src/main/java/com/palnet/biz/api/acnt/crtfyhp/controller/AcntCrtfyhpController.java

@ -8,12 +8,12 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.palnet.biz.api.acnt.crtfyhp.model.AcntCrtfyhpRsModel;
import com.palnet.biz.api.acnt.crtfyhp.service.AcntCrtfyhpService;
import com.palnet.biz.api.acnt.cstmr.controller.AcntCstmrController;
import com.palnet.biz.api.acnt.cstmr.service.AcntCstmrService;
import com.palnet.biz.api.comn.response.BasicResponse;
import com.palnet.biz.api.comn.response.ErrorResponse;
import com.palnet.biz.api.comn.response.SuccessResponse;
@ -106,21 +106,62 @@ public class AcntCrtfyhpController {
}
//아이디 찾기 시 인증번호 발송 로직
@GetMapping(value = "/find/sendForId")
public boolean certifNum(String memberName, String hpno) throws Exception{
boolean result = service.certifNum(memberName, hpno);
public ResponseEntity<? extends BasicResponse> sendForId(String memberName, String hpno) {
Map<String , Boolean> resultMap = new HashMap<String,Boolean>();
if(memberName == null || hpno == null) {
return ResponseEntity.status(HttpStatus.OK)
.body(new ErrorResponse(RSErrorCode.ER_PARAM));
}
try {
boolean result = service.certifNum(memberName, hpno);
resultMap.put("result" , result);
} 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<Map>(resultMap));
}
//아이디 찾기
@GetMapping(value = "/find/findUserId")
public ResponseEntity<? extends BasicResponse> findUserId(String memberName, String hpno) {
AcntCrtfyhpRsModel model = new AcntCrtfyhpRsModel();
if(memberName == null || hpno == null) {
return ResponseEntity.status(HttpStatus.OK)
.body(new ErrorResponse(RSErrorCode.ER_PARAM));
}
try {
model.setUserId(service.findUserId(memberName, hpno));
} 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<>(model));
}
@GetMapping(value = "/find/sendForPw")
public boolean certifNumPw(String userId, String hpno) throws Exception{
boolean result = service.certifPw(userId, hpno);
log.info("result>>>>>>>>>>>>>>>>>>>>>>>> {}",result);
return result;
}
@GetMapping(value = "/find/findUserId")
public String findUserId(String memberName, String hpno) throws Exception{
String result = service.findUserId(memberName,hpno);
log.info("result>>>>>>>>>>>>>>>>>>>>>>>> {}",result);
@PutMapping(value = "/find/updatePw")
public boolean updatePw(String userId, String hpno, String newPw) throws Exception{
boolean result = service.updatePw(userId, hpno, newPw);
log.info("result>>>>>>>>>>>>>>>>>>>>>>>> {}",result);
return result;
}
return result;
}
}

9
src/main/java/com/palnet/biz/api/acnt/crtfyhp/model/AcntCrtfyhpRsModel.java

@ -0,0 +1,9 @@
package com.palnet.biz.api.acnt.crtfyhp.model;
import lombok.Data;
@Data
public class AcntCrtfyhpRsModel {
// private int errCode;
private String userId;
}

31
src/main/java/com/palnet/biz/api/acnt/crtfyhp/service/AcntCrtfyhpService.java

@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import com.palnet.biz.api.acnt.crtfyhp.model.AcntCrtfyhpRsModel;
import com.palnet.biz.api.acnt.cstmr.model.AcntCstmrRqModel;
import com.palnet.biz.api.acnt.cstmr.model.AcntCstmrRsModel;
import com.palnet.biz.api.acnt.cstmr.model.AnctCstmrTermsModel;
@ -91,6 +92,9 @@ public class AcntCrtfyhpService {
@Autowired
private PtyCrtfyhpBasRepository ptyCrtfyhpBasRepository;
@Autowired
private PtyCstmrBasRepository ptyCstmrBasRepository;
@Autowired
private SuredataRepository sureDataRepository;
@ -212,10 +216,37 @@ public class AcntCrtfyhpService {
}
return certifNum;
}
public String findUserId(String memberName, String hpno) throws Exception{
String name = EncryptUtils.encrypt(memberName);
String phone = EncryptUtils.encrypt(hpno);
String resultFindId = cstmrQuery.findUserId(name,phone);
return resultFindId;
}
public boolean certifPw(String userId, String hpno) throws Exception{
String phone = EncryptUtils.encrypt(hpno);
PtyCstmrBas certifNum = cstmrQuery.findUserPw(userId , phone);
boolean result = false;
if(certifNum != null) {
certifySend(hpno);
result = true;
}
return result;
}
public boolean updatePw(String userId, String hpno, String newPw) throws Exception{
String phone = EncryptUtils.encrypt(hpno);
PtyCstmrBas certifNum = cstmrQuery.findUserPw(userId , phone);
boolean result = false;
if(certifNum != null) {
String encryptPw = EncryptUtils.sha256Encrypt(newPw);
certifNum.setUserPswd(encryptPw);
certifNum.setPswdUpdtDt(DateUtils.nowDate());
ptyCstmrBasRepository.save(certifNum);
result = true;
}
return result;
}
}

18
src/main/java/com/palnet/biz/jpa/repository/pty/PtyCstmrQueryRepository.java

@ -85,7 +85,23 @@ public class PtyCstmrQueryRepository{
String userId = entity.getUserId();
return userId;
}
public PtyCstmrBas findUserPw(String id , String hpno) {
QPtyCstmrBas bas = QPtyCstmrBas.ptyCstmrBas;
QPtyCstmrDtl dtl = QPtyCstmrDtl.ptyCstmrDtl;
BooleanBuilder builder = new BooleanBuilder();
builder.and(bas.cstmrStatusCd.eq("A"));
builder.and(dtl.hpno.eq(hpno));
builder.and(bas.userId.eq(id));
PtyCstmrBas entity = query.select(bas)
.from(bas)
.leftJoin(dtl)
.on(bas.cstmrSno.eq(dtl.cstmrSno))
.where(builder)
.fetchFirst();
return entity;
}
public boolean findCstmrByHpno(String hpno) {
boolean result = false;

Loading…
Cancel
Save