Skip to content

Commit

Permalink
[BE] Room Controller 역할 분리(#595) (#596)
Browse files Browse the repository at this point in the history
* refactor: Room Controller 역할 분리

* refactor: 피드백 반영

---------

Co-authored-by: youngsu5582 <[email protected]>
  • Loading branch information
github-actions[bot] and youngsu5582 authored Oct 14, 2024
1 parent f6beb1a commit 83c7406
Show file tree
Hide file tree
Showing 10 changed files with 303 additions and 179 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package corea.matchresult.controller;

import corea.auth.annotation.LoginMember;
import corea.auth.domain.AuthInfo;
import corea.matchresult.dto.MatchResultResponses;
import corea.matchresult.service.MatchResultService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/rooms")
@RequiredArgsConstructor
public class MatchingResultController implements MatchingResultControllerSpecification {

private final MatchResultService matchResultService;

@GetMapping("/{id}/reviewers")
public ResponseEntity<MatchResultResponses> reviewers(@PathVariable long id, @LoginMember AuthInfo authInfo) {
MatchResultResponses response = matchResultService.findReviewers(authInfo.getId(), id);
return ResponseEntity.ok(response);
}

@GetMapping("/{id}/reviewees")
public ResponseEntity<MatchResultResponses> reviewees(@PathVariable long id, @LoginMember AuthInfo authInfo) {
MatchResultResponses response = matchResultService.findReviewees(authInfo.getId(), id);
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package corea.matchresult.controller;

import corea.auth.domain.AuthInfo;
import corea.exception.ExceptionType;
import corea.global.annotation.ApiErrorResponses;
import corea.matchresult.dto.MatchResultResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.http.ResponseEntity;

public interface MatchingResultControllerSpecification {
@Operation(summary = "해당 방에서 나에게 배정된 리뷰어들의 정보를 반환합니다.",
description = "해당 방에서 자신에게 배정된 리뷰어를 확인합니다. <br>" +
"요청 시 `Authorization Header`에 `Bearer JWT token`을 포함시켜야 합니다. " +
"이 토큰을 기반으로 `AuthInfo` 객체가 생성되며 사용자의 정보가 자동으로 주입됩니다. <br>" +
"JWT 토큰에서 추출된 사용자 정보는 피드백 작성에 필요한 인증된 사용자 정보를 제공합니다. " +
"<br><br>**참고:** 이 API를 사용하기 위해서는 유효한 JWT 토큰이 필요하며, " +
"토큰이 없거나 유효하지 않은 경우 인증 오류가 발생합니다.")
@ApiErrorResponses(value = {ExceptionType.MEMBER_NOT_FOUND, ExceptionType.ROOM_NOT_FOUND})
ResponseEntity<MatchResultResponses> reviewers(@Parameter(description = "방 아이디", example = "1")
long id,
AuthInfo authInfo);

@Operation(summary = "해당 방에서 나에게 배정된 리뷰이들의 정보를 반환합니다.",
description = "해당 방에서 자신에게 배정된 리뷰이를 확인합니다. <br>" +
"요청 시 `Authorization Header`에 `Bearer JWT token`을 포함시켜야 합니다. " +
"이 토큰을 기반으로 `AuthInfo` 객체가 생성되며 사용자의 정보가 자동으로 주입됩니다. <br>" +
"JWT 토큰에서 추출된 사용자 정보는 피드백 작성에 필요한 인증된 사용자 정보를 제공합니다. " +
"<br><br>**참고:** 이 API를 사용하기 위해서는 유효한 JWT 토큰이 필요하며, " +
"토큰이 없거나 유효하지 않은 경우 인증 오류가 발생합니다.")
@ApiErrorResponses(value = {ExceptionType.MEMBER_NOT_FOUND, ExceptionType.ROOM_NOT_FOUND})
ResponseEntity<MatchResultResponses> reviewees(@Parameter(description = "방 아이디", example = "1")
long id,
AuthInfo authInfo);
}
40 changes: 0 additions & 40 deletions backend/src/main/java/corea/room/controller/RoomController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import corea.auth.annotation.AccessedMember;
import corea.auth.annotation.LoginMember;
import corea.auth.domain.AuthInfo;
import corea.matchresult.dto.MatchResultResponses;
import corea.matchresult.service.MatchResultService;
import corea.room.domain.RoomStatus;
import corea.room.dto.RoomCreateRequest;
import corea.room.dto.RoomParticipantResponses;
import corea.room.dto.RoomResponse;
Expand All @@ -25,7 +22,6 @@
public class RoomController implements RoomControllerSpecification {

private final RoomService roomService;
private final MatchResultService matchResultService;
private final AutomaticUpdateService automaticUpdateService;
private final AutomaticMatchingService automaticMatchingService;

Expand All @@ -52,48 +48,12 @@ public ResponseEntity<RoomParticipantResponses> participants(@PathVariable long
return ResponseEntity.ok(response);
}

@GetMapping("/{id}/reviewers")
public ResponseEntity<MatchResultResponses> reviewers(@PathVariable long id, @LoginMember AuthInfo authInfo) {
MatchResultResponses response = matchResultService.findReviewers(authInfo.getId(), id);
return ResponseEntity.ok(response);
}

@GetMapping("/{id}/reviewees")
public ResponseEntity<MatchResultResponses> reviewees(@PathVariable long id, @LoginMember AuthInfo authInfo) {
MatchResultResponses response = matchResultService.findReviewees(authInfo.getId(), id);
return ResponseEntity.ok(response);
}

@GetMapping("/participated")
public ResponseEntity<RoomResponses> participatedRooms(@LoginMember AuthInfo authInfo) {
RoomResponses response = roomService.findParticipatedRooms(authInfo.getId());
return ResponseEntity.ok(response);
}

@GetMapping("/opened")
public ResponseEntity<RoomResponses> openedRooms(@AccessedMember AuthInfo authInfo,
@RequestParam(defaultValue = "0") int page,
@RequestParam(value = "classification", defaultValue = "all") String expression) {
RoomResponses response = roomService.findRoomsWithRoomStatus(authInfo.getId(), page, expression, RoomStatus.OPEN);
return ResponseEntity.ok(response);
}

@GetMapping("/progress")
public ResponseEntity<RoomResponses> progressRooms(@AccessedMember AuthInfo authInfo,
@RequestParam(defaultValue = "0") int page,
@RequestParam(value = "classification", defaultValue = "all") String expression) {
RoomResponses response = roomService.findRoomsWithRoomStatus(authInfo.getId(), page, expression, RoomStatus.PROGRESS);
return ResponseEntity.ok(response);
}

@GetMapping("/closed")
public ResponseEntity<RoomResponses> closedRooms(@AccessedMember AuthInfo authInfo,
@RequestParam(defaultValue = "0") int page,
@RequestParam(value = "classification", defaultValue = "all") String expression) {
RoomResponses response = roomService.findRoomsWithRoomStatus(authInfo.getId(), page, expression, RoomStatus.CLOSE);
return ResponseEntity.ok(response);
}

@DeleteMapping("/{id}")
public ResponseEntity<Void> delete(@PathVariable long id, @LoginMember AuthInfo authInfo) {
roomService.delete(id, authInfo.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,6 @@ ResponseEntity<RoomParticipantResponses> participants(@Parameter(description = "
long id,
AuthInfo authInfo);

@Operation(summary = "해당 방에서 나에게 배정된 리뷰어들의 정보를 반환합니다.",
description = "해당 방에서 자신에게 배정된 리뷰어를 확인합니다. <br>" +
"요청 시 `Authorization Header`에 `Bearer JWT token`을 포함시켜야 합니다. " +
"이 토큰을 기반으로 `AuthInfo` 객체가 생성되며 사용자의 정보가 자동으로 주입됩니다. <br>" +
"JWT 토큰에서 추출된 사용자 정보는 피드백 작성에 필요한 인증된 사용자 정보를 제공합니다. " +
"<br><br>**참고:** 이 API를 사용하기 위해서는 유효한 JWT 토큰이 필요하며, " +
"토큰이 없거나 유효하지 않은 경우 인증 오류가 발생합니다.")
@ApiErrorResponses(value = {ExceptionType.MEMBER_NOT_FOUND, ExceptionType.ROOM_NOT_FOUND})
ResponseEntity<MatchResultResponses> reviewers(@Parameter(description = "방 아이디", example = "1")
long id,
AuthInfo authInfo);

@Operation(summary = "해당 방에서 나에게 배정된 리뷰이들의 정보를 반환합니다.",
description = "해당 방에서 자신에게 배정된 리뷰이를 확인합니다. <br>" +
"요청 시 `Authorization Header`에 `Bearer JWT token`을 포함시켜야 합니다. " +
"이 토큰을 기반으로 `AuthInfo` 객체가 생성되며 사용자의 정보가 자동으로 주입됩니다. <br>" +
"JWT 토큰에서 추출된 사용자 정보는 피드백 작성에 필요한 인증된 사용자 정보를 제공합니다. " +
"<br><br>**참고:** 이 API를 사용하기 위해서는 유효한 JWT 토큰이 필요하며, " +
"토큰이 없거나 유효하지 않은 경우 인증 오류가 발생합니다.")
@ApiErrorResponses(value = {ExceptionType.MEMBER_NOT_FOUND, ExceptionType.ROOM_NOT_FOUND})
ResponseEntity<MatchResultResponses> reviewees(@Parameter(description = "방 아이디", example = "1")
long id,
AuthInfo authInfo);

@Operation(summary = "참여 중인 방 정보를 반환합니다..",
description = "해당 멤버가 참여 중인 방들의 정보를 리뷰 마감일이 임박한 순으로 정렬해 반환합니다. <br>" +
"요청 시 `Authorization Header`에 `Bearer JWT token`을 포함시켜야 합니다. " +
Expand All @@ -83,54 +59,6 @@ ResponseEntity<MatchResultResponses> reviewees(@Parameter(description = "방 아
"토큰이 없거나 유효하지 않은 경우 인증 오류가 발생합니다.")
ResponseEntity<RoomResponses> participatedRooms(AuthInfo authInfo);

@Operation(summary = "현재 모집 중인 방 정보를 반환합니다.",
description = "현재 모집 중인 방들의 정보를 모집 마감일이 임박한 순으로 정렬해 반환합니다. 이미 참여 중인 방들의 정보는 제외됩니다. <br>" +
"요청 시 `Authorization Header`에 `Bearer JWT token`을 포함시켜야 합니다. " +
"이 토큰을 기반으로 `AuthInfo` 객체가 생성되며 사용자의 정보가 자동으로 주입됩니다. <br>" +
"JWT 토큰에서 추출된 사용자 정보는 피드백 작성에 필요한 인증된 사용자 정보를 제공합니다. " +
"<br><br>**참고:** 이 API를 사용하기 위해서는 유효한 JWT 토큰이 필요하며, " +
"토큰이 없거나 유효하지 않은 경우 인증 오류가 발생합니다.")
@ApiErrorResponses(value = ExceptionType.NOT_FOUND_ERROR)
ResponseEntity<RoomResponses> openedRooms(AuthInfo authInfo,

@Parameter(description = "페이지 정보", example = "1")
int page,

@Parameter(description = "방 분야", example = "AN")
String expression);

@Operation(summary = "현재 모집 완료된 방 정보를 반환합니다.",
description = "현재 모집 완료된 방들의 정보를 반환합니다. 이미 참여 중인 방들의 정보는 제외됩니다. <br>" +
"요청 시 `Authorization Header`에 `Bearer JWT token`을 포함시켜야 합니다. " +
"이 토큰을 기반으로 `AuthInfo` 객체가 생성되며 사용자의 정보가 자동으로 주입됩니다. <br>" +
"JWT 토큰에서 추출된 사용자 정보는 피드백 작성에 필요한 인증된 사용자 정보를 제공합니다. " +
"<br><br>**참고:** 이 API를 사용하기 위해서는 유효한 JWT 토큰이 필요하며, " +
"토큰이 없거나 유효하지 않은 경우 인증 오류가 발생합니다.")
@ApiErrorResponses(value = ExceptionType.NOT_FOUND_ERROR)
ResponseEntity<RoomResponses> progressRooms(AuthInfo authInfo,

@Parameter(description = "페이지 정보", example = "1")
int page,

@Parameter(description = "방 분야", example = "AN")
String expression);

@Operation(summary = "현재 종료된 방 정보를 반환합니다.",
description = "현재 모든 진행이 종료된 방들의 정보를 반환합니다. 이미 참여 중인 방들의 정보는 제외됩니다. <br>" +
"요청 시 `Authorization Header`에 `Bearer JWT token`을 포함시켜야 합니다. " +
"이 토큰을 기반으로 `AuthInfo` 객체가 생성되며 사용자의 정보가 자동으로 주입됩니다. <br>" +
"JWT 토큰에서 추출된 사용자 정보는 피드백 작성에 필요한 인증된 사용자 정보를 제공합니다. " +
"<br><br>**참고:** 이 API를 사용하기 위해서는 유효한 JWT 토큰이 필요하며, " +
"토큰이 없거나 유효하지 않은 경우 인증 오류가 발생합니다.")
@ApiErrorResponses(value = ExceptionType.NOT_FOUND_ERROR)
ResponseEntity<RoomResponses> closedRooms(AuthInfo authInfo,

@Parameter(description = "페이지 정보", example = "2")
int page,

@Parameter(description = "방 분야", example = "FE")
String expression);

@Operation(summary = "방을 삭제합니다.",
description = "이미 생성되어 있는 방을 삭제합니다. <br>" +
"요청 시 `Authorization Header`에 `Bearer JWT token`을 포함시켜야 합니다. " +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package corea.room.controller;

import corea.auth.annotation.AccessedMember;
import corea.auth.domain.AuthInfo;
import corea.room.domain.RoomStatus;
import corea.room.dto.RoomResponses;
import corea.room.service.RoomInquiryService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/rooms")
@RequiredArgsConstructor
public class RoomInquiryController implements RoomInquiryControllerSpecification {

private final RoomInquiryService roomInquiryService;

@GetMapping("/opened")
public ResponseEntity<RoomResponses> openedRooms(@AccessedMember AuthInfo authInfo,
@RequestParam(defaultValue = "0") int page,
@RequestParam(value = "classification", defaultValue = "all") String expression) {
RoomResponses response = roomInquiryService.findRoomsWithRoomStatus(authInfo.getId(), page, expression, RoomStatus.OPEN);
return ResponseEntity.ok(response);
}

@GetMapping("/progress")
public ResponseEntity<RoomResponses> progressRooms(@AccessedMember AuthInfo authInfo,
@RequestParam(defaultValue = "0") int page,
@RequestParam(value = "classification", defaultValue = "all") String expression) {
RoomResponses response = roomInquiryService.findRoomsWithRoomStatus(authInfo.getId(), page, expression, RoomStatus.PROGRESS);
return ResponseEntity.ok(response);
}

@GetMapping("/closed")
public ResponseEntity<RoomResponses> closedRooms(@AccessedMember AuthInfo authInfo,
@RequestParam(defaultValue = "0") int page,
@RequestParam(value = "classification", defaultValue = "all") String expression) {
RoomResponses response = roomInquiryService.findRoomsWithRoomStatus(authInfo.getId(), page, expression, RoomStatus.CLOSE);
return ResponseEntity.ok(response);
}
}
Loading

0 comments on commit 83c7406

Please sign in to comment.