-
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 #51 from PowerSupply-ES/chore-swagger
Swagger 적용
- Loading branch information
Showing
49 changed files
with
972 additions
and
572 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
75 changes: 75 additions & 0 deletions
75
src/main/java/com/powersupply/PES/answer/controller/AnswerController.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,75 @@ | ||
package com.powersupply.PES.answer.controller; | ||
|
||
import com.powersupply.PES.answer.dto.AnswerDTO; | ||
import com.powersupply.PES.answer.service.AnswerService; | ||
import com.powersupply.PES.utils.ResponseUtil; | ||
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.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@Tag(name = "Answer", description = "답변 관련 API") | ||
public class AnswerController { | ||
|
||
private final AnswerService answerService; | ||
|
||
@Operation(summary = "답변 생성", description = "사용자가 답변을 생성합니다.") | ||
@ApiResponses({ | ||
@ApiResponse(responseCode = "201", description = "답변 생성 성공"), | ||
@ApiResponse(responseCode = "400", description = "잘못된 요청"), | ||
@ApiResponse(responseCode = "500", description = "서버 오류") | ||
}) | ||
@PostMapping("/api/answer") | ||
public ResponseEntity<AnswerDTO.GetAnswerId> createAnswer( | ||
@Parameter(description = "회원 이메일", example = "[email protected]") @RequestParam("memberEmail") String email, | ||
@Parameter(description = "문제 ID", example = "1") @RequestParam("problemId") Long problemId) { | ||
return ResponseEntity.status(HttpStatus.CREATED).body(answerService.createAnswer(email, problemId)); | ||
} | ||
|
||
@Operation(summary = "질문 및 답변 조회", description = "특정 답변 ID에 대한 질문과 답변을 조회합니다.") | ||
@ApiResponses({ | ||
@ApiResponse(responseCode = "200", description = "조회 성공(토큰에 문제가 없고 유저를 DB에서 찾을 수 있는 경우)"), | ||
@ApiResponse(responseCode = "404", description = "해당 answerId를 찾을 수 없는 경우"), | ||
@ApiResponse(responseCode = "500", description = "서버 오류") | ||
}) | ||
@GetMapping("/api/answer/{answerId}") | ||
public ResponseEntity<AnswerDTO.GetAnswer> getAnswer( | ||
@Parameter(description = "답변 ID", example = "1") @PathVariable Long answerId) { | ||
return ResponseEntity.ok().body(answerService.getAnswer(answerId)); | ||
} | ||
|
||
@Operation(summary = "답변하기", description = "사용자가 특정 답변 ID에 대해 답변을 작성합니다.") | ||
@ApiResponses({ | ||
@ApiResponse(responseCode = "200", description = "답변 작성 성공"), | ||
@ApiResponse(responseCode = "400", description = "answer 내용이 null인 경우 or 이미 댓글이 있어 수정이 불가능 한 경우"), | ||
@ApiResponse(responseCode = "404", description = "answer의 주인과 토큰이 다른 경우"), | ||
@ApiResponse(responseCode = "500", description = "서버 오류") | ||
}) | ||
@PostMapping("/api/answer/{answerId}") | ||
public ResponseEntity<?> postAnswer( | ||
@Parameter(description = "답변 ID", example = "1") @PathVariable Long answerId, | ||
@RequestBody AnswerDTO.AnswerContent dto) { | ||
answerService.postAnswer(answerId, dto); | ||
return ResponseUtil.successResponse(""); | ||
} | ||
|
||
@Operation(summary = "풀이 보기", description = "특정 문제 ID에 대한 풀이 목록을 조회합니다.") | ||
@ApiResponses({ | ||
@ApiResponse(responseCode = "201", description = "토큰에 문제가 없고 유저를 DB에서 찾을 수 있는 경우"), | ||
@ApiResponse(responseCode = "204", description = "아직 푼 사람이 없는 경우"), | ||
@ApiResponse(responseCode = "404", description = "problemId가 잘못된 경우"), | ||
@ApiResponse(responseCode = "500", description = "서버 오류") | ||
}) | ||
@GetMapping("/api/answerlist/{problemId}") | ||
public ResponseEntity<?> getAnswerList( | ||
@Parameter(description = "문제 ID", example = "1") @PathVariable Long problemId) { | ||
return answerService.getAnswerList(problemId); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...powersupply/PES/domain/dto/AnswerDTO.java → ...powersupply/PES/answer/dto/AnswerDTO.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
7 changes: 6 additions & 1 deletion
7
...upply/PES/domain/entity/AnswerEntity.java → ...upply/PES/answer/entity/AnswerEntity.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
6 changes: 3 additions & 3 deletions
6
...pply/PES/repository/AnswerRepository.java → ...S/answer/repository/AnswerRepository.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
16 changes: 12 additions & 4 deletions
16
...owersupply/PES/service/AnswerService.java → ...ply/PES/answer/service/AnswerService.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
47 changes: 47 additions & 0 deletions
47
src/main/java/com/powersupply/PES/comment/controller/CommentController.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,47 @@ | ||
package com.powersupply.PES.comment.controller; | ||
|
||
import com.powersupply.PES.comment.dto.CommentDTO; | ||
import com.powersupply.PES.comment.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.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@Tag(name = "Comment", description = "댓글 관련 API") | ||
public class CommentController { | ||
|
||
private final CommentService commentService; | ||
|
||
@Operation(summary = "댓글 조회", description = "특정 답변 ID에 대한 댓글을 조회합니다.") | ||
@ApiResponses({ | ||
@ApiResponse(responseCode = "200", description = "조회 성공"), | ||
@ApiResponse(responseCode = "204", description = "댓글이 없는 경우"), | ||
@ApiResponse(responseCode = "500", description = "서버 오류") | ||
}) | ||
@GetMapping("/api/comment/{answerId}") | ||
public ResponseEntity<?> getComment( | ||
@Parameter(description = "답변 ID", example = "1") @PathVariable Long answerId) { | ||
return commentService.getComment(answerId); | ||
} | ||
|
||
@Operation(summary = "댓글 달기", description = "특정 답변 ID에 대해 댓글을 작성합니다.") | ||
@ApiResponses({ | ||
@ApiResponse(responseCode = "201", description = "토큰에 문제가 없고 유저를 DB에서 찾아 정상적으로 댓글을 생성한 경우"), | ||
@ApiResponse(responseCode = "400", description = "이미 자신의 댓글이 있는 경우"), | ||
@ApiResponse(responseCode = "403", description = "재학생이 아닌 경우 / jwt 문제 / 자신의 답변에 댓글을 단 경우 / 최대 댓글 수 도달"), | ||
@ApiResponse(responseCode = "404", description = "answerId가 잘못된 경우"), | ||
@ApiResponse(responseCode = "500", description = "서버 오류") | ||
}) | ||
@PostMapping("/api/comment/{answerId}") | ||
public ResponseEntity<?> createComment( | ||
@Parameter(description = "답변 ID", example = "1") @PathVariable Long answerId, | ||
@RequestBody CommentDTO.CreateComment dto) { | ||
return commentService.createComment(answerId, dto); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...owersupply/PES/domain/dto/CommentDTO.java → ...wersupply/PES/comment/dto/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
5 changes: 4 additions & 1 deletion
5
...pply/PES/domain/entity/CommentEntity.java → ...ply/PES/comment/entity/CommentEntity.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
4 changes: 2 additions & 2 deletions
4
...ply/PES/repository/CommentRepository.java → ...comment/repository/CommentRepository.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
16 changes: 8 additions & 8 deletions
16
...wersupply/PES/service/CommentService.java → ...y/PES/comment/service/CommentService.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
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
Oops, something went wrong.