Skip to content

Commit

Permalink
fix: 유저 레포지토리 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
SangWoon123 committed May 8, 2024
1 parent fd290d2 commit 206f7f3
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -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<GroupFavorite> findByUserFavorite(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
public class GroupInviteRepositoryCustom {
private final JPAQueryFactory queryFactory;

public List<GroupInvite> findPendingInvitationsForUser(User user) {
public List<GroupInvite> 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());

Expand All @@ -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())) {
Expand All @@ -75,7 +75,7 @@ public void deleteGroup(UserInfo userInfo, Long groupId) {

// 유저가 속한 그룹룸 가져오기
public List<GroupResponse> getAllGroupRoomByUser(UserInfo userInfo) {
User user = userQueryService.getUserByUserCode(userInfo);
User user = userQueryService.getUserByUserCode(userInfo.getUserCode());

List<GroupRoom> groupRooms = groupQueryService.findGroupsByUserId(user.getId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public GroupInvite getInvitationByInviteCode(String inviteCode) {
.orElseThrow(() -> new BusinessException(ErrorCode.NOTEXIST_INVITE));
}

public List<GroupInvite> getPendingInvitationForUser(User user) {
return groupInviteRepositoryCustom.findPendingInvitationsForUser(user);
public List<GroupInvite> getPendingInvitationForUser(Long userId) {
return groupInviteRepositoryCustom.findPendingInvitationsForUser(userId);
}

public Long countInvitation(String userCode, InviteStatus inviteStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public List<Schedule> findByGroupRoomId(Long groupRoomId) {
return scheduleRepository.findByGroupRoomId(groupRoomId);
}

public List<Schedule> showTodaySchedule(Long userId) {
return scheduleRepositoryCustom.showTodaySchedule(userId);
}

public Schedule save(Schedule schedule) {
return scheduleRepository.save(schedule);
}
Expand Down

0 comments on commit 206f7f3

Please sign in to comment.