diff --git a/src/main/java/com/loafle/overflow/module/member/exception/JoinedEmailException.java b/src/main/java/com/loafle/overflow/module/member/exception/JoinedEmailException.java new file mode 100644 index 0000000..76162d7 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/member/exception/JoinedEmailException.java @@ -0,0 +1,16 @@ +package com.loafle.overflow.module.member.exception; + +import com.loafle.overflow.commons.exception.OverflowRuntimeException; + +/** + * Created by geek on 17. 8. 18. + */ +public class JoinedEmailException extends OverflowRuntimeException { + public JoinedEmailException() { + super(); + } + + public JoinedEmailException(String message) { + super(message); + } +} diff --git a/src/main/java/com/loafle/overflow/module/member/service/MemberService.java b/src/main/java/com/loafle/overflow/module/member/service/MemberService.java index 3324d2b..5f0ec1a 100644 --- a/src/main/java/com/loafle/overflow/module/member/service/MemberService.java +++ b/src/main/java/com/loafle/overflow/module/member/service/MemberService.java @@ -3,6 +3,7 @@ package com.loafle.overflow.module.member.service; import com.loafle.overflow.module.email.service.EmailAuthService; import com.loafle.overflow.module.member.dao.MemberDAO; import com.loafle.overflow.module.member.exception.EmailNotConfirmedException; +import com.loafle.overflow.module.member.exception.JoinedEmailException; import com.loafle.overflow.module.member.exception.SignInIdNotExistException; import com.loafle.overflow.module.member.exception.SignInPwNotMatchException; import com.loafle.overflow.module.member.model.Member; @@ -45,6 +46,12 @@ public class MemberService { public Member signup(Member member) { + Member isMember = this.memberDAO.findByEmail(member.getEmail()); + + if (null != isMember && isMember.getId() > 0) { + throw new JoinedEmailException(); + } + BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); member.setPw(passwordEncoder.encode(member.getPw())); diff --git a/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java b/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java index 6246da6..6168bab 100644 --- a/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java +++ b/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java @@ -1,11 +1,15 @@ package com.loafle.overflow.module.noauthprobe.service; import com.loafle.overflow.module.domain.model.Domain; +import com.loafle.overflow.module.member.model.Member; import com.loafle.overflow.module.noauthprobe.dao.NoAuthProbeDAO; import com.loafle.overflow.module.noauthprobe.model.NoAuthProbe; +import com.loafle.overflow.module.probe.model.Probe; +import com.loafle.overflow.module.probe.service.ProbeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; /** @@ -17,6 +21,8 @@ public class NoAuthProbeService { @Autowired private NoAuthProbeDAO noAuthProbeDAO; + @Autowired + private ProbeService probeService; public NoAuthProbe regist(NoAuthProbe noAuthProbe) { @@ -32,8 +38,21 @@ public class NoAuthProbeService { return this.noAuthProbeDAO.findOne(id); } - public List registForNoAuthProbes(List noAuthProbes) { + public void registForNoAuthProbes(List noAuthProbes) { + + // Todo encryption key generation & probe key generation + + // Todo domain injection & member injection +// List resProbe = new ArrayList<>(); + Probe probe = null; + for (NoAuthProbe noAuth : noAuthProbes) { + probe = new Probe(); + probe.setProbeKey(noAuth.getApiKey()); + probe.setDomain(new Domain(1)); + probe.setAuthorizeMember(new Member(1)); +// resProbe.add(probe); + this.probeService.regist(probe); + } - return this.noAuthProbeDAO.save(noAuthProbes); } }