Skip to content
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

Open
wants to merge 61 commits into
base: econo-jonggeun
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
08610e5
feat: fornt-end main page transition function
Bellroute Sep 27, 2019
ff6fc1a
fet: promotion entity
Bellroute Sep 27, 2019
ebd59c4
feat: promotion service (read)
Bellroute Sep 27, 2019
a5d9ed9
feat: data mapping in front using mushtache
Bellroute Sep 27, 2019
300b9b2
fix: database migration h2 -> mysql
Bellroute Sep 28, 2019
ce82d2a
feat: @loginUser (아직 사용은 안함)
Bellroute Oct 2, 2019
d41e8b2
feat: @loginUser (아직 사용은 안함)
Bellroute Oct 2, 2019
8220c37
fix: admin acceptance with basic auth interceptor
Bellroute Oct 2, 2019
2fb5af0
fix: test code for deploy
Bellroute Oct 3, 2019
d89fba3
fix: MockitoJUnitRunner add Silent
Bellroute Oct 3, 2019
7fb9470
fix: MockitoJUnitRunner add Silent
Bellroute Oct 3, 2019
e3c08eb
fix: datasource info
Bellroute Oct 3, 2019
0b381c1
Merge pull request #1 from Bellroute/step3
Bellroute Oct 3, 2019
b5b1952
fix: for deploy
Bellroute Oct 4, 2019
4155921
fix
Bellroute Oct 4, 2019
85119fb
fix:
Bellroute Oct 4, 2019
77e5e77
add: travis ci
Bellroute Oct 4, 2019
638b03c
add: travis ci
Bellroute Oct 4, 2019
767635e
add: travis ci
Bellroute Oct 4, 2019
f765284
fix: travis ci
Bellroute Oct 4, 2019
ea8f430
fix: travis ci
Bellroute Oct 4, 2019
a03b604
fix: travis ci
Bellroute Oct 4, 2019
99a7883
fix: travis ci
Bellroute Oct 4, 2019
f3c32f7
fix: springbootapplication class name for travis ci
Bellroute Oct 4, 2019
ce31464
fix: travis ci
Bellroute Oct 4, 2019
87c2803
fix: delete build.gradle for travis ci
Bellroute Oct 4, 2019
dab5bfe
fix: travis ci
Bellroute Oct 4, 2019
4564ad8
fix: travis ci
Bellroute Oct 4, 2019
13672d1
add: aws s3
Bellroute Oct 4, 2019
f5aa648
fix: travis.yml
Bellroute Oct 4, 2019
730a35d
fix: travis.yml
Bellroute Oct 4, 2019
b18777d
add: excute-deploy.sh
Bellroute Oct 4, 2019
1077b1f
chore: test auto deploy
Bellroute Oct 4, 2019
e0b1d2e
feat: front-end login, logout function
Bellroute Oct 8, 2019
303efeb
feat: finding id, pw page templates
Bellroute Oct 9, 2019
7549b19
feat: id, password 찾기에 대한 요구사항
Bellroute Oct 9, 2019
a2e630a
tdd: 아이디 찾기 테스트 코드(실패)
Bellroute Oct 9, 2019
b76c60a
tdd: 아이디 찾기 구현(통과)
Bellroute Oct 9, 2019
f3f31bf
tdd: 비밀번호 찾기 테스트 코드(실패)
Bellroute Oct 9, 2019
3e33b72
tdd: 비밀번호 찾기 테스트 수정(실패)
Bellroute Oct 9, 2019
cec6e26
tdd: 비밀번호 찾기 service 테스트 구현(실패)
Bellroute Oct 9, 2019
d13dee1
tdd: 비밀번호 찾기 기능 구현(통과)
Bellroute Oct 9, 2019
a7d0815
refactor:
Bellroute Oct 9, 2019
49b8b29
chore: import.sql에 카테고리 insert
Bellroute Oct 9, 2019
1ba50aa
feat: 프론트에서 메인화면 카테고리 목록 db 기준으로 불러오기
Bellroute Oct 9, 2019
7505668
chore
Bellroute Oct 9, 2019
3a08062
fix: front-end promotion dot
Bellroute Oct 10, 2019
a3decac
fix: front-end promotion dot
Bellroute Oct 10, 2019
a2ce36d
fix: reduce dependency of ResponseGenerator
Bellroute Oct 10, 2019
bc0fc91
fix: change travis branch
Bellroute Oct 10, 2019
380dfaa
Merge pull request #2 from Bellroute/step3
Bellroute Oct 10, 2019
eef85a8
chore
Bellroute Oct 10, 2019
aa0c36d
chore
Bellroute Oct 10, 2019
f823515
chore
Bellroute Oct 10, 2019
e967c96
chore
Bellroute Oct 10, 2019
f90699a
chore
Bellroute Oct 10, 2019
d8a25c2
chore
Bellroute Oct 10, 2019
b1db9e4
fix: login acceptance test code
Bellroute Oct 10, 2019
09aac72
chore
Bellroute Oct 10, 2019
af0e229
chore
Bellroute Oct 10, 2019
bb592c5
chore
Bellroute Oct 10, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .travis.yml
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]
10 changes: 10 additions & 0 deletions appspec.yml
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
Empty file modified build.gradle
100755 → 100644
Empty file.
2 changes: 2 additions & 0 deletions execute-deploy.sh
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 &
4,881 changes: 4,881 additions & 0 deletions log/mylog.txt

Large diffs are not rendered by default.

6,866 changes: 6,866 additions & 0 deletions mylog-2019-10-03.0.txt

Large diffs are not rendered by default.

22,401 changes: 22,401 additions & 0 deletions mylog-2019-10-04.0.txt

Large diffs are not rendered by default.

1,258 changes: 1,258 additions & 0 deletions mylog-2019-10-08.0.txt

Large diffs are not rendered by default.

3,736 changes: 3,736 additions & 0 deletions mylog-2019-10-09.0.txt

Large diffs are not rendered by default.

1,984 changes: 1,984 additions & 0 deletions mylog-2019-10-10.0.txt

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>kr.codesquad</groupId>
<artifactId>baeminchan</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<packaging>jar</packaging>

<name>baeminchan</name>
Expand Down Expand Up @@ -43,6 +43,11 @@
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.17</version>
</dependency>
<dependency>
<groupId>net.rakugakibox.spring.boot</groupId>
<artifactId>logback-access-spring-boot-starter</artifactId>
Expand Down Expand Up @@ -70,7 +75,12 @@
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.0</version>
<scope>provided</scope>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
38 changes: 37 additions & 1 deletion src/main/java/codesquad/config/WebMvcConfig.java
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 {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abstract로 선언한 이유는 무엇인가요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

profile 공통 설정을 가진 부모 클래스를 만들면서 초기에 선언 했었는데 추상 메소드를 따로 구현안해서 필요없는 부분이 되버린 걸 안 지웠네요

@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());
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 아직 구분을 못해서
위의 두 메서드가 하는 역할이 어떻게 다른지 궁금합니다.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loginuser 라는 어노테이션을 커스텀해 사용하기 위해 작성한 부분입니다.
HandlerMethodArgumentResolver를 상속받은 loginUserArgumentResolver는 @loginuser를 위한 바인딩 설정을 하는 역할이고,
addArgumentResolver는 만든 resolver를 argumentREsolvers 리스트에 추가함으로써 어노테이션이 동작하게 하는 역할인데 솔직히 아직 와닿는 부분이 아니라서 학습이 필요한 부분입니다.


@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 {
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 코드의 의도는 test 스코프가 아닌 다른 scope일때 아래를 적용하라는 것 같은데
이 코드를 아예 작성하지 않았을때와 어떤 차이가 있나요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 코드를 작성하지 않으면 test 스코프 밖에 남지 않아서 다른 프로필에서는 동작하지 않을 것 같습니다. 나중에 시도하고 직접 확인해 보겠습니다.

}
11 changes: 10 additions & 1 deletion src/main/java/codesquad/domain/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static codesquad.domain.AccountType.USER;

@Entity
@Table(name = "account")
@Getter
@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

필드의 변수명으로 칼럼명을 추론하도록 둘 수 있는데
굳이 필드명에서 자동 생성되는 이름 말고 다른 칼럼명을 부여해 준 이유가 궁금합니다

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로그에서 나중에 다른 엔티티의 칼럼명과 혼동이 올까봐 가독성을 고려해서 변경하게 되었습니다

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

조금 더 이야기를 해볼까요
저는 name=""으로 선언된 칼럼 속성이 매우 불필요한 반복작업 처럼 느껴져서요.

헷갈릴 가능성이 있는 다른 엔티티의 예시가 있을까요?

Account 객체의 name필드인데, 저는 이게 다른 엔티티와 쉽게 혼동이 생길거라고 생각되지는 않습니다!


@Column(nullable = false, name = "phone_number")
Expand Down Expand Up @@ -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);
}
}
1 change: 1 addition & 0 deletions src/main/java/codesquad/domain/AccountRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
public interface AccountRepository extends JpaRepository<Account, Long> {

Optional<Account> findByEmail(String accountId);
Optional<Account> findByName(String name);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name과 email이 중복된 경우가 있을땐 어떻게 되나요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

서비스단에서 email에 대한 중복 예외 처리 구현했는데 디비에서 unique 처리하도록 수정하겠습니다

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 name이 여러개 있을경우

    Optional<Account> findByName(String name);

위 코드에서 id가 젤 빠른 한개만 가져온다고 설명드렸었는데,
지금 생각해보니 확실하지 않은 정보를 전달한 것 같네요.
그말은 잊어버리고 궁금해질때 직접 찾아보시길 권합니다~

}
21 changes: 16 additions & 5 deletions src/main/java/codesquad/domain/Category.java
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;
Expand All @@ -12,6 +13,7 @@
import java.util.stream.Collectors;

@Entity
@Table(name = "category")
@Getter
@NoArgsConstructor
@AllArgsConstructor
Expand All @@ -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<>();

Copy link
Collaborator

Choose a reason for hiding this comment

The 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;

영속성 전이 적용된게 잘못된듯 한데
현재 자식 카테고리를 삭제하면 정상동작 하나요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

데이터를 실제로 delete하는게 아니라 delted=true 처리하는 방식으로 구현해서 문제가 발견 안 됐는데 확인해 보니까 자식을 삭제 했을 때

  1. 부모도 함께 삭제
  2. 다른 자식들은 부모만 지워지고 그대로 존재
    하는 문제가 나는 걸 확인했습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 All 로 처리하지말고, 필요한 CascadeType만 선별적으로 사용하면 좋을 것 같습니다.

@Column(name = "deleted", nullable = false)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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());
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위 메서드는 CategoryDTO클래스에 필드를 추가하게 되면, Category쪽 코드도 다시 와서 같이 바꿔줘야 하는 상황이 생기는 것 같네요.

변화가 다른곳에 덜 영향을 주도록 한번 수정해보는것도 좋을 것 같습니다.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

객체지향 5대원칙 찾아보고 반영하겠습니다

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아직 그렇게까진 안해도 될 것 같아요
객체지향 5대원칙을 공부한다고, 바로 원칙에 맞게 코드를 딱 바꿀수 있는 것도 아니라고 생각합니다.

현재에서 수정이 일어났을때 어떤 상황이 발생하고, 그 방지책으로 조금더 수정에 닫혀있는 구조로 바꿔보기를 권한것 뿐입니다.


public Category createDefaultCategory(String defaultMenuTitle) {
this.id = 9999l;
this.title = defaultMenuTitle;
this.parent = null;
this.children = null;

return this.build();
}
Copy link
Collaborator

@dadadamarine dadadamarine Oct 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 이 메서드를 사용하기 위해서, build()메서드, Category를 파라미터로 받는 생성자 까지 2개의 메서드를 추가로 사용해야 하네요.
빌더 패턴과는 달리 원하는 필드를 자유롭게 하나씩 설정 할 수 있는 장점도 없어져 있어서, 다른 방식을 사용하는게 좋을 듯 합니다.

기본 값을 가진 객체 생성 + 특정 이름을 주고 싶은 의도라면 적절한 디자인 패턴이 존재합니다.
객체 생성과 관련된 디자인 패턴 한번 정리해보시면 좋을 것 같아요

너무 시간쓰지 마시고 적당히 찾아서 안나오면 그냥 물어보시면 좋을 것 같습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빌더 패턴을 이해하고, 변화시켜 응용하려고 하신점은 훌륭하신것 같습니다

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정적 팩토리 메서드 알아보고 반영하겠습니다

}
39 changes: 39 additions & 0 deletions src/main/java/codesquad/domain/Promotion.java
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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메서드 이름은
[짧은 것 << 의도가 잘 나타나는 것] 순으로 우선순위를 주는게 좋을 것 같아요

조금 길더라도 isSameType과 같은식으로 누가봐도 중의적으로 해석 되지 않을 메서드 명을 사용하면 좋을 것 같습니다.

isType 이라고 해서 전달한 타입이 올바른 타입 객체인지 유효성 검증하는 메서드인가 잠깐 생각했습니다.

return this.type == promotionType;
}
}
8 changes: 8 additions & 0 deletions src/main/java/codesquad/domain/PromotionRepository.java
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> {
}
5 changes: 5 additions & 0 deletions src/main/java/codesquad/domain/PromotionType.java
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
}
23 changes: 23 additions & 0 deletions src/main/java/codesquad/dto/FindingEmailDTO.java
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;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 DTO는 불변객체가 아닐 이유가 없는 객체로 보입니다. (데이터가 많지 않네용)
Setter를 두면, 다른 클라이언트가 사용시에 동기화도 보장 할 수 없고, 불변성이 보장되지도 않는 단점이 있습니다.

final을 통해서 필드들의 불변성이 보장되는 불변 객체로 만들면 좋을 것 같습니다. (Setter는 꼭 필요할 때만 쓰고, 안쓸 수 있다면 안써야합니다)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어떻게 수정하실건지도 들려주세요!
불변 객체에 대해 찾아보시길 권합니다!

26 changes: 26 additions & 0 deletions src/main/java/codesquad/dto/FindingPasswordDTO.java
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위와 같은듯 합니다

}
6 changes: 6 additions & 0 deletions src/main/java/codesquad/exception/UnAuthorizedException.java
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) {
}
Copy link
Collaborator

@dadadamarine dadadamarine Oct 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super(s)가 없는 이유가 있나요?.?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

실수로 빼먹은 것 같습니다. super(s)는 문자열 s를 파라미터로 받는 부모 클래스인 runtimeExeption의 생성자를 호출합니다.

}
8 changes: 4 additions & 4 deletions src/main/java/codesquad/interceptor/AdminInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import codesquad.domain.Account;
import codesquad.exception.NotAdminException;
import codesquad.utils.SessionUtil;
import codesquad.sequrity.HttpSessionUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

Expand All @@ -15,13 +15,13 @@ public class AdminInterceptor extends HandlerInterceptorAdapter {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
log.info("-------------------------log-----------------------------");
log.info("session info: {}", request.getSession().getAttribute(SessionUtil.SESSIONED_USER));
log.info("session info: {}", request.getSession().getAttribute(HttpSessionUtils.SESSIONED_USER));

Object session = request.getSession().getAttribute(SessionUtil.SESSIONED_USER);
Object session = request.getSession().getAttribute(HttpSessionUtils.SESSIONED_USER);
Account sessionedAccount = (Account) session;

if (sessionedAccount == null) {
response.sendRedirect("/login");
response.sendRedirect("/member/login");

return false;
}
Expand Down
Loading