Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve/정우진 #82

Merged
merged 50 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
1732eb4
리뷰 널값 들어가는거 없애기
woojin065 Jan 13, 2024
fbb19c3
리뷰 널값 들어가는거 없애기
woojin065 Jan 13, 2024
a20345f
Merge branch 'Improve/정우진' of https://github.com/Dev-Tinos/JSGames-Ba…
woojin065 Feb 3, 2024
628c4f8
DAO 변경
woojin065 Feb 5, 2024
8d88c81
레포지토리 생성
woojin065 Feb 5, 2024
c11adc4
서비스 생성
woojin065 Feb 5, 2024
bb2e5a3
친구 목록 조회
woojin065 Feb 5, 2024
d583784
컨트롤러 생성
woojin065 Feb 5, 2024
711f88c
친구 삭제
woojin065 Feb 5, 2024
f9f5507
친구 신청 수락
woojin065 Feb 5, 2024
df0343f
친구 삭제
woojin065 Feb 5, 2024
251bee1
친구 신청
woojin065 Feb 5, 2024
6237cf8
친구 신청 받은 목록 조회
woojin065 Feb 5, 2024
a232bef
친구 신청 보낸 목록 조회
woojin065 Feb 5, 2024
518ad87
친구 거절
woojin065 Feb 5, 2024
695ccf7
친구 기능 SmallBean
woojin065 Feb 5, 2024
5c37cb1
친구 DTO 생성
woojin065 Feb 5, 2024
d116856
친구 신청 상태
woojin065 Feb 5, 2024
ea7d44c
친구 목록 최근플레이순 조회 수정
woojin065 Feb 5, 2024
28ec1d6
helpful 파라미터 수정
woojin065 Feb 23, 2024
e35ab01
이미지 Controller로 이름 변경
woojin065 Feb 23, 2024
bb3a1e4
test 코드 추가
woojin065 Feb 23, 2024
f4c62fe
친구 요청 오류 수정
woojin065 Feb 23, 2024
e30d24f
빌더 디폴트 추가
woojin065 Feb 23, 2024
d2b7569
테스트 코드 오류 보류(캐싱문제)
woojin065 Feb 23, 2024
c92805c
리뷰 널값 들어가는거 없애기
woojin065 Jan 13, 2024
fee70c5
DAO 변경
woojin065 Feb 5, 2024
f47912d
레포지토리 생성
woojin065 Feb 5, 2024
d1d0034
서비스 생성
woojin065 Feb 5, 2024
b95cbc7
친구 목록 조회
woojin065 Feb 5, 2024
cd86c6b
컨트롤러 생성
woojin065 Feb 5, 2024
0682ac0
친구 삭제
woojin065 Feb 5, 2024
c18a391
친구 신청 수락
woojin065 Feb 5, 2024
d31ee4a
친구 삭제
woojin065 Feb 5, 2024
50d2827
친구 신청
woojin065 Feb 5, 2024
ffb261f
친구 신청 받은 목록 조회
woojin065 Feb 5, 2024
922ed11
친구 신청 보낸 목록 조회
woojin065 Feb 5, 2024
89604c9
친구 거절
woojin065 Feb 5, 2024
c0378a8
친구 기능 SmallBean
woojin065 Feb 5, 2024
68e4fa2
친구 DTO 생성
woojin065 Feb 5, 2024
fce8e30
친구 신청 상태
woojin065 Feb 5, 2024
6d50d9f
친구 목록 최근플레이순 조회 수정
woojin065 Feb 5, 2024
7b827cc
helpful 파라미터 수정
woojin065 Feb 23, 2024
279b1ca
이미지 Controller로 이름 변경
woojin065 Feb 23, 2024
d3697e7
test 코드 추가
woojin065 Feb 23, 2024
e739f14
친구 요청 오류 수정
woojin065 Feb 23, 2024
18a83d8
빌더 디폴트 추가
woojin065 Feb 23, 2024
6ad925b
테스트 코드 오류 보류(캐싱문제)
woojin065 Feb 23, 2024
280e6bc
Merge branch 'Improve/정우진' of https://github.com/Dev-Tinos/JSGames-Ba…
woojin065 Feb 23, 2024
90992ea
테스트 오류 수정
woojin065 Feb 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.jsgamesbackendmain.Bean.FriendBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean.FriendDeleteSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByEmailSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByIdSmallBean;
import com.example.jsgamesbackendmain.Model.DAO.UserDAO;
import com.example.jsgamesbackendmain.Model.DTO.Friend.Request.FriendRequestDTO;
import com.example.jsgamesbackendmain.Model.DTO.StateResponseDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class FriendDeleteBean {
private final FriendDeleteSmallBean friendDeleteSmallBean;
private final UserGetByEmailSmallBean userGetByEmailSmallBean;
private final UserGetByIdSmallBean userGetByIdSmallBean;

public StateResponseDTO exec(FriendRequestDTO friendRequestDTO) {
UserDAO userDAO = userGetByIdSmallBean.exec(friendRequestDTO.getUserId());
UserDAO friendDAO = userGetByEmailSmallBean.exec(friendRequestDTO.getFriendEmail());
return friendDeleteSmallBean.exec(userDAO, friendDAO);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.example.jsgamesbackendmain.Bean.FriendBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean.FriendListByRecentSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean.FriendListByTimeSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByIdSmallBean;
import com.example.jsgamesbackendmain.Model.DAO.UserDAO;
import com.example.jsgamesbackendmain.Model.DTO.Friend.Response.FriendListResponseDTO;
import com.example.jsgamesbackendmain.Model.ENUM.FriendSort;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RequiredArgsConstructor
public class FriendListBean {
private final UserGetByIdSmallBean userGetByIdSmallBean;
private final FriendListByRecentSmallBean friendListByRecentSmallBean;
private final FriendListByTimeSmallBean friendListByTimeSmallBean;

public List<FriendListResponseDTO> exec(String userId, Integer page, Integer size, FriendSort sort) {
UserDAO user = userGetByIdSmallBean.exec(userId);
List<FriendListResponseDTO> friendListResponseDTOS;
if (sort == FriendSort.RECENT) {
friendListResponseDTOS = friendListByRecentSmallBean.exec(user, page, size);
} else {
friendListResponseDTOS = friendListByTimeSmallBean.exec(user, page, size);
}

return friendListResponseDTOS;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.example.jsgamesbackendmain.Bean.FriendBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean.FriendFindSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean.FriendRequestDeleteSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean.FriendSaveSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByEmailSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByIdSmallBean;
import com.example.jsgamesbackendmain.Model.DAO.UserDAO;
import com.example.jsgamesbackendmain.Model.DTO.Friend.Request.FriendRequestDTO;
import com.example.jsgamesbackendmain.Model.DTO.StateResponseDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class FriendRequestAcceptBean {
private final FriendRequestDeleteSmallBean friendRequestDeleteSmallBean;
private final UserGetByEmailSmallBean userGetByEmailSmallBean;
private final UserGetByIdSmallBean userGetByIdSmallBean;
private final FriendSaveSmallBean friendSaveSmallBean;
private final FriendFindSmallBean friendFindSmallBean;

public StateResponseDTO exec(FriendRequestDTO friendRequestDTO) {
UserDAO user = userGetByIdSmallBean.exec(friendRequestDTO.getUserId());
UserDAO friend = userGetByEmailSmallBean.exec(friendRequestDTO.getFriendEmail());
friendFindSmallBean.exec(friend.getUserId(), user.getUserId());
friendRequestDeleteSmallBean.exec(friend.getUserId(), friendRequestDTO.getUserId());
friendSaveSmallBean.exec(user, friend);
friendSaveSmallBean.exec(friend, user);

return StateResponseDTO.builder().state(true).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.jsgamesbackendmain.Bean.FriendBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean.FriendRequestSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByEmailSmallBean;
import com.example.jsgamesbackendmain.Model.DTO.Friend.Request.FriendRequestDTO;
import com.example.jsgamesbackendmain.Model.DTO.StateResponseDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class FriendRequestBean {

private final FriendRequestSmallBean friendRequestSmallBean;
private final UserGetByEmailSmallBean userGetByEmailSmallBean;

public StateResponseDTO exec(FriendRequestDTO friendRequestDTO) {
String friendId = userGetByEmailSmallBean.exec(friendRequestDTO.getFriendEmail()).getUserId();
return friendRequestSmallBean.exec(friendRequestDTO.getUserId(), friendId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.jsgamesbackendmain.Bean.FriendBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean.FriendRequestDeleteSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByEmailSmallBean;
import com.example.jsgamesbackendmain.Model.DTO.Friend.Request.FriendRequestDTO;
import com.example.jsgamesbackendmain.Model.DTO.StateResponseDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class FriendRequestDeleteBean {
private final FriendRequestDeleteSmallBean friendRequestDeleteSmallBean;
private final UserGetByEmailSmallBean userGetByEmailSmallBean;

public StateResponseDTO exec(FriendRequestDTO friendRequestDTO) {
return friendRequestDeleteSmallBean.exec(friendRequestDTO.getUserId(), userGetByEmailSmallBean.exec(friendRequestDTO.getFriendEmail()).getUserId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.example.jsgamesbackendmain.Bean.FriendBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean.FriendRequestListSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByIdSmallBean;
import com.example.jsgamesbackendmain.Model.DAO.FriendRequestDAO;
import com.example.jsgamesbackendmain.Model.DAO.UserDAO;
import com.example.jsgamesbackendmain.Model.DTO.Friend.Response.FriendRequestListResponseDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

@Component
@RequiredArgsConstructor
public class FriendRequestListBean {
private final FriendRequestListSmallBean friendRequestListSmallBean;
private final UserGetByIdSmallBean userGetByIdSmallBean;

public List<FriendRequestListResponseDTO> exec(String userId, Integer page, Integer size) {
List<FriendRequestDAO> friendRequestDAOS = friendRequestListSmallBean.exec(userId, page, size);


return friendRequestDAOS.stream()
.map(friendRequestDAO -> FriendRequestListResponseDTO.builder()
.friendEmail(userGetByIdSmallBean.exec(friendRequestDAO.getFriendId()).getEmail())
.friendName(userGetByIdSmallBean.exec(friendRequestDAO.getFriendId()).getNickname())
.friendProfile(userGetByIdSmallBean.exec(friendRequestDAO.getFriendId()).getProfileImageURL())
.friendStatus(friendRequestDAO.getState())
.createdAt(friendRequestDAO.getCreatedAt())
.build())
.collect(Collectors.toList());

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.jsgamesbackendmain.Bean.FriendBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean.FriendRequestRejectionSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByEmailSmallBean;
import com.example.jsgamesbackendmain.Model.DTO.Friend.Request.FriendRequestDTO;
import com.example.jsgamesbackendmain.Model.DTO.StateResponseDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class FriendRequestRejectionBean {
private final FriendRequestRejectionSmallBean friendRequestRejectionSmallBean;
private final UserGetByEmailSmallBean userGetByEmailSmallBean;

public StateResponseDTO exec(FriendRequestDTO friendRequestDTO) {
return friendRequestRejectionSmallBean.exec(friendRequestDTO.getUserId(), userGetByEmailSmallBean.exec(friendRequestDTO.getFriendEmail()).getUserId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.example.jsgamesbackendmain.Bean.FriendBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean.FriendRequestedListSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByIdSmallBean;
import com.example.jsgamesbackendmain.Model.DAO.FriendRequestDAO;
import com.example.jsgamesbackendmain.Model.DTO.Friend.Response.FriendRequestListResponseDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

@Component
@RequiredArgsConstructor
public class FriendRequestedListBean {
private final FriendRequestedListSmallBean friendRequestedListSmallBean;
private final UserGetByIdSmallBean userGetByIdSmallBean;

public List<FriendRequestListResponseDTO> exec(String userId, Integer page, Integer size) {
List<FriendRequestDAO> friendRequestDAOS = friendRequestedListSmallBean.exec(userId, page, size);

return friendRequestDAOS.stream()
.map(friendRequestDAO -> FriendRequestListResponseDTO.builder()
.friendEmail(userGetByIdSmallBean.exec(friendRequestDAO.getUserId()).getEmail())
.friendName(userGetByIdSmallBean.exec(friendRequestDAO.getUserId()).getNickname())
.friendProfile(userGetByIdSmallBean.exec(friendRequestDAO.getUserId()).getProfileImageURL())
.friendStatus(friendRequestDAO.getState())
.createdAt(friendRequestDAO.getCreatedAt())
.build())
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean;

import com.example.jsgamesbackendmain.Model.DAO.UserDAO;
import com.example.jsgamesbackendmain.Model.DTO.StateResponseDTO;
import com.example.jsgamesbackendmain.Repository.FriendRepository;
import com.example.jsgamesbackendmain.Repository.FriendRequestRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class FriendDeleteSmallBean {
private final FriendRepository friendRepository;

public StateResponseDTO exec(UserDAO userDAO, UserDAO friendDAO) {
friendRepository.deleteByUserAndFriend(userDAO, friendDAO);
friendRepository.deleteByUserAndFriend(friendDAO, userDAO);
return StateResponseDTO.builder().state(true).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean;

import com.example.jsgamesbackendmain.Controller.ExceptionControll.FailException;
import com.example.jsgamesbackendmain.Model.DAO.FriendRequestDAO;
import com.example.jsgamesbackendmain.Repository.FriendRequestRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component
@RequiredArgsConstructor
public class FriendFindSmallBean {
private final FriendRequestRepository friendRequestRepository;

public void exec(String userId, String friendId) {
Optional<FriendRequestDAO> friendRequestDAO = friendRequestRepository.findByUserIdAndFriendId(userId, friendId);
if(!friendRequestDAO.isPresent()) {
throw new FailException("헤당 친구요청이 없습니다.");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserRecentPlayTimeSmallBean;
import com.example.jsgamesbackendmain.Model.DAO.FriendDAO;
import com.example.jsgamesbackendmain.Model.DAO.UserDAO;
import com.example.jsgamesbackendmain.Model.DTO.Friend.Response.FriendListResponseDTO;
import com.example.jsgamesbackendmain.Repository.FriendRepository;
import com.example.jsgamesbackendmain.Repository.LogRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

@Component
@RequiredArgsConstructor
public class FriendListByRecentSmallBean {
private final FriendRepository friendRepository;
private final UserRecentPlayTimeSmallBean userRecentPlayTimeSmallBean;

public List<FriendListResponseDTO> exec(UserDAO user, Integer page, Integer size) {
// 페이지와 크기를 이용하여 pageable 객체 생성
Pageable pageable = PageRequest.of(page, size);

// 현재 사용자의 친구 목록 가져오기
List<FriendDAO> friendDAOS = friendRepository.findByUserOrderByCreatedAtDesc(user, pageable).toList();

// 각 친구의 최근 게임 플레이 시간을 찾고 정렬하기
return friendDAOS.stream().map(friendDAO -> FriendListResponseDTO.builder()
.friendEmail(friendDAO.getFriend().getEmail())
.friendName(friendDAO.getFriend().getNickname())
.friendProfile(friendDAO.getFriend().getProfileImageURL())
.parentMajor(friendDAO.getFriend().getParentMajor())
.major(friendDAO.getFriend().getMajor())
.createdAt(friendDAO.getCreatedAt())
.recentPlay(userRecentPlayTimeSmallBean.exec(friendDAO.getFriend()))
.build()).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserRecentPlayTimeSmallBean;
import com.example.jsgamesbackendmain.Model.DAO.FriendDAO;
import com.example.jsgamesbackendmain.Model.DAO.UserDAO;
import com.example.jsgamesbackendmain.Model.DTO.Friend.Response.FriendListResponseDTO;
import com.example.jsgamesbackendmain.Repository.FriendRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

@Component
@RequiredArgsConstructor
public class FriendListByTimeSmallBean {
private final FriendRepository friendRepository;
private final UserRecentPlayTimeSmallBean userRecentPlayTimeSmallBean;

public List<FriendListResponseDTO> exec(UserDAO user, Integer page, Integer size) {
List<FriendDAO> friendDAOS = friendRepository.findByUserOrderByCreatedAtDesc(user, PageRequest.of(page, size)).toList();

return friendDAOS.stream().map(friendDAO -> FriendListResponseDTO.builder()
.friendEmail(friendDAO.getFriend().getEmail())
.friendName(friendDAO.getFriend().getNickname())
.friendProfile(friendDAO.getFriend().getProfileImageURL())
.parentMajor(friendDAO.getFriend().getParentMajor())
.major(friendDAO.getFriend().getMajor())
.createdAt(friendDAO.getCreatedAt())
.recentPlay(userRecentPlayTimeSmallBean.exec(friendDAO.getFriend()))
.build()).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean;

import com.example.jsgamesbackendmain.Model.DTO.StateResponseDTO;
import com.example.jsgamesbackendmain.Repository.FriendRequestRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class FriendRequestDeleteSmallBean {
private final FriendRequestRepository friendRequestRepository;

public StateResponseDTO exec(String userId, String friendId) {
friendRequestRepository.deleteByUserIdAndFriendId(userId, friendId);
return StateResponseDTO.builder().state(true).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.jsgamesbackendmain.Bean.SmallBean.FriendBean;

import com.example.jsgamesbackendmain.Model.DAO.FriendRequestDAO;
import com.example.jsgamesbackendmain.Repository.FriendRequestRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RequiredArgsConstructor
public class FriendRequestListSmallBean {
private final FriendRequestRepository friendRequestRepository;

public List<FriendRequestDAO> exec(String userId, Integer page, Integer size) {
PageRequest request = PageRequest.of(page, size);
Page<FriendRequestDAO> friendRequestDAOS = friendRequestRepository.findByUserIdOrderByCreatedAtDesc(userId, request);
return friendRequestDAOS.toList();
}
}
Loading
Loading