-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[종근] 배민찬 3단계(프로모션) 구현 완료 + 1~3단계 프론트 구현 #11
base: econo-jonggeun
Are you sure you want to change the base?
Changes from all commits
08610e5
ff6fc1a
ebd59c4
a5d9ed9
300b9b2
ce82d2a
d41e8b2
8220c37
2fb5af0
d89fba3
7fb9470
e3c08eb
0b381c1
b5b1952
4155921
85119fb
77e5e77
638b03c
767635e
f765284
ea8f430
a03b604
99a7883
f3c32f7
ce31464
87c2803
dab5bfe
4564ad8
13672d1
f5aa648
730a35d
b18777d
1077b1f
e0b1d2e
303efeb
7549b19
a2e630a
b76c60a
f3f31bf
3e33b72
cec6e26
d13dee1
a7d0815
49b8b29
1ba50aa
7505668
3a08062
a3decac
a2ce36d
bc0fc91
380dfaa
eef85a8
aa0c36d
f823515
e967c96
f90699a
d8a25c2
b1db9e4
09aac72
af0e229
bb592c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
language: java | ||
jdk: | ||
- openjdk8 | ||
|
||
branches: | ||
only: | ||
- econo-jonggeun | ||
|
||
before_install: | ||
- chmod +x mvnw | ||
|
||
install: | ||
- | ||
- "./mvnw clean install" | ||
|
||
# Travis CI 서버의 Home | ||
cache: | ||
directories: | ||
- .autoconf | ||
- $HOME/.m2 | ||
|
||
script: | ||
|
||
- "./mvnw clean package" | ||
|
||
before_deploy: | ||
- zip -r baeminchan * | ||
- mkdir -p deploy | ||
- mv baeminchan.zip deploy/baeminchan.zip | ||
|
||
deploy: | ||
- provider: s3 | ||
local_dir: deploy # before_deploy에서 생성한 디렉토리 | ||
access_key_id: $AWS_ACCESS_KEY # Travis repo settings에 설정된 값 | ||
secret_access_key: $AWS_SECRET_KEY # Travis repo settings에 설정된 값 | ||
bucket: baeminchan-deploy # 6-3-3에서 생성한 S3 버킷 | ||
region: ap-northeast-2 | ||
skip_cleanup: true | ||
acl: public_read | ||
wait-until-deployed: true | ||
on: | ||
repo: Bellroute/baeminchan #Github 주소 | ||
branch: econo-jonggeun | ||
|
||
- provider: codedeploy | ||
access_key_id: $AWS_ACCESS_KEY # Travis repo settings에 설정된 값 | ||
secret_access_key: $AWS_SECRET_KEY # Travis repo settings에 설정된 값 | ||
bucket: baeminchan-deploy # S3 버킷 | ||
key: baeminchan.zip # 빌드 파일을 압축해서 전달 | ||
bundle_type: zip | ||
application: baeminchan # 웹 콘솔에서 등록한 CodeDeploy 어플리케이션 | ||
deployment_group: baeminchan-group # 웹 콘솔에서 등록한 CodeDeploy 배포 그룹 | ||
region: ap-northeast-2 | ||
wait-until-deployed: true | ||
on: | ||
repo: Bellroute/baeminchan | ||
branch: econo-jonggeun | ||
|
||
# CI 실행 완료시 메일로 알람 | ||
notifications: | ||
email: | ||
recipients: | ||
- [email protected] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: 0.0 | ||
os: linux | ||
files: | ||
- source: / | ||
destination: /home/ec2-user/app/travis/build/ | ||
|
||
hooks: | ||
AfterInstall: # 배포가 끝나면 아래 명령어를 실행 | ||
- location: execute-deploy.sh | ||
timeout: 180 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
/home/ec2-user/app/travis/deploy.sh > /dev/null 2> /dev/null < /dev/null & |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,52 @@ | ||
package codesquad.config; | ||
|
||
import codesquad.interceptor.AdminInterceptor; | ||
import codesquad.sequrity.BasicAuthInterceptor; | ||
import codesquad.sequrity.LoginUserHandlerMethodArgumentResolver; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
import java.util.List; | ||
|
||
@Configuration | ||
public class WebMvcConfig implements WebMvcConfigurer { | ||
public abstract class WebMvcConfig implements WebMvcConfigurer { | ||
|
||
@Override | ||
public void addInterceptors(InterceptorRegistry registry) { | ||
registry.addInterceptor(new AdminInterceptor()) | ||
.addPathPatterns("/admin/**"); | ||
} | ||
|
||
@Bean | ||
public LoginUserHandlerMethodArgumentResolver loginUserArgumentResolver() { | ||
return new LoginUserHandlerMethodArgumentResolver(); | ||
} | ||
|
||
@Override | ||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) { | ||
argumentResolvers.add(loginUserArgumentResolver()); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제가 아직 구분을 못해서 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @loginuser 라는 어노테이션을 커스텀해 사용하기 위해 작성한 부분입니다. |
||
|
||
@Configuration | ||
@Profile({ "test" }) | ||
static class TestWebMvcConfig extends WebMvcConfig { | ||
@Bean | ||
public BasicAuthInterceptor basicAuthInterceptor() { | ||
return new BasicAuthInterceptor(); | ||
} | ||
|
||
@Override | ||
public void addInterceptors(InterceptorRegistry registry) { | ||
registry.addInterceptor(basicAuthInterceptor()); | ||
} | ||
} | ||
|
||
@Configuration | ||
@Profile({ "local", "dev", "prod" }) | ||
static class NotTestWebMvcConfig extends WebMvcConfig { | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 코드의 의도는 test 스코프가 아닌 다른 scope일때 아래를 적용하라는 것 같은데 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 코드를 작성하지 않으면 test 스코프 밖에 남지 않아서 다른 프로필에서는 동작하지 않을 것 같습니다. 나중에 시도하고 직접 확인해 보겠습니다. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
import static codesquad.domain.AccountType.USER; | ||
|
||
@Entity | ||
@Table(name = "account") | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
|
@@ -27,7 +28,7 @@ public class Account { | |
@Column(nullable = false, name = "password") | ||
private String password; | ||
|
||
@Column(nullable = false, name = "name") | ||
@Column(nullable = false, name = "user_name") | ||
private String name; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 필드의 변수명으로 칼럼명을 추론하도록 둘 수 있는데 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 로그에서 나중에 다른 엔티티의 칼럼명과 혼동이 올까봐 가독성을 고려해서 변경하게 되었습니다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 조금 더 이야기를 해볼까요 헷갈릴 가능성이 있는 다른 엔티티의 예시가 있을까요? Account 객체의 name필드인데, 저는 이게 다른 엔티티와 쉽게 혼동이 생길거라고 생각되지는 않습니다! |
||
|
||
@Column(nullable = false, name = "phone_number") | ||
|
@@ -106,4 +107,12 @@ public String toString() { | |
public boolean isAdmin() { | ||
return this.accountType.equals(ADMIN); | ||
} | ||
|
||
public boolean hasSamePhoneNumber(String phoneNumber) { | ||
return this.phoneNumber.equals(phoneNumber); | ||
} | ||
|
||
public boolean hasSameName(String name) { | ||
return this.name.equals(name); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ | |
public interface AccountRepository extends JpaRepository<Account, Long> { | ||
|
||
Optional<Account> findByEmail(String accountId); | ||
Optional<Account> findByName(String name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. name과 email이 중복된 경우가 있을땐 어떻게 되나요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 서비스단에서 email에 대한 중복 예외 처리 구현했는데 디비에서 unique 처리하도록 수정하겠습니다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제가 name이 여러개 있을경우 Optional<Account> findByName(String name); 위 코드에서 id가 젤 빠른 한개만 가져온다고 설명드렸었는데, |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package codesquad.domain; | ||
|
||
import codesquad.dto.CategoryDTO; | ||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
@@ -12,6 +13,7 @@ | |
import java.util.stream.Collectors; | ||
|
||
@Entity | ||
@Table(name = "category") | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
|
@@ -34,6 +36,7 @@ public class Category { | |
@Where(clause = "deleted='false'") | ||
@OneToMany(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "parentId", nullable = true) | ||
@JsonIgnore | ||
private List<Category> children = new ArrayList<>(); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed엔 없지만 클래스에 포함된 코드 @Where(clause = "deleted='false'")
@JoinColumn(name = "parentId", nullable = true)
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JsonIgnore
private Category parent; 영속성 전이 적용된게 잘못된듯 한데 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 데이터를 실제로 delete하는게 아니라 delted=true 처리하는 방식으로 구현해서 문제가 발견 안 됐는데 확인해 보니까 자식을 삭제 했을 때
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네 All 로 처리하지말고, 필요한 CascadeType만 선별적으로 사용하면 좋을 것 같습니다. |
||
@Column(name = "deleted", nullable = false) | ||
|
@@ -75,11 +78,6 @@ public void setParent(Category parent) { | |
this.parent = parent; | ||
} | ||
|
||
public List<Category> getChildrenExceptDeleted() { | ||
return this.children.stream() | ||
.filter(child -> !child.isDeleted()).collect(Collectors.toList()); | ||
} | ||
|
||
public void delete() { | ||
this.deleted = true; | ||
} | ||
|
@@ -115,4 +113,17 @@ private boolean isSame(Category category) { | |
public void update(String title) { | ||
this.title = title; | ||
} | ||
|
||
public CategoryDTO changeToDTO() { | ||
return new CategoryDTO(this.title, this.parent.getId()); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 위 메서드는 CategoryDTO클래스에 필드를 추가하게 되면, Category쪽 코드도 다시 와서 같이 바꿔줘야 하는 상황이 생기는 것 같네요. 변화가 다른곳에 덜 영향을 주도록 한번 수정해보는것도 좋을 것 같습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 객체지향 5대원칙 찾아보고 반영하겠습니다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아직 그렇게까진 안해도 될 것 같아요 현재에서 수정이 일어났을때 어떤 상황이 발생하고, 그 방지책으로 조금더 수정에 닫혀있는 구조로 바꿔보기를 권한것 뿐입니다. |
||
|
||
public Category createDefaultCategory(String defaultMenuTitle) { | ||
this.id = 9999l; | ||
this.title = defaultMenuTitle; | ||
this.parent = null; | ||
this.children = null; | ||
|
||
return this.build(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 이 메서드를 사용하기 위해서, build()메서드, Category를 파라미터로 받는 생성자 까지 2개의 메서드를 추가로 사용해야 하네요. 기본 값을 가진 객체 생성 + 특정 이름을 주고 싶은 의도라면 적절한 디자인 패턴이 존재합니다. 너무 시간쓰지 마시고 적당히 찾아서 안나오면 그냥 물어보시면 좋을 것 같습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 빌더 패턴을 이해하고, 변화시켜 응용하려고 하신점은 훌륭하신것 같습니다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 정적 팩토리 메서드 알아보고 반영하겠습니다 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package codesquad.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Table(name = "promotion") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
public class Promotion { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
private Long id; | ||
|
||
@Column(nullable = false, name = "promotion_type") | ||
@Enumerated(EnumType.STRING) | ||
private PromotionType type; | ||
|
||
@Column(nullable = false, name = "title") | ||
private String title; | ||
|
||
@Column(nullable = false, name = "description") | ||
private String describe; | ||
|
||
@Column(nullable = false, name = "original_price") | ||
private int originalPrice; | ||
|
||
@Column(nullable = false, name = "final_price") | ||
private int finalPrice; | ||
|
||
public boolean isType(PromotionType promotionType) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 메서드 이름은 조금 길더라도 isSameType과 같은식으로 누가봐도 중의적으로 해석 되지 않을 메서드 명을 사용하면 좋을 것 같습니다. isType 이라고 해서 전달한 타입이 올바른 타입 객체인지 유효성 검증하는 메서드인가 잠깐 생각했습니다. |
||
return this.type == promotionType; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package codesquad.domain; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface PromotionRepository extends JpaRepository<Promotion, Long> { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package codesquad.domain; | ||
|
||
public enum PromotionType { | ||
SUB_DISH, MAIN_DISH, SOUP_AND_STEW | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package codesquad.dto; | ||
|
||
import codesquad.utils.RegexUtil; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.Pattern; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class FindingEmailDTO { | ||
|
||
@NotBlank | ||
private String name; | ||
|
||
@Pattern(regexp = RegexUtil.REGEX_PHONE_NUMBER) | ||
private String phoneNumber; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 DTO는 불변객체가 아닐 이유가 없는 객체로 보입니다. (데이터가 많지 않네용) final을 통해서 필드들의 불변성이 보장되는 불변 객체로 만들면 좋을 것 같습니다. (Setter는 꼭 필요할 때만 쓰고, 안쓸 수 있다면 안써야합니다) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 어떻게 수정하실건지도 들려주세요! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package codesquad.dto; | ||
|
||
import codesquad.utils.RegexUtil; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.Pattern; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class FindingPasswordDTO { | ||
|
||
@NotBlank | ||
String email; | ||
|
||
@NotBlank | ||
String name; | ||
|
||
@Pattern(regexp = RegexUtil.REGEX_PHONE_NUMBER) | ||
String phoneNumber; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 위와 같은듯 합니다 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package codesquad.exception; | ||
|
||
public class UnAuthorizedException extends RuntimeException { | ||
public UnAuthorizedException(String s) { | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super(s)가 없는 이유가 있나요?.? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 실수로 빼먹은 것 같습니다. super(s)는 문자열 s를 파라미터로 받는 부모 클래스인 runtimeExeption의 생성자를 호출합니다. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstract로 선언한 이유는 무엇인가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
profile 공통 설정을 가진 부모 클래스를 만들면서 초기에 선언 했었는데 추상 메소드를 따로 구현안해서 필요없는 부분이 되버린 걸 안 지웠네요