-
Notifications
You must be signed in to change notification settings - Fork 70
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
[team-31] 데이먼 3주차 1번째 PR 요청 #236
base: team-31
Are you sure you want to change the base?
Changes from all commits
76c7816
88959d8
255ea03
c108ed1
9f6b7f2
cf605c5
a45bbac
7bc2761
63220f0
63fbab4
a8452c4
15335aa
0158fca
3c5bd32
3c6bcf4
ad584e6
8720160
2cf586a
ac84249
48eacb0
d378d61
a925f97
bfbfd5d
4252772
fd970fe
71d418b
61d8f3d
d54b505
f327a27
980812c
4bd74be
99dc6b9
ea95188
8f7a2ab
136fb85
cb09f89
55d478a
330e6ad
2588314
051e0db
4c0ee73
e9e5ff9
6ab7f22
f2d9f42
fe5d8f1
8bc243d
c2cf89c
d1b086c
3829105
c255b26
175c412
634cbf8
c5cb45c
3f331aa
4b08528
c9766f6
e83f296
268bdc3
e724a99
17b4f4c
2cabec0
d9d4cd9
f160e26
bb3ed63
e67e54d
2a82190
c594140
d93f419
ab7a951
4045917
3edc806
890f5aa
abd2cd3
cfd3168
314d2cf
667e18c
6f77896
e7c4094
ef02b32
1b83dfc
7e53aa5
fa33c1e
f1279ae
8cbe36d
fd7547c
d944723
052bc45
571fe4a
42c9c13
1488fac
6b66bb8
ecc2e59
513f83a
878870e
ed6956e
1f6bf0e
133172d
8776ded
76332a4
c02cf28
b53c17d
7cb228c
ed448a0
e041e10
d005123
967b48c
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package com.team31.codesquad.issuetracker.config.mvc; | ||
|
||
import com.team31.codesquad.issuetracker.config.mvc.annotation.LoginName; | ||
import com.team31.codesquad.issuetracker.config.mvc.annotation.LoginUser; | ||
import com.team31.codesquad.issuetracker.domain.user.UserRepository; | ||
import com.team31.codesquad.issuetracker.util.JwtUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.core.MethodParameter; | ||
|
@@ -12,12 +13,13 @@ | |
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class LoginNameArgumentResolver implements HandlerMethodArgumentResolver { | ||
public class LoginUserArgumentResolver implements HandlerMethodArgumentResolver { | ||
|
||
private final JwtUtil jwtUtil; | ||
private final UserRepository userRepository; | ||
|
||
@Override public boolean supportsParameter(MethodParameter parameter) { | ||
return parameter.getParameterAnnotation(LoginName.class) != null; | ||
return parameter.getParameterAnnotation(LoginUser.class) != null; | ||
} | ||
|
||
@Override | ||
|
@@ -32,10 +34,10 @@ public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer m | |
|
||
String token = authorizationHeader.substring(7); | ||
if (token.equals(jwtUtil.getAdminPassword())) { | ||
return jwtUtil.getAdminLoginName(); | ||
return userRepository.findByLoginName(jwtUtil.getAdminLoginName()); | ||
} | ||
|
||
String loginName = jwtUtil.getPayload(token); | ||
System.out.println("loginName = " + loginName); | ||
return loginName; | ||
return userRepository.findByLoginName(loginName); | ||
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.
따라서 서비스 레이어에서 User를 검색하는 코드를 한곳에 모을 수 있었는데 이렇게 되면 컨트롤러에서 도메인에 대한 의존성이 필연적으로 생기게 됩니다. LINK 에서는 Service 레이어가 도메인을 캡슐화하는 계층이라고 언급하고 있는데 컨트롤러에서의 도메인 의존에 대해서 피터는 어떻게 생각하시는지 궁금합니다. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.team31.codesquad.issuetracker.config.querydsl; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import javax.persistence.EntityManager; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class QuerydslConfig { | ||
|
||
@Bean | ||
public JPAQueryFactory jpaQueryFactory(EntityManager em) { | ||
return new JPAQueryFactory(em); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,10 +57,14 @@ public Comment(Issue issue, User author, String content) { | |
this.systemMessage = false; | ||
} | ||
|
||
public static Comment createStatusChangeComment(Issue issue, | ||
IssueStatus status, User statusChangeUser) { | ||
public Comment(User author, String content) { | ||
this.author = author; | ||
this.content = content; | ||
this.systemMessage = false; | ||
} | ||
|
||
public static Comment createStatusChangeComment(IssueStatus status, User statusChangeUser) { | ||
Comment comment = new Comment(); | ||
comment.issue = issue; | ||
comment.author = statusChangeUser; | ||
comment.content = | ||
status.equals(IssueStatus.OPEN) ? ISSUE_OPEN_MESSAGE : ISSUE_CLOSED_MESSAGE; | ||
|
@@ -79,8 +83,8 @@ public void validateIssue(Long issueId) { | |
} | ||
} | ||
|
||
public void validateAuthor(String loginName) { | ||
if (!loginName.equals(getAuthor().getLoginName())) { | ||
public void validateAuthor(User user) { | ||
if (!user.equals(getAuthor())) { | ||
Comment on lines
+86
to
+87
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. user를 전체가 비교하기보단, user의 unique한 값을 꺼내서 check하는건 어떨까요? |
||
throw new IllegalArgumentException("작성자만 접근이 가능합니다."); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
package com.team31.codesquad.issuetracker.domain.comment; | ||
|
||
import com.team31.codesquad.issuetracker.domain.issue.Issue; | ||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface CommentRepository extends JpaRepository<Comment, Long> { | ||
|
||
List<Comment> findAllByIssue(Issue issue); | ||
} |
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.
👍