diff --git a/src/main/java/com/loafle/overflow/central/module/member/service/CentralMemberService.java b/src/main/java/com/loafle/overflow/central/module/member/service/CentralMemberService.java index a294e84..bfe2ea9 100644 --- a/src/main/java/com/loafle/overflow/central/module/member/service/CentralMemberService.java +++ b/src/main/java/com/loafle/overflow/central/module/member/service/CentralMemberService.java @@ -5,6 +5,7 @@ import com.loafle.overflow.central.module.member.dao.MemberDAO; import com.loafle.overflow.core.exception.OverflowException; import com.loafle.overflow.model.apikey.ApiKey; +import com.loafle.overflow.model.domain.Domain; import com.loafle.overflow.model.domain.DomainMember; import com.loafle.overflow.model.email.EmailAuth; import com.loafle.overflow.model.member.Member; @@ -13,6 +14,7 @@ import com.loafle.overflow.model.meta.MetaMemberStatus; import com.loafle.overflow.service.central.apikey.ApiKeyService; import com.loafle.overflow.service.central.domain.DomainMemberService; +import com.loafle.overflow.service.central.domain.DomainService; import com.loafle.overflow.service.central.email.EmailAuthService; import com.loafle.overflow.service.central.member.MemberService; import com.loafle.overflow.service.central.probe.ProbeService; @@ -45,6 +47,9 @@ public class CentralMemberService implements MemberService { @Autowired private DomainMemberService domainMemberService; + @Autowired + private DomainService domainService; + @Autowired private ProbeService probeService; @@ -107,6 +112,8 @@ public class CentralMemberService implements MemberService { Member resMember = this.memberDAO.save(member); + this.registDomainMember(member); + try { this.emailAuthService.sendEmailByMember(resMember); } catch (Exception e) { @@ -117,6 +124,34 @@ public class CentralMemberService implements MemberService { return resMember; } + private void registDomainMember(Member member) throws OverflowException { + if (null == member) { + throw new OverflowException("registDomainMember()", new Throwable()); + } + + String domainName = ""; + + if (null == member.getCompanyName() || member.getCompanyName().equals("")) { + String[] emails = member.getEmail().split("@"); + int idx = emails[1].indexOf("."); + domainName = emails[1].substring(0, idx ) + "`s domain"; + } else { + domainName = member.getCompanyName() + "`s Domain" ; + } + + DomainMember domainMember = new DomainMember(); + Domain domain = new Domain(); + + domain.setName(domainName); + this.domainService.regist(domain); + + domainMember.setDomain(domain); + domainMember.setMember(member); + + this.domainMemberService.regist(domainMember); + } + + public Member sendEmailForPassword(String email) throws OverflowException { Member member = this.memberDAO.findByEmail(email); diff --git a/src/test/java/com/loafle/overflow/central/module/member/service/MemberServiceTest.java b/src/test/java/com/loafle/overflow/central/module/member/service/MemberServiceTest.java index 183c9ad..2184bfc 100644 --- a/src/test/java/com/loafle/overflow/central/module/member/service/MemberServiceTest.java +++ b/src/test/java/com/loafle/overflow/central/module/member/service/MemberServiceTest.java @@ -27,20 +27,21 @@ MemberTotpService totpService; -// @Test -// public void regist() throws Exception { + @Test + public void regist() throws Exception { // Member m = new Member(); -// m.setPw("!@#$qwer1234"); -// m.setStatus(new MetaMemberStatus((short)1)); +// m.setPw("!@#$Qwer1234"); +//// m.setStatus(new MetaMemberStatus((short)1)); +// m.setMetaMemberStatus(MetaMemberStatus.Enum.NOAUTH.to()); // m.setCreateDate(new Date()); -// m.setCompanyName("Loafle"); +//// m.setCompanyName("Loafle"); // m.setEmail("geekhot@hotmail.co.kr"); // m.setName("administrator"); // m.setPhone("00000000"); // -// Member res = this.memberService.signup(m,"!@#$qwer1234"); +// Member res = this.memberService.signup(m,"!@#$Qwer1234"); // Assert.assertNotNull(res); -// } + } @Test public void signin() throws Exception {