-
Notifications
You must be signed in to change notification settings - Fork 7
/
CreateMemberService.java
38 lines (32 loc) · 1.47 KB
/
CreateMemberService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.gaebaljip.exceed.application.service.member;
import com.gaebaljip.exceed.common.annotation.Timer;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.gaebaljip.exceed.adapter.in.member.request.SignUpMemberRequest;
import com.gaebaljip.exceed.application.domain.member.MemberEntity;
import com.gaebaljip.exceed.application.port.in.member.CreateMemberUsecase;
import com.gaebaljip.exceed.application.port.out.member.MemberPort;
import com.gaebaljip.exceed.common.exception.member.AlreadyEmailException;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class CreateMemberService implements CreateMemberUsecase {
private final MemberPort memberPort;
private final BCryptPasswordEncoder bCryptPasswordEncoder;
@Override
@Timer
@Transactional
public void execute(SignUpMemberRequest signUpMemberRequest) {
if (!memberPort.existsByEmail(signUpMemberRequest.email())) {
MemberEntity memberEntity =
MemberEntity.builder()
.email(signUpMemberRequest.email())
.password(bCryptPasswordEncoder.encode(signUpMemberRequest.password()))
.build();
memberPort.command(memberEntity);
} else {
throw AlreadyEmailException.EXECPTION;
}
}
}