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

[댓글 기능] 제이 미션 제출합니다. #107

Merged
merged 72 commits into from
Aug 3, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
dd87430
docs: Readme 업데이트
MrKwon Jul 9, 2019
a2287b4
feat: 게시글 생성, 목록 조회 기능 구현
MrKwon Jul 9, 2019
940525c
feat: 게시글 조회 구현
MrKwon Jul 9, 2019
5430d29
feat: 공통 Head 분리
MrKwon Jul 9, 2019
1f9ef73
feat: html 중복제거
JunHoPark93 Jul 10, 2019
8dced8c
feat: 게시글 수정
JunHoPark93 Jul 10, 2019
9a3475c
feat: 게시글 삭제 구현
JunHoPark93 Jul 10, 2019
8731d42
feat: devtools 적용
JunHoPark93 Jul 10, 2019
66751cd
refactor: Js 분리
JunHoPark93 Jul 10, 2019
8901bf4
refactor: 컨트롤러 메서드 이름 수정, autowired 삭제
JunHoPark93 Jul 10, 2019
07ebbc1
refactor: 불필요한 메서드 제거
JunHoPark93 Jul 10, 2019
f2e700e
feat: Article 제목 검증 추가
JunHoPark93 Jul 11, 2019
1961b76
feat: error 페이지 추가
JunHoPark93 Jul 11, 2019
f44d9ff
refactor: 피드백 반영
JunHoPark93 Jul 15, 2019
8ef6ba5
feat: Jpa repository 적용
JunHoPark93 Jul 16, 2019
dc2a199
Merge branch 'temp' into JunHoPark93
JunHoPark93 Jul 16, 2019
087e5e0
docs: README 업데이트
JunHoPark93 Jul 16, 2019
15e570a
feat: 회원 등록 기능
JunHoPark93 Jul 16, 2019
47ae91d
feat: 유저 조회 기능 구현
JunHoPark93 Jul 16, 2019
6e9726b
feat: 로그인 및 로그아웃 기능 구현
JunHoPark93 Jul 17, 2019
c2ea962
feat: 회원 수정 및 탈퇴기능 구현
JunHoPark93 Jul 17, 2019
e6f5579
refactor: html 중복제거 및 세션적용
JunHoPark93 Jul 18, 2019
3e2bd3e
fix: Interceptor에서 /users post요청은 통과
JunHoPark93 Jul 18, 2019
63235c6
feat: Error 객체의 정의
JunHoPark93 Jul 18, 2019
924cee2
test: 세션관련 인수테스트 작성
JunHoPark93 Jul 18, 2019
7c83e30
test: 회원관련 인수테스트
JunHoPark93 Jul 18, 2019
bb280ba
refactor: 들여쓰기 및 사용하지 않는 import 제거
JunHoPark93 Jul 18, 2019
e00061f
feat: 회원가입시 이메일 중복 오류 처리
JunHoPark93 Jul 18, 2019
614121c
fix: 회원 가입시 email 중복 테스트 수정
JunHoPark93 Jul 18, 2019
8d0188b
refactor: UserService 분리
JunHoPark93 Jul 18, 2019
7a76891
feat: 회원 수정시 이름 형식 오류 처리
JunHoPark93 Jul 18, 2019
2553842
feat: 회원 가입시 유효하지 않은 입력 처리
JunHoPark93 Jul 18, 2019
c2f89df
refactor: Article 서비스 패키지 분리
JunHoPark93 Jul 18, 2019
dbe40f5
fix: 유저 리스트에서 다른 유저 정보에 접근하는 오류 처리
JunHoPark93 Jul 19, 2019
8985502
feat: 데이터베이스 구축
JunHoPark93 Jul 19, 2019
e537451
refactor: 삼항 연산자로 변경
JunHoPark93 Jul 19, 2019
c48f2f6
refactor: 삼항 연산자로 변경
JunHoPark93 Jul 19, 2019
e2fec3b
fix: 게시글 id 접근하는 로직 수정
JunHoPark93 Jul 19, 2019
6f21dfa
fix: 절대 경로로 변경
JunHoPark93 Jul 19, 2019
0ed6e1b
refactor: 삼항 연산자로 변경, url 변경
JunHoPark93 Jul 19, 2019
615e6fd
refactor: fragments 패키지로 분리
JunHoPark93 Jul 19, 2019
0e6e088
refactor: 피드백 반영
JunHoPark93 Jul 19, 2019
5447551
feat: 비밀번호 암호화 구현
JunHoPark93 Jul 20, 2019
cefea32
refactor: implements 삭제
JunHoPark93 Jul 20, 2019
b4d7ea5
feat: 비밀번호, 이메일 검증 로직 개선
JunHoPark93 Jul 22, 2019
e42ed91
feat: 검증 로직 추가
JunHoPark93 Jul 22, 2019
b90115e
fix: 없는 게시물 접근 처리
JunHoPark93 Jul 22, 2019
9f8190b
test: 테스트 파라미터 추가
JunHoPark93 Jul 22, 2019
59eaeb7
fix: email validation 추가
JunHoPark93 Jul 22, 2019
95ae854
test: cookie를 이용한 테스트
JunHoPark93 Jul 23, 2019
09b41c6
refactor: 피드백 반영
JunHoPark93 Jul 23, 2019
840253b
refactor: localport 제거
JunHoPark93 Jul 23, 2019
49fbaa5
refactor: 패키지 이름 변경
JunHoPark93 Jul 23, 2019
52a6d6c
refactor: 클래스 이름 변경
JunHoPark93 Jul 23, 2019
f4537c5
Merge remote-tracking branch 'upstream/JunHoPark93' into JunHoPark93
JunHoPark93 Jul 25, 2019
ed42da0
feat: paging 적용
JunHoPark93 Jul 26, 2019
cabf579
feat: article, user 관계 매핑
JunHoPark93 Jul 26, 2019
ccb502d
feat: article 작성자 매핑 기능 추가
JunHoPark93 Jul 26, 2019
8eb91d1
feat: Comment 작성, 조회
JunHoPark93 Jul 29, 2019
cc93b1a
feat: Comment 수정, 삭제
JunHoPark93 Jul 29, 2019
5304a84
refactor: comment redirect
JunHoPark93 Jul 30, 2019
0c28a01
feat: Comment 시간 계산
JunHoPark93 Jul 30, 2019
b4ef0a2
fix: 타인이 게시글 삭제 막기
JunHoPark93 Jul 30, 2019
85ff44c
test: 삭제 테스트 수정 및 정리
JunHoPark93 Jul 30, 2019
c915849
feat: JPA auditing 적용
JunHoPark93 Jul 31, 2019
fc5aa5c
feat: Comment 응답 dto에 대한 Custom Mapper의 구현
JunHoPark93 Jul 31, 2019
ed0e739
refactor: test 중복제거
JunHoPark93 Jul 31, 2019
e743f49
feat: JPA auditing, custom Context holder 적용
JunHoPark93 Aug 1, 2019
411388d
fix: session holder 코드 원복
JunHoPark93 Aug 2, 2019
6be9e90
refactor: Comment 검증 로직
JunHoPark93 Aug 2, 2019
c1b252e
feat: CoverUrl resource의 존재 확인
JunHoPark93 Aug 2, 2019
8454227
test: coverUrl 경로 수정
JunHoPark93 Aug 2, 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
8 changes: 8 additions & 0 deletions src/main/java/techcourse/myblog/config/ExceptionHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.web.bind.annotation.ControllerAdvice;
import techcourse.myblog.exception.ErrorMessage;
import techcourse.myblog.exception.LoginException;
import techcourse.myblog.exception.SignUpException;

@ControllerAdvice
public class ExceptionHandler {
Expand All @@ -13,4 +14,11 @@ public String handleLoginException(LoginException e, Model model) {
model.addAttribute("error", errorMessage);
return "login";
}

@org.springframework.web.bind.annotation.ExceptionHandler(SignUpException.class)
public String handleSignUpException(SignUpException e, Model model) {
ErrorMessage errorMessage = new ErrorMessage(e.getMessage());
model.addAttribute("error", errorMessage);
return "signup";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package techcourse.myblog.exception;

public class SignUpException extends RuntimeException {
public SignUpException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.FIELD)
@Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = EmailConstraintValidator.class)
public @interface EmailConstraint {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package techcourse.myblog.validator;

import techcourse.myblog.domain.UserRepository;
import techcourse.myblog.exception.LoginException;
import techcourse.myblog.exception.SignUpException;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
Expand All @@ -23,14 +25,6 @@ public boolean isValid(String value, ConstraintValidatorContext context) {
return false;
}

boolean isExist = userRepository.existsByEmail(value);
if (isExist) {
context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate("이메일 중복")
.addConstraintViolation();
return false;
}

return true;
return !userRepository.existsByEmail(value);

Choose a reason for hiding this comment

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

아, 이런 로직이 있었군요.
Dto와 Repository가 연관관계가 형성되는 것이 좋은 구조인지는 의문이 드네요.
Presentation Layer에서의 값 검증과 Service Layer, Domain Layer에서 각각에서의 유효성 검증은 다르다고 생각해요.
Dto에서는 값의 형식 등을 테스트하는 것이 좋다고 생각합니다
https://stackoverflow.com/questions/21073878/validation-in-3-tier-architecture

}
}
7 changes: 6 additions & 1 deletion src/main/java/techcourse/myblog/web/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import techcourse.myblog.exception.LoginException;
import techcourse.myblog.domain.User;
import techcourse.myblog.domain.UserRepository;
import techcourse.myblog.dto.UserDto;
import techcourse.myblog.dto.UserLoginDto;
import techcourse.myblog.dto.UserResponseDto;
import techcourse.myblog.exception.SignUpException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
Expand Down Expand Up @@ -39,7 +41,10 @@ public String createSignForm() {
}

@PostMapping("/users")
public String saveUser(@Valid UserDto userDto, HttpSession httpSession) {
public String saveUser(@Valid UserDto userDto, BindingResult bindingResult, HttpSession httpSession) {
if (bindingResult.hasErrors()) {
throw new SignUpException("email 중복");
}
User user = new User(userDto.getName(), userDto.getEmail(), userDto.getPassword());
userRepository.save(user);

Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/templates/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<head th:replace="signup-head :: signUpHead"></head>

<body>
<div th:unless="${error} == null" class="alert alert-danger" th:text="${error.errorMessage}">
Invalid username or password.
</div>
<div class="app">
<div class="header navbar bg-transparent no-border">
<div class="header-container pdd-right-15">
Expand Down