-
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 #13 from f-lab-edu/issue10-comment
[Issue10] 댓글 기능 구현
- Loading branch information
Showing
42 changed files
with
788 additions
and
65 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
54 changes: 54 additions & 0 deletions
54
mitube-app/src/main/java/com/misim/controller/ChannelController.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,54 @@ | ||
package com.misim.controller; | ||
|
||
import com.misim.controller.model.Request.SubscribingRequest; | ||
import com.misim.exception.CommonResponse; | ||
import com.misim.service.SubscriptionService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
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; | ||
|
||
@Tag(name = "채널 API", description = "채널 정보 관련 API") | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/channels") | ||
public class ChannelController { | ||
|
||
private final SubscriptionService subscriptionService; | ||
|
||
@Operation(summary = "채널 구독", description = "채널을 구독합니다.") | ||
@Parameter(name = "SubscribingRequest", description = "채널 구독 요청을 위한 정보", required = true) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "채널 구독 성공"), | ||
@ApiResponse(responseCode = "400", description = "요청이 올바르지 않습니다.", content = @Content(schema = @Schema(implementation = CommonResponse.class))) | ||
}) | ||
@PostMapping("/subscribe") | ||
public void subscribing(@RequestBody SubscribingRequest request) { | ||
|
||
request.check(); | ||
|
||
subscriptionService.subscribing(request.getChannelId(), request.getSubscriberId()); | ||
} | ||
|
||
@Operation(summary = "채널 구독 취소", description = "채널 구독을 취소합니다.") | ||
@Parameter(name = "SubscribingRequest", description = "채널 구독 취소 요청을 위한 정보", required = true) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "채널 구독 취소 성공"), | ||
@ApiResponse(responseCode = "400", description = "요청이 올바르지 않습니다.", content = @Content(schema = @Schema(implementation = CommonResponse.class))) | ||
}) | ||
@PostMapping("/unsubscribe") | ||
public void unsubscribing(@RequestBody SubscribingRequest request) { | ||
|
||
request.check(); | ||
|
||
subscriptionService.unsubscribing(request.getChannelId(), request.getSubscriberId()); | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
mitube-app/src/main/java/com/misim/controller/model/CommentDto.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,21 @@ | ||
package com.misim.controller.model; | ||
|
||
import com.misim.exception.MitubeErrorCode; | ||
import com.misim.exception.MitubeException; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class CommentDto implements Checker{ | ||
|
||
@Schema(name = "commentId", description = "댓글 식별 정보", example = "1", requiredMode = Schema.RequiredMode.REQUIRED) | ||
private Long commentId; | ||
|
||
@Override | ||
public void check() { | ||
|
||
if (commentId == null) { | ||
throw new MitubeException(MitubeErrorCode.INVALID_COMMENT_ID); | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
mitube-app/src/main/java/com/misim/controller/model/Request/CreateCommentRequest.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
Oops, something went wrong.