-
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.
Merge pull request #12 from woowa-techcamp-2024/feature/6_Dr-KoKo_점주_…
…회원가입 점주 회원가입
- Loading branch information
Showing
40 changed files
with
1,318 additions
and
46 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
17 changes: 11 additions & 6 deletions
17
src/main/java/camp/woowak/lab/customer/domain/Customer.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,13 +1,18 @@ | ||
package camp.woowak.lab.customer.domain; | ||
|
||
import camp.woowak.lab.payaccount.domain.PayAccount; | ||
import jakarta.persistence.*; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.OneToOne; | ||
|
||
@Entity | ||
public class Customer { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@OneToOne(fetch = FetchType.LAZY) | ||
private PayAccount payAccount; | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@OneToOne(fetch = FetchType.LAZY) | ||
private PayAccount payAccount; | ||
} |
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,13 +1,18 @@ | ||
package camp.woowak.lab.menu.domain; | ||
|
||
import camp.woowak.lab.store.domain.Store; | ||
import jakarta.persistence.*; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.ManyToOne; | ||
|
||
@Entity | ||
public class Menu { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Store store; | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Store store; | ||
} |
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
8 changes: 8 additions & 0 deletions
8
src/main/java/camp/woowak/lab/payaccount/repository/PayAccountRepository.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,8 @@ | ||
package camp.woowak.lab.payaccount.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import camp.woowak.lab.payaccount.domain.PayAccount; | ||
|
||
public interface PayAccountRepository extends JpaRepository<PayAccount, Long> { | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
package camp.woowak.lab.store.domain; | ||
|
||
import camp.woowak.lab.vendor.domain.Vendor; | ||
import jakarta.persistence.*; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.ManyToOne; | ||
|
||
@Entity | ||
public class Store { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Vendor owner; | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Vendor owner; | ||
} |
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,13 +1,49 @@ | ||
package camp.woowak.lab.vendor.domain; | ||
|
||
import camp.woowak.lab.payaccount.domain.PayAccount; | ||
import jakarta.persistence.*; | ||
import camp.woowak.lab.vendor.exception.InvalidVendorCreationException; | ||
import camp.woowak.lab.web.authentication.PasswordEncoder; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.OneToOne; | ||
|
||
@Entity | ||
public class Vendor { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@OneToOne(fetch = FetchType.LAZY) | ||
private PayAccount payAccount; | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Column(nullable = false, length = 50) | ||
private String name; | ||
@Column(unique = true, nullable = false, length = 100) | ||
private String email; | ||
@Column(nullable = false, length = 30) | ||
private String password; | ||
@Column(nullable = false, length = 30) | ||
private String phone; | ||
@OneToOne(fetch = FetchType.LAZY) | ||
private PayAccount payAccount; | ||
|
||
protected Vendor() { | ||
} | ||
|
||
/** | ||
* @throws InvalidVendorCreationException 검증에 실패하면 | ||
*/ | ||
public Vendor(String name, String email, String password, String phone, PayAccount payAccount, | ||
PasswordEncoder passwordEncoder) { | ||
VendorValidator.validate(name, email, password, phone, payAccount); | ||
this.name = name; | ||
this.email = email; | ||
this.password = passwordEncoder.encode(password); | ||
this.phone = phone; | ||
this.payAccount = payAccount; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/camp/woowak/lab/vendor/domain/VendorValidator.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,64 @@ | ||
package camp.woowak.lab.vendor.domain; | ||
|
||
import camp.woowak.lab.payaccount.domain.PayAccount; | ||
import camp.woowak.lab.vendor.exception.InvalidVendorCreationException; | ||
import camp.woowak.lab.vendor.exception.VendorErrorCode; | ||
|
||
public final class VendorValidator { | ||
private static final int MAX_NAME_LENGTH = 50; | ||
private static final int MAX_EMAIL_LENGTH = 100; | ||
private static final int MIN_PASSWORD_LENGTH = 8; | ||
private static final int MAX_PASSWORD_LENGTH = 30; | ||
private static final int MAX_PHONE_LENGTH = 30; | ||
|
||
public static void validate(final String name, final String email, final String password, final String phone, | ||
final PayAccount payAccount) throws InvalidVendorCreationException { | ||
checkName(name); | ||
checkEmail(email); | ||
checkPassword(password); | ||
checkPhone(phone); | ||
checkPayAccount(payAccount); | ||
} | ||
|
||
private static void checkName(String name) throws InvalidVendorCreationException { | ||
if (name == null || name.isBlank()) { | ||
throw new InvalidVendorCreationException(VendorErrorCode.INVALID_NAME_EMPTY); | ||
} | ||
if (name.length() > MAX_NAME_LENGTH) { | ||
throw new InvalidVendorCreationException(VendorErrorCode.INVALID_NAME_RANGE); | ||
} | ||
} | ||
|
||
private static void checkEmail(String email) throws InvalidVendorCreationException { | ||
if (email == null || email.isBlank()) { | ||
throw new InvalidVendorCreationException(VendorErrorCode.INVALID_EMAIL_EMPTY); | ||
} | ||
if (email.trim().length() > MAX_EMAIL_LENGTH) { | ||
throw new InvalidVendorCreationException(VendorErrorCode.INVALID_EMAIL_RANGE); | ||
} | ||
} | ||
|
||
private static void checkPassword(String password) throws InvalidVendorCreationException { | ||
if (password == null || password.isBlank()) { | ||
throw new InvalidVendorCreationException(VendorErrorCode.INVALID_PASSWORD_EMPTY); | ||
} | ||
if (password.trim().length() < MIN_PASSWORD_LENGTH || password.trim().length() > MAX_PASSWORD_LENGTH) { | ||
throw new InvalidVendorCreationException(VendorErrorCode.INVALID_PASSWORD_RANGE); | ||
} | ||
} | ||
|
||
private static void checkPhone(String phone) throws InvalidVendorCreationException { | ||
if (phone == null || phone.isBlank()) { | ||
throw new InvalidVendorCreationException(VendorErrorCode.INVALID_PHONE_EMPTY); | ||
} | ||
if (phone.trim().length() > MAX_PHONE_LENGTH) { | ||
throw new InvalidVendorCreationException(VendorErrorCode.INVALID_PHONE_RANGE); | ||
} | ||
} | ||
|
||
private static void checkPayAccount(PayAccount payAccount) throws InvalidVendorCreationException { | ||
if (payAccount == null) { | ||
throw new InvalidVendorCreationException(VendorErrorCode.INVALID_PAY_ACCOUNT_EMPTY); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/camp/woowak/lab/vendor/exception/DuplicateEmailException.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 DuplicateEmailException extends BadRequestException { | ||
public DuplicateEmailException() { | ||
super(VendorErrorCode.DUPLICATE_EMAIL); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/camp/woowak/lab/vendor/exception/InvalidVendorCreationException.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,10 @@ | ||
package camp.woowak.lab.vendor.exception; | ||
|
||
import camp.woowak.lab.common.exception.BadRequestException; | ||
import camp.woowak.lab.common.exception.ErrorCode; | ||
|
||
public class InvalidVendorCreationException extends BadRequestException { | ||
public InvalidVendorCreationException(ErrorCode errorCode) { | ||
super(errorCode); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/camp/woowak/lab/vendor/exception/VendorErrorCode.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,43 @@ | ||
package camp.woowak.lab.vendor.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
import camp.woowak.lab.common.exception.ErrorCode; | ||
|
||
public enum VendorErrorCode implements ErrorCode { | ||
INVALID_PHONE_EMPTY(HttpStatus.BAD_REQUEST, "v_1_1", "전화번호가 입력되지 않았습니다."), | ||
INVALID_PHONE_RANGE(HttpStatus.BAD_REQUEST, "v_1_2", "전화번호는 30자를 넘을 수 없습니다."), | ||
INVALID_PASSWORD_EMPTY(HttpStatus.BAD_REQUEST, "v1_3", "비밀번호가 입력되지 않았습니다."), | ||
INVALID_PASSWORD_RANGE(HttpStatus.BAD_REQUEST, "v1_4", "비밀번호는 8-30자 입력되어야 합니다."), | ||
INVALID_EMAIL_EMPTY(HttpStatus.BAD_REQUEST, "v1_5", "이메일이 입력되지 않았습니다."), | ||
INVALID_EMAIL_RANGE(HttpStatus.BAD_REQUEST, "v1_6", "이메일은 100자를 넘을 수 없습니다."), | ||
INVALID_NAME_EMPTY(HttpStatus.BAD_REQUEST, "v1_7", "이름이 입력되지 않았습니다."), | ||
INVALID_NAME_RANGE(HttpStatus.BAD_REQUEST, "v1_8", "이름은 50자를 넘을 수 없습니다."), | ||
INVALID_PAY_ACCOUNT_EMPTY(HttpStatus.BAD_REQUEST, "v_1_9", "포인트 계좌가 입력되지 않았습니다."), | ||
DUPLICATE_EMAIL(HttpStatus.BAD_REQUEST, "v_2", "이미 가입된 이메일입니다."); | ||
|
||
private final int status; | ||
private final String errorCode; | ||
private final String message; | ||
|
||
VendorErrorCode(HttpStatus httpStatus, String errorCode, String message) { | ||
this.status = httpStatus.value(); | ||
this.errorCode = errorCode; | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public int getStatus() { | ||
return status; | ||
} | ||
|
||
@Override | ||
public String getErrorCode() { | ||
return errorCode; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return message; | ||
} | ||
} |
Empty file.
8 changes: 8 additions & 0 deletions
8
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package camp.woowak.lab.vendor.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import camp.woowak.lab.vendor.domain.Vendor; | ||
|
||
public interface VendorRepository extends JpaRepository<Vendor, Long> { | ||
} |
Empty file.
Oops, something went wrong.