Skip to content

Commit

Permalink
Merge pull request #170 from tukcomCD2024/feat/#169-backend-api-succe…
Browse files Browse the repository at this point in the history
…ss-response

Feat/#169 Api Success Response 설정
  • Loading branch information
yeonjy authored Jun 30, 2024
2 parents 54e2364 + 43f0208 commit e60c1d6
Show file tree
Hide file tree
Showing 86 changed files with 2,806 additions and 819 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,42 @@

import com.rollthedice.backend.domain.bookmark.dto.response.BookmarkResponse;
import com.rollthedice.backend.domain.news.dto.response.NewsResponse;
import com.rollthedice.backend.global.common.response.SuccessResponse;
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 io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.data.domain.Pageable;

import java.util.List;

@Tag(name = "Bookmark")
public interface BookmarkApi {
@Operation(
summary = "북마크 전체 조회",
description = "회원이 북마크한 뉴스를 페이지로 나누어 조회합니다.",
security = {@SecurityRequirement(name = "access_token")},
tags = {"북마크"}
security = {@SecurityRequirement(name = "access_token")}
)
@ApiResponse(
responseCode = "200",
description = "OK"
description = "북마크 전체 조회를 성공했습니다."
)
List<NewsResponse> getAllBookmarkedNews(
SuccessResponse<List<NewsResponse>> getAllBookmarkedNews(
Pageable pageable
);

@Operation(
summary = "뉴스 북마크 여부 조회",
description = "로그인한 회원이 해당 뉴스를 북마크 했는지 여부를 조회합니다.",
security = {@SecurityRequirement(name = "access_token")},
tags = {"북마크"}
security = {@SecurityRequirement(name = "access_token")}
)
@ApiResponse(
responseCode = "200",
description = "OK"
description = "뉴스가 북마크 여부 조회를 성공했습니다."
)
BookmarkResponse getIsBookmarked(
SuccessResponse<BookmarkResponse> getIsBookmarked(
@Parameter(in = ParameterIn.PATH, description = "뉴스 ID", required = true)
Long newsId
);
Expand All @@ -45,29 +46,27 @@ BookmarkResponse getIsBookmarked(
@Operation(
summary = "북마크 저장",
description = "뉴스에 대하여 북마크로 저장합니다.",
security = {@SecurityRequirement(name = "access_token")},
tags = {"북마크"}
security = {@SecurityRequirement(name = "access_token")}
)
@ApiResponse(
responseCode = "201",
description = "Created"
description = "북마크 저장에 성공했습니다."
)
void saveBookmark(
SuccessResponse<String> saveBookmark(
@Parameter(in = ParameterIn.PATH, description = "뉴스 ID", required = true)
Long newsId
);

@Operation(
summary = "북마크 삭제",
description = "저장된 북마크를 해제합니다.",
security = {@SecurityRequirement(name = "access_token")},
tags = {"북마크"}
security = {@SecurityRequirement(name = "access_token")}
)
@ApiResponse(
responseCode = "204",
description = "No Content"
description = "북마크 삭제에 성공했습니다."
)
void deleteBookmark(
SuccessResponse<String> deleteBookmark(
@Parameter(in = ParameterIn.PATH, description = "뉴스 ID", required = true)
Long newsId
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import com.rollthedice.backend.domain.bookmark.dto.response.BookmarkResponse;
import com.rollthedice.backend.domain.bookmark.service.BookmarkService;
import com.rollthedice.backend.domain.news.dto.response.NewsResponse;
import com.rollthedice.backend.global.common.response.SuccessResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.rollthedice.backend.global.common.response.SuccessCode.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("bookmarks")
Expand All @@ -19,28 +22,32 @@ public class BookmarkController implements BookmarkApi {
@ResponseStatus(HttpStatus.OK)
@GetMapping("")
@Override
public List<NewsResponse> getAllBookmarkedNews(final Pageable pageable) {
return bookmarkService.getAllBookmarkedNews(pageable);
public SuccessResponse<List<NewsResponse>> getAllBookmarkedNews(final Pageable pageable) {
List<NewsResponse> response = bookmarkService.getAllBookmarkedNews(pageable);
return SuccessResponse.of(GET_ALL_BOOKMARK_SUCCESS, response);
}

@ResponseStatus(HttpStatus.OK)
@GetMapping("/{newsId}")
@Override
public BookmarkResponse getIsBookmarked(@PathVariable final Long newsId) {
return bookmarkService.getIsBookmarked(newsId);
public SuccessResponse<BookmarkResponse> getIsBookmarked(@PathVariable final Long newsId) {
BookmarkResponse response = bookmarkService.getIsBookmarked(newsId);
return SuccessResponse.of(GET_IS_BOOKMARKED_SUCCESS, response);
}

@ResponseStatus(HttpStatus.CREATED)
@PostMapping("/{newsId}")
@Override
public void saveBookmark(@PathVariable final Long newsId) {
public SuccessResponse<String> saveBookmark(@PathVariable final Long newsId) {
bookmarkService.saveBookmark(newsId);
return SuccessResponse.of(CREATE_BOOKMARK_SUCCESS);
}

@ResponseStatus(HttpStatus.NO_CONTENT)
@DeleteMapping("/{newsId}")
@Override
public void deleteBookmark(@PathVariable final Long newsId) {
public SuccessResponse<String> deleteBookmark(@PathVariable final Long newsId) {
bookmarkService.deleteBookmark(newsId);
return SuccessResponse.of(DELETE_BOOKMARK_SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.rollthedice.backend.domain.member.entity.Member;
import com.rollthedice.backend.domain.news.entity.News;
import com.rollthedice.backend.global.config.BaseTimeEntity;
import com.rollthedice.backend.global.common.BaseTimeEntity;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,67 @@
import com.rollthedice.backend.domain.debate.dto.response.DebateRoomResponse;
import com.rollthedice.backend.domain.debate.dto.response.DebateRoomSaveResponse;
import com.rollthedice.backend.domain.debate.dto.response.DebateSummaryResponse;
import com.rollthedice.backend.global.common.response.SuccessResponse;
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.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;


@Tag(name = "Debate")
public interface DebateApi {

@Operation(
summary = "토론방 생성",
description = "주제가 선택된 토론방을 생성합니다.",
security = {@SecurityRequirement(name = "access_token")},
tags = {"토론방"}
security = {@SecurityRequirement(name = "access_token")}
)
@ApiResponse(
responseCode = "201",
description = "Created"
description = "토론방 생성에 성공했습니다."
)
DebateRoomSaveResponse saveDebateRoom(@RequestBody DebateRoomRequest request);
SuccessResponse<DebateRoomSaveResponse> saveDebateRoom(@RequestBody DebateRoomRequest request);

@Operation(
summary = "토론방 전체 조회",
description = "회원의 토론방을 페이지로 나누어 조회합니다.",
security = {@SecurityRequirement(name = "access_token")},
tags = {"토론방"}
security = {@SecurityRequirement(name = "access_token")}
)
@ApiResponse(
responseCode = "200",
description = "요청에 성공하였습니다."
description = "토론방 전체 조회에 성공했습니다"
)
List<DebateRoomResponse> getDebateRooms(Pageable pageable);
SuccessResponse<List<DebateRoomResponse>> getDebateRooms(Pageable pageable);

@Operation(
summary = "토론방 삭제",
description = "토론방을 삭제합니다.",
security = {@SecurityRequirement(name = "access_token")},
tags = {"토론방"}
security = {@SecurityRequirement(name = "access_token")}
)
@ApiResponse(
responseCode = "204",
description = "토론방 삭제에 성공하였으며, 응답값은 없습니다."
description = "토론방 삭제에 성공했습니다."
)
void deleteDebateRoom(@Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true)
SuccessResponse<String> deleteDebateRoom(@Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true)
Long roomId
);

@Operation(
summary = "[인간] 토론 메세지 저장",
description = "사용자가 보낸 토론 메세지를 저장합니다.",
security = {@SecurityRequirement(name = "access_token")},
tags = {"토론 메세지"}
security = {@SecurityRequirement(name = "access_token")}
)
@ApiResponse(
responseCode = "201",
description = "Created"
description = "사용자가 보낸 토론 메세지 저장에 성공했습니다."
)
void saveHumanDebateMessage(
SuccessResponse<String> saveHumanDebateMessage(
@Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true)
Long roomId,

Expand All @@ -78,14 +76,13 @@ void saveHumanDebateMessage(
@Operation(
summary = "[AI] 토론 메세지 저장",
description = "ChatGPT OPENAI가 보낸 토론 메세지를 저장합니다.",
security = {@SecurityRequirement(name = "access_token")},
tags = {"토론 메세지"}
security = {@SecurityRequirement(name = "access_token")}
)
@ApiResponse(
responseCode = "201",
description = "Created"
description = "AI가 보낸 토론 메세지 저장에 성공했습니다."
)
void saveAIDebateMessage(
SuccessResponse<String> saveAIDebateMessage(
@Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true)
Long roomId,

Expand All @@ -95,79 +92,74 @@ void saveAIDebateMessage(
@Operation(
summary = "토론 종료",
description = "토론을 종료합니다.",
security = {@SecurityRequirement(name = "access_token")},
tags = {"토론방"}
security = {@SecurityRequirement(name = "access_token")}
)
@ApiResponses(value = {
@ApiResponse(
responseCode = "204",
description = "요청에 성공하였으며 응답값은 없습니다."
description = "토론 종료에 성공했습니다."
),
@ApiResponse(
responseCode = "404",
description = "토론방을 찾지 못했습니다."
)
})
void finishDebate(
SuccessResponse<String> finishDebate(
@Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true)
Long roomId
);

@Operation(
summary = "토론 메세지 조회",
description = "토론방의 토론 메세지 이력을 조회합니다.",
security = {@SecurityRequirement(name = "access_token")},
tags = {"토론 메세지"}
security = {@SecurityRequirement(name = "access_token")}
)
@ApiResponse(
responseCode = "200",
description = "요청에 성공하였습니다."
description = "토론 메세지 조회에 성공했습니다."
)
List<DebateMessageResponse> getDebateMessages(
SuccessResponse<List<DebateMessageResponse>> getDebateMessages(
@Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true)
Long roomId
);

@Operation(
summary = "토론 요약",
description = "토론방의 토론 메세지들을 요약합니다.",
security = {@SecurityRequirement(name = "access_token")},
tags = {"토론방"}
security = {@SecurityRequirement(name = "access_token")}
)
@ApiResponses(value = {
@ApiResponse(
responseCode = "201",
description = "토론 요약이 성공하였습니다."
description = "토론 요약에 성공했습니다."
),
@ApiResponse(
responseCode = "404",
description = "토론방을 찾지 못했습니다."
)
})
DebateSummaryResponse summarizeDebate(
SuccessResponse<DebateSummaryResponse> summarizeDebate(
@Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true)
Long roomId
);

@Operation(
summary = "토론 요약 조회",
description = "토론 요약 내용을 조회합니다.",
security = {@SecurityRequirement(name = "access_token")},
tags = {"토론방"}
security = {@SecurityRequirement(name = "access_token")}
)
@ApiResponses(value = {
@ApiResponse(
responseCode = "200",
description = "요청에 성공하였습니다."
description = "토론 요약 조회에 성공했습니다."
),
@ApiResponse(
responseCode = "404",
description = "토론방을 찾지 못했습니다."
)
})
DebateSummaryResponse getSummarizedDebate(
SuccessResponse<DebateSummaryResponse> getSummarizedDebate(
@Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true)
Long roomId
);

}
Loading

0 comments on commit e60c1d6

Please sign in to comment.