Skip to content

Commit

Permalink
[chore] 클라이언트 요구사항 반영 배포 (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
2hyunjinn authored Jan 22, 2025
2 parents 686e2ea + 9493f13 commit b672c00
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.ggang.be.api.comment.facade.CommentFacade;
import com.ggang.be.api.common.ApiResponse;
import com.ggang.be.api.common.ResponseBuilder;
import com.ggang.be.domain.constant.GroupType;
import com.ggang.be.global.jwt.JwtService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand All @@ -21,14 +22,24 @@ public class CommentController {
private final JwtService jwtService;

@PostMapping("/comment")
public ResponseEntity<ApiResponse<WriteCommentResponse>> writeComment(@RequestHeader("Authorization") final String token, @RequestBody @Valid final WriteCommentRequest dto){
public ResponseEntity<ApiResponse<WriteCommentResponse>> writeComment(
@RequestHeader("Authorization") final String token,
@RequestBody @Valid final WriteCommentRequest dto
) {
Long userId = jwtService.parseTokenAndGetUserId(token);
return ResponseBuilder.created(commentFacade.writeComment(userId, dto));
}

@GetMapping("/comments")
public ResponseEntity<ApiResponse<ReadCommentResponse>> getComments(@RequestHeader("Authorization") final String token, @RequestParam boolean isPublic, @RequestBody final ReadCommentRequest dto){
public ResponseEntity<ApiResponse<ReadCommentResponse>> getComments(
@RequestHeader("Authorization") final String token,
@RequestParam boolean isPublic,
@RequestParam("groupId") long groupId,
@RequestParam("groupType") GroupType groupType
) {
Long userId = jwtService.parseTokenAndGetUserId(token);
ReadCommentRequest dto = new ReadCommentRequest(groupId, groupType);

return ResponseBuilder.ok(commentFacade.readComment(userId, isPublic, dto));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ public class GroupController {
@GetMapping("/fill/info")
public ResponseEntity<ApiResponse<GroupResponse>> getGroupInfo(
@RequestHeader("Authorization") final String accessToken,
@RequestBody final GroupRequest groupRequestDto
@RequestParam("groupId") long groupId,
@RequestParam("groupType") GroupType groupType
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);
GroupRequest groupRequestDto = new GroupRequest(groupId, groupType);

GroupResponse groupResponseDto = groupFacade.getGroupInfo(
groupRequestDto.groupType(), groupRequestDto.groupId(), userId
Expand All @@ -42,9 +44,11 @@ public ResponseEntity<ApiResponse<GroupResponse>> getGroupInfo(
@GetMapping("/fill/user/info")
public ResponseEntity<ApiResponse<GroupUserInfoResponseDto>> getGroupUserInfo(
@RequestHeader("Authorization") final String accessToken,
@RequestBody final GroupRequest groupRequestDto
@RequestParam("groupId") long groupId,
@RequestParam("groupType") GroupType groupType
){
jwtService.isValidToken(accessToken);
GroupRequest groupRequestDto = new GroupRequest(groupId, groupType);

GroupUserInfoResponseDto groupUserInfoResponseDto = GroupUserInfoResponseDto.of(
groupFacade.getGroupUserInfo(groupRequestDto.groupType(), groupRequestDto.groupId()));
Expand All @@ -67,24 +71,28 @@ public ResponseEntity<ApiResponse<RegisterGroupResponse>> registerGongbaek(
@GetMapping("/fill/members")
public ResponseEntity<ApiResponse<ReadFillMembersResponse>> getGroupMembers(
@RequestHeader("Authorization") String token,
@RequestBody ReadFillMembersRequest dto
@RequestParam("groupId") long groupId,
@RequestParam("groupType") GroupType groupType
) {
Long userId = jwtService.parseTokenAndGetUserId(token);
ReadFillMembersRequest dto = new ReadFillMembersRequest(groupId, groupType);

return ResponseBuilder.ok(groupFacade.getGroupUsersInfo(userId, dto));
}

@GetMapping("/my/groups")
public ResponseEntity<ApiResponse<List<MyGroupResponse>>> getMyGroups(
@RequestHeader("Authorization") final String accessToken,
@RequestBody final FillGroupFilterRequest groupFilterRequest
@RequestParam(value = "category") FillGroupType category,
@RequestParam(value = "status") boolean status
) {
Long userId = jwtService.parseTokenAndGetUserId(accessToken);

if (!FillGroupType.isValidCategory(groupFilterRequest.category())) {
if (!FillGroupType.isValidCategory(category)) {
throw new GongBaekException(ResponseError.BAD_REQUEST);
}

return ResponseBuilder.ok(groupFacade.getMyGroups(userId, groupFilterRequest));
return ResponseBuilder.ok(groupFacade.getMyGroups(userId, category, status));
}

@GetMapping("/fill/groups")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public record ActiveGroupsResponse(
int profileImg,
GroupType groupType,
String groupTitle,
WeekDate weekDate,
LocalDate groupDate,
WeekDate weekDay,
LocalDate weekDate,
double startTime,
double endTime,
String location
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/ggang/be/api/group/facade/GroupFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.ggang.be.api.lectureTimeSlot.service.LectureTimeSlotService;
import com.ggang.be.api.user.service.UserService;
import com.ggang.be.domain.constant.Category;
import com.ggang.be.domain.constant.FillGroupType;
import com.ggang.be.domain.constant.GroupType;
import com.ggang.be.domain.group.dto.GroupVo;
import com.ggang.be.domain.group.vo.NearestGroup;
Expand Down Expand Up @@ -106,12 +107,12 @@ public void cancelMyApplication(Long userId, GroupRequest requestDto) {
cancelGroupStrategy.cancelGroup(findUserEntity, requestDto);
}

public List<MyGroupResponse> getMyGroups(long userId, FillGroupFilterRequest filterRequestDto) {
public List<MyGroupResponse> getMyGroups(long userId, FillGroupType category, boolean status) {
UserEntity currentUser = userService.getUserById(userId);

MyGroupStrategy groupStrategy = myGroupStrategyRegistry.getGroupStrategy(filterRequestDto.getFillGroupCategory());
MyGroupStrategy groupStrategy = myGroupStrategyRegistry.getGroupStrategy(category);

List<GroupVo> groupResponses = groupStrategy.getGroups(currentUser, filterRequestDto.status());
List<GroupVo> groupResponses = groupStrategy.getGroups(currentUser, status);

return groupResponses.stream()
.map(MyGroupResponse::fromGroupVo)
Expand Down

0 comments on commit b672c00

Please sign in to comment.