Skip to content

Commit

Permalink
Merge pull request #104 from tukcomCD2024/Dev-backend
Browse files Browse the repository at this point in the history
Dev backend
  • Loading branch information
yeonjy authored May 1, 2024
2 parents 140e629 + ede1eeb commit 7af5658
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 17 deletions.
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

0 comments on commit 7af5658

Please sign in to comment.