-
Notifications
You must be signed in to change notification settings - Fork 3
[Board] 1차 제출입니다! #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
Merged
Merged
Changes from 22 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
95886ea
docs: 기능 구현 목록 작성 및 member 도메인 exception 뼈대 구현
moonwhistle efe1e89
feat: 회원 가입 기능 구현
moonwhistle d35c083
feat: 로그인 기능 구현
moonwhistle 10c682d
feat: interceptor 기능 구현
moonwhistle 242e533
feat: 리졸버 구현
moonwhistle 0a4e8bb
feat: 리졸버 등록
moonwhistle 66961ed
feat: 마이페이지 회원 조회 기능 구현
moonwhistle aa4cf67
feat: 마이페이지 유저 정보 수정 기능 구현
moonwhistle 6d60d48
feat: 마이페이지 계정 탈퇴 기능 구현
moonwhistle 8d6a824
feat: 게시글 생성 기능 구현
moonwhistle 278f6bc
feat: api 테스트를 위한 더미 데이터 추가 기능 구현
moonwhistle 56e5bda
feat: 모든 게시글 조회 기능 구현
moonwhistle e2c2fac
feat: 게시글 단건 조회 기능 구현
moonwhistle 8c4ab2e
feat: 유저 게시글 조회 기능 구현
moonwhistle a4d046b
feat: 게시글 수정 기능 구현
moonwhistle 8c76392
feat: 게시글 삭제 기능 구현
moonwhistle 45e43f5
feat: 댓글 등록 기능 구현
moonwhistle 71d4d4c
feat: 특정 게시글 댓글 조회 기능 구현
moonwhistle 65c75e4
feat: 특정 유저의 댓글 조회 기능 구현
moonwhistle 3f8b554
feat: 댓글 수정 기능 구현
moonwhistle 1ee872c
feat: 댓글 삭제 기능 구현
moonwhistle f2e6d77
feat: swagger 세팅
moonwhistle 5205805
feat: ArticleRepositoryTest 구현
moonwhistle 77fffbb
feat: MemberRepositoryTest 구현
moonwhistle 90637c5
feat: CommentRepositoryTest 구현
moonwhistle 73545cc
refactor: prefix endpoint 를 위한 .yml 파일 작성 및 그에 따른 코드 수정
moonwhistle 9e49589
refactor: error 코드 재사용성을 위한 전체적인 error 코드 구조 수정
moonwhistle 1b81f17
feat: memberServiceTest 구현
moonwhistle ba530b0
feat: CommentServiceTest 구현
moonwhistle 00747c4
feat: ArticleServiceTest 구현
moonwhistle 8d5944b
refactor: 토큰 로직 관련 책임에 따라 메서드 분리
moonwhistle 912c548
feat: AuthServiceTest 구현
moonwhistle 7ae9e51
feat: MemberControllerTest 구현
moonwhistle 12703b3
feat: AuthControllerTest 구현
moonwhistle a8fedce
feat: ArticleControllerTest 구현
moonwhistle d91b26e
feat: CommentControllerTest 구현
moonwhistle 56eb314
feat: offset paging 기능 구현
moonwhistle 37b8313
feat: no-offset paging 기능 구현
moonwhistle 34eaf88
fix: http method 검증을 통해 비회원도 게시글을 조회할 수 있도록 로직 수정
moonwhistle 3537df3
refactor: interceptor allow uri 명시적으로 변경
moonwhistle 4b913db
feat: 비밀번호 암호화 기능 구현
moonwhistle 07cb5e0
refactor: DDD 설계를 통한 로직 구조 변경
moonwhistle c4b57e4
refactor: Member 역참조 수정 및 테스트 코드 수정
moonwhistle 78137cc
refactor: Comment 역참조 수정 및 테스트 코드 수정
moonwhistle b9430f7
refactor: Article 역참조 수정 및 테스트 코드 수정
moonwhistle fcc6f76
feat: Article 삭제 시, Comment 도 같이 삭제되는 기능 구현
moonwhistle 3eabf85
feat: Member 삭제 시, Article 작성자와 Comment 작성자 알 수 없음 처리 기능 구현
moonwhistle d0b81ea
refactor: get / find 컨벤션에 따라 네이밍 리팩토링
moonwhistle 5e146bc
refactor: article paging 반환값을 페이지 정보를 포함해서 반환하도록 리팩토링
moonwhistle e1c23f1
refactor: comment paging 반환값을 페이지 정보를 포함해서 반환하도록 리팩토링
moonwhistle aaade75
docs: 코드 리뷰 생각 정리
moonwhistle be18184
feat: article / comment 객체 연관관계를 간접참조로 수정 및 article 삭제 시, comment 도 삭…
moonwhistle 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 hidden or 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
This file contains hidden or 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,87 @@ | ||
| ## **Java Bean Validation: `@NotNull`, `@NotEmpty`, `@NotBlank` 차이점** | ||
|
|
||
| --- | ||
|
|
||
| ### 1. @NotNull | ||
|
|
||
| * null 값만 허용하지 않음 | ||
| * 빈 값("")과 공백(" ")은 허용됨 | ||
|
|
||
| ### 2. @NotEmpty | ||
|
|
||
| * null 값과 빈 값("") 모두 허용되지 않음 | ||
| * 공백(" ")은 허용됨 | ||
|
|
||
| ### 3. @NotBlank | ||
|
|
||
| * null 값, 빈 값(""), 공백(" ") 모두 허용되지 않음 | ||
|
|
||
| **회원 가입 시, @NotBlank 어노테이션 활용하는 것이 좋을 것 같음** | ||
|
|
||
|
|
||
| ## **Lombok의 생성자 어노테이션 비교 (`@AllArgsConstructor`, `@RequiredArgsConstructor`, `@NoArgsConstructor`)** | ||
|
|
||
| --- | ||
|
|
||
| ### 1. @AllArgsConstructor | ||
|
|
||
| * 클래스의 모든 필드를 초기화하는 생성자를 자동 생성 | ||
| * @NonNull 필드가 null이면 NullPointerException 발생 | ||
|
|
||
| ### 2. @RequiredArgsConstructor | ||
|
|
||
| * final 필드 및 @NonNull 필드만 포함하는 생성자를 생성 | ||
| * 초기화된 final 필드는 생성자에서 제외됨 | ||
|
|
||
| ### 3. @NoArgsConstructor | ||
|
|
||
| * 매개변수가 없는 기본 생성자를 생성 | ||
| * final 필드가 있을 경우 force = true 옵션 필요 | ||
|
|
||
| ### JPA 에서 기본 생성자가 필요한 이유(protected 쓰는 이유까지) | ||
|
|
||
| 1. JPA는 데이터베이스에서 조회한 결과를 기반으로 엔티티 객체를 생성해야 합니다. | ||
| 2. Reflection을 이용하여 객체를 만들기 때문에, 기본 생성자가 반드시 필요합니다. | ||
| 3. 외부에서 기본 생성자를 직접 호출하는 것을 막기 위해 protected 사용합니다. | ||
| 3. 만약 기본 생성자가 없으면 InstantiationException 오류 발생! | ||
|
|
||
|
|
||
| ## @RequestParam vs @PathVariable 차이점 | ||
|
|
||
| --- | ||
|
|
||
| ### 1. @RequestParam | ||
|
|
||
| * `@RequestParam`은 **쿼리 문자열**에서 값을 추출합니다. - (쿼리 파라미터) | ||
| * 예시 | ||
| ~~~ | ||
| @GetMapping("/foos") | ||
| @ResponseBody | ||
| public String getFooByIdUsingQueryParam(@RequestParam String id) { | ||
| return "ID: " + id; | ||
| } | ||
| ~~~ | ||
|
|
||
| 해당 요청을 처리하는 URL는 다음과 같습니다. - > `http://localhost:8080/spring-mvc-basics/foos?id=abc` | ||
|
|
||
| * @RequestParam은 URL 디코딩되어 값을 추출합니다. | ||
| `http://localhost:8080/foos?id=ab+c` -> `ab c` 를 추출합니다. (+ 가 공백으로 디코딩 됌) | ||
| * @RequestParam은 필터링이나 검색 조건을 전달할 때 유용합니다. | ||
|
|
||
| ### 2. @PathVariable | ||
|
|
||
| * `@PathVariable`은 **URI 경로**에서 값을 추출합니다. - (URI 경로) | ||
| * 예시 | ||
| ~~~ | ||
| @GetMapping({"/myfoos/optional", "/myfoos/optional/{id}"}) | ||
| @ResponseBody | ||
| public String getFooByOptionalId(@PathVariable(required = false) String id){ | ||
| return "ID: " + id; | ||
| } | ||
| ~~~ | ||
|
|
||
| 해당 요청을 처리하는 URL 은 다음과 같습니다. -> `http://localhost:8080/spring-mvc-basics/myfoos/optional/abc` | ||
|
|
||
| * @PathVariable은 URI 경로에서 값을 추출하기 때문에 값이 인코딩되지 않습니다. | ||
| `http://localhost:8080/foos/id=ab+c` -> `ab+b` 값을 정확하게 추출합니다. | ||
| * @PathVariable은 주로 리소스를 식별할 때 유용합니다. |
This file contains hidden or 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,23 @@ | ||
| ## @Transactional(readOnly = true) 를 사용한 경우 vs 사용하지 않은 경우 | ||
|
|
||
| --- | ||
|
|
||
| ### 1. @Transactional(readOnly = true)를 사용하지 않은 경우 | ||
|
|
||
| 1. 트랜잭션이 시작됩니다. | ||
| 2. SELECT 쿼리를 실행하여 데이터 조회합니다. | ||
| 3. 트랜잭션이 쓰기 모드이므로 변경 감지(Dirty Checking)가 활성화됩니다. | ||
| 4. 조회한 엔티티를 영속성 컨텍스트(Persistence Context)에 저장합니다. | ||
| 5. JPA가 Book 엔티티를 관리하기 시작합니다. | ||
| 6. 트랜잭션이 종료되면, 변경된 엔티티가 있으면 UPDATE 쿼리를 실행합니다. | ||
| 7. 변경이 없어도 flush()가 호출되면서 DB와 동기화 수행합니다. → 불필요한 성능 저하 가능 | ||
|
|
||
|
|
||
| ### 2. @Transactional(readOnly = true) 사용한 경우 | ||
|
|
||
| 1. 트랜잭션이 시작됩니다. (READ ONLY) | ||
| 2. SELECT 쿼리를 실행하여 데이터 조회합니다. | ||
| 3. 쓰기 관련 기능(변경 감지, flush, dirty checking)이 비활성화 됩니다. | ||
| 4. JPA가 엔티티를 관리하지 않습니다. (영속성 컨텍스트 제외) | ||
| 5. 트랜잭션이 종료됩니다. | ||
|
|
This file contains hidden or 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,216 @@ | ||
| ## API | ||
|
|
||
| ### 유저 CRUD | ||
|
|
||
| * 회원가입 기능. | ||
| * endPoint : [POST, /api/members/signUp] | ||
| * 설명 : 이름, 닉네임, 아이디, 비밀번호 저장. / 아이디 중복 확인 기능, 닉네임 중복 확인 기능 포함 | ||
| * Exception : 아이디 중복 시, 닉네임 중복 시 | ||
| * request : | ||
| ~~~ | ||
| { | ||
| "memberName": "juna", | ||
| "memberNickName": "juju", | ||
| "memberLoginId": "aaa", | ||
| "memberPassword": "ssssss" | ||
| } | ||
| ~~~ | ||
| * response : url location, | ||
| ~~~ | ||
| { | ||
| "memberId": "1", | ||
| "token": "jwtToken" | ||
| } | ||
| ~~~ | ||
|
|
||
|
|
||
|
|
||
| * 로그인 기능. | ||
| * endPoint : [POST, /api/members/login] | ||
| * 설명 : 로그인 기능. 쿠키 생성, 세션 생성. | ||
| * Exception : 아이디 혹은 비밀번호가 일치하지 않을 경우. | ||
| * request : | ||
| ~~~ | ||
| { | ||
| "memberLoginId": "aaa", | ||
| "memberPassword": "ssssss" | ||
| } | ||
| ~~~ | ||
| * response : X | ||
|
|
||
| ### **모든 마이페이지 기능은 로그인 한 유저만 접근할 수 있도록 구현** | ||
|
|
||
| * 정보 수정 기능.(마이페이지) | ||
| * endPoint : [PATCH, /api/members] | ||
| * 설명 : 이름, 닉네임, 아이디, 비밀번호 수정. | ||
| * Exception : 로그인 정보 가져왔을 때 값이 없을 경우. | ||
| * request : | ||
| ~~~ | ||
| { | ||
| "memberName": "hun", | ||
| "memberNickName": "hhun", | ||
| "memberLoginId": "ddd", | ||
| "memberPassword": "sssss" | ||
| } | ||
| ~~~ | ||
| * response : x | ||
|
|
||
| * 멤버 정보 조회 기능(마이페이지) | ||
| * endPoint : [GET, /api/members] | ||
| * 설명 : 유저 정보 가져옴. | ||
| * Exception : 로그인 정보 가져왔을 때 값이 없을 경우. | ||
| * request : x | ||
| * response : member | ||
|
|
||
|
|
||
| * 계정 탈퇴 기능(마이페이지) | ||
| * endPoint : [DELETE, /api/members] | ||
| * 설명 : 유저 탈퇴. | ||
| * Exception : 로그인 정보 가져왔을 때 값이 없을 경우. | ||
| * request : x | ||
| * response : member | ||
|
|
||
| ### 게시물 CRUD | ||
|
|
||
| * 글 작성 기능. (해당 유저만 작성할 수 있도록.) | ||
| * endPoint : [POST, /api/articles] | ||
| * 설명 : 글 작성 | ||
| * Exception : 쿠키나 세션 가져왔을 때 값이 없을 경우. | ||
| * request : | ||
| ~~~ | ||
| { | ||
| "title": "가가가", | ||
| "content": "나나나" | ||
| } | ||
| ~~~ | ||
| * response : url location 으로 반환 | ||
|
|
||
|
|
||
| * 모든 글 조회 기능 (유저 아니여도 접근 가능) | ||
| * endPoint : [GET, /api/articles] | ||
| * 설명 : 글 모두 끌어오기 | ||
| * Exception : 작성된 글이 없을 경우 | ||
| * request : x | ||
| * response : 조회된 모든 글 반환 | ||
|
|
||
|
|
||
| * 글 하나만 조회하는 기능 (유저 아니어도 접근 가능) | ||
| * endPoint : [GET, api/articles/{articleId}] | ||
| * 설명 : 해당 글 조회하기 | ||
| * Exception : 작성된 글이 없을 경우 | ||
| * request : x | ||
| * response : 게시글 반환 | ||
|
|
||
|
|
||
| * 글 수정하는 기능 (해당 글쓴 유저만 접근 가능) | ||
| * endPoint : [GET, api/articles/{articleId}] | ||
| * 설명 : 해당 글 조회하기 | ||
| * Exception : 작성된 글이 없을 경우, 해당 게시물에 대한 권한이 없을 경우 | ||
| * request : | ||
| ~~~ | ||
| { | ||
| "title": "가", | ||
| "content": "나" | ||
| } | ||
| ~~~ | ||
| * response : 수정된 글 반환 | ||
|
|
||
|
|
||
| * 게시물 삭제 기능(해당 글쓴 유저만 삭제 가능) | ||
| * endPoint : [GET, api/articles/{articleId}] | ||
| * 설명 : 해당 글 삭제하기 | ||
| * Exception : 작성된 글이 없을 경우, 해당 게시물에 대한 권한이 없을 경우 | ||
| * request : X | ||
| * response : 삭제된 게시물 반환 | ||
|
|
||
|
|
||
| * 유저 글 모아보는 기능(마이페이지) | ||
| * endPoint : [GET, api/members/articles] | ||
| * 설명 : 유저에 해당하는 글만 모아 보기 | ||
| * Exception : 작성된 글이 없을 경우 | ||
| * request : X | ||
| * response : 유저의 모든 게시물 반환 | ||
|
|
||
|
|
||
| ### 댓글 CRUD | ||
|
|
||
|
|
||
| * 댓글 달기 기능.(유저만 접근 가능) | ||
| * endPoint : [POST, api/articles/{articleId}/comments] | ||
| * 설명 : 댓글 작성하기 | ||
| * Exception : 작성된 글이 없을 경우, 로그인 상태 아닐 경우 | ||
| * request : | ||
| ~~~ | ||
| { | ||
| "content": "노잼" | ||
| } | ||
| ~~~ | ||
| * response : 게시글 url 반환 (api/articles/{articleId}) | ||
|
|
||
|
|
||
| * 게시물에 대한 댓글 조회 기능.(유저 아니어도 접근 가능) | ||
| * endPoint : [GET, api/articles/{articleId}/comments] | ||
| * 설명 : 게시물에 대한 댓글 조회하기 | ||
| * Exception : 작성된 글이 없을 경우, 댓글 없을 경우 | ||
| * request : x | ||
| * response : | ||
| ~~~ | ||
| { | ||
| "commentResponses": [ | ||
| { | ||
| "articleId": 1, | ||
| "memberNickName": "juj", | ||
| "content": "노잼s" | ||
| }, | ||
| { | ||
| "articleId": 1, | ||
| "memberNickName": "juj", | ||
| "content": "노잼잼" | ||
| } | ||
| ] | ||
| } | ||
| ~~~ | ||
|
|
||
|
|
||
| * 댓글 수정 (해당 댓글 작성자만 수정 가능) | ||
| * endPoint : [PATCH, api/comments/{commentId}] | ||
| * 설명 : 댓글 수정하기 | ||
| * Exception : 작성된 글이 없을 경우, 댓글 없을 경우 | ||
| * request : | ||
| ~~~ | ||
| { | ||
| "content": "게시판" | ||
| } | ||
| ~~~ | ||
| * response : | ||
| ~~~ | ||
| { | ||
| "articleId": 1, | ||
| "memberNickName": "juj", | ||
| "content": "게시판" | ||
| } | ||
| ~~~ | ||
|
|
||
|
|
||
| * 댓글 삭제 (해당 댓글 작성자만 삭제 가능) | ||
| * endPoint : [DELETE, api/comments/{commentId}] | ||
| * 설명 : 댓글 삭제하기 | ||
| * Exception : 작성된 글이 없을 경우, 댓글 없을 경우 | ||
| * request : x | ||
| * response : | ||
| ~~~ | ||
| { | ||
| "articleId": 1, | ||
| "memberNickName": "juj", | ||
| "content": "게시판" | ||
| } | ||
| ~~~ | ||
|
|
||
|
|
||
| * 유저 댓글 모아 보는 기능(마이페이지) | ||
| * endPoint : [GET, api/members/comments] | ||
| * 설명 : 유저 댓글 조회하기 | ||
| * Exception : 작성된 글이 없을 경우, 댓글 없을 경우 | ||
| * request : | ||
| * response : 유저의 모든 댓글 | ||
| --- | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.