Skip to content

Commit 6e9cc8d

Browse files
authored
#209, 210, 211 - 서버드리븐을 적용합니다. (#216)
2 parents db13a2f + a1bce7a commit 6e9cc8d

File tree

125 files changed

+2708
-315
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+2708
-315
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.wespot.comment
2+
3+
import com.wespot.comment.port.`in`.PostCommentDeletedUseCase
4+
import org.springframework.http.ResponseEntity
5+
import org.springframework.web.bind.annotation.DeleteMapping
6+
import org.springframework.web.bind.annotation.PathVariable
7+
import org.springframework.web.bind.annotation.RequestMapping
8+
import org.springframework.web.bind.annotation.RestController
9+
10+
@RestController
11+
@RequestMapping("/api/v1/post/comment")
12+
class PostCommentDeletedController(
13+
private val postCommentDeletedUseCase: PostCommentDeletedUseCase
14+
) {
15+
16+
@DeleteMapping("/{commentId}")
17+
fun deletePostComment(
18+
@PathVariable commentId: Long
19+
): ResponseEntity<Void> {
20+
postCommentDeletedUseCase.deleteComment(commentId)
21+
22+
return ResponseEntity.noContent()
23+
.build()
24+
}
25+
26+
27+
}

app/src/main/kotlin/com/wespot/comment/PostCommentLikeController.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.wespot.comment
22

33
import com.wespot.comment.port.`in`.PostCommentLikeUseCase
4+
import org.springframework.http.HttpStatus
45
import org.springframework.http.ResponseEntity
56
import org.springframework.web.bind.annotation.PatchMapping
67
import org.springframework.web.bind.annotation.PathVariable
8+
import org.springframework.web.bind.annotation.PostMapping
79
import org.springframework.web.bind.annotation.RequestMapping
810
import org.springframework.web.bind.annotation.RestController
911

@@ -13,11 +15,11 @@ class PostCommentLikeController(
1315
private val postCommentLikeUseCase: PostCommentLikeUseCase
1416
) {
1517

16-
@PatchMapping("/{commentId}/like")
18+
@PostMapping("/{commentId}/like")
1719
fun likePostComment(@PathVariable commentId: Long): ResponseEntity<Unit> {
1820
postCommentLikeUseCase.likeComment(commentId)
1921

20-
return ResponseEntity.noContent()
22+
return ResponseEntity.status(HttpStatus.CREATED)
2123
.build()
2224
}
2325

app/src/main/kotlin/com/wespot/comment/PostCommentReportController.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package com.wespot.comment
22

33
import com.wespot.comment.port.`in`.PostCommentReportUseCase
4+
import org.springframework.http.HttpStatus
45
import org.springframework.http.ResponseEntity
5-
import org.springframework.web.bind.annotation.PatchMapping
66
import org.springframework.web.bind.annotation.PathVariable
7+
import org.springframework.web.bind.annotation.PostMapping
78
import org.springframework.web.bind.annotation.RequestMapping
89
import org.springframework.web.bind.annotation.RestController
910

@@ -13,11 +14,11 @@ class PostCommentReportController(
1314
private val postCommentReportUseCase: PostCommentReportUseCase
1415
) {
1516

16-
@PatchMapping("/{commentId}/report")
17-
fun likePostComment(@PathVariable commentId: Long): ResponseEntity<Unit> {
17+
@PostMapping("/{commentId}/report")
18+
fun reportPostComment(@PathVariable commentId: Long): ResponseEntity<Unit> {
1819
postCommentReportUseCase.reportComment(commentId)
1920

20-
return ResponseEntity.noContent()
21+
return ResponseEntity.status(HttpStatus.CREATED)
2122
.build()
2223
}
2324

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.wespot.post
2+
3+
import com.wespot.post.dto.request.ModifyPostNotificationSettingRequest
4+
import com.wespot.post.port.`in`.ModifyPostNotificationSettingUseCase
5+
import org.springframework.http.ResponseEntity
6+
import org.springframework.web.bind.annotation.PatchMapping
7+
import org.springframework.web.bind.annotation.RequestBody
8+
import org.springframework.web.bind.annotation.RequestMapping
9+
import org.springframework.web.bind.annotation.RestController
10+
11+
@RestController
12+
@RequestMapping("/api/v2/post")
13+
class ModifyPostNotificationSettingController(
14+
private val modifyPostNotificationSettingUseCase: ModifyPostNotificationSettingUseCase
15+
) {
16+
17+
@PatchMapping("/notification-setting")
18+
fun modifyPostNotificationSetting(
19+
@RequestBody modifyPostNotificationSettingRequest: ModifyPostNotificationSettingRequest
20+
): ResponseEntity<Unit> {
21+
modifyPostNotificationSettingUseCase.changeSetting(modifyPostNotificationSettingRequest = modifyPostNotificationSettingRequest)
22+
23+
return ResponseEntity.noContent()
24+
.build()
25+
}
26+
27+
}

app/src/main/kotlin/com/wespot/post/PostBlockController.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.wespot.post
22

33
import com.wespot.post.port.`in`.PostBlockUseCase
4+
import org.springframework.http.HttpStatus
45
import org.springframework.http.ResponseEntity
56
import org.springframework.web.bind.annotation.PathVariable
67
import org.springframework.web.bind.annotation.PostMapping
@@ -17,7 +18,8 @@ class PostBlockController(
1718
fun blockPost(@PathVariable postId: Long): ResponseEntity<Unit> {
1819
postBlockUseCase.blockPost(postId)
1920

20-
return ResponseEntity.noContent().build()
21+
return ResponseEntity.status(HttpStatus.CREATED)
22+
.build()
2123
}
2224

2325
}

app/src/main/kotlin/com/wespot/post/PostCategoryController.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.wespot.post
22

3-
import com.wespot.post.dto.response.PostCategoryDetailResponses
4-
import com.wespot.post.dto.response.PostCategoryResponse
3+
import com.wespot.post.dto.response.FilterChipResponse
4+
import com.wespot.post.dto.response.PostCategoryItemsResponse
55
import com.wespot.post.port.`in`.PostCategoryUseCase
66
import org.springframework.http.ResponseEntity
77
import org.springframework.web.bind.annotation.GetMapping
@@ -15,14 +15,14 @@ class PostCategoryController(
1515
) {
1616

1717
@GetMapping("/details")
18-
fun getPostCategoryDetailResponse(): ResponseEntity<List<PostCategoryDetailResponses>> {
18+
fun getPostCategoryDetailResponse(): ResponseEntity<List<PostCategoryItemsResponse>> {
1919
val response = postCategoryUseCase.getCategoriesDetail()
2020

2121
return ResponseEntity.ok(response)
2222
}
2323

2424
@GetMapping
25-
fun getPostCategoryResponse(): ResponseEntity<List<PostCategoryResponse>> {
25+
fun getPostCategoryResponse(): ResponseEntity<List<FilterChipResponse>> {
2626
val response = postCategoryUseCase.getCategories()
2727

2828
return ResponseEntity.ok(response)

app/src/main/kotlin/com/wespot/post/PostEditController.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.wespot.post
22

33
import com.wespot.post.dto.request.UpdatedPostRequest
44
import com.wespot.post.port.`in`.PostEditUseCase
5+
import org.springframework.http.HttpStatus
56
import org.springframework.http.ResponseEntity
67
import org.springframework.web.bind.annotation.*
78

app/src/main/kotlin/com/wespot/post/PostInquiryController.kt

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,82 @@
11
package com.wespot.post
22

3-
import com.wespot.post.dto.response.PostResponse
4-
import com.wespot.post.port.`in`.PostInquiryByCategoryUseCase
3+
import com.wespot.common.dto.PostPagingResponse
4+
import com.wespot.post.dto.response.PostComponentResponse
5+
import com.wespot.post.port.`in`.PostInquiryUseCase
56
import org.springframework.http.ResponseEntity
6-
import org.springframework.web.bind.annotation.GetMapping
7-
import org.springframework.web.bind.annotation.PathVariable
8-
import org.springframework.web.bind.annotation.RequestMapping
9-
import org.springframework.web.bind.annotation.RestController
7+
import org.springframework.web.bind.annotation.*
108

119
@RestController
1210
@RequestMapping("/api/v1/post")
1311
class PostInquiryController(
14-
private val postInquiryByCategoryUseCase: PostInquiryByCategoryUseCase
12+
private val postInquiryByCategoryUseCase: PostInquiryUseCase
1513
) {
1614

17-
@GetMapping("/all")
18-
fun findAllPosts(): ResponseEntity<List<PostResponse>> {
19-
val responses = postInquiryByCategoryUseCase.findAllPosts()
20-
21-
return ResponseEntity.ok(responses)
22-
}
23-
2415
@GetMapping("/details")
25-
fun findPostsByCategoryId(categoryId: Long): ResponseEntity<List<PostResponse>> {
26-
val responses = postInquiryByCategoryUseCase.findPostsByCategoryId(categoryId)
16+
fun findPostsByCategoryId(
17+
@RequestParam categoryId: Long,
18+
@RequestParam(required = false, defaultValue = "10") inquirySize: Long,
19+
@RequestParam(required = false) cursorId: Long? = null,
20+
): ResponseEntity<PostPagingResponse> {
21+
val responses = postInquiryByCategoryUseCase.findPostsByCategoryId(
22+
categoryId,
23+
inquirySize = inquirySize,
24+
cursorId = cursorId
25+
)
2726

2827
return ResponseEntity.ok(responses)
2928
}
3029

3130
@GetMapping
32-
fun findPostsByMajorCategoryName(majorCategoryName: String): ResponseEntity<List<PostResponse>> {
33-
val responses = postInquiryByCategoryUseCase.findPostsByMajorCategoryName(majorCategoryName)
31+
fun findPostsByMajorCategoryName(
32+
@RequestParam majorCategoryName: String,
33+
@RequestParam(required = false, defaultValue = "0") countOfPostsViewed: Long,
34+
@RequestParam(required = false, defaultValue = "10") inquirySize: Long,
35+
@RequestParam(required = false) cursorId: Long? = null,
36+
): ResponseEntity<PostPagingResponse> {
37+
val responses = postInquiryByCategoryUseCase.findPostsByMajorCategoryName(
38+
majorCategoryName = majorCategoryName,
39+
countOfPostsViewed = countOfPostsViewed,
40+
inquirySize = inquirySize,
41+
cursorId = cursorId
42+
)
3443

3544
return ResponseEntity.ok(responses)
3645
}
3746

3847
@GetMapping("/{postId}")
39-
fun findDetailPost(@PathVariable postId: Long): ResponseEntity<PostResponse> {
48+
fun findDetailPost(@PathVariable postId: Long): ResponseEntity<PostComponentResponse> {
4049
val responses = postInquiryByCategoryUseCase.findPostById(postId)
4150

4251
return ResponseEntity.ok(responses)
4352
}
4453

4554
@GetMapping("/commented")
46-
fun findCommentedPosts(): ResponseEntity<List<PostResponse>> {
47-
val responses = postInquiryByCategoryUseCase.findCommentedPosts()
55+
fun findCommentedPosts(
56+
@RequestParam(required = false, defaultValue = "10") inquirySize: Long,
57+
@RequestParam(required = false) cursorId: Long? = null,
58+
): ResponseEntity<PostPagingResponse> {
59+
val responses = postInquiryByCategoryUseCase.findCommentedPosts(inquirySize = inquirySize, cursorId = cursorId)
4860

4961
return ResponseEntity.ok(responses)
5062
}
5163

5264
@GetMapping("/scrapped")
53-
fun findScrappedPosts(): ResponseEntity<List<PostResponse>> {
54-
val responses = postInquiryByCategoryUseCase.findScrappedPosts()
65+
fun findScrappedPosts(
66+
@RequestParam(required = false, defaultValue = "10") inquirySize: Long,
67+
@RequestParam(required = false) cursorId: Long? = null,
68+
): ResponseEntity<PostPagingResponse> {
69+
val responses = postInquiryByCategoryUseCase.findScrappedPosts(inquirySize = inquirySize, cursorId = cursorId)
5570

5671
return ResponseEntity.ok(responses)
5772
}
5873

5974
@GetMapping("/written")
60-
fun findWrittenPosts(): ResponseEntity<List<PostResponse>> {
61-
val responses = postInquiryByCategoryUseCase.findWrittenPosts()
75+
fun findWrittenPosts(
76+
@RequestParam(required = false, defaultValue = "10") inquirySize: Long,
77+
@RequestParam(required = false) cursorId: Long? = null,
78+
): ResponseEntity<PostPagingResponse> {
79+
val responses = postInquiryByCategoryUseCase.findWrittenPosts(inquirySize = inquirySize, cursorId = cursorId)
6280

6381
return ResponseEntity.ok(responses)
6482
}

app/src/main/kotlin/com/wespot/post/PostLikeController.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package com.wespot.post
22

33
import com.wespot.post.port.`in`.PostLikeUseCase
4+
import org.springframework.http.HttpStatus
45
import org.springframework.http.ResponseEntity
5-
import org.springframework.web.bind.annotation.PatchMapping
66
import org.springframework.web.bind.annotation.PathVariable
7+
import org.springframework.web.bind.annotation.PostMapping
78
import org.springframework.web.bind.annotation.RequestMapping
89
import org.springframework.web.bind.annotation.RestController
910

@@ -14,11 +15,11 @@ class PostLikeController(
1415
private val postLikeUseCase: PostLikeUseCase
1516
) {
1617

17-
@PatchMapping("/{postId}/like")
18+
@PostMapping("/{postId}/like")
1819
fun likePost(@PathVariable postId: Long): ResponseEntity<Unit> {
1920
postLikeUseCase.likePost(postId)
2021

21-
return ResponseEntity.noContent()
22+
return ResponseEntity.status(HttpStatus.CREATED)
2223
.build()
2324
}
2425

app/src/main/kotlin/com/wespot/post/PostNotificationSettingController.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package com.wespot.post
22

33
import com.wespot.post.port.`in`.PostNotificationUseCase
4+
import org.springframework.http.HttpStatus
45
import org.springframework.http.ResponseEntity
5-
import org.springframework.web.bind.annotation.PatchMapping
66
import org.springframework.web.bind.annotation.PathVariable
7+
import org.springframework.web.bind.annotation.PostMapping
78
import org.springframework.web.bind.annotation.RequestMapping
89
import org.springframework.web.bind.annotation.RestController
910

@@ -14,11 +15,11 @@ class PostNotificationSettingController(
1415
private val postNotificationUseCase: PostNotificationUseCase
1516
) {
1617

17-
@PatchMapping("/{postId}/notification/comment")
18+
@PostMapping("/{postId}/notification/comment")
1819
fun updatePostNotificationSettingForComment(@PathVariable postId: Long): ResponseEntity<Unit> {
1920
postNotificationUseCase.toggleNotification(postId)
2021

21-
return ResponseEntity.noContent()
22+
return ResponseEntity.status(HttpStatus.CREATED)
2223
.build()
2324
}
2425

0 commit comments

Comments
 (0)