-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [style] ArgumentResolver 개행 네이버 컨벤션에 부합하게 개행 처리 * [fix] LoginVendor 및 LoginCustomer의 id 변경 * [feat] POST /vendor/login 로그인 앤드 포인트 SignINVendorRequest에서 검증 수행 후 Service 에 위임 * [fix] Vendor의 id를 UUID로 수정 * [fix] Vendor id 변경으로 인한 VendorRepositoryTest 변경 * [fix] Vendor id 변경으로 인한 SignUPVendorServiceTest 변경 * [fix] Vendor id 변경으로 인한 VendorApiControllerTest 변경 * [feat] Vendor의 비밀번호 일치 여부를 확인하는 도메인 메서드 `+` matches() * [feat] VendorRepository에서 Email로 조회하는 메서드 `+` findByEmail() `+` findByEmailOrThrow() * [feat] Vendor가 로그인하기 위한 서비스 구현 입력된 비밀번호와 Vendor의 비밀번호의 일치 여부 확인 * [docs] SignInVendorService가 던지는 예외 명시 SignInVendorService는 PasswordMismatchException을 발생시킨다. * [fix] matches 메서드 파라미터 순서 오류 수정 * [fix] TestVendor 생성자 수정 부모 클래스에 필드값을 넣어주어야 제대로 동작한다. * [test] Vendor.matches() 테스트 * [test] SignInVendorServiceTest * [feat] 판매자 로그인 endpoint * [test] 로그인 컨트롤러 테스트 코드 작성 * [fix] LoginCustomer는 다른 이슈에서 처리될 예정 * [feat] Vendor 예외 처리 `+` PasswordMismatchException `+` NotFoundVendorException * [test] 점포 생성 테스트 코드 수정 Vendor의 id 타입의 변경으로 인한 수정 * [test] status 검증 수정 응답 상태 코드가 BadRequest인지 검증 * [fix] 로그인시 응답 메시지 생성 status 값을 담아주는 APIResponseAdvice 활용 * [fix] Id 전략 변경으로 인한 SignUpVendorService 수정 Service 내부에서 DataIntegrityViolationException을 받기 위해서는 flush가 수행되어야 한다. * [test] SignUpVendorServiceTest에서 SaveAndFlush를 mocking하게 수정
- Loading branch information
Showing
23 changed files
with
433 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/camp/woowak/lab/vendor/exception/NotFoundVendorException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package camp.woowak.lab.vendor.exception; | ||
|
||
import camp.woowak.lab.common.exception.NotFoundException; | ||
|
||
public class NotFoundVendorException extends NotFoundException { | ||
public NotFoundVendorException() { | ||
super(VendorErrorCode.NOT_FOUND_VENDOR); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/camp/woowak/lab/vendor/exception/PasswordMismatchException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package camp.woowak.lab.vendor.exception; | ||
|
||
import camp.woowak.lab.common.exception.BadRequestException; | ||
|
||
public class PasswordMismatchException extends BadRequestException { | ||
public PasswordMismatchException() { | ||
super(VendorErrorCode.WRONG_PASSWORD); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletion
11
src/main/java/camp/woowak/lab/vendor/repository/VendorRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
package camp.woowak.lab.vendor.repository; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import camp.woowak.lab.vendor.domain.Vendor; | ||
import camp.woowak.lab.vendor.exception.NotFoundVendorException; | ||
|
||
public interface VendorRepository extends JpaRepository<Vendor, UUID> { | ||
Optional<Vendor> findByEmail(String email); | ||
|
||
public interface VendorRepository extends JpaRepository<Vendor, Long> { | ||
default Vendor findByEmailOrThrow(String email) { | ||
return findByEmail(email).orElseThrow(NotFoundVendorException::new); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/camp/woowak/lab/vendor/service/SignInVendorService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package camp.woowak.lab.vendor.service; | ||
|
||
import java.util.UUID; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import camp.woowak.lab.vendor.domain.Vendor; | ||
import camp.woowak.lab.vendor.exception.PasswordMismatchException; | ||
import camp.woowak.lab.vendor.repository.VendorRepository; | ||
import camp.woowak.lab.vendor.service.command.SignInVendorCommand; | ||
import camp.woowak.lab.web.authentication.PasswordEncoder; | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
public class SignInVendorService { | ||
private final VendorRepository repository; | ||
private final PasswordEncoder passwordEncoder; | ||
|
||
public SignInVendorService(VendorRepository repository, PasswordEncoder passwordEncoder) { | ||
this.repository = repository; | ||
this.passwordEncoder = passwordEncoder; | ||
} | ||
|
||
/** | ||
* @throws PasswordMismatchException 비밀번호가 일치하지 않으면 | ||
*/ | ||
public UUID signIn(SignInVendorCommand cmd) { | ||
Vendor findVendor = repository.findByEmailOrThrow(cmd.email()); | ||
if (!findVendor.matches(cmd.password(), passwordEncoder)) { | ||
throw new PasswordMismatchException(); | ||
} | ||
return findVendor.getId(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/camp/woowak/lab/vendor/service/command/SignInVendorCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package camp.woowak.lab.vendor.service.command; | ||
|
||
public record SignInVendorCommand( | ||
String email, | ||
String password | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/camp/woowak/lab/web/authentication/LoginMember.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package camp.woowak.lab.web.authentication; | ||
|
||
public interface LoginMember { | ||
Long getId(); | ||
Object getId(); | ||
} |
8 changes: 5 additions & 3 deletions
8
src/main/java/camp/woowak/lab/web/authentication/LoginVendor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
package camp.woowak.lab.web.authentication; | ||
|
||
import java.util.UUID; | ||
|
||
public class LoginVendor implements LoginMember { | ||
private final Long id; | ||
private final UUID id; | ||
|
||
public LoginVendor(Long id) { | ||
public LoginVendor(UUID id) { | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public Long getId() { | ||
public UUID getId() { | ||
return id; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/camp/woowak/lab/web/dto/request/vendor/SignInVendorRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package camp.woowak.lab.web.dto.request.vendor; | ||
|
||
import org.hibernate.validator.constraints.Length; | ||
|
||
import jakarta.validation.constraints.Email; | ||
import jakarta.validation.constraints.NotBlank; | ||
|
||
public record SignInVendorRequest( | ||
@NotBlank @Email | ||
String email, | ||
@NotBlank @Length(min = 8, max = 30) | ||
String password | ||
) { | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/camp/woowak/lab/web/dto/response/vendor/SignInVendorResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package camp.woowak.lab.web.dto.response.vendor; | ||
|
||
public record SignInVendorResponse( | ||
String message | ||
) { | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/java/camp/woowak/lab/web/dto/response/vendor/SignUpVendorResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package camp.woowak.lab.web.dto.response.vendor; | ||
|
||
public record SignUpVendorResponse( | ||
Long id | ||
String id | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
package camp.woowak.lab.fixture; | ||
|
||
import java.util.UUID; | ||
|
||
import camp.woowak.lab.payaccount.domain.PayAccount; | ||
import camp.woowak.lab.vendor.TestVendor; | ||
import camp.woowak.lab.vendor.domain.Vendor; | ||
import camp.woowak.lab.web.authentication.PasswordEncoder; | ||
|
||
|
@@ -9,6 +12,12 @@ default PayAccount createPayAccount() { | |
return new PayAccount(); | ||
} | ||
|
||
default Vendor createSavedVendor(UUID id, PayAccount payAccount, PasswordEncoder passwordEncoder) { | ||
return new TestVendor( | ||
id, "vendorName", "[email protected]", "vendorPassword", "010-0000-0000", payAccount, | ||
passwordEncoder); | ||
} | ||
|
||
default Vendor createVendor(PayAccount payAccount, PasswordEncoder passwordEncoder) { | ||
return new Vendor("vendorName", "[email protected]", "vendorPassword", "010-0000-0000", payAccount, | ||
passwordEncoder); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package camp.woowak.lab.vendor; | ||
|
||
import java.util.UUID; | ||
|
||
import camp.woowak.lab.payaccount.domain.PayAccount; | ||
import camp.woowak.lab.vendor.domain.Vendor; | ||
import camp.woowak.lab.web.authentication.PasswordEncoder; | ||
|
||
public class TestVendor extends Vendor { | ||
private UUID id; | ||
|
||
public TestVendor(UUID id, String name, String email, String password, String phone, PayAccount payAccount, | ||
PasswordEncoder passwordEncoder) { | ||
super(name, email, password, phone, payAccount, passwordEncoder); | ||
this.id = id; | ||
} | ||
|
||
public UUID getId() { | ||
return id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.