Skip to content

Commit

Permalink
Merge pull request #57 from Dev-Tinos/develop
Browse files Browse the repository at this point in the history
Imporve_version_2.2 deploy
  • Loading branch information
Leewonchan14 authored Dec 1, 2023
2 parents 80e223f + 1d4fa3d commit b76de8a
Show file tree
Hide file tree
Showing 100 changed files with 1,569 additions and 381 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ dependencies {

//mail
implementation 'org.springframework.boot:spring-boot-starter-mail'

implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.example.jsgamesbackendmain.Bean.EmailBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.EmailBean.EmailDomainCheckSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.EmailBean.EmailDuplicateSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.EmailBean.EmailMaxCheckSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.EmailBean.EmailSendSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.EmailBean.*;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserEmailDuplicateSmallBean;
import com.example.jsgamesbackendmain.Model.DAO.EmailAccountDAO;
import com.example.jsgamesbackendmain.Model.DAO.EmailCodeDAO;
import com.example.jsgamesbackendmain.Model.DTO.Email.EmailSendRequestDTO;
import com.example.jsgamesbackendmain.Model.DTO.StateResponseDTO;
import com.example.jsgamesbackendmain.Repository.EmailAccountRepository;
import com.example.jsgamesbackendmain.Repository.EmailCodeRepository;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -17,12 +15,8 @@

@Component
public class EmailSendBean {

@Autowired
private EmailAccountRepository emailAccountRepository;

@Autowired
private EmailCodeRepository emailCodeRepository;
private EmailAccountGetSmallBean emailAccountGetSmallBean;

@Autowired
private EmailSendSmallBean emailSendSmallBean;
Expand All @@ -39,11 +33,15 @@ public class EmailSendBean {
@Autowired
private EmailDuplicateSmallBean emailDuplicateSmallBean;

public String exec(EmailSendRequestDTO emailSendRequestDTO) {
EmailAccountDAO account = emailAccountRepository.findById(0L).orElse(null);
String Email = emailSendRequestDTO.getEmail();
@Autowired
private EmailCodeSaveSmallBean emailCodeSaveSmallBean;

System.out.println("account = " + account);
@Autowired
private EmailAccoutPlusSmallBean emailAccoutPlusSmallBean;

public StateResponseDTO exec(EmailSendRequestDTO emailSendRequestDTO) {
EmailAccountDAO account = emailAccountGetSmallBean.exec();
String Email = emailSendRequestDTO.getEmail();

// 이메일 최대 개수 검사
emailMaxCheckSmallBean.exec(account);
Expand All @@ -60,15 +58,12 @@ public String exec(EmailSendRequestDTO emailSendRequestDTO) {
emailSendSmallBean.exec(Email, verificationCode);

// 인증 코드 저장
EmailCodeDAO newCode = new EmailCodeDAO();
newCode.setEmail(Email);
newCode.setCode(verificationCode);
emailCodeRepository.save(newCode);
emailCodeSaveSmallBean.exec(Email, verificationCode);

// 이메일 카운트 증가
emailAccoutPlusSmallBean.exec();

// sentEmails 카운트 업데이트
account.setSentEmails(account.getSentEmails() + 1);
emailAccountRepository.save(account);

return "Code sent";
return new StateResponseDTO(true);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.example.jsgamesbackendmain.Bean.EmailBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.EmailBean.EmailAppendSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.EmailBean.EmailClearSmallBean;
import com.example.jsgamesbackendmain.Model.DAO.EmailAccountDAO;
import com.example.jsgamesbackendmain.Repository.EmailAccountRepository;
import com.example.jsgamesbackendmain.Repository.EmailCodeRepository;
Expand All @@ -8,18 +10,14 @@
import org.springframework.stereotype.Component;

@Component
public class EmailClearBean {
public class EmailSetBean {
@Autowired
private EmailCodeRepository emailCodeRepository;
private EmailAppendSmallBean emailAppendSmallBean;
@Autowired
private EmailAccountRepository emailAccountRepository;
private EmailClearSmallBean emailClearSmallBean;
@Scheduled(cron = "0 55 23 * * *")
public void exec(){
emailAccountRepository.deleteAll();
emailCodeRepository.deleteAll();
EmailAccountDAO emailAccountDAO = new EmailAccountDAO();
emailAccountDAO.setSentEmails(0L);
emailAccountDAO.setId(0L);
emailAccountRepository.save(emailAccountDAO);
emailClearSmallBean.exec();
emailAppendSmallBean.exec();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.jsgamesbackendmain.Bean.GameBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.GameBean.GameGetListByPlayedUserSmallBean;
import com.example.jsgamesbackendmain.Model.DTO.Game.Response.GameListResponseDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class GameGetListByPlayedUser {

@Autowired
private GameGetListByPlayedUserSmallBean gameGetListByPlayedUserSmallBean;

public List<GameListResponseDTO> exec(String userId, Long page, Long size) {
PageRequest request = PageRequest.of(page.intValue(), size.intValue());

return gameGetListByPlayedUserSmallBean.exec(userId, request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,14 @@ public List<GameListResponseDTO> exec(Long page, Long size) {

return list;
}

public List<GameListResponseDTO> exec(Long userId, Long page, Long size) {
PageRequest pageRequest = PageRequest.of(page.intValue(), size.intValue());

Page<GameDAO> all = gameRepository.findAllByOrderByViewCountDescGameIdAsc(pageRequest);

List<GameListResponseDTO> list = all.toList().stream().map(game -> mapperBean.to(game, GameListResponseDTO.class)).collect(Collectors.toList());

return list;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.jsgamesbackendmain.Bean.HelpfulBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.HelpfulBean.HelpfulDeleteSmallBean;
import com.example.jsgamesbackendmain.Controller.ExceptionControll.DuplicateException;
import com.example.jsgamesbackendmain.Model.DAO.HelpfulDAO;
import com.example.jsgamesbackendmain.Model.DTO.StateResponseDTO;
import com.example.jsgamesbackendmain.Repository.HelpfulRepository;
import com.example.jsgamesbackendmain.Repository.ReviewRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component
public class HelpfulDeleteBean {
@Autowired
private HelpfulDeleteSmallBean helpfulDeleteSmallBean;
public StateResponseDTO exec(String userId, Long reviewId) {
helpfulDeleteSmallBean.exec(userId, reviewId);
return new StateResponseDTO(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.jsgamesbackendmain.Bean.HelpfulBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.HelpfulBean.HelpfulGetSmallBean;
import com.example.jsgamesbackendmain.Controller.ExceptionControll.ResourceNotFoundException;
import com.example.jsgamesbackendmain.Model.DAO.HelpfulDAO;
import com.example.jsgamesbackendmain.Model.DTO.Helpful.HelpfulGetReponseDTO;
import com.example.jsgamesbackendmain.Repository.HelpfulRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component
public class HelpfulGetBean {
@Autowired
private HelpfulGetSmallBean helpfulGetSmallBean;

public HelpfulGetReponseDTO exec(String userId, Long reviewId) {
HelpfulGetReponseDTO responseDTO = new HelpfulGetReponseDTO();
responseDTO.setHelpful(helpfulGetSmallBean.exec(userId, reviewId));
return responseDTO;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.jsgamesbackendmain.Bean.HelpfulBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.HelpfulBean.HelpfulDeleteSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.HelpfulBean.HelpfulPostSmallBean;
import com.example.jsgamesbackendmain.Controller.ExceptionControll.DuplicateException;
import com.example.jsgamesbackendmain.Model.DAO.HelpfulDAO;
import com.example.jsgamesbackendmain.Model.DAO.ReviewDAO;
import com.example.jsgamesbackendmain.Model.DTO.StateResponseDTO;
import com.example.jsgamesbackendmain.Repository.HelpfulRepository;
import com.example.jsgamesbackendmain.Repository.ReviewRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component
public class HelpfulPostBean {
@Autowired
private HelpfulPostSmallBean helpfulPostSmallBean;
public StateResponseDTO exec(String userId, Long reviewId) {
helpfulPostSmallBean.exec(userId, reviewId);
return new StateResponseDTO(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.example.jsgamesbackendmain.Bean.SmallBean.GameBean.GameGetSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.LogBean.LogGetByGameIdUserIdSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.LogBean.LogGetRankSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByIdSmallBean;
import com.example.jsgamesbackendmain.Bean.UserBean.UserGetBean;
import com.example.jsgamesbackendmain.Model.DAO.GameDAO;
import com.example.jsgamesbackendmain.Model.DAO.LogDAO;
Expand All @@ -19,7 +20,7 @@ public class LogGetByGamIdUserIdBean {
@Autowired
private LogGetByGameIdUserIdSmallBean logGetByGameIdUserIdSmallBean;
@Autowired
private UserGetBean userGetBean;
private UserGetByIdSmallBean userGetByIdSmallBean;
@Autowired
private LogGetRankSmallBean logGetRankSmallBean;

Expand All @@ -33,7 +34,7 @@ public LogGetByGameIdUserIdResponseDTO exec(Long gameId, String userId) {
GameDAO gameDAO = gameGetSmallBean.exec(gameId);

// UserDAO 조회
UserLogResponseDTO userDTO = mapperBean.to(userGetBean.getUser(userId), UserLogResponseDTO.class);
UserLogResponseDTO userDTO = mapperBean.to(userGetByIdSmallBean.exec(userId), UserLogResponseDTO.class);

// LogDAO 조회
LogDAO logDAO = logGetByGameIdUserIdSmallBean.exec(gameDAO, userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.example.jsgamesbackendmain.Bean.MapperBean.MapperBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.GameBean.GameGetSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.LogBean.LogGetByGameIdSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.LogBean.LogGetByGameSmallBean;
import com.example.jsgamesbackendmain.Model.DAO.GameDAO;
import com.example.jsgamesbackendmain.Model.DTO.Log.Response.LogGetByGameIdResponseDTO;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -13,7 +13,7 @@
@Component
public class LogGetByGameIdBean {
@Autowired
private LogGetByGameIdSmallBean logGetByGameIdSmallBean;
private LogGetByGameSmallBean logGetByGameSmallBean;

@Autowired
private GameGetSmallBean gameGetSmallBean;
Expand All @@ -25,7 +25,7 @@ public List<LogGetByGameIdResponseDTO> exec(Long gameId, Integer page, Integer s

GameDAO gameDAO = gameGetSmallBean.exec(gameId);

return logGetByGameIdSmallBean.exec(gameDAO, page, size);
return logGetByGameSmallBean.exec(gameDAO, page, size);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.example.jsgamesbackendmain.Bean.LogBean;

import com.example.jsgamesbackendmain.Bean.SmallBean.LogBean.LogGetByUserIdSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserValidationSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByIdSmallBean;
import com.example.jsgamesbackendmain.Model.DAO.UserDAO;
import com.example.jsgamesbackendmain.Model.DTO.Log.Response.LogGetByUserIdResponseDTO;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -15,12 +15,12 @@ public class LogGetByUserIdBean {
private LogGetByUserIdSmallBean logGetByUserIdSmallBean;

@Autowired
private UserValidationSmallBean userValidationSmallBean;
private UserGetByIdSmallBean userValidationSmallBean;

public List<LogGetByUserIdResponseDTO> exec(String userId, Long page, Long size) {

//userId 유효성 확인
UserDAO user = userValidationSmallBean.exec(userId).get();
UserDAO user = userValidationSmallBean.exec(userId);

return logGetByUserIdSmallBean.exec(user, page, size);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,31 @@

import com.example.jsgamesbackendmain.Bean.MapperBean.MapperBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.GameBean.GameGetSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.LogBean.LogCatchTopChange;
import com.example.jsgamesbackendmain.Bean.SmallBean.LogBean.LogGetByGameSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.LogBean.LogSaveSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserValidationSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.UserBean.UserGetByIdSmallBean;
import com.example.jsgamesbackendmain.Model.DAO.GameDAO;
import com.example.jsgamesbackendmain.Model.DAO.LogDAO;
import com.example.jsgamesbackendmain.Model.DTO.Log.Request.LogPostRequestDTO;
import com.example.jsgamesbackendmain.Model.DTO.Log.Response.LogGetByGameIdResponseDTO;
import com.example.jsgamesbackendmain.Model.DTO.Log.Response.LogPostResponseDTO;
import com.example.jsgamesbackendmain.Repository.LogRepository;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component
public class LogPostBean {
@Autowired
private LogSaveSmallBean logSaveSmallBean;

@Autowired
private LogCatchTopChange logCatchTopChange;
@Autowired
private LogGetByGameSmallBean logGetByGameSmallBean;
@Autowired
private UserValidationSmallBean userValidationSmallBean;
private UserGetByIdSmallBean userValidationSmallBean;
@Autowired
private GameGetSmallBean gameGetSmallBean;
@Autowired
Expand All @@ -27,13 +36,25 @@ public class LogPostBean {

public LogPostResponseDTO exec(LogPostRequestDTO logPostRequestDTO) {
// game found
gameGetSmallBean.exec(logPostRequestDTO.getGameId());
GameDAO game = gameGetSmallBean.exec(logPostRequestDTO.getGameId());

// user found
userValidationSmallBean.exec(logPostRequestDTO.getUserId());

// get top log
Optional<LogGetByGameIdResponseDTO> preTopLog = logGetByGameSmallBean.exec(game, 0, 1).stream().findAny();

// log save
LogDAO savedLogDAO = logSaveSmallBean.exec(logPostRequestDTO.toDAO());

// get top log
Optional<LogGetByGameIdResponseDTO> nextTopLog = logGetByGameSmallBean.exec(game, 0, 1).stream().findAny();

// log catch top change
Boolean isChange = logCatchTopChange.exec(preTopLog, nextTopLog);

// 여기서 이벤트 처리하면 됨!!!!!

return mapperBean.to(savedLogDAO, LogPostResponseDTO.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
import com.example.jsgamesbackendmain.Bean.SmallBean.RankBean.RankLastUpdatedSmallBean;
import com.example.jsgamesbackendmain.Bean.SmallBean.RankBean.RankGetTop100SmallBean;
import com.example.jsgamesbackendmain.Model.DTO.Rank.Response.RankGetResponseDTO;
import com.example.jsgamesbackendmain.Model.DTO.Rank.Response.RankTop100UserResponseDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

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

@Component
public class RankGetBean {

Expand All @@ -19,12 +15,10 @@ public class RankGetBean {
private RankLastUpdatedSmallBean rankLastUpdatedSmallBean;
public RankGetResponseDTO exec(Long page, Long size) {
RankGetResponseDTO responseDTO = new RankGetResponseDTO();

List<RankTop100UserResponseDTO> list = rankGetTop100SmallBean.exec(page, size);
LocalDateTime lastUpdateDated = rankLastUpdatedSmallBean.exec();
// RankTop100 DAO to Rank
responseDTO.setRankList(list);
responseDTO.setLastUpdated(lastUpdateDated);
responseDTO.setRankList(rankGetTop100SmallBean.exec(page, size));
responseDTO.setLastUpdated(rankLastUpdatedSmallBean.getLastUpdated());

return responseDTO;
}
}
Loading

0 comments on commit b76de8a

Please sign in to comment.