-
Notifications
You must be signed in to change notification settings - Fork 1
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
코드 리뷰~ #4
Open
parksooo
wants to merge
5
commits into
main
Choose a base branch
from
3-code-review
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
코드 리뷰~ #4
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ba7c924
[feat] : review member, location
parksooo 5e95967
[feat] : review Group, GroupMember
iko-ilko 2ff3936
[feat] : review Api, Search, OAuthToken
leeesooha 24cbdf4
[feat] : review Join, Exception
leeesooha a3e383e
[feat] : review Security, Jwt, Oauth, Logout
leeesooha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package kr.where.backend.join; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import kr.where.backend.api.exception.JsonException; | ||
import kr.where.backend.auth.authUser.AuthUser; | ||
import kr.where.backend.auth.authUser.AuthUserInfo; | ||
import kr.where.backend.join.swagger.JoinApiDocs; | ||
import kr.where.backend.jwt.dto.ResponseRefreshTokenDTO; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/v3/join") | ||
public class JoinController implements JoinApiDocs { | ||
private final JoinService joinService; | ||
|
||
@PostMapping("") | ||
public ResponseEntity<ResponseRefreshTokenDTO> join(@AuthUserInfo final AuthUser authUser) { | ||
|
||
return ResponseEntity.ok(joinService.join(authUser)); | ||
} | ||
} |
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,47 @@ | ||
package kr.where.backend.join; | ||
|
||
import kr.where.backend.api.HaneApiService; | ||
import kr.where.backend.api.json.CadetPrivacy; | ||
import kr.where.backend.auth.authUser.AuthUser; | ||
import kr.where.backend.jwt.dto.ResponseRefreshTokenDTO; | ||
import kr.where.backend.join.exception.JoinException; | ||
import kr.where.backend.jwt.JwtService; | ||
import kr.where.backend.member.Member; | ||
import kr.where.backend.member.MemberService; | ||
import kr.where.backend.member.exception.MemberException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class JoinService { | ||
private static final String TOKEN_HANE = "hane"; | ||
private final MemberService memberService; | ||
private final HaneApiService haneApiService; | ||
private final JwtService jwtService; | ||
|
||
@Transactional | ||
public ResponseRefreshTokenDTO join(final AuthUser authUser) { | ||
final Member member = memberService.findOne(authUser.getIntraId()) | ||
.orElseThrow(MemberException.NoMemberException::new); | ||
if (member.isAgree()) { | ||
throw new JoinException.DuplicatedJoinMember(); | ||
} | ||
memberService.createAgreeMember( | ||
CadetPrivacy | ||
.builder() | ||
.build(), | ||
haneApiService | ||
.getHaneInfo(member.getIntraName(), TOKEN_HANE) | ||
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. TOKEN_HANE의 값이 "hane" 로 설정되어있습니다. 그런데 TOKEN_HANE를 쓰는곳을 계속 따라 들어가니 아래 코드가 나왔습니다.
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. HANE string이 그냥 들어가지 않고, 디비에서 token 이름이 'hane'인 컬럼을 조회해서 사용합니다 |
||
); | ||
|
||
return ResponseRefreshTokenDTO | ||
.builder() | ||
.refreshToken( | ||
jwtService.createRefreshToken(authUser.getIntraId(), authUser.getIntraName()) | ||
) | ||
.build(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/kr/where/backend/join/exception/JoinErrorCode.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,14 @@ | ||
package kr.where.backend.join.exception; | ||
|
||
import kr.where.backend.exception.ErrorCode; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum JoinErrorCode implements ErrorCode { | ||
DUPLICATED_JOIN(1700, "이미 동의한 유저입니다"); | ||
|
||
private final int errorCode; | ||
private final String errorMessage; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/kr/where/backend/join/exception/JoinException.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,15 @@ | ||
package kr.where.backend.join.exception; | ||
|
||
import kr.where.backend.exception.CustomException; | ||
|
||
public class JoinException extends CustomException { | ||
public JoinException(final JoinErrorCode joinErrorCode) { | ||
super(joinErrorCode); | ||
} | ||
|
||
public static class DuplicatedJoinMember extends JoinException { | ||
public DuplicatedJoinMember() { | ||
super(JoinErrorCode.DUPLICATED_JOIN); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/kr/where/backend/join/swagger/JoinApiDocs.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,28 @@ | ||
package kr.where.backend.join.swagger; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import kr.where.backend.api.exception.JsonException; | ||
import kr.where.backend.auth.authUser.AuthUser; | ||
import kr.where.backend.auth.authUser.AuthUserInfo; | ||
import kr.where.backend.jwt.dto.ResponseRefreshTokenDTO; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
|
||
@Tag(name = "join", description = "join API") | ||
public interface JoinApiDocs { | ||
@Operation(summary = "3.1 JoinMember API", description = "동의 맴버 생성하는 Post API", | ||
responses = { | ||
@ApiResponse(responseCode = "200", description = "맴버 생성 성공", | ||
content = @Content(schema = @Schema(implementation = ResponseRefreshTokenDTO.class))), | ||
@ApiResponse(responseCode = "404", description = "맴버 생성 실패", | ||
content = @Content(schema = @Schema(implementation = JsonException.class))) | ||
} | ||
|
||
) | ||
@PostMapping("") | ||
ResponseEntity<ResponseRefreshTokenDTO> join(@AuthUserInfo final AuthUser authUser); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
아직 어느 상황에서 빌더 패턴을 사용하는게 좋은지 잘 모르겠습니다.
보통 객체를 생성 할 때 생성자에서 사용하는것보다 가독성이 좋아서 사용하는걸까요????
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.
음 많은이유가 있는데, 개인의 취향이라고 생각하면 편합니다
빌더 패턴을 쓰는 이유는 생성자를 사용시 변수를 지정하지 않으면 null로 채우주는 편리성 때문에 사용하는데
저같은 경우에는 가독성 측면에 좋아보여서 사용합니다.