Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Swagger API 문서에 설명 추가 및 타임존 설정 #49

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/master_weekly_cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ jobs:
script: |
cd ./project
sudo fuser -k -n tcp 8080 || true
nohup java -jar app.jar > ./output.log 2>&1 &
nohup java -Duser.timezone=Asia/Seoul -jar app.jar > ./output.log 2>&1 &
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
import com.potatocake.everymoment.dto.response.CategoryResponse;
import com.potatocake.everymoment.security.MemberDetails;
import com.potatocake.everymoment.service.CategoryService;
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.tags.Tag;
import jakarta.validation.Valid;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand All @@ -19,44 +25,64 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "Categories", description = "카테고리 관리 API")
@RequiredArgsConstructor
@RequestMapping("/api/categories")
@RestController
public class CategoryController {

private final CategoryService categoryService;

@Operation(summary = "카테고리 목록 조회", description = "사용자의 카테고리 목록을 조회합니다.")
@ApiResponse(responseCode = "200", description = "카테고리 목록 조회 성공", content = @Content(schema = @Schema(implementation = CategoryResponse.class)))
@GetMapping
public ResponseEntity<SuccessResponse<CategoryResponse>> getCategories(
@Parameter(description = "인증된 사용자 정보", hidden = true)
@AuthenticationPrincipal MemberDetails memberDetails) {
List<CategoryResponse> categories = categoryService.getCategories(memberDetails.getId());

return ResponseEntity.ok()
.body(SuccessResponse.ok(categories));
}

@Operation(summary = "카테고리 추가", description = "새로운 카테고리를 추가합니다.")
@ApiResponse(responseCode = "200", description = "카테고리 추가 성공")
@PostMapping
public ResponseEntity<SuccessResponse> addCategory(@RequestBody @Valid CategoryCreateRequest request,
@AuthenticationPrincipal MemberDetails memberDetails) {
public ResponseEntity<SuccessResponse> addCategory(
@Parameter(description = "카테고리 생성 정보", required = true)
@RequestBody @Valid CategoryCreateRequest request,
@Parameter(description = "인증된 사용자 정보", hidden = true)
@AuthenticationPrincipal MemberDetails memberDetails) {
categoryService.addCategory(memberDetails.getId(), request);

return ResponseEntity.ok()
.body(SuccessResponse.ok());
}

@Operation(summary = "카테고리 수정", description = "기존 카테고리를 수정합니다.")
@ApiResponse(responseCode = "200", description = "카테고리 수정 성공")
@PatchMapping("/{categoryId}")
public ResponseEntity<SuccessResponse> updateCategory(@PathVariable Long categoryId,
@RequestBody @Valid CategoryCreateRequest request,
@AuthenticationPrincipal MemberDetails memberDetails) {
public ResponseEntity<SuccessResponse> updateCategory(
@Parameter(description = "수정할 카테고리 ID", required = true)
@PathVariable Long categoryId,
@Parameter(description = "카테고리 수정 정보", required = true)
@RequestBody @Valid CategoryCreateRequest request,
@Parameter(description = "인증된 사용자 정보", hidden = true)
@AuthenticationPrincipal MemberDetails memberDetails) {
categoryService.updateCategory(categoryId, memberDetails.getId(), request);

return ResponseEntity.ok()
.body(SuccessResponse.ok());
}

@Operation(summary = "카테고리 삭제", description = "카테고리를 삭제합니다.")
@ApiResponse(responseCode = "200", description = "카테고리 삭제 성공")
@DeleteMapping("/{categoryId}")
public ResponseEntity<SuccessResponse> deleteCategory(@PathVariable Long categoryId,
@AuthenticationPrincipal MemberDetails memberDetails) {
public ResponseEntity<SuccessResponse> deleteCategory(
@Parameter(description = "삭제할 카테고리 ID", required = true)
@PathVariable Long categoryId,
@Parameter(description = "인증된 사용자 정보", hidden = true)
@AuthenticationPrincipal MemberDetails memberDetails) {
categoryService.deleteCategory(categoryId, memberDetails.getId());

return ResponseEntity.ok()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
import com.potatocake.everymoment.dto.request.CommentRequest;
import com.potatocake.everymoment.security.MemberDetails;
import com.potatocake.everymoment.service.CommentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand All @@ -15,18 +18,23 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "Comments", description = "댓글 관리 API")
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/comments")
public class CommentController {

private final CommentService commentService;

//댓글 수정
@Operation(summary = "댓글 수정", description = "기존 댓글을 수정합니다.")
@ApiResponse(responseCode = "200", description = "댓글 수정 성공")
@PatchMapping("/{commentId}")
public ResponseEntity<SuccessResponse<Void>> updateComment(
@Parameter(description = "인증된 사용자 정보", hidden = true)
@AuthenticationPrincipal MemberDetails memberDetails,
@Parameter(description = "수정할 댓글 ID", required = true)
@PathVariable Long commentId,
@Parameter(description = "댓글 수정 정보", required = true)
@RequestBody CommentRequest commentRequest) {
Long memberId = memberDetails.getId();

Expand All @@ -36,10 +44,13 @@ public ResponseEntity<SuccessResponse<Void>> updateComment(
.body(SuccessResponse.ok());
}

//댓글 삭제
@Operation(summary = "댓글 삭제", description = "댓글을 삭제합니다.")
@ApiResponse(responseCode = "200", description = "댓글 삭제 성공")
@DeleteMapping("/{commentId}")
public ResponseEntity<SuccessResponse<Void>> deleteComment(
@Parameter(description = "인증된 사용자 정보", hidden = true)
@AuthenticationPrincipal MemberDetails memberDetails,
@Parameter(description = "삭제할 댓글 ID", required = true)
@PathVariable Long commentId) {
Long memberId = memberDetails.getId();

Expand Down
Loading
Loading