|
|
@@ -5,11 +5,14 @@ import com.gagaframework.web.security.GagaPasswordEncoder;
|
|
|
import com.style24.core.biz.service.TscCustomerService;
|
|
|
import com.style24.core.support.env.TscConstants;
|
|
|
import com.style24.core.support.session.TscSession;
|
|
|
+import com.style24.front.support.security.TsfLoginDetails;
|
|
|
import com.style24.persistence.domain.Coupon;
|
|
|
import com.style24.persistence.domain.Customer;
|
|
|
+import com.style24.persistence.domain.Login;
|
|
|
import com.style24.persistence.domain.Point;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.style24.front.biz.dao.TsfCustomerDao;
|
|
|
@@ -17,6 +20,11 @@ import com.style24.front.biz.dao.TsfCustomerDao;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpSession;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* 고객(회원) Service
|
|
|
*
|
|
|
@@ -36,6 +44,10 @@ public class TsfCustomerService {
|
|
|
@Autowired
|
|
|
private GagaPasswordEncoder passwordEncoder;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TsfLoginService loginService;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 고객아이디 찾기
|
|
|
*
|
|
|
@@ -45,9 +57,9 @@ public class TsfCustomerService {
|
|
|
* @since 2021. 02. 08
|
|
|
*/
|
|
|
public Customer getCustomerFindId(Customer customer) {
|
|
|
+ TscSession.setAttribute("maskingYn","Y");
|
|
|
customer.setSiteCd(TscConstants.Site.STYLE24.value());
|
|
|
customer.encryptData(); // 데이터 암호하
|
|
|
- TscSession.setAttribute("maskingYn","Y");
|
|
|
return coreCustomerService.getCustomerInfo(customer);
|
|
|
}
|
|
|
|
|
|
@@ -118,11 +130,11 @@ public class TsfCustomerService {
|
|
|
* @since 2021. 02. 15
|
|
|
*/
|
|
|
public Customer getCustomerFindByCi(String ci) {
|
|
|
+ TscSession.setAttribute("maskingYn","Y");
|
|
|
Customer customer = new Customer();
|
|
|
customer.setCi(ci);
|
|
|
customer.setSiteCd(TscConstants.Site.STYLE24.value());
|
|
|
customer.encryptData();
|
|
|
-
|
|
|
return customerDao.getCustomerInfo(customer);
|
|
|
}
|
|
|
|
|
|
@@ -134,12 +146,12 @@ public class TsfCustomerService {
|
|
|
* @since 2021. 02. 15
|
|
|
*/
|
|
|
public Customer getCustomerFindByCellPhnno(String cellPhnno) {
|
|
|
+ TscSession.setAttribute("maskingYn","Y");
|
|
|
Customer customer = new Customer();
|
|
|
customer.setCellPhnno(cellPhnno);
|
|
|
customer.setHypenCellPhone(); // 010-0000-0000
|
|
|
customer.setSiteCd(TscConstants.Site.STYLE24.value());
|
|
|
customer.encryptData();
|
|
|
-
|
|
|
return customerDao.getCustomerInfo(customer);
|
|
|
}
|
|
|
|
|
|
@@ -195,16 +207,28 @@ public class TsfCustomerService {
|
|
|
* @since 2021. 02. 19
|
|
|
*/
|
|
|
@Transactional("shopTxnManager")
|
|
|
- public void saveJoinCustomer(Customer customer) {
|
|
|
- boolean isSnsJoin = isSnsJoin(customer);
|
|
|
- if (isSnsJoin) {
|
|
|
+ public boolean saveJoinCustomer(Customer customer) {
|
|
|
+ boolean isJoin = true;
|
|
|
+ // 1. validation
|
|
|
+ customer.encryptData();
|
|
|
+ if (StringUtils.isNotBlank(customer.getSnsId())) {
|
|
|
customer.setEncodedPasswd(" ");
|
|
|
+ customer.setCustId(customer.getSnsType()+"_"+customer.getSnsId());
|
|
|
} else {
|
|
|
customer.setEncodedPasswd(passwordEncoder.encode(customer.getPasswd()));
|
|
|
}
|
|
|
- customer.encryptData();
|
|
|
- customerDao.createCustomer(customer);
|
|
|
- saveJoinPostProcessing(customer);
|
|
|
+ customer.setCustStat(TscConstants.CustStat.ACTIVE.value());
|
|
|
+ customer.setCustGb(TscConstants.CustGb.NORMAL.value());
|
|
|
+ customer.setCustGrade(TscConstants.CustGrade.WELCOME.value());
|
|
|
+ int custCnt = customerDao.createCustomer(customer);
|
|
|
+
|
|
|
+ if (custCnt > 0) {
|
|
|
+ saveJoinPostProcessing(customer);
|
|
|
+ } else {
|
|
|
+ isJoin = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return isJoin;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -224,27 +248,48 @@ public class TsfCustomerService {
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * SNS 가입인지 확인
|
|
|
- * @param customer - 일반가입, SNS 가입
|
|
|
- * @return boolean - sns 가입이면 true 아니면 false
|
|
|
+ * 로그인 처리
|
|
|
+ * @param custNo - 고객번호
|
|
|
+ * @param request - 요청
|
|
|
* @author jsshin
|
|
|
- * @since 2021. 02. 19
|
|
|
+ * @since 2021. 02. 18
|
|
|
*/
|
|
|
- public boolean isSnsJoin(Customer customer) {
|
|
|
- boolean result = false;
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(customer.getKkJoinId())) {
|
|
|
- result = true;
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(customer.getNvJoinId())) {
|
|
|
- result = true;
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(customer.getYsJoinId())) {
|
|
|
- result = true;
|
|
|
+ public void getLogin(String custId, HttpServletRequest request) {
|
|
|
+ if (StringUtils.isBlank(custId)) {
|
|
|
+ throw new IllegalStateException("고객 아이디가 없습니다. 로그인 다시 해보시기 바랍니다.");
|
|
|
}
|
|
|
|
|
|
- return result;
|
|
|
+ Login loginParam = new Login();
|
|
|
+ loginParam.setCustId(custId);
|
|
|
+ Login loginInfo = loginService.getLoginCheckInfo(loginParam);
|
|
|
+
|
|
|
+ // 권한 설정
|
|
|
+ List<SimpleGrantedAuthority> authorities = new ArrayList<>();
|
|
|
+ authorities.add(new SimpleGrantedAuthority(loginInfo.getCustGb()));
|
|
|
+
|
|
|
+ TsfLoginDetails loginDetails = new TsfLoginDetails(loginInfo, authorities);
|
|
|
+
|
|
|
+ // 최종로그인일시 Update
|
|
|
+ loginService.updateLastLoginDate(loginInfo.getCustNo());
|
|
|
+
|
|
|
+ // 로그인이력 생성
|
|
|
+ loginService.createLoginHistory(loginInfo.getCustNo());
|
|
|
+
|
|
|
+ // 세션 생성
|
|
|
+ this.createSession(request, loginDetails);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Session 생성
|
|
|
+ * @param request - HttpServletRequest
|
|
|
+ * @param loginDetails - 로그인 상세 정보
|
|
|
+ */
|
|
|
+ private void createSession(HttpServletRequest request, TsfLoginDetails loginDetails) {
|
|
|
+ HttpSession session = request.getSession(true);
|
|
|
+ session.setMaxInactiveInterval(1800);
|
|
|
+ session.setAttribute("session", loginDetails);
|
|
|
}
|
|
|
|
|
|
}
|