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 #104

Merged
merged 10 commits into from
May 1, 2024
Original file line number Diff line number Diff line change
@@ -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<NewsResponse> 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
);

}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<NewsResponse> 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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<DebateRoomResponse> 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<DebateMessageResponse> getDebateMessages(
@Parameter(in = ParameterIn.PATH, description = "ํ† ๋ก ๋ฐฉ ID", required = true)
Long roomId
);



}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<DebateRoomResponse> 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<DebateMessageResponse> getDebateMessages(@PathVariable final Long roomId) {
return debateMessageService.getDebateMessages(roomId);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -13,10 +13,10 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("members")
public class MemberController {
public class MemberController implements MemberApi{
private final MemberService memberService;

@PostMapping
@PostMapping("")
public ResponseEntity<HttpStatus> updateMember(@LoginMemberEmail String email,
@RequestBody MemberUpdateDto memberUpdateDto) {
MemberServiceDto memberServiceDto = memberUpdateDto.toServiceDto(email);
Expand All @@ -31,6 +31,7 @@ public ResponseEntity<HttpStatus> updateMember(@LoginMemberEmail String email,

@ResponseStatus(HttpStatus.OK)
@GetMapping("")
@Override
public MemberResponse getMemberInfo() {
return memberService.getMemberInfo();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@
public class MemberUpdateDto {
@Schema(description = "๋ณ€๊ฒฝํ•  ๋‹‰๋„ค์ž„")
private String nickname;
@Schema(description = "๋ณ€๊ฒฝํ•  ์ด๋ฏธ์ง€ S3 Url")
private String imageUrl;

public MemberServiceDto toServiceDto(String email) {
return MemberServiceDto.builder()
.email(email)
.nickname(this.nickname)
.imageUrl(this.imageUrl)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -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<NewsResponse> getNews(Pageable pageable);
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<NewsResponse> getNews(final Pageable pageable) {
return newsService.getNews(pageable);
}
Expand Down
Loading
Loading