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

Dev backend #171

Merged
merged 22 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0c23e2e
refactor: ReadNews ๋„๋ฉ”์ธ ๋ถ„๋ฆฌ
yeonjy Jun 22, 2024
e13bb2a
refactor: ReadNews๋„๋ฉ”์ธ ๋ถ„๋ฆฌ ์ ์šฉ
yeonjy Jun 29, 2024
8e786ec
refactor: ReadNews ๋„๋ฉ”์ธ ๋ถ„๋ฆฌ api Test์— ์ ์šฉ
yeonjy Jun 29, 2024
167d066
refactor: ReadNews ๋„๋ฉ”์ธ ๋ถ„๋ฆฌ repository Test ์ ์šฉ
yeonjy Jun 29, 2024
83d8a83
refactor: ํ•„์š”์—†๋Š” mock bean ์ฃผ์ž… ์‚ญ์ œ
yeonjy Jun 29, 2024
b6a091a
refactor: lambda -> method reference
yeonjy Jun 29, 2024
54e2364
Merge pull request #168 from tukcomCD2024/refactor/#166-devide-news-rโ€ฆ
yeonjy Jun 29, 2024
0417379
Merge remote-tracking branch 'origin/Dev-backend' into feat/#169-backโ€ฆ
yeonjy Jun 29, 2024
2a702cb
feat: success response
yeonjy Jun 30, 2024
3308737
refactor: directory config -> common
yeonjy Jun 30, 2024
7f57204
feat: BookmarkApi์— success response ์ ์šฉ
yeonjy Jun 30, 2024
b43489d
refactor: BaseTimeEntity directory ์ด๋™ ์ ์šฉ
yeonjy Jun 30, 2024
dc2bca4
feat: Debate API ์— Success Response ์ ์šฉ
yeonjy Jun 30, 2024
cebd6bf
feat: Member API์— Success Response ์ ์šฉ
yeonjy Jun 30, 2024
107726b
feat: News API์— Success Response ์ ์šฉ
yeonjy Jun 30, 2024
d94fb91
feat: ReadNews API์— Success Response ์ ์šฉ
yeonjy Jun 30, 2024
e33a25e
feat: Statistics API์— Success Response ์ ์šฉ
yeonjy Jun 30, 2024
7c4567d
feat: Auth API์— Success Response ์ ์šฉ
yeonjy Jun 30, 2024
86c8b0a
feat: success message ์ˆ˜์ •
yeonjy Jun 30, 2024
79686b8
refactor: swagger tags -> @Tag
yeonjy Jun 30, 2024
43f0208
refactor: ํ•„์š”์—†๋Š” log ์‚ญ์ œ
yeonjy Jun 30, 2024
e60c1d6
Merge pull request #170 from tukcomCD2024/feat/#169-backend-api-succeโ€ฆ
yeonjy Jun 30, 2024
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
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
Loading