diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java new file mode 100644 index 00000000..ca710d00 --- /dev/null +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java @@ -0,0 +1,58 @@ +package com.rollthedice.backend.domain.bookmark.api; + +import com.rollthedice.backend.domain.news.dto.response.NewsResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +public interface BookmarkApi { + @Operation( + summary = "북마크 조회", + description = "회원이 북마크한 뉴스를 페이지로 나누어 조회합니다.", + security = {@SecurityRequirement(name = "access_token")}, + tags = {"bookmark"} + ) + @ApiResponse( + responseCode = "200", + description = "OK" + ) + List getBookmarked( + Pageable pageable + ); + + @Operation( + summary = "북마크 저장", + description = "뉴스에 대하여 북마크로 저장합니다.", + security = {@SecurityRequirement(name = "access_token")}, + tags = {"bookmark"} + ) + @ApiResponse( + responseCode = "201", + description = "Created" + ) + void saveBookmark( + @Parameter(in = ParameterIn.PATH, description = "뉴스 ID", required = true) + Long newsId + ); + + @Operation( + summary = "북마크 삭제", + description = "저장된 북마크를 해제합니다.", + security = {@SecurityRequirement(name = "access_token")}, + tags = {"bookmark"} + ) + @ApiResponse( + responseCode = "204", + description = "No Content" + ) + void deleteBookmark( + @Parameter(in = ParameterIn.PATH, description = "뉴스 ID", required = true) + Long newsId + ); + +} diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/controller/BookmarkController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkController.java similarity index 87% rename from backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/controller/BookmarkController.java rename to backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkController.java index 6797e57f..6d4ad706 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/controller/BookmarkController.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkController.java @@ -1,4 +1,4 @@ -package com.rollthedice.backend.domain.bookmark.controller; +package com.rollthedice.backend.domain.bookmark.api; import com.rollthedice.backend.domain.bookmark.service.BookmarkService; import com.rollthedice.backend.domain.news.dto.response.NewsResponse; @@ -12,23 +12,26 @@ @RestController @RequiredArgsConstructor @RequestMapping("bookmarks") -public class BookmarkController { +public class BookmarkController implements BookmarkApi { private final BookmarkService bookmarkService; @ResponseStatus(HttpStatus.OK) @GetMapping("") + @Override public List getBookmarked(final Pageable pageable) { return bookmarkService.getBookmarkedNews(pageable); } @ResponseStatus(HttpStatus.CREATED) @PostMapping("/{newsId}") + @Override public void saveBookmark(@PathVariable final Long newsId) { bookmarkService.saveBookmark(newsId); } @ResponseStatus(HttpStatus.NO_CONTENT) @DeleteMapping("/{newsId}") + @Override public void deleteBookmark(@PathVariable final Long newsId) { bookmarkService.deleteBookmark(newsId); } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java new file mode 100644 index 00000000..548f4f4c --- /dev/null +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java @@ -0,0 +1,109 @@ +package com.rollthedice.backend.domain.debate.api; + +import com.rollthedice.backend.domain.debate.dto.request.DebateMessageRequest; +import com.rollthedice.backend.domain.debate.dto.request.DebateRoomRequest; +import com.rollthedice.backend.domain.debate.dto.response.DebateMessageResponse; +import com.rollthedice.backend.domain.debate.dto.response.DebateRoomResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import org.springframework.data.domain.Pageable; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + + +public interface DebateApi { + + @Operation( + summary = "토론방 생성", + description = "주제가 선택된 토론방을 생성합니다.", + security = {@SecurityRequirement(name = "access_token")}, + tags = {"debate_room"} + ) + @ApiResponse( + responseCode = "201", + description = "Created" + ) + void saveDebateRoom(@RequestBody DebateRoomRequest request); + + @Operation( + summary = "토론방 전체 조회", + description = "회원의 토론방을 페이지로 나누어 조회합니다.", + security = {@SecurityRequirement(name = "access_token")}, + tags = {"debate_room"} + ) + @ApiResponse( + responseCode = "200", + description = "OK" + ) + List getDebateRooms(Pageable pageable); + + @Operation( + summary = "토론방 삭제", + description = "토론방을 삭제합니다.", + security = {@SecurityRequirement(name = "access_token")}, + tags = {"debate_room"} + ) + @ApiResponse( + responseCode = "204", + description = "No Content" + ) + void deleteDebateRoom(@Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) + Long roomId + ); + + @Operation( + summary = "[인간] 토론 메세지 저장", + description = "사용자가 보낸 토론 메세지를 저장합니다.", + security = {@SecurityRequirement(name = "access_token")}, + tags = {"debate_message"} + ) + @ApiResponse( + responseCode = "201", + description = "Created" + ) + void saveHumanDebateMessage( + @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) + Long roomId, + + @RequestBody DebateMessageRequest request + ); + + @Operation( + summary = "[AI] 토론 메세지 저장", + description = "ChatGPT OPENAI가 보낸 토론 메세지를 저장합니다.", + security = {@SecurityRequirement(name = "access_token")}, + tags = {"debate_message"} + ) + @ApiResponse( + responseCode = "201", + description = "Created" + ) + void saveAIDebateMessage( + @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) + Long roomId, + + @RequestBody DebateMessageRequest request + ); + + @Operation( + summary = "토론 메세지 조회", + description = "토론방의 토론 메세지 이력을 조회합니다.", + security = {@SecurityRequirement(name = "access_token")}, + tags = {"debate_message"} + ) + @ApiResponse( + responseCode = "200", + description = "OK" + ) + List getDebateMessages( + @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) + Long roomId + ); + + + +} diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/controller/DebateController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateController.java similarity index 92% rename from backend/core/src/main/java/com/rollthedice/backend/domain/debate/controller/DebateController.java rename to backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateController.java index 090a3114..1191ca7c 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/controller/DebateController.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateController.java @@ -1,4 +1,4 @@ -package com.rollthedice.backend.domain.debate.controller; +package com.rollthedice.backend.domain.debate.api; import com.rollthedice.backend.domain.debate.dto.request.DebateMessageRequest; import com.rollthedice.backend.domain.debate.dto.request.DebateRoomRequest; @@ -17,42 +17,48 @@ @RestController @RequiredArgsConstructor @RequestMapping("debates") -public class DebateController { +public class DebateController implements DebateApi { private final DebateRoomService debateRoomService; private final DebateMessageService debateMessageService; @ResponseStatus(HttpStatus.CREATED) @PostMapping("") + @Override public void saveDebateRoom(@RequestBody @Valid final DebateRoomRequest request) { debateRoomService.saveDebateRoom(request); } @ResponseStatus(HttpStatus.OK) @GetMapping("") + @Override public List getDebateRooms(final Pageable pageable) { return debateRoomService.getDebateRooms(pageable); } @ResponseStatus(HttpStatus.NO_CONTENT) @DeleteMapping("/{roomId}") + @Override public void deleteDebateRoom(@PathVariable final Long roomId) { debateRoomService.deleteDebateRoom(roomId); } @ResponseStatus(HttpStatus.CREATED) @PostMapping("/{roomId}/human") + @Override public void saveHumanDebateMessage(@PathVariable final Long roomId, @RequestBody final DebateMessageRequest request) { debateMessageService.saveHumanDebateMessage(roomId, request); } @ResponseStatus(HttpStatus.CREATED) @PostMapping("/{roomId}/ai") + @Override public void saveAIDebateMessage(@PathVariable final Long roomId, @RequestBody final DebateMessageRequest request) { debateMessageService.saveAIDebateMessage(roomId, request); } @ResponseStatus(HttpStatus.OK) @GetMapping("/{roomId}") + @Override public List getDebateMessages(@PathVariable final Long roomId) { return debateMessageService.getDebateMessages(roomId); } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java new file mode 100644 index 00000000..3f87ce34 --- /dev/null +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java @@ -0,0 +1,20 @@ +package com.rollthedice.backend.domain.member.api; + +import com.rollthedice.backend.domain.member.dto.response.MemberResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; + +public interface MemberApi { + @Operation( + summary = "회원 정보 조회", + description = "회원 정보를 조회합니다.", + security = {@SecurityRequirement(name = "access_token")}, + tags = {"member"} + ) + @ApiResponse( + responseCode = "200", + description = "OK" + ) + MemberResponse getMemberInfo(); +} diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/member/controller/MemberController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberController.java similarity index 90% rename from backend/core/src/main/java/com/rollthedice/backend/domain/member/controller/MemberController.java rename to backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberController.java index 4817d16d..59284ff2 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/member/controller/MemberController.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberController.java @@ -1,4 +1,4 @@ -package com.rollthedice.backend.domain.member.controller; +package com.rollthedice.backend.domain.member.api; import com.rollthedice.backend.domain.member.dto.MemberServiceDto; import com.rollthedice.backend.domain.member.dto.MemberUpdateDto; @@ -13,10 +13,10 @@ @RestController @RequiredArgsConstructor @RequestMapping("members") -public class MemberController { +public class MemberController implements MemberApi{ private final MemberService memberService; - @PostMapping + @PostMapping("") public ResponseEntity updateMember(@LoginMemberEmail String email, @RequestBody MemberUpdateDto memberUpdateDto) { MemberServiceDto memberServiceDto = memberUpdateDto.toServiceDto(email); @@ -31,6 +31,7 @@ public ResponseEntity updateMember(@LoginMemberEmail String email, @ResponseStatus(HttpStatus.OK) @GetMapping("") + @Override public MemberResponse getMemberInfo() { return memberService.getMemberInfo(); } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java new file mode 100644 index 00000000..c66a033d --- /dev/null +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java @@ -0,0 +1,23 @@ +package com.rollthedice.backend.domain.news.api; + +import com.rollthedice.backend.domain.news.dto.response.NewsResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +public interface NewsApi { + @Operation( + summary = "요약 뉴스 조회", + description = "요약 뉴스를 페이지로 나누어 조회합니다.", + security = {@SecurityRequirement(name = "access_token")}, + tags = {"news"} + ) + @ApiResponse( + responseCode = "200", + description = "OK" + ) + List getNews(Pageable pageable); +} diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/controller/NewsController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsController.java similarity index 84% rename from backend/core/src/main/java/com/rollthedice/backend/domain/news/controller/NewsController.java rename to backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsController.java index 7f138c81..83128e2f 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/news/controller/NewsController.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsController.java @@ -1,4 +1,4 @@ -package com.rollthedice.backend.domain.news.controller; +package com.rollthedice.backend.domain.news.api; import com.rollthedice.backend.domain.news.dto.response.NewsResponse; import com.rollthedice.backend.domain.news.service.NewsService; @@ -12,11 +12,12 @@ @RestController @RequiredArgsConstructor @RequestMapping("news") -public class NewsController { +public class NewsController implements NewsApi { private final NewsService newsService; @ResponseStatus(HttpStatus.OK) @GetMapping("") + @Override public List getNews(final Pageable pageable) { return newsService.getNews(pageable); } diff --git a/backend/core/src/test/java/com/rollthedice/backend/domain/auth/AuthTest.java b/backend/core/src/test/java/com/rollthedice/backend/domain/auth/AuthTest.java index 25085d20..9d1f0085 100644 --- a/backend/core/src/test/java/com/rollthedice/backend/domain/auth/AuthTest.java +++ b/backend/core/src/test/java/com/rollthedice/backend/domain/auth/AuthTest.java @@ -2,7 +2,7 @@ import com.auth0.jwt.JWT; import com.auth0.jwt.algorithms.Algorithm; -import com.rollthedice.backend.domain.member.controller.MemberController; +import com.rollthedice.backend.domain.member.api.MemberController; import com.rollthedice.backend.domain.member.dto.MemberUpdateDto; import com.rollthedice.backend.domain.member.service.MemberService; import com.rollthedice.backend.global.LoginTest;