-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/woowacourse-teams/2024-deve…
- Loading branch information
Showing
76 changed files
with
2,342 additions
and
260 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
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,67 @@ | ||
package develup.api; | ||
|
||
import java.net.URI; | ||
import java.util.List; | ||
import develup.api.auth.Auth; | ||
import develup.api.common.ApiResponse; | ||
import develup.application.auth.Accessor; | ||
import develup.application.solution.comment.CreateSolutionCommentResponse; | ||
import develup.application.solution.comment.SolutionCommentRequest; | ||
import develup.application.solution.comment.SolutionCommentService; | ||
import develup.application.solution.comment.SolutionCommentRepliesResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
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.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@Tag(name = "솔루션 댓글 API") | ||
public class SolutionCommentApi { | ||
|
||
private final SolutionCommentService solutionCommentService; | ||
|
||
public SolutionCommentApi(SolutionCommentService solutionCommentService) { | ||
this.solutionCommentService = solutionCommentService; | ||
} | ||
|
||
@GetMapping("/solutions/{solutionId}/comments") | ||
@Operation(summary = "솔루션 댓글 조회 API", description = "솔루션의 댓글 목록을 조회합니다. 댓글들과 댓글들에 대한 답글을 조회합니다.") | ||
public ResponseEntity<ApiResponse<List<SolutionCommentRepliesResponse>>> getComments( | ||
@PathVariable Long solutionId | ||
) { | ||
List<SolutionCommentRepliesResponse> responses = solutionCommentService.getCommentsWithReplies(solutionId); | ||
|
||
return ResponseEntity.ok(new ApiResponse<>(responses)); | ||
} | ||
|
||
@PostMapping("/solutions/{solutionId}/comments") | ||
@Operation(summary = "솔루션 댓글 추가 API", description = "솔루션에 댓글을 추가합니다. 부모 댓글 식별자로 답글을 추가할 수 있습니다.") | ||
public ResponseEntity<ApiResponse<CreateSolutionCommentResponse>> addComment( | ||
@PathVariable Long solutionId, | ||
@Valid @RequestBody SolutionCommentRequest request, | ||
@Auth Accessor accessor | ||
) { | ||
CreateSolutionCommentResponse response = solutionCommentService.addComment(solutionId, request, accessor.id()); | ||
|
||
URI location = URI.create("/solutions/" + response.solutionId() + "/comments/" + response.id()); | ||
|
||
return ResponseEntity.created(location).body(new ApiResponse<>(response)); | ||
} | ||
|
||
@DeleteMapping("/solutions/comments/{commentId}") | ||
@Operation(summary = "솔루션 댓글 삭제 API", description = "솔루션의 댓글을 삭제합니다.") | ||
public ResponseEntity<Void> deleteComment( | ||
@PathVariable Long commentId, | ||
@Auth Accessor accessor | ||
) { | ||
solutionCommentService.deleteComment(commentId, accessor.id()); | ||
|
||
return ResponseEntity.noContent().build(); | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
backend/src/main/java/develup/application/hashtag/HashTagResponse.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,13 @@ | ||
package develup.application.hashtag; | ||
|
||
import develup.domain.hashtag.HashTag; | ||
|
||
public record HashTagResponse(Long id, String name) { | ||
|
||
public static HashTagResponse from(HashTag hashTag) { | ||
return new HashTagResponse( | ||
hashTag.getId(), | ||
hashTag.getName() | ||
); | ||
} | ||
} |
15 changes: 13 additions & 2 deletions
15
backend/src/main/java/develup/application/mission/MissionResponse.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 |
---|---|---|
@@ -1,22 +1,33 @@ | ||
package develup.application.mission; | ||
|
||
import java.util.List; | ||
import develup.application.hashtag.HashTagResponse; | ||
import develup.domain.mission.Mission; | ||
import develup.domain.mission.MissionHashTag; | ||
|
||
public record MissionResponse( | ||
Long id, | ||
String title, | ||
String thumbnail, | ||
String summary, | ||
String url | ||
String url, | ||
List<HashTagResponse> hashTags | ||
) { | ||
|
||
public static MissionResponse from(Mission mission) { | ||
List<HashTagResponse> hashTagResponses = mission.getHashTags() | ||
.stream() | ||
.map(MissionHashTag::getHashTag) | ||
.map(HashTagResponse::from) | ||
.toList(); | ||
|
||
return new MissionResponse( | ||
mission.getId(), | ||
mission.getTitle(), | ||
mission.getThumbnail(), | ||
mission.getSummary(), | ||
mission.getUrl() | ||
mission.getUrl(), | ||
hashTagResponses | ||
); | ||
} | ||
} |
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
15 changes: 13 additions & 2 deletions
15
backend/src/main/java/develup/application/mission/MissionWithStartedResponse.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
10 changes: 10 additions & 0 deletions
10
backend/src/main/java/develup/application/solution/MySolutionResponse.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,10 @@ | ||
package develup.application.solution; | ||
|
||
import develup.domain.solution.Solution; | ||
|
||
public record MySolutionResponse(Long id, String thumbnail, String title) { | ||
|
||
public static MySolutionResponse from(Solution solution) { | ||
return new MySolutionResponse(solution.getId(), solution.getMissionThumbnail(), solution.getTitle()); | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
backend/src/main/java/develup/application/solution/SummarizedSolutionResponse.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,30 @@ | ||
package develup.application.solution; | ||
|
||
import java.util.List; | ||
import develup.application.hashtag.HashTagResponse; | ||
import develup.domain.mission.MissionHashTag; | ||
import develup.domain.solution.Solution; | ||
|
||
public record SummarizedSolutionResponse( | ||
Long id, | ||
String title, | ||
String thumbnail, | ||
String description, | ||
List<HashTagResponse> hashTags | ||
) { | ||
|
||
public static SummarizedSolutionResponse from(Solution solution) { | ||
List<HashTagResponse> hashTagResponses = solution.getHashTags().stream() | ||
.map(MissionHashTag::getHashTag) | ||
.map(HashTagResponse::from) | ||
.toList(); | ||
|
||
return new SummarizedSolutionResponse( | ||
solution.getId(), | ||
solution.getTitle(), | ||
solution.getMissionThumbnail(), | ||
solution.getDescription(), | ||
hashTagResponses | ||
); | ||
} | ||
} |
Oops, something went wrong.