From 206f7f301c0a4ff6dfb991bc5d4e3f18ff4fdc40 Mon Sep 17 00:00:00 2001 From: SangWoon123 Date: Thu, 9 May 2024 00:32:06 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=9C=A0=EC=A0=80=20=EB=A0=88=ED=8F=AC?= =?UTF-8?q?=EC=A7=80=ED=86=A0=EB=A6=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../group/repository/GroupFavoriteRepositoryCustom.java | 7 ++++--- .../group/repository/GroupInviteRepositoryCustom.java | 4 ++-- .../planding/domain/group/service/GroupRoomService.java | 8 ++++---- .../group/service/query/GroupInviteQueryService.java | 4 ++-- .../controller/GroupScheduleAttendanceController.java | 2 +- .../schedule/service/GroupScheduleAttendanceService.java | 5 +++-- .../domain/schedule/service/GroupScheduleService.java | 2 +- .../domain/schedule/service/ScheduleQueryService.java | 4 ++++ 8 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/tukorea/planding/domain/group/repository/GroupFavoriteRepositoryCustom.java b/src/main/java/com/tukorea/planding/domain/group/repository/GroupFavoriteRepositoryCustom.java index 7f697a9..c551b64 100644 --- a/src/main/java/com/tukorea/planding/domain/group/repository/GroupFavoriteRepositoryCustom.java +++ b/src/main/java/com/tukorea/planding/domain/group/repository/GroupFavoriteRepositoryCustom.java @@ -1,14 +1,15 @@ package com.tukorea.planding.domain.group.repository; import com.tukorea.planding.domain.group.entity.GroupFavorite; -import com.tukorea.planding.domain.group.entity.GroupRoom; -import com.tukorea.planding.domain.user.entity.User; import java.util.List; public interface GroupFavoriteRepositoryCustom { Long countMyFavoriteGroup(String userCode); + Boolean existsByUserAndGroupRoom(String userCode); - GroupFavorite findByUserAndGroupRoom(User user, GroupRoom groupRoom); + + GroupFavorite findByUserIdAndGroupId(Long userId, Long groupRoomId); + List findByUserFavorite(Long userId); } diff --git a/src/main/java/com/tukorea/planding/domain/group/repository/GroupInviteRepositoryCustom.java b/src/main/java/com/tukorea/planding/domain/group/repository/GroupInviteRepositoryCustom.java index 97c2bbd..2c6a27f 100644 --- a/src/main/java/com/tukorea/planding/domain/group/repository/GroupInviteRepositoryCustom.java +++ b/src/main/java/com/tukorea/planding/domain/group/repository/GroupInviteRepositoryCustom.java @@ -17,9 +17,9 @@ public class GroupInviteRepositoryCustom { private final JPAQueryFactory queryFactory; - public List findPendingInvitationsForUser(User user) { + public List findPendingInvitationsForUser(Long userId) { return queryFactory.selectFrom(groupInvite) - .where(groupInvite.invitedUser.userCode.eq(user.getUserCode()) + .where(groupInvite.invitedUser.id.eq(userId) .and(groupInvite.inviteStatus.eq(InviteStatus.PENDING))) .fetch(); } diff --git a/src/main/java/com/tukorea/planding/domain/group/service/GroupRoomService.java b/src/main/java/com/tukorea/planding/domain/group/service/GroupRoomService.java index ca47d65..a7135ff 100644 --- a/src/main/java/com/tukorea/planding/domain/group/service/GroupRoomService.java +++ b/src/main/java/com/tukorea/planding/domain/group/service/GroupRoomService.java @@ -33,7 +33,7 @@ public class GroupRoomService { @Transactional public GroupResponse createGroupRoom(UserInfo userInfo, GroupCreateRequest createGroupRoom) { - User user = userQueryService.getUserByUserCode(userInfo); + User user = userQueryService.getUserByUserCode(userInfo.getUserCode()); GroupRoom newGroupRoom = GroupRoom.createGroupRoom(createGroupRoom, user); GroupRoom savedGroupRoom = groupQueryService.createGroup(newGroupRoom); @@ -48,7 +48,7 @@ public GroupResponse createGroupRoom(UserInfo userInfo, GroupCreateRequest creat @Transactional public GroupResponse updateGroupNameOrDescription(UserInfo userInfo, GroupUpdateRequest groupUpdateRequest) { - User user = userQueryService.getUserByUserCode(userInfo); + User user = userQueryService.getUserByUserCode(userInfo.getUserCode()); GroupRoom groupRoom = groupQueryService.getGroupById(groupUpdateRequest.groupId()); @@ -63,7 +63,7 @@ public GroupResponse updateGroupNameOrDescription(UserInfo userInfo, GroupUpdate } public void deleteGroup(UserInfo userInfo, Long groupId) { - User user = userQueryService.getByUserInfo(userInfo.getUserCode()); + User user = userQueryService.getUserByUserCode(userInfo.getUserCode()); GroupRoom groupRoom = groupQueryService.getGroupById(groupId); if (!groupRoom.getOwner().equals(user.getUserCode())) { @@ -75,7 +75,7 @@ public void deleteGroup(UserInfo userInfo, Long groupId) { // 유저가 속한 그룹룸 가져오기 public List getAllGroupRoomByUser(UserInfo userInfo) { - User user = userQueryService.getUserByUserCode(userInfo); + User user = userQueryService.getUserByUserCode(userInfo.getUserCode()); List groupRooms = groupQueryService.findGroupsByUserId(user.getId()); diff --git a/src/main/java/com/tukorea/planding/domain/group/service/query/GroupInviteQueryService.java b/src/main/java/com/tukorea/planding/domain/group/service/query/GroupInviteQueryService.java index 89a394c..ce3d15b 100644 --- a/src/main/java/com/tukorea/planding/domain/group/service/query/GroupInviteQueryService.java +++ b/src/main/java/com/tukorea/planding/domain/group/service/query/GroupInviteQueryService.java @@ -24,8 +24,8 @@ public GroupInvite getInvitationByInviteCode(String inviteCode) { .orElseThrow(() -> new BusinessException(ErrorCode.NOTEXIST_INVITE)); } - public List getPendingInvitationForUser(User user) { - return groupInviteRepositoryCustom.findPendingInvitationsForUser(user); + public List getPendingInvitationForUser(Long userId) { + return groupInviteRepositoryCustom.findPendingInvitationsForUser(userId); } public Long countInvitation(String userCode, InviteStatus inviteStatus) { diff --git a/src/main/java/com/tukorea/planding/domain/schedule/controller/GroupScheduleAttendanceController.java b/src/main/java/com/tukorea/planding/domain/schedule/controller/GroupScheduleAttendanceController.java index c5b5dfd..e89959a 100644 --- a/src/main/java/com/tukorea/planding/domain/schedule/controller/GroupScheduleAttendanceController.java +++ b/src/main/java/com/tukorea/planding/domain/schedule/controller/GroupScheduleAttendanceController.java @@ -20,7 +20,7 @@ public class GroupScheduleAttendanceController { @GetMapping() public ResponseEntity participationGroupSchedule(@AuthenticationPrincipal UserInfo userInfo, GroupScheduleAttendanceRequest status) { - groupScheduleAttendanceService.participationGroupSchedule(userInfo.getUserCode(), status); + groupScheduleAttendanceService.participationGroupSchedule(userInfo, status); return new ResponseEntity<>("스케줄 참여여부 변경 완료되었습니다.", HttpStatus.OK); } } diff --git a/src/main/java/com/tukorea/planding/domain/schedule/service/GroupScheduleAttendanceService.java b/src/main/java/com/tukorea/planding/domain/schedule/service/GroupScheduleAttendanceService.java index e140512..0134f4e 100644 --- a/src/main/java/com/tukorea/planding/domain/schedule/service/GroupScheduleAttendanceService.java +++ b/src/main/java/com/tukorea/planding/domain/schedule/service/GroupScheduleAttendanceService.java @@ -5,6 +5,7 @@ import com.tukorea.planding.domain.schedule.entity.Schedule; import com.tukorea.planding.domain.schedule.repository.GroupScheduleAttendanceRepository; import com.tukorea.planding.domain.schedule.repository.ScheduleRepository; +import com.tukorea.planding.domain.user.dto.UserInfo; import com.tukorea.planding.domain.user.entity.User; import com.tukorea.planding.domain.user.service.UserQueryService; import com.tukorea.planding.global.error.BusinessException; @@ -22,8 +23,8 @@ public class GroupScheduleAttendanceService { private final ScheduleRepository scheduleRepository; @Transactional - public void participationGroupSchedule(String userCode, GroupScheduleAttendanceRequest request) { - User user = userQueryService.getByUserInfo(userCode); + public void participationGroupSchedule(UserInfo userInfo, GroupScheduleAttendanceRequest request) { + User user = userQueryService.getUserByUserCode(userInfo.getUserCode()); Schedule schedule = scheduleRepository.findById(request.scheduleId()) .orElseThrow(() -> new BusinessException(ErrorCode.SCHEDULE_NOT_FOUND)); diff --git a/src/main/java/com/tukorea/planding/domain/schedule/service/GroupScheduleService.java b/src/main/java/com/tukorea/planding/domain/schedule/service/GroupScheduleService.java index 5dfc77a..08e513a 100644 --- a/src/main/java/com/tukorea/planding/domain/schedule/service/GroupScheduleService.java +++ b/src/main/java/com/tukorea/planding/domain/schedule/service/GroupScheduleService.java @@ -37,7 +37,7 @@ public class GroupScheduleService { public ScheduleResponse createGroupSchedule(String groupCode, ScheduleRequest requestSchedule) { // [1] 작성한 유저 - User user = userQueryService.getByUserInfo(requestSchedule.userCode()); + User user = userQueryService.getUserByUserCode(requestSchedule.userCode()); // [2] 그룹방 GroupRoom groupRoom = groupRoomRepository.findByGroupCode(groupCode) diff --git a/src/main/java/com/tukorea/planding/domain/schedule/service/ScheduleQueryService.java b/src/main/java/com/tukorea/planding/domain/schedule/service/ScheduleQueryService.java index 4dc96dd..2f42a10 100644 --- a/src/main/java/com/tukorea/planding/domain/schedule/service/ScheduleQueryService.java +++ b/src/main/java/com/tukorea/planding/domain/schedule/service/ScheduleQueryService.java @@ -37,6 +37,10 @@ public List findByGroupRoomId(Long groupRoomId) { return scheduleRepository.findByGroupRoomId(groupRoomId); } + public List showTodaySchedule(Long userId) { + return scheduleRepositoryCustom.showTodaySchedule(userId); + } + public Schedule save(Schedule schedule) { return scheduleRepository.save(schedule); }