-
Notifications
You must be signed in to change notification settings - Fork 0
(김기현) Todo 일기 작성하기 (Side-Project) 리뷰 부탁드립니다. #2
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
Open
Duskafka
wants to merge
63
commits into
kihyun/main
Choose a base branch
from
kihyun/diary-project
base: kihyun/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
Changes from 42 commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
6a672c8
feat: 기본적인 CRUD
DongGeon0908 daaa823
fix: jpa config and webconfig cors
DongGeon0908 e280990
fix: 자원 없을시 exception
DongGeon0908 18f5af4
fix: 삽입, 삭제, 수정시 로그 출력
DongGeon0908 1b36daf
fix: todo
DongGeon0908 89ae461
fix: todo
DongGeon0908 a57ef58
feat: Response wrapping 변경
DongGeon0908 6bf1340
정적 펙토리 매서드 패턴 적용
DongGeon0908 f3e4dc0
exception 처리
DongGeon0908 b7db802
todo swagger 적용
DongGeon0908 7da10b1
데이터베이스 연결 수정
Duskafka 3ec64f8
fix : 요구명세서 작성
Duskafka fe7c7d4
fix : request, response
Duskafka 058728f
fix : Range Search
Duskafka 06413cf
complete : today`s feeling
Duskafka 54d72c0
fix : 요구사항 수정
Duskafka 970a123
fix : 불필요한 PathVariable 삭제
Duskafka f22869d
develop : month delete
Duskafka 14a39fa
fix : add year, month, day
Duskafka bab5a7c
fix : 클래스명 변경
Duskafka 3d82dee
fix : 클래스명 삭제
Duskafka ebef5f8
develop : month delete 추가
Duskafka 5f2b58f
fix : Diary 수정
Duskafka 60b2f2a
fix : Diary 수정
Duskafka 660ea95
fix : delete test
Duskafka b6a633d
fix : month search
Duskafka 91da852
fix : 스웨거 링크 추가
Duskafka 6ab4cb3
develop : Feeling 항목 추가
Duskafka ee7e7c7
update : Feeling 테이블 추가 및 update , findAll 추가
Duskafka be2b0e4
update : 검색 모듈 추가
Duskafka 8ae4591
fix : log
Duskafka 2fed5fb
fix : URL
Duskafka 0342a14
update : MonthRequest
Duskafka 700f32e
update : 다양한 검색기능 추가
Duskafka d9917b3
update : id
Duskafka c89f25c
fix : feeling id 추가에 따른 변경
Duskafka b4f3ac0
fix : search 객체 패키징
Duskafka c400005
update : 쿼리문으로 월별 삭제 기능 추가
Duskafka 0f0e229
fix : 사용하지 없는 변수 삭제
Duskafka d16cb02
fix : 중복 메소드 삭제
Duskafka f31e595
fix : url 수정
Duskafka bdccfdd
fix : ApiOperation 수정
Duskafka 9847235
fix : url 대문자 변경
Duskafka 23e1bda
fix : 원시타입 참조타입으로 변경
Duskafka 4470800
update : persistence 연결을 위한 xml
Duskafka 3abb773
fix : cleanCode
Duskafka bb14106
fix : 변수형 변경
Duskafka 4783817
update : Persistence DB 연동 성공
Duskafka cb0b484
none
Duskafka e2f77e9
fix : GenerateValue
Duskafka 0108538
fix : Entity name
Duskafka 067294b
update : feelingSearch
Duskafka 98c0374
update : feelingSearch
Duskafka 9f94913
delete
Duskafka e8f6a51
fix : cleancode
Duskafka d5a4661
fix : persistence name
Duskafka 7be9377
fix : Entity 추가
Duskafka 0976e81
update : JpaSpecificationExecutor
Duskafka ff93cf7
fix : cleancode
Duskafka 178fd36
fix : cleancode
Duskafka 59a7c6d
update : PersistenceService
Duskafka c05180b
update : 줄바꿈
Duskafka b9dc272
Merge remote-tracking branch 'origin/kihyun/diary-project' into kihyu…
Duskafka 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,74 @@ | ||
| # SELAB-TODO | ||
| > basic todo with spring-mvc | ||
| > basic diary with spring-mvc | ||
|
|
||
| [테스트링크](http://localhost:8080/swagger-ui/index.html#/TODO%20API) | ||
|
|
||
| # 요구명세서 | ||
| > 일기 작성 서비스 | ||
|
|
||
| ## 목차 | ||
| 1. 소개 | ||
| 1. 목적 | ||
| 2. 일반적인 기술 사항 | ||
| 1. 제품의 기능 | ||
| 2. 사용자 특성 | ||
| 3. 제약사항 | ||
| 4. 가정 및 의존성 | ||
| 3. 상세기능 요구 사항 | ||
| 1. 기능적 요구 사항 | ||
| 1. 기본적인 CRUD | ||
| 1. 등록 | ||
| 2. 조회 | ||
| 3. 수정 | ||
| 4. 삭제 | ||
|
|
||
| ## 소개 | ||
| ### 1.i 목적 | ||
| 동건이형께 Todo 스터디를 완료했으므로 사이드 프로젝트를 진행하기 위하여 시작함 | ||
| ## 일반적인 기술 사항 | ||
| ### 2. i 제품의 기능 | ||
| 앱은 아래와 같은 기능들을 주요 기능으로 갖는다 | ||
| * 단건 조회 | ||
| * 범위 조회 | ||
| * 전체 조회 | ||
| * 수정 | ||
| * 등록 | ||
| * 삭제 | ||
| * 전체 삭제 | ||
| ### 2.ii 사용자 특정 | ||
| 사용자는 일기를 생성할 수 있어야 한다. 생성은 Json 파일 형식으로 해야 한다 | ||
|
|
||
|
|
||
| 사용자는 일기 조회를 할 수 있어야 한다. 단건 조회는 ID를 입력했을 때 가능하며, 범위 조회는 | ||
| 월(Month)를 입력했을 때 가능해야 한다 | ||
|
|
||
|
|
||
| 사용자는 일기 수정이 가능해야 한다. 수정하는 것은 ID로 수정할 수 있도록 한다. | ||
|
|
||
|
|
||
| 사용자는 일기 삭제가 가능해야 한다. 삭제는 ID를 통해 이루어지도록 한다. | ||
| ### 2.iii 제약사항 | ||
| * spring framework를 사용하여 구현한다 | ||
| * MySQL과 Jpa를 사용하여 데이터베이스와 연결한다 | ||
| * create-drop을 사용하기 때문에 데이터베이스에 데이터베이스 스키마를 만들지 않아도 된다 | ||
|
|
||
| ## 상세기능 요구 사항 | ||
| ### 3.i. 기능적 요구 사항 | ||
| ### 3.i.a 기본적인 CRUD | ||
| ### 3.i.a.a 등록 | ||
| * request : id, 등록 날짜, 제목, 내용, 기분 | ||
| ### 3.i.a.b 조회 | ||
| #### 단건 조회 | ||
| * request : id | ||
| #### 범위 조회 | ||
| * request : Month | ||
| * response : page | ||
| #### 전체 조회 | ||
| * request : none | ||
| * response : page | ||
| ### 3.i.a.c 수정 | ||
| * request : id | ||
| ### 3.i.a.d 삭제 | ||
| * request : none | ||
|
|
||
|
|
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,21 @@ | ||
| package com.selab.todo.common; | ||
|
|
||
| import lombok.Getter; | ||
| import org.springframework.data.annotation.CreatedDate; | ||
| import org.springframework.data.annotation.LastModifiedDate; | ||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
|
||
| import javax.persistence.EntityListeners; | ||
| import javax.persistence.MappedSuperclass; | ||
| import java.time.LocalDateTime; | ||
|
|
||
| @Getter | ||
| @MappedSuperclass | ||
| @EntityListeners(AuditingEntityListener.class) | ||
| public abstract class BaseEntity { | ||
| @CreatedDate | ||
| private LocalDateTime createdAt; | ||
|
|
||
| @LastModifiedDate | ||
| private LocalDateTime modifiedAt; | ||
| } |
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,28 @@ | ||
| package com.selab.todo.common.dto; | ||
|
|
||
| import lombok.Data; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.http.ResponseEntity; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Data | ||
| @RequiredArgsConstructor | ||
| public class PageDto<T> { | ||
| private final List<T> data; | ||
| private final int page; | ||
| private final int size; | ||
| private final long totalElements; | ||
|
|
||
| public static <T> ResponseEntity<PageDto<T>> ok(Page<T> data) { | ||
| var response = new PageDto<T>( | ||
| data.getContent(), | ||
| data.getPageable().getPageNumber(), | ||
| data.getPageable().getPageSize(), | ||
| data.getTotalElements() | ||
| ); | ||
|
|
||
| return ResponseEntity.ok(response); | ||
| } | ||
| } |
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,30 @@ | ||
| package com.selab.todo.common.dto; | ||
|
|
||
| import lombok.Data; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
|
|
||
| @Data | ||
| @RequiredArgsConstructor | ||
| public class ResponseDto<T> { | ||
| private final T data; | ||
|
|
||
| public static <T> ResponseEntity<ResponseDto<T>> ok(T data) { | ||
| var response = new ResponseDto<T>(data); | ||
| return ResponseEntity.ok(response); | ||
| } | ||
|
|
||
| public static <T> ResponseEntity<ResponseDto<T>> created(T data) { | ||
| var response = new ResponseDto<T>(data); | ||
| return ResponseEntity | ||
| .status(HttpStatus.CREATED) | ||
| .body(response); | ||
| } | ||
|
|
||
| public static ResponseEntity<Void> noContent() { | ||
| return ResponseEntity | ||
| .status(HttpStatus.NO_CONTENT) | ||
| .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,9 @@ | ||
| package com.selab.todo.config; | ||
|
|
||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ||
|
|
||
| @Configuration | ||
| @EnableJpaAuditing | ||
| public class JpaConfig { | ||
| } |
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,39 @@ | ||
| package com.selab.todo.config; | ||
|
|
||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import springfox.documentation.builders.ApiInfoBuilder; | ||
| import springfox.documentation.builders.PathSelectors; | ||
| import springfox.documentation.builders.RequestHandlerSelectors; | ||
| import springfox.documentation.oas.annotations.EnableOpenApi; | ||
| import springfox.documentation.service.ApiInfo; | ||
| import springfox.documentation.spi.DocumentationType; | ||
| import springfox.documentation.spring.web.plugins.Docket; | ||
|
|
||
| import javax.servlet.http.HttpServletRequest; | ||
|
|
||
| @Configuration | ||
| @EnableOpenApi | ||
| public class SwaggerConfig { | ||
| @Bean | ||
| public Docket restApi() { | ||
| return new Docket(DocumentationType.OAS_30) | ||
| .ignoredParameterTypes( | ||
| HttpServletRequest.class | ||
| ) | ||
| .useDefaultResponseMessages(false) | ||
| .apiInfo(apiInfo()) | ||
| .select() | ||
| .apis(RequestHandlerSelectors.basePackage("com.selab.todo")) | ||
| .paths(PathSelectors.regex("/api/.*")) | ||
| .build(); | ||
| } | ||
|
|
||
| private ApiInfo apiInfo() { | ||
| return new ApiInfoBuilder() | ||
| .title("Selab Diary api info") | ||
| .description("SE Diary API") | ||
| .version("1.0.0") | ||
| .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,29 @@ | ||
| package com.selab.todo.config; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.web.cors.CorsConfiguration; | ||
| import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | ||
| import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
|
||
| // CORS --> 가장 많이 발생 | ||
| @Configuration | ||
| @RequiredArgsConstructor | ||
| public class WebConfig implements WebMvcConfigurer { | ||
| @Bean | ||
| public UrlBasedCorsConfigurationSource corsConfigurationSource() { | ||
| var corsConfig = new CorsConfiguration(); | ||
|
|
||
| corsConfig.addAllowedOriginPattern(CorsConfiguration.ALL); | ||
| corsConfig.addAllowedHeader(CorsConfiguration.ALL); | ||
| corsConfig.addAllowedMethod(CorsConfiguration.ALL); | ||
|
|
||
| corsConfig.setAllowCredentials(true); | ||
| corsConfig.setMaxAge(3600L); | ||
|
|
||
| var corsConfigSource = new UrlBasedCorsConfigurationSource(); | ||
| corsConfigSource.registerCorsConfiguration("/**", corsConfig); | ||
| return corsConfigSource; | ||
| } | ||
| } |
98 changes: 98 additions & 0 deletions
98
src/main/java/com/selab/todo/controller/DiaryController.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,98 @@ | ||
| package com.selab.todo.controller; | ||
|
|
||
| import com.selab.todo.common.dto.PageDto; | ||
| import com.selab.todo.common.dto.ResponseDto; | ||
| import com.selab.todo.dto.request.diary.DiaryRegisterRequest; | ||
| import com.selab.todo.dto.request.diary.DiaryUpdateRequest; | ||
| import com.selab.todo.dto.request.search.MonthSearchRequest; | ||
| import com.selab.todo.dto.request.feel.FeelingUpdateRequest; | ||
| import com.selab.todo.service.DiaryService; | ||
| import com.selab.todo.service.FeelingService; | ||
| import io.swagger.annotations.Api; | ||
| import io.swagger.annotations.ApiOperation; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.domain.Sort; | ||
| import org.springframework.data.web.PageableDefault; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.PutMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @Api(tags = {"Diary API"}) | ||
| @RestController | ||
| @RequestMapping(value = "/api/v1/Diarys/default", produces = MediaType.APPLICATION_JSON_VALUE) | ||
| @RequiredArgsConstructor | ||
| public class DiaryController { | ||
|
Member
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. url path에 대해 다시 한번 더 점검 부탁드릅니다!
Author
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. 적용해보았습니다 |
||
| private final DiaryService diaryService; | ||
| private final FeelingService feelingService; | ||
|
|
||
| @ApiOperation(value = "Diary 등록하기") | ||
| @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, value = "/register") | ||
| public ResponseEntity<?> register(@RequestBody DiaryRegisterRequest request) { | ||
| var response = diaryService.register(request); | ||
| return ResponseDto.created(response); | ||
| } | ||
|
|
||
| @ApiOperation(value = "Diary 단건 조회하기") | ||
| @GetMapping("/{id}") | ||
| public ResponseEntity<?> get(@PathVariable Long id) { | ||
| var response = diaryService.get(id); | ||
| return ResponseDto.ok(response); | ||
| } | ||
|
|
||
| @ApiOperation(value = "Diary 전체 조회하기") | ||
| @GetMapping("/search-all") | ||
| public ResponseEntity<?> getAll( | ||
| @PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC) Pageable pageable | ||
| ) { | ||
| var response = diaryService.getAll(pageable); | ||
| return PageDto.ok(response); | ||
| } | ||
|
|
||
| @ApiOperation(value = "Diary 수정하기") | ||
| @PutMapping("/{id}") // @PatchMapping | ||
| public ResponseEntity<?> update( | ||
| @PathVariable Long id, | ||
| @RequestBody DiaryUpdateRequest request | ||
| ) { | ||
| var response = diaryService.update(id, request); | ||
| return ResponseDto.ok(response); | ||
| } | ||
|
|
||
| @ApiOperation(value = "Diary 삭제하기") | ||
| @DeleteMapping("/{id}") | ||
| public ResponseEntity<Void> delete( | ||
| @PathVariable Long id | ||
| ) { | ||
| diaryService.delete(id); | ||
| return ResponseDto.noContent(); | ||
| } | ||
|
|
||
| @ApiOperation(value = "Diary 월별 삭제하기") | ||
| @DeleteMapping("/month/{month}") | ||
| public ResponseEntity<Void> monthDelete(@PathVariable int month) { | ||
| diaryService.monthDelete(month); | ||
| return ResponseDto.noContent(); | ||
| } | ||
|
|
||
| @ApiOperation(value = "Feeling 수정하기") | ||
| @PutMapping(consumes = MediaType.APPLICATION_JSON_VALUE, value = "/feeling/{id}") | ||
| public ResponseEntity<?> updateFeeling(@PathVariable Long id, @RequestBody FeelingUpdateRequest request) { | ||
| var response = feelingService.updateFeeling(id, request); | ||
| return ResponseDto.ok(response); | ||
| } | ||
|
|
||
| @ApiOperation(value = "Feeling 전체 조회하기") | ||
| @GetMapping("/feeling-all") | ||
| public ResponseEntity<?> getAllFeeling(@PageableDefault Pageable pageable) { | ||
| var response = feelingService.getAllFeeling(pageable); | ||
| return PageDto.ok(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.
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.
default는 왜 필요해요??
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.
REST API
이 형태 아닌가요?
그리고 url path에 왜 대문자가 들어가는걸까용?