-
Notifications
You must be signed in to change notification settings - Fork 1
[INIT] Note 도메인 생성, 노트 생성 API 추가 및 에러 핸들러 추가 #159
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 59 commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
b4482b3
NoteController note 생성 api 추가
paragon0107 6dc26d3
메세지 추가
paragon0107 1bc3c4b
Note Entity 추가
paragon0107 dee3a72
누락된 team 추가
paragon0107 8d16299
request DTO 추가
paragon0107 bf9b75d
NoteCreateResponse 추가
paragon0107 6a1cb2e
NoteRepository 추가
paragon0107 0c2f939
NoteService 추가
paragon0107 4ffd98a
NoteAdapter 추가
paragon0107 c0930a9
NoteControllerDocs추가
paragon0107 6bde536
[FEAT] NoteController 추가
paragon0107 9920c8b
[FEAT] Note도메인 request, response DTO추가
paragon0107 87fef43
[FEAT] NoteFree 엔티티 추가
paragon0107 bb653e0
[FEAT] NoteTemplate 엔티티 추가
paragon0107 5bb11b4
[FEAT] NoteService 구현
paragon0107 aaf298a
[FEAT] NoteSaver 구현
paragon0107 b3f0e41
[FEAT] NoteRepository 구현
paragon0107 eab7fb4
[FEAT] SuccessMessage 추가
paragon0107 c3afbf2
[FEAT] NoteException 추가
paragon0107 ef3a303
[FEAT] Note ErrorCode 추가
paragon0107 385975d
[FEAT] 잘못된 json 형식 에러 핸들러 추가
paragon0107 c6755eb
[FEAT] 잘못된 json 형식 에러 핸들러 추가
paragon0107 ff6ec4a
[CHORE] 임시 커밋
paragon0107 598dc92
[FEAT] 글로벌 핸들러에 NoteException 추가
paragon0107 9b951a3
[CHORE] NoteException 잘못된 메서드 네이밍 수정
paragon0107 990bd9d
[CHORE] Note Entity, Base time 상속
paragon0107 ec26d31
[CHORE] 원시값을 레퍼값으로 포장
paragon0107 558526e
[FEAT] 에러 코드 추가
paragon0107 0b996f1
[FEAT] Note 엔티티 원시값을 레퍼값으로 변경
paragon0107 0cae74f
[CHORE] 검증 방식을 Valid에서 VO로 변경
paragon0107 65b7e62
[CHORE] 서비스단 DTO 추가, 역의존성 제거
paragon0107 5d74b27
[CHORE] 서비스단 DTO 추가
paragon0107 4cd3509
[CHORE] 기존 DTO 컨트롤러 부분으로 경로 변경
paragon0107 b9166f3
[CHORE] 기존 ResponseDTO 삭제
paragon0107 14e0f13
[CHORE] 포맷팅 적용
paragon0107 9f816fb
[CHORE] VO 삭제
paragon0107 94f0cf0
[CHORE] VO 삭제 및 Note 부모 엔티티 생성
paragon0107 db1396a
[CHORE] VO 삭제 반영
paragon0107 c460514
[CHORE] Note Entity 단일화
paragon0107 5c8f9ca
[CHORE] Note Entity 단일화
paragon0107 09c1d52
[CHORE] Note Entity 단일화
paragon0107 2369248
[CHORE] Note Entity 단일화
paragon0107 1d37f80
[CHORE] NoteCreateDTO DocumentIds, TimeBlockIds 추가
paragon0107 5270da1
[CHORE] NoteDocumentManager 엔티티 추가
paragon0107 5ae5d59
[FEAT] NoteDocumentManagerRepository 추가
paragon0107 fc104fd
[FEAT] NoteDocumentManagerSaver 추가
paragon0107 9af9281
[FEAT] NoteTimeBlockManager 추가
paragon0107 53b92f0
[FEAT] NoteTimeBlockManagerRepository 추가
paragon0107 142658b
[FEAT] NoteTimeBlockManagerSaver 추가
paragon0107 de6fe11
[FEAT] NoteService 구현
paragon0107 5aba62f
[CHORE] 포맷팅 적용
paragon0107 9fb449c
[CHORE] 일부 메서드, 변수 네이밍 수정
paragon0107 b603399
[CHORE] 컨트롤러단 Free, Template 재분리
paragon0107 ff29329
[CHORE] 컨트롤러단 Free, Template DTO 재분리
paragon0107 0f6459a
[CHORE] 서비스단 Free, Template DTO 재분리
paragon0107 18e5611
[CHORE] Note Entity 누락된 필드 추가
paragon0107 bc40f76
[FEAT] NoteEntity 추가
paragon0107 5e505ec
[FEAT] 노트 서비스 로직 수정
paragon0107 0a9c49d
[FEAT] 서비스 레이어 내 DTO 추가
paragon0107 f5491f5
[FEAT] 컨벤션 적용
paragon0107 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
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,17 @@ | ||
| package com.tiki.server.note.adapter; | ||
|
|
||
| import com.tiki.server.common.support.RepositoryAdapter; | ||
| import com.tiki.server.note.entity.Note; | ||
| import com.tiki.server.note.repository.NoteRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @RepositoryAdapter | ||
| @RequiredArgsConstructor | ||
| public class NoteSaver { | ||
|
|
||
| private final NoteRepository noteRepository; | ||
|
|
||
| public Note createNote(final Note note) { | ||
| return noteRepository.save(note); | ||
| } | ||
| } |
53 changes: 53 additions & 0 deletions
53
src/main/java/com/tiki/server/note/controller/NoteController.java
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,53 @@ | ||
| package com.tiki.server.note.controller; | ||
|
|
||
| import com.tiki.server.common.dto.SuccessResponse; | ||
| import com.tiki.server.common.support.UriGenerator; | ||
| import com.tiki.server.note.controller.dto.request.NoteFreeCreateRequest; | ||
| import com.tiki.server.note.controller.dto.request.NoteTemplateCreateRequest; | ||
| import com.tiki.server.note.service.NoteService; | ||
| import com.tiki.server.note.service.dto.request.NoteFreeCreateDTO; | ||
| import com.tiki.server.note.service.dto.request.NoteTemplateCreateDTO; | ||
| import com.tiki.server.note.service.dto.response.NoteCreateResponseDTO; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import java.security.Principal; | ||
|
|
||
| import static com.tiki.server.common.dto.SuccessResponse.success; | ||
| import static com.tiki.server.note.message.SuccessMessage.CREATE_NOTE_FREE; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/api/v1/notes") | ||
| public class NoteController { | ||
|
|
||
| private final NoteService noteService; | ||
|
|
||
| @PostMapping("/free") | ||
| public ResponseEntity<SuccessResponse<NoteCreateResponseDTO>> createNoteFree( | ||
| final Principal principal, | ||
| @RequestBody final NoteFreeCreateRequest request | ||
| ) { | ||
| long memberId = Long.parseLong(principal.getName()); | ||
| NoteCreateResponseDTO response = noteService.createNoteFree(NoteFreeCreateDTO.of(request, memberId)); | ||
| return ResponseEntity.created( | ||
| UriGenerator.getUri("/api/v1/notes" + response.noteId()) | ||
| ).body(success(CREATE_NOTE_FREE.getMessage(), response)); | ||
| } | ||
|
|
||
| @PostMapping("/template") | ||
| public ResponseEntity<SuccessResponse<NoteCreateResponseDTO>> createNoteTemplate( | ||
| final Principal principal, | ||
| @RequestBody final NoteTemplateCreateRequest request | ||
| ) { | ||
| long memberId = Long.parseLong(principal.getName()); | ||
| NoteCreateResponseDTO response = noteService.createNoteTemplate(NoteTemplateCreateDTO.of(request, memberId)); | ||
| return ResponseEntity.created( | ||
| UriGenerator.getUri("/api/v1/notes" + response.noteId()) | ||
| ).body(success(CREATE_NOTE_FREE.getMessage(), response)); | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/tiki/server/note/controller/dto/request/NoteFreeCreateRequest.java
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,20 @@ | ||
| package com.tiki.server.note.controller.dto.request; | ||
|
|
||
| import lombok.NonNull; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| public record NoteFreeCreateRequest( | ||
| @NonNull | ||
| String title, | ||
| boolean complete, | ||
| @NonNull LocalDate startDate, | ||
| @NonNull LocalDate endDate, | ||
| @NonNull String contents, | ||
| List<Long> timeBlockIds, | ||
| List<Long> documentIds, | ||
| long teamId | ||
|
|
||
| ) { | ||
| } | ||
22 changes: 22 additions & 0 deletions
22
src/main/java/com/tiki/server/note/controller/dto/request/NoteTemplateCreateRequest.java
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,22 @@ | ||
| package com.tiki.server.note.controller.dto.request; | ||
|
|
||
| import lombok.NonNull; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| public record NoteTemplateCreateRequest( | ||
| @NonNull | ||
| String title, | ||
| boolean complete, | ||
| @NonNull LocalDate startDate, | ||
| @NonNull LocalDate endDate, | ||
| @NonNull String answerWhatActivity, | ||
| @NonNull String answerHowToPrepare, | ||
| @NonNull String answerWhatIsDisappointedThing, | ||
| @NonNull String answerHowToFix, | ||
| @NonNull List<Long> timeBlockIds, | ||
| @NonNull List<Long> documentIds, | ||
| long teamId | ||
| ) { | ||
| } |
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,65 @@ | ||
| package com.tiki.server.note.entity; | ||
|
|
||
| import com.tiki.server.common.entity.BaseTime; | ||
| import jakarta.persistence.*; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| import static jakarta.persistence.GenerationType.IDENTITY; | ||
| import static lombok.AccessLevel.PRIVATE; | ||
| import static lombok.AccessLevel.PROTECTED; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| @Builder | ||
| @AllArgsConstructor(access = PRIVATE) | ||
| @NoArgsConstructor(access = PROTECTED) | ||
| public class Note extends BaseTime { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = IDENTITY) | ||
| @Column(name = "note_id") | ||
| private Long id; | ||
|
|
||
| private String title; | ||
|
|
||
| private boolean complete; | ||
|
|
||
| private LocalDate startDate; | ||
|
|
||
| private LocalDate endDate; | ||
|
|
||
| private long memberId; | ||
|
|
||
| private long teamId; | ||
|
|
||
| private String contents; | ||
|
|
||
| private NoteType noteType; | ||
|
|
||
| public static Note of( | ||
| final String title, | ||
| final boolean complete, | ||
| final LocalDate startDate, | ||
| final LocalDate endDate, | ||
| final String contents, | ||
| final long memberId, | ||
| final long teamId, | ||
| final NoteType noteType | ||
| ) { | ||
| return Note.builder() | ||
| .title(title) | ||
| .complete(complete) | ||
| .startDate(startDate) | ||
| .endDate(endDate) | ||
| .memberId(memberId) | ||
| .teamId(teamId) | ||
| .contents(contents) | ||
| .noteType(noteType) | ||
| .build(); | ||
| } | ||
| } |
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,6 @@ | ||
| package com.tiki.server.note.entity; | ||
|
|
||
| public enum NoteType { | ||
| FREE, | ||
| TEMPLATE | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/tiki/server/note/exception/NoteException.java
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,15 @@ | ||
| package com.tiki.server.note.exception; | ||
|
|
||
| import com.tiki.server.note.message.ErrorCode; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public class NoteException extends RuntimeException { | ||
|
|
||
| private final ErrorCode errorCode; | ||
|
|
||
| public NoteException(final ErrorCode errorCode) { | ||
| super("[NoteException] : " + errorCode.getMessage()); | ||
| this.errorCode = errorCode; | ||
| } | ||
| } |
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 @@ | ||
| package com.tiki.server.note.message; | ||
|
|
||
| import static org.springframework.http.HttpStatus.BAD_REQUEST; | ||
| import static org.springframework.http.HttpStatus.NOT_FOUND; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| public enum ErrorCode { | ||
|
|
||
| /* 400 BAD REQUEST : 잘못된 요청 */ | ||
| TITLE_IS_EMPTY(BAD_REQUEST, "제목은 필수 입력값 입니다."), | ||
| TITLE_LENGTH_OVER(BAD_REQUEST, "제목은 100자를 넘길 수 없습니다."), | ||
|
|
||
| /* 404 NOT_FOUND : 자원을 찾을 수 없음 */ | ||
| INVALID_NOTE(NOT_FOUND, "유효하지 않은 노트입니다."); | ||
|
|
||
| private final HttpStatus httpStatus; | ||
| private final String message; | ||
| } |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/tiki/server/note/message/SuccessMessage.java
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,13 @@ | ||
| package com.tiki.server.note.message; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Getter | ||
| @RequiredArgsConstructor | ||
| public enum SuccessMessage { | ||
|
|
||
| CREATE_NOTE_FREE("노트 생성 성공"); | ||
|
|
||
| private final String message; | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/tiki/server/note/repository/NoteRepository.java
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,11 @@ | ||
| package com.tiki.server.note.repository; | ||
|
|
||
| import com.tiki.server.note.entity.Note; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface NoteRepository extends JpaRepository<Note, Long> { | ||
|
|
||
| List<Note> findAllByTeamId(final long teamId); | ||
| } |
Oops, something went wrong.
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.