-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from DO-SOPT-SERVER/feature/5
[3주차] 기본 과제 & 심화 과제
- Loading branch information
Showing
39 changed files
with
483 additions
and
104 deletions.
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
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 |
---|---|---|
|
@@ -40,4 +40,4 @@ out/ | |
.DS_Store | ||
|
||
### Yml ### | ||
src/main/resources/application.yml | ||
api/src/main/resources/application.yml |
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,16 @@ | ||
dependencies { | ||
// spring boot web | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
// spring data jpa | ||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' | ||
// h2 | ||
runtimeOnly 'com.h2database:h2' | ||
// domain dependency | ||
implementation project(path: ':domain') | ||
// common dependency | ||
implementation project(path: ':common') | ||
} | ||
|
||
jar { | ||
enabled = false | ||
} |
2 changes: 1 addition & 1 deletion
2
.../org/sopt/seminar/SeminarApplication.java → ...ain/java/org/sopt/SeminarApplication.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
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
2 changes: 1 addition & 1 deletion
2
.../seminar/global/common/SuccessStatus.java → ...va/org/sopt/api/common/SuccessStatus.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
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
16 changes: 8 additions & 8 deletions
16
...omain/member/api/MemberApiController.java → ...t/api/member/api/MemberApiController.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
4 changes: 2 additions & 2 deletions
4
...member/dto/request/MemberSaveRequest.java → ...member/dto/request/MemberSaveRequest.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
8 changes: 8 additions & 0 deletions
8
api/src/main/java/org/sopt/api/member/dto/request/MemberUpdateRequest.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,8 @@ | ||
package org.sopt.api.member.dto.request; | ||
|
||
import org.sopt.domain.member.domain.Part; | ||
|
||
public record MemberUpdateRequest( | ||
int generation, | ||
Part part) { | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...mber/dto/response/MemberSaveResponse.java → ...mber/dto/response/MemberSaveResponse.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
24 changes: 12 additions & 12 deletions
24
.../domain/member/service/MemberService.java → ...opt/api/member/service/MemberService.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
56 changes: 56 additions & 0 deletions
56
api/src/main/java/org/sopt/api/post/api/PostApiController.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,56 @@ | ||
package org.sopt.api.post.api; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.sopt.api.common.ApiResponse; | ||
import org.sopt.api.common.SuccessStatus; | ||
import org.sopt.api.post.dto.request.PostSaveOrUpdateRequest; | ||
import org.sopt.api.post.dto.response.PostGetResponse; | ||
import org.sopt.api.post.dto.response.PostSaveResponse; | ||
import org.sopt.api.post.service.PostService; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/api/post") | ||
@Controller | ||
public class PostApiController { | ||
private static final String CUSTOM_AUTHENTICATION = "X-Auth-Id"; | ||
private final PostService postService; | ||
|
||
@PostMapping | ||
public ResponseEntity<ApiResponse<?>> savePost(@RequestHeader(CUSTOM_AUTHENTICATION) final Long memberId, | ||
@RequestBody final PostSaveOrUpdateRequest postSaveOrUpdateRequest) { | ||
final PostSaveResponse postSaveResponse = postService.savePost(memberId, postSaveOrUpdateRequest); | ||
return ApiResponse.success(SuccessStatus.CREATED, postSaveResponse); | ||
} | ||
|
||
@GetMapping("/{postId}") | ||
public ResponseEntity<ApiResponse<?>> getPost(@PathVariable final Long postId) { | ||
final PostGetResponse post = postService.getPost(postId); | ||
return ApiResponse.success(SuccessStatus.OK, post); | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<ApiResponse<?>> getPosts(@RequestHeader(CUSTOM_AUTHENTICATION) final Long memberId, | ||
final Pageable pageable) { | ||
final List<PostGetResponse> posts = postService.getPosts(memberId, pageable); | ||
return ApiResponse.success(SuccessStatus.OK, posts); | ||
} | ||
|
||
@PatchMapping("/{postId}") | ||
public ResponseEntity<ApiResponse<?>> updatePost(@PathVariable final Long postId, | ||
@RequestBody final PostSaveOrUpdateRequest postSaveOrUpdateRequest) { | ||
postService.updatePost(postId, postSaveOrUpdateRequest); | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
@DeleteMapping("/{postId}") | ||
public ResponseEntity<ApiResponse<?>> deletePost(@PathVariable final Long postId) { | ||
postService.deletePost(postId); | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
api/src/main/java/org/sopt/api/post/dto/request/PostSaveOrUpdateRequest.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,8 @@ | ||
package org.sopt.api.post.dto.request; | ||
|
||
public record PostSaveOrUpdateRequest( | ||
String title, | ||
String postContent, | ||
String categoryContent | ||
) { | ||
} |
22 changes: 22 additions & 0 deletions
22
api/src/main/java/org/sopt/api/post/dto/response/PostGetResponse.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,22 @@ | ||
package org.sopt.api.post.dto.response; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import org.sopt.domain.post.domain.Category; | ||
import org.sopt.domain.post.domain.Post; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public record PostGetResponse( | ||
String title, | ||
String postContent, | ||
String categoryContent | ||
) { | ||
public static PostGetResponse of(Post post) { | ||
Category category = post.getCategory(); | ||
return builder() | ||
.title(post.getTitle()) | ||
.postContent(post.getContent()) | ||
.categoryContent(category.getContent()) | ||
.build(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
api/src/main/java/org/sopt/api/post/dto/response/PostSaveResponse.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,11 @@ | ||
package org.sopt.api.post.dto.response; | ||
|
||
import org.sopt.domain.post.domain.Post; | ||
|
||
public record PostSaveResponse( | ||
Long postId | ||
) { | ||
public static PostSaveResponse of(Post post) { | ||
return new PostSaveResponse(post.getId()); | ||
} | ||
} |
Oops, something went wrong.