Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Kimhan-nah authored Dec 22, 2023
2 parents 8771413 + dbbcfba commit 0ce665d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.gg.server.admin.game.dto.RankGamePPPModifyReqDto;
import com.gg.server.admin.game.exception.NotRecentlyGameException;
import com.gg.server.admin.pchange.data.PChangeAdminRepository;
import com.gg.server.admin.pchange.exception.PChangeNotExistException;
import com.gg.server.admin.season.data.SeasonAdminRepository;
import com.gg.server.admin.team.data.TeamUserAdminRepository;
import com.gg.server.admin.user.data.UserAdminRepository;
Expand Down Expand Up @@ -129,7 +130,11 @@ public void rankResultEdit(RankGamePPPModifyReqDto reqDto, Long gameId) {
for (TeamUser teamUser :
teamUsers) {
List<PChange> pChanges = pChangeAdminRepository.findByTeamUser(teamUser.getUser().getId());
if (!pChanges.get(0).getGame().getId().equals(gameId)) {
throw new PChangeNotExistException();
}
rollbackGameResult(reqDto, season, teamUser, pChanges);
teamUserAdminRepository.flush();
pChangeAdminRepository.delete(pChanges.get(0));
}
rankRedisService.updateRankRedis(teamUsers.get(0), teamUsers.get(1), game);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public void rollbackRank(TeamUser teamUser, int ppp, Long seasonId) {
log.info("Before: userId: " + teamUser.getUser().getIntraId() + ", " + "ppp: rank(" + rank.getPpp() + "), redis(" + myTeam.getPpp() + ")");
rank.modifyUserRank(ppp, win, losses);
myTeam.changedRank(ppp, win, losses);
rankRepository.flush();
updateRankUser(hashkey, RedisKeyManager.getZSetKey(seasonId), teamUser.getUser().getId(), myTeam);
log.info("After: userId: " + teamUser.getUser().getIntraId() + ", " + "ppp: rank(" + rank.getPpp() + "), redis(" + myTeam.getPpp() + ")");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.gg.server.domain.team.data;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

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

public interface TeamUserRepository extends JpaRepository<TeamUser, Long> {
@Query(value = "select team_user.id, team_user.team_id, team_user.user_id from team, team_user " +
"where team.game_id =:gid and team.id = team_user.team_id", nativeQuery = true)
List<TeamUser> findAllByGameId(@Param("gid")Long gid);

@Query(value = "select count(*) from game, team, team_user " +
"where game.start_time >= :today and team_user.team_id = team.id and team_user.user_id = :userId " +
"and team.game_id = game.id and game.status = 'END'", nativeQuery = true)
Integer findByDateAndUser(@Param("today")LocalDateTime today, @Param("userId") Long userId);

}
package com.gg.server.domain.team.data;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

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

public interface TeamUserRepository extends JpaRepository<TeamUser, Long> {
@Query(value = "select team_user.id, team_user.team_id, team_user.user_id from team, team_user " +
"where team.game_id =:gid and team.id = team_user.team_id", nativeQuery = true)
List<TeamUser> findAllByGameId(@Param("gid")Long gid);

@Query(value = "select count(*) from game, team, team_user " +
"where game.start_time >= :today and team_user.team_id = team.id and team_user.user_id = :userId " +
"and team.game_id = game.id and game.status = 'END'", nativeQuery = true)
Integer findByDateAndUser(@Param("today")LocalDateTime today, @Param("userId") Long userId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected String determineTargetUrl(HttpServletRequest request, HttpServletRespo

// token 설정
String accessToken = tokenProvider.createToken(principal.getId());
String refreshToken = tokenProvider.refreshToken();
String refreshToken = tokenProvider.refreshToken(principal.getId());

cookieUtil.addCookie(response, TokenHeaders.REFRESH_TOKEN, refreshToken,
(int)(refreshTokenExpiry / 1000));
Expand Down Expand Up @@ -114,7 +114,7 @@ private String saveAndGetUserAccessToken(HttpServletResponse response,

// token 설정
String accessToken = tokenProvider.createToken(remainedUser.getId());
String refreshToken = tokenProvider.refreshToken();
String refreshToken = tokenProvider.refreshToken(remainedUser.getId());
jwtRedisRepository.addRefToken(refreshToken, refreshTokenExpiry, remainedUser.getId());

cookieUtil.addCookie(response, TokenHeaders.REFRESH_TOKEN, refreshToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ public AuthTokenProvider(AppProperties appProperties) {
refreshKey = Keys.hmacShaKeyFor(appProperties.getAuth().getRefreshTokenSecret().getBytes());
log.info(key.getAlgorithm());
}
public String refreshToken() {
public String refreshToken(Long userId) {
Date now = new Date();
Date expiryDate = new Date(now.getTime() +
appProperties.getAuth().getRefreshTokenExpiry());
return Jwts.builder()
.setSubject(userId.toString())
.setIssuedAt(new Date())
.setExpiration(expiryDate)
.signWith(refreshKey)
Expand Down

0 comments on commit 0ce665d

Please sign in to comment.