Skip to content

Commit

Permalink
Merge pull request #198 from TRIP-Side-Project/feature/#174-forum-swa…
Browse files Browse the repository at this point in the history
…gger

게시판 관련 Swagger 작성
  • Loading branch information
kwondongwook authored Jan 5, 2024
2 parents 1fa781f + 85e8ddf commit 9751f32
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.api.trip.domain.article.controller.dto.*;
import com.api.trip.domain.article.service.ArticleService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
Expand All @@ -17,32 +18,37 @@ public class ArticleController {

private final ArticleService articleService;

@Operation(summary = "게시글 등록")
@PostMapping
public ResponseEntity<Long> createArticle(@RequestBody @Valid CreateArticleRequest request) {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
return ResponseEntity.ok(articleService.createArticle(request, email));
}

@Operation(summary = "게시글 수정")
@PatchMapping("/{articleId}")
public ResponseEntity<Void> updateArticle(@PathVariable Long articleId, @RequestBody @Valid UpdateArticleRequest request) {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
articleService.updateArticle(articleId, request, email);
return ResponseEntity.ok().build();
}

@Operation(summary = "게시글 삭제")
@DeleteMapping("/{articleId}")
public ResponseEntity<Void> deleteArticle(@PathVariable Long articleId) {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
articleService.deleteArticle(articleId, email);
return ResponseEntity.ok().build();
}

@Operation(summary = "게시글 상세 조회")
@GetMapping("/{articleId}")
public ResponseEntity<ReadArticleResponse> readArticle(@PathVariable Long articleId) {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
return ResponseEntity.ok(articleService.readArticle(articleId, email));
}

@Operation(summary = "게시글 목록 조회 (게시글 검색)")
@GetMapping
public ResponseEntity<GetArticlesResponse> getArticles(
@PageableDefault(size = 8) Pageable pageable,
Expand All @@ -54,6 +60,7 @@ public ResponseEntity<GetArticlesResponse> getArticles(
return ResponseEntity.ok(articleService.getArticles(pageable, sortCode, category, title, tagName));
}

@Operation(summary = "내가 쓴 게시글 목록 조회")
@GetMapping("/me")
public ResponseEntity<GetMyArticlesResponse> getMyArticles() {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class ReadArticleResponse {
private String writerNickname;
private String writerRole;
private String writerProfileImg;
private String writerIntro;
private List<String> tags;
private String content;
private long viewCount;
Expand All @@ -34,6 +35,7 @@ public static ReadArticleResponse of(Article article, List<ArticleTag> articleTa
.title(article.getTitle())
.writerId(writer.getId())
.writerNickname(writer.getNickname())
.writerIntro(writer.getIntro())
.writerProfileImg(writer.getProfileImg())
.writerRole(writer.getRole().name())
.tags(articleTags.stream().map(articleTag -> articleTag.getTag().getName()).toList())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.api.trip.domain.articlefile.controller;

import com.api.trip.domain.articlefile.service.ArticleFileService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.context.SecurityContextHolder;
Expand All @@ -16,6 +17,7 @@ public class ArticleFileController {

private final ArticleFileService articleFileService;

@Operation(summary = "게시글 파일(이미지) 업로드")
@PostMapping
public ResponseEntity<String> upload(MultipartFile file) {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.api.trip.domain.comment.controller.dto.GetMyCommentsResponse;
import com.api.trip.domain.comment.controller.dto.UpdateCommentRequest;
import com.api.trip.domain.comment.service.CommentService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
Expand All @@ -18,31 +19,36 @@ public class CommentController {

private final CommentService commentService;

@Operation(summary = "(대)댓글 등록")
@PostMapping
public ResponseEntity<Long> createComment(@RequestBody @Valid CreateCommentRequest request) {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
return ResponseEntity.ok(commentService.createComment(request, email));
}

@Operation(summary = "(대)댓글 수정")
@PatchMapping("/{commentId}")
public ResponseEntity<Void> updateComment(@PathVariable Long commentId, @RequestBody @Valid UpdateCommentRequest request) {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
commentService.updateComment(commentId, request, email);
return ResponseEntity.ok().build();
}

@Operation(summary = "(대)댓글 삭제")
@DeleteMapping("/{commentId}")
public ResponseEntity<Void> deleteComment(@PathVariable Long commentId) {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
commentService.deleteComment(commentId, email);
return ResponseEntity.ok().build();
}

@Operation(summary = "(대)댓글 목록 조회")
@GetMapping
public ResponseEntity<GetCommentsResponse> getComments(Long articleId) {
return ResponseEntity.ok(commentService.getComments(articleId));
}

@Operation(summary = "내가 쓴 (대)댓글 목록 조회")
@GetMapping("/me")
public ResponseEntity<GetMyCommentsResponse> getMyComments() {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.api.trip.domain.interestarticle.controller.dto.CreateInterestArticleRequest;
import com.api.trip.domain.interestarticle.controller.dto.GetMyInterestArticlesResponse;
import com.api.trip.domain.interestarticle.service.InterestArticleService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
Expand All @@ -16,19 +17,22 @@ public class InterestArticleController {

private final InterestArticleService interestArticleService;

@Operation(summary = "게시글 좋아요")
@PostMapping
public ResponseEntity<Long> createInterestArticle(@RequestBody @Valid CreateInterestArticleRequest request) {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
return ResponseEntity.ok(interestArticleService.createInterestArticle(request, email));
}

@Operation(summary = "게시글 좋아요 취소")
@DeleteMapping("/{interestArticleId}")
public ResponseEntity<Void> deleteInterestArticle(@PathVariable Long interestArticleId) {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
interestArticleService.deleteInterestArticle(interestArticleId, email);
return ResponseEntity.ok().build();
}

@Operation(summary = "내가 좋아한 게시글 목록 조회")
@GetMapping("/me")
public ResponseEntity<GetMyInterestArticlesResponse> getMyInterestArticles() {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.api.trip.domain.notification.controller.dto.GetMyNotificationsResponse;
import com.api.trip.domain.notification.controller.dto.ReadNotificationRequest;
import com.api.trip.domain.notification.service.NotificationService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand All @@ -27,6 +28,7 @@ public class NotificationController {
private final NotificationService notificationService;
private final SseEmitterMap sseEmitterMap;

@Operation(summary = "SSE 연결")
@GetMapping(value = "/connect", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public ResponseEntity<SseEmitter> connect() {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
Expand All @@ -39,26 +41,30 @@ public ResponseEntity<SseEmitter> connect() {
return ResponseEntity.ok(sseEmitter);
}

@Operation(summary = "알림 목록 조회")
@GetMapping("/me")
public ResponseEntity<GetMyNotificationsResponse> getMyNotifications() {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
return ResponseEntity.ok(notificationService.getMyNotifications(email));
}

@Operation(summary = "알림 읽음 처리")
@PatchMapping
public ResponseEntity<Void> readNotification(@RequestBody ReadNotificationRequest request) {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
notificationService.readNotification(request, email);
return ResponseEntity.ok().build();
}

@Operation(summary = "알림 삭제")
@DeleteMapping
public ResponseEntity<Void> deleteNotification(@RequestBody DeleteNotificationRequest request) {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
notificationService.deleteNotification(request, email);
return ResponseEntity.ok().build();
}

@Operation(summary = "알림 목록 삭제")
@DeleteMapping("/me")
public ResponseEntity<Void> deleteMyNotifications() {
String email = SecurityContextHolder.getContext().getAuthentication().getName();
Expand Down

0 comments on commit 9751f32

Please sign in to comment.