From 72d04065899f54cf613b245ea99d565f6a8ee606 Mon Sep 17 00:00:00 2001 From: hannkim Date: Sat, 20 Jan 2024 19:20:53 +0900 Subject: [PATCH 01/32] =?UTF-8?q?:hammer:=20[Refactor]=20=ED=86=A0?= =?UTF-8?q?=EB=84=88=EB=A8=BC=ED=8A=B8=20=EC=A7=84=ED=96=89=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=EB=8F=99=EC=95=88=EC=9D=98=20=EC=8A=AC=EB=A1=AF=20?= =?UTF-8?q?=EB=B8=94=EB=9D=BD=20=EB=A1=9C=EC=A7=81=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?(#488)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../match/service/MatchFindService.java | 2 -- .../domain/match/utils/SlotGenerator.java | 19 ------------------- 2 files changed, 21 deletions(-) diff --git a/src/main/java/com/gg/server/domain/match/service/MatchFindService.java b/src/main/java/com/gg/server/domain/match/service/MatchFindService.java index 16ddb0543..46f675a89 100644 --- a/src/main/java/com/gg/server/domain/match/service/MatchFindService.java +++ b/src/main/java/com/gg/server/domain/match/service/MatchFindService.java @@ -90,8 +90,6 @@ public SlotStatusResponseListDto getAllMatchStatus(UserDto userDto, Option optio List games = gameRepository.findAllBetween(slotGenerator.getNow(), slotGenerator.getMaxTime()); slotGenerator.addPastSlots(); slotGenerator.addMatchedSlots(games); - List tournaments = tournamentRepository.findAllByStatusIsNot(TournamentStatus.END); - slotGenerator.addTournamentSlots(tournaments); Optional myGame = gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, userDto.getId()); Set gameTimes = games.stream().map(Game::getStartTime).collect(Collectors.toSet()); diff --git a/src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java b/src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java index 99918c179..f9272111c 100644 --- a/src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java +++ b/src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java @@ -61,25 +61,6 @@ public void addMatchedSlots(List games) { new SlotStatusDto(e.getStartTime(), SlotStatus.CLOSE, interval))); } - /** - * BEFORE, LIVE 상태의 토너먼트 진행 시간에 슬롯을 block함 - */ - public void addTournamentSlots(List tournaments) { - for (Tournament tournament : tournaments) { - LocalDateTime startTime = tournament.getStartTime(); - int startTimeMinute = startTime.getMinute(); - startTimeMinute = startTimeMinute - (startTimeMinute % interval); - startTime = startTime.withMinute(startTimeMinute); - LocalDateTime endTime = tournament.getEndTime(); - int endTimeMinute = endTime.getMinute(); - endTimeMinute = endTimeMinute + (interval - (endTimeMinute % interval)); - endTime = endTime.withMinute(endTimeMinute); - for (LocalDateTime time = startTime; time.isBefore(endTime); time = time.plusMinutes(interval)) { - slots.put(time, new SlotStatusDto(time, SlotStatus.CLOSE, interval)); - } - } - } - public void addMySlots(Game myGame) { slots.put(myGame.getStartTime(), new SlotStatusDto(myGame.getStartTime(), myGame.getEndTime(), From adcc9513d6a352106cde547a1c1ff62b39e26400 Mon Sep 17 00:00:00 2001 From: SeungChul Chung Date: Sun, 21 Jan 2024 22:11:39 +0900 Subject: [PATCH 02/32] =?UTF-8?q?=F0=9F=90=9B=20[Fix]=20codecov=20version?= =?UTF-8?q?=20to=20v3=20(#510)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test-code-validation.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-code-validation.yml b/.github/workflows/test-code-validation.yml index a7b94c572..20862e44d 100644 --- a/.github/workflows/test-code-validation.yml +++ b/.github/workflows/test-code-validation.yml @@ -22,7 +22,7 @@ jobs: - name: mv for separate report name run: mv ./build/reports/jacoco/unitTest/jacocoTestReport.xml ./build/reports/jacoco/unitTest/unitTestReport.xml - name: 📲 Upload unitTest coverage to Codecov - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true @@ -33,7 +33,7 @@ jobs: - name: 👨‍👨‍👧‍👦 Integration Test with Gradle run: ./gradlew --console verbose clean integrationTestCoverage - name: 📲 Upload integrationTest coverage to Codecov - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true From 21f33a2c764e93f85fcad062bfed9e3d22b0c52e Mon Sep 17 00:00:00 2001 From: SeungChul Chung Date: Sun, 21 Jan 2024 22:12:56 +0900 Subject: [PATCH 03/32] =?UTF-8?q?=E2=9C=A8[Feature]=20slice=20test?= =?UTF-8?q?=EC=9A=A9=20=EC=95=A0=EB=84=88=ED=85=8C=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(#513)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/annotation/DataJpaUnitTest.java | 20 +++++++++++++++++++ .../utils/annotation/WebMvcUnitTest.java | 20 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/test/java/com/gg/server/utils/annotation/DataJpaUnitTest.java create mode 100644 src/test/java/com/gg/server/utils/annotation/WebMvcUnitTest.java diff --git a/src/test/java/com/gg/server/utils/annotation/DataJpaUnitTest.java b/src/test/java/com/gg/server/utils/annotation/DataJpaUnitTest.java new file mode 100644 index 000000000..db6241380 --- /dev/null +++ b/src/test/java/com/gg/server/utils/annotation/DataJpaUnitTest.java @@ -0,0 +1,20 @@ +package com.gg.server.utils.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import org.junit.jupiter.api.Tag; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; + +/** + * DataJpa 테스트를 위한 어노테이션 + * + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Tag(TestTypeConstant.UNIT_TEST) +@DataJpaTest +public @interface DataJpaUnitTest { + +} \ No newline at end of file diff --git a/src/test/java/com/gg/server/utils/annotation/WebMvcUnitTest.java b/src/test/java/com/gg/server/utils/annotation/WebMvcUnitTest.java new file mode 100644 index 000000000..8f7fb7064 --- /dev/null +++ b/src/test/java/com/gg/server/utils/annotation/WebMvcUnitTest.java @@ -0,0 +1,20 @@ +package com.gg.server.utils.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import org.junit.jupiter.api.Tag; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; + +/** + * WebMvc 테스트를 위한 어노테이션 + * + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Tag(TestTypeConstant.UNIT_TEST) +@WebMvcTest +public @interface WebMvcUnitTest { + +} \ No newline at end of file From f767c2584e47062ec6dcf79532643209bd283432 Mon Sep 17 00:00:00 2001 From: yoahn <46748334+AYoungSn@users.noreply.github.com> Date: Sat, 27 Jan 2024 14:17:50 +0900 Subject: [PATCH 04/32] =?UTF-8?q?[FIX]=20#232=20admin=20=EA=B2=8C=EC=9E=84?= =?UTF-8?q?=20=EA=B4=80=EB=A6=AC=20=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=A0=90=EC=88=98=20=EC=88=98=EC=A0=95=20=EC=8B=9C?= =?UTF-8?q?=20=EC=8A=B9=ED=8C=A8=20=EC=88=98=EC=A0=95=20=EC=95=88=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20(#473)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../game/controller/GameAdminController.java | 3 + .../admin/game/data/GameAdminRepository.java | 3 + .../admin/game/service/GameAdminService.java | 60 +++++++++++++------ .../team/data/TeamUserAdminRepository.java | 2 +- .../com/gg/server/domain/game/data/Game.java | 3 + .../com/gg/server/domain/rank/data/Rank.java | 3 + .../domain/rank/redis/RankRedisService.java | 30 ++++++++-- .../domain/season/data/SeasonRepository.java | 1 + .../exception/SeasonNotFoundException.java | 3 + .../domain/season/service/SeasonService.java | 12 ++-- .../com/gg/server/domain/team/data/Team.java | 4 ++ .../com/gg/server/domain/user/data/User.java | 3 + .../controller/GameAdminControllerTest.java | 6 ++ src/test/resources/application.yml | 1 + 14 files changed, 105 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/gg/server/admin/game/controller/GameAdminController.java b/src/main/java/com/gg/server/admin/game/controller/GameAdminController.java index a2846779f..2afd82350 100644 --- a/src/main/java/com/gg/server/admin/game/controller/GameAdminController.java +++ b/src/main/java/com/gg/server/admin/game/controller/GameAdminController.java @@ -4,6 +4,7 @@ import com.gg.server.admin.game.dto.GameUserLogAdminReqDto; import com.gg.server.admin.game.dto.RankGamePPPModifyReqDto; import com.gg.server.admin.game.service.GameAdminService; +import com.gg.server.domain.rank.redis.RankRedisService; import com.gg.server.global.dto.PageRequestDto; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.InvalidParameterException; @@ -23,6 +24,7 @@ @RequestMapping("/pingpong/admin/games") public class GameAdminController { private final GameAdminService gameAdminService; + private final RankRedisService rankRedisService; @GetMapping public GameLogListAdminResponseDto gameFindBySeasonId(@ModelAttribute @Valid PageRequestDto pageRequestDto) { @@ -59,6 +61,7 @@ public ResponseEntity gameResultEdit(@Valid @RequestBody RankGamePPPModify throw new InvalidParameterException("점수를 잘못 입력했습니다.", ErrorCode.VALID_FAILED); } gameAdminService.rankResultEdit(reqDto, gameId); + rankRedisService.updateAllTier(gameId); return new ResponseEntity(HttpStatus.NO_CONTENT); } } diff --git a/src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java b/src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java index 4f5d0a2df..37ac7eaad 100644 --- a/src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java +++ b/src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java @@ -31,4 +31,7 @@ public interface GameAdminRepository extends JpaRepository { @Query(value = "SELECT g FROM Game g, Team t, TeamUser tu WHERE g.status = :status AND g.id = t.game.id" + " AND t.id = tu.team.id AND tu.user.id = :userId") Optional findByStatusTypeAndUserId(@Param("status") StatusType status, @Param("userId") Long userId); + + @Query(value = "SELECT g FROM Game g JOIN FETCH g.season WHERE g.id = :gameId") + Optional findGameWithSeasonByGameId(@Param("gameId")Long gameId); } diff --git a/src/main/java/com/gg/server/admin/game/service/GameAdminService.java b/src/main/java/com/gg/server/admin/game/service/GameAdminService.java index 64d7cf47d..58bb62a86 100644 --- a/src/main/java/com/gg/server/admin/game/service/GameAdminService.java +++ b/src/main/java/com/gg/server/admin/game/service/GameAdminService.java @@ -19,13 +19,18 @@ import com.gg.server.domain.pchange.data.PChange; import com.gg.server.domain.pchange.data.PChangeRepository; +import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisService; import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.dto.CurSeason; import com.gg.server.domain.season.exception.SeasonNotFoundException; +import com.gg.server.domain.season.service.SeasonService; import com.gg.server.domain.team.data.TeamUser; +import com.gg.server.domain.tier.service.TierService; import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.exception.UserNotFoundException; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Caching; import org.springframework.data.domain.*; @@ -36,8 +41,11 @@ import java.util.List; import java.util.stream.Collectors; +import javax.persistence.EntityManager; + @Service @RequiredArgsConstructor +@Slf4j public class GameAdminService { private final GameAdminRepository gameAdminRepository; @@ -48,6 +56,9 @@ public class GameAdminService { private final RankRedisService rankRedisService; private final TeamUserAdminRepository teamUserAdminRepository; private final RedisMatchUserRepository redisMatchUserRepository; + private final TierService tierService; + private final SeasonService seasonService; + private final EntityManager entityManager; /** *

토너먼트 게임을 제외한 일반, 랭크 게임들을 찾아서 반환해준다.

@@ -119,41 +130,54 @@ public GameLogListAdminResponseDto findGamesByIntraId(String intraId, Pageable p public void rankResultEdit(RankGamePPPModifyReqDto reqDto, Long gameId) { // 게임이 두명 다 가장 마지막 게임인지 확인 (그 game에 해당하는 팀이 맞는지 확인) List teamUsers = teamUserAdminRepository.findUsersByTeamIdIn(List.of(reqDto.getTeam1Id(), reqDto.getTeam2Id())); - Game game = gameAdminRepository.findById(gameId) + Game game = gameAdminRepository.findGameWithSeasonByGameId(gameId) .orElseThrow(GameNotExistException::new); - Season season = seasonAdminRepository.findById(game.getSeason().getId()) - .orElseThrow(SeasonNotFoundException::new); - if (!isRecentlyGame(teamUsers, gameId) || EnrollSlots(teamUsers)) { + CurSeason curSeason = seasonService.getCurSeason(); + if (!isRecentlyGame(teamUsers, gameId) || EnrollSlots(teamUsers) || !game.getSeason().getId().equals(curSeason.getId())) { throw new NotRecentlyGameException(); } // pchange 가져와서 rank ppp 이전 값을 가지고 새 점수를 바탕으로 다시 계산 - for (TeamUser teamUser : - teamUsers) { - List 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)); + // user 1 + List pChanges = pChangeAdminRepository.findByTeamUser(teamUsers.get(0).getUser().getId()); + if (!pChanges.get(0).getGame().getId().equals(gameId)) { + throw new PChangeNotExistException(); + } + RankRedis rankRedis1 = rollbackGameResult(game.getSeason(), teamUsers.get(0), pChanges); + pChangeAdminRepository.deleteById(pChanges.get(0).getId()); + // user 2 + pChanges = pChangeAdminRepository.findByTeamUser(teamUsers.get(1).getUser().getId()); + if (!pChanges.get(0).getGame().getId().equals(gameId)) { + throw new PChangeNotExistException(); } - rankRedisService.updateRankRedis(teamUsers.get(0), teamUsers.get(1), game); - rankRedisService.updateAllTier(gameId); + RankRedis rankRedis2 = rollbackGameResult(game.getSeason(), teamUsers.get(1), pChanges); + pChangeAdminRepository.deleteById(pChanges.get(0).getId()); + entityManager.flush(); + for (int i = 0; i < teamUsers.size(); i++) { + updateScore(reqDto, teamUsers.get(i)); + } + teamUserAdminRepository.flush(); + rankRedisService.updateAdminRankData(teamUsers.get(0), teamUsers.get(1), game, rankRedis1, rankRedis2); + tierService.updateAllTier(game.getSeason()); } - private void rollbackGameResult(RankGamePPPModifyReqDto reqDto, Season season, TeamUser teamUser, List pChanges) { + private RankRedis rollbackGameResult(Season season, TeamUser teamUser, List pChanges) { // pchange ppp도 update // rankredis 에 ppp 다시 반영 // rank zset 도 update // 이전 ppp, exp 되돌리기 // rank data 에 있는 ppp 되돌리기 + RankRedis rankRedis; if (pChanges.size() == 1) { - rankRedisService.rollbackRank(teamUser, season.getStartPpp(), season.getId()); + rankRedis = rankRedisService.rollbackRank(teamUser, season.getStartPpp(), season.getId()); teamUser.getUser().updateExp(0); } else { - rankRedisService.rollbackRank(teamUser, pChanges.get(1).getPppResult(), season.getId()); + rankRedis = rankRedisService.rollbackRank(teamUser, pChanges.get(1).getPppResult(), season.getId()); teamUser.getUser().updateExp(pChanges.get(1).getExp()); } + return rankRedis; + } + + private void updateScore(RankGamePPPModifyReqDto reqDto, TeamUser teamUser) { if (teamUser.getTeam().getId().equals(reqDto.getTeam1Id())) { teamUser.getTeam().updateScore(reqDto.getTeam1Score(), reqDto.getTeam1Score() > reqDto.getTeam2Score()); } else if (teamUser.getTeam().getId().equals(reqDto.getTeam2Id())) { diff --git a/src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java b/src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java index 07974e80d..0fe3650fa 100644 --- a/src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java +++ b/src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java @@ -12,6 +12,6 @@ public interface TeamUserAdminRepository extends JpaRepository { @Query("SELECT tu.user FROM TeamUser tu WHERE tu.team.id = :teamId") List findUsersByTeamId(@Param("teamId") Long teamId); - @Query("SELECT tu FROM TeamUser tu, Team t WHERE tu.team.id IN (:teamId) AND t.id = tu.team.id") + @Query("SELECT tu FROM TeamUser tu JOIN FETCH tu.team t JOIN FETCH tu.user WHERE tu.team.id IN (:teamId)") List findUsersByTeamIdIn(@Param("teamId") List teamId); } diff --git a/src/main/java/com/gg/server/domain/game/data/Game.java b/src/main/java/com/gg/server/domain/game/data/Game.java index c8ab0972a..cab8f8643 100644 --- a/src/main/java/com/gg/server/domain/game/data/Game.java +++ b/src/main/java/com/gg/server/domain/game/data/Game.java @@ -16,10 +16,13 @@ import java.util.List; import java.util.Optional; +import org.hibernate.annotations.DynamicUpdate; + @NoArgsConstructor @AllArgsConstructor @Getter @Entity +@DynamicUpdate public class Game { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/com/gg/server/domain/rank/data/Rank.java b/src/main/java/com/gg/server/domain/rank/data/Rank.java index 275f21646..35c69fff2 100644 --- a/src/main/java/com/gg/server/domain/rank/data/Rank.java +++ b/src/main/java/com/gg/server/domain/rank/data/Rank.java @@ -14,12 +14,15 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; +import org.hibernate.annotations.DynamicUpdate; + @Entity @Getter @Builder @NoArgsConstructor @AllArgsConstructor @Table(name="ranks") +@DynamicUpdate public class Rank extends BaseTimeEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java b/src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java index ed4aeadf6..29b17219a 100644 --- a/src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java +++ b/src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java @@ -22,6 +22,8 @@ import java.time.LocalDateTime; import java.util.List; +import javax.persistence.EntityManager; + @Service @RequiredArgsConstructor @Slf4j @@ -31,11 +33,25 @@ public class RankRedisService { private final PChangeService pChangeService; private final RankRepository rankRepository; private final SeasonFindService seasonFindService; + private final EntityManager entityManager; public Integer getUserPpp(Long userId, Long seasonId) { String hashKey = RedisKeyManager.getHashKey(seasonId); return rankRedisRepository.findRankByUserId(hashKey, userId).getPpp(); } + public void updateAdminRankData(TeamUser myTeamUser, TeamUser enemyTeamUser, Game game, RankRedis myTeam, RankRedis enemyTeam) { + // 단식 -> 2명 기준 + String key = RedisKeyManager.getHashKey(game.getSeason().getId()); + String zsetKey = RedisKeyManager.getZSetKey(game.getSeason().getId()); + Integer myPPP = myTeam.getPpp(); + Integer enemyPPP = enemyTeam.getPpp(); + updatePPP(myTeamUser, myTeam, enemyTeamUser.getTeam().getScore(), myPPP, enemyPPP, game.getSeason().getId()); + updatePPP(enemyTeamUser, enemyTeam, myTeamUser.getTeam().getScore(), enemyPPP, myPPP, game.getSeason().getId()); + updateRankUser(key, zsetKey, myTeamUser.getUser().getId(), myTeam); + updateRankUser(key, zsetKey, enemyTeamUser.getUser().getId(), enemyTeam); + pChangeService.addPChange(game, myTeamUser.getUser(), myTeam.getPpp(), false); + pChangeService.addPChange(game, enemyTeamUser.getUser(), enemyTeam.getPpp(), false); + } public void updateRankRedis(TeamUser myTeamUser, TeamUser enemyTeamUser, Game game) { // 단식 -> 2명 기준 String key = RedisKeyManager.getHashKey(game.getSeason().getId()); @@ -60,11 +76,11 @@ private void updateRankUser(String hashKey, String zsetKey, Long userId, RankRed @Transactional public void updatePPP(TeamUser teamuser, RankRedis myTeam, int enemyScore, Integer myPPP, Integer enemyPPP, Long seasonId) { - int win = teamuser.getTeam().getWin() ? myTeam.getWins() + 1 : myTeam.getWins(); - int losses = !teamuser.getTeam().getWin() ? myTeam.getLosses() + 1: myTeam.getLosses(); // rank table 수정 Rank rank = rankRepository.findByUserIdAndSeasonId(myTeam.getUserId(), seasonId) .orElseThrow(() -> new NotExistException("rank 정보가 없습니다.", ErrorCode.NOT_FOUND)); + int win = teamuser.getTeam().getWin() ? rank.getWins() + 1 : rank.getWins(); + int losses = !teamuser.getTeam().getWin() ? rank.getLosses() + 1: rank.getLosses(); Integer changedPpp = EloRating.pppChange(myPPP, enemyPPP, teamuser.getTeam().getWin(), Math.abs(teamuser.getTeam().getScore() - enemyScore) == 2); @@ -128,22 +144,24 @@ public void updateAllTier(Long gameId) { } } - public void rollbackRank(TeamUser teamUser, int ppp, Long seasonId) { + @Transactional + public RankRedis rollbackRank(TeamUser teamUser, int ppp, Long seasonId) { String hashkey = RedisKeyManager.getHashKey(seasonId); RankRedis myTeam = rankRedisRepository.findRankByUserId(hashkey, teamUser.getUser().getId()); - int win = teamUser.getTeam().getWin() ? myTeam.getWins() - 1 : myTeam.getWins(); - int losses = !teamUser.getTeam().getWin() ? myTeam.getLosses() - 1: myTeam.getLosses(); Rank rank = rankRepository.findByUserIdAndSeasonId(myTeam.getUserId(), seasonId) .orElseThrow(RankNotFoundException::new); + int win = teamUser.getTeam().getWin() ? rank.getWins() - 1 : rank.getWins(); + int losses = !teamUser.getTeam().getWin() ? rank.getLosses() - 1: rank.getLosses(); log.info("Before: userId: " + teamUser.getUser().getIntraId() + ", " + "ppp: rank(" + rank.getPpp() + "), redis(" + myTeam.getPpp() + "), win: " + myTeam.getWins() + ", losses: " + myTeam.getLosses()); rank.modifyUserRank(ppp, win, losses); myTeam.changedRank(ppp, win, losses); - rankRepository.flush(); updateRankUser(hashkey, RedisKeyManager.getZSetKey(seasonId), teamUser.getUser().getId(), myTeam); + entityManager.flush(); log.info("After: userId: " + teamUser.getUser().getIntraId() + ", " + "ppp: rank(" + rank.getPpp() + "), redis(" + myTeam.getPpp() + "), win: " + myTeam.getWins() + ", losses: " + myTeam.getLosses()); + return myTeam; } } diff --git a/src/main/java/com/gg/server/domain/season/data/SeasonRepository.java b/src/main/java/com/gg/server/domain/season/data/SeasonRepository.java index 12b643b7f..ae6625826 100644 --- a/src/main/java/com/gg/server/domain/season/data/SeasonRepository.java +++ b/src/main/java/com/gg/server/domain/season/data/SeasonRepository.java @@ -21,4 +21,5 @@ public interface SeasonRepository extends JpaRepository { @Query("select s from Season s where s.startTime <= :now and s.endTime >= :now or s.startTime > :now") List findCurrentAndNewSeason(@Param("now") LocalDateTime now); + } diff --git a/src/main/java/com/gg/server/domain/season/exception/SeasonNotFoundException.java b/src/main/java/com/gg/server/domain/season/exception/SeasonNotFoundException.java index 53e0ddc00..f71457df0 100644 --- a/src/main/java/com/gg/server/domain/season/exception/SeasonNotFoundException.java +++ b/src/main/java/com/gg/server/domain/season/exception/SeasonNotFoundException.java @@ -7,4 +7,7 @@ public class SeasonNotFoundException extends NotExistException { public SeasonNotFoundException() { super("시즌이 없습니다.", ErrorCode.SEASON_NOT_FOUND); } + public SeasonNotFoundException(String message) { + super(message, ErrorCode.SEASON_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/season/service/SeasonService.java b/src/main/java/com/gg/server/domain/season/service/SeasonService.java index 9c0d9571a..769dc5473 100644 --- a/src/main/java/com/gg/server/domain/season/service/SeasonService.java +++ b/src/main/java/com/gg/server/domain/season/service/SeasonService.java @@ -1,7 +1,11 @@ package com.gg.server.domain.season.service; import com.gg.server.domain.season.data.SeasonRepository; +import com.gg.server.domain.season.dto.CurSeason; import com.gg.server.domain.season.dto.SeasonResDto; +import com.gg.server.domain.season.exception.SeasonNotFoundException; +import com.gg.server.global.exception.ErrorCode; + import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -19,8 +23,8 @@ public List seasonList() { .stream().map(SeasonResDto::new).collect(Collectors.toList()); } -// public CurSeason getCurSeason() { -// return new CurSeason(seasonRepository.findByStartTimeGreaterThanEqualAndEndTimeLessThanEqual(LocalDateTime.now()) -// .orElseThrow(() -> new NotExistException("현재 시즌이 존재하지 않습니다.", ErrorCode.NOT_FOUND))); -// } + public CurSeason getCurSeason() { + return new CurSeason(seasonRepository.findCurrentSeason(LocalDateTime.now()) + .orElseThrow(() -> new SeasonNotFoundException("현재 시즌이 존재하지 않습니다."))); + } } diff --git a/src/main/java/com/gg/server/domain/team/data/Team.java b/src/main/java/com/gg/server/domain/team/data/Team.java index a3f4e0b5d..dfb2ce647 100644 --- a/src/main/java/com/gg/server/domain/team/data/Team.java +++ b/src/main/java/com/gg/server/domain/team/data/Team.java @@ -16,6 +16,9 @@ import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.validation.constraints.NotNull; + +import org.hibernate.annotations.DynamicUpdate; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -24,6 +27,7 @@ @AllArgsConstructor @Entity @Getter +@DynamicUpdate public class Team { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/com/gg/server/domain/user/data/User.java b/src/main/java/com/gg/server/domain/user/data/User.java index 1a9b58b21..fc4a3e4d4 100644 --- a/src/main/java/com/gg/server/domain/user/data/User.java +++ b/src/main/java/com/gg/server/domain/user/data/User.java @@ -10,9 +10,12 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; +import org.hibernate.annotations.DynamicUpdate; + @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) +@DynamicUpdate public class User extends BaseTimeEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java b/src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java index 8bb1bf9dc..489271352 100644 --- a/src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java @@ -42,6 +42,8 @@ import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import javax.persistence.EntityManager; + @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc @@ -77,6 +79,8 @@ class GameAdminControllerTest { @Autowired RankRedisRepository rankRedisRepository; + @Autowired + EntityManager entityManager; @AfterEach void redisDown() { @@ -203,6 +207,8 @@ void getUserGameListEndPage() throws Exception { .andReturn().getResponse().getContentAsString(); GameTeamUser historyGame1 = gameRepository.findTeamsByGameIsIn(List.of(game1Info.getGameId())).get(0); + entityManager.flush(); + entityManager.clear(); adminUserRank = rankRepository.findByUserIdAndSeasonId(adminUserId, season.getId()).get(); enemyUser1Rank = rankRepository.findByUserIdAndSeasonId(enemyUser1.getId(), season.getId()) .get(); diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 4bad41a72..f28374ce9 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -155,6 +155,7 @@ cors: logging-level: org.hibernate.SQL: debug + org.hibernate.type: trace slack: xoxbToken: "dummy" From 51d81b886c3c102d0c082bce7fb2456ed3d6fc0f Mon Sep 17 00:00:00 2001 From: hannkim Date: Sat, 27 Jan 2024 19:05:47 +0900 Subject: [PATCH 05/32] =?UTF-8?q?=F0=9F=A7=AA=20[Test]=20MatchFindService?= =?UTF-8?q?=20=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20(#518)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../match/service/MatchFindService.java | 1 - .../service/MatchFindServiceUnitTest.java | 247 ++++++++++++++++++ ...t.java => MatchTournamentServiceTest.java} | 2 +- 3 files changed, 248 insertions(+), 2 deletions(-) create mode 100644 src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java rename src/test/java/com/gg/server/domain/match/service/{MatchTournamentTest.java => MatchTournamentServiceTest.java} (99%) diff --git a/src/main/java/com/gg/server/domain/match/service/MatchFindService.java b/src/main/java/com/gg/server/domain/match/service/MatchFindService.java index 46f675a89..3a8bddf2f 100644 --- a/src/main/java/com/gg/server/domain/match/service/MatchFindService.java +++ b/src/main/java/com/gg/server/domain/match/service/MatchFindService.java @@ -51,7 +51,6 @@ public class MatchFindService { private final RankRedisRepository rankRedisRepository; private final RedisMatchTimeRepository redisMatchTimeRepository; private final TierRepository tierRepository; - private final TournamentRepository tournamentRepository; @Transactional(readOnly = true) diff --git a/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java b/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java new file mode 100644 index 000000000..937b08056 --- /dev/null +++ b/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java @@ -0,0 +1,247 @@ +package com.gg.server.domain.match.service; + +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.data.GameRepository; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.match.data.RedisMatchTime; +import com.gg.server.domain.match.data.RedisMatchTimeRepository; +import com.gg.server.domain.match.data.RedisMatchUserRepository; +import com.gg.server.domain.match.type.Option; +import com.gg.server.domain.match.utils.SlotGenerator; +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.rank.redis.RedisKeyManager; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.service.SeasonFindService; +import com.gg.server.domain.slotmanagement.SlotManagement; +import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; +import com.gg.server.domain.team.data.Team; +import com.gg.server.domain.team.data.TeamUser; +import com.gg.server.domain.tier.data.Tier; +import com.gg.server.domain.tier.data.TierRepository; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.utils.annotation.UnitTest; +import org.junit.jupiter.api.*; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; +import java.util.Set; + +import static com.gg.server.utils.ReflectionUtilsForUnitTest.setFieldWithReflection; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +@UnitTest +@ExtendWith(MockitoExtension.class) +public class MatchFindServiceUnitTest { + @InjectMocks + MatchFindService matchFindService; + @Mock + private SlotManagementRepository slotManagementRepository; + @Mock + private GameRepository gameRepository; + @Mock + private UserRepository userRepository; + @Mock + private RedisMatchUserRepository redisMatchUserRepository; + @Mock + private SeasonFindService seasonFindService; + @Mock + private RankRedisRepository rankRedisRepository; + @Mock + private RedisMatchTimeRepository redisMatchTimeRepository; + @Mock + private TierRepository tierRepository; + + private static final SlotManagement slotManagement = SlotManagement.builder() + .pastSlotTime(0) + .futureSlotTime(12) + .openMinute(5) + .gameInterval(15) + .startTime(LocalDateTime.now()) + .build(); + private static final Season season = Season.builder().startTime(LocalDateTime.now()).startPpp(123).build(); + private static final Tier tier = new Tier(); + + @BeforeEach + public void init() { + setFieldWithReflection(slotManagement, "id", 1L); + setFieldWithReflection(season, "id", 1L); + setFieldWithReflection(tier, "id", 1L); + } + + private Game createGame(User user, User enemy) { + LocalDateTime startTime = LocalDateTime.of(2024, 1, 1, 0, 0); + Game game = new Game(season, StatusType.BEFORE, Mode.NORMAL, startTime, startTime.plusMinutes(15)); + Team teamA = new Team(game, -1, false); + Team teamB = new Team(game, -1, false); + new TeamUser(teamA, user); + new TeamUser(teamB, enemy); + setFieldWithReflection(game, "id", 1L); + return game; + } + + @Nested + @DisplayName("현재 내가 등록한 슬롯 정보 가져오기") + class getCurrentMatch { + private final User user = User.builder().roleType(RoleType.USER).intraId("hannkim").build(); + + @BeforeEach + public void init() { + setFieldWithReflection(user, "id", 1L); + } + + @Test + @DisplayName("등록한 슬롯(최대 3개) 정보를 가져온다.") + void successUnmatchedSlots() { + // given + UserDto userDto = UserDto.from(user); + LocalDateTime startTime = LocalDateTime.of(2024, 1, 1, 0, 0); + RedisMatchTime redisMatchTime = new RedisMatchTime(startTime, Option.BOTH); + given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn(Optional.of(slotManagement)); + given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, user.getId())).willReturn(Optional.empty()); + given(redisMatchUserRepository.getAllMatchTime(user.getId())).willReturn(Set.of(redisMatchTime)); + + // when + matchFindService.getCurrentMatch(userDto); + + // then + verify(slotManagementRepository, times(1)).findCurrent(any(LocalDateTime.class)); + verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, user.getId()); + verify(redisMatchUserRepository, times(1)).getAllMatchTime(user.getId()); + } + + @Test + @DisplayName("매칭된 슬롯(1개) 정보를 가져온다.") + void successMatchedSlot() { + // given + UserDto userDto = UserDto.from(user); + User enemy = User.builder().roleType(RoleType.USER).intraId("enemy").build(); + setFieldWithReflection(enemy, "id", 2L); + Game myGame = createGame(user, enemy); + given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn(Optional.of(slotManagement)); + given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, user.getId())).willReturn(Optional.of(myGame)); + given(userRepository.findEnemyByGameAndUser(myGame.getId(), user.getId())).willReturn(List.of(enemy)); + + // when + matchFindService.getCurrentMatch(userDto); + + // then + verify(slotManagementRepository, times(1)).findCurrent(any(LocalDateTime.class)); + verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, user.getId()); + verify(userRepository, times(1)).findEnemyByGameAndUser(myGame.getId(), user.getId()); + } + + } + + @Nested + @DisplayName("경기 매칭 가능 상태 조회") + class getAllMatchStatus { + private final User user = User.builder().roleType(RoleType.USER).intraId("hannkim").build(); + private SlotGenerator slotGenerator; + + @BeforeEach + void init() { + setFieldWithReflection(user, "id", 1L); + given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn(Optional.of(slotManagement)); + given(seasonFindService.findCurrentSeason(any(LocalDateTime.class))).willReturn(season); + given(tierRepository.findStartTier()).willReturn(Optional.of(tier)); + List games = List.of(); // TODO 수정? 또는 slogGenerator에서 검증? + given(gameRepository.findAllBetween(any(LocalDateTime.class), any(LocalDateTime.class))).willReturn(games); + } + + @AfterEach + void verifyEach() { + verify(slotManagementRepository, times(1)).findCurrent(any(LocalDateTime.class)); + verify(seasonFindService, times(1)).findCurrentSeason(any(LocalDateTime.class)); + verify(tierRepository, times(1)).findStartTier(); + verify(gameRepository, times(1)).findAllBetween(any(LocalDateTime.class), any(LocalDateTime.class)); + } + + @Test + @DisplayName("슬롯 정보를 가져온다. - 내가 등록한 슬롯이 없는 경우") + void success() { + // given + UserDto userDto = UserDto.from(user); + RankRedis redisUser = RankRedis.from(userDto, season.getStartPpp(), tier.getImageUri()); + String hashKey = RedisKeyManager.getHashKey(season.getId()); + slotGenerator = new SlotGenerator(redisUser, slotManagement, season, Option.BOTH); + given(rankRedisRepository.findRankByUserId(hashKey, user.getId())).willReturn(redisUser); // guest가 아닌 유저일 경우 + given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(user).getId())).willReturn(Optional.empty()); + given(redisMatchTimeRepository.getAllEnrolledStartTimes()).willReturn(Set.of(LocalDateTime.now())); + given(redisMatchUserRepository.getAllMatchTime(slotGenerator.getMatchUser().getUserId())).willReturn(Set.of()); + given(redisMatchTimeRepository.getAllMatchUsers(any(LocalDateTime.class))).willReturn(List.of()); // TODO 수정 + + // when + matchFindService.getAllMatchStatus(userDto, Option.BOTH); + + // then + verify(rankRedisRepository, times(1)).findRankByUserId(hashKey, user.getId()); + verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(user).getId()); + verify(redisMatchTimeRepository, times(1)).getAllEnrolledStartTimes(); + verify(redisMatchUserRepository, times(1)).getAllMatchTime(slotGenerator.getMatchUser().getUserId()); + verify(redisMatchTimeRepository, times(1)).getAllMatchUsers(any(LocalDateTime.class)); + + // TODO slotGenerator 검증 (response dto) + } + + @Test + @DisplayName("GUEST 유저가 슬롯 정보를 가져온다. - 내가 등록한 슬롯 없는 경우") + void successGuest() { + // given + User guest = User.builder().intraId("guest").roleType(RoleType.GUEST).build(); + RankRedis redisUser = RankRedis.from(UserDto.from(guest), season.getStartPpp(), tier.getImageUri()); + slotGenerator = new SlotGenerator(redisUser, slotManagement, season, Option.BOTH); + given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(guest).getId())).willReturn(Optional.empty()); + given(redisMatchTimeRepository.getAllEnrolledStartTimes()).willReturn(Set.of(LocalDateTime.now())); + given(redisMatchUserRepository.getAllMatchTime(slotGenerator.getMatchUser().getUserId())).willReturn(Set.of()); + given(redisMatchTimeRepository.getAllMatchUsers(any(LocalDateTime.class))).willReturn(List.of()); // TODO 수정 + + // when + matchFindService.getAllMatchStatus(UserDto.from(guest), Option.BOTH); + + // then + verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(guest).getId()); + verify(redisMatchTimeRepository, times(1)).getAllEnrolledStartTimes(); + verify(redisMatchUserRepository, times(1)).getAllMatchTime(slotGenerator.getMatchUser().getUserId()); + verify(redisMatchTimeRepository, times(1)).getAllMatchUsers(any(LocalDateTime.class)); + } + + @Test + @DisplayName("슬롯 정보를 가져온다. - 내가 등록한 슬롯이 있는 경우") + void successWithMySlot() { + // given + UserDto userDto = UserDto.from(user); + RankRedis redisUser = RankRedis.from(userDto, season.getStartPpp(), tier.getImageUri()); + String hashKey = RedisKeyManager.getHashKey(season.getId()); + User enemy = User.builder().roleType(RoleType.USER).intraId("enemy").build(); + Game game = createGame(user, enemy); + setFieldWithReflection(enemy, "id", 2L); + setFieldWithReflection(game, "id", 1L); + given(rankRedisRepository.findRankByUserId(hashKey, user.getId())).willReturn(redisUser); + given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(user).getId())).willReturn(Optional.of(game)); + given(redisMatchTimeRepository.getAllEnrolledStartTimes()).willReturn(Set.of(LocalDateTime.now())); + given(redisMatchTimeRepository.getAllMatchUsers(any(LocalDateTime.class))).willReturn(List.of()); // TODO 수정 + + // when + matchFindService.getAllMatchStatus(userDto, Option.BOTH); + + // then + verify(rankRedisRepository, times(1)).findRankByUserId(hashKey, user.getId()); + verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(user).getId()); + verify(redisMatchTimeRepository, times(1)).getAllEnrolledStartTimes(); + verify(redisMatchTimeRepository, times(1)).getAllMatchUsers(any(LocalDateTime.class)); + } + } +} diff --git a/src/test/java/com/gg/server/domain/match/service/MatchTournamentTest.java b/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java similarity index 99% rename from src/test/java/com/gg/server/domain/match/service/MatchTournamentTest.java rename to src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java index bdb7b9c79..5f503071a 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchTournamentTest.java +++ b/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java @@ -43,7 +43,7 @@ @IntegrationTest @SpringBootTest @Transactional -public class MatchTournamentTest { +public class MatchTournamentServiceTest { @Autowired TestDataUtils testDataUtils; @Autowired From 191beb32d68d1439b35fae93c8d277edfce11e29 Mon Sep 17 00:00:00 2001 From: SeungChul Chung Date: Sat, 27 Jan 2024 21:55:43 +0900 Subject: [PATCH 06/32] =?UTF-8?q?=E2=9C=A8[Feature]=20checkstyle=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9=20(#517)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 29 + .gitattributes | 24 +- .github/workflows/checkstyle-validation.yml | 21 + build.gradle | 375 ++-- naver-checkstyle-rules.xml | 439 ++++ naver-checkstyle-suppressions.xml | 7 + naver-intellij-formatter.xml | 62 + src/main/java/com/gg/server/Application.java | 1 - .../AnnouncementAdminController.java | 59 +- .../data/AnnouncementAdminRepository.java | 7 +- .../dto/AnnouncementAdminAddDto.java | 12 +- .../dto/AnnouncementAdminListResponseDto.java | 8 +- .../dto/AnnouncementAdminResponseDto.java | 34 +- .../service/AnnouncementAdminService.java | 75 +- .../coin/controller/CoinAdminController.java | 23 +- .../controller/CoinPolicyAdminController.java | 52 +- .../coin/data/CoinPolicyAdminRepository.java | 7 +- .../admin/coin/dto/CoinPolicyAdminAddDto.java | 32 +- .../dto/CoinPolicyAdminListResponseDto.java | 9 +- .../coin/dto/CoinPolicyAdminResponseDto.java | 39 +- .../admin/coin/dto/CoinUpdateRequestDto.java | 16 +- .../admin/coin/service/CoinAdminService.java | 24 +- .../coin/service/CoinPolicyAdminService.java | 43 +- .../controller/FeedbackAdminController.java | 60 +- .../data/FeedbackAdminRepository.java | 5 +- .../data/FeedbackAdminRepositorySearch.java | 5 +- .../FeedbackAdminRepositorySearchImpl.java | 57 +- .../dto/FeedbackAdminPageRequestDto.java | 13 +- .../dto/FeedbackAdminResponseDto.java | 34 +- .../dto/FeedbackListAdminResponseDto.java | 16 +- .../service/FeedbackAdminService.java | 72 +- .../game/controller/GameAdminController.java | 98 +- .../admin/game/data/GameAdminRepository.java | 45 +- .../admin/game/dto/GameLogAdminDto.java | 44 +- .../game/dto/GameLogListAdminResponseDto.java | 8 +- .../admin/game/dto/GameTeamAdminDto.java | 27 +- .../game/dto/GameUserLogAdminReqDto.java | 17 +- .../game/dto/RankGamePPPModifyReqDto.java | 38 +- .../exception/NotRecentlyGameException.java | 6 +- .../admin/game/service/GameAdminService.java | 433 ++-- .../item/controller/ItemAdminController.java | 97 +- .../admin/item/data/ItemAdminRepository.java | 5 +- .../item/dto/ItemHistoryResponseDto.java | 85 +- .../admin/item/dto/ItemListResponseDto.java | 8 +- .../admin/item/dto/ItemUpdateRequestDto.java | 63 +- .../item/exception/ItemNotFoundException.java | 6 +- .../admin/item/service/ItemAdminService.java | 95 +- .../controller/MegaphoneAdminController.java | 39 +- .../data/MegaphoneAdminRepository.java | 5 +- .../dto/MegaphoneAdminResponseDto.java | 25 +- .../dto/MegaphoneHistoryResponseDto.java | 16 +- .../service/MegaphoneAdminService.java | 30 +- .../noti/controller/NotiAdminController.java | 60 +- .../admin/noti/data/NotiAdminRepository.java | 11 +- .../noti/data/NotiAdminRepositoryCustom.java | 5 +- .../data/NotiAdminRepositoryCustomImpl.java | 54 +- .../server/admin/noti/dto/NotiAdminDto.java | 94 +- .../noti/dto/NotiListAdminRequestDto.java | 11 +- .../noti/dto/NotiListAdminResponseDto.java | 46 +- .../noti/dto/SendNotiAdminRequestDto.java | 41 +- .../admin/noti/service/NotiAdminService.java | 104 +- .../pchange/data/PChangeAdminRepository.java | 3 +- .../data/PChangeAdminRepositoryCustom.java | 6 +- .../PChangeAdminRepositoryCustomImpl.java | 29 +- .../exception/PChangeNotExistException.java | 6 +- .../controller/PenaltyAdminController.java | 60 +- .../penalty/data/PenaltyAdminRepository.java | 17 +- .../data/PenaltyAdminRepositoryCustom.java | 16 +- .../PenaltyAdminRepositoryCustomImpl.java | 145 +- .../data/PenaltyUserAdminRedisRepository.java | 87 +- .../penalty/dto/PenaltyListResponseDto.java | 5 +- .../admin/penalty/dto/PenaltyRequestDto.java | 14 +- .../penalty/dto/PenaltyUserResponseDto.java | 52 +- .../penalty/service/PenaltyAdminService.java | 222 +- .../server/admin/penalty/type/PenaltyKey.java | 6 +- .../admin/rank/service/RankAdminService.java | 120 +- .../rank/service/RankRedisAdminService.java | 128 +- .../controller/ReceiptAdminController.java | 38 +- .../receipt/data/ReceiptAdminRepository.java | 7 +- .../data/ReceiptAdminRepositorySearch.java | 7 +- .../dto/ReceiptAdminPageRequestDto.java | 11 +- .../receipt/dto/ReceiptListResponseDto.java | 8 +- .../admin/receipt/dto/ReceiptResponseDto.java | 63 +- .../receipt/service/ReceiptAdminService.java | 34 +- .../controller/SeasonAdminController.java | 69 +- .../season/data/SeasonAdminRepository.java | 27 +- .../admin/season/dto/SeasonAdminDto.java | 64 +- .../season/dto/SeasonCreateRequestDto.java | 56 +- .../dto/SeasonListAdminResponseDto.java | 12 +- .../season/dto/SeasonUpdateRequestDto.java | 32 +- .../season/service/SeasonAdminService.java | 339 +-- .../admin/season/type/SeasonStatus.java | 9 +- .../controller/SlotAdminController.java | 47 +- .../data/AdminSlotManagementsRepository.java | 23 + .../data/adminSlotManagementRepository.java | 20 - .../slotmanagement/dto/SlotAdminDto.java | 33 +- .../dto/SlotCreateRequestDto.java | 66 +- .../dto/SlotListAdminResponseDto.java | 12 +- .../service/SlotAdminService.java | 144 +- .../admin/team/data/TeamAdminRepository.java | 9 +- .../team/data/TeamUserAdminRepository.java | 35 +- .../controller/TournamentAdminController.java | 217 +- .../dto/TournamentAdminAddUserRequestDto.java | 5 +- .../TournamentAdminAddUserResponseDto.java | 7 +- .../dto/TournamentAdminCreateRequestDto.java | 40 +- .../dto/TournamentAdminUpdateRequestDto.java | 42 +- .../dto/TournamentGameUpdateRequestDto.java | 42 +- .../service/TournamentAdminService.java | 642 +++--- .../user/controller/UserAdminController.java | 204 +- .../admin/user/data/UserAdminRepository.java | 34 +- .../user/data/UserImageAdminRepository.java | 53 +- .../server/admin/user/dto/UserAdminDto.java | 116 +- .../user/dto/UserDetailAdminResponseDto.java | 147 +- .../admin/user/dto/UserImageAdminDto.java | 33 +- .../dto/UserImageListAdminResponseDto.java | 9 +- .../admin/user/dto/UserSearchAdminDto.java | 65 +- .../user/dto/UserSearchAdminRequestDto.java | 18 +- .../user/dto/UserSearchAdminResponseDto.java | 51 +- .../user/dto/UserUpdateAdminRequestDto.java | 57 +- .../admin/user/service/UserAdminService.java | 393 ++-- .../controller/AnnouncementController.java | 18 +- .../announcement/data/Announcement.java | 76 +- .../data/AnnouncementRepository.java | 6 +- .../announcement/dto/AnnouncementDto.java | 10 +- .../dto/AnnouncementResponseDto.java | 3 +- .../exception/AnnounceDupException.java | 6 +- .../exception/AnnounceNotFoundException.java | 8 +- .../service/AnnouncementService.java | 24 +- .../server/domain/coin/data/CoinHistory.java | 92 +- .../coin/data/CoinHistoryRepository.java | 25 +- .../server/domain/coin/data/CoinPolicy.java | 134 +- .../coin/data/CoinPolicyRepository.java | 6 +- .../coin/dto/UserGameCoinResultDto.java | 16 +- .../CoinHistoryNotFoundException.java | 6 +- .../CoinPolicyNotFoundException.java | 6 +- .../coin/service/CoinHistoryService.java | 107 +- .../coin/service/UserCoinChangeService.java | 160 +- .../server/domain/coin/type/HistoryType.java | 10 +- .../controller/FeedbackController.java | 67 +- .../server/domain/feedback/data/Feedback.java | 101 +- .../feedback/data/FeedbackRepository.java | 2 +- .../feedback/dto/FeedbackRequestDto.java | 52 +- .../exception/FeedbackNotFoundException.java | 6 +- .../feedback/service/FeedbackService.java | 54 +- .../domain/feedback/type/FeedbackType.java | 42 +- .../gg/server/domain/game/GameController.java | 218 +- .../com/gg/server/domain/game/data/Game.java | 182 +- .../domain/game/data/GameRepository.java | 209 +- .../game/data/GameRepositoryCustom.java | 2 +- .../domain/game/data/GameRepositoryImpl.java | 41 +- .../domain/game/dto/GameListResDto.java | 54 +- .../game/dto/GamePChangeResultResDto.java | 77 +- .../game/dto/GamePPPChangeResultResDto.java | 38 +- .../domain/game/dto/GameResultResDto.java | 134 +- .../server/domain/game/dto/GameTeamInfo.java | 94 +- .../server/domain/game/dto/GameTeamUser.java | 66 +- .../domain/game/dto/GameTeamUserInfo.java | 33 +- .../game/dto/request/GameListReqDto.java | 12 +- .../dto/request/NormalGameListReqDto.java | 11 +- .../game/dto/request/NormalResultReqDto.java | 10 +- .../game/dto/request/RankGameListReqDto.java | 18 +- .../game/dto/request/RankResultReqDto.java | 42 +- .../dto/request/TournamentResultReqDto.java | 44 +- .../exception/GameAlreadyExistException.java | 6 +- .../GameDataConsistencyException.java | 7 +- .../game/exception/GameNotExistException.java | 6 +- .../GameStatusNotMatchedException.java | 6 +- .../ScoreAlreadyEnteredException.java | 6 +- .../exception/ScoreNotInvalidException.java | 6 +- .../exception/ScoreNotMatchedException.java | 7 +- .../domain/game/service/GameFindService.java | 254 ++- .../domain/game/service/GameService.java | 600 +++--- .../game/service/GameStatusService.java | 147 +- .../com/gg/server/domain/game/type/Mode.java | 57 +- .../server/domain/game/type/StatusType.java | 40 +- .../item/controller/ItemController.java | 82 +- .../com/gg/server/domain/item/data/Item.java | 212 +- .../domain/item/data/ItemRepository.java | 7 +- .../domain/item/data/UserItemRepository.java | 9 +- .../domain/item/dto/ItemGiftRequestDto.java | 4 +- .../item/dto/ItemStoreListResponseDto.java | 12 +- .../domain/item/dto/ItemStoreResponseDto.java | 41 +- .../item/dto/UserItemListResponseDto.java | 18 +- .../domain/item/dto/UserItemResponseDto.java | 33 +- .../InsufficientGgcoinException.java | 6 +- .../exception/ItemImageLargeException.java | 6 +- .../exception/ItemImageTypeException.java | 6 +- .../exception/ItemNotAvailableException.java | 6 +- .../item/exception/ItemNotFoundException.java | 8 +- .../ItemNotPurchasableException.java | 8 +- .../item/exception/ItemTypeException.java | 4 +- .../item/exception/KakaoGiftException.java | 6 +- .../exception/KakaoPurchaseException.java | 6 +- .../domain/item/service/ItemService.java | 252 +-- .../gg/server/domain/item/type/ItemType.java | 2 +- .../match/controller/MatchController.java | 98 +- .../domain/match/data/RedisMatchTime.java | 30 +- .../match/data/RedisMatchTimeRepository.java | 70 +- .../domain/match/data/RedisMatchUser.java | 26 +- .../match/data/RedisMatchUserRepository.java | 85 +- .../server/domain/match/dto/GameAddDto.java | 35 +- .../domain/match/dto/MatchRequestDto.java | 29 +- .../domain/match/dto/MatchStatusDto.java | 120 +- .../match/dto/MatchStatusResponseListDto.java | 22 +- .../domain/match/dto/SlotStatusDto.java | 50 +- .../match/dto/SlotStatusResponseListDto.java | 23 +- .../exception/EnrolledSlotException.java | 6 +- .../LosingTeamNotFoundException.java | 6 +- .../exception/OptionInvalidException.java | 6 +- .../match/exception/PastSlotException.java | 6 +- .../exception/PenaltyUserSlotException.java | 6 +- .../match/exception/SlotCountException.java | 6 +- .../exception/SlotNotFoundException.java | 6 +- .../WinningTeamNotFoundException.java | 6 +- .../match/service/GameUpdateService.java | 103 +- .../match/service/MatchFindService.java | 185 +- .../domain/match/service/MatchService.java | 362 ++-- .../match/service/MatchTournamentService.java | 450 ++-- .../gg/server/domain/match/type/MatchKey.java | 31 +- .../gg/server/domain/match/type/Option.java | 48 +- .../server/domain/match/type/SlotStatus.java | 38 +- .../match/type/TournamentMatchStatus.java | 16 +- .../domain/match/utils/MatchCalculator.java | 156 +- .../domain/match/utils/SlotGenerator.java | 179 +- .../controller/MegaphoneController.java | 73 +- .../domain/megaphone/data/Megaphone.java | 97 +- .../megaphone/data/MegaphoneRepository.java | 15 +- .../dto/MegaphoneDetailResponseDto.java | 17 +- .../dto/MegaphoneTodayListResponseDto.java | 17 +- .../megaphone/dto/MegaphoneUseRequestDto.java | 15 +- .../exception/MegaphoneContentException.java | 6 +- .../exception/MegaphoneNotFoundException.java | 4 +- .../exception/MegaphoneTimeException.java | 6 +- .../megaphone/redis/MegaphoneRedis.java | 25 +- .../redis/MegaphoneRedisRepository.java | 36 +- .../megaphone/service/MegaphoneService.java | 148 +- .../noti/controller/NotiController.java | 53 +- .../com/gg/server/domain/noti/data/Noti.java | 118 +- .../domain/noti/data/NotiRepository.java | 34 +- .../noti/data/NotiRepositoryCustom.java | 2 +- .../domain/noti/data/NotiRepositoryImpl.java | 24 +- .../gg/server/domain/noti/dto/NotiDto.java | 108 +- .../domain/noti/dto/NotiListResponseDto.java | 41 +- .../domain/noti/dto/NotiResponseDto.java | 102 +- .../server/domain/noti/dto/UserNotiDto.java | 25 +- .../exception/SlackJsonParseException.java | 6 +- .../noti/exception/SlackSendException.java | 6 +- .../SlackUserGetFailedException.java | 6 +- .../domain/noti/service/NotiService.java | 220 +- .../domain/noti/service/SnsNotiService.java | 80 +- .../noti/service/sns/NotiMailSender.java | 77 +- .../noti/service/sns/SlackbotService.java | 290 +-- .../noti/service/sns/SlackbotUtils.java | 10 +- .../gg/server/domain/noti/type/NotiType.java | 70 +- .../server/domain/pchange/data/PChange.java | 147 +- .../pchange/data/PChangeRepository.java | 32 +- .../pchange/data/PChangeRepositoryCustom.java | 8 +- .../pchange/data/PChangeRepositoryImpl.java | 92 +- .../exception/PChangeNotExistException.java | 6 +- .../pchange/service/PChangeService.java | 80 +- .../server/domain/penalty/data/Penalty.java | 119 +- .../penalty/data/PenaltyRepository.java | 1 - .../exception/PenaltyExpiredException.java | 6 +- .../exception/PenaltyNotFoundException.java | 6 +- .../RedisPenaltyUserNotFoundException.java | 6 +- .../redis/PenaltyUserRedisRepository.java | 33 +- .../penalty/redis/RedisPenaltyUser.java | 60 +- .../penalty/service/PenaltyService.java | 110 +- .../domain/penalty/type/PenaltyType.java | 50 +- .../rank/controller/RankController.java | 65 +- .../rank/controller/RankV2Controller.java | 67 +- .../com/gg/server/domain/rank/data/Rank.java | 215 +- .../domain/rank/data/RankRepository.java | 110 +- .../gg/server/domain/rank/dto/ExpRankDto.java | 96 +- .../rank/dto/ExpRankPageResponseDto.java | 11 +- .../server/domain/rank/dto/ExpRankV2Dto.java | 17 +- .../gg/server/domain/rank/dto/RankDto.java | 55 +- .../domain/rank/dto/RankPageResponseDto.java | 12 +- .../gg/server/domain/rank/dto/RankV2Dto.java | 17 +- .../rank/exception/RankNotFoundException.java | 6 +- .../rank/exception/RankUpdateException.java | 6 +- .../exception/RedisDataNotFoundException.java | 6 +- .../server/domain/rank/redis/RankRedis.java | 178 +- .../rank/redis/RankRedisRepository.java | 420 ++-- .../domain/rank/redis/RankRedisService.java | 279 +-- .../domain/rank/redis/RedisKeyManager.java | 24 +- .../domain/rank/service/RankFindService.java | 14 +- .../domain/rank/service/RankService.java | 408 ++-- .../rank/service/RedisUploadService.java | 108 +- .../server/domain/receipt/data/Receipt.java | 145 +- .../exception/ItemStatusException.java | 4 +- .../exception/ReceiptNotFoundException.java | 4 +- .../exception/ReceiptNotOwnerException.java | 4 +- .../domain/receipt/type/ItemStatus.java | 32 +- .../domain/season/SeasonController.java | 19 +- .../gg/server/domain/season/data/Season.java | 108 +- .../domain/season/data/SeasonRepository.java | 25 +- .../server/domain/season/dto/CurSeason.java | 33 +- .../domain/season/dto/SeasonListResDto.java | 12 +- .../domain/season/dto/SeasonResDto.java | 27 +- .../exception/SeasonForbiddenException.java | 6 +- .../exception/SeasonNotFoundException.java | 13 +- .../exception/SeasonTimeBeforeException.java | 6 +- .../season/service/SeasonFindService.java | 47 +- .../domain/season/service/SeasonService.java | 30 +- .../domain/slotmanagement/SlotManagement.java | 114 +- .../data/SlotManagementRepository.java | 19 +- .../SlotManagementForbiddenException.java | 6 +- .../SlotManagementNotFoundException.java | 6 +- .../com/gg/server/domain/team/data/Team.java | 66 +- .../domain/team/data/TeamRepository.java | 6 +- .../gg/server/domain/team/data/TeamUser.java | 93 +- .../domain/team/data/TeamUserRepository.java | 20 +- .../gg/server/domain/team/dto/GameUser.java | 14 +- .../domain/team/dto/MatchTeamsInfoDto.java | 66 +- .../gg/server/domain/team/dto/TeamInfo.java | 69 +- .../gg/server/domain/team/dto/TeamReqDto.java | 42 +- .../domain/team/dto/TeamUserInfoDto.java | 77 +- .../domain/team/dto/TeamUserListDto.java | 90 +- .../exception/TeamIdNotMatchException.java | 6 +- .../team/exception/TeamNotFoundException.java | 6 +- .../com/gg/server/domain/tier/data/Tier.java | 61 +- .../domain/tier/data/TierRepository.java | 12 +- .../tier/exception/TierNotFoundException.java | 6 +- .../domain/tier/service/TierService.java | 102 +- .../controller/TournamentController.java | 147 +- .../domain/tournament/data/Tournament.java | 249 ++- .../tournament/data/TournamentGame.java | 105 +- .../data/TournamentGameRepository.java | 13 +- .../tournament/data/TournamentRepository.java | 36 +- .../tournament/data/TournamentUser.java | 82 +- .../data/TournamentUserRepository.java | 16 +- .../dto/TournamentFilterRequestDto.java | 15 +- .../dto/TournamentGameListResponseDto.java | 30 +- .../tournament/dto/TournamentGameResDto.java | 41 +- .../dto/TournamentListResponseDto.java | 7 +- .../tournament/dto/TournamentResponseDto.java | 54 +- .../dto/TournamentUserListResponseDto.java | 27 +- ...TournamentUserRegistrationResponseDto.java | 4 +- .../dto/TournamentUserResponseDto.java | 25 +- .../TournamentConflictException.java | 13 +- .../TournamentGameNotFoundException.java | 6 +- .../TournamentNotFoundException.java | 13 +- .../exception/TournamentUpdateException.java | 13 +- .../tournament/service/TournamentService.java | 521 ++--- .../tournament/type/TournamentRound.java | 76 +- .../tournament/type/TournamentStatus.java | 42 +- .../tournament/type/TournamentType.java | 42 +- .../tournament/type/TournamentUserStatus.java | 10 +- .../user/controller/UserController.java | 322 +-- .../com/gg/server/domain/user/data/User.java | 285 +-- .../gg/server/domain/user/data/UserImage.java | 97 +- .../domain/user/data/UserImageRepository.java | 6 +- .../domain/user/data/UserRepository.java | 105 +- .../user/dto/CoinHistoryResponseDto.java | 22 +- .../domain/user/dto/UserAccessTokenDto.java | 2 +- .../user/dto/UserAttendanceResponseDto.java | 6 +- .../domain/user/dto/UserBackgroundDto.java | 30 +- .../dto/UserCoinHistoryListResponseDto.java | 10 +- .../domain/user/dto/UserCoinResponseDto.java | 8 +- .../user/dto/UserDetailResponseDto.java | 103 +- .../gg/server/domain/user/dto/UserDto.java | 115 +- .../server/domain/user/dto/UserEdgeDto.java | 30 +- .../domain/user/dto/UserHistoryData.java | 17 +- .../user/dto/UserHistoryResponseDto.java | 6 +- .../server/domain/user/dto/UserImageDto.java | 34 +- .../domain/user/dto/UserImageResponseDto.java | 6 +- .../domain/user/dto/UserLiveResponseDto.java | 9 +- .../domain/user/dto/UserModifyRequestDto.java | 7 +- .../user/dto/UserNormalDetailResponseDto.java | 17 +- .../server/domain/user/dto/UserOauthDto.java | 4 +- .../user/dto/UserProfileImageRequestDto.java | 8 +- .../domain/user/dto/UserRankResponseDto.java | 10 +- .../user/dto/UserSearchResponseDto.java | 6 +- .../domain/user/dto/UserTextColorDto.java | 33 +- .../KakaoOauth2AlreadyExistException.java | 7 +- .../KakaoOauth2NotFoundException.java | 6 +- .../exception/TokenNotValidException.java | 6 +- .../UserAlreadyAttendanceException.java | 6 +- .../exception/UserImageLargeException.java | 6 +- .../exception/UserImageNullException.java | 6 +- .../exception/UserImageTypeException.java | 6 +- .../user/exception/UserNotFoundException.java | 6 +- .../exception/UserTextColorException.java | 20 +- .../service/UserAuthenticationService.java | 21 +- .../domain/user/service/UserCoinService.java | 47 +- .../domain/user/service/UserFindService.java | 94 +- .../domain/user/service/UserService.java | 755 ++++--- .../service/UserTextColorCheckService.java | 52 +- .../domain/user/type/BackgroundType.java | 91 +- .../gg/server/domain/user/type/EdgeType.java | 103 +- .../gg/server/domain/user/type/OauthType.java | 54 +- .../server/domain/user/type/RacketType.java | 38 +- .../gg/server/domain/user/type/RoleType.java | 27 +- .../gg/server/domain/user/type/SnsType.java | 28 +- .../gg/server/global/config/AWSConfig.java | 37 +- .../global/config/AsyncConfiguration.java | 42 +- .../server/global/config/ConstantConfig.java | 16 +- .../gg/server/global/config/RedisConfig.java | 154 +- .../server/global/config/SwaggerConfig.java | 79 +- .../global/config/TimeZoneConfiguration.java | 13 +- .../gg/server/global/config/WebConfig.java | 64 +- .../gg/server/global/dto/PageRequestDto.java | 35 +- .../gg/server/global/exception/ErrorCode.java | 308 ++- .../global/exception/ErrorResponse.java | 16 +- .../exception/GlobalExceptionHandler.java | 220 +- .../custom/AuthenticationException.java | 8 +- .../exception/custom/BusinessException.java | 14 +- .../custom/CustomRuntimeException.java | 21 +- .../custom/DBConsistencyException.java | 7 +- .../custom/DuplicationException.java | 8 +- .../exception/custom/ExpiredException.java | 8 +- .../exception/custom/FileException.java | 8 +- .../exception/custom/ForbiddenException.java | 8 +- .../custom/InvalidParameterException.java | 9 +- .../exception/custom/NotExistException.java | 8 +- .../custom/PageNotFoundException.java | 15 +- .../exception/custom/ParseException.java | 6 +- .../exception/custom/SendException.java | 6 +- .../server/global/log/aspect/TraceAspect.java | 76 +- .../gg/server/global/log/domain/TraceId.java | 72 +- .../server/global/log/domain/TraceStatus.java | 16 +- .../global/log/pointcut/TracePointcut.java | 19 +- .../server/global/log/service/LogTrace.java | 8 +- .../log/service/ThreadLocalLogTrace.java | 112 +- .../global/scheduler/AbstractScheduler.java | 81 +- .../global/scheduler/GameStatusScheduler.java | 40 +- .../global/scheduler/MegaphoneScheduler.java | 32 +- .../global/scheduler/TournamentScheduler.java | 32 +- .../server/global/security/UserPrincipal.java | 167 +- .../config/RestAuthenticationEntryPoint.java | 38 +- .../security/config/SecurityConfig.java | 132 +- .../config/properties/AppProperties.java | 63 +- .../config/properties/CorsProperties.java | 13 +- .../global/security/cookie/CookieUtil.java | 149 +- .../OAuthAuthenticationSuccessHandler.java | 226 +- .../global/security/info/OAuthUserInfo.java | 27 +- .../security/info/OAuthUserInfoFactory.java | 21 +- .../global/security/info/ProviderType.java | 32 +- .../info/impl/FortyTwoOAuthUserInfo.java | 78 +- .../info/impl/KakaoOAuthUserInfo.java | 77 +- .../jwt/repository/JwtRedisRepository.java | 32 +- .../security/jwt/utils/AuthTokenProvider.java | 134 +- .../jwt/utils/TokenAuthenticationFilter.java | 88 +- .../security/jwt/utils/TokenHeaders.java | 4 +- ...izationRequestBasedOnCookieRepository.java | 83 +- .../service/CustomOAuth2UserService.java | 224 +- .../service/CustomUserDetailsService.java | 61 +- .../global/utils/ApplicationYmlRead.java | 26 +- .../server/global/utils/AsyncMailSender.java | 25 +- .../server/global/utils/BaseTimeEntity.java | 20 +- .../server/global/utils/BusinessChecker.java | 44 +- .../com/gg/server/global/utils/EloRating.java | 22 +- .../global/utils/ExpLevelCalculator.java | 72 +- .../server/global/utils/FileDownloader.java | 36 +- .../gg/server/global/utils/HeaderUtil.java | 24 +- .../global/utils/ImageResizingUtil.java | 35 +- .../server/global/utils/ItemImageHandler.java | 82 +- .../global/utils/JpegMultipartFile.java | 94 +- .../server/global/utils/UserImageHandler.java | 156 +- .../LoginMemberArgumentResolver.java | 80 +- .../utils/aws/AsyncNewItemImageUploader.java | 39 +- .../utils/aws/AsyncNewUserImageUploader.java | 129 +- .../utils/querytracker/ApiQueryCounter.java | 11 +- .../querytracker/ApiQueryCounterAop.java | 28 +- .../utils/querytracker/ApiQueryInspector.java | 32 +- .../querytracker/ConnectionProxyHandler.java | 42 +- .../querytracker/LoggingInterceptor.java | 33 +- .../PreparedStatementProxyHandler.java | 56 +- .../com/gg/server/ServerApplicationTests.java | 7 +- .../AnnouncementAdminControllerFailTest.java | 90 +- .../AnnouncementAdminControllerTest.java | 264 +-- .../controller/CoinAdminControllerTest.java | 82 +- .../CoinPolicyAdminControllerFailTest.java | 70 +- .../CoinPolicyAdminControllerTest.java | 172 +- .../FeedbackAdminControllerTest.java | 275 +-- .../controller/GameAdminControllerTest.java | 559 ++--- .../controller/ItemAdminControllerTest.java | 212 +- .../MegaphoneAdminControllerTest.java | 63 +- .../controller/NotiAdminControllerTest.java | 292 +-- .../PenaltyAdminControllerTest.java | 704 +++--- .../ReceiptAdminControllerTest.java | 180 +- .../season/SeasonAdminControllerTest.java | 422 ++-- .../SlotAdminControllerFailTest.java | 299 ++- .../controller/SlotAdminControllerTest.java | 339 +-- .../TournamentAdminControllerTest.java | 1900 +++++++++-------- .../TournamentAdminUserControllerTest.java | 170 +- .../service/TournamentAdminServiceTest.java | 1115 +++++----- .../controller/UserAdminControllerTest.java | 522 ++--- .../AnnouncementControllerTest.java | 108 +- .../coin/service/CoinHistoryServiceTest.java | 264 +-- .../service/UserCoinChangeServiceTest.java | 399 ++-- .../controller/FeedbackControllerTest.java | 96 +- .../domain/game/GameControllerTest.java | 1613 +++++++------- .../server/domain/game/data/GameUnitTest.java | 209 +- .../domain/game/service/GameDBTest.java | 147 +- .../game/service/GameFindServiceTest.java | 212 +- .../domain/game/service/GameServiceTest.java | 240 ++- .../game/service/GameStatusServiceTest.java | 216 +- .../controller/ItemGiftControllerTest.java | 90 +- .../ItemPurchaseControllerTest.java | 83 +- .../ItemStoreListControllerTest.java | 173 +- .../UserItemResponseControllerTest.java | 56 +- .../match/dto/MatchStatusDtoUnitTest.java | 168 +- .../match/service/MatchBothServiceTest.java | 291 +-- .../service/MatchFindServiceUnitTest.java | 448 ++-- .../match/service/MatchServiceTest.java | 1000 ++++----- .../service/MatchTournamentServiceTest.java | 606 +++--- .../controller/MegaphoneControllerTest.java | 271 +-- .../noti/controller/NotiControllerTest.java | 252 +-- .../domain/noti/service/NotiServiceTest.java | 148 +- .../rank/controller/RankControllerTest.java | 331 ++- .../rank/controller/RankV2ControllerTest.java | 141 +- .../rank/redis/RankRedisRepositoryTest.java | 528 ++--- .../domain/rank/redis/RedisTestService.java | 26 +- .../rank/redis/RedisTransactionTest.java | 122 +- .../domain/rank/service/RankServiceTest.java | 315 +-- .../domain/season/SeasonTestController.java | 107 +- .../domain/season/SeasonTriggerTest.java | 100 +- .../server/domain/team/data/TeamUnitTest.java | 207 +- .../TournamentFindControllerTest.java | 1036 ++++----- .../TournamentGameControllerTest.java | 137 +- .../controller/TournamentSchedulerTest.java | 172 +- .../data/TournamentGameUnitTest.java | 40 +- .../tournament/data/TournamentUnitTest.java | 670 +++--- .../data/TournamentUserUnitTest.java | 87 +- .../service/TournamentServiceTest.java | 473 ++-- .../user/controller/UserControllerTest.java | 1198 ++++++----- .../user/controller/dto/GameInfoDto.java | 10 +- .../com/gg/server/utils/ItemTestUtils.java | 77 +- .../com/gg/server/utils/MatchTestUtils.java | 360 ++-- .../utils/ReflectionUtilsForUnitTest.java | 27 +- .../com/gg/server/utils/TestDataUtils.java | 1495 ++++++------- .../utils/annotation/DataJpaUnitTest.java | 3 +- .../utils/annotation/IntegrationTest.java | 10 +- .../annotation/IntegrationTestAspect.java | 23 +- .../IntegrationTestWithRedisTransaction.java | 8 +- .../utils/annotation/TestTypeConstant.java | 4 +- .../gg/server/utils/annotation/UnitTest.java | 3 +- .../utils/annotation/WebMvcUnitTest.java | 3 +- .../server/utils/config/MySQLInitializer.java | 36 +- .../server/utils/config/RedisInitializer.java | 33 +- .../server/utils/config/TestRedisConfig.java | 24 +- 543 files changed, 26672 insertions(+), 24483 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/checkstyle-validation.yml create mode 100644 naver-checkstyle-rules.xml create mode 100644 naver-checkstyle-suppressions.xml create mode 100644 naver-intellij-formatter.xml create mode 100644 src/main/java/com/gg/server/admin/slotmanagement/data/AdminSlotManagementsRepository.java delete mode 100644 src/main/java/com/gg/server/admin/slotmanagement/data/adminSlotManagementRepository.java diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..2b2595ef1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,29 @@ +# top-most EditorConfig file +root = true + +[*] +# [encoding-utf8] +charset = utf-8 + +# [newline-lf] +end_of_line = lf + +# [newline-eof] +insert_final_newline = true + +[*.bat] +end_of_line = crlf + +[*.java] +# [indentation-tab] +indent_style = tab + +# [4-spaces-tab] +indent_size = 4 +tab_width = 4 + +# [no-trailing-spaces] +trim_trailing_whitespace = true + +[line-length-120] +max_line_length = 120 diff --git a/.gitattributes b/.gitattributes index 5811c65a2..2e0efdd4b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,18 +1,18 @@ # Set the default behavior, in case people don't have core.autocrlf set. -* text=auto +* text=auto eol=lf # Explicitly declare text files you want to always be normalized and converted # to native line endings on checkout. -*.java text=auto -*.sql text=auto -*.md text=auto -*.txt text=auto -*.gradle text=auto -Dockerfile text=auto -*.yml text=auto -*.yaml text=auto -*.sh text=auto - +*.java text=auto eol=lf +*.sql text=auto eol=lf +*.md text=auto eol=lf +*.txt text=auto eol=lf +*.gradle text=auto eol=lf +Dockerfile text=auto eol=lf +*.yml text=auto eol=lf +*.yaml text=auto eol=lf +*.sh text=auto eol=lf +*.bat text=auto eol=crlf # Denote all files that are truly binary and should not be modified. *.png binary -*.jpg binary \ No newline at end of file +*.jpg binary diff --git a/.github/workflows/checkstyle-validation.yml b/.github/workflows/checkstyle-validation.yml new file mode 100644 index 000000000..86277c01f --- /dev/null +++ b/.github/workflows/checkstyle-validation.yml @@ -0,0 +1,21 @@ +name: 👮Checkstyle validation + +on: + pull_request: + branches: [ main, dev ] + +jobs: + checkstyle: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Main checkstyle + run: ./gradlew --console verbose clean checkstyleMain + - name: ️Test checkstyle + run: ./gradlew --console verbose clean checkstyleTest diff --git a/build.gradle b/build.gradle index 49a217681..e91a7ac69 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,27 @@ plugins { - id 'org.springframework.boot' version '2.6.8' - id 'io.spring.dependency-management' version '1.0.11.RELEASE' - id 'org.asciidoctor.jvm.convert' version '3.3.2' - id 'java' - id 'jacoco' + id 'org.springframework.boot' version '2.6.8' + id 'io.spring.dependency-management' version '1.0.11.RELEASE' + id 'org.asciidoctor.jvm.convert' version '3.3.2' + id 'java' + id 'jacoco' + id 'org.ec4j.editorconfig' version '0.0.3' + id 'checkstyle' } +editorconfig { + excludes = ['build'] +} + +checkstyle { + maxWarnings = 0 + configFile = file("${rootDir}/naver-checkstyle-rules.xml") + configProperties = ["suppressionFile": "${rootDir}/naver-checkstyle-suppressions.xml"] + toolVersion = "8.24" +} + + springBoot { - mainClass = "com.gg.server.Application" + mainClass = "com.gg.server.Application" } group = 'io.42pp' @@ -15,236 +29,237 @@ version = '42gg' sourceCompatibility = '11' configurations { - compileOnly { - extendsFrom annotationProcessor - } + compileOnly { + extendsFrom annotationProcessor + } } repositories { - mavenCentral() + mavenCentral() } ext { - set('snippetsDir', file("build/generated-snippets")) + set('snippetsDir', file("build/generated-snippets")) } dependencies { - /* spring */ - implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-mail' - annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' - - /* database */ - runtimeOnly 'mysql:mysql-connector-java' - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' - - /* redis */ - implementation 'org.springframework.boot:spring-boot-starter-data-redis' - implementation 'org.springframework.session:spring-session-data-redis' - implementation 'org.redisson:redisson:3.17.3' - - /* oauth */ - implementation 'org.springframework.boot:spring-boot-starter-security' - implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' - - /* JSON Web Token */ - implementation 'io.jsonwebtoken:jjwt-api:0.11.2' - implementation 'io.jsonwebtoken:jjwt-impl:0.11.2' - implementation 'io.jsonwebtoken:jjwt-jackson:0.11.2' - - /* test */ - testImplementation 'org.springframework.boot:spring-boot-starter-test' - testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' - - /* lombok */ - implementation 'org.projectlombok:lombok:1.18.26' - annotationProcessor 'org.projectlombok:lombok' - compileOnly 'org.projectlombok:lombok' - - /* SHA256 */ - implementation 'com.google.guava:guava:31.0.1-jre' - - /* When..? Error */ - implementation 'org.apache.commons:commons-lang3:3.12.0' - - /* REST template */ - implementation 'org.apache.httpcomponents:httpcore:4.4.15' - implementation 'org.apache.httpcomponents:httpclient:4.5.13' - - /* S3 Image Bucket */ - implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' - implementation 'org.springframework:spring-test:5.3.20' - implementation "com.amazonaws:aws-java-sdk-s3:1.12.281" - - testImplementation 'org.springframework.security:spring-security-test' - - //test에서 lombok 사용 - testImplementation 'org.projectlombok:lombok' - testCompileOnly 'org.projectlombok:lombok' - testAnnotationProcessor 'org.projectlombok:lombok' - - /* spring doc */ - implementation 'org.springdoc:springdoc-openapi-ui:1.6.6' - - /* flyway */ - implementation 'org.flywaydb:flyway-core' - - /* elk-logstash */ - implementation 'net.logstash.logback:logstash-logback-encoder:6.3' - - //actuator 추가 - implementation 'org.springframework.boot:spring-boot-starter-actuator' - - //prometheus 추가 - implementation 'io.micrometer:micrometer-registry-prometheus' - - //testcontainers 추가 - testImplementation "org.testcontainers:mysql:1.19.3" - testImplementation "com.redis:testcontainers-redis:2.0.1" - testImplementation "org.junit.jupiter:junit-jupiter:5.8.1" - testImplementation "org.testcontainers:testcontainers:1.19.3" - testImplementation "org.testcontainers:junit-jupiter:1.19.3" + /* spring */ + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-mail' + annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' + + /* database */ + runtimeOnly 'mysql:mysql-connector-java' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + + /* redis */ + implementation 'org.springframework.boot:spring-boot-starter-data-redis' + implementation 'org.springframework.session:spring-session-data-redis' + implementation 'org.redisson:redisson:3.17.3' + + /* oauth */ + implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' + + /* JSON Web Token */ + implementation 'io.jsonwebtoken:jjwt-api:0.11.2' + implementation 'io.jsonwebtoken:jjwt-impl:0.11.2' + implementation 'io.jsonwebtoken:jjwt-jackson:0.11.2' + + /* test */ + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' + + /* lombok */ + implementation 'org.projectlombok:lombok:1.18.26' + annotationProcessor 'org.projectlombok:lombok' + compileOnly 'org.projectlombok:lombok' + + /* SHA256 */ + implementation 'com.google.guava:guava:31.0.1-jre' + + /* When..? Error */ + implementation 'org.apache.commons:commons-lang3:3.12.0' + + /* REST template */ + implementation 'org.apache.httpcomponents:httpcore:4.4.15' + implementation 'org.apache.httpcomponents:httpclient:4.5.13' + + /* S3 Image Bucket */ + implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' + implementation 'org.springframework:spring-test:5.3.20' + implementation "com.amazonaws:aws-java-sdk-s3:1.12.281" + + testImplementation 'org.springframework.security:spring-security-test' + + //test에서 lombok 사용 + testImplementation 'org.projectlombok:lombok' + testCompileOnly 'org.projectlombok:lombok' + testAnnotationProcessor 'org.projectlombok:lombok' + + /* spring doc */ + implementation 'org.springdoc:springdoc-openapi-ui:1.6.6' + + /* flyway */ + implementation 'org.flywaydb:flyway-core' + + /* elk-logstash */ + implementation 'net.logstash.logback:logstash-logback-encoder:6.3' + + //actuator 추가 + implementation 'org.springframework.boot:spring-boot-starter-actuator' + + //prometheus 추가 + implementation 'io.micrometer:micrometer-registry-prometheus' + + //testcontainers 추가 + testImplementation "org.testcontainers:mysql:1.19.3" + testImplementation "com.redis:testcontainers-redis:2.0.1" + testImplementation "org.junit.jupiter:junit-jupiter:5.8.1" + testImplementation "org.testcontainers:testcontainers:1.19.3" + testImplementation "org.testcontainers:junit-jupiter:1.19.3" } //테스트 커버리지 측정도구 jacoco { - toolVersion = "0.8.8" + toolVersion = "0.8.8" } // dto, 외부 연동 서비스는 테스트에서 제외 -def jacocoExcludes = [ - '*Application*', - "**/config/*", - "**/security/*", - "**/dto/*", - "**/aws/*", - "*NotiMailSender*", - '*SlackbotService*', +def jacocoExcludes = [ + '*Application*', + "**/config/*", + "**/security/*", + "**/dto/*", + "**/aws/*", + "*NotiMailSender*", + '*SlackbotService*', ] //커버리지 리포트 생성 jacocoTestReport { - reports { - xml.enabled true - html.enabled true - csv.enabled false - } - - afterEvaluate { - //dto 및 외부 연동 서비스는 테스트에서 제외 - classDirectories.setFrom(files(classDirectories.files.collect { - fileTree(dir: it, exclude: jacocoExcludes)}) - ) - } + reports { + xml.enabled true + html.enabled true + csv.enabled false + } + + afterEvaluate { + //dto 및 외부 연동 서비스는 테스트에서 제외 + classDirectories.setFrom(files(classDirectories.files.collect { + fileTree(dir: it, exclude: jacocoExcludes) + }) + ) + } } // 커버리지 검증 설정 jacocoTestCoverageVerification { - violationRules { - rule { - enabled = true - element = 'CLASS' - - //브랜치 커버리지 - limit { - counter = 'BRANCH' - value = 'COVEREDRATIO' - minimum = 0.00 - } - - //메소드 커버리지 - limit { - counter = 'METHOD' - value = 'COVEREDRATIO' - minimum = 0.00 - } - - //라인 커버리지 - limit { - counter = 'LINE' - value = 'COVEREDRATIO' - minimum = 0.00 - } - - //검증에서 제외할 패키지, 클래스 - excludes = jacocoExcludes - } - } + violationRules { + rule { + enabled = true + element = 'CLASS' + + //브랜치 커버리지 + limit { + counter = 'BRANCH' + value = 'COVEREDRATIO' + minimum = 0.00 + } + + //메소드 커버리지 + limit { + counter = 'METHOD' + value = 'COVEREDRATIO' + minimum = 0.00 + } + + //라인 커버리지 + limit { + counter = 'LINE' + value = 'COVEREDRATIO' + minimum = 0.00 + } + + //검증에서 제외할 패키지, 클래스 + excludes = jacocoExcludes + } + } } //전체 테스트 test { - description = 'Runs the total tests.' - useJUnitPlatform() + description = 'Runs the total tests.' + useJUnitPlatform() } //유닛 테스트 task unitTest(type: Test) { - group = 'verification' - description = 'Runs the unit tests.' - useJUnitPlatform{ - includeTags 'UnitTest' - excludeTags 'IntegrationTest' - } + group = 'verification' + description = 'Runs the unit tests.' + useJUnitPlatform { + includeTags 'UnitTest' + excludeTags 'IntegrationTest' + } - jacoco { - destinationFile = file("$buildDir/jacoco/test.exec") - } + jacoco { + destinationFile = file("$buildDir/jacoco/test.exec") + } } //통합 테스트 task integrationTest(type: Test) { - group = 'verification' - description = 'Runs the integration tests.' - useJUnitPlatform{ - includeTags 'IntegrationTest' - excludeTags 'UnitTest' - } - - jacoco { - destinationFile = file("$buildDir/jacoco/test.exec") - } + group = 'verification' + description = 'Runs the integration tests.' + useJUnitPlatform { + includeTags 'IntegrationTest' + excludeTags 'UnitTest' + } + + jacoco { + destinationFile = file("$buildDir/jacoco/test.exec") + } } //전체 테스트, 리포트 생성, 검증 task totalTestCoverage(type: Test) { - group 'verification' - description 'Runs the total tests with coverage' + group 'verification' + description 'Runs the total tests with coverage' - dependsOn(':test', - ':jacocoTestReport', - ':jacocoTestCoverageVerification') + dependsOn(':test', + ':jacocoTestReport', + ':jacocoTestCoverageVerification') - tasks['jacocoTestReport'].mustRunAfter(tasks['test']) - tasks['jacocoTestCoverageVerification'].mustRunAfter(tasks['jacocoTestReport']) + tasks['jacocoTestReport'].mustRunAfter(tasks['test']) + tasks['jacocoTestCoverageVerification'].mustRunAfter(tasks['jacocoTestReport']) } //유닛 테스트, 리포트 생성, 검증 task unitTestCoverage(type: Test) { - group 'verification' - description 'Runs the unit tests with coverage' + group 'verification' + description 'Runs the unit tests with coverage' - dependsOn(':unitTest', - ':jacocoTestReport', - ':jacocoTestCoverageVerification') + dependsOn(':unitTest', + ':jacocoTestReport', + ':jacocoTestCoverageVerification') - tasks['jacocoTestReport'].mustRunAfter(tasks['unitTest']) - tasks['jacocoTestCoverageVerification'].mustRunAfter(tasks['jacocoTestReport']) + tasks['jacocoTestReport'].mustRunAfter(tasks['unitTest']) + tasks['jacocoTestCoverageVerification'].mustRunAfter(tasks['jacocoTestReport']) } //통합 테스트, 리포트 생성, 검증 task integrationTestCoverage(type: Test) { - group 'verification' - description 'Runs the integration tests with coverage' + group 'verification' + description 'Runs the integration tests with coverage' - dependsOn(':integrationTest', - ':jacocoTestReport', - ':jacocoTestCoverageVerification') + dependsOn(':integrationTest', + ':jacocoTestReport', + ':jacocoTestCoverageVerification') - tasks['jacocoTestReport'].mustRunAfter(tasks['integrationTest']) - tasks['jacocoTestCoverageVerification'].mustRunAfter(tasks['jacocoTestReport']) + tasks['jacocoTestReport'].mustRunAfter(tasks['integrationTest']) + tasks['jacocoTestCoverageVerification'].mustRunAfter(tasks['jacocoTestReport']) } diff --git a/naver-checkstyle-rules.xml b/naver-checkstyle-rules.xml new file mode 100644 index 000000000..a022f4485 --- /dev/null +++ b/naver-checkstyle-rules.xml @@ -0,0 +1,439 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/naver-checkstyle-suppressions.xml b/naver-checkstyle-suppressions.xml new file mode 100644 index 000000000..3f11e0cd3 --- /dev/null +++ b/naver-checkstyle-suppressions.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/naver-intellij-formatter.xml b/naver-intellij-formatter.xml new file mode 100644 index 000000000..658fc659f --- /dev/null +++ b/naver-intellij-formatter.xml @@ -0,0 +1,62 @@ + + + diff --git a/src/main/java/com/gg/server/Application.java b/src/main/java/com/gg/server/Application.java index d09e439f3..ae01225eb 100644 --- a/src/main/java/com/gg/server/Application.java +++ b/src/main/java/com/gg/server/Application.java @@ -2,7 +2,6 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; @SpringBootApplication public class Application { diff --git a/src/main/java/com/gg/server/admin/announcement/controller/AnnouncementAdminController.java b/src/main/java/com/gg/server/admin/announcement/controller/AnnouncementAdminController.java index c8e6c4006..b750e1f84 100644 --- a/src/main/java/com/gg/server/admin/announcement/controller/AnnouncementAdminController.java +++ b/src/main/java/com/gg/server/admin/announcement/controller/AnnouncementAdminController.java @@ -1,10 +1,6 @@ package com.gg.server.admin.announcement.controller; -import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; -import com.gg.server.admin.announcement.dto.AnnouncementAdminListResponseDto; -import com.gg.server.admin.announcement.service.AnnouncementAdminService; -import com.gg.server.global.dto.PageRequestDto; -import lombok.AllArgsConstructor; +import javax.validation.Valid; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -12,39 +8,50 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; -import javax.validation.Valid; +import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; +import com.gg.server.admin.announcement.dto.AnnouncementAdminListResponseDto; +import com.gg.server.admin.announcement.service.AnnouncementAdminService; +import com.gg.server.global.dto.PageRequestDto; + +import lombok.AllArgsConstructor; @RestController @AllArgsConstructor @RequestMapping("pingpong/admin") @Validated public class AnnouncementAdminController { - private final AnnouncementAdminService announcementAdminService; - - @GetMapping("/announcement") - public ResponseEntity getAnnouncementList( - @ModelAttribute @Valid PageRequestDto anReq) { + private final AnnouncementAdminService announcementAdminService; - Pageable pageable = PageRequest.of(anReq.getPage() - 1, anReq.getSize(), Sort.by("createdAt").descending()); + @GetMapping("/announcement") + public ResponseEntity getAnnouncementList( + @ModelAttribute @Valid PageRequestDto anReq) { - return ResponseEntity.ok() - .body(announcementAdminService.findAllAnnouncement(pageable)); - } + Pageable pageable = PageRequest.of(anReq.getPage() - 1, anReq.getSize(), Sort.by("createdAt").descending()); - @PostMapping("/announcement") - public ResponseEntity addaAnnouncement(@Valid @RequestBody AnnouncementAdminAddDto addDto){ - announcementAdminService.addAnnouncement(addDto); + return ResponseEntity.ok() + .body(announcementAdminService.findAllAnnouncement(pageable)); + } - return new ResponseEntity(HttpStatus.CREATED); - } + @PostMapping("/announcement") + public ResponseEntity addaAnnouncement(@Valid @RequestBody AnnouncementAdminAddDto addDto) { + announcementAdminService.addAnnouncement(addDto); + return new ResponseEntity(HttpStatus.CREATED); + } - @DeleteMapping("/announcement/{deleterIntraId}") - public ResponseEntity announcementModify(@PathVariable String deleterIntraId) { - announcementAdminService.modifyAnnouncementIsDel(deleterIntraId); + @DeleteMapping("/announcement/{deleterIntraId}") + public ResponseEntity announcementModify(@PathVariable String deleterIntraId) { + announcementAdminService.modifyAnnouncementIsDel(deleterIntraId); - return new ResponseEntity(HttpStatus.NO_CONTENT); - } + return new ResponseEntity(HttpStatus.NO_CONTENT); + } } diff --git a/src/main/java/com/gg/server/admin/announcement/data/AnnouncementAdminRepository.java b/src/main/java/com/gg/server/admin/announcement/data/AnnouncementAdminRepository.java index d85cac043..8a3ed6b4f 100644 --- a/src/main/java/com/gg/server/admin/announcement/data/AnnouncementAdminRepository.java +++ b/src/main/java/com/gg/server/admin/announcement/data/AnnouncementAdminRepository.java @@ -1,11 +1,12 @@ package com.gg.server.admin.announcement.data; -import com.gg.server.domain.announcement.data.Announcement; +import java.util.Optional; + import org.springframework.data.jpa.repository.JpaRepository; -import java.util.Optional; +import com.gg.server.domain.announcement.data.Announcement; public interface AnnouncementAdminRepository extends JpaRepository { - Optional findFirstByOrderByIdDesc(); + Optional findFirstByOrderByIdDesc(); } diff --git a/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminAddDto.java b/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminAddDto.java index 368d619b5..36140d7f1 100644 --- a/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminAddDto.java +++ b/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminAddDto.java @@ -1,17 +1,17 @@ package com.gg.server.admin.announcement.dto; +import javax.validation.constraints.NotNull; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotNull; - @Getter @NoArgsConstructor @AllArgsConstructor public class AnnouncementAdminAddDto { - @NotNull(message = "plz. content") - private String content; - @NotNull(message = "plz. creatorIntraId") - private String creatorIntraId; + @NotNull(message = "plz. content") + private String content; + @NotNull(message = "plz. creatorIntraId") + private String creatorIntraId; } diff --git a/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminListResponseDto.java b/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminListResponseDto.java index f851a2716..b516b46ee 100644 --- a/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminListResponseDto.java +++ b/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminListResponseDto.java @@ -1,15 +1,15 @@ package com.gg.server.admin.announcement.dto; +import java.util.List; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @AllArgsConstructor @NoArgsConstructor @Getter public class AnnouncementAdminListResponseDto { - private List announcementList; - private int totalPage; + private List announcementList; + private int totalPage; } diff --git a/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminResponseDto.java b/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminResponseDto.java index c236dfa83..c7ad638d4 100644 --- a/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminResponseDto.java @@ -1,28 +1,28 @@ package com.gg.server.admin.announcement.dto; +import java.time.LocalDateTime; + import com.gg.server.domain.announcement.data.Announcement; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; - @Getter @NoArgsConstructor public class AnnouncementAdminResponseDto { - private String creatorIntraId; - private String deleterIntraId; - private String content; - private LocalDateTime createdAt; - private LocalDateTime modifiedAt; - private LocalDateTime deletedAt; + private String creatorIntraId; + private String deleterIntraId; + private String content; + private LocalDateTime createdAt; + private LocalDateTime modifiedAt; + private LocalDateTime deletedAt; - public AnnouncementAdminResponseDto(Announcement announcementAdmin) - { - this.content = announcementAdmin.getContent(); - this.creatorIntraId = announcementAdmin.getCreatorIntraId(); - this.deleterIntraId = announcementAdmin.getDeleterIntraId(); - this.createdAt = announcementAdmin.getCreatedAt(); - this.modifiedAt = announcementAdmin.getModifiedAt(); - this.deletedAt = announcementAdmin.getDeletedAt(); - } + public AnnouncementAdminResponseDto(Announcement announcementAdmin) { + this.content = announcementAdmin.getContent(); + this.creatorIntraId = announcementAdmin.getCreatorIntraId(); + this.deleterIntraId = announcementAdmin.getDeleterIntraId(); + this.createdAt = announcementAdmin.getCreatedAt(); + this.modifiedAt = announcementAdmin.getModifiedAt(); + this.deletedAt = announcementAdmin.getDeletedAt(); + } } diff --git a/src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java b/src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java index f6f4da05a..24f272114 100644 --- a/src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java +++ b/src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java @@ -1,5 +1,12 @@ package com.gg.server.admin.announcement.service; +import java.time.LocalDateTime; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.admin.announcement.data.AnnouncementAdminRepository; import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; import com.gg.server.admin.announcement.dto.AnnouncementAdminListResponseDto; @@ -7,54 +14,54 @@ import com.gg.server.domain.announcement.data.Announcement; import com.gg.server.domain.announcement.exception.AnnounceDupException; import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; -import lombok.AllArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; +import lombok.AllArgsConstructor; @Service @AllArgsConstructor public class AnnouncementAdminService { - private final AnnouncementAdminRepository announcementAdminRepository; + private final AnnouncementAdminRepository announcementAdminRepository; - @Transactional(readOnly = true) - public AnnouncementAdminListResponseDto findAllAnnouncement(Pageable pageable) { - Page allAnnouncements = announcementAdminRepository.findAll(pageable); - Page responseDtos = allAnnouncements.map(AnnouncementAdminResponseDto::new); + @Transactional(readOnly = true) + public AnnouncementAdminListResponseDto findAllAnnouncement(Pageable pageable) { + Page allAnnouncements = announcementAdminRepository.findAll(pageable); + Page responseDtos = allAnnouncements.map(AnnouncementAdminResponseDto::new); - return new AnnouncementAdminListResponseDto(responseDtos.getContent(), - responseDtos.getTotalPages()); - } + return new AnnouncementAdminListResponseDto(responseDtos.getContent(), + responseDtos.getTotalPages()); + } - @Transactional - public void addAnnouncement(AnnouncementAdminAddDto addDto){ - if (findAnnouncementExist() == true) - throw new AnnounceDupException(); + @Transactional + public void addAnnouncement(AnnouncementAdminAddDto addDto) { + if (findAnnouncementExist() == true) { + throw new AnnounceDupException(); + } - Announcement announcementAdmin = Announcement.from(addDto); + Announcement announcementAdmin = Announcement.from(addDto); - announcementAdminRepository.save(announcementAdmin); - } + announcementAdminRepository.save(announcementAdmin); + } - @Transactional - public void modifyAnnouncementIsDel(String deleterIntraId) { - if (findAnnouncementExist() == false) - throw new AnnounceNotFoundException(); + @Transactional + public void modifyAnnouncementIsDel(String deleterIntraId) { + if (findAnnouncementExist() == false) { + throw new AnnounceNotFoundException(); + } - Announcement announcement = announcementAdminRepository.findFirstByOrderByIdDesc().orElseThrow(()-> new AnnounceNotFoundException()); - announcement.update(deleterIntraId, LocalDateTime.now()); - } + Announcement announcement = announcementAdminRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new AnnounceNotFoundException()); + announcement.update(deleterIntraId, LocalDateTime.now()); + } - private Boolean findAnnouncementExist() { - Announcement announcement = announcementAdminRepository.findFirstByOrderByIdDesc().orElseThrow(()-> new AnnounceNotFoundException()); + private Boolean findAnnouncementExist() { + Announcement announcement = announcementAdminRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new AnnounceNotFoundException()); - if (announcement.getDeletedAt() == null) - return true; + if (announcement.getDeletedAt() == null) { + return true; + } - return false; - } + return false; + } } diff --git a/src/main/java/com/gg/server/admin/coin/controller/CoinAdminController.java b/src/main/java/com/gg/server/admin/coin/controller/CoinAdminController.java index 581766615..8470432d2 100644 --- a/src/main/java/com/gg/server/admin/coin/controller/CoinAdminController.java +++ b/src/main/java/com/gg/server/admin/coin/controller/CoinAdminController.java @@ -1,21 +1,26 @@ package com.gg.server.admin.coin.controller; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import com.gg.server.admin.coin.dto.CoinUpdateRequestDto; import com.gg.server.admin.coin.service.CoinAdminService; + import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; @RestController @RequiredArgsConstructor @RequestMapping("pingpong/admin/coin") public class CoinAdminController { - private final CoinAdminService coinAdminService; + private final CoinAdminService coinAdminService; - @PutMapping() - public ResponseEntity updateUserCoin(@RequestBody CoinUpdateRequestDto coinUpdateRequestDto) { - coinAdminService.updateUserCoin(coinUpdateRequestDto); - return new ResponseEntity(HttpStatus.NO_CONTENT); - } + @PutMapping() + public ResponseEntity updateUserCoin(@RequestBody CoinUpdateRequestDto coinUpdateRequestDto) { + coinAdminService.updateUserCoin(coinUpdateRequestDto); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } } diff --git a/src/main/java/com/gg/server/admin/coin/controller/CoinPolicyAdminController.java b/src/main/java/com/gg/server/admin/coin/controller/CoinPolicyAdminController.java index b67d1537a..0bf3a5aed 100644 --- a/src/main/java/com/gg/server/admin/coin/controller/CoinPolicyAdminController.java +++ b/src/main/java/com/gg/server/admin/coin/controller/CoinPolicyAdminController.java @@ -1,44 +1,52 @@ package com.gg.server.admin.coin.controller; +import javax.validation.Valid; + +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import com.gg.server.admin.coin.dto.CoinPolicyAdminAddDto; import com.gg.server.admin.coin.dto.CoinPolicyAdminListResponseDto; import com.gg.server.admin.coin.service.CoinPolicyAdminService; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.dto.PageRequestDto; import com.gg.server.global.utils.argumentresolver.Login; + import io.swagger.v3.oas.annotations.Parameter; -import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; @RestController @RequiredArgsConstructor @RequestMapping("pingpong/admin") @Validated public class CoinPolicyAdminController { - private final CoinPolicyAdminService coinPolicyAdminService; + private final CoinPolicyAdminService coinPolicyAdminService; - @GetMapping("/coinpolicy") - public ResponseEntity getCoinPolicyList(@ModelAttribute @Valid PageRequestDto coReq){ - Pageable pageable = PageRequest.of(coReq.getPage() - 1, coReq.getSize(), Sort.by("createdAt").descending()); + @GetMapping("/coinpolicy") + public ResponseEntity getCoinPolicyList( + @ModelAttribute @Valid PageRequestDto coReq) { + Pageable pageable = PageRequest.of(coReq.getPage() - 1, coReq.getSize(), Sort.by("createdAt").descending()); - return ResponseEntity.ok() - .body(coinPolicyAdminService.findAllCoinPolicy(pageable)); - } + return ResponseEntity.ok() + .body(coinPolicyAdminService.findAllCoinPolicy(pageable)); + } - @PostMapping("/coinpolicy") - public ResponseEntity addCoinPolicy(@Parameter(hidden = true) @Login UserDto userDto, @Valid @RequestBody CoinPolicyAdminAddDto addDto){ + @PostMapping("/coinpolicy") + public ResponseEntity addCoinPolicy(@Parameter(hidden = true) @Login UserDto userDto, + @Valid @RequestBody CoinPolicyAdminAddDto addDto) { - coinPolicyAdminService.addCoinPolicy(userDto, addDto); - return new ResponseEntity(HttpStatus.CREATED); - } + coinPolicyAdminService.addCoinPolicy(userDto, addDto); + return new ResponseEntity(HttpStatus.CREATED); + } } diff --git a/src/main/java/com/gg/server/admin/coin/data/CoinPolicyAdminRepository.java b/src/main/java/com/gg/server/admin/coin/data/CoinPolicyAdminRepository.java index 87e8f5412..292472f7e 100644 --- a/src/main/java/com/gg/server/admin/coin/data/CoinPolicyAdminRepository.java +++ b/src/main/java/com/gg/server/admin/coin/data/CoinPolicyAdminRepository.java @@ -1,10 +1,11 @@ package com.gg.server.admin.coin.data; -import com.gg.server.domain.coin.data.CoinPolicy; +import java.util.Optional; + import org.springframework.data.jpa.repository.JpaRepository; -import java.util.Optional; +import com.gg.server.domain.coin.data.CoinPolicy; public interface CoinPolicyAdminRepository extends JpaRepository { - Optional findFirstByOrderByIdDesc(); + Optional findFirstByOrderByIdDesc(); } diff --git a/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminAddDto.java b/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminAddDto.java index 1420c2ea3..e79c697ca 100644 --- a/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminAddDto.java +++ b/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminAddDto.java @@ -1,29 +1,29 @@ package com.gg.server.admin.coin.dto; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.PositiveOrZero; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.PositiveOrZero; - @Getter @NoArgsConstructor @AllArgsConstructor public class CoinPolicyAdminAddDto { - @NotNull(message = "plz. not null attendance") - @PositiveOrZero(message = "plz. attendance PositiveOrZero") - private int attendance; + @NotNull(message = "plz. not null attendance") + @PositiveOrZero(message = "plz. attendance PositiveOrZero") + private int attendance; - @NotNull(message = "plz. not null normal") - @PositiveOrZero(message = "plz. normal PositiveOrZero") - private int normal; + @NotNull(message = "plz. not null normal") + @PositiveOrZero(message = "plz. normal PositiveOrZero") + private int normal; - @NotNull(message = "plz. not null rankWin") - @PositiveOrZero(message = "plz. rankWin PositiveOrZero") - private int rankWin; + @NotNull(message = "plz. not null rankWin") + @PositiveOrZero(message = "plz. rankWin PositiveOrZero") + private int rankWin; - @NotNull(message = "plz. not null rankLose") - @PositiveOrZero(message = "plz. rankLose PositiveOrZero") - private int rankLose; -} \ No newline at end of file + @NotNull(message = "plz. not null rankLose") + @PositiveOrZero(message = "plz. rankLose PositiveOrZero") + private int rankLose; +} diff --git a/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminListResponseDto.java b/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminListResponseDto.java index b5014b54e..8ac8d68f3 100644 --- a/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminListResponseDto.java +++ b/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminListResponseDto.java @@ -1,16 +1,15 @@ package com.gg.server.admin.coin.dto; -import com.gg.server.admin.announcement.dto.AnnouncementAdminResponseDto; +import java.util.List; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @AllArgsConstructor @NoArgsConstructor @Getter public class CoinPolicyAdminListResponseDto { - private List coinPolicyList; - private int totalPage; + private List coinPolicyList; + private int totalPage; } diff --git a/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminResponseDto.java b/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminResponseDto.java index 08110e751..d1aa2a11e 100644 --- a/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminResponseDto.java @@ -1,31 +1,30 @@ package com.gg.server.admin.coin.dto; -import com.gg.server.domain.announcement.data.Announcement; +import java.time.LocalDateTime; + import com.gg.server.domain.coin.data.CoinPolicy; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; - @Getter @NoArgsConstructor public class CoinPolicyAdminResponseDto { - private Long coinPolicyId; - private String createUserId; - private int attendance; - private int normal; - private int rankWin; - private int rankLose; - private LocalDateTime createdAt; + private Long coinPolicyId; + private String createUserId; + private int attendance; + private int normal; + private int rankWin; + private int rankLose; + private LocalDateTime createdAt; - public CoinPolicyAdminResponseDto(CoinPolicy coinPolicyAdmin) - { - this.coinPolicyId = coinPolicyAdmin.getId(); - this.createUserId = coinPolicyAdmin.getUser().getIntraId(); - this.attendance = coinPolicyAdmin.getAttendance(); - this.normal = coinPolicyAdmin.getNormal(); - this.rankWin = coinPolicyAdmin.getRankWin(); - this.rankLose = coinPolicyAdmin.getRankLose(); - this.createdAt = coinPolicyAdmin.getCreatedAt(); - } + public CoinPolicyAdminResponseDto(CoinPolicy coinPolicyAdmin) { + this.coinPolicyId = coinPolicyAdmin.getId(); + this.createUserId = coinPolicyAdmin.getUser().getIntraId(); + this.attendance = coinPolicyAdmin.getAttendance(); + this.normal = coinPolicyAdmin.getNormal(); + this.rankWin = coinPolicyAdmin.getRankWin(); + this.rankLose = coinPolicyAdmin.getRankLose(); + this.createdAt = coinPolicyAdmin.getCreatedAt(); + } } diff --git a/src/main/java/com/gg/server/admin/coin/dto/CoinUpdateRequestDto.java b/src/main/java/com/gg/server/admin/coin/dto/CoinUpdateRequestDto.java index 85349c464..97e59c6aa 100644 --- a/src/main/java/com/gg/server/admin/coin/dto/CoinUpdateRequestDto.java +++ b/src/main/java/com/gg/server/admin/coin/dto/CoinUpdateRequestDto.java @@ -1,19 +1,19 @@ package com.gg.server.admin.coin.dto; +import javax.validation.constraints.NotNull; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotNull; - @Getter @AllArgsConstructor @NoArgsConstructor public class CoinUpdateRequestDto { - @NotNull(message = "intraId는 null이 될 수 없습니다.") - private String intraId; - @NotNull(message = "change는 null이 될 수 없습니다.") - private int change; - @NotNull(message = "content는 null이 될 수 없습니다.") - private String content; + @NotNull(message = "intraId는 null이 될 수 없습니다.") + private String intraId; + @NotNull(message = "change는 null이 될 수 없습니다.") + private int change; + @NotNull(message = "content는 null이 될 수 없습니다.") + private String content; } diff --git a/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java b/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java index 2c2237f26..3fe706cb9 100644 --- a/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java +++ b/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java @@ -1,25 +1,29 @@ package com.gg.server.admin.coin.service; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.admin.coin.dto.CoinUpdateRequestDto; import com.gg.server.domain.coin.data.CoinHistory; import com.gg.server.domain.coin.service.CoinHistoryService; import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.exception.UserNotFoundException; + import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor public class CoinAdminService { - private final UserRepository userRepository; - private final CoinHistoryService coinHistoryService; + private final UserRepository userRepository; + private final CoinHistoryService coinHistoryService; - @Transactional - public void updateUserCoin(CoinUpdateRequestDto coinUpdateRequestDto) { - User user = userRepository.findByIntraId(coinUpdateRequestDto.getIntraId()).orElseThrow(UserNotFoundException::new); - user.addGgCoin(coinUpdateRequestDto.getChange()); - coinHistoryService.addCoinHistory(new CoinHistory(user, coinUpdateRequestDto.getContent(), coinUpdateRequestDto.getChange())); - } + @Transactional + public void updateUserCoin(CoinUpdateRequestDto coinUpdateRequestDto) { + User user = userRepository.findByIntraId(coinUpdateRequestDto.getIntraId()) + .orElseThrow(UserNotFoundException::new); + user.addGgCoin(coinUpdateRequestDto.getChange()); + coinHistoryService.addCoinHistory( + new CoinHistory(user, coinUpdateRequestDto.getContent(), coinUpdateRequestDto.getChange())); + } } diff --git a/src/main/java/com/gg/server/admin/coin/service/CoinPolicyAdminService.java b/src/main/java/com/gg/server/admin/coin/service/CoinPolicyAdminService.java index 8311b72e7..1f84d2206 100644 --- a/src/main/java/com/gg/server/admin/coin/service/CoinPolicyAdminService.java +++ b/src/main/java/com/gg/server/admin/coin/service/CoinPolicyAdminService.java @@ -1,43 +1,42 @@ package com.gg.server.admin.coin.service; -import com.gg.server.admin.announcement.dto.AnnouncementAdminListResponseDto; -import com.gg.server.admin.announcement.dto.AnnouncementAdminResponseDto; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.admin.coin.data.CoinPolicyAdminRepository; import com.gg.server.admin.coin.dto.CoinPolicyAdminAddDto; import com.gg.server.admin.coin.dto.CoinPolicyAdminListResponseDto; import com.gg.server.admin.coin.dto.CoinPolicyAdminResponseDto; import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.domain.announcement.data.Announcement; import com.gg.server.domain.coin.data.CoinPolicy; import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; + import lombok.AllArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service @AllArgsConstructor public class CoinPolicyAdminService { - private final CoinPolicyAdminRepository coinPolicyAdminRepository; - private final UserAdminRepository userAdminRepository; + private final CoinPolicyAdminRepository coinPolicyAdminRepository; + private final UserAdminRepository userAdminRepository; - @Transactional(readOnly = true) - public CoinPolicyAdminListResponseDto findAllCoinPolicy(Pageable pageable) { - Page allCoinPolicy = coinPolicyAdminRepository.findAll(pageable); - Page responseDtos = allCoinPolicy.map(CoinPolicyAdminResponseDto::new); + @Transactional(readOnly = true) + public CoinPolicyAdminListResponseDto findAllCoinPolicy(Pageable pageable) { + Page allCoinPolicy = coinPolicyAdminRepository.findAll(pageable); + Page responseDtos = allCoinPolicy.map(CoinPolicyAdminResponseDto::new); - return new CoinPolicyAdminListResponseDto(responseDtos.getContent(), - responseDtos.getTotalPages()); - } + return new CoinPolicyAdminListResponseDto(responseDtos.getContent(), + responseDtos.getTotalPages()); + } - @Transactional - public void addCoinPolicy(UserDto userDto, CoinPolicyAdminAddDto addDto){ - User user = userAdminRepository.findByIntraId(userDto.getIntraId()).orElseThrow(UserNotFoundException::new); + @Transactional + public void addCoinPolicy(UserDto userDto, CoinPolicyAdminAddDto addDto) { + User user = userAdminRepository.findByIntraId(userDto.getIntraId()).orElseThrow(UserNotFoundException::new); - CoinPolicy coinPolicy = CoinPolicy.from(user, addDto); - coinPolicyAdminRepository.save(coinPolicy); - } + CoinPolicy coinPolicy = CoinPolicy.from(user, addDto); + coinPolicyAdminRepository.save(coinPolicy); + } } diff --git a/src/main/java/com/gg/server/admin/feedback/controller/FeedbackAdminController.java b/src/main/java/com/gg/server/admin/feedback/controller/FeedbackAdminController.java index acd10b0f2..693644a4d 100644 --- a/src/main/java/com/gg/server/admin/feedback/controller/FeedbackAdminController.java +++ b/src/main/java/com/gg/server/admin/feedback/controller/FeedbackAdminController.java @@ -1,43 +1,51 @@ package com.gg.server.admin.feedback.controller; -import com.gg.server.admin.feedback.dto.FeedbackAdminPageRequestDto; -import com.gg.server.admin.feedback.dto.FeedbackListAdminResponseDto; -import com.gg.server.admin.feedback.service.FeedbackAdminService; -import com.gg.server.global.dto.PageRequestDto; -import lombok.RequiredArgsConstructor; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; + import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; +import com.gg.server.admin.feedback.dto.FeedbackAdminPageRequestDto; +import com.gg.server.admin.feedback.dto.FeedbackListAdminResponseDto; +import com.gg.server.admin.feedback.service.FeedbackAdminService; + +import lombok.RequiredArgsConstructor; @RestController @RequestMapping("pingpong/admin/feedback") @RequiredArgsConstructor @Validated public class FeedbackAdminController { - private final FeedbackAdminService feedbackAdminService; - - @GetMapping - public FeedbackListAdminResponseDto feedbackAll(@ModelAttribute @Valid FeedbackAdminPageRequestDto req) { - - if (req.getIntraId() == null){ - Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize(), Sort.by("isSolved").and(Sort.by("createdAt"))); - return feedbackAdminService.findAllFeedback(pageable); - } - Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize(), Sort.by("intra_id").and(Sort.by("createdAt"))); - return feedbackAdminService.findByPartsOfIntraId(req.getIntraId(), pageable); - } - - @PatchMapping("/{feedbackId}") - public ResponseEntity feedbackIsSolvedToggle(@PathVariable @NotNull Long feedbackId){ - feedbackAdminService.toggleFeedbackIsSolvedByAdmin(feedbackId); - return new ResponseEntity(HttpStatus.NO_CONTENT); - } + private final FeedbackAdminService feedbackAdminService; + + @GetMapping + public FeedbackListAdminResponseDto feedbackAll(@ModelAttribute @Valid FeedbackAdminPageRequestDto req) { + + if (req.getIntraId() == null) { + Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize(), + Sort.by("isSolved").and(Sort.by("createdAt"))); + return feedbackAdminService.findAllFeedback(pageable); + } + Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize(), + Sort.by("intra_id").and(Sort.by("createdAt"))); + return feedbackAdminService.findByPartsOfIntraId(req.getIntraId(), pageable); + } + + @PatchMapping("/{feedbackId}") + public ResponseEntity feedbackIsSolvedToggle(@PathVariable @NotNull Long feedbackId) { + feedbackAdminService.toggleFeedbackIsSolvedByAdmin(feedbackId); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } } diff --git a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java b/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java index 887fcb1fe..3339d0d30 100644 --- a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java +++ b/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java @@ -1,7 +1,8 @@ package com.gg.server.admin.feedback.data; -import com.gg.server.domain.feedback.data.Feedback; import org.springframework.data.jpa.repository.JpaRepository; +import com.gg.server.domain.feedback.data.Feedback; + public interface FeedbackAdminRepository extends JpaRepository, FeedbackAdminRepositorySearch { -} \ No newline at end of file +} diff --git a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearch.java b/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearch.java index 1744f0cf6..8964322dd 100644 --- a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearch.java +++ b/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearch.java @@ -1,10 +1,11 @@ package com.gg.server.admin.feedback.data; -import com.gg.server.domain.feedback.data.Feedback; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.query.Param; +import com.gg.server.domain.feedback.data.Feedback; + public interface FeedbackAdminRepositorySearch { - Page findFeedbacksByUserIntraId(@Param("intraId") String intraId, Pageable pageable); + Page findFeedbacksByUserIntraId(@Param("intraId") String intraId, Pageable pageable); } diff --git a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearchImpl.java b/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearchImpl.java index ea3e3c6c1..6cad3337f 100644 --- a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearchImpl.java +++ b/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearchImpl.java @@ -1,36 +1,39 @@ package com.gg.server.admin.feedback.data; -import com.gg.server.domain.feedback.data.Feedback; -import lombok.RequiredArgsConstructor; +import java.util.List; + +import javax.persistence.EntityManager; + import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import javax.persistence.EntityManager; -import java.util.List; +import com.gg.server.domain.feedback.data.Feedback; + +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor -public class FeedbackAdminRepositorySearchImpl implements FeedbackAdminRepositorySearch{ - - private final EntityManager em; - - public Page findFeedbacksByUserIntraId(String intraId, Pageable pageable) { - long feedbackNum = countTotalFeedbacks(intraId, pageable); - String sql = "select f from Feedback f join fetch f.user where " + - "f.user.intraId like \'%" + intraId + "%\' order by f.user.intraId asc, f.createdAt asc"; - List feedbackList = em.createQuery(sql, Feedback.class) - .setFirstResult((int) pageable.getOffset()) - .setMaxResults(pageable.getPageSize()) - .getResultList(); - Page feedbackPage = new PageImpl<>(feedbackList, pageable, feedbackNum); - return feedbackPage; - } - - private long countTotalFeedbacks(String intraId, Pageable pageable){ - String sql = "select f from Feedback f join fetch f.user where " + - "f.user.intraId like \'%" + intraId + "%\'"; - List feedbackList = em.createQuery(sql, Feedback.class) - .getResultList(); - return feedbackList.size(); - } +public class FeedbackAdminRepositorySearchImpl implements FeedbackAdminRepositorySearch { + + private final EntityManager em; + + public Page findFeedbacksByUserIntraId(String intraId, Pageable pageable) { + long feedbackNum = countTotalFeedbacks(intraId, pageable); + String sql = "select f from Feedback f join fetch f.user where " + + "f.user.intraId like \'%" + intraId + "%\' order by f.user.intraId asc, f.createdAt asc"; + List feedbackList = em.createQuery(sql, Feedback.class) + .setFirstResult((int)pageable.getOffset()) + .setMaxResults(pageable.getPageSize()) + .getResultList(); + Page feedbackPage = new PageImpl<>(feedbackList, pageable, feedbackNum); + return feedbackPage; + } + + private long countTotalFeedbacks(String intraId, Pageable pageable) { + String sql = "select f from Feedback f join fetch f.user where " + + "f.user.intraId like \'%" + intraId + "%\'"; + List feedbackList = em.createQuery(sql, Feedback.class) + .getResultList(); + return feedbackList.size(); + } } diff --git a/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminPageRequestDto.java b/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminPageRequestDto.java index 217b99d3a..cf22d56ce 100644 --- a/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminPageRequestDto.java +++ b/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminPageRequestDto.java @@ -1,16 +1,15 @@ package com.gg.server.admin.feedback.dto; import com.gg.server.global.dto.PageRequestDto; -import lombok.Getter; -import javax.validation.constraints.NotNull; +import lombok.Getter; @Getter public class FeedbackAdminPageRequestDto extends PageRequestDto { - String intraId; + String intraId; - public FeedbackAdminPageRequestDto(String intraId, Integer page, Integer size) { - super(page, size); - this.intraId = intraId; - } + public FeedbackAdminPageRequestDto(String intraId, Integer page, Integer size) { + super(page, size); + this.intraId = intraId; + } } diff --git a/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminResponseDto.java b/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminResponseDto.java index 8c0f680b3..a2bafaba5 100644 --- a/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminResponseDto.java @@ -1,29 +1,29 @@ package com.gg.server.admin.feedback.dto; +import java.time.LocalDateTime; + import com.gg.server.domain.feedback.data.Feedback; import com.gg.server.domain.feedback.type.FeedbackType; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.sql.Date; -import java.time.LocalDateTime; - @Getter @NoArgsConstructor public class FeedbackAdminResponseDto { - private Long id; - private String intraId; - private LocalDateTime createdAt; - private FeedbackType category; - private String content; - private Boolean isSolved; + private Long id; + private String intraId; + private LocalDateTime createdAt; + private FeedbackType category; + private String content; + private Boolean isSolved; - public FeedbackAdminResponseDto(Feedback feedback){ - this.id = feedback.getId(); - this.intraId = feedback.getUser().getIntraId(); - this.createdAt = feedback.getCreatedAt(); - this.category = feedback.getCategory(); - this.content = feedback.getContent(); - this.isSolved = feedback.getIsSolved(); - } + public FeedbackAdminResponseDto(Feedback feedback) { + this.id = feedback.getId(); + this.intraId = feedback.getUser().getIntraId(); + this.createdAt = feedback.getCreatedAt(); + this.category = feedback.getCategory(); + this.content = feedback.getContent(); + this.isSolved = feedback.getIsSolved(); + } } diff --git a/src/main/java/com/gg/server/admin/feedback/dto/FeedbackListAdminResponseDto.java b/src/main/java/com/gg/server/admin/feedback/dto/FeedbackListAdminResponseDto.java index d222e9a49..7447d8c5b 100644 --- a/src/main/java/com/gg/server/admin/feedback/dto/FeedbackListAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/feedback/dto/FeedbackListAdminResponseDto.java @@ -1,18 +1,18 @@ package com.gg.server.admin.feedback.dto; +import java.util.List; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @NoArgsConstructor @Getter public class FeedbackListAdminResponseDto { - private List feedbackList; - private int totalPage; + private List feedbackList; + private int totalPage; - public FeedbackListAdminResponseDto(List newDtos, int totalPage){ - this.feedbackList = newDtos; - this.totalPage= totalPage; - } + public FeedbackListAdminResponseDto(List newDtos, int totalPage) { + this.feedbackList = newDtos; + this.totalPage = totalPage; + } } diff --git a/src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java b/src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java index ee272d076..4fe7adca4 100644 --- a/src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java +++ b/src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java @@ -1,47 +1,51 @@ package com.gg.server.admin.feedback.service; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.admin.feedback.data.FeedbackAdminRepository; import com.gg.server.admin.feedback.dto.FeedbackAdminResponseDto; import com.gg.server.admin.feedback.dto.FeedbackListAdminResponseDto; import com.gg.server.domain.feedback.data.Feedback; import com.gg.server.domain.feedback.exception.FeedbackNotFoundException; + import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor public class FeedbackAdminService { - private final FeedbackAdminRepository feedbackAdminRepository; - - @Transactional(readOnly = true) - public FeedbackListAdminResponseDto findAllFeedback(Pageable pageable){ - Page feedbacks = feedbackAdminRepository.findAll(pageable); - Page feedbackAdminResponseDtos = feedbacks.map(FeedbackAdminResponseDto::new); - - FeedbackListAdminResponseDto responseDto = new FeedbackListAdminResponseDto(feedbackAdminResponseDtos.getContent(), - feedbackAdminResponseDtos.getTotalPages()); - return responseDto; - } - - @Transactional - public void toggleFeedbackIsSolvedByAdmin(Long feedbackId){ - Feedback feedback = feedbackAdminRepository.findById(feedbackId).orElseThrow(FeedbackNotFoundException::new); - if (feedback.getIsSolved()){ - feedback.setIsSolved(false); - }else { - feedback.setIsSolved(true); - } - } - - @Transactional(readOnly = true) - public FeedbackListAdminResponseDto findByPartsOfIntraId(String intraId, Pageable pageable) { - Page feedbacks = feedbackAdminRepository.findFeedbacksByUserIntraId(intraId, pageable); - Page feedbackAdminResponseDtos = feedbacks.map(FeedbackAdminResponseDto::new); - FeedbackListAdminResponseDto responseDto = new FeedbackListAdminResponseDto(feedbackAdminResponseDtos.getContent(), - feedbackAdminResponseDtos.getTotalPages()); - return responseDto; - } + private final FeedbackAdminRepository feedbackAdminRepository; + + @Transactional(readOnly = true) + public FeedbackListAdminResponseDto findAllFeedback(Pageable pageable) { + Page feedbacks = feedbackAdminRepository.findAll(pageable); + Page feedbackAdminResponseDtos = feedbacks.map(FeedbackAdminResponseDto::new); + + FeedbackListAdminResponseDto responseDto = new FeedbackListAdminResponseDto( + feedbackAdminResponseDtos.getContent(), + feedbackAdminResponseDtos.getTotalPages()); + return responseDto; + } + + @Transactional + public void toggleFeedbackIsSolvedByAdmin(Long feedbackId) { + Feedback feedback = feedbackAdminRepository.findById(feedbackId).orElseThrow(FeedbackNotFoundException::new); + if (feedback.getIsSolved()) { + feedback.setIsSolved(false); + } else { + feedback.setIsSolved(true); + } + } + + @Transactional(readOnly = true) + public FeedbackListAdminResponseDto findByPartsOfIntraId(String intraId, Pageable pageable) { + Page feedbacks = feedbackAdminRepository.findFeedbacksByUserIntraId(intraId, pageable); + Page feedbackAdminResponseDtos = feedbacks.map(FeedbackAdminResponseDto::new); + FeedbackListAdminResponseDto responseDto = new FeedbackListAdminResponseDto( + feedbackAdminResponseDtos.getContent(), + feedbackAdminResponseDtos.getTotalPages()); + return responseDto; + } } diff --git a/src/main/java/com/gg/server/admin/game/controller/GameAdminController.java b/src/main/java/com/gg/server/admin/game/controller/GameAdminController.java index 2afd82350..21311a7e0 100644 --- a/src/main/java/com/gg/server/admin/game/controller/GameAdminController.java +++ b/src/main/java/com/gg/server/admin/game/controller/GameAdminController.java @@ -1,5 +1,21 @@ package com.gg.server.admin.game.controller; +import javax.validation.Valid; +import javax.validation.constraints.Positive; + +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import com.gg.server.admin.game.dto.GameLogListAdminResponseDto; import com.gg.server.admin.game.dto.GameUserLogAdminReqDto; import com.gg.server.admin.game.dto.RankGamePPPModifyReqDto; @@ -8,60 +24,52 @@ import com.gg.server.global.dto.PageRequestDto; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.InvalidParameterException; -import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import javax.validation.constraints.Positive; +import lombok.RequiredArgsConstructor; @RestController @RequiredArgsConstructor @RequestMapping("/pingpong/admin/games") public class GameAdminController { - private final GameAdminService gameAdminService; - private final RankRedisService rankRedisService; + private final GameAdminService gameAdminService; + private final RankRedisService rankRedisService; - @GetMapping - public GameLogListAdminResponseDto gameFindBySeasonId(@ModelAttribute @Valid PageRequestDto pageRequestDto) { - int page = pageRequestDto.getPage(); - int size = pageRequestDto.getSize(); + @GetMapping + public GameLogListAdminResponseDto gameFindBySeasonId(@ModelAttribute @Valid PageRequestDto pageRequestDto) { + int page = pageRequestDto.getPage(); + int size = pageRequestDto.getSize(); - Pageable pageable = PageRequest.of(page - 1, size, Sort.by("startTime").descending()); - return gameAdminService.findAllGamesByAdmin(pageable); - } + Pageable pageable = PageRequest.of(page - 1, size, Sort.by("startTime").descending()); + return gameAdminService.findAllGamesByAdmin(pageable); + } - /** - * 특정 유저의 게임 목록 조회 API - * @param reqDto intraId page size - * @return GameLogListAdminResponseDto gameLogList totalPage - */ - @GetMapping("/users") - public GameLogListAdminResponseDto gameFindByIntraId(@ModelAttribute GameUserLogAdminReqDto reqDto) { + /** + * 특정 유저의 게임 목록 조회 API + * @param reqDto intraId page size + * @return GameLogListAdminResponseDto gameLogList totalPage + */ + @GetMapping("/users") + public GameLogListAdminResponseDto gameFindByIntraId(@ModelAttribute GameUserLogAdminReqDto reqDto) { - Pageable pageable = PageRequest.of(reqDto.getPage() - 1, reqDto.getSize()); - return gameAdminService.findGamesByIntraId(reqDto.getIntraId(), pageable); - } + Pageable pageable = PageRequest.of(reqDto.getPage() - 1, reqDto.getSize()); + return gameAdminService.findGamesByIntraId(reqDto.getIntraId(), pageable); + } - /** - * 랭킹 점수 수정 API - * @param reqDto team1Id team1Score team2Id team2Score - * @param gameId 수정할 게임 id - * @return ResponseEntity - * @throws InvalidParameterException 점수가 3점을 초과하거나, 두 팀의 점수가 같을 경우 - */ - @PutMapping("/{gameId}") - public ResponseEntity gameResultEdit(@Valid @RequestBody RankGamePPPModifyReqDto reqDto, - @PathVariable @Positive Long gameId) { - if (reqDto.getTeam1Score() + reqDto.getTeam2Score() > 3 || reqDto.getTeam1Score() == reqDto.getTeam2Score()) { - throw new InvalidParameterException("점수를 잘못 입력했습니다.", ErrorCode.VALID_FAILED); - } - gameAdminService.rankResultEdit(reqDto, gameId); - rankRedisService.updateAllTier(gameId); - return new ResponseEntity(HttpStatus.NO_CONTENT); - } + /** + * 랭킹 점수 수정 API + * @param reqDto team1Id team1Score team2Id team2Score + * @param gameId 수정할 게임 id + * @return ResponseEntity + * @throws InvalidParameterException 점수가 3점을 초과하거나, 두 팀의 점수가 같을 경우 + */ + @PutMapping("/{gameId}") + public ResponseEntity gameResultEdit(@Valid @RequestBody RankGamePPPModifyReqDto reqDto, + @PathVariable @Positive Long gameId) { + if (reqDto.getTeam1Score() + reqDto.getTeam2Score() > 3 || reqDto.getTeam1Score() == reqDto.getTeam2Score()) { + throw new InvalidParameterException("점수를 잘못 입력했습니다.", ErrorCode.VALID_FAILED); + } + gameAdminService.rankResultEdit(reqDto, gameId); + rankRedisService.updateAllTier(gameId); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } } diff --git a/src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java b/src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java index 37ac7eaad..576cb41c6 100644 --- a/src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java +++ b/src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java @@ -1,37 +1,42 @@ package com.gg.server.admin.game.data; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.season.data.Season; +import java.util.List; import java.util.Optional; + import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import java.util.List; +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.dto.GameTeamUser; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.season.data.Season; public interface GameAdminRepository extends JpaRepository { - Page findBySeason(Pageable pageable, Season season); + Page findBySeason(Pageable pageable, Season season); + + Page findBySeasonAndModeIn(Pageable pageable, Season season, List modes); - Page findBySeasonAndModeIn(Pageable pageable, Season season, List modes); + Page findAllByModeIn(Pageable pageable, List modes); - Page findAllByModeIn(Pageable pageable, List modes); + @Query(value = "select t1.gameId, t1.startTime, t1.endTime, t1.status, t1.mode, " + + "t1.teamId t1TeamId, t1.intraId t1IntraId, t1.win t1IsWin, t1.score t1Score, " + + "t1.image t1Image, t1.total_exp t1Exp, t1.wins t1Wins, t1.losses t1Losses, " + + "t2.teamId t2TeamId, t2.win t2IsWin, t2.score t2Score, t2.intraId t2IntraId, " + + "t2.wins t2Wins, t2.losses t2Losses, t2.image t2Image, t2.total_exp t2Exp " + + "from v_rank_game_detail t1, v_rank_game_detail t2 " + + "where t1.gameId IN (:games) and t1.teamId findTeamsByGameIsIn(@Param("games") List games); - @Query(value = "select t1.gameId, t1.startTime, t1.endTime, t1.status, t1.mode, " + - "t1.teamId t1TeamId, t1.intraId t1IntraId, t1.win t1IsWin, t1.score t1Score, t1.image t1Image, t1.total_exp t1Exp, t1.wins t1Wins, t1.losses t1Losses, " + - "t2.teamId t2TeamId, t2.win t2IsWin, t2.score t2Score, t2.intraId t2IntraId, t2.wins t2Wins, t2.losses t2Losses, t2.image t2Image, t2.total_exp t2Exp " + - "from v_rank_game_detail t1, v_rank_game_detail t2 " + - "where t1.gameId IN (:games) and t1.teamId findTeamsByGameIsIn(@Param("games") List games); - @Query(value = "SELECT g FROM Game g, Team t, TeamUser tu WHERE g.status = :status AND g.id = t.game.id" - + " AND t.id = tu.team.id AND tu.user.id = :userId") - Optional findByStatusTypeAndUserId(@Param("status") StatusType status, @Param("userId") Long userId); + @Query(value = "SELECT g FROM Game g, Team t, TeamUser tu WHERE g.status = :status AND g.id = t.game.id" + + " AND t.id = tu.team.id AND tu.user.id = :userId") + Optional findByStatusTypeAndUserId(@Param("status") StatusType status, @Param("userId") Long userId); - @Query(value = "SELECT g FROM Game g JOIN FETCH g.season WHERE g.id = :gameId") - Optional findGameWithSeasonByGameId(@Param("gameId")Long gameId); + @Query(value = "SELECT g FROM Game g JOIN FETCH g.season WHERE g.id = :gameId") + Optional findGameWithSeasonByGameId(@Param("gameId") Long gameId); } diff --git a/src/main/java/com/gg/server/admin/game/dto/GameLogAdminDto.java b/src/main/java/com/gg/server/admin/game/dto/GameLogAdminDto.java index 58d080092..17b4a731a 100644 --- a/src/main/java/com/gg/server/admin/game/dto/GameLogAdminDto.java +++ b/src/main/java/com/gg/server/admin/game/dto/GameLogAdminDto.java @@ -1,34 +1,38 @@ package com.gg.server.admin.game.dto; +import java.time.Duration; +import java.time.LocalDateTime; + import com.gg.server.domain.game.dto.GameTeamUser; import com.gg.server.domain.game.type.StatusType; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.Duration; -import java.time.LocalDateTime; - @Getter @AllArgsConstructor @NoArgsConstructor public class GameLogAdminDto { - private Long gameId; - private LocalDateTime startAt; - private String slotTime; - private String mode; - private StatusType status; - private GameTeamAdminDto team1; - private GameTeamAdminDto team2; + private Long gameId; + private LocalDateTime startAt; + private String slotTime; + private String mode; + private StatusType status; + private GameTeamAdminDto team1; + private GameTeamAdminDto team2; - public GameLogAdminDto(GameTeamUser game) { - this.gameId = game.getGameId(); - this.startAt = game.getStartTime(); - this.slotTime = game.getEndTime() == null ? null : - String.valueOf(Duration.between(game.getStartTime().toLocalTime(), game.getEndTime().toLocalTime()).toMinutes()); - this.mode = game.getMode().getCode(); - this.team1 = new GameTeamAdminDto(game.getT1IntraId(), game.getT1TeamId(), game.getT1Score(), game.getT1IsWin()); - this.team2 = new GameTeamAdminDto(game.getT2IntraId(), game.getT2TeamId(), game.getT2Score(), game.getT2IsWin()); - this.status = game.getStatus(); - } + public GameLogAdminDto(GameTeamUser game) { + this.gameId = game.getGameId(); + this.startAt = game.getStartTime(); + this.slotTime = game.getEndTime() == null ? null : + String.valueOf( + Duration.between(game.getStartTime().toLocalTime(), game.getEndTime().toLocalTime()).toMinutes()); + this.mode = game.getMode().getCode(); + this.team1 = new GameTeamAdminDto(game.getT1IntraId(), game.getT1TeamId(), game.getT1Score(), + game.getT1IsWin()); + this.team2 = new GameTeamAdminDto(game.getT2IntraId(), game.getT2TeamId(), game.getT2Score(), + game.getT2IsWin()); + this.status = game.getStatus(); + } } diff --git a/src/main/java/com/gg/server/admin/game/dto/GameLogListAdminResponseDto.java b/src/main/java/com/gg/server/admin/game/dto/GameLogListAdminResponseDto.java index ce3629ff6..be826c2d7 100644 --- a/src/main/java/com/gg/server/admin/game/dto/GameLogListAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/game/dto/GameLogListAdminResponseDto.java @@ -1,16 +1,16 @@ package com.gg.server.admin.game.dto; +import java.util.List; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @AllArgsConstructor @NoArgsConstructor @Getter public class GameLogListAdminResponseDto { - private List gameLogList; - private int totalPage; + private List gameLogList; + private int totalPage; } diff --git a/src/main/java/com/gg/server/admin/game/dto/GameTeamAdminDto.java b/src/main/java/com/gg/server/admin/game/dto/GameTeamAdminDto.java index 8a2376c1b..dbfa836cf 100644 --- a/src/main/java/com/gg/server/admin/game/dto/GameTeamAdminDto.java +++ b/src/main/java/com/gg/server/admin/game/dto/GameTeamAdminDto.java @@ -1,6 +1,7 @@ package com.gg.server.admin.game.dto; import com.fasterxml.jackson.annotation.JsonInclude; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -9,18 +10,18 @@ @AllArgsConstructor @NoArgsConstructor public class GameTeamAdminDto { - private String intraId1; - @JsonInclude(JsonInclude.Include.NON_NULL) - private String intraId2; //복식일 경우에만 있음 - private Long teamId; - private Integer score; - @JsonInclude(JsonInclude.Include.NON_NULL) - private Boolean win; + private String intraId1; + @JsonInclude(JsonInclude.Include.NON_NULL) + private String intraId2; //복식일 경우에만 있음 + private Long teamId; + private Integer score; + @JsonInclude(JsonInclude.Include.NON_NULL) + private Boolean win; - public GameTeamAdminDto(String intraId, Long teamId, Integer score, Boolean win) { - this.intraId1 = intraId; - this.teamId = teamId; - this.score = score; - this.win = win; - } + public GameTeamAdminDto(String intraId, Long teamId, Integer score, Boolean win) { + this.intraId1 = intraId; + this.teamId = teamId; + this.score = score; + this.win = win; + } } diff --git a/src/main/java/com/gg/server/admin/game/dto/GameUserLogAdminReqDto.java b/src/main/java/com/gg/server/admin/game/dto/GameUserLogAdminReqDto.java index d040c00f9..45d2530e4 100644 --- a/src/main/java/com/gg/server/admin/game/dto/GameUserLogAdminReqDto.java +++ b/src/main/java/com/gg/server/admin/game/dto/GameUserLogAdminReqDto.java @@ -1,17 +1,18 @@ package com.gg.server.admin.game.dto; +import javax.validation.constraints.NotNull; + import com.gg.server.global.dto.PageRequestDto; -import lombok.Getter; -import javax.validation.constraints.NotNull; +import lombok.Getter; @Getter public class GameUserLogAdminReqDto extends PageRequestDto { - @NotNull(message = "plz, intraId") - private String intraId; + @NotNull(message = "plz, intraId") + private String intraId; - public GameUserLogAdminReqDto(String intraId, Integer page, Integer size){ - super(page,size); - this.intraId = intraId; - } + public GameUserLogAdminReqDto(String intraId, Integer page, Integer size) { + super(page, size); + this.intraId = intraId; + } } diff --git a/src/main/java/com/gg/server/admin/game/dto/RankGamePPPModifyReqDto.java b/src/main/java/com/gg/server/admin/game/dto/RankGamePPPModifyReqDto.java index 26d607217..688c31dbe 100644 --- a/src/main/java/com/gg/server/admin/game/dto/RankGamePPPModifyReqDto.java +++ b/src/main/java/com/gg/server/admin/game/dto/RankGamePPPModifyReqDto.java @@ -1,31 +1,31 @@ package com.gg.server.admin.game.dto; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; - import javax.validation.constraints.Max; import javax.validation.constraints.NotNull; import javax.validation.constraints.Positive; import javax.validation.constraints.PositiveOrZero; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; import lombok.NoArgsConstructor; @Getter @AllArgsConstructor -@NoArgsConstructor(access = AccessLevel.PROTECTED) +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class RankGamePPPModifyReqDto { - @NotNull(message = "Team1Id 는 필수 값입니다.") - @Positive - private Long team1Id; - @NotNull(message = "Team1Score 는 필수 값입니다.") - @PositiveOrZero - @Max(2) - private int team1Score; - @NotNull(message = "Team2Id 는 필수 값입니다.") - @Positive - private Long team2Id; - @NotNull(message = "Team2Score 는 필수 값입니다.") - @PositiveOrZero - @Max(2) - private int team2Score; + @NotNull(message = "Team1Id 는 필수 값입니다.") + @Positive + private Long team1Id; + @NotNull(message = "Team1Score 는 필수 값입니다.") + @PositiveOrZero + @Max(2) + private int team1Score; + @NotNull(message = "Team2Id 는 필수 값입니다.") + @Positive + private Long team2Id; + @NotNull(message = "Team2Score 는 필수 값입니다.") + @PositiveOrZero + @Max(2) + private int team2Score; } diff --git a/src/main/java/com/gg/server/admin/game/exception/NotRecentlyGameException.java b/src/main/java/com/gg/server/admin/game/exception/NotRecentlyGameException.java index 2e8663ae5..f9028b6fd 100644 --- a/src/main/java/com/gg/server/admin/game/exception/NotRecentlyGameException.java +++ b/src/main/java/com/gg/server/admin/game/exception/NotRecentlyGameException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.InvalidParameterException; public class NotRecentlyGameException extends InvalidParameterException { - public NotRecentlyGameException() { - super(ErrorCode.GAME_NOT_RECENTLY.getMessage(), ErrorCode.GAME_NOT_RECENTLY); - } + public NotRecentlyGameException() { + super(ErrorCode.GAME_NOT_RECENTLY.getMessage(), ErrorCode.GAME_NOT_RECENTLY); + } } diff --git a/src/main/java/com/gg/server/admin/game/service/GameAdminService.java b/src/main/java/com/gg/server/admin/game/service/GameAdminService.java index 58bb62a86..edccc8fba 100644 --- a/src/main/java/com/gg/server/admin/game/service/GameAdminService.java +++ b/src/main/java/com/gg/server/admin/game/service/GameAdminService.java @@ -1,209 +1,224 @@ -package com.gg.server.admin.game.service; - -import com.gg.server.admin.game.dto.GameLogAdminDto; -import com.gg.server.admin.game.dto.GameLogListAdminResponseDto; -import com.gg.server.admin.game.data.GameAdminRepository; -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; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.game.exception.GameNotExistException; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.match.data.RedisMatchUserRepository; -import com.gg.server.domain.pchange.data.PChange; -import com.gg.server.domain.pchange.data.PChangeRepository; - -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.rank.redis.RankRedisService; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.dto.CurSeason; -import com.gg.server.domain.season.exception.SeasonNotFoundException; -import com.gg.server.domain.season.service.SeasonService; -import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.tier.service.TierService; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.exception.UserNotFoundException; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Caching; -import org.springframework.data.domain.*; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -import javax.persistence.EntityManager; - -@Service -@RequiredArgsConstructor -@Slf4j -public class GameAdminService { - - private final GameAdminRepository gameAdminRepository; - private final SeasonAdminRepository seasonAdminRepository; - private final UserAdminRepository userAdminRepository; - private final PChangeRepository pChangeRepository; - private final PChangeAdminRepository pChangeAdminRepository; - private final RankRedisService rankRedisService; - private final TeamUserAdminRepository teamUserAdminRepository; - private final RedisMatchUserRepository redisMatchUserRepository; - private final TierService tierService; - private final SeasonService seasonService; - private final EntityManager entityManager; - - /** - *

토너먼트 게임을 제외한 일반, 랭크 게임들을 찾아서 반환해준다.

- * @param pageable - * @return - */ - @Transactional(readOnly = true) - public GameLogListAdminResponseDto findAllGamesByAdmin(Pageable pageable) { - Page gamePage = gameAdminRepository.findAllByModeIn(pageable, List.of(Mode.NORMAL, Mode.RANK)); - return new GameLogListAdminResponseDto(getGameLogList(gamePage.getContent().stream().map(Game::getId).collect(Collectors.toList())), gamePage.getTotalPages()); - } - - /** - *

토너먼트 게임을 제외한 해당 시즌의 일반, 랭크 게임들을 찾아서 반환해준다.

- * @param pageable - * @return - */ - @Transactional(readOnly = true) - public GameLogListAdminResponseDto findGamesBySeasonId(Long seasonId, Pageable pageable){ - Season season = seasonAdminRepository.findById(seasonId).orElseThrow(SeasonNotFoundException::new); - Page games = gameAdminRepository.findBySeasonAndModeIn(pageable, season, List.of(Mode.NORMAL, Mode.RANK)); - return new GameLogListAdminResponseDto(getGameLogList(games.getContent().stream().map(Game::getId).collect(Collectors.toList())), games.getTotalPages()); - } - - @Transactional(readOnly = true) - public List getGameLogList(List gameIdList){ - List teamViews = gameAdminRepository.findTeamsByGameIsIn(gameIdList); - return teamViews.stream().map(GameLogAdminDto::new).collect(Collectors.toList()); - } - - /** - * 특정 유저의 게임 목록 조회 (토너먼트 게임 제외) - * @param intraId 조회할 유저의 intraId - * @param pageable page size - * @return GameLogListAdminResponseDto - * @throws UserNotFoundException intraId에 해당하는 유저가 없을 경우 - */ - @Transactional(readOnly = true) - public GameLogListAdminResponseDto findGamesByIntraId(String intraId, Pageable pageable){ - User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); - List pChangeList = pChangeRepository.findAllByUserIdGameModeIn(user.getId(), List.of(Mode.NORMAL, Mode.RANK)); - List gameList = new ArrayList<>(); - - for(PChange pChange : pChangeList) - gameList.add(pChange.getGame()); - - int start = (int)pageable.getOffset(); - int end = Math.min((start + pageable.getPageSize()), gameList.size()); - Page games = new PageImpl<>(gameList.subList(start, end), pageable, gameList.size()); - return new GameLogListAdminResponseDto(getGameLogList(games.getContent().stream().map(Game::getId).collect(Collectors.toList())), games.getTotalPages()); - } - - /** - * 랭킹 점수 수정 - * @param reqDto team1Id team1Score team2Id team2Score - * @param gameId 수정할 게임 id - * @throws GameNotExistException gameId에 해당하는 게임이 없을 경우 - * @throws SeasonNotFoundException 게임에 해당하는 시즌이 없을 경우 - * @throws NotRecentlyGameException 게임이 두명 다 가장 마지막 게임이 아닐 경우 - */ - @Transactional - @Caching(evict = { - @CacheEvict(value = "rankGameListByIntra", allEntries = true), - @CacheEvict(value = "rankGameList", allEntries = true), - @CacheEvict(value = "allGameList", allEntries = true), - @CacheEvict(value = "allGameListByUser", allEntries = true), - @CacheEvict(value = "ranking", allEntries = true) - }) - public void rankResultEdit(RankGamePPPModifyReqDto reqDto, Long gameId) { - // 게임이 두명 다 가장 마지막 게임인지 확인 (그 game에 해당하는 팀이 맞는지 확인) - List teamUsers = teamUserAdminRepository.findUsersByTeamIdIn(List.of(reqDto.getTeam1Id(), reqDto.getTeam2Id())); - Game game = gameAdminRepository.findGameWithSeasonByGameId(gameId) - .orElseThrow(GameNotExistException::new); - CurSeason curSeason = seasonService.getCurSeason(); - if (!isRecentlyGame(teamUsers, gameId) || EnrollSlots(teamUsers) || !game.getSeason().getId().equals(curSeason.getId())) { - throw new NotRecentlyGameException(); - } - // pchange 가져와서 rank ppp 이전 값을 가지고 새 점수를 바탕으로 다시 계산 - // user 1 - List pChanges = pChangeAdminRepository.findByTeamUser(teamUsers.get(0).getUser().getId()); - if (!pChanges.get(0).getGame().getId().equals(gameId)) { - throw new PChangeNotExistException(); - } - RankRedis rankRedis1 = rollbackGameResult(game.getSeason(), teamUsers.get(0), pChanges); - pChangeAdminRepository.deleteById(pChanges.get(0).getId()); - // user 2 - pChanges = pChangeAdminRepository.findByTeamUser(teamUsers.get(1).getUser().getId()); - if (!pChanges.get(0).getGame().getId().equals(gameId)) { - throw new PChangeNotExistException(); - } - RankRedis rankRedis2 = rollbackGameResult(game.getSeason(), teamUsers.get(1), pChanges); - pChangeAdminRepository.deleteById(pChanges.get(0).getId()); - entityManager.flush(); - for (int i = 0; i < teamUsers.size(); i++) { - updateScore(reqDto, teamUsers.get(i)); - } - teamUserAdminRepository.flush(); - rankRedisService.updateAdminRankData(teamUsers.get(0), teamUsers.get(1), game, rankRedis1, rankRedis2); - tierService.updateAllTier(game.getSeason()); - } - - private RankRedis rollbackGameResult(Season season, TeamUser teamUser, List pChanges) { - // pchange ppp도 update - // rankredis 에 ppp 다시 반영 - // rank zset 도 update - // 이전 ppp, exp 되돌리기 - // rank data 에 있는 ppp 되돌리기 - RankRedis rankRedis; - if (pChanges.size() == 1) { - rankRedis = rankRedisService.rollbackRank(teamUser, season.getStartPpp(), season.getId()); - teamUser.getUser().updateExp(0); - } else { - rankRedis = rankRedisService.rollbackRank(teamUser, pChanges.get(1).getPppResult(), season.getId()); - teamUser.getUser().updateExp(pChanges.get(1).getExp()); - } - return rankRedis; - } - - private void updateScore(RankGamePPPModifyReqDto reqDto, TeamUser teamUser) { - if (teamUser.getTeam().getId().equals(reqDto.getTeam1Id())) { - teamUser.getTeam().updateScore(reqDto.getTeam1Score(), reqDto.getTeam1Score() > reqDto.getTeam2Score()); - } else if (teamUser.getTeam().getId().equals(reqDto.getTeam2Id())) { - teamUser.getTeam().updateScore(reqDto.getTeam2Score(), reqDto.getTeam2Score() > reqDto.getTeam1Score()); - } - } - - private Boolean isRecentlyGame(List teamUsers, Long gameId) { - for (TeamUser teamUser : teamUsers) { - List pChanges = pChangeAdminRepository.findByTeamUser(teamUser.getUser().getId()); - if (!pChanges.get(0).getGame().getId().equals(gameId)) - return false; - } - return true; - } - - private Boolean EnrollSlots(List teamUsers) { - for (TeamUser teamUser : teamUsers) { - Long userId = teamUser.getUser().getId(); - if (redisMatchUserRepository.countMatchTime(userId) > 0) { - return true; - } - if (gameAdminRepository.findByStatusTypeAndUserId(StatusType.BEFORE, userId).isPresent()) { - return true; - } - } - return false; - } -} \ No newline at end of file +package com.gg.server.admin.game.service; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import javax.persistence.EntityManager; + +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Caching; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.admin.game.data.GameAdminRepository; +import com.gg.server.admin.game.dto.GameLogAdminDto; +import com.gg.server.admin.game.dto.GameLogListAdminResponseDto; +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; +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.dto.GameTeamUser; +import com.gg.server.domain.game.exception.GameNotExistException; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.match.data.RedisMatchUserRepository; +import com.gg.server.domain.pchange.data.PChange; +import com.gg.server.domain.pchange.data.PChangeRepository; +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.rank.redis.RankRedisService; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.dto.CurSeason; +import com.gg.server.domain.season.exception.SeasonNotFoundException; +import com.gg.server.domain.season.service.SeasonService; +import com.gg.server.domain.team.data.TeamUser; +import com.gg.server.domain.tier.service.TierService; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.exception.UserNotFoundException; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +@Service +@RequiredArgsConstructor +@Slf4j +public class GameAdminService { + + private final GameAdminRepository gameAdminRepository; + private final SeasonAdminRepository seasonAdminRepository; + private final UserAdminRepository userAdminRepository; + private final PChangeRepository pChangeRepository; + private final PChangeAdminRepository pChangeAdminRepository; + private final RankRedisService rankRedisService; + private final TeamUserAdminRepository teamUserAdminRepository; + private final RedisMatchUserRepository redisMatchUserRepository; + private final TierService tierService; + private final SeasonService seasonService; + private final EntityManager entityManager; + + /** + *

토너먼트 게임을 제외한 일반, 랭크 게임들을 찾아서 반환해준다.

+ * @param pageable + * @return + */ + @Transactional(readOnly = true) + public GameLogListAdminResponseDto findAllGamesByAdmin(Pageable pageable) { + Page gamePage = gameAdminRepository.findAllByModeIn(pageable, List.of(Mode.NORMAL, Mode.RANK)); + return new GameLogListAdminResponseDto( + getGameLogList(gamePage.getContent().stream().map(Game::getId).collect(Collectors.toList())), + gamePage.getTotalPages()); + } + + /** + *

토너먼트 게임을 제외한 해당 시즌의 일반, 랭크 게임들을 찾아서 반환해준다.

+ * @param pageable + * @return + */ + @Transactional(readOnly = true) + public GameLogListAdminResponseDto findGamesBySeasonId(Long seasonId, Pageable pageable) { + Season season = seasonAdminRepository.findById(seasonId).orElseThrow(SeasonNotFoundException::new); + Page games = gameAdminRepository.findBySeasonAndModeIn(pageable, season, List.of(Mode.NORMAL, Mode.RANK)); + return new GameLogListAdminResponseDto( + getGameLogList(games.getContent().stream().map(Game::getId).collect(Collectors.toList())), + games.getTotalPages()); + } + + @Transactional(readOnly = true) + public List getGameLogList(List gameIdList) { + List teamViews = gameAdminRepository.findTeamsByGameIsIn(gameIdList); + return teamViews.stream().map(GameLogAdminDto::new).collect(Collectors.toList()); + } + + /** + * 특정 유저의 게임 목록 조회 (토너먼트 게임 제외) + * @param intraId 조회할 유저의 intraId + * @param pageable page size + * @return GameLogListAdminResponseDto + * @throws UserNotFoundException intraId에 해당하는 유저가 없을 경우 + */ + @Transactional(readOnly = true) + public GameLogListAdminResponseDto findGamesByIntraId(String intraId, Pageable pageable) { + User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); + List pChangeList = pChangeRepository.findAllByUserIdGameModeIn(user.getId(), + List.of(Mode.NORMAL, Mode.RANK)); + List gameList = new ArrayList<>(); + + for (PChange pChange : pChangeList) { + gameList.add(pChange.getGame()); + } + + int start = (int)pageable.getOffset(); + int end = Math.min((start + pageable.getPageSize()), gameList.size()); + Page games = new PageImpl<>(gameList.subList(start, end), pageable, gameList.size()); + return new GameLogListAdminResponseDto( + getGameLogList(games.getContent().stream().map(Game::getId).collect(Collectors.toList())), + games.getTotalPages()); + } + + /** + * 랭킹 점수 수정 + * @param reqDto team1Id team1Score team2Id team2Score + * @param gameId 수정할 게임 id + * @throws GameNotExistException gameId에 해당하는 게임이 없을 경우 + * @throws SeasonNotFoundException 게임에 해당하는 시즌이 없을 경우 + * @throws NotRecentlyGameException 게임이 두명 다 가장 마지막 게임이 아닐 경우 + */ + @Transactional + @Caching(evict = { + @CacheEvict(value = "rankGameListByIntra", allEntries = true), + @CacheEvict(value = "rankGameList", allEntries = true), + @CacheEvict(value = "allGameList", allEntries = true), + @CacheEvict(value = "allGameListByUser", allEntries = true), + @CacheEvict(value = "ranking", allEntries = true) + }) + public void rankResultEdit(RankGamePPPModifyReqDto reqDto, Long gameId) { + // 게임이 두명 다 가장 마지막 게임인지 확인 (그 game에 해당하는 팀이 맞는지 확인) + List teamUsers = teamUserAdminRepository.findUsersByTeamIdIn( + List.of(reqDto.getTeam1Id(), reqDto.getTeam2Id())); + Game game = gameAdminRepository.findGameWithSeasonByGameId(gameId) + .orElseThrow(GameNotExistException::new); + CurSeason curSeason = seasonService.getCurSeason(); + if (!isRecentlyGame(teamUsers, gameId) || enrollSlots(teamUsers) || !game.getSeason() + .getId() + .equals(curSeason.getId())) { + throw new NotRecentlyGameException(); + } + // pchange 가져와서 rank ppp 이전 값을 가지고 새 점수를 바탕으로 다시 계산 + // user 1 + List pChanges = pChangeAdminRepository.findByTeamUser(teamUsers.get(0).getUser().getId()); + if (!pChanges.get(0).getGame().getId().equals(gameId)) { + throw new PChangeNotExistException(); + } + RankRedis rankRedis1 = rollbackGameResult(game.getSeason(), teamUsers.get(0), pChanges); + pChangeAdminRepository.deleteById(pChanges.get(0).getId()); + // user 2 + pChanges = pChangeAdminRepository.findByTeamUser(teamUsers.get(1).getUser().getId()); + if (!pChanges.get(0).getGame().getId().equals(gameId)) { + throw new PChangeNotExistException(); + } + RankRedis rankRedis2 = rollbackGameResult(game.getSeason(), teamUsers.get(1), pChanges); + pChangeAdminRepository.deleteById(pChanges.get(0).getId()); + entityManager.flush(); + for (int i = 0; i < teamUsers.size(); i++) { + updateScore(reqDto, teamUsers.get(i)); + } + teamUserAdminRepository.flush(); + rankRedisService.updateAdminRankData(teamUsers.get(0), teamUsers.get(1), game, rankRedis1, rankRedis2); + tierService.updateAllTier(game.getSeason()); + } + + private RankRedis rollbackGameResult(Season season, TeamUser teamUser, List pChanges) { + // pchange ppp도 update + // rankredis 에 ppp 다시 반영 + // rank zset 도 update + // 이전 ppp, exp 되돌리기 + // rank data 에 있는 ppp 되돌리기 + RankRedis rankRedis; + if (pChanges.size() == 1) { + rankRedis = rankRedisService.rollbackRank(teamUser, season.getStartPpp(), season.getId()); + teamUser.getUser().updateExp(0); + } else { + rankRedis = rankRedisService.rollbackRank(teamUser, pChanges.get(1).getPppResult(), season.getId()); + teamUser.getUser().updateExp(pChanges.get(1).getExp()); + } + return rankRedis; + } + + private void updateScore(RankGamePPPModifyReqDto reqDto, TeamUser teamUser) { + if (teamUser.getTeam().getId().equals(reqDto.getTeam1Id())) { + teamUser.getTeam().updateScore(reqDto.getTeam1Score(), reqDto.getTeam1Score() > reqDto.getTeam2Score()); + } else if (teamUser.getTeam().getId().equals(reqDto.getTeam2Id())) { + teamUser.getTeam().updateScore(reqDto.getTeam2Score(), reqDto.getTeam2Score() > reqDto.getTeam1Score()); + } + } + + private Boolean isRecentlyGame(List teamUsers, Long gameId) { + for (TeamUser teamUser : teamUsers) { + List pChanges = pChangeAdminRepository.findByTeamUser(teamUser.getUser().getId()); + if (!pChanges.get(0).getGame().getId().equals(gameId)) { + return false; + } + } + return true; + } + + private Boolean enrollSlots(List teamUsers) { + for (TeamUser teamUser : teamUsers) { + Long userId = teamUser.getUser().getId(); + if (redisMatchUserRepository.countMatchTime(userId) > 0) { + return true; + } + if (gameAdminRepository.findByStatusTypeAndUserId(StatusType.BEFORE, userId).isPresent()) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/com/gg/server/admin/item/controller/ItemAdminController.java b/src/main/java/com/gg/server/admin/item/controller/ItemAdminController.java index ab76b429e..f2c769822 100644 --- a/src/main/java/com/gg/server/admin/item/controller/ItemAdminController.java +++ b/src/main/java/com/gg/server/admin/item/controller/ItemAdminController.java @@ -1,5 +1,25 @@ package com.gg.server.admin.item.controller; +import java.io.IOException; + +import javax.validation.Valid; + +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + import com.gg.server.admin.item.dto.ItemListResponseDto; import com.gg.server.admin.item.dto.ItemUpdateRequestDto; import com.gg.server.admin.item.service.ItemAdminService; @@ -8,54 +28,45 @@ import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.dto.PageRequestDto; import com.gg.server.global.utils.argumentresolver.Login; + import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import javax.validation.Valid; -import java.io.IOException; @RestController @RequiredArgsConstructor @RequestMapping("/pingpong/admin/items") public class ItemAdminController { - private final ItemAdminService itemAdminService; - - @GetMapping("/history") - public ItemListResponseDto getItemHistory(@ModelAttribute @Valid PageRequestDto pageRequestDto) { - Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, pageRequestDto.getSize(), - Sort.by("createdAt").descending()); - return itemAdminService.getAllItemHistory(pageable); - } - - @PostMapping(path="/{itemId}", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) - public ResponseEntity updateItem(@PathVariable("itemId") Long itemId, - @RequestPart @Valid ItemUpdateRequestDto updateItemInfo, - @RequestPart(required = false) MultipartFile imgData, - @Parameter(hidden = true) @Login UserDto user) throws IOException { - if (imgData != null) { - if (imgData.getSize() > 50000) { - throw new ItemImageLargeException(); - } else if (imgData.getContentType() == null || !imgData.getContentType().equals("image/jpeg")) { - throw new ItemImageTypeException(); - } - itemAdminService.updateItem(itemId, updateItemInfo, imgData, user); - } else { - itemAdminService.updateItem(itemId, updateItemInfo, user); - } - return new ResponseEntity(HttpStatus.NO_CONTENT); - } - - @DeleteMapping("/{itemId}") - public ResponseEntity deleteItem(@PathVariable("itemId") Long itemId, @Parameter(hidden = true) @Login UserDto user) { - itemAdminService.deleteItem(itemId, user); - return new ResponseEntity(HttpStatus.NO_CONTENT); - } + private final ItemAdminService itemAdminService; + + @GetMapping("/history") + public ItemListResponseDto getItemHistory(@ModelAttribute @Valid PageRequestDto pageRequestDto) { + Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, pageRequestDto.getSize(), + Sort.by("createdAt").descending()); + return itemAdminService.getAllItemHistory(pageable); + } + + @PostMapping(path = "/{itemId}", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE}) + public ResponseEntity updateItem(@PathVariable("itemId") Long itemId, + @RequestPart @Valid ItemUpdateRequestDto updateItemInfo, + @RequestPart(required = false) MultipartFile imgData, + @Parameter(hidden = true) @Login UserDto user) throws IOException { + if (imgData != null) { + if (imgData.getSize() > 50000) { + throw new ItemImageLargeException(); + } else if (imgData.getContentType() == null || !imgData.getContentType().equals("image/jpeg")) { + throw new ItemImageTypeException(); + } + itemAdminService.updateItem(itemId, updateItemInfo, imgData, user); + } else { + itemAdminService.updateItem(itemId, updateItemInfo, user); + } + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + @DeleteMapping("/{itemId}") + public ResponseEntity deleteItem(@PathVariable("itemId") Long itemId, + @Parameter(hidden = true) @Login UserDto user) { + itemAdminService.deleteItem(itemId, user); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } } diff --git a/src/main/java/com/gg/server/admin/item/data/ItemAdminRepository.java b/src/main/java/com/gg/server/admin/item/data/ItemAdminRepository.java index 7525bc053..dc289869f 100644 --- a/src/main/java/com/gg/server/admin/item/data/ItemAdminRepository.java +++ b/src/main/java/com/gg/server/admin/item/data/ItemAdminRepository.java @@ -1,10 +1,11 @@ package com.gg.server.admin.item.data; -import com.gg.server.domain.item.data.Item; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; +import com.gg.server.domain.item.data.Item; + public interface ItemAdminRepository extends JpaRepository { - Page findAll(Pageable pageable); + Page findAll(Pageable pageable); } diff --git a/src/main/java/com/gg/server/admin/item/dto/ItemHistoryResponseDto.java b/src/main/java/com/gg/server/admin/item/dto/ItemHistoryResponseDto.java index 5e8acf572..07a6f7a3e 100644 --- a/src/main/java/com/gg/server/admin/item/dto/ItemHistoryResponseDto.java +++ b/src/main/java/com/gg/server/admin/item/dto/ItemHistoryResponseDto.java @@ -1,56 +1,57 @@ package com.gg.server.admin.item.dto; +import java.time.LocalDateTime; + import com.gg.server.domain.item.data.Item; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; - @Getter @NoArgsConstructor @AllArgsConstructor public class ItemHistoryResponseDto { - private Long itemId; - private String name; - private String mainContent; - private String subContent; - private String imageUri; - private Integer price; - private Integer discount; - private boolean isVisible; - private LocalDateTime createdAt; - private String creatorIntraId; - private String deleterIntraId; + private Long itemId; + private String name; + private String mainContent; + private String subContent; + private String imageUri; + private Integer price; + private Integer discount; + private boolean isVisible; + private LocalDateTime createdAt; + private String creatorIntraId; + private String deleterIntraId; - public ItemHistoryResponseDto(Item item) { - this.itemId = item.getId(); - this.name = item.getName(); - this.mainContent = item.getMainContent(); - this.subContent = item.getSubContent(); - this.imageUri = item.getImageUri(); - this.price = item.getPrice(); - this.discount = item.getDiscount(); - this.isVisible = item.getIsVisible(); - this.createdAt = item.getCreatedAt(); - this.creatorIntraId = item.getCreatorIntraId(); - this.deleterIntraId = item.getDeleterIntraId(); - } + public ItemHistoryResponseDto(Item item) { + this.itemId = item.getId(); + this.name = item.getName(); + this.mainContent = item.getMainContent(); + this.subContent = item.getSubContent(); + this.imageUri = item.getImageUri(); + this.price = item.getPrice(); + this.discount = item.getDiscount(); + this.isVisible = item.getIsVisible(); + this.createdAt = item.getCreatedAt(); + this.creatorIntraId = item.getCreatorIntraId(); + this.deleterIntraId = item.getDeleterIntraId(); + } - @Override - public String toString() { - return "ItemHistoryResponseDto{" + - "itemId=" + itemId + - ", name='" + name + '\'' + - ", mainContent='" + mainContent + '\'' + - ", subContent='" + subContent + '\'' + - ", imageUri='" + imageUri + '\'' + - ", price=" + price + - ", discount=" + discount + - ", isVisible=" + isVisible + - ", createdAt=" + createdAt + - ", creatorIntraId='" + creatorIntraId + '\'' + - ", deleterIntraId='" + deleterIntraId + '\'' + - '}'; - } + @Override + public String toString() { + return "ItemHistoryResponseDto{" + + "itemId=" + itemId + + ", name='" + name + '\'' + + ", mainContent='" + mainContent + '\'' + + ", subContent='" + subContent + '\'' + + ", imageUri='" + imageUri + '\'' + + ", price=" + price + + ", discount=" + discount + + ", isVisible=" + isVisible + + ", createdAt=" + createdAt + + ", creatorIntraId='" + creatorIntraId + '\'' + + ", deleterIntraId='" + deleterIntraId + '\'' + + '}'; + } } diff --git a/src/main/java/com/gg/server/admin/item/dto/ItemListResponseDto.java b/src/main/java/com/gg/server/admin/item/dto/ItemListResponseDto.java index c56e7f1a1..b7f8dc8f2 100644 --- a/src/main/java/com/gg/server/admin/item/dto/ItemListResponseDto.java +++ b/src/main/java/com/gg/server/admin/item/dto/ItemListResponseDto.java @@ -1,15 +1,15 @@ package com.gg.server.admin.item.dto; +import java.util.List; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @Getter @NoArgsConstructor @AllArgsConstructor public class ItemListResponseDto { - private List historyList; - private Integer totalPage; + private List historyList; + private Integer totalPage; } diff --git a/src/main/java/com/gg/server/admin/item/dto/ItemUpdateRequestDto.java b/src/main/java/com/gg/server/admin/item/dto/ItemUpdateRequestDto.java index 4c454ebe7..f51616d53 100644 --- a/src/main/java/com/gg/server/admin/item/dto/ItemUpdateRequestDto.java +++ b/src/main/java/com/gg/server/admin/item/dto/ItemUpdateRequestDto.java @@ -1,43 +1,44 @@ package com.gg.server.admin.item.dto; +import javax.validation.constraints.NotNull; + import com.gg.server.domain.item.type.ItemType; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotNull; - @Getter @NoArgsConstructor @AllArgsConstructor public class ItemUpdateRequestDto { - @NotNull(message = "[Request] 아이템 이름은 Null 일 수 없습니다.") - private String name; - - @NotNull(message = "[Request] 주 설명은 Null 일 수 없습니다.") - private String mainContent; - - @NotNull(message = "[Request] 부 설명은 Null 일 수 없습니다.") - private String subContent; - - @NotNull(message = "[Request] 가격은 Null 일 수 없습니다.") - private Integer price; - - @NotNull(message = "[Request] 할인율은 Null 일 수 없습니다.") - private Integer discount; - - @NotNull(message = "[Request] 아이템 타입은 Null 일 수 없습니다.") - private ItemType itemType; - - @Override - public String toString() { - return "ItemUpdateRequestDto{" + - "name='" + name + '\'' + - ", mainContent='" + mainContent + '\'' + - ", subContent='" + subContent + '\'' + - ", price=" + price + - ", discount=" + discount + - ", itemType='" + itemType + '\'' + - '}'; - } + @NotNull(message = "[Request] 아이템 이름은 Null 일 수 없습니다.") + private String name; + + @NotNull(message = "[Request] 주 설명은 Null 일 수 없습니다.") + private String mainContent; + + @NotNull(message = "[Request] 부 설명은 Null 일 수 없습니다.") + private String subContent; + + @NotNull(message = "[Request] 가격은 Null 일 수 없습니다.") + private Integer price; + + @NotNull(message = "[Request] 할인율은 Null 일 수 없습니다.") + private Integer discount; + + @NotNull(message = "[Request] 아이템 타입은 Null 일 수 없습니다.") + private ItemType itemType; + + @Override + public String toString() { + return "ItemUpdateRequestDto{" + + "name='" + name + '\'' + + ", mainContent='" + mainContent + '\'' + + ", subContent='" + subContent + '\'' + + ", price=" + price + + ", discount=" + discount + + ", itemType='" + itemType + '\'' + + '}'; + } } diff --git a/src/main/java/com/gg/server/admin/item/exception/ItemNotFoundException.java b/src/main/java/com/gg/server/admin/item/exception/ItemNotFoundException.java index 1334c1909..a18f68019 100644 --- a/src/main/java/com/gg/server/admin/item/exception/ItemNotFoundException.java +++ b/src/main/java/com/gg/server/admin/item/exception/ItemNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class ItemNotFoundException extends NotExistException { - public ItemNotFoundException() { - super("아이템이 없습니다.", ErrorCode.ITEM_NOT_FOUND); - } + public ItemNotFoundException() { + super("아이템이 없습니다.", ErrorCode.ITEM_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/admin/item/service/ItemAdminService.java b/src/main/java/com/gg/server/admin/item/service/ItemAdminService.java index 7fb4a6f49..5c4267656 100644 --- a/src/main/java/com/gg/server/admin/item/service/ItemAdminService.java +++ b/src/main/java/com/gg/server/admin/item/service/ItemAdminService.java @@ -1,5 +1,13 @@ package com.gg.server.admin.item.service; +import java.io.IOException; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + import com.gg.server.admin.item.data.ItemAdminRepository; import com.gg.server.admin.item.dto.ItemHistoryResponseDto; import com.gg.server.admin.item.dto.ItemListResponseDto; @@ -9,60 +17,55 @@ import com.gg.server.domain.item.exception.ItemNotAvailableException; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.utils.aws.AsyncNewItemImageUploader; -import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; +import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class ItemAdminService { - private final ItemAdminRepository itemAdminRepository; - private final AsyncNewItemImageUploader asyncNewItemImageUploader; + private final ItemAdminRepository itemAdminRepository; + private final AsyncNewItemImageUploader asyncNewItemImageUploader; - @Transactional(readOnly = true) - public ItemListResponseDto getAllItemHistory(Pageable pageable) { - Page responseDtos = itemAdminRepository.findAll(pageable).map(ItemHistoryResponseDto::new); - return new ItemListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); - } + @Transactional(readOnly = true) + public ItemListResponseDto getAllItemHistory(Pageable pageable) { + Page responseDtos = itemAdminRepository.findAll(pageable) + .map(ItemHistoryResponseDto::new); + return new ItemListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); + } - // 아이템 수정 시 신규 이미지가 존재하는 경우 - @Transactional - public void updateItem(Long itemId, ItemUpdateRequestDto itemUpdateRequestDto, - MultipartFile itemImageFile, UserDto user) throws IOException { - Item item = itemAdminRepository.findById(itemId).orElseThrow(ItemNotFoundException::new); - if (!item.getIsVisible()) { - throw new ItemNotAvailableException(); - } - item.setVisibility(user.getIntraId()); - Item newItem = new Item(itemUpdateRequestDto, user.getIntraId(), null); - if (itemImageFile != null) - asyncNewItemImageUploader.upload(newItem, itemImageFile); - itemAdminRepository.save(newItem); - } + // 아이템 수정 시 신규 이미지가 존재하는 경우 + @Transactional + public void updateItem(Long itemId, ItemUpdateRequestDto itemUpdateRequestDto, + MultipartFile itemImageFile, UserDto user) throws IOException { + Item item = itemAdminRepository.findById(itemId).orElseThrow(ItemNotFoundException::new); + if (!item.getIsVisible()) { + throw new ItemNotAvailableException(); + } + item.setVisibility(user.getIntraId()); + Item newItem = new Item(itemUpdateRequestDto, user.getIntraId(), null); + if (itemImageFile != null) { + asyncNewItemImageUploader.upload(newItem, itemImageFile); + } + itemAdminRepository.save(newItem); + } - // 아이템 수정 시 신규 이미지가 존재하지 않는 경우 - @Transactional - public void updateItem(Long itemId, ItemUpdateRequestDto itemUpdateRequestDto, - UserDto user) { - Item item = itemAdminRepository.findById(itemId).orElseThrow(ItemNotFoundException::new); - if (!item.getIsVisible()) { - throw new ItemNotAvailableException(); - } - item.setVisibility(user.getIntraId()); - Item newItem = new Item(itemUpdateRequestDto, user.getIntraId(), item.getImageUri()); - itemAdminRepository.save(newItem); - } + // 아이템 수정 시 신규 이미지가 존재하지 않는 경우 + @Transactional + public void updateItem(Long itemId, ItemUpdateRequestDto itemUpdateRequestDto, + UserDto user) { + Item item = itemAdminRepository.findById(itemId).orElseThrow(ItemNotFoundException::new); + if (!item.getIsVisible()) { + throw new ItemNotAvailableException(); + } + item.setVisibility(user.getIntraId()); + Item newItem = new Item(itemUpdateRequestDto, user.getIntraId(), item.getImageUri()); + itemAdminRepository.save(newItem); + } - @Transactional - public void deleteItem(Long itemId, UserDto user) { - Item item = itemAdminRepository.findById(itemId).orElseThrow(ItemNotFoundException::new); - item.setVisibility(user.getIntraId()); - } + @Transactional + public void deleteItem(Long itemId, UserDto user) { + Item item = itemAdminRepository.findById(itemId).orElseThrow(ItemNotFoundException::new); + item.setVisibility(user.getIntraId()); + } } diff --git a/src/main/java/com/gg/server/admin/megaphone/controller/MegaphoneAdminController.java b/src/main/java/com/gg/server/admin/megaphone/controller/MegaphoneAdminController.java index 2986447f9..e4d736895 100644 --- a/src/main/java/com/gg/server/admin/megaphone/controller/MegaphoneAdminController.java +++ b/src/main/java/com/gg/server/admin/megaphone/controller/MegaphoneAdminController.java @@ -1,30 +1,37 @@ package com.gg.server.admin.megaphone.controller; -import com.gg.server.admin.megaphone.dto.MegaphoneHistoryResponseDto; -import com.gg.server.admin.megaphone.service.MegaphoneAdminService; -import com.gg.server.global.dto.PageRequestDto; -import lombok.RequiredArgsConstructor; +import javax.validation.Valid; + import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; -import javax.validation.Valid; +import com.gg.server.admin.megaphone.dto.MegaphoneHistoryResponseDto; +import com.gg.server.admin.megaphone.service.MegaphoneAdminService; +import com.gg.server.global.dto.PageRequestDto; + +import lombok.RequiredArgsConstructor; @RestController @RequiredArgsConstructor @RequestMapping("/pingpong/admin/megaphones") public class MegaphoneAdminController { - private final MegaphoneAdminService megaphoneAdminService; + private final MegaphoneAdminService megaphoneAdminService; - @GetMapping("/history") - public MegaphoneHistoryResponseDto getMegaphoneHistory(@ModelAttribute @Valid PageRequestDto pageRequestDto, - @RequestParam(required = false) String intraId) { - Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, pageRequestDto.getSize(), - Sort.by("id").descending()); - if (intraId == null) - return megaphoneAdminService.getMegaphoneHistory(pageable); - return megaphoneAdminService.getMegaphoneHistoryByIntraId(intraId, pageable); + @GetMapping("/history") + public MegaphoneHistoryResponseDto getMegaphoneHistory(@ModelAttribute @Valid PageRequestDto pageRequestDto, + @RequestParam(required = false) String intraId) { + Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, pageRequestDto.getSize(), + Sort.by("id").descending()); + if (intraId == null) { + return megaphoneAdminService.getMegaphoneHistory(pageable); + } + return megaphoneAdminService.getMegaphoneHistoryByIntraId(intraId, pageable); - } + } } diff --git a/src/main/java/com/gg/server/admin/megaphone/data/MegaphoneAdminRepository.java b/src/main/java/com/gg/server/admin/megaphone/data/MegaphoneAdminRepository.java index 18e964254..e8b39bf54 100644 --- a/src/main/java/com/gg/server/admin/megaphone/data/MegaphoneAdminRepository.java +++ b/src/main/java/com/gg/server/admin/megaphone/data/MegaphoneAdminRepository.java @@ -1,10 +1,11 @@ package com.gg.server.admin.megaphone.data; -import com.gg.server.domain.megaphone.data.Megaphone; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; +import com.gg.server.domain.megaphone.data.Megaphone; + public interface MegaphoneAdminRepository extends JpaRepository { - Page findMegaphonesByUserIntraId(String intraId, Pageable pageable); + Page findMegaphonesByUserIntraId(String intraId, Pageable pageable); } diff --git a/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneAdminResponseDto.java b/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneAdminResponseDto.java index 9984a0351..7dba27a8c 100644 --- a/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneAdminResponseDto.java @@ -1,23 +1,24 @@ package com.gg.server.admin.megaphone.dto; import com.gg.server.domain.megaphone.data.Megaphone; + import lombok.Getter; import lombok.NoArgsConstructor; @Getter @NoArgsConstructor public class MegaphoneAdminResponseDto { - private Long megaphoneId; - private String content; - private String usedAt; - private String status; - private String intraId; + private Long megaphoneId; + private String content; + private String usedAt; + private String status; + private String intraId; - public MegaphoneAdminResponseDto(Megaphone megaphone){ - this.megaphoneId = megaphone.getId(); - this.content = megaphone.getContent(); - this.usedAt = megaphone.getUsedAt().toString(); - this.status = megaphone.getReceipt().getStatus().getDescription(); - this.intraId = megaphone.getUser().getIntraId(); - } + public MegaphoneAdminResponseDto(Megaphone megaphone) { + this.megaphoneId = megaphone.getId(); + this.content = megaphone.getContent(); + this.usedAt = megaphone.getUsedAt().toString(); + this.status = megaphone.getReceipt().getStatus().getDescription(); + this.intraId = megaphone.getUser().getIntraId(); + } } diff --git a/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneHistoryResponseDto.java b/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneHistoryResponseDto.java index 9337d047e..bb5ac60d4 100644 --- a/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneHistoryResponseDto.java +++ b/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneHistoryResponseDto.java @@ -1,18 +1,18 @@ package com.gg.server.admin.megaphone.dto; +import java.util.List; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @Getter @NoArgsConstructor public class MegaphoneHistoryResponseDto { - private List megaphoneList; - private int totalPage; + private List megaphoneList; + private int totalPage; - public MegaphoneHistoryResponseDto(List newDtos, int totalPage){ - this.megaphoneList = newDtos; - this.totalPage= totalPage; - } + public MegaphoneHistoryResponseDto(List newDtos, int totalPage) { + this.megaphoneList = newDtos; + this.totalPage = totalPage; + } } diff --git a/src/main/java/com/gg/server/admin/megaphone/service/MegaphoneAdminService.java b/src/main/java/com/gg/server/admin/megaphone/service/MegaphoneAdminService.java index b91076db5..4aed020c6 100644 --- a/src/main/java/com/gg/server/admin/megaphone/service/MegaphoneAdminService.java +++ b/src/main/java/com/gg/server/admin/megaphone/service/MegaphoneAdminService.java @@ -1,27 +1,29 @@ package com.gg.server.admin.megaphone.service; -import com.gg.server.admin.megaphone.data.MegaphoneAdminRepository; - -import com.gg.server.admin.megaphone.dto.MegaphoneAdminResponseDto; -import com.gg.server.admin.megaphone.dto.MegaphoneHistoryResponseDto; -import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import com.gg.server.admin.megaphone.data.MegaphoneAdminRepository; +import com.gg.server.admin.megaphone.dto.MegaphoneAdminResponseDto; +import com.gg.server.admin.megaphone.dto.MegaphoneHistoryResponseDto; + +import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class MegaphoneAdminService { - private final MegaphoneAdminRepository megaphoneAdminRepository; + private final MegaphoneAdminRepository megaphoneAdminRepository; - public MegaphoneHistoryResponseDto getMegaphoneHistory(Pageable pageable) { - Page megaphoneHistory = megaphoneAdminRepository.findAll(pageable).map(MegaphoneAdminResponseDto::new); - return new MegaphoneHistoryResponseDto(megaphoneHistory.getContent(), megaphoneHistory.getTotalPages()); - } + public MegaphoneHistoryResponseDto getMegaphoneHistory(Pageable pageable) { + Page megaphoneHistory = megaphoneAdminRepository.findAll(pageable) + .map(MegaphoneAdminResponseDto::new); + return new MegaphoneHistoryResponseDto(megaphoneHistory.getContent(), megaphoneHistory.getTotalPages()); + } - public MegaphoneHistoryResponseDto getMegaphoneHistoryByIntraId(String intraId, Pageable pageable) { - Page megaphoneHistory = megaphoneAdminRepository.findMegaphonesByUserIntraId(intraId, pageable).map(MegaphoneAdminResponseDto::new); - return new MegaphoneHistoryResponseDto(megaphoneHistory.getContent(), megaphoneHistory.getTotalPages()); - } + public MegaphoneHistoryResponseDto getMegaphoneHistoryByIntraId(String intraId, Pageable pageable) { + Page megaphoneHistory = megaphoneAdminRepository.findMegaphonesByUserIntraId(intraId, + pageable).map(MegaphoneAdminResponseDto::new); + return new MegaphoneHistoryResponseDto(megaphoneHistory.getContent(), megaphoneHistory.getTotalPages()); + } } diff --git a/src/main/java/com/gg/server/admin/noti/controller/NotiAdminController.java b/src/main/java/com/gg/server/admin/noti/controller/NotiAdminController.java index 5af681f7e..61672cd1d 100644 --- a/src/main/java/com/gg/server/admin/noti/controller/NotiAdminController.java +++ b/src/main/java/com/gg/server/admin/noti/controller/NotiAdminController.java @@ -1,41 +1,49 @@ package com.gg.server.admin.noti.controller; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import com.gg.server.admin.noti.dto.NotiListAdminRequestDto; import com.gg.server.admin.noti.dto.NotiListAdminResponseDto; import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; import com.gg.server.admin.noti.service.NotiAdminService; + import lombok.AllArgsConstructor; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; @RestController @AllArgsConstructor @RequestMapping(value = "/pingpong/admin/notifications") public class NotiAdminController { - private final NotiAdminService notiAdminService; - - @GetMapping - public NotiListAdminResponseDto getAllNoti(@ModelAttribute NotiListAdminRequestDto requestDto) { - int page = requestDto.getPage(); - int size = requestDto.getSize(); - String intraId = requestDto.getIntraId(); - - Pageable pageable = PageRequest.of(page - 1, size, - Sort.by("createdAt").descending().and(Sort.by("user.intraId").ascending())); - if (intraId == null) - return notiAdminService.getAllNoti(pageable); - else - return notiAdminService.getFilteredNotifications(pageable, intraId); - } - @PostMapping - public ResponseEntity sendNotiToUser(@RequestBody SendNotiAdminRequestDto sendNotiAdminRequestDto) { - notiAdminService.sendAnnounceNotiToUser(sendNotiAdminRequestDto); - return new ResponseEntity(HttpStatus.CREATED); - } + private final NotiAdminService notiAdminService; + + @GetMapping + public NotiListAdminResponseDto getAllNoti(@ModelAttribute NotiListAdminRequestDto requestDto) { + int page = requestDto.getPage(); + int size = requestDto.getSize(); + String intraId = requestDto.getIntraId(); + + Pageable pageable = PageRequest.of(page - 1, size, + Sort.by("createdAt").descending().and(Sort.by("user.intraId").ascending())); + if (intraId == null) { + return notiAdminService.getAllNoti(pageable); + } else { + return notiAdminService.getFilteredNotifications(pageable, intraId); + } + } + + @PostMapping + public ResponseEntity sendNotiToUser(@RequestBody SendNotiAdminRequestDto sendNotiAdminRequestDto) { + notiAdminService.sendAnnounceNotiToUser(sendNotiAdminRequestDto); + return new ResponseEntity(HttpStatus.CREATED); + } } diff --git a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepository.java b/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepository.java index 0f8c3ffb7..35c136cf9 100644 --- a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepository.java +++ b/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepository.java @@ -1,16 +1,17 @@ package com.gg.server.admin.noti.data; -import com.gg.server.domain.noti.data.Noti; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; +import com.gg.server.domain.noti.data.Noti; + public interface NotiAdminRepository - extends JpaRepository, NotiAdminRepositoryCustom{ + extends JpaRepository, NotiAdminRepositoryCustom { - @Override - @EntityGraph(attributePaths = {"user"}) - Page findAll(Pageable pageable); + @Override + @EntityGraph(attributePaths = {"user"}) + Page findAll(Pageable pageable); } diff --git a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustom.java b/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustom.java index 4f9adfc18..fd886f9e4 100644 --- a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustom.java +++ b/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustom.java @@ -1,11 +1,12 @@ package com.gg.server.admin.noti.data; -import com.gg.server.domain.noti.data.Noti; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.query.Param; +import com.gg.server.domain.noti.data.Noti; + public interface NotiAdminRepositoryCustom { - Page findNotisByUserIntraId(Pageable pageable, @Param("intraId") String intraId); + Page findNotisByUserIntraId(Pageable pageable, @Param("intraId") String intraId); } diff --git a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustomImpl.java b/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustomImpl.java index 306b85913..6460fd8fa 100644 --- a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustomImpl.java +++ b/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustomImpl.java @@ -1,35 +1,39 @@ package com.gg.server.admin.noti.data; -import com.gg.server.domain.noti.data.Noti; -import lombok.RequiredArgsConstructor; +import java.util.List; + +import javax.persistence.EntityManager; + import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import javax.persistence.EntityManager; -import java.util.List; +import com.gg.server.domain.noti.data.Noti; + +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor public class NotiAdminRepositoryCustomImpl implements NotiAdminRepositoryCustom { - private final EntityManager em; - @Override - public Page findNotisByUserIntraId(Pageable pageable, String intraId) { - long totalElem = countTotalElem(intraId); - String sql = "select n from Noti n join fetch n.user where " + - "n.user.intraId like \'%" + intraId + "%\' order by n.createdAt desc, n.user.intraId asc"; - List notis = em.createQuery(sql, Noti.class) - .setFirstResult((int) pageable.getOffset()) - .setMaxResults(pageable.getPageSize()) - .getResultList(); - Page result = new PageImpl<>(notis, pageable, totalElem); - return result; - } - - private long countTotalElem(String intraId) { - String sql = "select n from Noti n join fetch n.user where " + - "n.user.intraId like \'%" + intraId + "%\'"; - List notiList = em.createQuery(sql, Noti.class) - .getResultList(); - return notiList.size(); - } + private final EntityManager em; + + @Override + public Page findNotisByUserIntraId(Pageable pageable, String intraId) { + long totalElem = countTotalElem(intraId); + String sql = "select n from Noti n join fetch n.user where " + + "n.user.intraId like \'%" + intraId + "%\' order by n.createdAt desc, n.user.intraId asc"; + List notis = em.createQuery(sql, Noti.class) + .setFirstResult((int)pageable.getOffset()) + .setMaxResults(pageable.getPageSize()) + .getResultList(); + Page result = new PageImpl<>(notis, pageable, totalElem); + return result; + } + + private long countTotalElem(String intraId) { + String sql = "select n from Noti n join fetch n.user where " + + "n.user.intraId like \'%" + intraId + "%\'"; + List notiList = em.createQuery(sql, Noti.class) + .getResultList(); + return notiList.size(); + } } diff --git a/src/main/java/com/gg/server/admin/noti/dto/NotiAdminDto.java b/src/main/java/com/gg/server/admin/noti/dto/NotiAdminDto.java index 3d1aeaca2..77e4e32f4 100644 --- a/src/main/java/com/gg/server/admin/noti/dto/NotiAdminDto.java +++ b/src/main/java/com/gg/server/admin/noti/dto/NotiAdminDto.java @@ -1,64 +1,64 @@ package com.gg.server.admin.noti.dto; +import java.time.LocalDateTime; +import java.util.Objects; + import com.gg.server.domain.noti.data.Noti; import com.gg.server.domain.noti.type.NotiType; + import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; - -import java.time.LocalDateTime; -import java.util.Objects; import lombok.NoArgsConstructor; @Getter @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) public class NotiAdminDto { - private Long id; - private String intraId; - private NotiType type; - private Boolean isChecked; - private String message; - private LocalDateTime createdAt; + private Long id; + private String intraId; + private NotiType type; + private Boolean isChecked; + private String message; + private LocalDateTime createdAt; - public NotiAdminDto(Noti noti) - { - if (noti != null) { - this.id = noti.getId(); - this.intraId = noti.getUser().getIntraId(); - this.type = noti.getType(); - this.isChecked = noti.getIsChecked(); - this.message = noti.getMessage(); - this.createdAt = noti.getCreatedAt(); - } - } + public NotiAdminDto(Noti noti) { + if (noti != null) { + this.id = noti.getId(); + this.intraId = noti.getUser().getIntraId(); + this.type = noti.getType(); + this.isChecked = noti.getIsChecked(); + this.message = noti.getMessage(); + this.createdAt = noti.getCreatedAt(); + } + } - @Override - public String toString() { - return "NotiAdminDto{" + - "id=" + id + - ", user=" + intraId + - ", type=" + type + - ", isChecked=" + isChecked + - ", message='" + message + '\'' + - ", creatdDate=" + createdAt + - '}'; - } + @Override + public String toString() { + return "NotiAdminDto{" + + "id=" + id + + ", user=" + intraId + + ", type=" + type + + ", isChecked=" + isChecked + + ", message='" + message + '\'' + + ", creatdDate=" + createdAt + + '}'; + } - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (!(o instanceof NotiAdminDto)) { - return false; - } - NotiAdminDto other = (NotiAdminDto) o; - return Objects.equals(id, other.id) - && Objects.equals(intraId, other.intraId) - && Objects.equals(type, other.type) - && Objects.equals(isChecked, other.isChecked) - && Objects.equals(message, other.message) - && Objects.equals(createdAt, other.createdAt); - } + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof NotiAdminDto)) { + return false; + } + NotiAdminDto other = (NotiAdminDto)obj; + return Objects.equals(id, other.id) + && Objects.equals(intraId, other.intraId) + && Objects.equals(type, other.type) + && Objects.equals(isChecked, other.isChecked) + && Objects.equals(message, other.message) + && Objects.equals(createdAt, other.createdAt); + } } diff --git a/src/main/java/com/gg/server/admin/noti/dto/NotiListAdminRequestDto.java b/src/main/java/com/gg/server/admin/noti/dto/NotiListAdminRequestDto.java index 6a9e334e6..6d00cdd1a 100644 --- a/src/main/java/com/gg/server/admin/noti/dto/NotiListAdminRequestDto.java +++ b/src/main/java/com/gg/server/admin/noti/dto/NotiListAdminRequestDto.java @@ -1,16 +1,17 @@ package com.gg.server.admin.noti.dto; import com.gg.server.global.dto.PageRequestDto; + import lombok.Getter; import lombok.Setter; @Getter @Setter public class NotiListAdminRequestDto extends PageRequestDto { - private String intraId; + private String intraId; - public NotiListAdminRequestDto(Integer page, Integer size, String intraId) { - super(page, size); - this.intraId = intraId; - } + public NotiListAdminRequestDto(Integer page, Integer size, String intraId) { + super(page, size); + this.intraId = intraId; + } } diff --git a/src/main/java/com/gg/server/admin/noti/dto/NotiListAdminResponseDto.java b/src/main/java/com/gg/server/admin/noti/dto/NotiListAdminResponseDto.java index ceaedd5c8..67ac4dc2f 100644 --- a/src/main/java/com/gg/server/admin/noti/dto/NotiListAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/noti/dto/NotiListAdminResponseDto.java @@ -1,32 +1,38 @@ package com.gg.server.admin.noti.dto; +import java.util.List; +import java.util.Objects; + import com.fasterxml.jackson.annotation.JsonInclude; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; -import java.util.Objects; - @Getter @AllArgsConstructor @NoArgsConstructor public class NotiListAdminResponseDto { - private List notiList; - @JsonInclude(JsonInclude.Include.NON_NULL) - private Integer totalPage; - @Override - public String toString() { - return "NotiListResponseDto{" + - "notifications=" + notiList + - '}'; - } + private List notiList; + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer totalPage; + + @Override + public String toString() { + return "NotiListResponseDto{" + + "notifications=" + notiList + + '}'; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - NotiListAdminResponseDto other = (NotiListAdminResponseDto) o; - return Objects.equals(notiList, other.notiList); - } -} \ No newline at end of file + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + NotiListAdminResponseDto other = (NotiListAdminResponseDto)obj; + return Objects.equals(notiList, other.notiList); + } +} diff --git a/src/main/java/com/gg/server/admin/noti/dto/SendNotiAdminRequestDto.java b/src/main/java/com/gg/server/admin/noti/dto/SendNotiAdminRequestDto.java index 4d286d150..576aba015 100644 --- a/src/main/java/com/gg/server/admin/noti/dto/SendNotiAdminRequestDto.java +++ b/src/main/java/com/gg/server/admin/noti/dto/SendNotiAdminRequestDto.java @@ -1,34 +1,35 @@ package com.gg.server.admin.noti.dto; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; +import java.util.Objects; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import java.util.Objects; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; @Getter @AllArgsConstructor @NoArgsConstructor public class SendNotiAdminRequestDto { - @NotNull - private String intraId; + @NotNull + private String intraId; - @NotNull - @Size(max=255) - private String message; + @NotNull + @Size(max = 255) + private String message; - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (!(o instanceof SendNotiAdminRequestDto)) { - return false; - } - SendNotiAdminRequestDto other = (SendNotiAdminRequestDto) o; - return Objects.equals(message, other.message); - } + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SendNotiAdminRequestDto)) { + return false; + } + SendNotiAdminRequestDto other = (SendNotiAdminRequestDto)obj; + return Objects.equals(message, other.message); + } } diff --git a/src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java b/src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java index c5478e47a..da056cc0d 100644 --- a/src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java +++ b/src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java @@ -1,51 +1,53 @@ -package com.gg.server.admin.noti.service; - -import com.gg.server.admin.noti.data.NotiAdminRepository; -import com.gg.server.admin.noti.dto.NotiAdminDto; -import com.gg.server.admin.noti.dto.NotiListAdminResponseDto; -import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; -import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.domain.noti.data.Noti; -import com.gg.server.domain.noti.service.SnsNotiService; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import lombok.AllArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@AllArgsConstructor -public class NotiAdminService { - private final NotiAdminRepository notiAdminRepository; - private final UserAdminRepository userAdminRepository; - private final SnsNotiService snsNotiService; - - @Transactional - public void sendAnnounceNotiToUser(SendNotiAdminRequestDto sendNotiAdminRequestDto) { - String message = sendNotiAdminRequestDto.getMessage(); - String intraId = sendNotiAdminRequestDto.getIntraId(); - - User user = userAdminRepository.findByIntraId(intraId) - .orElseThrow(UserNotFoundException::new); - Noti noti = notiAdminRepository.save(new Noti(user, NotiType.ANNOUNCE, message, false)); - snsNotiService.sendSnsNotification(noti, UserDto.from(user)); - } - - @Transactional(readOnly = true) - public NotiListAdminResponseDto getAllNoti(Pageable pageable) { - Page allNotiPage = notiAdminRepository.findAll(pageable); - Page notiAdminDtoPage = allNotiPage.map(NotiAdminDto::new); - return new NotiListAdminResponseDto(notiAdminDtoPage.getContent(), notiAdminDtoPage.getTotalPages()); - } - - @Transactional(readOnly = true) - public NotiListAdminResponseDto getFilteredNotifications(Pageable pageable, String intraId) { - Page findNotis = notiAdminRepository.findNotisByUserIntraId(pageable, intraId); - Page notiResponseDtoPage = findNotis.map(NotiAdminDto::new); - return new NotiListAdminResponseDto(notiResponseDtoPage.getContent(), notiResponseDtoPage.getTotalPages()); - } -} +package com.gg.server.admin.noti.service; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.admin.noti.data.NotiAdminRepository; +import com.gg.server.admin.noti.dto.NotiAdminDto; +import com.gg.server.admin.noti.dto.NotiListAdminResponseDto; +import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; +import com.gg.server.admin.user.data.UserAdminRepository; +import com.gg.server.domain.noti.data.Noti; +import com.gg.server.domain.noti.service.SnsNotiService; +import com.gg.server.domain.noti.type.NotiType; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.exception.UserNotFoundException; + +import lombok.AllArgsConstructor; + +@Service +@AllArgsConstructor +public class NotiAdminService { + private final NotiAdminRepository notiAdminRepository; + private final UserAdminRepository userAdminRepository; + private final SnsNotiService snsNotiService; + + @Transactional + public void sendAnnounceNotiToUser(SendNotiAdminRequestDto sendNotiAdminRequestDto) { + String message = sendNotiAdminRequestDto.getMessage(); + String intraId = sendNotiAdminRequestDto.getIntraId(); + + User user = userAdminRepository.findByIntraId(intraId) + .orElseThrow(UserNotFoundException::new); + Noti noti = notiAdminRepository.save(new Noti(user, NotiType.ANNOUNCE, message, false)); + snsNotiService.sendSnsNotification(noti, UserDto.from(user)); + } + + @Transactional(readOnly = true) + public NotiListAdminResponseDto getAllNoti(Pageable pageable) { + Page allNotiPage = notiAdminRepository.findAll(pageable); + Page notiAdminDtoPage = allNotiPage.map(NotiAdminDto::new); + return new NotiListAdminResponseDto(notiAdminDtoPage.getContent(), notiAdminDtoPage.getTotalPages()); + } + + @Transactional(readOnly = true) + public NotiListAdminResponseDto getFilteredNotifications(Pageable pageable, String intraId) { + Page findNotis = notiAdminRepository.findNotisByUserIntraId(pageable, intraId); + Page notiResponseDtoPage = findNotis.map(NotiAdminDto::new); + return new NotiListAdminResponseDto(notiResponseDtoPage.getContent(), notiResponseDtoPage.getTotalPages()); + } +} diff --git a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepository.java b/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepository.java index 4e8b3c3b1..32ee9fa0d 100644 --- a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepository.java +++ b/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepository.java @@ -1,7 +1,8 @@ package com.gg.server.admin.pchange.data; -import com.gg.server.domain.pchange.data.PChange; import org.springframework.data.jpa.repository.JpaRepository; +import com.gg.server.domain.pchange.data.PChange; + public interface PChangeAdminRepository extends JpaRepository, PChangeAdminRepositoryCustom { } diff --git a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustom.java b/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustom.java index 215056b7d..0cbdf1f02 100644 --- a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustom.java +++ b/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustom.java @@ -1,9 +1,9 @@ package com.gg.server.admin.pchange.data; -import com.gg.server.domain.pchange.data.PChange; - import java.util.List; +import com.gg.server.domain.pchange.data.PChange; + public interface PChangeAdminRepositoryCustom { - List findByTeamUser(Long userId); + List findByTeamUser(Long userId); } diff --git a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustomImpl.java b/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustomImpl.java index 341b936ea..4aacf7474 100644 --- a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustomImpl.java +++ b/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustomImpl.java @@ -1,22 +1,25 @@ package com.gg.server.admin.pchange.data; -import com.gg.server.domain.pchange.data.PChange; -import lombok.RequiredArgsConstructor; +import java.util.List; import javax.persistence.EntityManager; import javax.persistence.LockModeType; -import java.util.List; + +import com.gg.server.domain.pchange.data.PChange; + +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor public class PChangeAdminRepositoryCustomImpl implements PChangeAdminRepositoryCustom { - private final EntityManager em; - @Override - public List findByTeamUser(Long userId) { - String query = "SELECT p FROM PChange p WHERE p.user.id = :userId ORDER BY p.createdAt desc"; - return em.createQuery(query, PChange.class) - .setParameter("userId", userId) - .setMaxResults(2) - .setLockMode(LockModeType.PESSIMISTIC_WRITE) - .getResultList(); - } + private final EntityManager em; + + @Override + public List findByTeamUser(Long userId) { + String query = "SELECT p FROM PChange p WHERE p.user.id = :userId ORDER BY p.createdAt desc"; + return em.createQuery(query, PChange.class) + .setParameter("userId", userId) + .setMaxResults(2) + .setLockMode(LockModeType.PESSIMISTIC_WRITE) + .getResultList(); + } } diff --git a/src/main/java/com/gg/server/admin/pchange/exception/PChangeNotExistException.java b/src/main/java/com/gg/server/admin/pchange/exception/PChangeNotExistException.java index 0c89a5f8d..20999c559 100644 --- a/src/main/java/com/gg/server/admin/pchange/exception/PChangeNotExistException.java +++ b/src/main/java/com/gg/server/admin/pchange/exception/PChangeNotExistException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class PChangeNotExistException extends NotExistException { - public PChangeNotExistException() { - super(ErrorCode.PCHANGE_NOT_FOUND.getMessage(), ErrorCode.PCHANGE_NOT_FOUND); - } + public PChangeNotExistException() { + super(ErrorCode.PCHANGE_NOT_FOUND.getMessage(), ErrorCode.PCHANGE_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/admin/penalty/controller/PenaltyAdminController.java b/src/main/java/com/gg/server/admin/penalty/controller/PenaltyAdminController.java index d9ea1893b..5215175c2 100644 --- a/src/main/java/com/gg/server/admin/penalty/controller/PenaltyAdminController.java +++ b/src/main/java/com/gg/server/admin/penalty/controller/PenaltyAdminController.java @@ -1,12 +1,8 @@ package com.gg.server.admin.penalty.controller; -import com.gg.server.admin.penalty.dto.PenaltyListResponseDto; -import com.gg.server.admin.penalty.dto.PenaltyRequestDto; -import com.gg.server.admin.penalty.service.PenaltyAdminService; -import com.gg.server.global.dto.PageRequestDto; import javax.validation.Valid; import javax.validation.constraints.Min; -import lombok.RequiredArgsConstructor; + import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; @@ -23,32 +19,40 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import com.gg.server.admin.penalty.dto.PenaltyListResponseDto; +import com.gg.server.admin.penalty.dto.PenaltyRequestDto; +import com.gg.server.admin.penalty.service.PenaltyAdminService; +import com.gg.server.global.dto.PageRequestDto; + +import lombok.RequiredArgsConstructor; + @RestController @RequiredArgsConstructor @Validated @RequestMapping("/pingpong/admin/") public class PenaltyAdminController { - private final PenaltyAdminService penaltyAdminService; - - @PostMapping("penalty") - public ResponseEntity givePenaltyToUser(@RequestBody @Valid PenaltyRequestDto requestDto) { - penaltyAdminService.givePenalty(requestDto.getIntraId(), requestDto.getPenaltyTime(), requestDto.getReason()); - return ResponseEntity.status(HttpStatus.CREATED).build(); - } - - @GetMapping("penalty") - public PenaltyListResponseDto getAllPenaltyUser(@ModelAttribute @Valid PageRequestDto pageRequestDto, - @RequestParam(required = false) String intraId, @RequestParam Boolean current) { - Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, pageRequestDto.getSize(), - Sort.by("startTime").descending()); - if (intraId == null) - return penaltyAdminService.getAllPenalties(pageable, current); - return penaltyAdminService.getAllPenaltiesByIntraId(pageable, intraId, current); - } - - @DeleteMapping("penalty/{penaltyId}") - public ResponseEntity releasePenaltyUser(@PathVariable @Min(1) Long penaltyId) { - penaltyAdminService.deletePenalty(penaltyId); - return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); - } + private final PenaltyAdminService penaltyAdminService; + + @PostMapping("penalty") + public ResponseEntity givePenaltyToUser(@RequestBody @Valid PenaltyRequestDto requestDto) { + penaltyAdminService.givePenalty(requestDto.getIntraId(), requestDto.getPenaltyTime(), requestDto.getReason()); + return ResponseEntity.status(HttpStatus.CREATED).build(); + } + + @GetMapping("penalty") + public PenaltyListResponseDto getAllPenaltyUser(@ModelAttribute @Valid PageRequestDto pageRequestDto, + @RequestParam(required = false) String intraId, @RequestParam Boolean current) { + Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, pageRequestDto.getSize(), + Sort.by("startTime").descending()); + if (intraId == null) { + return penaltyAdminService.getAllPenalties(pageable, current); + } + return penaltyAdminService.getAllPenaltiesByIntraId(pageable, intraId, current); + } + + @DeleteMapping("penalty/{penaltyId}") + public ResponseEntity releasePenaltyUser(@PathVariable @Min(1) Long penaltyId) { + penaltyAdminService.deletePenalty(penaltyId); + return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); + } } diff --git a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepository.java b/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepository.java index eac12e24b..da1980ae2 100644 --- a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepository.java +++ b/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepository.java @@ -1,8 +1,8 @@ package com.gg.server.admin.penalty.data; -import com.gg.server.domain.penalty.data.Penalty; import java.time.LocalDateTime; import java.util.List; + import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.EntityGraph; @@ -10,10 +10,13 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -public interface PenaltyAdminRepository extends JpaRepository, PenaltyAdminRepositoryCustom{ - @EntityGraph(attributePaths = {"user"}) - Page findAll(Pageable pageable); - @Query("select p from Penalty p where p.user.id = :userId and p.startTime > :startTime") - List findAfterPenaltiesByUser(@Param("userId") Long userId, - @Param("startTime") LocalDateTime startTime); +import com.gg.server.domain.penalty.data.Penalty; + +public interface PenaltyAdminRepository extends JpaRepository, PenaltyAdminRepositoryCustom { + @EntityGraph(attributePaths = {"user"}) + Page findAll(Pageable pageable); + + @Query("select p from Penalty p where p.user.id = :userId and p.startTime > :startTime") + List findAfterPenaltiesByUser(@Param("userId") Long userId, + @Param("startTime") LocalDateTime startTime); } diff --git a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustom.java b/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustom.java index 86284955a..f0b843ad7 100644 --- a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustom.java +++ b/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustom.java @@ -1,15 +1,17 @@ package com.gg.server.admin.penalty.data; -import com.gg.server.domain.penalty.data.Penalty; import java.time.LocalDateTime; -import java.util.List; + import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.data.repository.query.Param; + +import com.gg.server.domain.penalty.data.Penalty; public interface PenaltyAdminRepositoryCustom { - Page findAllCurrent(Pageable pageable, LocalDateTime targetTime); - Page findAllByIntraId(Pageable pageable, String intraId); - Page findAllCurrentByIntraId(Pageable pageable, LocalDateTime targetTime, - String intraId); + Page findAllCurrent(Pageable pageable, LocalDateTime targetTime); + + Page findAllByIntraId(Pageable pageable, String intraId); + + Page findAllCurrentByIntraId(Pageable pageable, LocalDateTime targetTime, + String intraId); } diff --git a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustomImpl.java b/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustomImpl.java index c449b03c5..14b778331 100644 --- a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustomImpl.java +++ b/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustomImpl.java @@ -1,87 +1,94 @@ package com.gg.server.admin.penalty.data; -import com.gg.server.domain.penalty.data.Penalty; import java.time.LocalDateTime; import java.util.List; + import javax.persistence.EntityManager; -import lombok.RequiredArgsConstructor; + import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; +import com.gg.server.domain.penalty.data.Penalty; + +import lombok.RequiredArgsConstructor; + @RequiredArgsConstructor -public class PenaltyAdminRepositoryCustomImpl implements PenaltyAdminRepositoryCustom{ - private final EntityManager em; +public class PenaltyAdminRepositoryCustomImpl implements PenaltyAdminRepositoryCustom { + private final EntityManager em; - @Override - public Page findAllCurrent(Pageable pageable, LocalDateTime targetTime) { - String sql = "select p from Penalty p where TIME_TO_SEC(TIMEDIFF(:targetTime, p.startTime)) < p.penaltyTime * 60 " - + "order by p.startTime desc"; - long count = countCurrent(targetTime); - List penalties = em.createQuery(sql, Penalty.class) - .setParameter("targetTime", targetTime) - .setFirstResult((int) pageable.getOffset()) - .setMaxResults(pageable.getPageSize()) - .getResultList(); - Page result = new PageImpl<>(penalties, pageable, count); - return result; - } + @Override + public Page findAllCurrent(Pageable pageable, LocalDateTime targetTime) { + String sql = + "select p from Penalty p where TIME_TO_SEC(TIMEDIFF(:targetTime, p.startTime)) < p.penaltyTime * 60 " + + "order by p.startTime desc"; + long count = countCurrent(targetTime); + List penalties = em.createQuery(sql, Penalty.class) + .setParameter("targetTime", targetTime) + .setFirstResult((int)pageable.getOffset()) + .setMaxResults(pageable.getPageSize()) + .getResultList(); + Page result = new PageImpl<>(penalties, pageable, count); + return result; + } - @Override - public Page findAllByIntraId(Pageable pageable, String intraId) { - String sql = "SELECT p FROM Penalty p JOIN FETCH p.user WHERE p.user.intraId LIKE :intraId ORDER BY p.startTime DESC"; - long count = countByIntraId(intraId); - List penalties = em.createQuery(sql, Penalty.class) - .setParameter("intraId", "%" + intraId + "%") - .setFirstResult((int) pageable.getOffset()) - .setMaxResults(pageable.getPageSize()) - .getResultList(); - Page result = new PageImpl<>(penalties, pageable, count); - return result; - } + @Override + public Page findAllByIntraId(Pageable pageable, String intraId) { + String sql = "SELECT p FROM Penalty p JOIN FETCH p.user " + + "WHERE p.user.intraId LIKE :intraId ORDER BY p.startTime DESC"; + long count = countByIntraId(intraId); + List penalties = em.createQuery(sql, Penalty.class) + .setParameter("intraId", "%" + intraId + "%") + .setFirstResult((int)pageable.getOffset()) + .setMaxResults(pageable.getPageSize()) + .getResultList(); + Page result = new PageImpl<>(penalties, pageable, count); + return result; + } - @Override - public Page findAllCurrentByIntraId(Pageable pageable, LocalDateTime targetTime, String intraId) { - String sql = "select p from Penalty p join fetch p.user where " + - "p.user.intraId like :intraId and TIME_TO_SEC(TIMEDIFF(:targetTime, p.startTime)) < p.penaltyTime * 60 " - + "order by p.startTime desc"; - long count = countCurrentByIntraId(intraId, targetTime); - List penalties = em.createQuery(sql, Penalty.class) - .setParameter("intraId", "%" + intraId + "%") - .setParameter("targetTime", targetTime) - .setFirstResult((int) pageable.getOffset()) - .setMaxResults(pageable.getPageSize()) - .getResultList(); - Page result = new PageImpl<>(penalties, pageable, count); - return result; - } + @Override + public Page findAllCurrentByIntraId(Pageable pageable, LocalDateTime targetTime, String intraId) { + String sql = "select p from Penalty p join fetch p.user where " + + "p.user.intraId like :intraId and TIME_TO_SEC(TIMEDIFF(:targetTime, p.startTime)) < p.penaltyTime * 60 " + + "order by p.startTime desc"; + long count = countCurrentByIntraId(intraId, targetTime); + List penalties = em.createQuery(sql, Penalty.class) + .setParameter("intraId", "%" + intraId + "%") + .setParameter("targetTime", targetTime) + .setFirstResult((int)pageable.getOffset()) + .setMaxResults(pageable.getPageSize()) + .getResultList(); + Page result = new PageImpl<>(penalties, pageable, count); + return result; + } - private long countCurrent(LocalDateTime targetTime) { - String sql = "select p from Penalty p where TIME_TO_SEC(TIMEDIFF(:targetTime, p.startTime)) < p.penaltyTime * 60 " - + "order by p.startTime desc"; - return em.createQuery(sql, Penalty.class) - .setParameter("targetTime", targetTime) - .getResultList().size(); - } + private long countCurrent(LocalDateTime targetTime) { + String sql = + "select p from Penalty p where TIME_TO_SEC(TIMEDIFF(:targetTime, p.startTime)) < p.penaltyTime * 60 " + + "order by p.startTime desc"; + return em.createQuery(sql, Penalty.class) + .setParameter("targetTime", targetTime) + .getResultList().size(); + } - private long countByIntraId(String intraId) { - String sql = "select p FROM Penalty p join fetch p.user u WHERE u.intraId LIKE :intraId " - + "order by p.startTime desc"; - return em.createQuery(sql, Penalty.class) - .setParameter("intraId", "%" + intraId + "%") - .getResultList() - .size(); - } + private long countByIntraId(String intraId) { + String sql = "select p FROM Penalty p join fetch p.user u WHERE u.intraId LIKE :intraId " + + "order by p.startTime desc"; + return em.createQuery(sql, Penalty.class) + .setParameter("intraId", "%" + intraId + "%") + .getResultList() + .size(); + } - private long countCurrentByIntraId(String intraId, LocalDateTime targetTime) { - String sql = "select p from Penalty p join fetch p.user where " + - "p.user.intraId like :intraId and TIME_TO_SEC(TIMEDIFF(:targetTime, p.startTime)) < p.penaltyTime * 60 " - + "order by p.startTime desc"; - return em.createQuery(sql, Penalty.class) - .setParameter("intraId", "%" + intraId + "%") - .setParameter("targetTime", targetTime) - .getResultList() - .size(); + private long countCurrentByIntraId(String intraId, LocalDateTime targetTime) { + String sql = "select p from Penalty p join fetch p.user where " + + "p.user.intraId like :intraId and TIME_TO_SEC(TIMEDIFF(:targetTime, p.startTime)) < p.penaltyTime * 60 " + + "order by p.startTime desc"; + return em.createQuery(sql, Penalty.class) + .setParameter("intraId", "%" + intraId + "%") + .setParameter("targetTime", targetTime) + .getResultList() + .size(); - } + } } diff --git a/src/main/java/com/gg/server/admin/penalty/data/PenaltyUserAdminRedisRepository.java b/src/main/java/com/gg/server/admin/penalty/data/PenaltyUserAdminRedisRepository.java index 9e9226078..45f56531f 100644 --- a/src/main/java/com/gg/server/admin/penalty/data/PenaltyUserAdminRedisRepository.java +++ b/src/main/java/com/gg/server/admin/penalty/data/PenaltyUserAdminRedisRepository.java @@ -1,7 +1,5 @@ package com.gg.server.admin.penalty.data; -import com.gg.server.admin.penalty.type.PenaltyKey; -import com.gg.server.domain.penalty.redis.RedisPenaltyUser; import java.time.Duration; import java.time.LocalDateTime; import java.util.List; @@ -9,50 +7,55 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import lombok.RequiredArgsConstructor; + import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; +import com.gg.server.admin.penalty.type.PenaltyKey; +import com.gg.server.domain.penalty.redis.RedisPenaltyUser; + +import lombok.RequiredArgsConstructor; + @Repository @RequiredArgsConstructor public class PenaltyUserAdminRedisRepository { - private final RedisTemplate redisTemplate; - - public void addPenaltyUser(RedisPenaltyUser penaltyUser, LocalDateTime releaseTime) { - LocalDateTime now = LocalDateTime.now(); - Duration duration = Duration.between(now, releaseTime); - redisTemplate.opsForValue().set(PenaltyKey.USER_ADMIN + penaltyUser.getIntraId(), penaltyUser, - duration.getSeconds(), TimeUnit.SECONDS); - } - public Optional findByIntraId(String intraId) { - RedisPenaltyUser penaltyUser = redisTemplate.opsForValue().get(PenaltyKey.USER_ADMIN + intraId); - return Optional.ofNullable(penaltyUser); - } - - - public List findAll() { - Set penaltyUserKeys = redisTemplate.keys(PenaltyKey.ALL + "*"); - List users = penaltyUserKeys.stream().map(key -> redisTemplate.opsForValue().get(key)) - .collect(Collectors.toList()); - return users; - } - - public List findAllByKeyword(String keyword) { - Set penaltyUserKeys = redisTemplate.keys(PenaltyKey.ALL + "*" + keyword + "*"); - List users = penaltyUserKeys.stream().map(key -> redisTemplate.opsForValue().get(key)) - .collect(Collectors.toList()); - return users; - } - - public void deletePenaltyInUser(RedisPenaltyUser penaltyUser, Integer penaltyTime) { - LocalDateTime newReleaseTime = penaltyUser.getReleaseTime().minusMinutes(penaltyTime); - penaltyUser.updateReleaseTime(newReleaseTime, penaltyUser.getPenaltyTime() - penaltyTime); - Duration duration = Duration.between(LocalDateTime.now(), newReleaseTime); - if (duration.isNegative()) { - redisTemplate.delete(PenaltyKey.USER_ADMIN + penaltyUser.getIntraId()); - return; - } - redisTemplate.opsForValue().set(PenaltyKey.USER_ADMIN + penaltyUser.getIntraId(), penaltyUser, - duration.getSeconds(), TimeUnit.SECONDS); - } + private final RedisTemplate redisTemplate; + + public void addPenaltyUser(RedisPenaltyUser penaltyUser, LocalDateTime releaseTime) { + LocalDateTime now = LocalDateTime.now(); + Duration duration = Duration.between(now, releaseTime); + redisTemplate.opsForValue().set(PenaltyKey.USER_ADMIN + penaltyUser.getIntraId(), penaltyUser, + duration.getSeconds(), TimeUnit.SECONDS); + } + + public Optional findByIntraId(String intraId) { + RedisPenaltyUser penaltyUser = redisTemplate.opsForValue().get(PenaltyKey.USER_ADMIN + intraId); + return Optional.ofNullable(penaltyUser); + } + + public List findAll() { + Set penaltyUserKeys = redisTemplate.keys(PenaltyKey.ALL + "*"); + List users = penaltyUserKeys.stream().map(key -> redisTemplate.opsForValue().get(key)) + .collect(Collectors.toList()); + return users; + } + + public List findAllByKeyword(String keyword) { + Set penaltyUserKeys = redisTemplate.keys(PenaltyKey.ALL + "*" + keyword + "*"); + List users = penaltyUserKeys.stream().map(key -> redisTemplate.opsForValue().get(key)) + .collect(Collectors.toList()); + return users; + } + + public void deletePenaltyInUser(RedisPenaltyUser penaltyUser, Integer penaltyTime) { + LocalDateTime newReleaseTime = penaltyUser.getReleaseTime().minusMinutes(penaltyTime); + penaltyUser.updateReleaseTime(newReleaseTime, penaltyUser.getPenaltyTime() - penaltyTime); + Duration duration = Duration.between(LocalDateTime.now(), newReleaseTime); + if (duration.isNegative()) { + redisTemplate.delete(PenaltyKey.USER_ADMIN + penaltyUser.getIntraId()); + return; + } + redisTemplate.opsForValue().set(PenaltyKey.USER_ADMIN + penaltyUser.getIntraId(), penaltyUser, + duration.getSeconds(), TimeUnit.SECONDS); + } } diff --git a/src/main/java/com/gg/server/admin/penalty/dto/PenaltyListResponseDto.java b/src/main/java/com/gg/server/admin/penalty/dto/PenaltyListResponseDto.java index e2feef6b6..99a868fb4 100644 --- a/src/main/java/com/gg/server/admin/penalty/dto/PenaltyListResponseDto.java +++ b/src/main/java/com/gg/server/admin/penalty/dto/PenaltyListResponseDto.java @@ -1,6 +1,7 @@ package com.gg.server.admin.penalty.dto; import java.util.List; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -9,6 +10,6 @@ @NoArgsConstructor @AllArgsConstructor public class PenaltyListResponseDto { - List penaltyList; - Integer totalPage; + List penaltyList; + Integer totalPage; } diff --git a/src/main/java/com/gg/server/admin/penalty/dto/PenaltyRequestDto.java b/src/main/java/com/gg/server/admin/penalty/dto/PenaltyRequestDto.java index 06ea3493a..b4092ebc8 100644 --- a/src/main/java/com/gg/server/admin/penalty/dto/PenaltyRequestDto.java +++ b/src/main/java/com/gg/server/admin/penalty/dto/PenaltyRequestDto.java @@ -1,18 +1,20 @@ package com.gg.server.admin.penalty.dto; import javax.validation.constraints.PositiveOrZero; + +import org.hibernate.validator.constraints.Length; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; @Getter @NoArgsConstructor @AllArgsConstructor public class PenaltyRequestDto { - @Length(max = 30) - private String intraId; - @PositiveOrZero - private Integer penaltyTime; - private String reason; + @Length(max = 30) + private String intraId; + @PositiveOrZero + private Integer penaltyTime; + private String reason; } diff --git a/src/main/java/com/gg/server/admin/penalty/dto/PenaltyUserResponseDto.java b/src/main/java/com/gg/server/admin/penalty/dto/PenaltyUserResponseDto.java index 02b56de0e..e3f6e75a4 100644 --- a/src/main/java/com/gg/server/admin/penalty/dto/PenaltyUserResponseDto.java +++ b/src/main/java/com/gg/server/admin/penalty/dto/PenaltyUserResponseDto.java @@ -1,8 +1,10 @@ package com.gg.server.admin.penalty.dto; +import java.time.LocalDateTime; + import com.gg.server.domain.penalty.data.Penalty; import com.gg.server.domain.penalty.redis.RedisPenaltyUser; -import java.time.LocalDateTime; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -11,31 +13,31 @@ @NoArgsConstructor @AllArgsConstructor public class PenaltyUserResponseDto { - private Long penaltyId; - private String intraId; - private String reason; - private LocalDateTime releaseTime; + private Long penaltyId; + private String intraId; + private String reason; + private LocalDateTime releaseTime; - public PenaltyUserResponseDto(RedisPenaltyUser penaltyUser) { - this.intraId = penaltyUser.getIntraId(); - this.reason = penaltyUser.getReason(); - this.releaseTime = penaltyUser.getReleaseTime(); - } + public PenaltyUserResponseDto(RedisPenaltyUser penaltyUser) { + this.intraId = penaltyUser.getIntraId(); + this.reason = penaltyUser.getReason(); + this.releaseTime = penaltyUser.getReleaseTime(); + } - public PenaltyUserResponseDto(Penalty penalty) { - this.penaltyId = penalty.getId(); - this.intraId = penalty.getUser().getIntraId(); - this.reason = penalty.getMessage(); - this.releaseTime = penalty.getStartTime().plusMinutes(penalty.getPenaltyTime()); - } + public PenaltyUserResponseDto(Penalty penalty) { + this.penaltyId = penalty.getId(); + this.intraId = penalty.getUser().getIntraId(); + this.reason = penalty.getMessage(); + this.releaseTime = penalty.getStartTime().plusMinutes(penalty.getPenaltyTime()); + } - @Override - public String toString() { - return "PenaltyUserResponseDto{" + - "penaltyId=" + penaltyId + - ", intraId='" + intraId + '\'' + - ", reason='" + reason + '\'' + - ", releaseTime=" + releaseTime + - '}'; - } + @Override + public String toString() { + return "PenaltyUserResponseDto{" + + "penaltyId=" + penaltyId + ", intraId='" + + intraId + '\'' + ", reason='" + + reason + '\'' + ", releaseTime=" + + releaseTime + + '}'; + } } diff --git a/src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java b/src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java index dcff03b48..0b1947870 100644 --- a/src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java +++ b/src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java @@ -1,110 +1,112 @@ -package com.gg.server.admin.penalty.service; - -import com.gg.server.admin.penalty.data.PenaltyAdminRepository; -import com.gg.server.domain.penalty.data.Penalty; -import com.gg.server.domain.penalty.redis.RedisPenaltyUser; -import com.gg.server.admin.penalty.data.PenaltyUserAdminRedisRepository; -import com.gg.server.admin.penalty.dto.PenaltyListResponseDto; -import com.gg.server.admin.penalty.dto.PenaltyUserResponseDto; -import com.gg.server.domain.penalty.exception.PenaltyExpiredException; -import com.gg.server.domain.penalty.exception.PenaltyNotFoundException; -import com.gg.server.domain.penalty.exception.RedisPenaltyUserNotFoundException; -import com.gg.server.domain.penalty.type.PenaltyType; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.service.UserFindService; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Optional; -import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@RequiredArgsConstructor -public class PenaltyAdminService { - private final PenaltyUserAdminRedisRepository penaltyUserAdminRedisRepository; - private final UserFindService userFindService; - private final PenaltyAdminRepository penaltyRepository; - - @Transactional - public void givePenalty(String intraId, Integer penaltyTime, String reason) { - User user = userFindService.findByIntraId(intraId); - Optional redisPenaltyUser = penaltyUserAdminRedisRepository.findByIntraId(intraId); - LocalDateTime releaseTime; - RedisPenaltyUser penaltyUser; - Penalty penalty; - LocalDateTime now = LocalDateTime.now(); - if (redisPenaltyUser.isPresent()) { - releaseTime = redisPenaltyUser.get().getReleaseTime().plusHours(penaltyTime); - penaltyUser = new RedisPenaltyUser(intraId, redisPenaltyUser.get().getPenaltyTime() + penaltyTime * 60, - releaseTime, redisPenaltyUser.get().getStartTime(), reason); - penalty = new Penalty(user, PenaltyType.NOSHOW, reason, redisPenaltyUser.get().getReleaseTime(), penaltyTime * 60); - } else { - releaseTime = now.plusHours(penaltyTime); - penaltyUser = new RedisPenaltyUser(intraId, penaltyTime * 60, releaseTime, now, reason); - penalty = new Penalty(user, PenaltyType.NOSHOW, reason, now, penaltyTime * 60); - } - penaltyRepository.save(penalty); - penaltyUserAdminRedisRepository.addPenaltyUser(penaltyUser, releaseTime); - } - - - @Transactional(readOnly = true) - public PenaltyListResponseDto getAllPenalties(Pageable pageable, Boolean current) { - Page allPenalties; - if (current) { - allPenalties = penaltyRepository.findAllCurrent(pageable, LocalDateTime.now()); - } else { - allPenalties = penaltyRepository.findAll(pageable); - } - Page responseDtos = allPenalties.map(PenaltyUserResponseDto::new); - return new PenaltyListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); - } - - - @Transactional - public void deletePenalty(Long penaltyId) { - Penalty penalty = penaltyRepository.findById(penaltyId).orElseThrow(() - -> new PenaltyNotFoundException()); - if (penalty.getStartTime().plusMinutes(penalty.getPenaltyTime()).isBefore(LocalDateTime.now())) { - throw new PenaltyExpiredException(); - } - RedisPenaltyUser penaltyUser = penaltyUserAdminRedisRepository - .findByIntraId(penalty.getUser().getIntraId()).orElseThrow(() - -> new RedisPenaltyUserNotFoundException()); - penaltyUserAdminRedisRepository.deletePenaltyInUser(penaltyUser, - penalty.getPenaltyTime());//redis 시간 줄여주기 - //뒤에 있는 penalty 시간 당겨주기 - modifyStartTimeOfAfterPenalties(penalty); - penaltyRepository.delete(penalty); - } - - @Transactional(readOnly = true) - public PenaltyListResponseDto getAllPenaltiesByIntraId(Pageable pageable, String intraId, Boolean current) { - Page allPenalties; - if (current) { - allPenalties = penaltyRepository.findAllCurrentByIntraId(pageable, LocalDateTime.now(), intraId); - } else { - allPenalties = penaltyRepository.findAllByIntraId(pageable, intraId); - } - Page responseDtos = allPenalties.map(PenaltyUserResponseDto::new); - return new PenaltyListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); - } - - private void modifyStartTimeOfAfterPenalties(Penalty penalty) { - List afterPenalties = penaltyRepository.findAfterPenaltiesByUser(penalty.getUser().getId(), - penalty.getStartTime()); - LocalDateTime newStartTime; - if (penalty.getStartTime().isAfter(LocalDateTime.now())) { - newStartTime = penalty.getStartTime(); - } else { - newStartTime = LocalDateTime.now(); - } - for (Penalty afterPenalty : afterPenalties) { - afterPenalty.updateStartTime(newStartTime); - newStartTime = newStartTime.plusMinutes(afterPenalty.getPenaltyTime()); - } - } -} +package com.gg.server.admin.penalty.service; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.admin.penalty.data.PenaltyAdminRepository; +import com.gg.server.admin.penalty.data.PenaltyUserAdminRedisRepository; +import com.gg.server.admin.penalty.dto.PenaltyListResponseDto; +import com.gg.server.admin.penalty.dto.PenaltyUserResponseDto; +import com.gg.server.domain.penalty.data.Penalty; +import com.gg.server.domain.penalty.exception.PenaltyExpiredException; +import com.gg.server.domain.penalty.exception.PenaltyNotFoundException; +import com.gg.server.domain.penalty.exception.RedisPenaltyUserNotFoundException; +import com.gg.server.domain.penalty.redis.RedisPenaltyUser; +import com.gg.server.domain.penalty.type.PenaltyType; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.service.UserFindService; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class PenaltyAdminService { + private final PenaltyUserAdminRedisRepository penaltyUserAdminRedisRepository; + private final UserFindService userFindService; + private final PenaltyAdminRepository penaltyRepository; + + @Transactional + public void givePenalty(String intraId, Integer penaltyTime, String reason) { + User user = userFindService.findByIntraId(intraId); + Optional redisPenaltyUser = penaltyUserAdminRedisRepository.findByIntraId(intraId); + LocalDateTime releaseTime; + RedisPenaltyUser penaltyUser; + Penalty penalty; + LocalDateTime now = LocalDateTime.now(); + if (redisPenaltyUser.isPresent()) { + releaseTime = redisPenaltyUser.get().getReleaseTime().plusHours(penaltyTime); + penaltyUser = new RedisPenaltyUser(intraId, redisPenaltyUser.get().getPenaltyTime() + penaltyTime * 60, + releaseTime, redisPenaltyUser.get().getStartTime(), reason); + penalty = new Penalty(user, PenaltyType.NOSHOW, reason, redisPenaltyUser.get().getReleaseTime(), + penaltyTime * 60); + } else { + releaseTime = now.plusHours(penaltyTime); + penaltyUser = new RedisPenaltyUser(intraId, penaltyTime * 60, releaseTime, now, reason); + penalty = new Penalty(user, PenaltyType.NOSHOW, reason, now, penaltyTime * 60); + } + penaltyRepository.save(penalty); + penaltyUserAdminRedisRepository.addPenaltyUser(penaltyUser, releaseTime); + } + + @Transactional(readOnly = true) + public PenaltyListResponseDto getAllPenalties(Pageable pageable, Boolean current) { + Page allPenalties; + if (current) { + allPenalties = penaltyRepository.findAllCurrent(pageable, LocalDateTime.now()); + } else { + allPenalties = penaltyRepository.findAll(pageable); + } + Page responseDtos = allPenalties.map(PenaltyUserResponseDto::new); + return new PenaltyListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); + } + + @Transactional + public void deletePenalty(Long penaltyId) { + Penalty penalty = penaltyRepository.findById(penaltyId).orElseThrow(() + -> new PenaltyNotFoundException()); + if (penalty.getStartTime().plusMinutes(penalty.getPenaltyTime()).isBefore(LocalDateTime.now())) { + throw new PenaltyExpiredException(); + } + RedisPenaltyUser penaltyUser = penaltyUserAdminRedisRepository + .findByIntraId(penalty.getUser().getIntraId()).orElseThrow(() + -> new RedisPenaltyUserNotFoundException()); + penaltyUserAdminRedisRepository.deletePenaltyInUser(penaltyUser, + penalty.getPenaltyTime()); //redis 시간 줄여주기 + //뒤에 있는 penalty 시간 당겨주기 + modifyStartTimeOfAfterPenalties(penalty); + penaltyRepository.delete(penalty); + } + + @Transactional(readOnly = true) + public PenaltyListResponseDto getAllPenaltiesByIntraId(Pageable pageable, String intraId, Boolean current) { + Page allPenalties; + if (current) { + allPenalties = penaltyRepository.findAllCurrentByIntraId(pageable, LocalDateTime.now(), intraId); + } else { + allPenalties = penaltyRepository.findAllByIntraId(pageable, intraId); + } + Page responseDtos = allPenalties.map(PenaltyUserResponseDto::new); + return new PenaltyListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); + } + + private void modifyStartTimeOfAfterPenalties(Penalty penalty) { + List afterPenalties = penaltyRepository.findAfterPenaltiesByUser(penalty.getUser().getId(), + penalty.getStartTime()); + LocalDateTime newStartTime; + if (penalty.getStartTime().isAfter(LocalDateTime.now())) { + newStartTime = penalty.getStartTime(); + } else { + newStartTime = LocalDateTime.now(); + } + for (Penalty afterPenalty : afterPenalties) { + afterPenalty.updateStartTime(newStartTime); + newStartTime = newStartTime.plusMinutes(afterPenalty.getPenaltyTime()); + } + } +} diff --git a/src/main/java/com/gg/server/admin/penalty/type/PenaltyKey.java b/src/main/java/com/gg/server/admin/penalty/type/PenaltyKey.java index 3ef35a89c..45b73d4e9 100644 --- a/src/main/java/com/gg/server/admin/penalty/type/PenaltyKey.java +++ b/src/main/java/com/gg/server/admin/penalty/type/PenaltyKey.java @@ -1,7 +1,7 @@ package com.gg.server.admin.penalty.type; public class PenaltyKey { - public static final String ALL = "PENALTY:"; - public static final String USER = "PENALTY:USER:"; - public static final String USER_ADMIN = "PENALTY:USER:ADMIN:"; + public static final String ALL = "PENALTY:"; + public static final String USER = "PENALTY:USER:"; + public static final String USER_ADMIN = "PENALTY:USER:ADMIN:"; } diff --git a/src/main/java/com/gg/server/admin/rank/service/RankAdminService.java b/src/main/java/com/gg/server/admin/rank/service/RankAdminService.java index ceed91df3..999d6df11 100644 --- a/src/main/java/com/gg/server/admin/rank/service/RankAdminService.java +++ b/src/main/java/com/gg/server/admin/rank/service/RankAdminService.java @@ -1,58 +1,62 @@ -package com.gg.server.admin.rank.service; - -import com.gg.server.admin.season.dto.SeasonAdminDto; -import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.domain.rank.data.Rank; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.season.exception.SeasonForbiddenException; -import com.gg.server.domain.season.exception.SeasonTimeBeforeException; -import com.gg.server.domain.tier.data.Tier; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.User; -import lombok.AllArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -import static com.gg.server.domain.user.type.RoleType.GUEST; - -@Service -@AllArgsConstructor -public class RankAdminService { - private final RankRepository rankRepository; - private final UserAdminRepository userAdminRepository; - private final SeasonRepository seasonRepository; - private final TierRepository tierRepository; - - @Transactional - public void addAllUserRankByNewSeason(SeasonAdminDto seasonAdminDto) { - if (LocalDateTime.now().isAfter(seasonAdminDto.getStartTime())) - throw new SeasonTimeBeforeException(); - List users = userAdminRepository.findAll(); - - List ranks = new ArrayList<>(); - Season season = seasonRepository.findById(seasonAdminDto.getSeasonId()).get(); - Tier tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); - users.forEach(user -> { - if (user.getRoleType() != GUEST) { - Rank userRank = Rank.from(user, season, seasonAdminDto.getStartPpp(), tier); - ranks.add(userRank); - } - }); - rankRepository.saveAll(ranks); - } - - @Transactional - public void deleteAllUserRankBySeason(SeasonAdminDto seasonAdminDto) { - if (LocalDateTime.now().isAfter(seasonAdminDto.getStartTime())) - throw new SeasonForbiddenException(); - - rankRepository.deleteAllBySeasonId(seasonAdminDto.getSeasonId()); - } -} +package com.gg.server.admin.rank.service; + +import static com.gg.server.domain.user.type.RoleType.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.admin.season.dto.SeasonAdminDto; +import com.gg.server.admin.user.data.UserAdminRepository; +import com.gg.server.domain.rank.data.Rank; +import com.gg.server.domain.rank.data.RankRepository; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.data.SeasonRepository; +import com.gg.server.domain.season.exception.SeasonForbiddenException; +import com.gg.server.domain.season.exception.SeasonTimeBeforeException; +import com.gg.server.domain.tier.data.Tier; +import com.gg.server.domain.tier.data.TierRepository; +import com.gg.server.domain.tier.exception.TierNotFoundException; +import com.gg.server.domain.user.data.User; + +import lombok.AllArgsConstructor; + +@Service +@AllArgsConstructor +public class RankAdminService { + private final RankRepository rankRepository; + private final UserAdminRepository userAdminRepository; + private final SeasonRepository seasonRepository; + private final TierRepository tierRepository; + + @Transactional + public void addAllUserRankByNewSeason(SeasonAdminDto seasonAdminDto) { + if (LocalDateTime.now().isAfter(seasonAdminDto.getStartTime())) { + throw new SeasonTimeBeforeException(); + } + List users = userAdminRepository.findAll(); + + List ranks = new ArrayList<>(); + Season season = seasonRepository.findById(seasonAdminDto.getSeasonId()).get(); + Tier tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); + users.forEach(user -> { + if (user.getRoleType() != GUEST) { + Rank userRank = Rank.from(user, season, seasonAdminDto.getStartPpp(), tier); + ranks.add(userRank); + } + }); + rankRepository.saveAll(ranks); + } + + @Transactional + public void deleteAllUserRankBySeason(SeasonAdminDto seasonAdminDto) { + if (LocalDateTime.now().isAfter(seasonAdminDto.getStartTime())) { + throw new SeasonForbiddenException(); + } + + rankRepository.deleteAllBySeasonId(seasonAdminDto.getSeasonId()); + } +} diff --git a/src/main/java/com/gg/server/admin/rank/service/RankRedisAdminService.java b/src/main/java/com/gg/server/admin/rank/service/RankRedisAdminService.java index c8c6a1cca..02ebb98b2 100644 --- a/src/main/java/com/gg/server/admin/rank/service/RankRedisAdminService.java +++ b/src/main/java/com/gg/server/admin/rank/service/RankRedisAdminService.java @@ -1,63 +1,65 @@ -package com.gg.server.admin.rank.service; - -import com.gg.server.admin.season.dto.SeasonAdminDto; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.tier.data.Tier; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import lombok.AllArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -import static com.gg.server.domain.user.type.RoleType.GUEST; - -@Service -@AllArgsConstructor -public class RankRedisAdminService { - private final UserRepository userRepository; - private final RankRedisRepository rankRedisRepository; - private final TierRepository tierRepository; - - @Transactional - public void addAllUserRankByNewSeason(SeasonAdminDto seasonAdminDto) { - List users = userRepository.findAll(); - - String redisHashKey = RedisKeyManager.getHashKey(seasonAdminDto.getSeasonId()); - Tier tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); - - users.forEach(user -> { - if (user.getRoleType() != GUEST) { - UserDto userDto = UserDto.from(user); - RankRedis userRank = RankRedis.from(userDto, seasonAdminDto.getStartPpp(), tier.getImageUri()); - - rankRedisRepository.addRankData(redisHashKey, user.getId(), userRank); - } - }); - } - - @Transactional - public void deleteSeasonRankBySeasonId(Long seasonId) { - String redisHashKey = RedisKeyManager.getHashKey(seasonId); - - rankRedisRepository.deleteHashKey(redisHashKey); - } - - public void updateRankUser(String hashKey, String zsetKey, Long userId, RankRedis userRank) { - rankRedisRepository.updateRankData(hashKey, userId, userRank); - if (userPlayedRank(userRank)){ - rankRedisRepository.deleteFromZSet(zsetKey, userId); - rankRedisRepository.addToZSet(zsetKey, userId, userRank.getPpp()); - } - } - - private boolean userPlayedRank(RankRedis userRank) { - return (userRank.getWins() + userRank.getLosses()) != 0; - } -} +package com.gg.server.admin.rank.service; + +import static com.gg.server.domain.user.type.RoleType.*; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.admin.season.dto.SeasonAdminDto; +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.rank.redis.RedisKeyManager; +import com.gg.server.domain.tier.data.Tier; +import com.gg.server.domain.tier.data.TierRepository; +import com.gg.server.domain.tier.exception.TierNotFoundException; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; + +import lombok.AllArgsConstructor; + +@Service +@AllArgsConstructor +public class RankRedisAdminService { + private final UserRepository userRepository; + private final RankRedisRepository rankRedisRepository; + private final TierRepository tierRepository; + + @Transactional + public void addAllUserRankByNewSeason(SeasonAdminDto seasonAdminDto) { + List users = userRepository.findAll(); + + String redisHashKey = RedisKeyManager.getHashKey(seasonAdminDto.getSeasonId()); + Tier tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); + + users.forEach(user -> { + if (user.getRoleType() != GUEST) { + UserDto userDto = UserDto.from(user); + RankRedis userRank = RankRedis.from(userDto, seasonAdminDto.getStartPpp(), tier.getImageUri()); + + rankRedisRepository.addRankData(redisHashKey, user.getId(), userRank); + } + }); + } + + @Transactional + public void deleteSeasonRankBySeasonId(Long seasonId) { + String redisHashKey = RedisKeyManager.getHashKey(seasonId); + + rankRedisRepository.deleteHashKey(redisHashKey); + } + + public void updateRankUser(String hashKey, String zsetKey, Long userId, RankRedis userRank) { + rankRedisRepository.updateRankData(hashKey, userId, userRank); + if (userPlayedRank(userRank)) { + rankRedisRepository.deleteFromZSet(zsetKey, userId); + rankRedisRepository.addToZSet(zsetKey, userId, userRank.getPpp()); + } + } + + private boolean userPlayedRank(RankRedis userRank) { + return (userRank.getWins() + userRank.getLosses()) != 0; + } +} diff --git a/src/main/java/com/gg/server/admin/receipt/controller/ReceiptAdminController.java b/src/main/java/com/gg/server/admin/receipt/controller/ReceiptAdminController.java index 5f67a94e0..829b25a82 100644 --- a/src/main/java/com/gg/server/admin/receipt/controller/ReceiptAdminController.java +++ b/src/main/java/com/gg/server/admin/receipt/controller/ReceiptAdminController.java @@ -1,9 +1,7 @@ package com.gg.server.admin.receipt.controller; -import com.gg.server.admin.receipt.dto.ReceiptAdminPageRequestDto; -import com.gg.server.admin.receipt.dto.ReceiptListResponseDto; -import com.gg.server.admin.receipt.service.ReceiptAdminService; -import lombok.RequiredArgsConstructor; +import javax.validation.Valid; + import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; @@ -12,24 +10,28 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.validation.Valid; +import com.gg.server.admin.receipt.dto.ReceiptAdminPageRequestDto; +import com.gg.server.admin.receipt.dto.ReceiptListResponseDto; +import com.gg.server.admin.receipt.service.ReceiptAdminService; + +import lombok.RequiredArgsConstructor; @RestController @RequiredArgsConstructor @RequestMapping("/pingpong/admin/receipt") public class ReceiptAdminController { - private final ReceiptAdminService receiptAdminService; + private final ReceiptAdminService receiptAdminService; - @GetMapping - public ReceiptListResponseDto getReceiptList(@ModelAttribute @Valid ReceiptAdminPageRequestDto req) { + @GetMapping + public ReceiptListResponseDto getReceiptList(@ModelAttribute @Valid ReceiptAdminPageRequestDto req) { - if (req.getIntraId() == null) { - Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize(), - Sort.by("createdAt").descending()); - return receiptAdminService.getAllReceipt(pageable); - } - Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize(), - Sort.by("createdAt").descending()); - return receiptAdminService.findByIntraId(req.getIntraId(), pageable); - } -} \ No newline at end of file + if (req.getIntraId() == null) { + Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize(), + Sort.by("createdAt").descending()); + return receiptAdminService.getAllReceipt(pageable); + } + Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize(), + Sort.by("createdAt").descending()); + return receiptAdminService.findByIntraId(req.getIntraId(), pageable); + } +} diff --git a/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepository.java b/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepository.java index 69f387d11..2e0d0879c 100644 --- a/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepository.java +++ b/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepository.java @@ -1,10 +1,11 @@ package com.gg.server.admin.receipt.data; -import com.gg.server.domain.receipt.data.Receipt; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -public interface ReceiptAdminRepository extends JpaRepository, ReceiptAdminRepositorySearch{ - Page findAll(Pageable pageable); +import com.gg.server.domain.receipt.data.Receipt; + +public interface ReceiptAdminRepository extends JpaRepository, ReceiptAdminRepositorySearch { + Page findAll(Pageable pageable); } diff --git a/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepositorySearch.java b/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepositorySearch.java index 4065857a5..2c3a3b218 100644 --- a/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepositorySearch.java +++ b/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepositorySearch.java @@ -1,12 +1,13 @@ package com.gg.server.admin.receipt.data; -import com.gg.server.domain.receipt.data.Receipt; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import com.gg.server.domain.receipt.data.Receipt; + public interface ReceiptAdminRepositorySearch { - @Query(value = "select re from Receipt re where re.purchaserIntraId = :intraId or re.ownerIntraId = :intraId") - Page findReceiptByIntraId(@Param("intraId") String intraId, Pageable pageable); + @Query(value = "select re from Receipt re where re.purchaserIntraId = :intraId or re.ownerIntraId = :intraId") + Page findReceiptByIntraId(@Param("intraId") String intraId, Pageable pageable); } diff --git a/src/main/java/com/gg/server/admin/receipt/dto/ReceiptAdminPageRequestDto.java b/src/main/java/com/gg/server/admin/receipt/dto/ReceiptAdminPageRequestDto.java index 5fcd0db68..8437b9329 100644 --- a/src/main/java/com/gg/server/admin/receipt/dto/ReceiptAdminPageRequestDto.java +++ b/src/main/java/com/gg/server/admin/receipt/dto/ReceiptAdminPageRequestDto.java @@ -1,14 +1,15 @@ package com.gg.server.admin.receipt.dto; import com.gg.server.global.dto.PageRequestDto; + import lombok.Getter; @Getter public class ReceiptAdminPageRequestDto extends PageRequestDto { - private String intraId; + private String intraId; - public ReceiptAdminPageRequestDto(String intraId, Integer page, Integer size) { - super(page, size); - this.intraId = intraId; - } + public ReceiptAdminPageRequestDto(String intraId, Integer page, Integer size) { + super(page, size); + this.intraId = intraId; + } } diff --git a/src/main/java/com/gg/server/admin/receipt/dto/ReceiptListResponseDto.java b/src/main/java/com/gg/server/admin/receipt/dto/ReceiptListResponseDto.java index e994ac244..f9b69c700 100644 --- a/src/main/java/com/gg/server/admin/receipt/dto/ReceiptListResponseDto.java +++ b/src/main/java/com/gg/server/admin/receipt/dto/ReceiptListResponseDto.java @@ -1,15 +1,15 @@ package com.gg.server.admin.receipt.dto; +import java.util.List; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @Getter @NoArgsConstructor @AllArgsConstructor public class ReceiptListResponseDto { - private List receiptList; - private Integer totalPage; + private List receiptList; + private Integer totalPage; } diff --git a/src/main/java/com/gg/server/admin/receipt/dto/ReceiptResponseDto.java b/src/main/java/com/gg/server/admin/receipt/dto/ReceiptResponseDto.java index 41c9e1b44..a10d2b0c3 100644 --- a/src/main/java/com/gg/server/admin/receipt/dto/ReceiptResponseDto.java +++ b/src/main/java/com/gg/server/admin/receipt/dto/ReceiptResponseDto.java @@ -1,47 +1,48 @@ package com.gg.server.admin.receipt.dto; +import java.time.LocalDateTime; + import com.gg.server.domain.item.data.Item; import com.gg.server.domain.receipt.data.Receipt; import com.gg.server.domain.receipt.type.ItemStatus; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; - @Getter @NoArgsConstructor @AllArgsConstructor public class ReceiptResponseDto { - private Long receiptId; - private LocalDateTime createdAt; - private String itemName; - private Integer itemPrice; - private String purchaserIntraId; - private String ownerIntraId; - private ItemStatus itemStatusType; + private Long receiptId; + private LocalDateTime createdAt; + private String itemName; + private Integer itemPrice; + private String purchaserIntraId; + private String ownerIntraId; + private ItemStatus itemStatusType; - public ReceiptResponseDto(Receipt receipt) { - Item item = receipt.getItem(); - this.itemName = item.getName(); - this.itemPrice = item.getPrice() - (item.getPrice() * item.getDiscount() / 100); - this.receiptId = receipt.getId(); - this.createdAt = receipt.getCreatedAt(); - this.purchaserIntraId = receipt.getPurchaserIntraId(); - this.ownerIntraId = receipt.getOwnerIntraId(); - this.itemStatusType = receipt.getStatus(); - } + public ReceiptResponseDto(Receipt receipt) { + Item item = receipt.getItem(); + this.itemName = item.getName(); + this.itemPrice = item.getPrice() - (item.getPrice() * item.getDiscount() / 100); + this.receiptId = receipt.getId(); + this.createdAt = receipt.getCreatedAt(); + this.purchaserIntraId = receipt.getPurchaserIntraId(); + this.ownerIntraId = receipt.getOwnerIntraId(); + this.itemStatusType = receipt.getStatus(); + } - @Override - public String toString() { - return "ReceiptResponseDto{" + - "receiptId=" + receiptId + - ", createdAt=" + createdAt + - ", itemName='" + itemName + '\'' + - ", itemPrice=" + itemPrice + - ", purchaserIntraId='" + purchaserIntraId + '\'' + - ", ownerIntraId='" + ownerIntraId + '\'' + - ", itemStatusType=" + itemStatusType + - '}'; - } + @Override + public String toString() { + return "ReceiptResponseDto{" + + "receiptId=" + receiptId + + ", createdAt=" + createdAt + + ", itemName='" + itemName + '\'' + + ", itemPrice=" + itemPrice + + ", purchaserIntraId='" + purchaserIntraId + '\'' + + ", ownerIntraId='" + ownerIntraId + '\'' + + ", itemStatusType=" + itemStatusType + + '}'; + } } diff --git a/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java b/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java index 9462acbbf..0d397c701 100644 --- a/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java +++ b/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java @@ -1,30 +1,32 @@ package com.gg.server.admin.receipt.service; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.admin.receipt.data.ReceiptAdminRepository; import com.gg.server.admin.receipt.dto.ReceiptListResponseDto; import com.gg.server.admin.receipt.dto.ReceiptResponseDto; import com.gg.server.domain.receipt.data.Receipt; + import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor public class ReceiptAdminService { - private final ReceiptAdminRepository receiptAdminRepository; + private final ReceiptAdminRepository receiptAdminRepository; - @Transactional(readOnly = true) - public ReceiptListResponseDto getAllReceipt(Pageable pageable) { - Page responseDtos = receiptAdminRepository.findAll(pageable).map(ReceiptResponseDto::new); - return new ReceiptListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); - } + @Transactional(readOnly = true) + public ReceiptListResponseDto getAllReceipt(Pageable pageable) { + Page responseDtos = receiptAdminRepository.findAll(pageable).map(ReceiptResponseDto::new); + return new ReceiptListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); + } - @Transactional(readOnly = true) - public ReceiptListResponseDto findByIntraId(String intraId, Pageable pageable) { - Page receipts = receiptAdminRepository.findReceiptByIntraId(intraId, pageable); - Page responseDtos = receipts.map(ReceiptResponseDto::new); - return new ReceiptListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); - } + @Transactional(readOnly = true) + public ReceiptListResponseDto findByIntraId(String intraId, Pageable pageable) { + Page receipts = receiptAdminRepository.findReceiptByIntraId(intraId, pageable); + Page responseDtos = receipts.map(ReceiptResponseDto::new); + return new ReceiptListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); + } } diff --git a/src/main/java/com/gg/server/admin/season/controller/SeasonAdminController.java b/src/main/java/com/gg/server/admin/season/controller/SeasonAdminController.java index 71faca85e..cf67394bf 100644 --- a/src/main/java/com/gg/server/admin/season/controller/SeasonAdminController.java +++ b/src/main/java/com/gg/server/admin/season/controller/SeasonAdminController.java @@ -1,49 +1,60 @@ package com.gg.server.admin.season.controller; +import java.util.List; + +import javax.validation.Valid; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.gg.server.admin.season.dto.SeasonAdminDto; import com.gg.server.admin.season.dto.SeasonCreateRequestDto; +import com.gg.server.admin.season.dto.SeasonListAdminResponseDto; import com.gg.server.admin.season.dto.SeasonUpdateRequestDto; import com.gg.server.admin.season.service.SeasonAdminService; -import com.gg.server.admin.season.dto.SeasonAdminDto; -import com.gg.server.admin.season.dto.SeasonListAdminResponseDto; -import lombok.AllArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; -import java.util.List; +import lombok.AllArgsConstructor; @RestController @RequestMapping(value = "/pingpong/admin") @AllArgsConstructor public class SeasonAdminController { - private final SeasonAdminService seasonAdminService; + private final SeasonAdminService seasonAdminService; - @GetMapping(value = "/seasons") - public SeasonListAdminResponseDto rankSeasonList() { - List seasons = seasonAdminService.findAllSeasons(); + @GetMapping(value = "/seasons") + public SeasonListAdminResponseDto rankSeasonList() { + List seasons = seasonAdminService.findAllSeasons(); - return new SeasonListAdminResponseDto(seasons); - } + return new SeasonListAdminResponseDto(seasons); + } - @PostMapping(value = "/seasons") - public synchronized ResponseEntity createSeason(@Valid @RequestBody SeasonCreateRequestDto seasonCreateReqeustDto) { - seasonAdminService.createSeason(seasonCreateReqeustDto); + @PostMapping(value = "/seasons") + public synchronized ResponseEntity createSeason(@Valid @RequestBody SeasonCreateRequestDto seasonCreateReqeustDto) { + seasonAdminService.createSeason(seasonCreateReqeustDto); - return new ResponseEntity(HttpStatus.CREATED); - } + return new ResponseEntity(HttpStatus.CREATED); + } - @DeleteMapping(value = "/seasons/{seasonId}") - public synchronized ResponseEntity deleteSeason(@PathVariable Long seasonId) { - seasonAdminService.deleteSeason(seasonId); + @DeleteMapping(value = "/seasons/{seasonId}") + public synchronized ResponseEntity deleteSeason(@PathVariable Long seasonId) { + seasonAdminService.deleteSeason(seasonId); - return new ResponseEntity(HttpStatus.NO_CONTENT); - } + return new ResponseEntity(HttpStatus.NO_CONTENT); + } - @PutMapping(value = "/seasons/{seasonId}") - public synchronized ResponseEntity updateSeason(@PathVariable Long seasonId, @RequestBody SeasonUpdateRequestDto seasonUpdateRequestDto) { - seasonAdminService.updateSeason(seasonId, seasonUpdateRequestDto); + @PutMapping(value = "/seasons/{seasonId}") + public synchronized ResponseEntity updateSeason(@PathVariable Long seasonId, + @RequestBody SeasonUpdateRequestDto seasonUpdateRequestDto) { + seasonAdminService.updateSeason(seasonId, seasonUpdateRequestDto); - return new ResponseEntity(HttpStatus.NO_CONTENT); - } + return new ResponseEntity(HttpStatus.NO_CONTENT); + } } diff --git a/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java b/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java index 171c8fd13..0f3a8b28b 100644 --- a/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java +++ b/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java @@ -1,22 +1,25 @@ package com.gg.server.admin.season.data; -import com.gg.server.domain.season.data.Season; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; + 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; -import java.util.Optional; +import com.gg.server.domain.season.data.Season; public interface SeasonAdminRepository extends JpaRepository { - /* 입력시간과 모드로 입력시간 이후 가장 가까운 시즌 가져오기 */ - @Query("SELECT e FROM Season e WHERE e.startTime > :targetTime ORDER BY e.startTime ASC") - List findAfterSeasons(@Param("targetTime") LocalDateTime targetTime); - @Query("SELECT e FROM Season e WHERE e.startTime < :targetTime ORDER BY e.startTime DESC") - List findBeforeSeasons(@Param("targetTime") LocalDateTime targetTime); - @Query("select s from Season s where s.startTime <= :now and s.endTime >= :now") - Optional findCurrentSeason(@Param("now") LocalDateTime now); + /* 입력시간과 모드로 입력시간 이후 가장 가까운 시즌 가져오기 */ + @Query("SELECT e FROM Season e WHERE e.startTime > :targetTime ORDER BY e.startTime ASC") + List findAfterSeasons(@Param("targetTime") LocalDateTime targetTime); + + @Query("SELECT e FROM Season e WHERE e.startTime < :targetTime ORDER BY e.startTime DESC") + List findBeforeSeasons(@Param("targetTime") LocalDateTime targetTime); + + @Query("select s from Season s where s.startTime <= :now and s.endTime >= :now") + Optional findCurrentSeason(@Param("now") LocalDateTime now); - List findAllByOrderByStartTimeDesc(); + List findAllByOrderByStartTimeDesc(); } diff --git a/src/main/java/com/gg/server/admin/season/dto/SeasonAdminDto.java b/src/main/java/com/gg/server/admin/season/dto/SeasonAdminDto.java index c4a385b8e..1db9a9e24 100644 --- a/src/main/java/com/gg/server/admin/season/dto/SeasonAdminDto.java +++ b/src/main/java/com/gg/server/admin/season/dto/SeasonAdminDto.java @@ -1,42 +1,46 @@ package com.gg.server.admin.season.dto; +import java.time.LocalDateTime; + import com.gg.server.admin.season.type.SeasonStatus; import com.gg.server.domain.season.data.Season; -import lombok.*; -import java.time.LocalDateTime; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; @Getter @AllArgsConstructor @NoArgsConstructor public class SeasonAdminDto { - private Long seasonId; - private String seasonName; - private LocalDateTime startTime; - private LocalDateTime endTime; - private Integer startPpp; - private Integer pppGap; - private String status; - - public SeasonAdminDto(Season season) { - this.seasonId = season.getId(); - this.seasonName = season.getSeasonName(); - this.startTime = season.getStartTime(); - this.endTime = season.getEndTime(); - this.startPpp = season.getStartPpp(); - this.pppGap = season.getPppGap(); - this.status = getSeasonStatus(season); - } - - public String getSeasonStatus(Season season) { - LocalDateTime now = LocalDateTime.now(); - - if (now.isAfter(season.getEndTime())) - return SeasonStatus.SEASON_PAST.getSesonstauts(); - else if (now.isAfter(season.getStartTime()) && now.isBefore((season.getEndTime()))) - return SeasonStatus.SEASON_CURRENT.getSesonstauts(); - else - return SeasonStatus.SEASON_FUTURE.getSesonstauts(); - } + private Long seasonId; + private String seasonName; + private LocalDateTime startTime; + private LocalDateTime endTime; + private Integer startPpp; + private Integer pppGap; + private String status; + + public SeasonAdminDto(Season season) { + this.seasonId = season.getId(); + this.seasonName = season.getSeasonName(); + this.startTime = season.getStartTime(); + this.endTime = season.getEndTime(); + this.startPpp = season.getStartPpp(); + this.pppGap = season.getPppGap(); + this.status = getSeasonStatus(season); + } + + public String getSeasonStatus(Season season) { + LocalDateTime now = LocalDateTime.now(); + + if (now.isAfter(season.getEndTime())) { + return SeasonStatus.SEASON_PAST.getSeasonStatus(); + } else if (now.isAfter(season.getStartTime()) && now.isBefore((season.getEndTime()))) { + return SeasonStatus.SEASON_CURRENT.getSeasonStatus(); + } else { + return SeasonStatus.SEASON_FUTURE.getSeasonStatus(); + } + } } diff --git a/src/main/java/com/gg/server/admin/season/dto/SeasonCreateRequestDto.java b/src/main/java/com/gg/server/admin/season/dto/SeasonCreateRequestDto.java index d24f7e0a4..055f1514d 100644 --- a/src/main/java/com/gg/server/admin/season/dto/SeasonCreateRequestDto.java +++ b/src/main/java/com/gg/server/admin/season/dto/SeasonCreateRequestDto.java @@ -1,38 +1,40 @@ package com.gg.server.admin.season.dto; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; import javax.validation.constraints.Future; import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; + +import org.springframework.format.annotation.DateTimeFormat; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; @Getter @AllArgsConstructor @NoArgsConstructor public class SeasonCreateRequestDto { - @NotNull(message = "plz. seasonName") - private String seasonName; - - @NotNull(message = "plz. startTime") - @Future(message = "불가능한 예약시점입니다.") - @DateTimeFormat(iso = DateTimeFormat.ISO.TIME) - private LocalDateTime startTime; - - @NotNull(message = "plz. startPpp") - private Integer startPpp; - - @NotNull(message = "plz. pppGap") - private Integer pppGap; - - public String toString() { - return "SeasonCreateRequestAdminDto{" + '\'' + - "seasonName=" + seasonName + '\'' + - ", startTime=" + startTime + - ", startPpp='" + startPpp + '\'' + - ", pppGap='" + pppGap + '\'' + - '}'; - } + @NotNull(message = "plz. seasonName") + private String seasonName; + + @NotNull(message = "plz. startTime") + @Future(message = "불가능한 예약시점입니다.") + @DateTimeFormat(iso = DateTimeFormat.ISO.TIME) + private LocalDateTime startTime; + + @NotNull(message = "plz. startPpp") + private Integer startPpp; + + @NotNull(message = "plz. pppGap") + private Integer pppGap; + + public String toString() { + return "SeasonCreateRequestAdminDto{" + '\'' + + "seasonName=" + seasonName + '\'' + + ", startTime=" + startTime + + ", startPpp='" + startPpp + '\'' + + ", pppGap='" + pppGap + '\'' + + '}'; + } } diff --git a/src/main/java/com/gg/server/admin/season/dto/SeasonListAdminResponseDto.java b/src/main/java/com/gg/server/admin/season/dto/SeasonListAdminResponseDto.java index 43290915f..334d6b0c2 100644 --- a/src/main/java/com/gg/server/admin/season/dto/SeasonListAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/season/dto/SeasonListAdminResponseDto.java @@ -1,17 +1,17 @@ package com.gg.server.admin.season.dto; +import java.util.List; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @Getter @NoArgsConstructor public class SeasonListAdminResponseDto { - List seasonList; + List seasonList; - public SeasonListAdminResponseDto(List seasonList) { - this.seasonList = seasonList; - } + public SeasonListAdminResponseDto(List seasonList) { + this.seasonList = seasonList; + } } diff --git a/src/main/java/com/gg/server/admin/season/dto/SeasonUpdateRequestDto.java b/src/main/java/com/gg/server/admin/season/dto/SeasonUpdateRequestDto.java index 6d2d081bd..51859cbf0 100644 --- a/src/main/java/com/gg/server/admin/season/dto/SeasonUpdateRequestDto.java +++ b/src/main/java/com/gg/server/admin/season/dto/SeasonUpdateRequestDto.java @@ -1,30 +1,32 @@ package com.gg.server.admin.season.dto; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; import javax.validation.constraints.Future; import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; + +import org.springframework.format.annotation.DateTimeFormat; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; @Getter @NoArgsConstructor @AllArgsConstructor public class SeasonUpdateRequestDto { - @NotNull(message = "plz. seasonName") - private String seasonName; + @NotNull(message = "plz. seasonName") + private String seasonName; - @NotNull(message = "plz. startTime") - @Future(message = "불가능한 예약시점입니다.") - @DateTimeFormat(iso = DateTimeFormat.ISO.TIME) - private LocalDateTime startTime; + @NotNull(message = "plz. startTime") + @Future(message = "불가능한 예약시점입니다.") + @DateTimeFormat(iso = DateTimeFormat.ISO.TIME) + private LocalDateTime startTime; - @NotNull(message = "plz. startPpp") - private Integer startPpp; + @NotNull(message = "plz. startPpp") + private Integer startPpp; - @NotNull(message = "plz. pppGap") - private Integer pppGap; + @NotNull(message = "plz. pppGap") + private Integer pppGap; } diff --git a/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java b/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java index aeee8b46d..7bb99bb12 100644 --- a/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java +++ b/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java @@ -1,184 +1,189 @@ package com.gg.server.admin.season.service; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.admin.rank.service.RankAdminService; import com.gg.server.admin.rank.service.RankRedisAdminService; -import com.gg.server.admin.season.dto.SeasonAdminDto; import com.gg.server.admin.season.data.SeasonAdminRepository; +import com.gg.server.admin.season.dto.SeasonAdminDto; import com.gg.server.admin.season.dto.SeasonCreateRequestDto; import com.gg.server.admin.season.dto.SeasonUpdateRequestDto; import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.exception.SeasonForbiddenException; import com.gg.server.domain.season.exception.SeasonNotFoundException; import com.gg.server.domain.season.exception.SeasonTimeBeforeException; -import com.gg.server.global.exception.ErrorCode; -import lombok.AllArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; +import lombok.AllArgsConstructor; @Service @AllArgsConstructor public class SeasonAdminService { - private final SeasonAdminRepository seasonAdminRepository; - private final RankRedisAdminService rankRedisAdminService; - private final RankAdminService rankAdminService; - - public List findAllSeasons() { - List seasons = seasonAdminRepository.findAllByOrderByStartTimeDesc(); - List dtoList = new ArrayList<>(); - for (Season season : seasons) { - SeasonAdminDto dto = new SeasonAdminDto(season); - dtoList.add(dto); - } - return dtoList; - } - - @Transactional - public void createSeason(SeasonCreateRequestDto createDto) { - Season newSeason = new Season(createDto); - - insert(newSeason); - seasonAdminRepository.save(newSeason); - - checkSeasonAtDB(); - - Long seasonId = newSeason.getId(); - SeasonAdminDto seasonAdminDto = findSeasonById(seasonId); - - if (LocalDateTime.now().isBefore(seasonAdminDto.getStartTime())) { - rankAdminService.addAllUserRankByNewSeason(seasonAdminDto); - rankRedisAdminService.addAllUserRankByNewSeason(seasonAdminDto); - } - } - - @Transactional - public SeasonAdminDto findSeasonById(Long seasonId) { - Season season = seasonAdminRepository.findById(seasonId).orElseThrow(()-> new SeasonNotFoundException()); - - return new SeasonAdminDto(season); - } - - - @Transactional - public void deleteSeason(Long seasonId) { - SeasonAdminDto seasonDto = findSeasonById(seasonId); - - Season season = seasonAdminRepository.findById(seasonDto.getSeasonId()) - .orElseThrow(() -> new SeasonNotFoundException()); - detach(season); - - if (LocalDateTime.now().isBefore(seasonDto.getStartTime())) { - rankAdminService.deleteAllUserRankBySeason(seasonDto); - rankRedisAdminService.deleteSeasonRankBySeasonId(seasonDto.getSeasonId()); - seasonAdminRepository.delete(season); - } - checkSeasonAtDB(); - } - - @Transactional - public void updateSeason(Long seasonId, SeasonUpdateRequestDto updateDto) { - Season season = seasonAdminRepository.findById(seasonId) - .orElseThrow(() -> new SeasonNotFoundException()); - - if (LocalDateTime.now().isAfter(season.getStartTime())) - throw new SeasonForbiddenException(); - - if (LocalDateTime.now().isBefore(season.getStartTime())) { - detach(season); - season.setSeasonName(updateDto.getSeasonName()); - season.setStartTime(updateDto.getStartTime()); - season.setStartPpp(updateDto.getStartPpp()); - season.setPppGap(updateDto.getPppGap()); - insert(season); - seasonAdminRepository.save(season); - checkSeasonAtDB(); - } - - SeasonAdminDto seasonAdminDto = findSeasonById(seasonId); - if (LocalDateTime.now().isBefore(seasonAdminDto.getStartTime())) { - rankAdminService.deleteAllUserRankBySeason(seasonAdminDto); - rankAdminService.addAllUserRankByNewSeason(seasonAdminDto); - rankRedisAdminService.deleteSeasonRankBySeasonId(seasonAdminDto.getSeasonId()); - rankRedisAdminService.addAllUserRankByNewSeason(seasonAdminDto); - } - } - - private void insert(Season season) - { - List beforeSeasons = seasonAdminRepository.findBeforeSeasons(season.getStartTime()); - Season beforeSeason; - if (beforeSeasons.isEmpty()) - beforeSeason = null; - else - beforeSeason = beforeSeasons.get(0).getId() != season.getId()? beforeSeasons.get(0) : beforeSeasons.get(1); - List afterSeasons = seasonAdminRepository.findAfterSeasons(season.getStartTime()); - Season afterSeason = afterSeasons.isEmpty() ? null : afterSeasons.get(0); - - if (LocalDateTime.now().plusHours(24).isAfter(season.getStartTime())) - throw new SeasonTimeBeforeException(); - if (beforeSeason != null) { - if (beforeSeason.getStartTime().plusDays(1).isAfter(season.getStartTime())) - throw new SeasonForbiddenException(); - beforeSeason.setEndTime(season.getStartTime().minusSeconds(1)); - } - if (afterSeason != null) - season.setEndTime(afterSeason.getStartTime().minusSeconds(1)); - else - season.setEndTime(LocalDateTime.of(9999, 12, 31, 23, 59, 59)); - } - - private void detach(Season season) - { - List beforeSeasons = seasonAdminRepository.findBeforeSeasons(season.getStartTime()); - Season beforeSeason = beforeSeasons.isEmpty() ? null : beforeSeasons.get(0); - List afterSeasons = seasonAdminRepository.findAfterSeasons(season.getStartTime()); - Season afterSeason = afterSeasons.isEmpty() ? null : afterSeasons.get(0); - - if ((LocalDateTime.now().isAfter(season.getStartTime()) && LocalDateTime.now().isBefore(season.getEndTime())) - || season.getEndTime().isBefore(LocalDateTime.now())) - throw new SeasonForbiddenException(); - if (beforeSeason != null) { - if (afterSeason != null) - beforeSeason.setEndTime(afterSeason.getStartTime().minusSeconds(1)); - else - beforeSeason.setEndTime(LocalDateTime.of(9999, 12, 31, 23, 59, 59)); - } - } - - private void checkSeasonAtDB() - { - List seasons = seasonAdminRepository.findAll(); - for (int i = 0; i < seasons.size(); i++) { - for (int j = i + 1; j < seasons.size(); j++) { - if (isOverlap(seasons.get(i), seasons.get(j))) - throw new SeasonForbiddenException(); - } - } - } - - private boolean isOverlap(Season season1, Season season2) { - LocalDateTime start1 = season1.getStartTime(); - LocalDateTime end1 = season1.getEndTime(); - LocalDateTime start2 = season2.getStartTime(); - LocalDateTime end2 = season2.getEndTime(); - - if (start1.isEqual(end1) || start2.isEqual(end2)) { - return false; - } - // 첫 번째 기간이 두 번째 기간의 이전에 끝날 때 - if (end1.isBefore(start2)) { - return false; - } - - // 첫 번째 기간이 두 번째 기간의 이후에 시작할 때 - if (start1.isAfter(end2)) { - return false; - } - - // 나머지 경우에는 두 기간이 겹칩니다. - return true; - } + private final SeasonAdminRepository seasonAdminRepository; + private final RankRedisAdminService rankRedisAdminService; + private final RankAdminService rankAdminService; + + public List findAllSeasons() { + List seasons = seasonAdminRepository.findAllByOrderByStartTimeDesc(); + List dtoList = new ArrayList<>(); + for (Season season : seasons) { + SeasonAdminDto dto = new SeasonAdminDto(season); + dtoList.add(dto); + } + return dtoList; + } + + @Transactional + public void createSeason(SeasonCreateRequestDto createDto) { + Season newSeason = new Season(createDto); + + insert(newSeason); + seasonAdminRepository.save(newSeason); + + checkSeasonAtDB(); + + Long seasonId = newSeason.getId(); + SeasonAdminDto seasonAdminDto = findSeasonById(seasonId); + + if (LocalDateTime.now().isBefore(seasonAdminDto.getStartTime())) { + rankAdminService.addAllUserRankByNewSeason(seasonAdminDto); + rankRedisAdminService.addAllUserRankByNewSeason(seasonAdminDto); + } + } + + @Transactional + public SeasonAdminDto findSeasonById(Long seasonId) { + Season season = seasonAdminRepository.findById(seasonId).orElseThrow(() -> new SeasonNotFoundException()); + + return new SeasonAdminDto(season); + } + + @Transactional + public void deleteSeason(Long seasonId) { + SeasonAdminDto seasonDto = findSeasonById(seasonId); + + Season season = seasonAdminRepository.findById(seasonDto.getSeasonId()) + .orElseThrow(() -> new SeasonNotFoundException()); + detach(season); + + if (LocalDateTime.now().isBefore(seasonDto.getStartTime())) { + rankAdminService.deleteAllUserRankBySeason(seasonDto); + rankRedisAdminService.deleteSeasonRankBySeasonId(seasonDto.getSeasonId()); + seasonAdminRepository.delete(season); + } + checkSeasonAtDB(); + } + + @Transactional + public void updateSeason(Long seasonId, SeasonUpdateRequestDto updateDto) { + Season season = seasonAdminRepository.findById(seasonId) + .orElseThrow(() -> new SeasonNotFoundException()); + + if (LocalDateTime.now().isAfter(season.getStartTime())) { + throw new SeasonForbiddenException(); + } + + if (LocalDateTime.now().isBefore(season.getStartTime())) { + detach(season); + season.setSeasonName(updateDto.getSeasonName()); + season.setStartTime(updateDto.getStartTime()); + season.setStartPpp(updateDto.getStartPpp()); + season.setPppGap(updateDto.getPppGap()); + insert(season); + seasonAdminRepository.save(season); + checkSeasonAtDB(); + } + + SeasonAdminDto seasonAdminDto = findSeasonById(seasonId); + if (LocalDateTime.now().isBefore(seasonAdminDto.getStartTime())) { + rankAdminService.deleteAllUserRankBySeason(seasonAdminDto); + rankAdminService.addAllUserRankByNewSeason(seasonAdminDto); + rankRedisAdminService.deleteSeasonRankBySeasonId(seasonAdminDto.getSeasonId()); + rankRedisAdminService.addAllUserRankByNewSeason(seasonAdminDto); + } + } + + private void insert(Season season) { + List beforeSeasons = seasonAdminRepository.findBeforeSeasons(season.getStartTime()); + Season beforeSeason; + if (beforeSeasons.isEmpty()) { + beforeSeason = null; + } else { + beforeSeason = beforeSeasons.get(0).getId() != season.getId() ? beforeSeasons.get(0) : beforeSeasons.get(1); + } + List afterSeasons = seasonAdminRepository.findAfterSeasons(season.getStartTime()); + Season afterSeason = afterSeasons.isEmpty() ? null : afterSeasons.get(0); + + if (LocalDateTime.now().plusHours(24).isAfter(season.getStartTime())) { + throw new SeasonTimeBeforeException(); + } + if (beforeSeason != null) { + if (beforeSeason.getStartTime().plusDays(1).isAfter(season.getStartTime())) { + throw new SeasonForbiddenException(); + } + beforeSeason.setEndTime(season.getStartTime().minusSeconds(1)); + } + if (afterSeason != null) { + season.setEndTime(afterSeason.getStartTime().minusSeconds(1)); + } else { + season.setEndTime(LocalDateTime.of(9999, 12, 31, 23, 59, 59)); + } + } + + private void detach(Season season) { + List beforeSeasons = seasonAdminRepository.findBeforeSeasons(season.getStartTime()); + Season beforeSeason = beforeSeasons.isEmpty() ? null : beforeSeasons.get(0); + List afterSeasons = seasonAdminRepository.findAfterSeasons(season.getStartTime()); + Season afterSeason = afterSeasons.isEmpty() ? null : afterSeasons.get(0); + + if ((LocalDateTime.now().isAfter(season.getStartTime()) && LocalDateTime.now().isBefore(season.getEndTime())) + || season.getEndTime().isBefore(LocalDateTime.now())) { + throw new SeasonForbiddenException(); + } + if (beforeSeason != null) { + if (afterSeason != null) { + beforeSeason.setEndTime(afterSeason.getStartTime().minusSeconds(1)); + } else { + beforeSeason.setEndTime(LocalDateTime.of(9999, 12, 31, 23, 59, 59)); + } + } + } + + private void checkSeasonAtDB() { + List seasons = seasonAdminRepository.findAll(); + for (int i = 0; i < seasons.size(); i++) { + for (int j = i + 1; j < seasons.size(); j++) { + if (isOverlap(seasons.get(i), seasons.get(j))) { + throw new SeasonForbiddenException(); + } + } + } + } + + private boolean isOverlap(Season season1, Season season2) { + LocalDateTime start1 = season1.getStartTime(); + LocalDateTime end1 = season1.getEndTime(); + LocalDateTime start2 = season2.getStartTime(); + LocalDateTime end2 = season2.getEndTime(); + + if (start1.isEqual(end1) || start2.isEqual(end2)) { + return false; + } + // 첫 번째 기간이 두 번째 기간의 이전에 끝날 때 + if (end1.isBefore(start2)) { + return false; + } + + // 첫 번째 기간이 두 번째 기간의 이후에 시작할 때 + if (start1.isAfter(end2)) { + return false; + } + + // 나머지 경우에는 두 기간이 겹칩니다. + return true; + } } diff --git a/src/main/java/com/gg/server/admin/season/type/SeasonStatus.java b/src/main/java/com/gg/server/admin/season/type/SeasonStatus.java index 9ed5ba3bc..d2ef056ec 100644 --- a/src/main/java/com/gg/server/admin/season/type/SeasonStatus.java +++ b/src/main/java/com/gg/server/admin/season/type/SeasonStatus.java @@ -3,15 +3,14 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; - @Getter @RequiredArgsConstructor public enum SeasonStatus { - SEASON_PAST("PAST"), - SEASON_CURRENT("CURRENT"), - SEASON_FUTURE("FUTURE"); + SEASON_PAST("PAST"), + SEASON_CURRENT("CURRENT"), + SEASON_FUTURE("FUTURE"); - private final String Sesonstauts; + private final String seasonStatus; } diff --git a/src/main/java/com/gg/server/admin/slotmanagement/controller/SlotAdminController.java b/src/main/java/com/gg/server/admin/slotmanagement/controller/SlotAdminController.java index 427c0938f..b2fef7d1d 100644 --- a/src/main/java/com/gg/server/admin/slotmanagement/controller/SlotAdminController.java +++ b/src/main/java/com/gg/server/admin/slotmanagement/controller/SlotAdminController.java @@ -1,39 +1,46 @@ package com.gg.server.admin.slotmanagement.controller; +import javax.validation.Valid; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import com.gg.server.admin.slotmanagement.dto.SlotCreateRequestDto; import com.gg.server.admin.slotmanagement.dto.SlotListAdminResponseDto; import com.gg.server.admin.slotmanagement.service.SlotAdminService; + import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; @Slf4j @RestController @RequiredArgsConstructor @RequestMapping("/pingpong/admin/slot-management") public class SlotAdminController { - private final SlotAdminService slotAdminService; + private final SlotAdminService slotAdminService; - @GetMapping - public SlotListAdminResponseDto getSlotSetting() { + @GetMapping + public SlotListAdminResponseDto getSlotSetting() { - return slotAdminService.getSlotSetting(); - } + return slotAdminService.getSlotSetting(); + } - @PostMapping - public synchronized ResponseEntity addSlotSetting(@Valid @RequestBody SlotCreateRequestDto requestDto){ - slotAdminService.addSlotSetting(requestDto); - return new ResponseEntity(HttpStatus.CREATED); - } + @PostMapping + public synchronized ResponseEntity addSlotSetting(@Valid @RequestBody SlotCreateRequestDto requestDto) { + slotAdminService.addSlotSetting(requestDto); + return new ResponseEntity(HttpStatus.CREATED); + } - @DeleteMapping - public synchronized ResponseEntity delSlotSetting(){ - slotAdminService.delSlotSetting(); - return new ResponseEntity(HttpStatus.NO_CONTENT); - } + @DeleteMapping + public synchronized ResponseEntity delSlotSetting() { + slotAdminService.delSlotSetting(); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } } diff --git a/src/main/java/com/gg/server/admin/slotmanagement/data/AdminSlotManagementsRepository.java b/src/main/java/com/gg/server/admin/slotmanagement/data/AdminSlotManagementsRepository.java new file mode 100644 index 000000000..c029b281a --- /dev/null +++ b/src/main/java/com/gg/server/admin/slotmanagement/data/AdminSlotManagementsRepository.java @@ -0,0 +1,23 @@ +package com.gg.server.admin.slotmanagement.data; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +import com.gg.server.domain.slotmanagement.SlotManagement; + +public interface AdminSlotManagementsRepository extends JpaRepository { + @Query("select slot from SlotManagement slot " + + "where slot.endTime > :nowTime or slot.startTime > :nowTime or slot.endTime = null " + + "order by slot.startTime desc") + List findAfterNowSlotManagement(@Param("nowTime") LocalDateTime nowTime); + + List findAllByOrderByCreatedAtDesc(); + + Optional findFirstByOrderByIdDesc(); + +} diff --git a/src/main/java/com/gg/server/admin/slotmanagement/data/adminSlotManagementRepository.java b/src/main/java/com/gg/server/admin/slotmanagement/data/adminSlotManagementRepository.java deleted file mode 100644 index bdc7ad793..000000000 --- a/src/main/java/com/gg/server/admin/slotmanagement/data/adminSlotManagementRepository.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.gg.server.admin.slotmanagement.data; - -import com.gg.server.domain.slotmanagement.SlotManagement; -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; -import java.util.Optional; - -public interface adminSlotManagementRepository extends JpaRepository { - @Query("select slot from SlotManagement slot where slot.endTime > :nowTime or slot.startTime > :nowTime or slot.endTime = null order by slot.startTime desc") - List findAfterNowSlotManagement(@Param("nowTime")LocalDateTime nowTime); - - List findAllByOrderByCreatedAtDesc(); - - Optional findFirstByOrderByIdDesc(); - -} diff --git a/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotAdminDto.java b/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotAdminDto.java index 6b57e7b72..07853d666 100644 --- a/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotAdminDto.java +++ b/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotAdminDto.java @@ -1,34 +1,35 @@ package com.gg.server.admin.slotmanagement.dto; +import java.time.LocalDateTime; + import com.gg.server.domain.slotmanagement.SlotManagement; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; - @Getter @AllArgsConstructor @NoArgsConstructor public class SlotAdminDto { - private Integer pastSlotTime; + private Integer pastSlotTime; - private Integer futureSlotTime; + private Integer futureSlotTime; - private Integer interval; + private Integer interval; - private Integer openMinute; + private Integer openMinute; - private LocalDateTime startTime; + private LocalDateTime startTime; - private LocalDateTime endTime; + private LocalDateTime endTime; - public SlotAdminDto(SlotManagement slotManagement) { - this.pastSlotTime = slotManagement.getPastSlotTime(); - this.futureSlotTime = slotManagement.getFutureSlotTime(); - this.interval = slotManagement.getGameInterval(); - this.openMinute = slotManagement.getOpenMinute(); - this.startTime = slotManagement.getStartTime(); - this.endTime = slotManagement.getEndTime(); - } + public SlotAdminDto(SlotManagement slotManagement) { + this.pastSlotTime = slotManagement.getPastSlotTime(); + this.futureSlotTime = slotManagement.getFutureSlotTime(); + this.interval = slotManagement.getGameInterval(); + this.openMinute = slotManagement.getOpenMinute(); + this.startTime = slotManagement.getStartTime(); + this.endTime = slotManagement.getEndTime(); + } } diff --git a/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotCreateRequestDto.java b/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotCreateRequestDto.java index 64aad8f73..4cf6b9bee 100644 --- a/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotCreateRequestDto.java +++ b/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotCreateRequestDto.java @@ -1,45 +1,47 @@ package com.gg.server.admin.slotmanagement.dto; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; import javax.validation.constraints.Future; import javax.validation.constraints.NotNull; import javax.validation.constraints.PositiveOrZero; -import java.time.LocalDateTime; + +import org.springframework.format.annotation.DateTimeFormat; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; @Getter @AllArgsConstructor @NoArgsConstructor public class SlotCreateRequestDto { - @NotNull(message = "Nothing pastSlotTime") - @PositiveOrZero(message = "plz. Positive Or Zero") - private Integer pastSlotTime; - - @NotNull(message = "Nothing futureSlotTime") - @PositiveOrZero(message = "plz. Positive Or Zero") - private Integer futureSlotTime; - - @NotNull(message = "Nothing interval") - @PositiveOrZero(message = "plz. Positive Or Zero") - private Integer interval; - - @NotNull(message = "Nothing openMinute") - @PositiveOrZero(message = "plz. Positive Or Zero") - private Integer openMinute; - - @NotNull(message = "Nothing startTime") - @Future(message = "불가능한 예약시점입니다.") - @DateTimeFormat(iso = DateTimeFormat.ISO.TIME) - private LocalDateTime startTime; - - public void updateStartTime(){ - LocalDateTime setStartTime = LocalDateTime.of( - this.startTime.getYear(), this.startTime.getMonth(), - this.startTime.getDayOfMonth(), this.startTime.getHour(), 0); - this.startTime = setStartTime; - } + @NotNull(message = "Nothing pastSlotTime") + @PositiveOrZero(message = "plz. Positive Or Zero") + private Integer pastSlotTime; + + @NotNull(message = "Nothing futureSlotTime") + @PositiveOrZero(message = "plz. Positive Or Zero") + private Integer futureSlotTime; + + @NotNull(message = "Nothing interval") + @PositiveOrZero(message = "plz. Positive Or Zero") + private Integer interval; + + @NotNull(message = "Nothing openMinute") + @PositiveOrZero(message = "plz. Positive Or Zero") + private Integer openMinute; + + @NotNull(message = "Nothing startTime") + @Future(message = "불가능한 예약시점입니다.") + @DateTimeFormat(iso = DateTimeFormat.ISO.TIME) + private LocalDateTime startTime; + + public void updateStartTime() { + LocalDateTime setStartTime = LocalDateTime.of( + this.startTime.getYear(), this.startTime.getMonth(), + this.startTime.getDayOfMonth(), this.startTime.getHour(), 0); + this.startTime = setStartTime; + } } diff --git a/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotListAdminResponseDto.java b/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotListAdminResponseDto.java index 2149c9f0c..aea0e9440 100644 --- a/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotListAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotListAdminResponseDto.java @@ -1,16 +1,16 @@ package com.gg.server.admin.slotmanagement.dto; +import java.util.List; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @Getter @NoArgsConstructor public class SlotListAdminResponseDto { - List slotList; + List slotList; - public SlotListAdminResponseDto(List slotList) { - this.slotList = slotList; - } + public SlotListAdminResponseDto(List slotList) { + this.slotList = slotList; + } } diff --git a/src/main/java/com/gg/server/admin/slotmanagement/service/SlotAdminService.java b/src/main/java/com/gg/server/admin/slotmanagement/service/SlotAdminService.java index 046dc7127..44c253b49 100644 --- a/src/main/java/com/gg/server/admin/slotmanagement/service/SlotAdminService.java +++ b/src/main/java/com/gg/server/admin/slotmanagement/service/SlotAdminService.java @@ -1,81 +1,91 @@ package com.gg.server.admin.slotmanagement.service; -import com.gg.server.admin.slotmanagement.data.adminSlotManagementRepository; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.admin.slotmanagement.data.AdminSlotManagementsRepository; import com.gg.server.admin.slotmanagement.dto.SlotAdminDto; import com.gg.server.admin.slotmanagement.dto.SlotCreateRequestDto; import com.gg.server.admin.slotmanagement.dto.SlotListAdminResponseDto; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.exception.SlotManagementForbiddenException; import com.gg.server.domain.slotmanagement.exception.SlotManagementNotFoundException; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; +import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class SlotAdminService { - private final adminSlotManagementRepository adminSlotManagementRepository; - - @Transactional(readOnly = true) - public SlotListAdminResponseDto getSlotSetting() { - List slotManagements = adminSlotManagementRepository.findAfterNowSlotManagement(LocalDateTime.now()); - List dtoList = new ArrayList<>(); - for (SlotManagement slot : slotManagements) { - SlotAdminDto dto = new SlotAdminDto(slot); - dtoList.add(dto); - } - return new SlotListAdminResponseDto(dtoList); - } - - @Transactional - public void addSlotSetting(SlotCreateRequestDto requestDto) { - checkVaildSlotManagement(requestDto); - requestDto.updateStartTime(); - updateNowSlotManagementEndTime(requestDto.getStartTime()); - SlotManagement slotManagement = new SlotManagement(requestDto); - - adminSlotManagementRepository.save(slotManagement); - } - - @Transactional - public void delSlotSetting() { - List slotManagements = adminSlotManagementRepository.findAfterNowSlotManagement(LocalDateTime.now()); - - SlotManagement slotManagement = slotManagements.get(0); - if (LocalDateTime.now().isAfter(slotManagement.getStartTime())) - throw new SlotManagementForbiddenException(); - adminSlotManagementRepository.delete(slotManagement); - - SlotManagement beforeSlotManagement = slotManagements.get(1); - beforeSlotManagement.setNullEndTime(); - } - - private void checkVaildSlotManagement(SlotCreateRequestDto requestDto) { - if (requestDto.getPastSlotTime() > 23) - throw new SlotManagementForbiddenException(); - if (requestDto.getFutureSlotTime() > 12) - throw new SlotManagementForbiddenException(); - if (60 % requestDto.getInterval() != 0 || requestDto.getInterval() % 5 != 0) - throw new SlotManagementForbiddenException(); - if (requestDto.getPastSlotTime() > requestDto.getInterval()) - throw new SlotManagementForbiddenException(); - } - - private void updateNowSlotManagementEndTime(LocalDateTime endTime){ - SlotManagement nowSlotManagement = adminSlotManagementRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new SlotManagementNotFoundException()); - - LocalDateTime nowFutureSlotTime = LocalDateTime.now().isAfter(nowSlotManagement.getStartTime()) - ?LocalDateTime.now().plusHours(nowSlotManagement.getFutureSlotTime()) - :nowSlotManagement.getStartTime().plusHours(nowSlotManagement.getFutureSlotTime()); - - if (nowFutureSlotTime.isAfter(endTime)) - throw new SlotManagementForbiddenException(); - - nowSlotManagement.updateEndTime(endTime); - } + private final AdminSlotManagementsRepository adminSlotManagementRepository; + + @Transactional(readOnly = true) + public SlotListAdminResponseDto getSlotSetting() { + List slotManagements = adminSlotManagementRepository.findAfterNowSlotManagement( + LocalDateTime.now()); + List dtoList = new ArrayList<>(); + for (SlotManagement slot : slotManagements) { + SlotAdminDto dto = new SlotAdminDto(slot); + dtoList.add(dto); + } + return new SlotListAdminResponseDto(dtoList); + } + + @Transactional + public void addSlotSetting(SlotCreateRequestDto requestDto) { + checkVaildSlotManagement(requestDto); + requestDto.updateStartTime(); + updateNowSlotManagementEndTime(requestDto.getStartTime()); + SlotManagement slotManagement = new SlotManagement(requestDto); + + adminSlotManagementRepository.save(slotManagement); + } + + @Transactional + public void delSlotSetting() { + List slotManagements = adminSlotManagementRepository.findAfterNowSlotManagement( + LocalDateTime.now()); + + SlotManagement slotManagement = slotManagements.get(0); + if (LocalDateTime.now().isAfter(slotManagement.getStartTime())) { + throw new SlotManagementForbiddenException(); + } + adminSlotManagementRepository.delete(slotManagement); + + SlotManagement beforeSlotManagement = slotManagements.get(1); + beforeSlotManagement.setNullEndTime(); + } + + private void checkVaildSlotManagement(SlotCreateRequestDto requestDto) { + if (requestDto.getPastSlotTime() > 23) { + throw new SlotManagementForbiddenException(); + } + if (requestDto.getFutureSlotTime() > 12) { + throw new SlotManagementForbiddenException(); + } + if (60 % requestDto.getInterval() != 0 || requestDto.getInterval() % 5 != 0) { + throw new SlotManagementForbiddenException(); + } + if (requestDto.getPastSlotTime() > requestDto.getInterval()) { + throw new SlotManagementForbiddenException(); + } + } + + private void updateNowSlotManagementEndTime(LocalDateTime endTime) { + SlotManagement nowSlotManagement = adminSlotManagementRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new SlotManagementNotFoundException()); + + LocalDateTime nowFutureSlotTime = LocalDateTime.now().isAfter(nowSlotManagement.getStartTime()) + ? LocalDateTime.now().plusHours(nowSlotManagement.getFutureSlotTime()) + : nowSlotManagement.getStartTime().plusHours(nowSlotManagement.getFutureSlotTime()); + + if (nowFutureSlotTime.isAfter(endTime)) { + throw new SlotManagementForbiddenException(); + } + + nowSlotManagement.updateEndTime(endTime); + } } diff --git a/src/main/java/com/gg/server/admin/team/data/TeamAdminRepository.java b/src/main/java/com/gg/server/admin/team/data/TeamAdminRepository.java index 9fd091379..d16b8fa2c 100644 --- a/src/main/java/com/gg/server/admin/team/data/TeamAdminRepository.java +++ b/src/main/java/com/gg/server/admin/team/data/TeamAdminRepository.java @@ -1,12 +1,13 @@ package com.gg.server.admin.team.data; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.team.data.Team; +import java.util.List; + import org.springframework.data.jpa.repository.JpaRepository; -import java.util.List; +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.team.data.Team; public interface TeamAdminRepository extends JpaRepository { - List findAllByGame(Game game); + List findAllByGame(Game game); } diff --git a/src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java b/src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java index 0fe3650fa..088988a63 100644 --- a/src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java +++ b/src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java @@ -1,17 +1,18 @@ -package com.gg.server.admin.team.data; - -import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.user.data.User; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; - -import java.util.List; - -public interface TeamUserAdminRepository extends JpaRepository { - @Query("SELECT tu.user FROM TeamUser tu WHERE tu.team.id = :teamId") - List findUsersByTeamId(@Param("teamId") Long teamId); - - @Query("SELECT tu FROM TeamUser tu JOIN FETCH tu.team t JOIN FETCH tu.user WHERE tu.team.id IN (:teamId)") - List findUsersByTeamIdIn(@Param("teamId") List teamId); -} +package com.gg.server.admin.team.data; + +import java.util.List; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +import com.gg.server.domain.team.data.TeamUser; +import com.gg.server.domain.user.data.User; + +public interface TeamUserAdminRepository extends JpaRepository { + @Query("SELECT tu.user FROM TeamUser tu WHERE tu.team.id = :teamId") + List findUsersByTeamId(@Param("teamId") Long teamId); + + @Query("SELECT tu FROM TeamUser tu JOIN FETCH tu.team t JOIN FETCH tu.user WHERE tu.team.id IN (:teamId)") + List findUsersByTeamIdIn(@Param("teamId") List teamId); +} diff --git a/src/main/java/com/gg/server/admin/tournament/controller/TournamentAdminController.java b/src/main/java/com/gg/server/admin/tournament/controller/TournamentAdminController.java index 6117eaa72..47e0e8ecc 100644 --- a/src/main/java/com/gg/server/admin/tournament/controller/TournamentAdminController.java +++ b/src/main/java/com/gg/server/admin/tournament/controller/TournamentAdminController.java @@ -1,113 +1,132 @@ package com.gg.server.admin.tournament.controller; -import com.gg.server.admin.tournament.dto.*; -import com.gg.server.admin.tournament.service.TournamentAdminService; import javax.validation.Valid; - -import com.gg.server.domain.tournament.dto.TournamentUserListResponseDto; -import lombok.AllArgsConstructor; import javax.validation.constraints.Positive; + import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.gg.server.admin.tournament.dto.TournamentAdminAddUserRequestDto; +import com.gg.server.admin.tournament.dto.TournamentAdminAddUserResponseDto; +import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; +import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; +import com.gg.server.admin.tournament.dto.TournamentGameUpdateRequestDto; +import com.gg.server.admin.tournament.service.TournamentAdminService; +import com.gg.server.domain.tournament.dto.TournamentUserListResponseDto; + +import lombok.AllArgsConstructor; @RestController @AllArgsConstructor @RequestMapping("/pingpong/admin/tournaments") @Validated public class TournamentAdminController { - private final TournamentAdminService tournamentAdminService; - - /*** - * 토너먼트 생성 - * @param tournamentAdminCreateRequestDto 생성에 필요한 데이터 - * @return "CREATED" 응답 코드 - */ - @PostMapping() - public ResponseEntity createTournament(@RequestBody @Valid TournamentAdminCreateRequestDto tournamentAdminCreateRequestDto) { - tournamentAdminService.createTournament(tournamentAdminCreateRequestDto); - return ResponseEntity.status(HttpStatus.CREATED).build(); - } - - /** - *

토너먼트 정보 수정

- * @param tournamentId 업데이트 하고자 하는 토너먼트 id - * @param tournamentAdminUpdateRequestDto 요청 데이터 - * @return HttpStatus.NO_CONTENT - */ - @PatchMapping("/{tournamentId}") - public ResponseEntity updateTournamentInfo(@PathVariable @Positive Long tournamentId, - @Valid @RequestBody TournamentAdminUpdateRequestDto tournamentAdminUpdateRequestDto) { - tournamentAdminService.updateTournamentInfo(tournamentId, tournamentAdminUpdateRequestDto); - - return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); - } - - /** - *

토너먼트 정보 삭제

- * @param tournamentId 삭제하고자 하는 토너먼트 id - * @return HttpStatus.NO_CONTENT - */ - @DeleteMapping("/{tournamentId}") - public ResponseEntity deleteTournament(@PathVariable @Positive Long tournamentId) { - tournamentAdminService.deleteTournament(tournamentId); - - return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); - } - - /** - *

토너먼트 유저 추가

- *

이미 해당 토너먼트에 참여중이거나 대기자인 유저는 신청할 수 없다.

- * @param tournamentId 유저를 추가할 토너먼트 id - * @param tournamentAdminUserAddRequestDto 요청 데이터 - * @return TournamentAdminAddUserResponseDto, HttpStatus.CREATED - */ - @PostMapping("/{tournamentId}/users") - public ResponseEntity addTournamentUser(@PathVariable @Positive Long tournamentId, - @Valid @RequestBody TournamentAdminAddUserRequestDto tournamentAdminUserAddRequestDto) { - TournamentAdminAddUserResponseDto responseDto = tournamentAdminService.addTournamentUser(tournamentId, tournamentAdminUserAddRequestDto); - - return ResponseEntity.status(HttpStatus.CREATED).body(responseDto); - } - - /** - *

토너먼트 유저 조회

- * @param tournamentId 유저를 조회할 토너먼트 id - * @param isJoined 참여중인 유저만 조회할지 여부 - * @return TournamentUserListResponseDto - */ - @GetMapping("/{tournamentId}/users") - public ResponseEntity getTournamentUserList(@PathVariable @Positive Long tournamentId, - @RequestParam(required = false) Boolean isJoined) { - TournamentUserListResponseDto responseDto = tournamentAdminService.getTournamentUserList(tournamentId, isJoined); - return ResponseEntity.status(HttpStatus.OK).body(responseDto); - } - - /** - *

관리자 토너먼트 유저 삭제

- *

토너먼트 유저를 삭제시켜 주며, 참가자가 삭제되는 경우 상황에 따라 대기자를 참가자로 바꾸어준다.

- * @param tournamentId 타겟 토너먼트 id - * @param userId 타겟 유저 id - */ - @DeleteMapping("/{tournamentId}/users/{userId}") - public ResponseEntity deleteTournamentUser(@PathVariable @Positive Long tournamentId, - @PathVariable @Positive Long userId) { - tournamentAdminService.deleteTournamentUser(tournamentId, userId); - - return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); - } - - /** - *

토너먼트 게임 점수 정보 수정

- * @param tournamentId 타겟 토너먼트 id - * @param tournamentGameUpdateReqDto 수정할 게임 정보 - * @return HttpStatus.OK - */ - @PatchMapping("{tournamentId}/games") - public ResponseEntity updateTournamentGame(@PathVariable @Positive Long tournamentId, - @Valid @RequestBody TournamentGameUpdateRequestDto tournamentGameUpdateReqDto) { - tournamentAdminService.updateTournamentGame(tournamentId, tournamentGameUpdateReqDto); - return ResponseEntity.status(HttpStatus.OK).build(); - } + private final TournamentAdminService tournamentAdminService; + + /*** + * 토너먼트 생성 + * @param tournamentAdminCreateRequestDto 생성에 필요한 데이터 + * @return "CREATED" 응답 코드 + */ + @PostMapping() + public ResponseEntity createTournament( + @RequestBody @Valid TournamentAdminCreateRequestDto tournamentAdminCreateRequestDto) { + tournamentAdminService.createTournament(tournamentAdminCreateRequestDto); + return ResponseEntity.status(HttpStatus.CREATED).build(); + } + + /** + *

토너먼트 정보 수정

+ * @param tournamentId 업데이트 하고자 하는 토너먼트 id + * @param tournamentAdminUpdateRequestDto 요청 데이터 + * @return HttpStatus.NO_CONTENT + */ + @PatchMapping("/{tournamentId}") + public ResponseEntity updateTournamentInfo(@PathVariable @Positive Long tournamentId, + @Valid @RequestBody TournamentAdminUpdateRequestDto tournamentAdminUpdateRequestDto) { + tournamentAdminService.updateTournamentInfo(tournamentId, tournamentAdminUpdateRequestDto); + + return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); + } + + /** + *

토너먼트 정보 삭제

+ * @param tournamentId 삭제하고자 하는 토너먼트 id + * @return HttpStatus.NO_CONTENT + */ + @DeleteMapping("/{tournamentId}") + public ResponseEntity deleteTournament(@PathVariable @Positive Long tournamentId) { + tournamentAdminService.deleteTournament(tournamentId); + + return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); + } + + /** + *

토너먼트 유저 추가

+ *

이미 해당 토너먼트에 참여중이거나 대기자인 유저는 신청할 수 없다.

+ * @param tournamentId 유저를 추가할 토너먼트 id + * @param tournamentAdminUserAddRequestDto 요청 데이터 + * @return TournamentAdminAddUserResponseDto, HttpStatus.CREATED + */ + @PostMapping("/{tournamentId}/users") + public ResponseEntity addTournamentUser( + @PathVariable @Positive Long tournamentId, + @Valid @RequestBody TournamentAdminAddUserRequestDto tournamentAdminUserAddRequestDto) { + TournamentAdminAddUserResponseDto responseDto = tournamentAdminService.addTournamentUser(tournamentId, + tournamentAdminUserAddRequestDto); + + return ResponseEntity.status(HttpStatus.CREATED).body(responseDto); + } + + /** + *

토너먼트 유저 조회

+ * @param tournamentId 유저를 조회할 토너먼트 id + * @param isJoined 참여중인 유저만 조회할지 여부 + * @return TournamentUserListResponseDto + */ + @GetMapping("/{tournamentId}/users") + public ResponseEntity getTournamentUserList( + @PathVariable @Positive Long tournamentId, + @RequestParam(required = false) Boolean isJoined) { + TournamentUserListResponseDto responseDto = tournamentAdminService.getTournamentUserList(tournamentId, + isJoined); + return ResponseEntity.status(HttpStatus.OK).body(responseDto); + } + + /** + *

관리자 토너먼트 유저 삭제

+ *

토너먼트 유저를 삭제시켜 주며, 참가자가 삭제되는 경우 상황에 따라 대기자를 참가자로 바꾸어준다.

+ * @param tournamentId 타겟 토너먼트 id + * @param userId 타겟 유저 id + */ + @DeleteMapping("/{tournamentId}/users/{userId}") + public ResponseEntity deleteTournamentUser(@PathVariable @Positive Long tournamentId, + @PathVariable @Positive Long userId) { + tournamentAdminService.deleteTournamentUser(tournamentId, userId); + + return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); + } + + /** + *

토너먼트 게임 점수 정보 수정

+ * @param tournamentId 타겟 토너먼트 id + * @param tournamentGameUpdateReqDto 수정할 게임 정보 + * @return HttpStatus.OK + */ + @PatchMapping("{tournamentId}/games") + public ResponseEntity updateTournamentGame(@PathVariable @Positive Long tournamentId, + @Valid @RequestBody TournamentGameUpdateRequestDto tournamentGameUpdateReqDto) { + tournamentAdminService.updateTournamentGame(tournamentId, tournamentGameUpdateReqDto); + return ResponseEntity.status(HttpStatus.OK).build(); + } } diff --git a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminAddUserRequestDto.java b/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminAddUserRequestDto.java index f5be89a01..bdc863500 100644 --- a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminAddUserRequestDto.java +++ b/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminAddUserRequestDto.java @@ -1,6 +1,7 @@ package com.gg.server.admin.tournament.dto; import javax.validation.constraints.NotNull; + import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -10,6 +11,6 @@ @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) public class TournamentAdminAddUserRequestDto { - @NotNull(message = "intraId가 필요합니다.") - private String intraId; + @NotNull(message = "intraId가 필요합니다.") + private String intraId; } diff --git a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminAddUserResponseDto.java b/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminAddUserResponseDto.java index 063e0a302..083ea72c9 100644 --- a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminAddUserResponseDto.java +++ b/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminAddUserResponseDto.java @@ -1,6 +1,5 @@ package com.gg.server.admin.tournament.dto; -import javax.validation.constraints.NotNull; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -10,10 +9,10 @@ @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) public class TournamentAdminAddUserResponseDto { - private Long userId; + private Long userId; - private String intraId; + private String intraId; - private Boolean isJoined; + private Boolean isJoined; } diff --git a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminCreateRequestDto.java b/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminCreateRequestDto.java index 2c40d764a..8b7d81955 100644 --- a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminCreateRequestDto.java +++ b/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminCreateRequestDto.java @@ -1,35 +1,39 @@ package com.gg.server.admin.tournament.dto; +import java.time.LocalDateTime; + +import javax.validation.constraints.NotNull; + +import org.hibernate.validator.constraints.Length; +import org.springframework.format.annotation.DateTimeFormat; + import com.gg.server.domain.tournament.type.TournamentType; + import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; -import org.springframework.format.annotation.DateTimeFormat; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor public class TournamentAdminCreateRequestDto { - @NotNull(message = "제목이 필요합니다.") - @Length(max = 30, message = "제목은 30자 이내로 작성해주세요.") - private String title; + @NotNull(message = "제목이 필요합니다.") + @Length(max = 30, message = "제목은 30자 이내로 작성해주세요.") + private String title; - @NotNull(message = "내용이 필요합니다.") - @Length(max = 3000, message = "내용은 3000자 이내로 작성해주세요.") - private String contents; + @NotNull(message = "내용이 필요합니다.") + @Length(max = 3000, message = "내용은 3000자 이내로 작성해주세요.") + private String contents; - @NotNull(message = "시작 시간이 필요합니다.") - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) - private LocalDateTime startTime; + @NotNull(message = "시작 시간이 필요합니다.") + @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + private LocalDateTime startTime; - @NotNull(message = "종료 시간이 필요합니다.") - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) - private LocalDateTime endTime; + @NotNull(message = "종료 시간이 필요합니다.") + @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) + private LocalDateTime endTime; - @NotNull(message = "토너먼트 종류가 필요합니다.") - private TournamentType type; + @NotNull(message = "토너먼트 종류가 필요합니다.") + private TournamentType type; } diff --git a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminUpdateRequestDto.java b/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminUpdateRequestDto.java index ef7def536..127c8565f 100644 --- a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminUpdateRequestDto.java +++ b/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminUpdateRequestDto.java @@ -1,39 +1,43 @@ package com.gg.server.admin.tournament.dto; -import com.gg.server.domain.tournament.type.TournamentType; import java.time.LocalDateTime; + import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.validation.constraints.NotNull; + +import org.hibernate.validator.constraints.Length; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.format.annotation.DateTimeFormat.ISO; + +import com.gg.server.domain.tournament.type.TournamentType; + import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; -import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.format.annotation.DateTimeFormat.ISO; @Getter @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) public class TournamentAdminUpdateRequestDto { - @NotNull(message = "제목이 필요합니다.") - @Length(max = 30, message = "제목은 30자 이내로 작성해주세요.") - private String title; + @NotNull(message = "제목이 필요합니다.") + @Length(max = 30, message = "제목은 30자 이내로 작성해주세요.") + private String title; - @NotNull(message = "내용이 필요합니다.") - @Length(max = 3000, message = "내용은 3000자 이내로 작성해주세요.") - private String contents; + @NotNull(message = "내용이 필요합니다.") + @Length(max = 3000, message = "내용은 3000자 이내로 작성해주세요.") + private String contents; - @NotNull(message = "시작 시간이 필요합니다.") - @DateTimeFormat(iso = ISO.DATE_TIME) - private LocalDateTime startTime; + @NotNull(message = "시작 시간이 필요합니다.") + @DateTimeFormat(iso = ISO.DATE_TIME) + private LocalDateTime startTime; - @NotNull(message = "종료 시간이 필요합니다.") - @DateTimeFormat(iso = ISO.DATE_TIME) - private LocalDateTime endTime; + @NotNull(message = "종료 시간이 필요합니다.") + @DateTimeFormat(iso = ISO.DATE_TIME) + private LocalDateTime endTime; - @NotNull(message = "토너먼트 종류가 필요합니다.") - @Enumerated(EnumType.STRING) - private TournamentType type; + @NotNull(message = "토너먼트 종류가 필요합니다.") + @Enumerated(EnumType.STRING) + private TournamentType type; } diff --git a/src/main/java/com/gg/server/admin/tournament/dto/TournamentGameUpdateRequestDto.java b/src/main/java/com/gg/server/admin/tournament/dto/TournamentGameUpdateRequestDto.java index fc1f6a954..317dafcbc 100644 --- a/src/main/java/com/gg/server/admin/tournament/dto/TournamentGameUpdateRequestDto.java +++ b/src/main/java/com/gg/server/admin/tournament/dto/TournamentGameUpdateRequestDto.java @@ -1,37 +1,37 @@ package com.gg.server.admin.tournament.dto; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; + import com.gg.server.domain.team.dto.TeamReqDto; + import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor public class TournamentGameUpdateRequestDto { - @NotNull - private Long tournamentGameId; + @NotNull + private Long tournamentGameId; - private Long nextTournamentGameId; - @NotNull - @Valid - private TeamReqDto team1; - @NotNull - @Valid - private TeamReqDto team2; + private Long nextTournamentGameId; + @NotNull + @Valid + private TeamReqDto team1; + @NotNull + @Valid + private TeamReqDto team2; - @Override - public String toString() { - return "TournamentGameUpdateReqDto{" + - "tournamentGameId=" + tournamentGameId + - ", nextTournamentGameId=" + nextTournamentGameId + - ", team1=" + team1 + - ", team2=" + team2 + - '}'; - } + @Override + public String toString() { + return "TournamentGameUpdateReqDto{" + + "tournamentGameId=" + tournamentGameId + + ", nextTournamentGameId=" + nextTournamentGameId + + ", team1=" + team1 + ", team2=" + + team2 + '}'; + } } diff --git a/src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java b/src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java index 8e7840635..bd67b9c04 100644 --- a/src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java +++ b/src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java @@ -1,19 +1,38 @@ package com.gg.server.admin.tournament.service; -import com.gg.server.admin.tournament.dto.*; +import static com.gg.server.domain.match.type.TournamentMatchStatus.*; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.admin.tournament.dto.TournamentAdminAddUserRequestDto; +import com.gg.server.admin.tournament.dto.TournamentAdminAddUserResponseDto; +import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; +import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; +import com.gg.server.admin.tournament.dto.TournamentGameUpdateRequestDto; import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.exception.ScoreNotInvalidException; import com.gg.server.domain.game.service.GameService; import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; import com.gg.server.domain.match.service.MatchTournamentService; import com.gg.server.domain.match.type.TournamentMatchStatus; +import com.gg.server.domain.slotmanagement.SlotManagement; +import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; import com.gg.server.domain.team.data.Team; import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.tournament.data.*; +import com.gg.server.domain.tournament.data.Tournament; +import com.gg.server.domain.tournament.data.TournamentGame; +import com.gg.server.domain.tournament.data.TournamentGameRepository; +import com.gg.server.domain.tournament.data.TournamentRepository; +import com.gg.server.domain.tournament.data.TournamentUser; +import com.gg.server.domain.tournament.data.TournamentUserRepository; import com.gg.server.domain.tournament.dto.TournamentUserListResponseDto; import com.gg.server.domain.tournament.exception.TournamentConflictException; import com.gg.server.domain.tournament.exception.TournamentGameNotFoundException; @@ -27,329 +46,346 @@ import com.gg.server.global.config.ConstantConfig; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.InvalidParameterException; -import java.time.LocalDate; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -import static com.gg.server.domain.match.type.TournamentMatchStatus.*; +import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class TournamentAdminService { - private final TournamentRepository tournamentRepository; - private final TournamentUserRepository tournamentUserRepository; - private final UserRepository userRepository; - private final GameRepository gameRepository; - private final TournamentGameRepository tournamentGameRepository; - private final SlotManagementRepository slotManagementRepository; - private final MatchTournamentService matchTournamentService; - private final ConstantConfig constantConfig; - private final GameService gameService; + private final TournamentRepository tournamentRepository; + private final TournamentUserRepository tournamentUserRepository; + private final UserRepository userRepository; + private final GameRepository gameRepository; + private final TournamentGameRepository tournamentGameRepository; + private final SlotManagementRepository slotManagementRepository; + private final MatchTournamentService matchTournamentService; + private final ConstantConfig constantConfig; + private final GameService gameService; - /*** - * 토너먼트 생성 Method - * @param tournamentAdminCreateRequestDto 토너먼트 생성에 필요한 데이터 - * @throws TournamentConflictException 토너먼트의 제목이 겹칠 때 - * @throws TournamentUpdateException 토너먼트 시간으로 부적합 할 때 - * @throws TournamentConflictException 업데이트 하고자 하는 토너먼트의 시간이 겹칠 때 && 게임 존재할 때 - * @return 새로 생성된 tournament - */ - @Transactional - public void createTournament(TournamentAdminCreateRequestDto tournamentAdminCreateRequestDto) { - checkValidTournamentTime(tournamentAdminCreateRequestDto.getStartTime(), tournamentAdminCreateRequestDto.getEndTime()); - checkConflictedTournament(-1L, tournamentAdminCreateRequestDto.getStartTime(), tournamentAdminCreateRequestDto.getEndTime()); - checkGameExistence(tournamentAdminCreateRequestDto.getStartTime(), tournamentAdminCreateRequestDto.getEndTime()); + /*** + * 토너먼트 생성 Method + * @param tournamentAdminCreateRequestDto 토너먼트 생성에 필요한 데이터 + * @throws TournamentConflictException 토너먼트의 제목이 겹칠 때 + * @throws TournamentUpdateException 토너먼트 시간으로 부적합 할 때 + * @throws TournamentConflictException 업데이트 하고자 하는 토너먼트의 시간이 겹칠 때 && 게임 존재할 때 + * @return 새로 생성된 tournament + */ + @Transactional + public void createTournament(TournamentAdminCreateRequestDto tournamentAdminCreateRequestDto) { + checkValidTournamentTime(tournamentAdminCreateRequestDto.getStartTime(), + tournamentAdminCreateRequestDto.getEndTime()); + checkConflictedTournament(-1L, tournamentAdminCreateRequestDto.getStartTime(), + tournamentAdminCreateRequestDto.getEndTime()); + checkGameExistence(tournamentAdminCreateRequestDto.getStartTime(), + tournamentAdminCreateRequestDto.getEndTime()); - Tournament tournament = Tournament.builder() - .title(tournamentAdminCreateRequestDto.getTitle()) - .contents(tournamentAdminCreateRequestDto.getContents()) - .startTime(tournamentAdminCreateRequestDto.getStartTime()) - .endTime(tournamentAdminCreateRequestDto.getEndTime()) - .type(tournamentAdminCreateRequestDto.getType()) - .status(TournamentStatus.BEFORE).build(); - createTournamentGameList(tournament, 7); - tournamentRepository.save(tournament); - } + Tournament tournament = Tournament.builder() + .title(tournamentAdminCreateRequestDto.getTitle()) + .contents(tournamentAdminCreateRequestDto.getContents()) + .startTime(tournamentAdminCreateRequestDto.getStartTime()) + .endTime(tournamentAdminCreateRequestDto.getEndTime()) + .type(tournamentAdminCreateRequestDto.getType()) + .status(TournamentStatus.BEFORE).build(); + createTournamentGameList(tournament, 7); + tournamentRepository.save(tournament); + } - /** - *

토너먼트 업데이트 Method

- * @param tournamentId 업데이트할 토너먼트 id - * @param requestDto 요청한 Dto - * @throws TournamentNotFoundException 찾을 수 없는 토너먼트 일 때 - * @throws TournamentUpdateException 업데이트 할 수 없는 토너먼트 일 때, 변경할 토너먼트 시간이 부적합 할 때 - * @throws TournamentConflictException 업데이트 하고자 하는 토너먼트의 시간이 겹칠 때 && 게임 존재할 때 - */ - @Transactional - public Tournament updateTournamentInfo(Long tournamentId, TournamentAdminUpdateRequestDto requestDto) { - Tournament targetTournament = tournamentRepository.findById(tournamentId).orElseThrow(TournamentNotFoundException::new); - if (!targetTournament.getStatus().equals(TournamentStatus.BEFORE)) { - throw new TournamentUpdateException(); - } - checkValidTournamentTime(requestDto.getStartTime(), requestDto.getEndTime()); - checkConflictedTournament(targetTournament.getId(), requestDto.getStartTime(), requestDto.getEndTime()); - checkGameExistence(requestDto.getStartTime(), requestDto.getEndTime()); + /** + *

토너먼트 업데이트 Method

+ * @param tournamentId 업데이트할 토너먼트 id + * @param requestDto 요청한 Dto + * @throws TournamentNotFoundException 찾을 수 없는 토너먼트 일 때 + * @throws TournamentUpdateException 업데이트 할 수 없는 토너먼트 일 때, 변경할 토너먼트 시간이 부적합 할 때 + * @throws TournamentConflictException 업데이트 하고자 하는 토너먼트의 시간이 겹칠 때 && 게임 존재할 때 + */ + @Transactional + public Tournament updateTournamentInfo(Long tournamentId, TournamentAdminUpdateRequestDto requestDto) { + Tournament targetTournament = tournamentRepository.findById(tournamentId) + .orElseThrow(TournamentNotFoundException::new); + if (!targetTournament.getStatus().equals(TournamentStatus.BEFORE)) { + throw new TournamentUpdateException(); + } + checkValidTournamentTime(requestDto.getStartTime(), requestDto.getEndTime()); + checkConflictedTournament(targetTournament.getId(), requestDto.getStartTime(), requestDto.getEndTime()); + checkGameExistence(requestDto.getStartTime(), requestDto.getEndTime()); - targetTournament.update( - requestDto.getTitle(), - requestDto.getContents(), - requestDto.getStartTime(), - requestDto.getEndTime(), - requestDto.getType(), - TournamentStatus.BEFORE); - return tournamentRepository.save(targetTournament); - } + targetTournament.update( + requestDto.getTitle(), + requestDto.getContents(), + requestDto.getStartTime(), + requestDto.getEndTime(), + requestDto.getType(), + TournamentStatus.BEFORE); + return tournamentRepository.save(targetTournament); + } - /** - *

토너먼트 삭제 매서드

- *

토너먼트는 BEFORE 인 경우에만 삭제 가능하다.

- * @param tournamentId 타겟 토너먼트 id - * @throws TournamentNotFoundException 찾을 수 없는 토너먼트 일 때 - * @throws TournamentUpdateException 업데이트 할 수 없는 토너먼트 일 때 - */ - @Transactional - public void deleteTournament(Long tournamentId) { - Tournament targetTournament = tournamentRepository.findById(tournamentId).orElseThrow(TournamentNotFoundException::new); - if (!targetTournament.getStatus().equals(TournamentStatus.BEFORE)) { - throw new TournamentUpdateException(); - } - tournamentRepository.deleteById(tournamentId); - } + /** + *

토너먼트 삭제 매서드

+ *

토너먼트는 BEFORE 인 경우에만 삭제 가능하다.

+ * @param tournamentId 타겟 토너먼트 id + * @throws TournamentNotFoundException 찾을 수 없는 토너먼트 일 때 + * @throws TournamentUpdateException 업데이트 할 수 없는 토너먼트 일 때 + */ + @Transactional + public void deleteTournament(Long tournamentId) { + Tournament targetTournament = tournamentRepository.findById(tournamentId) + .orElseThrow(TournamentNotFoundException::new); + if (!targetTournament.getStatus().equals(TournamentStatus.BEFORE)) { + throw new TournamentUpdateException(); + } + tournamentRepository.deleteById(tournamentId); + } - /** - *

관리자 토너먼트 참가 유저 추가 매서드

- *

해당 토너먼트에 이미 신청 되어 있으면 추가 불가

- * @param tournamentId 타겟 토너먼트 - * @param requestDto 요청 dto - * @return TournamentAdminAddUserResponseDto dto 반환 - * @throws TournamentNotFoundException 타겟 토너먼트 없음 - * @throws TournamentUpdateException 이미 시작했거나 종료된 토너먼트 - * @throws UserNotFoundException 유저 없음 - * @throws TournamentConflictException 이미 해당 토너먼트 참가중인 유저 - */ - @Transactional - public TournamentAdminAddUserResponseDto addTournamentUser(Long tournamentId, TournamentAdminAddUserRequestDto requestDto) { - Tournament targetTournament = tournamentRepository.findById(tournamentId).orElseThrow(TournamentNotFoundException::new); - if (!targetTournament.getStatus().equals(TournamentStatus.BEFORE)) { - throw new TournamentUpdateException(); - } + /** + *

관리자 토너먼트 참가 유저 추가 매서드

+ *

해당 토너먼트에 이미 신청 되어 있으면 추가 불가

+ * @param tournamentId 타겟 토너먼트 + * @param requestDto 요청 dto + * @return TournamentAdminAddUserResponseDto dto 반환 + * @throws TournamentNotFoundException 타겟 토너먼트 없음 + * @throws TournamentUpdateException 이미 시작했거나 종료된 토너먼트 + * @throws UserNotFoundException 유저 없음 + * @throws TournamentConflictException 이미 해당 토너먼트 참가중인 유저 + */ + @Transactional + public TournamentAdminAddUserResponseDto addTournamentUser(Long tournamentId, + TournamentAdminAddUserRequestDto requestDto) { + Tournament targetTournament = tournamentRepository.findById(tournamentId) + .orElseThrow(TournamentNotFoundException::new); + if (!targetTournament.getStatus().equals(TournamentStatus.BEFORE)) { + throw new TournamentUpdateException(); + } - User targetUser = userRepository.findByIntraId(requestDto.getIntraId()).orElseThrow(UserNotFoundException::new); + User targetUser = userRepository.findByIntraId(requestDto.getIntraId()).orElseThrow(UserNotFoundException::new); - List tournamentList = targetTournament.getTournamentUsers(); - tournamentList.stream().filter(tu->tu.getUser().getIntraId().equals(targetUser.getIntraId())) - .findAny() - .ifPresent(a->{throw new TournamentConflictException(ErrorCode.TOURNAMENT_ALREADY_PARTICIPANT);}); + List tournamentList = targetTournament.getTournamentUsers(); + tournamentList.stream().filter(tu -> tu.getUser().getIntraId().equals(targetUser.getIntraId())) + .findAny() + .ifPresent(a -> { + throw new TournamentConflictException(ErrorCode.TOURNAMENT_ALREADY_PARTICIPANT); + }); - TournamentUser tournamentUser = new TournamentUser(targetUser, targetTournament, - tournamentList.size() < Tournament.ALLOWED_JOINED_NUMBER, LocalDateTime.now()); - tournamentUserRepository.save(tournamentUser); + TournamentUser tournamentUser = new TournamentUser(targetUser, targetTournament, + tournamentList.size() < Tournament.ALLOWED_JOINED_NUMBER, LocalDateTime.now()); + tournamentUserRepository.save(tournamentUser); - return new TournamentAdminAddUserResponseDto( - targetUser.getId(), - targetUser.getIntraId(), - tournamentUser.getIsJoined() - ); - } + return new TournamentAdminAddUserResponseDto( + targetUser.getId(), + targetUser.getIntraId(), + tournamentUser.getIsJoined() + ); + } - /** - *

토너먼트 유저 삭제 매서드

- *

삭제하고자 하는 유저가 참가자이고, 현재 대기자가 있다면 참가신청이 빠른 대기자를 참가자로 변경해준다.

- * @param tournamentId 타겟 토너먼트 id - * @param userId 타겟 유저 id - * @throws TournamentNotFoundException 타겟 토너먼트 없음 - * @throws TournamentUpdateException 이미 시작했거나 종료된 토너먼트 - * @throws UserNotFoundException 유저 없음 || 토너먼트 신청자가 아님 - */ - @Transactional - public void deleteTournamentUser(Long tournamentId, Long userId) { - Tournament targetTournament = tournamentRepository.findById(tournamentId).orElseThrow(TournamentNotFoundException::new); - if (!targetTournament.getStatus().equals(TournamentStatus.BEFORE)) { - throw new TournamentUpdateException(); - } - User targetUser = userRepository.findById(userId).orElseThrow(UserNotFoundException::new); + /** + *

토너먼트 유저 삭제 매서드

+ *

삭제하고자 하는 유저가 참가자이고, 현재 대기자가 있다면 참가신청이 빠른 대기자를 참가자로 변경해준다.

+ * @param tournamentId 타겟 토너먼트 id + * @param userId 타겟 유저 id + * @throws TournamentNotFoundException 타겟 토너먼트 없음 + * @throws TournamentUpdateException 이미 시작했거나 종료된 토너먼트 + * @throws UserNotFoundException 유저 없음 || 토너먼트 신청자가 아님 + */ + @Transactional + public void deleteTournamentUser(Long tournamentId, Long userId) { + Tournament targetTournament = tournamentRepository.findById(tournamentId) + .orElseThrow(TournamentNotFoundException::new); + if (!targetTournament.getStatus().equals(TournamentStatus.BEFORE)) { + throw new TournamentUpdateException(); + } + User targetUser = userRepository.findById(userId).orElseThrow(UserNotFoundException::new); - List tournamentUserList = targetTournament.getTournamentUsers(); - TournamentUser targetTournamentUser = tournamentUserList.stream() - .filter(tu->tu.getUser().getId().equals(targetUser.getId())) - .findAny() - .orElseThrow(()->new TournamentNotFoundException(ErrorCode.TOURNAMENT_NOT_PARTICIPANT)); - targetTournamentUser.deleteTournament(); - if (targetTournamentUser.getIsJoined() && tournamentUserList.size() >= Tournament.ALLOWED_JOINED_NUMBER) { - tournamentUserList.get(Tournament.ALLOWED_JOINED_NUMBER - 1).updateIsJoined(true); - } - tournamentUserRepository.delete(targetTournamentUser); - } + List tournamentUserList = targetTournament.getTournamentUsers(); + TournamentUser targetTournamentUser = tournamentUserList.stream() + .filter(tu -> tu.getUser().getId().equals(targetUser.getId())) + .findAny() + .orElseThrow(() -> new TournamentNotFoundException(ErrorCode.TOURNAMENT_NOT_PARTICIPANT)); + targetTournamentUser.deleteTournament(); + if (targetTournamentUser.getIsJoined() && tournamentUserList.size() >= Tournament.ALLOWED_JOINED_NUMBER) { + tournamentUserList.get(Tournament.ALLOWED_JOINED_NUMBER - 1).updateIsJoined(true); + } + tournamentUserRepository.delete(targetTournamentUser); + } - /*** - * 토너먼트 게임 테이블 생성 Method - * @param tournament 토너먼트 게임에 매칭될 토너먼트 - * @param cnt 토너먼트 전체 라운드 수 - */ - private void createTournamentGameList(Tournament tournament, int cnt) { - TournamentRound[] rounds = TournamentRound.values(); - while (--cnt >= 0) { - TournamentGame tournamentGame = new TournamentGame(null, tournament, rounds[cnt]); - } - } + /*** + * 토너먼트 게임 테이블 생성 Method + * @param tournament 토너먼트 게임에 매칭될 토너먼트 + * @param cnt 토너먼트 전체 라운드 수 + */ + private void createTournamentGameList(Tournament tournament, int cnt) { + TournamentRound[] rounds = TournamentRound.values(); + while (--cnt >= 0) { + TournamentGame tournamentGame = new TournamentGame(null, tournament, rounds[cnt]); + } + } - /** - * 토너먼트 시간 체크 : - * [ 현재 시간 + 최소 2일 ], - * [ 현재시간 보다 미래 ], - * [ 시작 시간이 종료시간보다 현재시에 가까움 ] - * [ 진행 시간 최소 2시간 ] - * - * @param startTime 업데이트할 토너먼트 시작 시간 - * @param endTime 업데이트할 토너먼트 종료 시간 - * @throws InvalidParameterException 토너먼트 시간으로 부적합 할 때 - */ - private void checkValidTournamentTime(LocalDateTime startTime, LocalDateTime endTime) { - SlotManagement slotManagement = slotManagementRepository.findCurrent(startTime) - .orElseThrow(SlotNotFoundException::new); - int interval = slotManagement.getGameInterval(); + /** + * 토너먼트 시간 체크 : + * [ 현재 시간 + 최소 2일 ], + * [ 현재시간 보다 미래 ], + * [ 시작 시간이 종료시간보다 현재시에 가까움 ] + * [ 진행 시간 최소 2시간 ] + * + * @param startTime 업데이트할 토너먼트 시작 시간 + * @param endTime 업데이트할 토너먼트 종료 시간 + * @throws InvalidParameterException 토너먼트 시간으로 부적합 할 때 + */ + private void checkValidTournamentTime(LocalDateTime startTime, LocalDateTime endTime) { + SlotManagement slotManagement = slotManagementRepository.findCurrent(startTime) + .orElseThrow(SlotNotFoundException::new); + int interval = slotManagement.getGameInterval(); - if (startTime.isAfter(endTime) || startTime.isEqual(endTime) || - LocalDate.now().plusDays(constantConfig.getAllowedMinimalStartDays()).isAfter(startTime.toLocalDate()) || - startTime.plusHours(Tournament.MINIMUM_TOURNAMENT_DURATION).isAfter(endTime) || - startTime.getMinute() % interval != 0 || endTime.getMinute() % interval != 0) { - throw new TournamentUpdateException(ErrorCode.TOURNAMENT_INVALID_TIME); - } - } + if (startTime.isAfter(endTime) + || startTime.isEqual(endTime) + || LocalDate.now().plusDays(constantConfig.getAllowedMinimalStartDays()).isAfter(startTime.toLocalDate()) + || startTime.plusHours(Tournament.MINIMUM_TOURNAMENT_DURATION).isAfter(endTime) + || startTime.getMinute() % interval != 0 + || endTime.getMinute() % interval != 0) { + throw new TournamentUpdateException(ErrorCode.TOURNAMENT_INVALID_TIME); + } + } - /** - *

tournamentList 에서 targetTournament을 제외한 토너먼트 중 겹치는 시간대 존재 유무 확인

- * @param targetTournamentId 업데이트할 토너먼트 id - * @param startTime 업데이트할 토너먼트 시작 시간 - * @param endTime 업데이트할 토너먼트 종료 시간 - * @throws TournamentConflictException 업데이트 하고자 하는 토너먼트의 시간이 겹칠 때 - */ - private void checkConflictedTournament(Long targetTournamentId, LocalDateTime startTime, LocalDateTime endTime) { - List tournamentList = tournamentRepository.findAllBetween(startTime, endTime); - for (Tournament tournament : tournamentList) { - if (targetTournamentId.equals(tournament.getId()) || - (!tournament.getStatus().equals(TournamentStatus.BEFORE) && !tournament.getStatus().equals(TournamentStatus.LIVE))) { - continue; - } - throw new TournamentConflictException(); - } - } + /** + *

tournamentList 에서 targetTournament을 제외한 토너먼트 중 겹치는 시간대 존재 유무 확인

+ * @param targetTournamentId 업데이트할 토너먼트 id + * @param startTime 업데이트할 토너먼트 시작 시간 + * @param endTime 업데이트할 토너먼트 종료 시간 + * @throws TournamentConflictException 업데이트 하고자 하는 토너먼트의 시간이 겹칠 때 + */ + private void checkConflictedTournament(Long targetTournamentId, LocalDateTime startTime, LocalDateTime endTime) { + List tournamentList = tournamentRepository.findAllBetween(startTime, endTime); + for (Tournament tournament : tournamentList) { + if (targetTournamentId.equals(tournament.getId()) + || (!tournament.getStatus().equals(TournamentStatus.BEFORE) + && !tournament.getStatus() + .equals(TournamentStatus.LIVE))) { + continue; + } + throw new TournamentConflictException(); + } + } - /** - *

타겟 시간 내에 게임이 존재하는지 체크

- * @param startTime 시작 시간 - * @param endTime 종료 시간 - */ - private void checkGameExistence(LocalDateTime startTime, LocalDateTime endTime) { - gameRepository.findAllBetweenTournament(startTime, endTime).stream() - .findAny() - .ifPresent(a->{throw new TournamentConflictException(ErrorCode.TOURNAMENT_CONFLICT_GAME);}); - } + /** + *

타겟 시간 내에 게임이 존재하는지 체크

+ * @param startTime 시작 시간 + * @param endTime 종료 시간 + */ + private void checkGameExistence(LocalDateTime startTime, LocalDateTime endTime) { + gameRepository.findAllBetweenTournament(startTime, endTime).stream() + .findAny() + .ifPresent(a -> { + throw new TournamentConflictException(ErrorCode.TOURNAMENT_CONFLICT_GAME); + }); + } - /** - *

토너먼트 유저 리스트 조회

- * @param tournamentId 토너먼트 id - * @param isJoined 참가자인지 대기자인지 여부 - * @return TournamentUserListResponseDto - * @throws TournamentNotFoundException 토너먼트가 존재하지 않을 때 - */ - public TournamentUserListResponseDto getTournamentUserList(Long tournamentId, Boolean isJoined) { - Tournament tournament = tournamentRepository.findById(tournamentId).orElseThrow(TournamentNotFoundException::new); - if (isJoined == null){ - return new TournamentUserListResponseDto(tournamentUserRepository.findAllByTournament(tournament)); - } else { - return new TournamentUserListResponseDto(tournamentUserRepository.findAllByTournamentAndIsJoined(tournament, isJoined)); - } - } + /** + *

토너먼트 유저 리스트 조회

+ * @param tournamentId 토너먼트 id + * @param isJoined 참가자인지 대기자인지 여부 + * @return TournamentUserListResponseDto + * @throws TournamentNotFoundException 토너먼트가 존재하지 않을 때 + */ + public TournamentUserListResponseDto getTournamentUserList(Long tournamentId, Boolean isJoined) { + Tournament tournament = tournamentRepository.findById(tournamentId) + .orElseThrow(TournamentNotFoundException::new); + if (isJoined == null) { + return new TournamentUserListResponseDto(tournamentUserRepository.findAllByTournament(tournament)); + } else { + return new TournamentUserListResponseDto( + tournamentUserRepository.findAllByTournamentAndIsJoined(tournament, isJoined)); + } + } - /** - *

토너먼트 게임 정보 수정

- * @param tournamentId 타겟 토너먼트 id - * @param reqDto 수정할 게임 정보 - * @throws TournamentUpdateException 토너먼트가 시작되지 않았을 때 - */ - @Transactional - public void updateTournamentGame(Long tournamentId, TournamentGameUpdateRequestDto reqDto) { - if (reqDto.getTeam1().getScore() + reqDto.getTeam2().getScore() > 3 || - reqDto.getTeam1().getScore() + reqDto.getTeam2().getScore() < 2 || - reqDto.getTeam1().getScore() == reqDto.getTeam2().getScore()) { - throw new ScoreNotInvalidException(); - } - Tournament tournament = tournamentRepository.findById(tournamentId) - .orElseThrow(TournamentNotFoundException::new); - if (tournament.getStatus() == TournamentStatus.BEFORE) { - throw new TournamentUpdateException(ErrorCode.TOURNAMENT_IS_BEFORE); - } - TournamentGame tournamentGame = tournament.getTournamentGames().stream(). - filter(t->t.getId().equals(reqDto.getTournamentGameId())).findAny() - .orElseThrow(TournamentGameNotFoundException::new); - Game game = tournamentGame.getGame(); - if (game == null){ - throw new TournamentGameNotFoundException(); - } - if (!canUpdateScore(tournamentGame,reqDto)){ - throw new TournamentUpdateException(ErrorCode.TOURNAMENT_INVALID_SCORE); - } - updateTeamScore(game, reqDto); - TournamentMatchStatus matchStatus = matchTournamentService.checkTournamentGame(game); - TournamentRound nextRound = tournamentGame.getTournamentRound().getNextRound(); - List teamUsers = new ArrayList<>(); - for(Team team : game.getTeams()){ - teamUsers.add(team.getTeamUsers().get(0)); - } - gameService.savePChange(game, teamUsers, teamUsers.get(0).getUser().getId()); - if (POSSIBLE.equals(matchStatus)) { - matchTournamentService.matchGames(tournament, nextRound); - } else if (ALREADY_MATCHED.equals(matchStatus)) { - Game nextMatchedGame = tournamentGameRepository.findByTournamentIdAndTournamentRound(tournament.getId(), nextRound) - .orElseThrow(TournamentGameNotFoundException::new) - .getGame(); - matchTournamentService.updateMatchedGameUser(game, nextMatchedGame); - } - } + /** + *

토너먼트 게임 정보 수정

+ * @param tournamentId 타겟 토너먼트 id + * @param reqDto 수정할 게임 정보 + * @throws TournamentUpdateException 토너먼트가 시작되지 않았을 때 + */ + @Transactional + public void updateTournamentGame(Long tournamentId, TournamentGameUpdateRequestDto reqDto) { + if (reqDto.getTeam1().getScore() + reqDto.getTeam2().getScore() > 3 + || reqDto.getTeam1().getScore() + reqDto.getTeam2().getScore() < 2 + || reqDto.getTeam1().getScore() == reqDto.getTeam2().getScore()) { + throw new ScoreNotInvalidException(); + } + Tournament tournament = tournamentRepository.findById(tournamentId) + .orElseThrow(TournamentNotFoundException::new); + if (tournament.getStatus() == TournamentStatus.BEFORE) { + throw new TournamentUpdateException(ErrorCode.TOURNAMENT_IS_BEFORE); + } + TournamentGame tournamentGame = tournament.getTournamentGames().stream() + .filter(t -> t.getId().equals(reqDto.getTournamentGameId())).findAny() + .orElseThrow(TournamentGameNotFoundException::new); + Game game = tournamentGame.getGame(); + if (game == null) { + throw new TournamentGameNotFoundException(); + } + if (!canUpdateScore(tournamentGame, reqDto)) { + throw new TournamentUpdateException(ErrorCode.TOURNAMENT_INVALID_SCORE); + } + updateTeamScore(game, reqDto); + TournamentMatchStatus matchStatus = matchTournamentService.checkTournamentGame(game); + TournamentRound nextRound = tournamentGame.getTournamentRound().getNextRound(); + List teamUsers = new ArrayList<>(); + for (Team team : game.getTeams()) { + teamUsers.add(team.getTeamUsers().get(0)); + } + gameService.savePChange(game, teamUsers, teamUsers.get(0).getUser().getId()); + if (POSSIBLE.equals(matchStatus)) { + matchTournamentService.matchGames(tournament, nextRound); + } else if (ALREADY_MATCHED.equals(matchStatus)) { + Game nextMatchedGame = tournamentGameRepository.findByTournamentIdAndTournamentRound(tournament.getId(), + nextRound) + .orElseThrow(TournamentGameNotFoundException::new) + .getGame(); + matchTournamentService.updateMatchedGameUser(game, nextMatchedGame); + } + } - /** - *

토너먼트 게임 점수 수정

- * @param game 수정될 게임 - * @param reqDto 수정할 게임 정보 - */ - private void updateTeamScore(Game game, TournamentGameUpdateRequestDto reqDto){ + /** + *

토너먼트 게임 점수 수정

+ * @param game 수정될 게임 + * @param reqDto 수정할 게임 정보 + */ + private void updateTeamScore(Game game, TournamentGameUpdateRequestDto reqDto) { - List teams = game.getTeams(); - Team team1 = teams.stream().filter(t->t.getId().equals(reqDto.getTeam1().getTeamId())).findAny().orElseThrow(TournamentGameNotFoundException::new); - Team team2 = teams.stream().filter(t->t.getId().equals(reqDto.getTeam2().getTeamId())).findAny().orElseThrow(TournamentGameNotFoundException::new); - team1.updateScore(reqDto.getTeam1().getScore(), reqDto.getTeam1().getScore() > reqDto.getTeam2().getScore()); - team2.updateScore(reqDto.getTeam2().getScore(), reqDto.getTeam2().getScore() > reqDto.getTeam1().getScore()); - if (game.getStatus() == StatusType.LIVE){ - game.updateStatus(); - } - game.updateStatus(); - } + List teams = game.getTeams(); + Team team1 = teams.stream() + .filter(t -> t.getId().equals(reqDto.getTeam1().getTeamId())) + .findAny() + .orElseThrow(TournamentGameNotFoundException::new); + Team team2 = teams.stream() + .filter(t -> t.getId().equals(reqDto.getTeam2().getTeamId())) + .findAny() + .orElseThrow(TournamentGameNotFoundException::new); + team1.updateScore(reqDto.getTeam1().getScore(), reqDto.getTeam1().getScore() > reqDto.getTeam2().getScore()); + team2.updateScore(reqDto.getTeam2().getScore(), reqDto.getTeam2().getScore() > reqDto.getTeam1().getScore()); + if (game.getStatus() == StatusType.LIVE) { + game.updateStatus(); + } + game.updateStatus(); + } - /** - *

토너먼트 게임 점수 수정 가능 여부

- * @param reqDto 수정할 게임 정보 - * @return 수정 가능 여부 - */ - private boolean canUpdateScore(TournamentGame tournamentGame, TournamentGameUpdateRequestDto reqDto) { - if (tournamentGame.getGame().getStatus() == StatusType.BEFORE) { - return false; - } - if (reqDto.getNextTournamentGameId() == null){ - return tournamentGame.getTournamentRound() == TournamentRound.THE_FINAL; - } - TournamentGame nextTournamentGame = tournamentGameRepository.findById(reqDto.getNextTournamentGameId()) - .orElseThrow(TournamentGameNotFoundException::new); - if (nextTournamentGame.getGame() == null){ - return true; - } - if (nextTournamentGame.getGame().getStatus() == StatusType.BEFORE){ - return true; - } - return false; - } -} \ No newline at end of file + /** + *

토너먼트 게임 점수 수정 가능 여부

+ * @param reqDto 수정할 게임 정보 + * @return 수정 가능 여부 + */ + private boolean canUpdateScore(TournamentGame tournamentGame, TournamentGameUpdateRequestDto reqDto) { + if (tournamentGame.getGame().getStatus() == StatusType.BEFORE) { + return false; + } + if (reqDto.getNextTournamentGameId() == null) { + return tournamentGame.getTournamentRound() == TournamentRound.THE_FINAL; + } + TournamentGame nextTournamentGame = tournamentGameRepository.findById(reqDto.getNextTournamentGameId()) + .orElseThrow(TournamentGameNotFoundException::new); + if (nextTournamentGame.getGame() == null) { + return true; + } + if (nextTournamentGame.getGame().getStatus() == StatusType.BEFORE) { + return true; + } + return false; + } +} diff --git a/src/main/java/com/gg/server/admin/user/controller/UserAdminController.java b/src/main/java/com/gg/server/admin/user/controller/UserAdminController.java index 69a870aff..a260d2e41 100644 --- a/src/main/java/com/gg/server/admin/user/controller/UserAdminController.java +++ b/src/main/java/com/gg/server/admin/user/controller/UserAdminController.java @@ -1,108 +1,126 @@ package com.gg.server.admin.user.controller; -import com.gg.server.admin.user.dto.*; -import com.gg.server.admin.user.service.UserAdminService; -import com.gg.server.domain.user.exception.UserImageLargeException; -import com.gg.server.domain.user.exception.UserImageTypeException; -import com.gg.server.global.dto.PageRequestDto; -import lombok.AllArgsConstructor; +import java.io.IOException; + +import javax.validation.Valid; + import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import javax.validation.Valid; -import java.io.IOException; +import com.gg.server.admin.user.dto.UserDetailAdminResponseDto; +import com.gg.server.admin.user.dto.UserImageListAdminResponseDto; +import com.gg.server.admin.user.dto.UserSearchAdminRequestDto; +import com.gg.server.admin.user.dto.UserSearchAdminResponseDto; +import com.gg.server.admin.user.dto.UserUpdateAdminRequestDto; +import com.gg.server.admin.user.service.UserAdminService; +import com.gg.server.domain.user.exception.UserImageLargeException; +import com.gg.server.domain.user.exception.UserImageTypeException; +import com.gg.server.global.dto.PageRequestDto; + +import lombok.AllArgsConstructor; @RestController @AllArgsConstructor @RequestMapping(value = "/pingpong/admin/users") public class UserAdminController { - private final UserAdminService userAdminService; - - @GetMapping - public UserSearchAdminResponseDto userSearchAll(@ModelAttribute @Valid UserSearchAdminRequestDto searchRequestDto) { - Pageable pageable = PageRequest.of(searchRequestDto.getPage() - 1, - searchRequestDto.getSize(), - Sort.by("intraId").ascending()); - if (searchRequestDto.getUserFilter() != null) - return userAdminService.searchByIntraId(pageable, searchRequestDto.getUserFilter()); - else if (searchRequestDto.getIntraId() != null) - return userAdminService.findByPartsOfIntraId(searchRequestDto.getIntraId(), pageable); - else - return userAdminService.searchAll(pageable); - } - - @GetMapping("/{intraId}") - public UserDetailAdminResponseDto userGetDetail(@PathVariable String intraId) { - return userAdminService.getUserDetailByIntraId(intraId); - } - - @PutMapping("/{intraId}") - public ResponseEntity userUpdateDetail(@PathVariable String intraId, - @RequestPart UserUpdateAdminRequestDto updateUserInfo, - @RequestPart(required = false) MultipartFile imgData) throws IOException { - if (imgData != null) { - if (imgData.getSize() > 50000) { - throw new UserImageLargeException(); - } else if (imgData.getContentType() == null || !imgData.getContentType().equals("image/jpeg")) { - throw new UserImageTypeException(); - } - } - userAdminService.updateUserDetail(intraId, updateUserInfo, imgData); - - return ResponseEntity.noContent().build(); - } - - @DeleteMapping("/images/{intraId}") - public ResponseEntity deleteUserProfileImage(@PathVariable String intraId) { - userAdminService.deleteUserProfileImage(intraId); - return ResponseEntity.noContent().build(); - } - - @GetMapping("/delete-list") - public UserImageListAdminResponseDto getUserImageDeleteList(@ModelAttribute @Valid PageRequestDto pageRequestDto) { - Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, - pageRequestDto.getSize(), - Sort.by("id").descending()); - return userAdminService.getUserImageDeleteList(pageable); - } - - @GetMapping("/delete-list/{intraId}") - public UserImageListAdminResponseDto getUserImageDeleteListByIntraId(@ModelAttribute @Valid PageRequestDto pageRequestDto, @PathVariable String intraId) { - Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, - pageRequestDto.getSize()); - return userAdminService.getUserImageDeleteListByIntraId(pageable, intraId); - } - - @GetMapping("/images") - public UserImageListAdminResponseDto getUserImageList(@ModelAttribute @Valid PageRequestDto pageRequestDto) { - Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, - pageRequestDto.getSize()); - return userAdminService.getUserImageList(pageable); - } - - @GetMapping("/images/{intraId}") - public UserImageListAdminResponseDto getUserImage(@ModelAttribute @Valid PageRequestDto pageRequestDto, @PathVariable String intraId) { - Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, - pageRequestDto.getSize()); - return userAdminService.getUserImageListByIntraId(pageable, intraId); - } - - @GetMapping("/images/current") - public UserImageListAdminResponseDto getUserImageCurrent(@ModelAttribute @Valid PageRequestDto pageRequestDto) { - Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, - pageRequestDto.getSize()); - return userAdminService.getUserImageCurrent(pageable); - } - - @GetMapping("/images/current/{intraId}") - public UserImageListAdminResponseDto getUserImageCurrentByIntraId(@ModelAttribute @Valid PageRequestDto pageRequestDto, @PathVariable String intraId) { - Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, - pageRequestDto.getSize()); - return userAdminService.getUserImageCurrentByIntraId(pageable, intraId); - } + private final UserAdminService userAdminService; + + @GetMapping + public UserSearchAdminResponseDto userSearchAll(@ModelAttribute @Valid UserSearchAdminRequestDto searchRequestDto) { + Pageable pageable = PageRequest.of(searchRequestDto.getPage() - 1, + searchRequestDto.getSize(), + Sort.by("intraId").ascending()); + if (searchRequestDto.getUserFilter() != null) { + return userAdminService.searchByIntraId(pageable, searchRequestDto.getUserFilter()); + } else if (searchRequestDto.getIntraId() != null) { + return userAdminService.findByPartsOfIntraId(searchRequestDto.getIntraId(), pageable); + } else { + return userAdminService.searchAll(pageable); + } + } + + @GetMapping("/{intraId}") + public UserDetailAdminResponseDto userGetDetail(@PathVariable String intraId) { + return userAdminService.getUserDetailByIntraId(intraId); + } + + @PutMapping("/{intraId}") + public ResponseEntity userUpdateDetail(@PathVariable String intraId, + @RequestPart UserUpdateAdminRequestDto updateUserInfo, + @RequestPart(required = false) MultipartFile imgData) throws IOException { + if (imgData != null) { + if (imgData.getSize() > 50000) { + throw new UserImageLargeException(); + } else if (imgData.getContentType() == null || !imgData.getContentType().equals("image/jpeg")) { + throw new UserImageTypeException(); + } + } + userAdminService.updateUserDetail(intraId, updateUserInfo, imgData); + + return ResponseEntity.noContent().build(); + } + + @DeleteMapping("/images/{intraId}") + public ResponseEntity deleteUserProfileImage(@PathVariable String intraId) { + userAdminService.deleteUserProfileImage(intraId); + return ResponseEntity.noContent().build(); + } + + @GetMapping("/delete-list") + public UserImageListAdminResponseDto getUserImageDeleteList(@ModelAttribute @Valid PageRequestDto pageRequestDto) { + Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, + pageRequestDto.getSize(), + Sort.by("id").descending()); + return userAdminService.getUserImageDeleteList(pageable); + } + + @GetMapping("/delete-list/{intraId}") + public UserImageListAdminResponseDto getUserImageDeleteListByIntraId( + @ModelAttribute @Valid PageRequestDto pageRequestDto, @PathVariable String intraId) { + Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, + pageRequestDto.getSize()); + return userAdminService.getUserImageDeleteListByIntraId(pageable, intraId); + } + + @GetMapping("/images") + public UserImageListAdminResponseDto getUserImageList(@ModelAttribute @Valid PageRequestDto pageRequestDto) { + Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, + pageRequestDto.getSize()); + return userAdminService.getUserImageList(pageable); + } + + @GetMapping("/images/{intraId}") + public UserImageListAdminResponseDto getUserImage(@ModelAttribute @Valid PageRequestDto pageRequestDto, + @PathVariable String intraId) { + Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, + pageRequestDto.getSize()); + return userAdminService.getUserImageListByIntraId(pageable, intraId); + } + + @GetMapping("/images/current") + public UserImageListAdminResponseDto getUserImageCurrent(@ModelAttribute @Valid PageRequestDto pageRequestDto) { + Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, + pageRequestDto.getSize()); + return userAdminService.getUserImageCurrent(pageable); + } + + @GetMapping("/images/current/{intraId}") + public UserImageListAdminResponseDto getUserImageCurrentByIntraId( + @ModelAttribute @Valid PageRequestDto pageRequestDto, @PathVariable String intraId) { + Pageable pageable = PageRequest.of(pageRequestDto.getPage() - 1, + pageRequestDto.getSize()); + return userAdminService.getUserImageCurrentByIntraId(pageable, intraId); + } } diff --git a/src/main/java/com/gg/server/admin/user/data/UserAdminRepository.java b/src/main/java/com/gg/server/admin/user/data/UserAdminRepository.java index 3eb4712ea..d30e731cf 100644 --- a/src/main/java/com/gg/server/admin/user/data/UserAdminRepository.java +++ b/src/main/java/com/gg/server/admin/user/data/UserAdminRepository.java @@ -1,15 +1,19 @@ -package com.gg.server.admin.user.data; - -import com.gg.server.domain.user.data.User; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.JpaRepository; - -import java.util.Optional; - -public interface UserAdminRepository extends JpaRepository { - Optional findByIntraId(String intraId); - Page findByIntraIdContains(Pageable pageable, String intraId); - Page findByIntraId(Pageable pageable, String intraId); - Page findAll(Pageable pageable); -} +package com.gg.server.admin.user.data; + +import java.util.Optional; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; + +import com.gg.server.domain.user.data.User; + +public interface UserAdminRepository extends JpaRepository { + Optional findByIntraId(String intraId); + + Page findByIntraIdContains(Pageable pageable, String intraId); + + Page findByIntraId(Pageable pageable, String intraId); + + Page findAll(Pageable pageable); +} diff --git a/src/main/java/com/gg/server/admin/user/data/UserImageAdminRepository.java b/src/main/java/com/gg/server/admin/user/data/UserImageAdminRepository.java index c18eb09dd..e9f29e54a 100644 --- a/src/main/java/com/gg/server/admin/user/data/UserImageAdminRepository.java +++ b/src/main/java/com/gg/server/admin/user/data/UserImageAdminRepository.java @@ -1,42 +1,43 @@ package com.gg.server.admin.user.data; -import com.gg.server.domain.user.data.User; -import org.springframework.data.repository.query.Param; +import java.util.Optional; + import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.user.data.UserImage; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserImage; -import java.util.Optional; +public interface UserImageAdminRepository extends JpaRepository { + Optional findTopByUserAndIsCurrentIsTrueOrderByCreatedAtDesc(User user); -public interface UserImageAdminRepository extends JpaRepository{ - Optional findTopByUserAndIsCurrentIsTrueOrderByCreatedAtDesc(User user); + Optional findTopByUserAndDeletedAtIsNullOrderByCreatedAtDesc(User user); - Optional findTopByUserAndDeletedAtIsNullOrderByCreatedAtDesc(User user); - - Page findAllByDeletedAtNotNullOrderByDeletedAtDesc(Pageable pageable); + Page findAllByDeletedAtNotNullOrderByDeletedAtDesc(Pageable pageable); - @Query(value = "SELECT ui FROM UserImage ui WHERE ui.user.id = :user_id " + - "AND ui.deletedAt != NULL ORDER BY ui.deletedAt DESC") - Page findAllByUserAndDeletedAtNotNullOrderByDeletedAtDesc(@Param("user_id") Long userId, Pageable pageable); + @Query(value = "SELECT ui FROM UserImage ui WHERE ui.user.id = :user_id " + + "AND ui.deletedAt != NULL ORDER BY ui.deletedAt DESC") + Page findAllByUserAndDeletedAtNotNullOrderByDeletedAtDesc(@Param("user_id") Long userId, + Pageable pageable); - @Query(value = "SELECT ui FROM UserImage ui WHERE ui.id NOT IN (" + - "SELECT MIN(ui.id) FROM UserImage ui GROUP BY ui.user.id" + - ") ORDER BY ui.createdAt DESC") - Page findAllChangedOrderByCreatedAtDesc(Pageable pageable); + @Query(value = "SELECT ui FROM UserImage ui WHERE ui.id NOT IN (" + + "SELECT MIN(ui.id) FROM UserImage ui GROUP BY ui.user.id" + + ") ORDER BY ui.createdAt DESC") + Page findAllChangedOrderByCreatedAtDesc(Pageable pageable); - @Query(value = "SELECT ui FROM UserImage ui WHERE ui.id NOT IN (" + - "SELECT MIN(ui.id) FROM UserImage ui GROUP BY ui.user.id" + - ") AND ui.user.id = :user_id ORDER BY ui.createdAt DESC") - Page findAllByUserOrderByCreatedAtDesc(@Param("user_id") Long userId, Pageable pageable); + @Query(value = "SELECT ui FROM UserImage ui WHERE ui.id NOT IN (" + + "SELECT MIN(ui.id) FROM UserImage ui GROUP BY ui.user.id" + + ") AND ui.user.id = :user_id ORDER BY ui.createdAt DESC") + Page findAllByUserOrderByCreatedAtDesc(@Param("user_id") Long userId, Pageable pageable); - @Query(value = "SELECT ui FROM UserImage ui WHERE ui.isCurrent IS TRUE" + - " ORDER BY ui.createdAt DESC") - Page findAllByIsCurrentTrueOrderByCreatedAtDesc(Pageable pageable); + @Query(value = "SELECT ui FROM UserImage ui WHERE ui.isCurrent IS TRUE" + + " ORDER BY ui.createdAt DESC") + Page findAllByIsCurrentTrueOrderByCreatedAtDesc(Pageable pageable); - @Query(value = "SELECT ui FROM UserImage ui WHERE ui.isCurrent IS True" + - " AND ui.user.id = :user_id ORDER BY ui.createdAt DESC") - Page findAllByUserAndIsCurrentTrueOrderByCreatedAtDesc(@Param("user_id") Long userId, Pageable pageable); + @Query(value = "SELECT ui FROM UserImage ui WHERE ui.isCurrent IS True" + + " AND ui.user.id = :user_id ORDER BY ui.createdAt DESC") + Page findAllByUserAndIsCurrentTrueOrderByCreatedAtDesc(@Param("user_id") Long userId, Pageable pageable); } diff --git a/src/main/java/com/gg/server/admin/user/dto/UserAdminDto.java b/src/main/java/com/gg/server/admin/user/dto/UserAdminDto.java index 521f0c36e..f60d19503 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserAdminDto.java +++ b/src/main/java/com/gg/server/admin/user/dto/UserAdminDto.java @@ -1,54 +1,62 @@ -package com.gg.server.admin.user.dto; - -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserImage; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; -import lombok.Builder; -import lombok.Getter; - -@Getter -@Builder -public class UserAdminDto { - private Long id; - private String intraId; - private String eMail; - private String imageUri; - private RacketType racketType; - private RoleType roleType; - private Integer totalExp; - private SnsType snsNotiOpt; - - static public UserAdminDto from (User user, UserImage userImage) { - UserAdminDto userDto; - if (user == null) { - userDto = null; - } else { - userDto = UserAdminDto.builder() - .id(user.getId()) - .intraId(user.getIntraId()) - .eMail(user.getEMail()) - .imageUri(userImage.getImageUri()) - .racketType(user.getRacketType()) - .roleType(user.getRoleType()) - .totalExp(user.getTotalExp()) - .snsNotiOpt(user.getSnsNotiOpt()) - .build(); - } - return userDto; - } - - @Override - public String toString() { - return "UserDto{" + - "id=" + id + - ", intraId='" + intraId + '\'' + - ", eMail='" + eMail + '\'' + - ", imageUri='" + imageUri + '\'' + - ", racketType=" + racketType + '\'' + - ", roleType=" + roleType + '\'' + - ", totalExp=" + totalExp + - '}'; - } -} +package com.gg.server.admin.user.dto; + +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserImage; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class UserAdminDto { + private Long id; + private String intraId; + private String eMail; + private String imageUri; + private RacketType racketType; + private RoleType roleType; + private Integer totalExp; + private SnsType snsNotiOpt; + + public static UserAdminDto from(User user, UserImage userImage) { + UserAdminDto userDto; + if (user == null) { + userDto = null; + } else { + userDto = UserAdminDto.builder() + .id(user.getId()) + .intraId(user.getIntraId()) + .eMail(user.getEMail()) + .imageUri(userImage.getImageUri()) + .racketType(user.getRacketType()) + .roleType(user.getRoleType()) + .totalExp(user.getTotalExp()) + .snsNotiOpt(user.getSnsNotiOpt()) + .build(); + } + return userDto; + } + + @Override + public String toString() { + return "UserDto{" + + "id=" + + id + + ", intraId='" + + intraId + '\'' + + ", eMail='" + + eMail + '\'' + + ", imageUri='" + + imageUri + '\'' + + ", racketType=" + + racketType + '\'' + + ", roleType=" + + roleType + '\'' + + ", totalExp=" + + totalExp + + '}'; + } +} diff --git a/src/main/java/com/gg/server/admin/user/dto/UserDetailAdminResponseDto.java b/src/main/java/com/gg/server/admin/user/dto/UserDetailAdminResponseDto.java index 819134d75..071e21e02 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserDetailAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/user/dto/UserDetailAdminResponseDto.java @@ -1,71 +1,76 @@ -package com.gg.server.admin.user.dto; - -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.user.data.User; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@AllArgsConstructor -@NoArgsConstructor -public class UserDetailAdminResponseDto { - private Long userId; - private String intraId; - private String userImageUri; - private String racketType; - private String statusMessage; - private Integer wins; - private Integer losses; - private Integer ppp; - private String email; - private String roleType; - private Integer exp; - private Integer coin; - - public UserDetailAdminResponseDto(User user, RankRedis rank) { - this.userId = user.getId(); - this.intraId = user.getIntraId(); - this.userImageUri = user.getImageUri(); - this.racketType = user.getRacketType().getCode(); - this.statusMessage = rank.getStatusMessage(); - this.wins = rank.getWins(); - this.losses = rank.getLosses(); - this.ppp = rank.getPpp(); - this.email = user.getEMail(); - this.roleType = user.getRoleType().getKey(); - this.exp = user.getTotalExp(); - this.coin = user.getGgCoin(); - } - - public UserDetailAdminResponseDto(User user) { - this.userId = user.getId(); - this.intraId = user.getIntraId(); - this.userImageUri = user.getImageUri(); - this.racketType = user.getRacketType().getCode(); - this.statusMessage = ""; - this.wins = 0; - this.losses = 0; - this.ppp = 0; - this.email = user.getEMail() == null ? "" : user.getEMail(); - this.roleType = user.getRoleType().getKey(); - this.exp = user.getTotalExp(); - this.coin = user.getGgCoin(); - } - - @Override - public String toString() { - return "UserDetailResponseDto{" + - "intraId='" + intraId + '\'' + - ", userImageUri='" + userImageUri + '\'' + - ", racketType='" + racketType + '\'' + - ", statusMessage='" + statusMessage + '\'' + - ", wins='" + wins.toString() + '\'' + - ", losses='" + losses.toString() + '\'' + - ", ppp='" + ppp.toString() + '\'' + - ", email='" + email + '\'' + - ", roleType='" + roleType + '\'' + - ", coin='" + coin + '\'' + - '}'; - } -} +package com.gg.server.admin.user.dto; + +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.user.data.User; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +public class UserDetailAdminResponseDto { + private Long userId; + private String intraId; + private String userImageUri; + private String racketType; + private String statusMessage; + private Integer wins; + private Integer losses; + private Integer ppp; + private String email; + private String roleType; + private Integer exp; + private Integer coin; + + public UserDetailAdminResponseDto(User user, RankRedis rank) { + this.userId = user.getId(); + this.intraId = user.getIntraId(); + this.userImageUri = user.getImageUri(); + this.racketType = user.getRacketType().getCode(); + this.statusMessage = rank.getStatusMessage(); + this.wins = rank.getWins(); + this.losses = rank.getLosses(); + this.ppp = rank.getPpp(); + this.email = user.getEMail(); + this.roleType = user.getRoleType().getKey(); + this.exp = user.getTotalExp(); + this.coin = user.getGgCoin(); + } + + public UserDetailAdminResponseDto(User user) { + this.userId = user.getId(); + this.intraId = user.getIntraId(); + this.userImageUri = user.getImageUri(); + this.racketType = user.getRacketType().getCode(); + this.statusMessage = ""; + this.wins = 0; + this.losses = 0; + this.ppp = 0; + this.email = user.getEMail() == null ? "" : user.getEMail(); + this.roleType = user.getRoleType().getKey(); + this.exp = user.getTotalExp(); + this.coin = user.getGgCoin(); + } + + @Override + public String toString() { + return "UserDetailResponseDto{" + + "intraId='" + intraId + '\'' + + ", userImageUri='" + userImageUri + + '\'' + + ", racketType='" + + racketType + '\'' + + ", statusMessage='" + + statusMessage + '\'' + + ", wins='" + wins.toString() + + '\'' + ", losses='" + losses.toString() + + '\'' + ", ppp='" + ppp.toString() + '\'' + + ", email='" + email + '\'' + ", roleType='" + + roleType + '\'' + + ", coin='" + coin + + '\'' + + '}'; + } +} diff --git a/src/main/java/com/gg/server/admin/user/dto/UserImageAdminDto.java b/src/main/java/com/gg/server/admin/user/dto/UserImageAdminDto.java index a0a90fda1..ad3cefba5 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserImageAdminDto.java +++ b/src/main/java/com/gg/server/admin/user/dto/UserImageAdminDto.java @@ -1,29 +1,30 @@ package com.gg.server.admin.user.dto; +import java.time.LocalDateTime; + import com.gg.server.domain.user.data.UserImage; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; - @Getter @NoArgsConstructor @AllArgsConstructor public class UserImageAdminDto { - Long id; - String userIntraId; - String imageUri; - LocalDateTime createdAt; - LocalDateTime deletedAt; - Boolean isCurrent; + Long id; + String userIntraId; + String imageUri; + LocalDateTime createdAt; + LocalDateTime deletedAt; + Boolean isCurrent; - public UserImageAdminDto(UserImage userImage) { - this.id = userImage.getId(); - this.userIntraId = userImage.getUser().getIntraId(); - this.imageUri = userImage.getImageUri(); - this.createdAt = userImage.getCreatedAt(); - this.deletedAt = userImage.getDeletedAt(); - this.isCurrent = userImage.getIsCurrent(); - } + public UserImageAdminDto(UserImage userImage) { + this.id = userImage.getId(); + this.userIntraId = userImage.getUser().getIntraId(); + this.imageUri = userImage.getImageUri(); + this.createdAt = userImage.getCreatedAt(); + this.deletedAt = userImage.getDeletedAt(); + this.isCurrent = userImage.getIsCurrent(); + } } diff --git a/src/main/java/com/gg/server/admin/user/dto/UserImageListAdminResponseDto.java b/src/main/java/com/gg/server/admin/user/dto/UserImageListAdminResponseDto.java index 1c07d01a2..11c731298 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserImageListAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/user/dto/UserImageListAdminResponseDto.java @@ -1,16 +1,15 @@ package com.gg.server.admin.user.dto; -import com.gg.server.admin.coin.dto.CoinPolicyAdminResponseDto; +import java.util.List; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @Getter @NoArgsConstructor @AllArgsConstructor public class UserImageListAdminResponseDto { - private List userImageList; - private int totalPage; + private List userImageList; + private int totalPage; } diff --git a/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminDto.java b/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminDto.java index 7acb80653..6ec679b84 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminDto.java +++ b/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminDto.java @@ -1,32 +1,33 @@ -package com.gg.server.admin.user.dto; - -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RoleType; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor -public class UserSearchAdminDto { - private Long id; - private String intraId; - private String statusMessage; - private RoleType roleType; - - public UserSearchAdminDto (User user, String statusMessage) { - this.id = user.getId(); - this.intraId = user.getIntraId(); - this.statusMessage = statusMessage; - this.roleType = user.getRoleType(); - } - - @Override - public String toString() { - return "{" + - "id=" + id + - ", intraId='" + intraId + '\'' + - ", statusMessage='" + statusMessage + '\'' + - ", roleType=" + roleType + - '}'; - } -} +package com.gg.server.admin.user.dto; + +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.type.RoleType; + +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public class UserSearchAdminDto { + private Long id; + private String intraId; + private String statusMessage; + private RoleType roleType; + + public UserSearchAdminDto(User user, String statusMessage) { + this.id = user.getId(); + this.intraId = user.getIntraId(); + this.statusMessage = statusMessage; + this.roleType = user.getRoleType(); + } + + @Override + public String toString() { + return "{" + + "id=" + id + + ", intraId='" + intraId + '\'' + + ", statusMessage='" + statusMessage + '\'' + + ", roleType=" + roleType + + '}'; + } +} diff --git a/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminRequestDto.java b/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminRequestDto.java index bcde2e7ff..e60edae04 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminRequestDto.java +++ b/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminRequestDto.java @@ -1,21 +1,19 @@ package com.gg.server.admin.user.dto; import com.gg.server.global.dto.PageRequestDto; -import lombok.AllArgsConstructor; + import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.Setter; - @Getter @Setter public class UserSearchAdminRequestDto extends PageRequestDto { - private String intraId; - private String userFilter; + private String intraId; + private String userFilter; - public UserSearchAdminRequestDto(Integer page, Integer size, String intraId, String userFilter) { - super(page, size); - this.intraId = intraId; - this.userFilter = userFilter; - } + public UserSearchAdminRequestDto(Integer page, Integer size, String intraId, String userFilter) { + super(page, size); + this.intraId = intraId; + this.userFilter = userFilter; + } } diff --git a/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminResponseDto.java b/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminResponseDto.java index c0fb57ef6..fcc0ae89f 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminResponseDto.java @@ -1,25 +1,26 @@ -package com.gg.server.admin.user.dto; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.List; -import java.util.stream.Collectors; -import lombok.NoArgsConstructor; - -@Getter -@AllArgsConstructor -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class UserSearchAdminResponseDto { - private List userSearchAdminDtos; - private Integer totalPage; - - public void filterUser(String filterString) { - if (filterString == null) - return ; - this.userSearchAdminDtos = this.userSearchAdminDtos.stream() - .filter(userSearchAdminDto -> userSearchAdminDto.getIntraId().equals(filterString)) - .collect(Collectors.toList()); - } -} +package com.gg.server.admin.user.dto; + +import java.util.List; +import java.util.stream.Collectors; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class UserSearchAdminResponseDto { + private List userSearchAdminDtos; + private Integer totalPage; + + public void filterUser(String filterString) { + if (filterString == null) { + return; + } + this.userSearchAdminDtos = this.userSearchAdminDtos.stream() + .filter(userSearchAdminDto -> userSearchAdminDto.getIntraId().equals(filterString)) + .collect(Collectors.toList()); + } +} diff --git a/src/main/java/com/gg/server/admin/user/dto/UserUpdateAdminRequestDto.java b/src/main/java/com/gg/server/admin/user/dto/UserUpdateAdminRequestDto.java index 7175be106..e96db7aaa 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserUpdateAdminRequestDto.java +++ b/src/main/java/com/gg/server/admin/user/dto/UserUpdateAdminRequestDto.java @@ -1,33 +1,46 @@ package com.gg.server.admin.user.dto; import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; + import lombok.Builder; import lombok.Getter; @Builder @Getter public class UserUpdateAdminRequestDto { - private RacketType racketType; - private String statusMessage; - private Integer wins; - private Integer losses; - private Integer ppp; - private String email; - private String roleType; - private Integer coin; + private RacketType racketType; + private String statusMessage; + private Integer wins; + private Integer losses; + private Integer ppp; + private String email; + private String roleType; + private Integer coin; - @Override - public String toString() { - return "UserUpdateRequestAdminDto{" + '\'' + - ", racketType=" + racketType + - ", statusMessage='" + statusMessage + '\'' + - ", wins='" + wins + '\'' + - ", losses'" + losses + '\'' + - ", ppp='" + ppp + '\'' + - ", email='" + email + '\'' + - ", roleType='" + roleType + '\'' + - ", coin='" + coin + '\'' + - '}'; - } + @Override + public String toString() { + return "UserUpdateRequestAdminDto{" + + '\'' + + ", racketType=" + + racketType + + ", statusMessage='" + + statusMessage + + '\'' + + ", wins='" + + wins + '\'' + + ", losses'" + + losses + '\'' + + ", ppp='" + + ppp + '\'' + + ", email='" + + email + + '\'' + + ", roleType='" + + roleType + + '\'' + + ", coin='" + + coin + + '\'' + + '}'; + } } diff --git a/src/main/java/com/gg/server/admin/user/service/UserAdminService.java b/src/main/java/com/gg/server/admin/user/service/UserAdminService.java index 65ce4f42d..2f0043728 100644 --- a/src/main/java/com/gg/server/admin/user/service/UserAdminService.java +++ b/src/main/java/com/gg/server/admin/user/service/UserAdminService.java @@ -1,185 +1,208 @@ -package com.gg.server.admin.user.service; -import com.gg.server.admin.rank.service.RankRedisAdminService; -import com.gg.server.admin.season.data.SeasonAdminRepository; -import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.admin.user.data.UserImageAdminRepository; -import com.gg.server.admin.user.dto.*; -import com.gg.server.domain.rank.data.Rank; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.exception.RankNotFoundException; -import com.gg.server.domain.rank.exception.RedisDataNotFoundException; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.exception.SeasonNotFoundException; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserImage; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.service.UserFindService; -import com.gg.server.global.utils.aws.AsyncNewUserImageUploader; -import lombok.AllArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -@Service -@AllArgsConstructor -public class UserAdminService { - - private final UserAdminRepository userAdminRepository; - private final SeasonAdminRepository seasonAdminRepository; - private final RankRepository rankRepository; - private final RankRedisRepository rankRedisRepository; - private final RankRedisAdminService rankRedisAdminService; - private final AsyncNewUserImageUploader asyncNewUserImageUploader; - private final UserFindService userFindService; - private final UserImageAdminRepository userImageAdminRepository; - - @Transactional(readOnly = true) - public UserSearchAdminResponseDto searchAll(Pageable pageable) { - Page userPage = userAdminRepository.findAll(pageable); - List userSearchAdminDtos = new ArrayList(); - for (User user : userPage.getContent()) - userSearchAdminDtos.add(new UserSearchAdminDto(user, userFindService.getUserStatusMessage(user))); - return new UserSearchAdminResponseDto(userSearchAdminDtos, userPage.getTotalPages()); - } - - @Transactional(readOnly = true) - public UserSearchAdminResponseDto searchByIntraId(Pageable pageable, String intraId) { - Page userPage = userAdminRepository.findByIntraId(pageable, intraId); - List userSearchAdminDtos = new ArrayList(); - for (User user : userPage.getContent()) - userSearchAdminDtos.add(new UserSearchAdminDto(user, userFindService.getUserStatusMessage(user))); - return new UserSearchAdminResponseDto(userSearchAdminDtos, userPage.getTotalPages()); - } - - /* 문자열을 포함하는 intraId를 가진 유저 찾기 */ - @Transactional(readOnly = true) - public UserSearchAdminResponseDto findByPartsOfIntraId(String intraId, Pageable pageable) { - Page userPage = userAdminRepository.findByIntraIdContains(pageable, intraId); - List userSearchAdminDtos = new ArrayList(); - for (User user : userPage.getContent()) - userSearchAdminDtos.add(new UserSearchAdminDto(user, userFindService.getUserStatusMessage(user))); - return new UserSearchAdminResponseDto(userSearchAdminDtos, userPage.getTotalPages()); - } - - @Transactional(readOnly = true) - public UserDetailAdminResponseDto getUserDetailByIntraId(String intraId) { - User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); - Season currSeason = seasonAdminRepository.findCurrentSeason(LocalDateTime.now()).orElseThrow(() -> new SeasonNotFoundException()); - try { - RankRedis userCurrRank = rankRedisRepository.findRankByUserId(RedisKeyManager.getHashKey(currSeason.getId()), - user.getId()); - return new UserDetailAdminResponseDto(user, userCurrRank); - } catch (RedisDataNotFoundException e){ - return new UserDetailAdminResponseDto(user); - } - } - - @Transactional - public void updateUserDetail(String intraId, - UserUpdateAdminRequestDto userUpdateAdminRequestDto, - MultipartFile userImageFile) throws IOException{ - Season currSeason = seasonAdminRepository.findCurrentSeason(LocalDateTime.now()).orElseThrow(() -> new SeasonNotFoundException()); - User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); - - user.modifyUserDetail(userUpdateAdminRequestDto); - if (userImageFile != null) - asyncNewUserImageUploader.update(intraId, userImageFile); - updateUserRank(user.getId(), currSeason.getId(), userUpdateAdminRequestDto); - } - - private void updateUserRank(Long userId, Long currSeasonId, UserUpdateAdminRequestDto updateReq) { - Rank userCurrRank = rankRepository.findByUserIdAndSeasonId(userId, currSeasonId).orElseThrow(() -> new RankNotFoundException()); - RankRedis userCurrRankRedis = rankRedisRepository.findRankByUserId(RedisKeyManager.getHashKey(currSeasonId), - userId); - - userCurrRank.modifyUserRank(updateReq); - userCurrRank.setStatusMessage(updateReq.getStatusMessage()); - - userCurrRankRedis.changedRank(updateReq.getPpp(), - updateReq.getWins(), - updateReq.getLosses()); - userCurrRankRedis.setStatusMessage(updateReq.getStatusMessage()); - rankRedisAdminService.updateRankUser(RedisKeyManager.getHashKey(currSeasonId), - RedisKeyManager.getZSetKey(currSeasonId), - userId, userCurrRankRedis); - } - - public String getUserImageToString(User user) { - UserImage userImage = userImageAdminRepository.findTopByUserAndDeletedAtIsNullOrderByCreatedAtDesc(user).orElse(null); - if (userImage == null) - return "null"; - else { - userImage.updateIsCurrent(); - return userImage.getImageUri(); - } - } - - @Transactional - public void deleteUserProfileImage(String intraId) { - User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); - UserImage userImage = userImageAdminRepository.findTopByUserAndIsCurrentIsTrueOrderByCreatedAtDesc(user).orElseThrow(UserNotFoundException::new); - userImage.updateDeletedAt(LocalDateTime.now()); - String userImageUri = getUserImageToString(user); - user.updateImageUri(userImageUri); - } - - @Transactional(readOnly = true) - public UserImageListAdminResponseDto getUserImageDeleteList(Pageable pageable) { - Page userImagePage = userImageAdminRepository.findAllByDeletedAtNotNullOrderByDeletedAtDesc(pageable); - Page userImageAdminDto = userImagePage.map(UserImageAdminDto::new); - - return new UserImageListAdminResponseDto(userImageAdminDto.getContent(), userImageAdminDto.getTotalPages()); - } - @Transactional(readOnly = true) - public UserImageListAdminResponseDto getUserImageDeleteListByIntraId(Pageable pageable, String intraId) { - User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); - Page userImagePage = userImageAdminRepository.findAllByUserAndDeletedAtNotNullOrderByDeletedAtDesc(user.getId(), pageable); - Page userImageAdminDto = userImagePage.map(UserImageAdminDto::new); - - return new UserImageListAdminResponseDto(userImageAdminDto.getContent(), userImageAdminDto.getTotalPages()); - } - - @Transactional(readOnly = true) - public UserImageListAdminResponseDto getUserImageList(Pageable pageable) { - Page userImagePage = userImageAdminRepository.findAllChangedOrderByCreatedAtDesc(pageable); - Page userImageAdminDto = userImagePage.map(UserImageAdminDto::new); - - return new UserImageListAdminResponseDto(userImageAdminDto.getContent(), userImageAdminDto.getTotalPages()); - } - - @Transactional(readOnly = true) - public UserImageListAdminResponseDto getUserImageListByIntraId(Pageable pageable, String intraId) { - User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); - Page userImagePage = userImageAdminRepository.findAllByUserOrderByCreatedAtDesc(user.getId(), pageable); - Page userImageAdminDto = userImagePage.map(UserImageAdminDto::new); - - return new UserImageListAdminResponseDto(userImageAdminDto.getContent(), userImageAdminDto.getTotalPages()); - } - - @Transactional(readOnly = true) - public UserImageListAdminResponseDto getUserImageCurrent(Pageable pageable) { - Page userImagePage = userImageAdminRepository.findAllByIsCurrentTrueOrderByCreatedAtDesc(pageable); - Page userImageAdminDto = userImagePage.map(UserImageAdminDto::new); - - return new UserImageListAdminResponseDto(userImageAdminDto.getContent(), userImageAdminDto.getTotalPages()); - } - - @Transactional(readOnly = true) - public UserImageListAdminResponseDto getUserImageCurrentByIntraId(Pageable pageable, String intraId) { - User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); - Page userImagePage = userImageAdminRepository.findAllByUserAndIsCurrentTrueOrderByCreatedAtDesc(user.getId(), pageable); - Page userImageAdminDto = userImagePage.map(UserImageAdminDto::new); - - return new UserImageListAdminResponseDto(userImageAdminDto.getContent(), userImageAdminDto.getTotalPages()); - } -} +package com.gg.server.admin.user.service; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import com.gg.server.admin.rank.service.RankRedisAdminService; +import com.gg.server.admin.season.data.SeasonAdminRepository; +import com.gg.server.admin.user.data.UserAdminRepository; +import com.gg.server.admin.user.data.UserImageAdminRepository; +import com.gg.server.admin.user.dto.UserDetailAdminResponseDto; +import com.gg.server.admin.user.dto.UserImageAdminDto; +import com.gg.server.admin.user.dto.UserImageListAdminResponseDto; +import com.gg.server.admin.user.dto.UserSearchAdminDto; +import com.gg.server.admin.user.dto.UserSearchAdminResponseDto; +import com.gg.server.admin.user.dto.UserUpdateAdminRequestDto; +import com.gg.server.domain.rank.data.Rank; +import com.gg.server.domain.rank.data.RankRepository; +import com.gg.server.domain.rank.exception.RankNotFoundException; +import com.gg.server.domain.rank.exception.RedisDataNotFoundException; +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.rank.redis.RedisKeyManager; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.exception.SeasonNotFoundException; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserImage; +import com.gg.server.domain.user.exception.UserNotFoundException; +import com.gg.server.domain.user.service.UserFindService; +import com.gg.server.global.utils.aws.AsyncNewUserImageUploader; + +import lombok.AllArgsConstructor; + +@Service +@AllArgsConstructor +public class UserAdminService { + + private final UserAdminRepository userAdminRepository; + private final SeasonAdminRepository seasonAdminRepository; + private final RankRepository rankRepository; + private final RankRedisRepository rankRedisRepository; + private final RankRedisAdminService rankRedisAdminService; + private final AsyncNewUserImageUploader asyncNewUserImageUploader; + private final UserFindService userFindService; + private final UserImageAdminRepository userImageAdminRepository; + + @Transactional(readOnly = true) + public UserSearchAdminResponseDto searchAll(Pageable pageable) { + Page userPage = userAdminRepository.findAll(pageable); + List userSearchAdminDtos = new ArrayList(); + for (User user : userPage.getContent()) { + userSearchAdminDtos.add(new UserSearchAdminDto(user, userFindService.getUserStatusMessage(user))); + } + return new UserSearchAdminResponseDto(userSearchAdminDtos, userPage.getTotalPages()); + } + + @Transactional(readOnly = true) + public UserSearchAdminResponseDto searchByIntraId(Pageable pageable, String intraId) { + Page userPage = userAdminRepository.findByIntraId(pageable, intraId); + List userSearchAdminDtos = new ArrayList(); + for (User user : userPage.getContent()) { + userSearchAdminDtos.add(new UserSearchAdminDto(user, userFindService.getUserStatusMessage(user))); + } + return new UserSearchAdminResponseDto(userSearchAdminDtos, userPage.getTotalPages()); + } + + /* 문자열을 포함하는 intraId를 가진 유저 찾기 */ + @Transactional(readOnly = true) + public UserSearchAdminResponseDto findByPartsOfIntraId(String intraId, Pageable pageable) { + Page userPage = userAdminRepository.findByIntraIdContains(pageable, intraId); + List userSearchAdminDtos = new ArrayList(); + for (User user : userPage.getContent()) { + userSearchAdminDtos.add(new UserSearchAdminDto(user, userFindService.getUserStatusMessage(user))); + } + return new UserSearchAdminResponseDto(userSearchAdminDtos, userPage.getTotalPages()); + } + + @Transactional(readOnly = true) + public UserDetailAdminResponseDto getUserDetailByIntraId(String intraId) { + User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); + Season currSeason = seasonAdminRepository.findCurrentSeason(LocalDateTime.now()) + .orElseThrow(() -> new SeasonNotFoundException()); + try { + RankRedis userCurrRank = rankRedisRepository.findRankByUserId( + RedisKeyManager.getHashKey(currSeason.getId()), + user.getId()); + return new UserDetailAdminResponseDto(user, userCurrRank); + } catch (RedisDataNotFoundException e) { + return new UserDetailAdminResponseDto(user); + } + } + + @Transactional + public void updateUserDetail(String intraId, + UserUpdateAdminRequestDto userUpdateAdminRequestDto, + MultipartFile userImageFile) throws IOException { + Season currSeason = seasonAdminRepository.findCurrentSeason(LocalDateTime.now()) + .orElseThrow(() -> new SeasonNotFoundException()); + User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); + + user.modifyUserDetail(userUpdateAdminRequestDto); + if (userImageFile != null) { + asyncNewUserImageUploader.update(intraId, userImageFile); + } + updateUserRank(user.getId(), currSeason.getId(), userUpdateAdminRequestDto); + } + + private void updateUserRank(Long userId, Long currSeasonId, UserUpdateAdminRequestDto updateReq) { + Rank userCurrRank = rankRepository.findByUserIdAndSeasonId(userId, currSeasonId) + .orElseThrow(() -> new RankNotFoundException()); + RankRedis userCurrRankRedis = rankRedisRepository.findRankByUserId(RedisKeyManager.getHashKey(currSeasonId), + userId); + + userCurrRank.modifyUserRank(updateReq); + userCurrRank.setStatusMessage(updateReq.getStatusMessage()); + + userCurrRankRedis.changedRank(updateReq.getPpp(), + updateReq.getWins(), + updateReq.getLosses()); + userCurrRankRedis.setStatusMessage(updateReq.getStatusMessage()); + rankRedisAdminService.updateRankUser(RedisKeyManager.getHashKey(currSeasonId), + RedisKeyManager.getZSetKey(currSeasonId), + userId, userCurrRankRedis); + } + + public String getUserImageToString(User user) { + UserImage userImage = userImageAdminRepository.findTopByUserAndDeletedAtIsNullOrderByCreatedAtDesc(user) + .orElse(null); + if (userImage == null) { + return "null"; + } else { + userImage.updateIsCurrent(); + return userImage.getImageUri(); + } + } + + @Transactional + public void deleteUserProfileImage(String intraId) { + User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); + UserImage userImage = userImageAdminRepository.findTopByUserAndIsCurrentIsTrueOrderByCreatedAtDesc(user) + .orElseThrow(UserNotFoundException::new); + userImage.updateDeletedAt(LocalDateTime.now()); + String userImageUri = getUserImageToString(user); + user.updateImageUri(userImageUri); + } + + @Transactional(readOnly = true) + public UserImageListAdminResponseDto getUserImageDeleteList(Pageable pageable) { + Page userImagePage = userImageAdminRepository.findAllByDeletedAtNotNullOrderByDeletedAtDesc( + pageable); + Page userImageAdminDto = userImagePage.map(UserImageAdminDto::new); + + return new UserImageListAdminResponseDto(userImageAdminDto.getContent(), userImageAdminDto.getTotalPages()); + } + + @Transactional(readOnly = true) + public UserImageListAdminResponseDto getUserImageDeleteListByIntraId(Pageable pageable, String intraId) { + User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); + Page userImagePage = userImageAdminRepository.findAllByUserAndDeletedAtNotNullOrderByDeletedAtDesc( + user.getId(), pageable); + Page userImageAdminDto = userImagePage.map(UserImageAdminDto::new); + + return new UserImageListAdminResponseDto(userImageAdminDto.getContent(), userImageAdminDto.getTotalPages()); + } + + @Transactional(readOnly = true) + public UserImageListAdminResponseDto getUserImageList(Pageable pageable) { + Page userImagePage = userImageAdminRepository.findAllChangedOrderByCreatedAtDesc(pageable); + Page userImageAdminDto = userImagePage.map(UserImageAdminDto::new); + + return new UserImageListAdminResponseDto(userImageAdminDto.getContent(), userImageAdminDto.getTotalPages()); + } + + @Transactional(readOnly = true) + public UserImageListAdminResponseDto getUserImageListByIntraId(Pageable pageable, String intraId) { + User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); + Page userImagePage = userImageAdminRepository.findAllByUserOrderByCreatedAtDesc(user.getId(), + pageable); + Page userImageAdminDto = userImagePage.map(UserImageAdminDto::new); + + return new UserImageListAdminResponseDto(userImageAdminDto.getContent(), userImageAdminDto.getTotalPages()); + } + + @Transactional(readOnly = true) + public UserImageListAdminResponseDto getUserImageCurrent(Pageable pageable) { + Page userImagePage = userImageAdminRepository.findAllByIsCurrentTrueOrderByCreatedAtDesc(pageable); + Page userImageAdminDto = userImagePage.map(UserImageAdminDto::new); + + return new UserImageListAdminResponseDto(userImageAdminDto.getContent(), userImageAdminDto.getTotalPages()); + } + + @Transactional(readOnly = true) + public UserImageListAdminResponseDto getUserImageCurrentByIntraId(Pageable pageable, String intraId) { + User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); + Page userImagePage = userImageAdminRepository.findAllByUserAndIsCurrentTrueOrderByCreatedAtDesc( + user.getId(), pageable); + Page userImageAdminDto = userImagePage.map(UserImageAdminDto::new); + + return new UserImageListAdminResponseDto(userImageAdminDto.getContent(), userImageAdminDto.getTotalPages()); + } +} diff --git a/src/main/java/com/gg/server/domain/announcement/controller/AnnouncementController.java b/src/main/java/com/gg/server/domain/announcement/controller/AnnouncementController.java index 53359d37f..a25094f4b 100644 --- a/src/main/java/com/gg/server/domain/announcement/controller/AnnouncementController.java +++ b/src/main/java/com/gg/server/domain/announcement/controller/AnnouncementController.java @@ -1,20 +1,22 @@ package com.gg.server.domain.announcement.controller; -import com.gg.server.domain.announcement.dto.AnnouncementResponseDto; -import com.gg.server.domain.announcement.service.AnnouncementService; -import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.gg.server.domain.announcement.dto.AnnouncementResponseDto; +import com.gg.server.domain.announcement.service.AnnouncementService; + +import lombok.RequiredArgsConstructor; + @RestController @RequiredArgsConstructor @RequestMapping(value = "/pingpong/announcement") public class AnnouncementController { - private final AnnouncementService announcementService; + private final AnnouncementService announcementService; - @GetMapping - public AnnouncementResponseDto findLastAnnounceContent() { - return new AnnouncementResponseDto(announcementService.findLastAnnouncement().getContent()); - } + @GetMapping + public AnnouncementResponseDto findLastAnnounceContent() { + return new AnnouncementResponseDto(announcementService.findLastAnnouncement().getContent()); + } } diff --git a/src/main/java/com/gg/server/domain/announcement/data/Announcement.java b/src/main/java/com/gg/server/domain/announcement/data/Announcement.java index 6f6532a4b..b960f8285 100644 --- a/src/main/java/com/gg/server/domain/announcement/data/Announcement.java +++ b/src/main/java/com/gg/server/domain/announcement/data/Announcement.java @@ -1,50 +1,56 @@ package com.gg.server.domain.announcement.data; +import java.time.LocalDateTime; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.validation.constraints.NotNull; + import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; import com.gg.server.global.utils.BaseTimeEntity; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import javax.persistence.*; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - @NoArgsConstructor @AllArgsConstructor @Getter @Entity public class Announcement extends BaseTimeEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - @NotNull - @Column(name = "content", length=1000) - private String content; - @NotNull - @Column(name = "creator_intra_id", length = 30) - private String creatorIntraId; - @Column(name = "deleter_intra_id", length = 30) - private String deleterIntraId; - @Column(name = "deleted_at") - private LocalDateTime deletedAt; - - @Builder - public Announcement(String content, String creatorIntraId){ - this.content = content; - this.creatorIntraId = creatorIntraId; - } - - public void update(String deleterIntraId, LocalDateTime deletedAt) { - this.deleterIntraId = deleterIntraId; - this.deletedAt = deletedAt; - } - - static public Announcement from(AnnouncementAdminAddDto addDto) { - return Announcement.builder() - .content(addDto.getContent()) - .creatorIntraId(addDto.getCreatorIntraId()) - .build(); - } + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + @NotNull + @Column(name = "content", length = 1000) + private String content; + @NotNull + @Column(name = "creator_intra_id", length = 30) + private String creatorIntraId; + @Column(name = "deleter_intra_id", length = 30) + private String deleterIntraId; + @Column(name = "deleted_at") + private LocalDateTime deletedAt; + + @Builder + public Announcement(String content, String creatorIntraId) { + this.content = content; + this.creatorIntraId = creatorIntraId; + } + + public void update(String deleterIntraId, LocalDateTime deletedAt) { + this.deleterIntraId = deleterIntraId; + this.deletedAt = deletedAt; + } + + public static Announcement from(AnnouncementAdminAddDto addDto) { + return Announcement.builder() + .content(addDto.getContent()) + .creatorIntraId(addDto.getCreatorIntraId()) + .build(); + } } diff --git a/src/main/java/com/gg/server/domain/announcement/data/AnnouncementRepository.java b/src/main/java/com/gg/server/domain/announcement/data/AnnouncementRepository.java index 60e58d2b7..dea9ba727 100644 --- a/src/main/java/com/gg/server/domain/announcement/data/AnnouncementRepository.java +++ b/src/main/java/com/gg/server/domain/announcement/data/AnnouncementRepository.java @@ -1,9 +1,9 @@ package com.gg.server.domain.announcement.data; -import org.springframework.data.jpa.repository.JpaRepository; - import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; + public interface AnnouncementRepository extends JpaRepository { - Optional findFirstByOrderByIdDesc(); + Optional findFirstByOrderByIdDesc(); } diff --git a/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementDto.java b/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementDto.java index 32aeefade..d21beae2f 100644 --- a/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementDto.java +++ b/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementDto.java @@ -1,8 +1,8 @@ package com.gg.server.domain.announcement.dto; import com.gg.server.domain.announcement.data.Announcement; + import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @@ -10,9 +10,9 @@ @AllArgsConstructor @NoArgsConstructor public class AnnouncementDto { - private String content; + private String content; - public static AnnouncementDto from(Announcement announcement) { - return new AnnouncementDto(announcement.getContent()); - } + public static AnnouncementDto from(Announcement announcement) { + return new AnnouncementDto(announcement.getContent()); + } } diff --git a/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementResponseDto.java b/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementResponseDto.java index c6d9a5734..9d6f9dfc2 100644 --- a/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementResponseDto.java +++ b/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementResponseDto.java @@ -1,11 +1,10 @@ package com.gg.server.domain.announcement.dto; import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Getter; @Getter @AllArgsConstructor public class AnnouncementResponseDto { - private String content; + private String content; } diff --git a/src/main/java/com/gg/server/domain/announcement/exception/AnnounceDupException.java b/src/main/java/com/gg/server/domain/announcement/exception/AnnounceDupException.java index 7f2138ad8..f664afc36 100644 --- a/src/main/java/com/gg/server/domain/announcement/exception/AnnounceDupException.java +++ b/src/main/java/com/gg/server/domain/announcement/exception/AnnounceDupException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.DuplicationException; public class AnnounceDupException extends DuplicationException { - public AnnounceDupException() { - super(ErrorCode.ANNOUNCE_DUPLICATE.getMessage(), ErrorCode.ANNOUNCE_DUPLICATE); - } + public AnnounceDupException() { + super(ErrorCode.ANNOUNCE_DUPLICATE.getMessage(), ErrorCode.ANNOUNCE_DUPLICATE); + } } diff --git a/src/main/java/com/gg/server/domain/announcement/exception/AnnounceNotFoundException.java b/src/main/java/com/gg/server/domain/announcement/exception/AnnounceNotFoundException.java index 888897093..8c835202f 100644 --- a/src/main/java/com/gg/server/domain/announcement/exception/AnnounceNotFoundException.java +++ b/src/main/java/com/gg/server/domain/announcement/exception/AnnounceNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.CustomRuntimeException; public class AnnounceNotFoundException extends CustomRuntimeException { - public AnnounceNotFoundException() { - super(ErrorCode.ANNOUNCE_NOT_FOUND.getMessage(), ErrorCode.ANNOUNCE_NOT_FOUND); - } -} \ No newline at end of file + public AnnounceNotFoundException() { + super(ErrorCode.ANNOUNCE_NOT_FOUND.getMessage(), ErrorCode.ANNOUNCE_NOT_FOUND); + } +} diff --git a/src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java b/src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java index 291ff7feb..b08e645fc 100644 --- a/src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java +++ b/src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java @@ -1,24 +1,28 @@ package com.gg.server.domain.announcement.service; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.domain.announcement.data.Announcement; import com.gg.server.domain.announcement.data.AnnouncementRepository; import com.gg.server.domain.announcement.dto.AnnouncementDto; import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; + import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor public class AnnouncementService { - private final AnnouncementRepository announcementRepository; + private final AnnouncementRepository announcementRepository; - @Transactional(readOnly = true) - public AnnouncementDto findLastAnnouncement() { - Announcement announcement = announcementRepository.findFirstByOrderByIdDesc().orElseThrow(() -> new AnnounceNotFoundException()); - if (announcement.getDeletedAt() != null) - return new AnnouncementDto(""); + @Transactional(readOnly = true) + public AnnouncementDto findLastAnnouncement() { + Announcement announcement = announcementRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new AnnounceNotFoundException()); + if (announcement.getDeletedAt() != null) { + return new AnnouncementDto(""); + } - return AnnouncementDto.from(announcement); - } + return AnnouncementDto.from(announcement); + } } diff --git a/src/main/java/com/gg/server/domain/coin/data/CoinHistory.java b/src/main/java/com/gg/server/domain/coin/data/CoinHistory.java index 96f746de4..cbaa82680 100644 --- a/src/main/java/com/gg/server/domain/coin/data/CoinHistory.java +++ b/src/main/java/com/gg/server/domain/coin/data/CoinHistory.java @@ -1,41 +1,51 @@ -package com.gg.server.domain.coin.data; - -import com.gg.server.domain.user.data.User; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.springframework.data.annotation.CreatedDate; - -import javax.persistence.*; -import java.time.LocalDateTime; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Entity -public class CoinHistory { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - @Column(name = "history", length = 30) - private String history; - - @Column(name = "amount") - private int amount; - - @CreatedDate - @Column(name = "createdAt", updatable = false, nullable = false) - private LocalDateTime createdAt; - - public CoinHistory(User user, String history, int amount) { - this.user = user; - this.history = history; - this.amount = amount; - this.createdAt = LocalDateTime.now(); - } -} \ No newline at end of file +package com.gg.server.domain.coin.data; + +import java.time.LocalDateTime; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +import org.springframework.data.annotation.CreatedDate; + +import com.gg.server.domain.user.data.User; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Entity +public class CoinHistory { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @Column(name = "history", length = 30) + private String history; + + @Column(name = "amount") + private int amount; + + @CreatedDate + @Column(name = "createdAt", updatable = false, nullable = false) + private LocalDateTime createdAt; + + public CoinHistory(User user, String history, int amount) { + this.user = user; + this.history = history; + this.amount = amount; + this.createdAt = LocalDateTime.now(); + } +} diff --git a/src/main/java/com/gg/server/domain/coin/data/CoinHistoryRepository.java b/src/main/java/com/gg/server/domain/coin/data/CoinHistoryRepository.java index 358b6c162..956400b60 100644 --- a/src/main/java/com/gg/server/domain/coin/data/CoinHistoryRepository.java +++ b/src/main/java/com/gg/server/domain/coin/data/CoinHistoryRepository.java @@ -1,24 +1,29 @@ package com.gg.server.domain.coin.data; -import com.gg.server.domain.feedback.data.Feedback; -import com.gg.server.domain.user.data.User; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; + import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; 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; -import java.util.Optional; +import com.gg.server.domain.user.data.User; public interface CoinHistoryRepository extends JpaRepository { - @Query("SELECT CASE WHEN COUNT(ch) > 0 THEN true ELSE false END FROM CoinHistory ch WHERE ch.user = :user AND ch.history = :history AND ch.createdAt >= :startOfDay AND ch.createdAt < :endOfDay") - boolean existsUserAttendedCheckToday(@Param("user") User user, @Param("history") String history, @Param("startOfDay") LocalDateTime startOfDay, @Param("endOfDay") LocalDateTime endOfDay); + @Query("SELECT CASE WHEN COUNT(ch) > 0 THEN true ELSE false END FROM CoinHistory ch " + + "WHERE ch.user = :user " + + "AND ch.history = :history " + + "AND ch.createdAt >= :startOfDay " + + "AND ch.createdAt < :endOfDay") + boolean existsUserAttendedCheckToday(@Param("user") User user, @Param("history") String history, + @Param("startOfDay") LocalDateTime startOfDay, @Param("endOfDay") LocalDateTime endOfDay); - Optional findFirstByOrderByIdDesc(); + Optional findFirstByOrderByIdDesc(); - List findAllByUserOrderByIdDesc(User user); + List findAllByUserOrderByIdDesc(User user); - Page findAllByUserOrderByIdDesc(User user, Pageable pageable); + Page findAllByUserOrderByIdDesc(User user, Pageable pageable); } diff --git a/src/main/java/com/gg/server/domain/coin/data/CoinPolicy.java b/src/main/java/com/gg/server/domain/coin/data/CoinPolicy.java index 28c884afd..fd895fb16 100644 --- a/src/main/java/com/gg/server/domain/coin/data/CoinPolicy.java +++ b/src/main/java/com/gg/server/domain/coin/data/CoinPolicy.java @@ -1,62 +1,72 @@ -package com.gg.server.domain.coin.data; - -import com.gg.server.admin.coin.dto.CoinPolicyAdminAddDto; -import com.gg.server.domain.user.data.User; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.springframework.data.annotation.CreatedDate; - -import javax.persistence.*; -import java.time.LocalDateTime; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Entity -public class CoinPolicy { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - @Column(name = "attendance") - private int attendance; - - @Column(name = "normal") - private int normal; - - @Column(name = "rankWin") - private int rankWin; - - @Column(name = "rankLose") - private int rankLose; - - @CreatedDate - @Column(name = "createdAt", updatable = false, nullable = false) - private LocalDateTime createdAt; - - @Builder - public CoinPolicy(User user, int attendance, int normal, int rankWin, int rankLose) { - this.user = user; - this.attendance = attendance; - this.normal = normal; - this.rankWin = rankWin; - this.rankLose = rankLose; - this.createdAt = LocalDateTime.now(); - } - - static public CoinPolicy from(User user, CoinPolicyAdminAddDto addDto) { - return CoinPolicy.builder() - .user(user) - .attendance(addDto.getAttendance()) - .normal(addDto.getNormal()) - .rankWin(addDto.getRankWin()) - .rankLose(addDto.getRankLose()) - .build(); - } -} \ No newline at end of file +package com.gg.server.domain.coin.data; + +import java.time.LocalDateTime; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +import org.springframework.data.annotation.CreatedDate; + +import com.gg.server.admin.coin.dto.CoinPolicyAdminAddDto; +import com.gg.server.domain.user.data.User; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Entity +public class CoinPolicy { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @Column(name = "attendance") + private int attendance; + + @Column(name = "normal") + private int normal; + + @Column(name = "rankWin") + private int rankWin; + + @Column(name = "rankLose") + private int rankLose; + + @CreatedDate + @Column(name = "createdAt", updatable = false, nullable = false) + private LocalDateTime createdAt; + + @Builder + public CoinPolicy(User user, int attendance, int normal, int rankWin, int rankLose) { + this.user = user; + this.attendance = attendance; + this.normal = normal; + this.rankWin = rankWin; + this.rankLose = rankLose; + this.createdAt = LocalDateTime.now(); + } + + public static CoinPolicy from(User user, CoinPolicyAdminAddDto addDto) { + return CoinPolicy.builder() + .user(user) + .attendance(addDto.getAttendance()) + .normal(addDto.getNormal()) + .rankWin(addDto.getRankWin()) + .rankLose(addDto.getRankLose()) + .build(); + } +} diff --git a/src/main/java/com/gg/server/domain/coin/data/CoinPolicyRepository.java b/src/main/java/com/gg/server/domain/coin/data/CoinPolicyRepository.java index 6e3eb8a77..f60f7ac7b 100644 --- a/src/main/java/com/gg/server/domain/coin/data/CoinPolicyRepository.java +++ b/src/main/java/com/gg/server/domain/coin/data/CoinPolicyRepository.java @@ -1,10 +1,10 @@ package com.gg.server.domain.coin.data; -import org.springframework.data.jpa.repository.JpaRepository; - import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; + public interface CoinPolicyRepository extends JpaRepository { - Optional findTopByOrderByCreatedAtDesc(); + Optional findTopByOrderByCreatedAtDesc(); } diff --git a/src/main/java/com/gg/server/domain/coin/dto/UserGameCoinResultDto.java b/src/main/java/com/gg/server/domain/coin/dto/UserGameCoinResultDto.java index 4030c370b..23f933cd4 100644 --- a/src/main/java/com/gg/server/domain/coin/dto/UserGameCoinResultDto.java +++ b/src/main/java/com/gg/server/domain/coin/dto/UserGameCoinResultDto.java @@ -6,13 +6,13 @@ @Getter @NoArgsConstructor public class UserGameCoinResultDto { - private int beforeCoin; - private int afterCoin; - private int coinIncrement; + private int beforeCoin; + private int afterCoin; + private int coinIncrement; - public UserGameCoinResultDto(int afterCoin, int coinIncrement) { - this.beforeCoin = afterCoin - coinIncrement; - this.afterCoin = afterCoin; - this.coinIncrement = coinIncrement; - } + public UserGameCoinResultDto(int afterCoin, int coinIncrement) { + this.beforeCoin = afterCoin - coinIncrement; + this.afterCoin = afterCoin; + this.coinIncrement = coinIncrement; + } } diff --git a/src/main/java/com/gg/server/domain/coin/exception/CoinHistoryNotFoundException.java b/src/main/java/com/gg/server/domain/coin/exception/CoinHistoryNotFoundException.java index c8e0710c5..902c165f7 100644 --- a/src/main/java/com/gg/server/domain/coin/exception/CoinHistoryNotFoundException.java +++ b/src/main/java/com/gg/server/domain/coin/exception/CoinHistoryNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.CustomRuntimeException; public class CoinHistoryNotFoundException extends CustomRuntimeException { - public CoinHistoryNotFoundException() { - super(ErrorCode.COIN_HISTORY_NOT_FOUND.getMessage(), ErrorCode.COIN_HISTORY_NOT_FOUND); - } + public CoinHistoryNotFoundException() { + super(ErrorCode.COIN_HISTORY_NOT_FOUND.getMessage(), ErrorCode.COIN_HISTORY_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/coin/exception/CoinPolicyNotFoundException.java b/src/main/java/com/gg/server/domain/coin/exception/CoinPolicyNotFoundException.java index 5e857eeab..ca7050f03 100644 --- a/src/main/java/com/gg/server/domain/coin/exception/CoinPolicyNotFoundException.java +++ b/src/main/java/com/gg/server/domain/coin/exception/CoinPolicyNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.CustomRuntimeException; public class CoinPolicyNotFoundException extends CustomRuntimeException { - public CoinPolicyNotFoundException() { - super(ErrorCode.CoinPolicy_NOT_FOUND.getMessage(), ErrorCode.CoinPolicy_NOT_FOUND); - } + public CoinPolicyNotFoundException() { + super(ErrorCode.CoinPolicy_NOT_FOUND.getMessage(), ErrorCode.CoinPolicy_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/coin/service/CoinHistoryService.java b/src/main/java/com/gg/server/domain/coin/service/CoinHistoryService.java index 36962a1f9..4ae1e109a 100644 --- a/src/main/java/com/gg/server/domain/coin/service/CoinHistoryService.java +++ b/src/main/java/com/gg/server/domain/coin/service/CoinHistoryService.java @@ -1,5 +1,10 @@ package com.gg.server.domain.coin.service; +import java.time.LocalDateTime; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.domain.coin.data.CoinHistory; import com.gg.server.domain.coin.data.CoinHistoryRepository; import com.gg.server.domain.coin.data.CoinPolicyRepository; @@ -7,70 +12,68 @@ import com.gg.server.domain.coin.type.HistoryType; import com.gg.server.domain.item.data.Item; import com.gg.server.domain.user.data.User; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; +import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class CoinHistoryService { - private final CoinHistoryRepository coinHistoryRepository; - private final CoinPolicyRepository coinPolicyRepository; + private final CoinHistoryRepository coinHistoryRepository; + private final CoinPolicyRepository coinPolicyRepository; - @Transactional - public void addAttendanceCoinHistory(User user) { - int amount = coinPolicyRepository.findTopByOrderByCreatedAtDesc() - .orElseThrow(() -> new CoinPolicyNotFoundException()).getAttendance(); - addCoinHistory(new CoinHistory(user, HistoryType.ATTENDANCECOIN.getHistory(), amount)); - } + @Transactional + public void addAttendanceCoinHistory(User user) { + int amount = coinPolicyRepository.findTopByOrderByCreatedAtDesc() + .orElseThrow(() -> new CoinPolicyNotFoundException()).getAttendance(); + addCoinHistory(new CoinHistory(user, HistoryType.ATTENDANCECOIN.getHistory(), amount)); + } - @Transactional - public void addPurchaseItemCoinHistory(User user, Item item, Integer price) { - addCoinHistory(new CoinHistory(user, item.getName() + " 구매", price * (-1))); - } + @Transactional + public void addPurchaseItemCoinHistory(User user, Item item, Integer price) { + addCoinHistory(new CoinHistory(user, item.getName() + " 구매", price * (-1))); + } - @Transactional - public void addGiftItemCoinHistory(User user, User giftTarget, Item item, Integer price) { - addCoinHistory(new CoinHistory(user, giftTarget.getIntraId() + "에게 " + item.getName() + " 선물", price * (-1))); - } + @Transactional + public void addGiftItemCoinHistory(User user, User giftTarget, Item item, Integer price) { + addCoinHistory(new CoinHistory(user, giftTarget.getIntraId() + "에게 " + item.getName() + " 선물", price * (-1))); + } - @Transactional - public void addNormalCoin(User user) { - int amount = coinPolicyRepository.findTopByOrderByCreatedAtDesc() - .orElseThrow(() -> new CoinPolicyNotFoundException()).getNormal(); - addCoinHistory(new CoinHistory(user, HistoryType.NORMAL.getHistory(), amount)); - } + @Transactional + public void addNormalCoin(User user) { + int amount = coinPolicyRepository.findTopByOrderByCreatedAtDesc() + .orElseThrow(() -> new CoinPolicyNotFoundException()).getNormal(); + addCoinHistory(new CoinHistory(user, HistoryType.NORMAL.getHistory(), amount)); + } - @Transactional - public int addRankWinCoin(User user) { - int amount = coinPolicyRepository.findTopByOrderByCreatedAtDesc() - .orElseThrow(() -> new CoinPolicyNotFoundException()).getRankWin(); - addCoinHistory(new CoinHistory(user, HistoryType.RANKWIN.getHistory(), amount)); - return amount; - } + @Transactional + public int addRankWinCoin(User user) { + int amount = coinPolicyRepository.findTopByOrderByCreatedAtDesc() + .orElseThrow(() -> new CoinPolicyNotFoundException()).getRankWin(); + addCoinHistory(new CoinHistory(user, HistoryType.RANKWIN.getHistory(), amount)); + return amount; + } - @Transactional - public int addRankLoseCoin(User user) { - int amount = coinPolicyRepository.findTopByOrderByCreatedAtDesc() - .orElseThrow(() -> new CoinPolicyNotFoundException()).getRankLose(); - if (amount == 0) - return amount; - addCoinHistory(new CoinHistory(user, HistoryType.RANKLOSE.getHistory(), amount)); - return amount; - } + @Transactional + public int addRankLoseCoin(User user) { + int amount = coinPolicyRepository.findTopByOrderByCreatedAtDesc() + .orElseThrow(() -> new CoinPolicyNotFoundException()).getRankLose(); + if (amount == 0) { + return amount; + } + addCoinHistory(new CoinHistory(user, HistoryType.RANKLOSE.getHistory(), amount)); + return amount; + } - @Transactional(readOnly = true) - public boolean hasAttendedToday(User user) { - LocalDateTime startOfDay = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0); - LocalDateTime endOfDay = startOfDay.plusDays(1); - return coinHistoryRepository.existsUserAttendedCheckToday( - user, HistoryType.ATTENDANCECOIN.getHistory(), startOfDay, endOfDay); - } + @Transactional(readOnly = true) + public boolean hasAttendedToday(User user) { + LocalDateTime startOfDay = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0); + LocalDateTime endOfDay = startOfDay.plusDays(1); + return coinHistoryRepository.existsUserAttendedCheckToday( + user, HistoryType.ATTENDANCECOIN.getHistory(), startOfDay, endOfDay); + } - public void addCoinHistory(CoinHistory coinHistory) { - coinHistoryRepository.save(coinHistory); - } + public void addCoinHistory(CoinHistory coinHistory) { + coinHistoryRepository.save(coinHistory); + } } diff --git a/src/main/java/com/gg/server/domain/coin/service/UserCoinChangeService.java b/src/main/java/com/gg/server/domain/coin/service/UserCoinChangeService.java index b30dbc385..0e94cc929 100644 --- a/src/main/java/com/gg/server/domain/coin/service/UserCoinChangeService.java +++ b/src/main/java/com/gg/server/domain/coin/service/UserCoinChangeService.java @@ -1,5 +1,10 @@ package com.gg.server.domain.coin.service; +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.domain.coin.data.CoinPolicyRepository; import com.gg.server.domain.coin.dto.UserGameCoinResultDto; import com.gg.server.domain.coin.exception.CoinPolicyNotFoundException; @@ -11,87 +16,86 @@ import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.exception.UserAlreadyAttendanceException; import com.gg.server.domain.user.exception.UserNotFoundException; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.util.List; +import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class UserCoinChangeService { - private final CoinPolicyRepository coinPolicyRepository; - private final CoinHistoryService coinHistoryService; - private final UserRepository userRepository; - private final GameFindService gameFindService; - - @Transactional - public int addAttendanceCoin(User user){ - if (coinHistoryService.hasAttendedToday(user)) - throw new UserAlreadyAttendanceException(); - int coinIncrement = coinPolicyRepository.findTopByOrderByCreatedAtDesc() - .orElseThrow(CoinPolicyNotFoundException::new).getAttendance(); - user.addGgCoin(coinIncrement); - coinHistoryService.addAttendanceCoinHistory(user); - return coinIncrement; - } - - @Transactional - public void purchaseItemCoin(Item item, Integer price, Long userId){ - - User user = userRepository.findById(userId) - .orElseThrow(UserNotFoundException::new); - - user.payGgCoin(price); - - coinHistoryService.addPurchaseItemCoinHistory(user, item, price); - } - - @Transactional - public void giftItemCoin(Item item, Integer price, User user, User giftTarget){ - user.payGgCoin(price); - - coinHistoryService.addGiftItemCoinHistory(user, giftTarget, item, price); - } - - - @Transactional - public UserGameCoinResultDto addNormalGameCoin(Long userId) { - User user = userRepository.findById(userId).orElseThrow(UserNotFoundException::new); - int coinIncrement = coinPolicyRepository.findTopByOrderByCreatedAtDesc() - .orElseThrow(CoinPolicyNotFoundException::new).getNormal(); - - user.addGgCoin(coinIncrement); - coinHistoryService.addNormalCoin(user); - return new UserGameCoinResultDto(user.getGgCoin(), coinIncrement); - } - - @Transactional - public UserGameCoinResultDto addRankGameCoin(Long gameId, Long userId) { - User user = userRepository.findById(userId).orElseThrow(UserNotFoundException::new); - int coinIncrement; - - if (userIsWinner(gameId, user)) - coinIncrement = coinHistoryService.addRankWinCoin(user); - else - coinIncrement = coinHistoryService.addRankLoseCoin(user); - - user.addGgCoin(coinIncrement); - return new UserGameCoinResultDto(user.getGgCoin(), coinIncrement); - } - - private boolean userIsWinner(Long gameId, User user) { - List teams = gameFindService.findByGameId(gameId).getTeams(); - - for(Team team: teams) { - for (TeamUser teamUser : team.getTeamUsers()){ - if (teamUser.getUser().getId() == user.getId() && team.getWin()) - return true; - else if (teamUser.getUser().getId() == user.getId() && !team.getWin()) - return false; - } - } - - return false; - } + private final CoinPolicyRepository coinPolicyRepository; + private final CoinHistoryService coinHistoryService; + private final UserRepository userRepository; + private final GameFindService gameFindService; + + @Transactional + public int addAttendanceCoin(User user) { + if (coinHistoryService.hasAttendedToday(user)) { + throw new UserAlreadyAttendanceException(); + } + int coinIncrement = coinPolicyRepository.findTopByOrderByCreatedAtDesc() + .orElseThrow(CoinPolicyNotFoundException::new).getAttendance(); + user.addGgCoin(coinIncrement); + coinHistoryService.addAttendanceCoinHistory(user); + return coinIncrement; + } + + @Transactional + public void purchaseItemCoin(Item item, Integer price, Long userId) { + + User user = userRepository.findById(userId) + .orElseThrow(UserNotFoundException::new); + + user.payGgCoin(price); + + coinHistoryService.addPurchaseItemCoinHistory(user, item, price); + } + + @Transactional + public void giftItemCoin(Item item, Integer price, User user, User giftTarget) { + user.payGgCoin(price); + + coinHistoryService.addGiftItemCoinHistory(user, giftTarget, item, price); + } + + @Transactional + public UserGameCoinResultDto addNormalGameCoin(Long userId) { + User user = userRepository.findById(userId).orElseThrow(UserNotFoundException::new); + int coinIncrement = coinPolicyRepository.findTopByOrderByCreatedAtDesc() + .orElseThrow(CoinPolicyNotFoundException::new).getNormal(); + + user.addGgCoin(coinIncrement); + coinHistoryService.addNormalCoin(user); + return new UserGameCoinResultDto(user.getGgCoin(), coinIncrement); + } + + @Transactional + public UserGameCoinResultDto addRankGameCoin(Long gameId, Long userId) { + User user = userRepository.findById(userId).orElseThrow(UserNotFoundException::new); + int coinIncrement; + + if (userIsWinner(gameId, user)) { + coinIncrement = coinHistoryService.addRankWinCoin(user); + } else { + coinIncrement = coinHistoryService.addRankLoseCoin(user); + } + + user.addGgCoin(coinIncrement); + return new UserGameCoinResultDto(user.getGgCoin(), coinIncrement); + } + + private boolean userIsWinner(Long gameId, User user) { + List teams = gameFindService.findByGameId(gameId).getTeams(); + + for (Team team : teams) { + for (TeamUser teamUser : team.getTeamUsers()) { + if (teamUser.getUser().getId() == user.getId() && team.getWin()) { + return true; + } else if (teamUser.getUser().getId() == user.getId() && !team.getWin()) { + return false; + } + } + } + + return false; + } } diff --git a/src/main/java/com/gg/server/domain/coin/type/HistoryType.java b/src/main/java/com/gg/server/domain/coin/type/HistoryType.java index 8144c712a..3242e6ed9 100644 --- a/src/main/java/com/gg/server/domain/coin/type/HistoryType.java +++ b/src/main/java/com/gg/server/domain/coin/type/HistoryType.java @@ -7,10 +7,10 @@ @RequiredArgsConstructor public enum HistoryType { - ATTENDANCECOIN("출석"), - NORMAL("일반전 참가"), - RANKWIN("랭크전 승리"), - RANKLOSE("랭크전 패배"); + ATTENDANCECOIN("출석"), + NORMAL("일반전 참가"), + RANKWIN("랭크전 승리"), + RANKLOSE("랭크전 패배"); - private final String history; + private final String history; } diff --git a/src/main/java/com/gg/server/domain/feedback/controller/FeedbackController.java b/src/main/java/com/gg/server/domain/feedback/controller/FeedbackController.java index b18bd2edd..6bec79846 100644 --- a/src/main/java/com/gg/server/domain/feedback/controller/FeedbackController.java +++ b/src/main/java/com/gg/server/domain/feedback/controller/FeedbackController.java @@ -1,33 +1,34 @@ -package com.gg.server.domain.feedback.controller; - - -import com.gg.server.domain.feedback.dto.FeedbackRequestDto; -import com.gg.server.domain.feedback.service.FeedbackService; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.utils.argumentresolver.Login; -import io.swagger.v3.oas.annotations.Parameter; -import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.validation.Valid; - -@RestController -@RequiredArgsConstructor -@RequestMapping(value = "/pingpong") -public class FeedbackController { - private final FeedbackService feedbackService; - private final UserRepository userRepository; - - @PostMapping(value = "/feedback") - public ResponseEntity feedbackSave(@Valid @RequestBody FeedbackRequestDto feedbackRequestDto, - @Parameter(hidden = true) @Login UserDto user) { - feedbackService.addFeedback(feedbackRequestDto, user.getId()); - return new ResponseEntity(HttpStatus.CREATED); - } -} +package com.gg.server.domain.feedback.controller; + +import javax.validation.Valid; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.gg.server.domain.feedback.dto.FeedbackRequestDto; +import com.gg.server.domain.feedback.service.FeedbackService; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.utils.argumentresolver.Login; + +import io.swagger.v3.oas.annotations.Parameter; +import lombok.RequiredArgsConstructor; + +@RestController +@RequiredArgsConstructor +@RequestMapping(value = "/pingpong") +public class FeedbackController { + private final FeedbackService feedbackService; + private final UserRepository userRepository; + + @PostMapping(value = "/feedback") + public ResponseEntity feedbackSave(@Valid @RequestBody FeedbackRequestDto feedbackRequestDto, + @Parameter(hidden = true) @Login UserDto user) { + feedbackService.addFeedback(feedbackRequestDto, user.getId()); + return new ResponseEntity(HttpStatus.CREATED); + } +} diff --git a/src/main/java/com/gg/server/domain/feedback/data/Feedback.java b/src/main/java/com/gg/server/domain/feedback/data/Feedback.java index f70d61947..d50e55350 100644 --- a/src/main/java/com/gg/server/domain/feedback/data/Feedback.java +++ b/src/main/java/com/gg/server/domain/feedback/data/Feedback.java @@ -1,44 +1,57 @@ -package com.gg.server.domain.feedback.data; - -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.feedback.type.FeedbackType; -import com.gg.server.global.utils.BaseTimeEntity; -import lombok.*; - -import javax.persistence.*; -import javax.validation.constraints.NotNull; - -@NoArgsConstructor -@Entity -@Getter -public class Feedback extends BaseTimeEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - @NotNull - @Enumerated(EnumType.STRING) - @Column(name = "category", length = 15) - private FeedbackType category; - - @NotNull - @Column(name = "content", length = 600) - private String content; - - @Setter - @NotNull - @Column(name = "is_solved") - private Boolean isSolved; - - @Builder - public Feedback(User user, FeedbackType category, String content) { - this.user = user; - this.category = category; - this.content = content; - this.isSolved = false; - } -} +package com.gg.server.domain.feedback.data; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.validation.constraints.NotNull; + +import com.gg.server.domain.feedback.type.FeedbackType; +import com.gg.server.domain.user.data.User; +import com.gg.server.global.utils.BaseTimeEntity; + +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@NoArgsConstructor +@Entity +@Getter +public class Feedback extends BaseTimeEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @NotNull + @Enumerated(EnumType.STRING) + @Column(name = "category", length = 15) + private FeedbackType category; + + @NotNull + @Column(name = "content", length = 600) + private String content; + + @Setter + @NotNull + @Column(name = "is_solved") + private Boolean isSolved; + + @Builder + public Feedback(User user, FeedbackType category, String content) { + this.user = user; + this.category = category; + this.content = content; + this.isSolved = false; + } +} diff --git a/src/main/java/com/gg/server/domain/feedback/data/FeedbackRepository.java b/src/main/java/com/gg/server/domain/feedback/data/FeedbackRepository.java index 08a4a89e6..615e6a65a 100644 --- a/src/main/java/com/gg/server/domain/feedback/data/FeedbackRepository.java +++ b/src/main/java/com/gg/server/domain/feedback/data/FeedbackRepository.java @@ -3,5 +3,5 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface FeedbackRepository extends JpaRepository { - Feedback findFirstByOrderByIdDesc(); + Feedback findFirstByOrderByIdDesc(); } diff --git a/src/main/java/com/gg/server/domain/feedback/dto/FeedbackRequestDto.java b/src/main/java/com/gg/server/domain/feedback/dto/FeedbackRequestDto.java index 3bccca5d5..ee6e8d6d1 100644 --- a/src/main/java/com/gg/server/domain/feedback/dto/FeedbackRequestDto.java +++ b/src/main/java/com/gg/server/domain/feedback/dto/FeedbackRequestDto.java @@ -1,25 +1,27 @@ -package com.gg.server.domain.feedback.dto; - -import com.gg.server.domain.feedback.type.FeedbackType; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; - -import javax.validation.constraints.NotNull; - -@Getter -@NoArgsConstructor -public class FeedbackRequestDto { - @NotNull(message = "plz. not null FeedbackType") - private FeedbackType category; - @NotNull(message = "plz. not null content") - @Length(max = 600, message = "plz. maxSizeMessage 600") - private String content; - - @Builder - public FeedbackRequestDto(FeedbackType category, String content) { - this.category = category; - this.content = content; - } -} +package com.gg.server.domain.feedback.dto; + +import javax.validation.constraints.NotNull; + +import org.hibernate.validator.constraints.Length; + +import com.gg.server.domain.feedback.type.FeedbackType; + +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public class FeedbackRequestDto { + @NotNull(message = "plz. not null FeedbackType") + private FeedbackType category; + @NotNull(message = "plz. not null content") + @Length(max = 600, message = "plz. maxSizeMessage 600") + private String content; + + @Builder + public FeedbackRequestDto(FeedbackType category, String content) { + this.category = category; + this.content = content; + } +} diff --git a/src/main/java/com/gg/server/domain/feedback/exception/FeedbackNotFoundException.java b/src/main/java/com/gg/server/domain/feedback/exception/FeedbackNotFoundException.java index cc1375d6f..8aef19e0f 100644 --- a/src/main/java/com/gg/server/domain/feedback/exception/FeedbackNotFoundException.java +++ b/src/main/java/com/gg/server/domain/feedback/exception/FeedbackNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.CustomRuntimeException; public class FeedbackNotFoundException extends CustomRuntimeException { - public FeedbackNotFoundException() { - super(ErrorCode.FEEDBACK_NOT_FOUND.getMessage(), ErrorCode.FEEDBACK_NOT_FOUND); - } + public FeedbackNotFoundException() { + super(ErrorCode.FEEDBACK_NOT_FOUND.getMessage(), ErrorCode.FEEDBACK_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/feedback/service/FeedbackService.java b/src/main/java/com/gg/server/domain/feedback/service/FeedbackService.java index 22df6d097..028e24d71 100644 --- a/src/main/java/com/gg/server/domain/feedback/service/FeedbackService.java +++ b/src/main/java/com/gg/server/domain/feedback/service/FeedbackService.java @@ -1,26 +1,28 @@ -package com.gg.server.domain.feedback.service; - -import com.gg.server.domain.feedback.data.Feedback; -import com.gg.server.domain.feedback.data.FeedbackRepository; -import com.gg.server.domain.feedback.dto.FeedbackRequestDto; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.exception.UserNotFoundException; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@RequiredArgsConstructor -public class FeedbackService { - private final FeedbackRepository feedbackRepository; - private final UserRepository userRepository; - - @Transactional - public void addFeedback(FeedbackRequestDto feedbackRequestDto, Long userId) { - User user = userRepository.findById(userId).orElseThrow(UserNotFoundException::new); - - Feedback feedback = new Feedback(user, feedbackRequestDto.getCategory(), feedbackRequestDto.getContent()); - feedbackRepository.save(feedback); - } -} +package com.gg.server.domain.feedback.service; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.domain.feedback.data.Feedback; +import com.gg.server.domain.feedback.data.FeedbackRepository; +import com.gg.server.domain.feedback.dto.FeedbackRequestDto; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.exception.UserNotFoundException; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class FeedbackService { + private final FeedbackRepository feedbackRepository; + private final UserRepository userRepository; + + @Transactional + public void addFeedback(FeedbackRequestDto feedbackRequestDto, Long userId) { + User user = userRepository.findById(userId).orElseThrow(UserNotFoundException::new); + + Feedback feedback = new Feedback(user, feedbackRequestDto.getCategory(), feedbackRequestDto.getContent()); + feedbackRepository.save(feedback); + } +} diff --git a/src/main/java/com/gg/server/domain/feedback/type/FeedbackType.java b/src/main/java/com/gg/server/domain/feedback/type/FeedbackType.java index bc63018df..4d792bdd3 100644 --- a/src/main/java/com/gg/server/domain/feedback/type/FeedbackType.java +++ b/src/main/java/com/gg/server/domain/feedback/type/FeedbackType.java @@ -1,33 +1,33 @@ package com.gg.server.domain.feedback.type; +import java.util.Locale; + import com.fasterxml.jackson.annotation.JsonCreator; + import lombok.Getter; import lombok.RequiredArgsConstructor; -import java.util.Locale; - @Getter @RequiredArgsConstructor public enum FeedbackType { - BUG("bug"), - GAMERESULT("gameresult"), - COMPLAINT("complaint"), - CHEERS("cheers"), - OPINION("opinion"), - ETC("etc"); + BUG("bug"), + GAMERESULT("gameresult"), + COMPLAINT("complaint"), + CHEERS("cheers"), + OPINION("opinion"), + ETC("etc"); - private final String code; + private final String code; - @JsonCreator - public static FeedbackType getEnumFromValue(String value) { - for(FeedbackType e : values()) { - if(e.code.equals(value)) { - return e; - } - else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { - return e; - } - } - return null; - } + @JsonCreator + public static FeedbackType getEnumFromValue(String value) { + for (FeedbackType e : values()) { + if (e.code.equals(value)) { + return e; + } else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { + return e; + } + } + return null; + } } diff --git a/src/main/java/com/gg/server/domain/game/GameController.java b/src/main/java/com/gg/server/domain/game/GameController.java index 542940400..239125b00 100644 --- a/src/main/java/com/gg/server/domain/game/GameController.java +++ b/src/main/java/com/gg/server/domain/game/GameController.java @@ -1,5 +1,21 @@ package com.gg.server.domain.game; +import javax.validation.Valid; + +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + import com.gg.server.domain.game.dto.GameListResDto; import com.gg.server.domain.game.dto.GamePChangeResultResDto; import com.gg.server.domain.game.dto.GameTeamInfo; @@ -19,121 +35,119 @@ import com.gg.server.global.exception.custom.BusinessException; import com.gg.server.global.exception.custom.InvalidParameterException; import com.gg.server.global.utils.argumentresolver.Login; + import io.swagger.v3.oas.annotations.Parameter; -import javax.validation.Valid; import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; @RestController @RequiredArgsConstructor @RequestMapping("/pingpong/games") public class GameController { - private final GameService gameService; - private final GameFindService gameFindService; - private final RankRedisService rankRedisService; + private final GameService gameService; + private final GameFindService gameFindService; + private final RankRedisService rankRedisService; - /** - * 전체 게임 목록 조회 API - * @param gameReq - page size [status] [intraId] - *

status가 "LIVE" -> 진행중인 게임도 포함해서 조회

- *

null -> 종료된 게임만 조회

- * @return GameListResDto - games isLast - * @throws InvalidParameterException - status가 "LIVE"가 아닌데 다른 값이 들어올 경우 - */ - @GetMapping - GameListResDto allGameList(@Valid GameListReqDto gameReq) { - if (gameReq.getStatus() != null && !gameReq.getStatus().name().equals("LIVE")) { - throw new InvalidParameterException("status not valid", ErrorCode.VALID_FAILED); - } - Pageable pageable = PageRequest.of(gameReq.getPage() - 1, gameReq.getSize(), Sort.by(Sort.Direction.DESC, "startTime")); - if (gameReq.getIntraId() != null) { - return gameFindService.allGameListUser(pageable, gameReq.getIntraId(), gameReq.getStatus() != null ? gameReq.getStatus().name() : "NULL"); - } - return gameFindService.allGameList(pageable, gameReq.getStatus() != null ? gameReq.getStatus().name() : "NULL"); - } + /** + * 전체 게임 목록 조회 API + * @param gameReq - page size [status] [intraId] + *

status가 "LIVE" -> 진행중인 게임도 포함해서 조회

+ *

null -> 종료된 게임만 조회

+ * @return GameListResDto - games isLast + * @throws InvalidParameterException - status가 "LIVE"가 아닌데 다른 값이 들어올 경우 + */ + @GetMapping + GameListResDto allGameList(@Valid GameListReqDto gameReq) { + if (gameReq.getStatus() != null && !gameReq.getStatus().name().equals("LIVE")) { + throw new InvalidParameterException("status not valid", ErrorCode.VALID_FAILED); + } + Pageable pageable = PageRequest.of(gameReq.getPage() - 1, gameReq.getSize(), + Sort.by(Sort.Direction.DESC, "startTime")); + if (gameReq.getIntraId() != null) { + return gameFindService.allGameListUser(pageable, gameReq.getIntraId(), + gameReq.getStatus() != null ? gameReq.getStatus().name() : "NULL"); + } + return gameFindService.allGameList(pageable, gameReq.getStatus() != null ? gameReq.getStatus().name() : "NULL"); + } - @GetMapping("/normal") - GameListResDto normalGameList(@ModelAttribute @Valid NormalGameListReqDto gameReq) { - Pageable pageable = PageRequest.of(gameReq.getPage() - 1, gameReq.getSize(), Sort.by(Sort.Direction.DESC, "startTime")); - if (gameReq.getIntraId() == null) { - return gameFindService.getNormalGameList(pageable); - } - return gameFindService.normalGameListByIntra(pageable, gameReq.getIntraId()); - } + @GetMapping("/normal") + GameListResDto normalGameList(@ModelAttribute @Valid NormalGameListReqDto gameReq) { + Pageable pageable = PageRequest.of(gameReq.getPage() - 1, gameReq.getSize(), + Sort.by(Sort.Direction.DESC, "startTime")); + if (gameReq.getIntraId() == null) { + return gameFindService.getNormalGameList(pageable); + } + return gameFindService.normalGameListByIntra(pageable, gameReq.getIntraId()); + } - @GetMapping("/rank") - GameListResDto rankGameList(@ModelAttribute @Valid RankGameListReqDto gameReq) { - Pageable pageable = PageRequest.of(gameReq.getPage() - 1, gameReq.getSize(), Sort.by(Sort.Direction.DESC, "startTime")); - if (gameReq.getIntraId() == null) { - return gameFindService.rankGameList(pageable, gameReq.getSeasonId()); - } - return gameFindService.rankGameListByIntra(pageable, gameReq.getSeasonId(), gameReq.getIntraId()); - } + @GetMapping("/rank") + GameListResDto rankGameList(@ModelAttribute @Valid RankGameListReqDto gameReq) { + Pageable pageable = PageRequest.of(gameReq.getPage() - 1, gameReq.getSize(), + Sort.by(Sort.Direction.DESC, "startTime")); + if (gameReq.getIntraId() == null) { + return gameFindService.rankGameList(pageable, gameReq.getSeasonId()); + } + return gameFindService.rankGameListByIntra(pageable, gameReq.getSeasonId(), gameReq.getIntraId()); + } - @GetMapping("/{gameId}") - GameTeamInfo getGameInfo(@PathVariable Long gameId, @Parameter(hidden = true) @Login UserDto userDto) { - return gameService.getUserGameInfo(gameId, userDto.getId()); - } + @GetMapping("/{gameId}") + GameTeamInfo getGameInfo(@PathVariable Long gameId, @Parameter(hidden = true) @Login UserDto userDto) { + return gameService.getUserGameInfo(gameId, userDto.getId()); + } - @PostMapping("/rank") - synchronized ResponseEntity createRankResult(@Valid @RequestBody RankResultReqDto reqDto, @Parameter(hidden = true) @Login UserDto user) { - if (reqDto.getMyTeamScore() + reqDto.getEnemyTeamScore() > 3 || reqDto.getMyTeamScore() + reqDto.getEnemyTeamScore() < 2 || - reqDto.getMyTeamScore() == reqDto.getEnemyTeamScore()) { - throw new InvalidParameterException("점수를 잘못 입력했습니다.", ErrorCode.VALID_FAILED); - } - if (!gameService.createRankResult(reqDto, user.getId())) { - throw new ScoreNotMatchedException(); - } - rankRedisService.updateAllTier(reqDto.getGameId()); - return new ResponseEntity<>(HttpStatus.CREATED); - } + @PostMapping("/rank") + synchronized ResponseEntity createRankResult(@Valid @RequestBody RankResultReqDto reqDto, + @Parameter(hidden = true) @Login UserDto user) { + if (reqDto.getMyTeamScore() + reqDto.getEnemyTeamScore() > 3 + || reqDto.getMyTeamScore() + reqDto.getEnemyTeamScore() < 2 + || reqDto.getMyTeamScore() == reqDto.getEnemyTeamScore()) { + throw new InvalidParameterException("점수를 잘못 입력했습니다.", ErrorCode.VALID_FAILED); + } + if (!gameService.createRankResult(reqDto, user.getId())) { + throw new ScoreNotMatchedException(); + } + rankRedisService.updateAllTier(reqDto.getGameId()); + return new ResponseEntity<>(HttpStatus.CREATED); + } - @PostMapping("/normal") - ResponseEntity createNormalResult(@Valid @RequestBody NormalResultReqDto reqDto, @Parameter(hidden = true) @Login UserDto user) { - if (gameService.normalExpResult(reqDto, user.getId())) - return new ResponseEntity<>(HttpStatus.CREATED); - return new ResponseEntity<>(HttpStatus.ACCEPTED); - } + @PostMapping("/normal") + ResponseEntity createNormalResult(@Valid @RequestBody NormalResultReqDto reqDto, + @Parameter(hidden = true) @Login UserDto user) { + if (gameService.normalExpResult(reqDto, user.getId())) { + return new ResponseEntity<>(HttpStatus.CREATED); + } + return new ResponseEntity<>(HttpStatus.ACCEPTED); + } - /** - * 토너먼트 게임 결과 등록 - * @param reqDto 요청 Dto - * @param user 사용자 - * @exception InvalidParameterException 유효하지 않은 점수 입력할 경우 - * @return 201 created - */ - @PostMapping("/tournament") - synchronized ResponseEntity createTournamentGameResult(@Valid @RequestBody TournamentResultReqDto reqDto, @Parameter(hidden = true) @Login UserDto user) { - if (reqDto.getMyTeamScore() + reqDto.getEnemyTeamScore() > 3 || reqDto.getMyTeamScore() + reqDto.getEnemyTeamScore() < 2 || - reqDto.getMyTeamScore() == reqDto.getEnemyTeamScore()) { - throw new InvalidParameterException("점수를 잘못 입력했습니다.", ErrorCode.VALID_FAILED); - } - gameService.createTournamentGameResult(reqDto, user.getId()); - return ResponseEntity.status(HttpStatus.CREATED).build(); - } + /** + * 토너먼트 게임 결과 등록 + * @param reqDto 요청 Dto + * @param user 사용자 + * @exception InvalidParameterException 유효하지 않은 점수 입력할 경우 + * @return 201 created + */ + @PostMapping("/tournament") + synchronized ResponseEntity createTournamentGameResult(@Valid @RequestBody TournamentResultReqDto reqDto, + @Parameter(hidden = true) @Login UserDto user) { + if (reqDto.getMyTeamScore() + reqDto.getEnemyTeamScore() > 3 + || reqDto.getMyTeamScore() + reqDto.getEnemyTeamScore() < 2 + || reqDto.getMyTeamScore() == reqDto.getEnemyTeamScore()) { + throw new InvalidParameterException("점수를 잘못 입력했습니다.", ErrorCode.VALID_FAILED); + } + gameService.createTournamentGameResult(reqDto, user.getId()); + return ResponseEntity.status(HttpStatus.CREATED).build(); + } - /** - * RANK, NORMAL, TOURNAMENT 게임 결과 반환. - */ - @GetMapping("/{gameId}/pchange/result") - ResponseEntity getGamePChangeResult(@PathVariable Long gameId, - @Parameter(hidden = true) @Login UserDto user, @RequestParam Mode mode) { - if (mode == Mode.RANK) - return ResponseEntity.ok(gameService.pppChangeResult(gameId, user.getId())); - else if (mode == Mode.NORMAL || mode == Mode.TOURNAMENT) - return ResponseEntity.ok(gameService.expChangeResult(gameId, user.getId())); - throw new BusinessException(ErrorCode.BAD_ARGU); - } + /** + * RANK, NORMAL, TOURNAMENT 게임 결과 반환. + */ + @GetMapping("/{gameId}/pchange/result") + ResponseEntity getGamePChangeResult(@PathVariable Long gameId, + @Parameter(hidden = true) @Login UserDto user, @RequestParam Mode mode) { + if (mode == Mode.RANK) { + return ResponseEntity.ok(gameService.pppChangeResult(gameId, user.getId())); + } else if (mode == Mode.NORMAL || mode == Mode.TOURNAMENT) { + return ResponseEntity.ok(gameService.expChangeResult(gameId, user.getId())); + } + throw new BusinessException(ErrorCode.BAD_ARGU); + } } diff --git a/src/main/java/com/gg/server/domain/game/data/Game.java b/src/main/java/com/gg/server/domain/game/data/Game.java index cab8f8643..bd978277e 100644 --- a/src/main/java/com/gg/server/domain/game/data/Game.java +++ b/src/main/java/com/gg/server/domain/game/data/Game.java @@ -1,22 +1,36 @@ package com.gg.server.domain.game.data; -import com.gg.server.domain.match.dto.GameAddDto; -import com.gg.server.domain.season.data.Season; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.validation.constraints.NotNull; + +import org.hibernate.annotations.DynamicUpdate; + import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.match.dto.GameAddDto; +import com.gg.server.domain.season.data.Season; import com.gg.server.domain.team.data.Team; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.utils.BusinessChecker; -import java.util.ArrayList; -import lombok.*; -import javax.persistence.*; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Optional; - -import org.hibernate.annotations.DynamicUpdate; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; @NoArgsConstructor @AllArgsConstructor @@ -24,78 +38,78 @@ @Entity @DynamicUpdate public class Game { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "season_id") - private Season season; - - @NotNull - @Enumerated(EnumType.STRING) - @Column(name = "status", length = 10) - private StatusType status; - - @NotNull - @Enumerated(EnumType.STRING) - @Column(name = "mode", length = 10) - private Mode mode; - - @NotNull - @Column(name = "start_time") - private LocalDateTime startTime; - - @Column(name = "end_time") - private LocalDateTime endTime; - - @OneToMany(mappedBy = "game", cascade = CascadeType.ALL) - private List teams = new ArrayList<>(); - - public Game(Season season, StatusType status, Mode mode, LocalDateTime startTime, LocalDateTime endTime) { - this.season = season; - this.status = status; - this.mode = mode; - this.startTime = startTime; - this.endTime = endTime; - } - - public Game(GameAddDto dto, Integer interval) { - this.season = dto.getSeason(); - this.status = StatusType.BEFORE; - this.mode = dto.getMode(); - this.startTime = dto.getStartTime(); - this.endTime = dto.getStartTime().plusMinutes(interval); - } - - @Override - public String toString() { - return "Game{" + - "id=" + id + - ", season=" + season + - ", status=" + status + - ", mode=" + mode + - ", startTime=" + startTime + - ", endTime=" + endTime + - '}'; - } - - public void updateStatus() { - if (status == StatusType.BEFORE) { - this.status = StatusType.LIVE; - } else if (status == StatusType.LIVE) { - this.status = StatusType.WAIT; - } else { - this.status = StatusType.END; - } - } - - public void addTeam(Team team) { - BusinessChecker.mustNotNull(team, ErrorCode.NULL_POINT); - BusinessChecker.mustNotExceed(1, teams, ErrorCode.TEAM_SIZE_EXCEED); - BusinessChecker.mustNotContains(team, teams, ErrorCode.TEAM_DUPLICATION); - this.teams.add(team); - } + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "season_id") + private Season season; + + @NotNull + @Enumerated(EnumType.STRING) + @Column(name = "status", length = 10) + private StatusType status; + + @NotNull + @Enumerated(EnumType.STRING) + @Column(name = "mode", length = 10) + private Mode mode; + + @NotNull + @Column(name = "start_time") + private LocalDateTime startTime; + + @Column(name = "end_time") + private LocalDateTime endTime; + + @OneToMany(mappedBy = "game", cascade = CascadeType.ALL) + private List teams = new ArrayList<>(); + + public Game(Season season, StatusType status, Mode mode, LocalDateTime startTime, LocalDateTime endTime) { + this.season = season; + this.status = status; + this.mode = mode; + this.startTime = startTime; + this.endTime = endTime; + } + + public Game(GameAddDto dto, Integer interval) { + this.season = dto.getSeason(); + this.status = StatusType.BEFORE; + this.mode = dto.getMode(); + this.startTime = dto.getStartTime(); + this.endTime = dto.getStartTime().plusMinutes(interval); + } + + @Override + public String toString() { + return "Game{" + + "id=" + id + + ", season=" + season + + ", status=" + status + + ", mode=" + mode + + ", startTime=" + startTime + + ", endTime=" + endTime + + '}'; + } + + public void updateStatus() { + if (status == StatusType.BEFORE) { + this.status = StatusType.LIVE; + } else if (status == StatusType.LIVE) { + this.status = StatusType.WAIT; + } else { + this.status = StatusType.END; + } + } + + public void addTeam(Team team) { + BusinessChecker.mustNotNull(team, ErrorCode.NULL_POINT); + BusinessChecker.mustNotExceed(1, teams, ErrorCode.TEAM_SIZE_EXCEED); + BusinessChecker.mustNotContains(team, teams, ErrorCode.TEAM_DUPLICATION); + this.teams.add(team); + } } diff --git a/src/main/java/com/gg/server/domain/game/data/GameRepository.java b/src/main/java/com/gg/server/domain/game/data/GameRepository.java index 4d9efc2e1..c6d6cb8cb 100644 --- a/src/main/java/com/gg/server/domain/game/data/GameRepository.java +++ b/src/main/java/com/gg/server/domain/game/data/GameRepository.java @@ -1,116 +1,125 @@ package com.gg.server.domain.game.data; -import com.gg.server.domain.game.dto.GameTeamUserInfo; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; - import java.time.LocalDateTime; +import java.util.List; import java.util.Optional; -import com.gg.server.domain.team.dto.GameUser; import javax.persistence.LockModeType; -import org.springframework.data.jpa.repository.EntityGraph; -import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.game.dto.GameTeamUser; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; +import org.springframework.data.jpa.repository.EntityGraph; +import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Lock; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import java.util.List; +import com.gg.server.domain.game.dto.GameTeamUser; +import com.gg.server.domain.game.dto.GameTeamUserInfo; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.team.dto.GameUser; public interface GameRepository extends JpaRepository, GameRepositoryCustom { - Slice findAllByModeAndStatus(Mode mode, StatusType status, Pageable pageable); - - /* - Slice findAllByStatus(StatusType status, Pageable pageable); - - Slice findAllByStatusIn(List statusList, Pageable pageable); - */ - - - Slice findAllByModeAndStatusAndSeasonId(Mode mode, StatusType status, Long season, Pageable pageable); - - Slice findAllByModeInAndStatusIn(List modeList, List statusList, Pageable pageable); - - Slice findAllByModeInAndStatus(List modeList, StatusType status, Pageable pageable); - - @Query(value = "select t1.gameId, t1.startTime, t1.status, t1.mode, " + - "t1.intraId t1IntraId, t1.win t1IsWin, t1.score t1Score, t1.image t1Image, t1.total_exp t1Exp, t1.wins t1Wins, t1.losses t1Losses, " + - "t2.win t2IsWin, t2.score t2Score, t2.intraId t2IntraId, t2.wins t2Wins, t2.losses t2Losses, t2.image t2Image, t2.total_exp t2Exp " + - "from v_rank_game_detail t1, v_rank_game_detail t2 " + - "where t1.gameId IN (:games) and t1.teamId findTeamsByGameIsIn(@Param("games") List games); - - @Query(value = "select t1.gameId, t1.startTime, t1.status, t1.mode, " + - "t1.intraId t1IntraId, t1.win t1IsWin, t1.score t1Score, t1.image t1Image, t1.total_exp t1Exp, " + - "t2.win t2IsWin, t2.score t2Score, t2.intraId t2IntraId, t2.image t2Image, t2.total_exp t2Exp " + - "from v_teamuser t1, v_teamuser t2 " + - "where t1.gameId IN (:games) and t1.teamId findTeamsByGameIsInAndNormalMode(@Param("games") List games); - - @Query(value = "select t1.gameId, t1.startTime, t1.status, t1.mode, " + - "t1.intraId t1IntraId, t1.teamId t1TeamId, t1.win t1IsWin, t1.score t1Score, t1.image t1Image, t1.total_exp t1Exp, t1.wins t1Wins, t1.losses t1Losses, " + - "t2.win t2IsWin, t2.teamId t2TeamId, t2.score t2Score, t2.intraId t2IntraId, t2.wins t2Wins, t2.losses t2Losses, t2.image t2Image, t2.total_exp t2Exp " + - "from v_rank_game_detail t1, v_rank_game_detail t2 " + - "where t1.gameId = (:gameId) and t1.teamId findTeamsByGameId(@Param("gameId") Long gameId); - - @Query(value = "SELECT teamId, gameId, score, startTime, status, mode, userId, intraId, image, total_exp exp" + - " FROM v_teamuser where gameId = :gameId", nativeQuery = true) - List findTeamGameUser(@Param("gameId") Long gameId); - - Optional findByStartTime(LocalDateTime startTime); - - @Query(value = "select g from Game g where g.startTime > :startTime and g.startTime < :endTime") - List findAllBetween(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime); - - @Query(value = "select g from Game g where (g.startTime between :startTime and :endTime) " - + "or (g.endTime between :startTime and :endTime) " - + "or (:startTime between g.startTime and g.endTime) " - + "or (:endTime between g.startTime and g.endTime)") - List findAllBetweenTournament(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime); - - @Query(value = "SELECT g FROM Game g, Team t, TeamUser tu WHERE g.startTime > :startTime AND g.startTime < :endTime " - + "AND g.id = t.game.id AND t.id = tu.team.id AND tu.user.id = :userId") - Optional findByUserInSlots(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime, @Param("userId") Long userId); - - @Query(value = "SELECT g FROM Game g, Team t, TeamUser tu WHERE g.status = :status AND g.id = t.game.id" - + " AND t.id = tu.team.id AND tu.user.id = :userId") - Optional findByStatusTypeAndUserId(@Param("status") StatusType status, @Param("userId") Long userId); - - @Query(value = "select gameId " + - "from v_teamuser " + - "where intraId = :intra and mode in (:mode) and status in(:status)", nativeQuery = true) - Slice findGamesByUserAndModeInAndStatusIn(@Param("intra") String intra, @Param("mode") List mode, @Param("status") List status, Pageable pageable); - - @Query(value = "select gameId " + - "from v_teamuser " + - "where intraId=:intra and mode=:mode and status=:status", nativeQuery = true) - Slice findGamesByUserAndModeAndStatus(@Param("intra") String intra, @Param("mode") String mode, @Param("status") String status, Pageable pageable); - - @Query(value = "select gameId " + - "from v_teamuser " + - "where intraId = :intra and mode=:mode and seasonId = :seasonId and status = :status", nativeQuery = true) - Slice findGamesByUserAndModeAndSeason(@Param("intra") String intra, @Param("mode") String mode, @Param("seasonId") Long seasonId, @Param("status") String status, Pageable pageable); - - List findAllByStatusAndStartTimeLessThanEqual(StatusType status, LocalDateTime startTime); - - List findAllByStatusAndEndTimeLessThanEqual(StatusType status, LocalDateTime endTime); - - @Query(value = "SELECT u.id userId, u.e_mail email, u.intra_id intraId, u.sns_noti_opt snsNotiOpt, g.id gameId " + - "FROM " + - "(SELECT id, status FROM game where start_time<=:time) g, " + - "team t, team_user tu, user u " + - "WHERE g.id=t.game_id AND t.id = tu.team_id AND tu.user_id=u.id AND g.status = 'BEFORE'", nativeQuery = true) - List findAllByStartTimeLessThanEqual(@Param("time") LocalDateTime time); - - @Lock(LockModeType.PESSIMISTIC_WRITE) - Optional findWithPessimisticLockById(Long gameId); - - @Override - @EntityGraph(attributePaths = {"season"}) - Optional findById(Long gameId); + Slice findAllByModeAndStatus(Mode mode, StatusType status, Pageable pageable); + + // Slice findAllByStatus(StatusType status, Pageable pageable); + + // Slice findAllByStatusIn(List statusList, Pageable pageable); + + Slice findAllByModeAndStatusAndSeasonId(Mode mode, StatusType status, Long season, Pageable pageable); + + Slice findAllByModeInAndStatusIn(List modeList, List statusList, Pageable pageable); + + Slice findAllByModeInAndStatus(List modeList, StatusType status, Pageable pageable); + + @Query(value = "select t1.gameId, t1.startTime, t1.status, t1.mode, " + + "t1.intraId t1IntraId, t1.win t1IsWin, t1.score t1Score, t1.image t1Image, t1.total_exp t1Exp, " + + "t1.wins t1Wins, t1.losses t1Losses, " + + "t2.win t2IsWin, t2.score t2Score, t2.intraId t2IntraId, t2.wins t2Wins, t2.losses t2Losses, " + + "t2.image t2Image, t2.total_exp t2Exp " + + "from v_rank_game_detail t1, v_rank_game_detail t2 " + + "where t1.gameId IN (:games) and t1.teamId findTeamsByGameIsIn(@Param("games") List games); + + @Query(value = "select t1.gameId, t1.startTime, t1.status, t1.mode, " + + "t1.intraId t1IntraId, t1.win t1IsWin, t1.score t1Score, t1.image t1Image, t1.total_exp t1Exp, " + + "t2.win t2IsWin, t2.score t2Score, t2.intraId t2IntraId, t2.image t2Image, t2.total_exp t2Exp " + + "from v_teamuser t1, v_teamuser t2 " + + "where t1.gameId IN (:games) and t1.teamId findTeamsByGameIsInAndNormalMode(@Param("games") List games); + + @Query(value = "select t1.gameId, t1.startTime, t1.status, t1.mode, " + + "t1.intraId t1IntraId, t1.teamId t1TeamId, t1.win t1IsWin, t1.score t1Score, " + + "t1.image t1Image, t1.total_exp t1Exp, t1.wins t1Wins, t1.losses t1Losses, " + + "t2.win t2IsWin, t2.teamId t2TeamId, t2.score t2Score, t2.intraId t2IntraId, " + + "t2.wins t2Wins, t2.losses t2Losses, t2.image t2Image, t2.total_exp t2Exp " + + "from v_rank_game_detail t1, v_rank_game_detail t2 " + + "where t1.gameId = (:gameId) and t1.teamId findTeamsByGameId(@Param("gameId") Long gameId); + + @Query(value = "SELECT teamId, gameId, score, startTime, status, mode, userId, intraId, image, total_exp exp" + + " FROM v_teamuser where gameId = :gameId", nativeQuery = true) + List findTeamGameUser(@Param("gameId") Long gameId); + + Optional findByStartTime(LocalDateTime startTime); + + @Query(value = "select g from Game g where g.startTime > :startTime and g.startTime < :endTime") + List findAllBetween(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime); + + @Query(value = "select g from Game g where (g.startTime between :startTime and :endTime) " + + "or (g.endTime between :startTime and :endTime) " + + "or (:startTime between g.startTime and g.endTime) " + + "or (:endTime between g.startTime and g.endTime)") + List findAllBetweenTournament(@Param("startTime") LocalDateTime startTime, + @Param("endTime") LocalDateTime endTime); + + @Query(value = + "SELECT g FROM Game g, Team t, TeamUser tu WHERE g.startTime > :startTime AND g.startTime < :endTime " + + "AND g.id = t.game.id AND t.id = tu.team.id AND tu.user.id = :userId") + Optional findByUserInSlots(@Param("startTime") LocalDateTime startTime, + @Param("endTime") LocalDateTime endTime, @Param("userId") Long userId); + + @Query(value = "SELECT g FROM Game g, Team t, TeamUser tu WHERE g.status = :status AND g.id = t.game.id" + + " AND t.id = tu.team.id AND tu.user.id = :userId") + Optional findByStatusTypeAndUserId(@Param("status") StatusType status, @Param("userId") Long userId); + + @Query(value = "select gameId " + + "from v_teamuser " + + "where intraId = :intra and mode in (:mode) and status in(:status)", nativeQuery = true) + Slice findGamesByUserAndModeInAndStatusIn(@Param("intra") String intra, @Param("mode") List mode, + @Param("status") List status, Pageable pageable); + + @Query(value = "select gameId " + + "from v_teamuser " + + "where intraId=:intra and mode=:mode and status=:status", nativeQuery = true) + Slice findGamesByUserAndModeAndStatus(@Param("intra") String intra, @Param("mode") String mode, + @Param("status") String status, Pageable pageable); + + @Query(value = "select gameId " + + "from v_teamuser " + + "where intraId = :intra and mode=:mode and seasonId = :seasonId and status = :status", nativeQuery = true) + Slice findGamesByUserAndModeAndSeason(@Param("intra") String intra, @Param("mode") String mode, + @Param("seasonId") Long seasonId, @Param("status") String status, Pageable pageable); + + List findAllByStatusAndStartTimeLessThanEqual(StatusType status, LocalDateTime startTime); + + List findAllByStatusAndEndTimeLessThanEqual(StatusType status, LocalDateTime endTime); + + @Query(value = "SELECT u.id userId, u.e_mail email, u.intra_id intraId, u.sns_noti_opt snsNotiOpt, g.id gameId " + + "FROM " + + "(SELECT id, status FROM game where start_time<=:time) g, " + + "team t, team_user tu, user u " + + "WHERE g.id=t.game_id AND t.id = tu.team_id AND tu.user_id=u.id AND g.status = 'BEFORE'", nativeQuery = true) + List findAllByStartTimeLessThanEqual(@Param("time") LocalDateTime time); + + @Lock(LockModeType.PESSIMISTIC_WRITE) + Optional findWithPessimisticLockById(Long gameId); + + @Override + @EntityGraph(attributePaths = {"season"}) + Optional findById(Long gameId); } diff --git a/src/main/java/com/gg/server/domain/game/data/GameRepositoryCustom.java b/src/main/java/com/gg/server/domain/game/data/GameRepositoryCustom.java index af8f83fc1..308e47909 100644 --- a/src/main/java/com/gg/server/domain/game/data/GameRepositoryCustom.java +++ b/src/main/java/com/gg/server/domain/game/data/GameRepositoryCustom.java @@ -3,5 +3,5 @@ import java.util.Optional; public interface GameRepositoryCustom { - Optional getLatestGameByUser(Long userId); + Optional getLatestGameByUser(Long userId); } diff --git a/src/main/java/com/gg/server/domain/game/data/GameRepositoryImpl.java b/src/main/java/com/gg/server/domain/game/data/GameRepositoryImpl.java index b72787d38..a5824571f 100644 --- a/src/main/java/com/gg/server/domain/game/data/GameRepositoryImpl.java +++ b/src/main/java/com/gg/server/domain/game/data/GameRepositoryImpl.java @@ -1,28 +1,31 @@ package com.gg.server.domain.game.data; -import com.gg.server.domain.team.data.TeamUser; -import lombok.RequiredArgsConstructor; +import java.util.Optional; import javax.persistence.EntityManager; import javax.persistence.NoResultException; -import java.util.Optional; + +import com.gg.server.domain.team.data.TeamUser; + +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor -public class GameRepositoryImpl implements GameRepositoryCustom{ - private final EntityManager em; - @Override - public Optional getLatestGameByUser(Long userId) { - String sql = "select tu from TeamUser tu join fetch tu.user join fetch tu.team " + - "join tu.team.game g where tu.user.id =: userId order by g.startTime desc"; +public class GameRepositoryImpl implements GameRepositoryCustom { + private final EntityManager em; + + @Override + public Optional getLatestGameByUser(Long userId) { + String sql = "select tu from TeamUser tu join fetch tu.user join fetch tu.team " + + "join tu.team.game g where tu.user.id =: userId order by g.startTime desc"; - try{ - TeamUser teamUser = em.createQuery(sql, TeamUser.class).setParameter("userId", userId) - .setFirstResult(0) - .setMaxResults(1) - .getSingleResult(); - return Optional.of(teamUser.getTeam().getGame()); - } catch (NoResultException e){ - return Optional.empty(); - } - } + try { + TeamUser teamUser = em.createQuery(sql, TeamUser.class).setParameter("userId", userId) + .setFirstResult(0) + .setMaxResults(1) + .getSingleResult(); + return Optional.of(teamUser.getTeam().getGame()); + } catch (NoResultException e) { + return Optional.empty(); + } + } } diff --git a/src/main/java/com/gg/server/domain/game/dto/GameListResDto.java b/src/main/java/com/gg/server/domain/game/dto/GameListResDto.java index d8d4d65a7..24ad5b3cb 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GameListResDto.java +++ b/src/main/java/com/gg/server/domain/game/dto/GameListResDto.java @@ -1,39 +1,39 @@ package com.gg.server.domain.game.dto; +import java.util.List; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.*; - @Getter @NoArgsConstructor public class GameListResDto { - private List games; - Boolean isLast; + private List games; + Boolean isLast; - public GameListResDto(List games, Boolean isLast) { - this.games = games; - this.isLast = isLast; - } + public GameListResDto(List games, Boolean isLast) { + this.games = games; + this.isLast = isLast; + } - @Override - public String toString() { - return "GameListResDto{" + - "games=" + games + - ", isLast=" + isLast + - '}'; - } + @Override + public String toString() { + return "GameListResDto{" + + "games=" + games + + ", isLast=" + isLast + + '}'; + } - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (!(obj instanceof GameListResDto)) { - return false; - } else { - GameListResDto other = (GameListResDto) obj; - return this.isLast == other.getIsLast() - && this.games.equals(other.getGames()); - } - } + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (!(obj instanceof GameListResDto)) { + return false; + } else { + GameListResDto other = (GameListResDto)obj; + return this.isLast == other.getIsLast() + && this.games.equals(other.getGames()); + } + } } diff --git a/src/main/java/com/gg/server/domain/game/dto/GamePChangeResultResDto.java b/src/main/java/com/gg/server/domain/game/dto/GamePChangeResultResDto.java index 1802d34ca..b5f0ae6ec 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GamePChangeResultResDto.java +++ b/src/main/java/com/gg/server/domain/game/dto/GamePChangeResultResDto.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.gg.server.domain.coin.dto.UserGameCoinResultDto; import com.gg.server.global.utils.ExpLevelCalculator; + import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -12,44 +13,44 @@ @Getter @JsonInclude(Include.NON_NULL) public class GamePChangeResultResDto { - private Integer beforeExp; - private Integer beforeMaxExp; - private Integer beforeLevel; - private Integer increasedExp; - private Integer increasedLevel; - private Integer afterMaxExp; - private int beforeCoin; - private int afterCoin; - private int coinIncrement; - protected Integer changedPpp; - protected Integer beforePpp; + private Integer beforeExp; + private Integer beforeMaxExp; + private Integer beforeLevel; + private Integer increasedExp; + private Integer increasedLevel; + private Integer afterMaxExp; + private int beforeCoin; + private int afterCoin; + private int coinIncrement; + protected Integer changedPpp; + protected Integer beforePpp; - public GamePChangeResultResDto(Integer beforeExp, Integer currentExp, UserGameCoinResultDto userGameCoinResultDto) { - this.beforeExp = ExpLevelCalculator.getCurrentLevelMyExp(beforeExp); - this.beforeLevel = ExpLevelCalculator.getLevel(beforeExp); - this.beforeMaxExp = ExpLevelCalculator.getLevelMaxExp(beforeLevel); - this.increasedExp = currentExp - beforeExp; - this.increasedLevel = ExpLevelCalculator.getLevel(currentExp) - this.beforeLevel; - this.afterMaxExp = ExpLevelCalculator.getLevelMaxExp(this.beforeLevel + this.increasedLevel); - this.beforeCoin = userGameCoinResultDto.getBeforeCoin(); - this.afterCoin = userGameCoinResultDto.getAfterCoin(); - this.coinIncrement = userGameCoinResultDto.getCoinIncrement(); - } + public GamePChangeResultResDto(Integer beforeExp, Integer currentExp, UserGameCoinResultDto userGameCoinResultDto) { + this.beforeExp = ExpLevelCalculator.getCurrentLevelMyExp(beforeExp); + this.beforeLevel = ExpLevelCalculator.getLevel(beforeExp); + this.beforeMaxExp = ExpLevelCalculator.getLevelMaxExp(beforeLevel); + this.increasedExp = currentExp - beforeExp; + this.increasedLevel = ExpLevelCalculator.getLevel(currentExp) - this.beforeLevel; + this.afterMaxExp = ExpLevelCalculator.getLevelMaxExp(this.beforeLevel + this.increasedLevel); + this.beforeCoin = userGameCoinResultDto.getBeforeCoin(); + this.afterCoin = userGameCoinResultDto.getAfterCoin(); + this.coinIncrement = userGameCoinResultDto.getCoinIncrement(); + } - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (!(obj instanceof GamePChangeResultResDto)) { - return false; - } else { - GamePChangeResultResDto other = (GamePChangeResultResDto) obj; - return this.beforeExp.equals(other.getBeforeExp()) - && this.beforeLevel.equals(other.getBeforeLevel()) - && this.beforeMaxExp.equals(other.getBeforeMaxExp()) - && this.increasedExp.equals(other.getIncreasedExp()) - && this.increasedLevel.equals(other.getIncreasedLevel()) - && this.afterMaxExp.equals(other.getAfterMaxExp()); - } - } + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (!(obj instanceof GamePChangeResultResDto)) { + return false; + } else { + GamePChangeResultResDto other = (GamePChangeResultResDto)obj; + return this.beforeExp.equals(other.getBeforeExp()) + && this.beforeLevel.equals(other.getBeforeLevel()) + && this.beforeMaxExp.equals(other.getBeforeMaxExp()) + && this.increasedExp.equals(other.getIncreasedExp()) + && this.increasedLevel.equals(other.getIncreasedLevel()) + && this.afterMaxExp.equals(other.getAfterMaxExp()); + } + } } diff --git a/src/main/java/com/gg/server/domain/game/dto/GamePPPChangeResultResDto.java b/src/main/java/com/gg/server/domain/game/dto/GamePPPChangeResultResDto.java index dfe67560e..f314919bf 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GamePPPChangeResultResDto.java +++ b/src/main/java/com/gg/server/domain/game/dto/GamePPPChangeResultResDto.java @@ -1,32 +1,32 @@ package com.gg.server.domain.game.dto; import com.gg.server.domain.coin.dto.UserGameCoinResultDto; + import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; - @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter public class GamePPPChangeResultResDto extends GamePChangeResultResDto { - public GamePPPChangeResultResDto(Integer beforeExp, Integer currentExp, Integer beforePpp, - Integer afterPpp, UserGameCoinResultDto userGameCoinResultDto) { - super(beforeExp, currentExp, userGameCoinResultDto); - this.changedPpp = afterPpp - beforePpp; - this.beforePpp = beforePpp; - } + public GamePPPChangeResultResDto(Integer beforeExp, Integer currentExp, Integer beforePpp, + Integer afterPpp, UserGameCoinResultDto userGameCoinResultDto) { + super(beforeExp, currentExp, userGameCoinResultDto); + this.changedPpp = afterPpp - beforePpp; + this.beforePpp = beforePpp; + } - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (!(obj instanceof GamePPPChangeResultResDto)) { - return false; - } else { - GamePPPChangeResultResDto other = (GamePPPChangeResultResDto) obj; - return this.changedPpp.equals(other.getChangedPpp()) - && this.beforePpp.equals(other.getBeforePpp()); - } - } + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (!(obj instanceof GamePPPChangeResultResDto)) { + return false; + } else { + GamePPPChangeResultResDto other = (GamePPPChangeResultResDto)obj; + return this.changedPpp.equals(other.getChangedPpp()) + && this.beforePpp.equals(other.getBeforePpp()); + } + } } diff --git a/src/main/java/com/gg/server/domain/game/dto/GameResultResDto.java b/src/main/java/com/gg/server/domain/game/dto/GameResultResDto.java index 531dca551..5a537deb4 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GameResultResDto.java +++ b/src/main/java/com/gg/server/domain/game/dto/GameResultResDto.java @@ -1,5 +1,8 @@ package com.gg.server.domain.game.dto; +import java.time.LocalDateTime; +import java.util.Arrays; + import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; @@ -7,76 +10,79 @@ import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.team.dto.TeamUserInfoDto; import com.gg.server.domain.team.dto.TeamUserListDto; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.io.Serializable; -import java.time.LocalDateTime; -import java.util.Arrays; - @Getter @NoArgsConstructor public class GameResultResDto { - private Long gameId; - private String status; - private Mode mode; - @JsonSerialize(using = LocalDateTimeSerializer.class) - @JsonDeserialize(using = LocalDateTimeDeserializer.class) - private LocalDateTime time; - private TeamUserListDto team1; - private TeamUserListDto team2; + private Long gameId; + private String status; + private Mode mode; + @JsonSerialize(using = LocalDateTimeSerializer.class) + @JsonDeserialize(using = LocalDateTimeDeserializer.class) + private LocalDateTime time; + private TeamUserListDto team1; + private TeamUserListDto team2; - public GameResultResDto(GameTeamUser game) { - this.gameId = game.getGameId(); - this.status = game.getStatus().name();//name -> 대문자 - this.time = game.getStartTime(); - this.mode = game.getMode(); - if (mode == Mode.NORMAL) { - team1 = new TeamUserListDto(Arrays.asList( - new TeamUserInfoDto(game.getT1IntraId(), game.getT1Image(), game.getT1Exp(), null, null)), null, null); - team2 = new TeamUserListDto(Arrays.asList( - new TeamUserInfoDto(game.getT2IntraId(), game.getT2Image(), game.getT2Exp(), null, null)), null, null); - } else if (mode == Mode.RANK) { - team1 = new TeamUserListDto(Arrays.asList( - new TeamUserInfoDto(game.getT1IntraId(), game.getT1Image(), game.getT1Exp(), game.getT1Wins(), game.getT1Losses())), game.getT1IsWin(), game.getT1Score()); - team2 = new TeamUserListDto(Arrays.asList( - new TeamUserInfoDto(game.getT2IntraId(), game.getT2Image(), game.getT2Exp(), game.getT2Wins(), game.getT2Losses())), game.getT2IsWin(), game.getT2Score()); - } else if (mode == Mode.TOURNAMENT) { - team1 = new TeamUserListDto( - game.getT1TeamId(), - Arrays.asList(new TeamUserInfoDto(game.getT1IntraId(), game.getT1Image(), game.getT1Exp(), game.getT1Wins(), game.getT1Losses())), - game.getT1IsWin(), game.getT1Score()); - team2 = new TeamUserListDto(game.getT2TeamId(), - Arrays.asList(new TeamUserInfoDto(game.getT2IntraId(), game.getT2Image(), game.getT2Exp(), game.getT2Wins(), game.getT2Losses())), - game.getT2IsWin(), game.getT2Score()); - } - } + public GameResultResDto(GameTeamUser game) { + this.gameId = game.getGameId(); + this.status = game.getStatus().name(); //name -> 대문자 + this.time = game.getStartTime(); + this.mode = game.getMode(); + if (mode == Mode.NORMAL) { + team1 = new TeamUserListDto(Arrays.asList( + new TeamUserInfoDto(game.getT1IntraId(), game.getT1Image(), game.getT1Exp(), null, null)), null, null); + team2 = new TeamUserListDto(Arrays.asList( + new TeamUserInfoDto(game.getT2IntraId(), game.getT2Image(), game.getT2Exp(), null, null)), null, null); + } else if (mode == Mode.RANK) { + team1 = new TeamUserListDto(Arrays.asList( + new TeamUserInfoDto(game.getT1IntraId(), game.getT1Image(), game.getT1Exp(), game.getT1Wins(), + game.getT1Losses())), game.getT1IsWin(), game.getT1Score()); + team2 = new TeamUserListDto(Arrays.asList( + new TeamUserInfoDto(game.getT2IntraId(), game.getT2Image(), game.getT2Exp(), game.getT2Wins(), + game.getT2Losses())), game.getT2IsWin(), game.getT2Score()); + } else if (mode == Mode.TOURNAMENT) { + team1 = new TeamUserListDto( + game.getT1TeamId(), + Arrays.asList( + new TeamUserInfoDto(game.getT1IntraId(), game.getT1Image(), game.getT1Exp(), game.getT1Wins(), + game.getT1Losses())), + game.getT1IsWin(), game.getT1Score()); + team2 = new TeamUserListDto(game.getT2TeamId(), + Arrays.asList( + new TeamUserInfoDto(game.getT2IntraId(), game.getT2Image(), game.getT2Exp(), game.getT2Wins(), + game.getT2Losses())), + game.getT2IsWin(), game.getT2Score()); + } + } - @Override - public String toString() { - return "NormalGameResDto{" + - "gameId=" + gameId + - ", status='" + status + '\'' + - ", time=" + time + - ", team1=" + team1 + - ", team2=" + team2 + - '}'; - } + @Override + public String toString() { + return "NormalGameResDto{" + + "gameId=" + gameId + + ", status='" + status + '\'' + + ", time=" + time + + ", team1=" + team1 + + ", team2=" + team2 + + '}'; + } - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (!(obj instanceof GameResultResDto)) { - return false; - } else { - GameResultResDto other = (GameResultResDto) obj; - return this.gameId.equals(other.getGameId()) - && this.status.equals(other.getStatus()) - && this.mode.equals(other.getMode()) - && this.time.equals(other.getTime()) - && this.team1.equals(other.getTeam1()) - && this.team2.equals(other.getTeam2()); - } - } -} \ No newline at end of file + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (!(obj instanceof GameResultResDto)) { + return false; + } else { + GameResultResDto other = (GameResultResDto)obj; + return this.gameId.equals(other.getGameId()) + && this.status.equals(other.getStatus()) + && this.mode.equals(other.getMode()) + && this.time.equals(other.getTime()) + && this.team1.equals(other.getTeam1()) + && this.team2.equals(other.getTeam2()); + } + } +} diff --git a/src/main/java/com/gg/server/domain/game/dto/GameTeamInfo.java b/src/main/java/com/gg/server/domain/game/dto/GameTeamInfo.java index 8a65012e0..dc6e656c1 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GameTeamInfo.java +++ b/src/main/java/com/gg/server/domain/game/dto/GameTeamInfo.java @@ -1,65 +1,67 @@ package com.gg.server.domain.game.dto; +import java.time.LocalDateTime; +import java.util.List; + import com.gg.server.domain.game.exception.GameDataConsistencyException; import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.team.dto.MatchTeamsInfoDto; + import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import java.time.LocalDateTime; -import java.util.List; - @Getter @NoArgsConstructor @ToString @Slf4j public class GameTeamInfo { - private Mode mode; - private Long gameId; - private LocalDateTime startTime; - private StatusType status; - private Boolean isScoreExist; - private MatchTeamsInfoDto matchTeamsInfo; + private Mode mode; + private Long gameId; + private LocalDateTime startTime; + private StatusType status; + private Boolean isScoreExist; + private MatchTeamsInfoDto matchTeamsInfo; - public GameTeamInfo(List infos, Long userId) { - this.mode = infos.get(0).getMode(); - this.gameId = infos.get(0).getGameId(); - this.startTime = infos.get(0).getStartTime(); - this.status = infos.get(0).getStatus(); - Long myTeamId = null; - for (GameTeamUserInfo info : - infos) { - if (info.getScore() > -1) { - this.isScoreExist = true; - } - if (!this.mode.equals(info.getMode()) || !this.gameId.equals(info.getGameId()) - || !this.startTime.equals(info.getStartTime()) || !this.status.equals(info.getStatus())) { - log.error("data error: gid 1: ", infos.get(0).getGameId(), ", gid 2:", infos.get(1).getGameId()); - throw new GameDataConsistencyException(); - } - if (info.getUserId().equals(userId)) - myTeamId = info.getTeamId(); - } - this.matchTeamsInfo = new MatchTeamsInfoDto(infos, myTeamId); - } + public GameTeamInfo(List infos, Long userId) { + this.mode = infos.get(0).getMode(); + this.gameId = infos.get(0).getGameId(); + this.startTime = infos.get(0).getStartTime(); + this.status = infos.get(0).getStatus(); + Long myTeamId = null; + for (GameTeamUserInfo info : + infos) { + if (info.getScore() > -1) { + this.isScoreExist = true; + } + if (!this.mode.equals(info.getMode()) || !this.gameId.equals(info.getGameId()) + || !this.startTime.equals(info.getStartTime()) || !this.status.equals(info.getStatus())) { + log.error("data error: gid 1: ", infos.get(0).getGameId(), ", gid 2:", infos.get(1).getGameId()); + throw new GameDataConsistencyException(); + } + if (info.getUserId().equals(userId)) { + myTeamId = info.getTeamId(); + } + } + this.matchTeamsInfo = new MatchTeamsInfoDto(infos, myTeamId); + } - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (!(obj instanceof GameTeamInfo)) { - return false; - } else { - GameTeamInfo other = (GameTeamInfo) obj; - return this.status.equals(other.getStatus()) - && this.gameId.equals(other.getGameId()) - && this.isScoreExist.equals(other.getIsScoreExist()) - && this.mode.equals(other.getMode()) - && this.startTime.equals(other.getStartTime()) - && this.matchTeamsInfo.equals(other.getMatchTeamsInfo()); - } - } + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (!(obj instanceof GameTeamInfo)) { + return false; + } else { + GameTeamInfo other = (GameTeamInfo)obj; + return this.status.equals(other.getStatus()) + && this.gameId.equals(other.getGameId()) + && this.isScoreExist.equals(other.getIsScoreExist()) + && this.mode.equals(other.getMode()) + && this.startTime.equals(other.getStartTime()) + && this.matchTeamsInfo.equals(other.getMatchTeamsInfo()); + } + } } diff --git a/src/main/java/com/gg/server/domain/game/dto/GameTeamUser.java b/src/main/java/com/gg/server/domain/game/dto/GameTeamUser.java index 3d572a4a3..c94a63db6 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GameTeamUser.java +++ b/src/main/java/com/gg/server/domain/game/dto/GameTeamUser.java @@ -1,30 +1,50 @@ package com.gg.server.domain.game.dto; +import java.time.LocalDateTime; + import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.game.type.StatusType; -import java.time.LocalDateTime; - public interface GameTeamUser { - Long getGameId(); - LocalDateTime getStartTime(); - LocalDateTime getEndTime(); - StatusType getStatus(); - Mode getMode(); - Long getT1TeamId(); - Integer getT1Wins(); - Integer getT1Losses(); - String getT1IntraId(); - String getT1Image(); - Integer getT1Exp(); - Integer getT1Score(); - Boolean getT1IsWin(); - Long getT2TeamId(); - Integer getT2Wins(); - Integer getT2Losses(); - String getT2IntraId(); - String getT2Image(); - Integer getT2Exp(); - Integer getT2Score(); - Boolean getT2IsWin(); + Long getGameId(); + + LocalDateTime getStartTime(); + + LocalDateTime getEndTime(); + + StatusType getStatus(); + + Mode getMode(); + + Long getT1TeamId(); + + Integer getT1Wins(); + + Integer getT1Losses(); + + String getT1IntraId(); + + String getT1Image(); + + Integer getT1Exp(); + + Integer getT1Score(); + + Boolean getT1IsWin(); + + Long getT2TeamId(); + + Integer getT2Wins(); + + Integer getT2Losses(); + + String getT2IntraId(); + + String getT2Image(); + + Integer getT2Exp(); + + Integer getT2Score(); + + Boolean getT2IsWin(); } diff --git a/src/main/java/com/gg/server/domain/game/dto/GameTeamUserInfo.java b/src/main/java/com/gg/server/domain/game/dto/GameTeamUserInfo.java index 6601f4650..d7a71b9dc 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GameTeamUserInfo.java +++ b/src/main/java/com/gg/server/domain/game/dto/GameTeamUserInfo.java @@ -1,20 +1,29 @@ package com.gg.server.domain.game.dto; +import java.time.LocalDateTime; + import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.game.type.StatusType; -import java.time.LocalDateTime; - public interface GameTeamUserInfo { - Long getGameId(); - LocalDateTime getStartTime(); - StatusType getStatus(); - Mode getMode(); - Long getTeamId(); - Integer getScore(); - Long getUserId(); - String getIntraId(); - Integer getExp(); - String getImage(); + Long getGameId(); + + LocalDateTime getStartTime(); + + StatusType getStatus(); + + Mode getMode(); + + Long getTeamId(); + + Integer getScore(); + + Long getUserId(); + + String getIntraId(); + + Integer getExp(); + + String getImage(); } diff --git a/src/main/java/com/gg/server/domain/game/dto/request/GameListReqDto.java b/src/main/java/com/gg/server/domain/game/dto/request/GameListReqDto.java index c6fac2b0c..60f21069f 100644 --- a/src/main/java/com/gg/server/domain/game/dto/request/GameListReqDto.java +++ b/src/main/java/com/gg/server/domain/game/dto/request/GameListReqDto.java @@ -1,13 +1,15 @@ package com.gg.server.domain.game.dto.request; import com.gg.server.domain.game.type.StatusType; + import lombok.Getter; @Getter public class GameListReqDto extends NormalGameListReqDto { - private StatusType status; - public GameListReqDto(Integer pageNum, Integer pageSize, String nickname, StatusType status) { - super(pageNum, pageSize, nickname); - this.status = status; - } + private StatusType status; + + public GameListReqDto(Integer pageNum, Integer pageSize, String nickname, StatusType status) { + super(pageNum, pageSize, nickname); + this.status = status; + } } diff --git a/src/main/java/com/gg/server/domain/game/dto/request/NormalGameListReqDto.java b/src/main/java/com/gg/server/domain/game/dto/request/NormalGameListReqDto.java index 0bfa71b3c..6da929827 100644 --- a/src/main/java/com/gg/server/domain/game/dto/request/NormalGameListReqDto.java +++ b/src/main/java/com/gg/server/domain/game/dto/request/NormalGameListReqDto.java @@ -1,16 +1,17 @@ package com.gg.server.domain.game.dto.request; import com.gg.server.global.dto.PageRequestDto; + import lombok.Getter; import lombok.Setter; @Getter @Setter public class NormalGameListReqDto extends PageRequestDto { - private String intraId; + private String intraId; - public NormalGameListReqDto(Integer page, Integer size, String intraId) { - super(page, size); - this.intraId = intraId; - } + public NormalGameListReqDto(Integer page, Integer size, String intraId) { + super(page, size); + this.intraId = intraId; + } } diff --git a/src/main/java/com/gg/server/domain/game/dto/request/NormalResultReqDto.java b/src/main/java/com/gg/server/domain/game/dto/request/NormalResultReqDto.java index 827c74b1b..0911f66b4 100644 --- a/src/main/java/com/gg/server/domain/game/dto/request/NormalResultReqDto.java +++ b/src/main/java/com/gg/server/domain/game/dto/request/NormalResultReqDto.java @@ -1,14 +1,14 @@ package com.gg.server.domain.game.dto.request; -import lombok.Getter; - import javax.validation.constraints.NotNull; import javax.validation.constraints.Positive; +import lombok.Getter; + @Getter public class NormalResultReqDto { - @NotNull(message = "gameId 는 필수 값입니다.") - @Positive(message = "gameId 는 양수만 입력 가능합니다.") - private Long gameId; + @NotNull(message = "gameId 는 필수 값입니다.") + @Positive(message = "gameId 는 양수만 입력 가능합니다.") + private Long gameId; } diff --git a/src/main/java/com/gg/server/domain/game/dto/request/RankGameListReqDto.java b/src/main/java/com/gg/server/domain/game/dto/request/RankGameListReqDto.java index 28d7398ca..41d03b243 100644 --- a/src/main/java/com/gg/server/domain/game/dto/request/RankGameListReqDto.java +++ b/src/main/java/com/gg/server/domain/game/dto/request/RankGameListReqDto.java @@ -1,18 +1,18 @@ package com.gg.server.domain.game.dto.request; -import lombok.Getter; - import javax.validation.constraints.NotNull; import javax.validation.constraints.Positive; +import lombok.Getter; + @Getter public class RankGameListReqDto extends NormalGameListReqDto { - @Positive - @NotNull(message = "seasonId 는 필수 값입니다.") - private Long seasonId; + @Positive + @NotNull(message = "seasonId 는 필수 값입니다.") + private Long seasonId; - public RankGameListReqDto(Integer pageNum, Integer pageSize, String nickname, Long seasonId) { - super(pageNum, pageSize, nickname); - this.seasonId = seasonId; - } + public RankGameListReqDto(Integer pageNum, Integer pageSize, String nickname, Long seasonId) { + super(pageNum, pageSize, nickname); + this.seasonId = seasonId; + } } diff --git a/src/main/java/com/gg/server/domain/game/dto/request/RankResultReqDto.java b/src/main/java/com/gg/server/domain/game/dto/request/RankResultReqDto.java index e76d4ac48..3741d997a 100644 --- a/src/main/java/com/gg/server/domain/game/dto/request/RankResultReqDto.java +++ b/src/main/java/com/gg/server/domain/game/dto/request/RankResultReqDto.java @@ -1,34 +1,34 @@ package com.gg.server.domain.game.dto.request; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - import javax.validation.constraints.Max; import javax.validation.constraints.NotNull; import javax.validation.constraints.Positive; import javax.validation.constraints.PositiveOrZero; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + @Getter @NoArgsConstructor @AllArgsConstructor public class RankResultReqDto { - @Positive - @NotNull(message = "gameId 는 필수 값입니다.") - private Long gameId; - @NotNull(message = "myTeamId 는 필수 값입니다.") - @Positive - private Long myTeamId; - @NotNull(message = "myTeamScore 는 필수 값입니다.") - @PositiveOrZero - @Max(2) - private int myTeamScore; - @NotNull(message = "enemyTeamId 는 필수 값입니다.") - @Positive - private Long enemyTeamId; - @NotNull(message = "enemyTeamScore 는 필수 값입니다.") - @PositiveOrZero - @Max(2) - private int enemyTeamScore; + @Positive + @NotNull(message = "gameId 는 필수 값입니다.") + private Long gameId; + @NotNull(message = "myTeamId 는 필수 값입니다.") + @Positive + private Long myTeamId; + @NotNull(message = "myTeamScore 는 필수 값입니다.") + @PositiveOrZero + @Max(2) + private int myTeamScore; + @NotNull(message = "enemyTeamId 는 필수 값입니다.") + @Positive + private Long enemyTeamId; + @NotNull(message = "enemyTeamScore 는 필수 값입니다.") + @PositiveOrZero + @Max(2) + private int enemyTeamScore; } diff --git a/src/main/java/com/gg/server/domain/game/dto/request/TournamentResultReqDto.java b/src/main/java/com/gg/server/domain/game/dto/request/TournamentResultReqDto.java index 915edf74e..95e881c8d 100644 --- a/src/main/java/com/gg/server/domain/game/dto/request/TournamentResultReqDto.java +++ b/src/main/java/com/gg/server/domain/game/dto/request/TournamentResultReqDto.java @@ -1,33 +1,33 @@ package com.gg.server.domain.game.dto.request; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import javax.validation.constraints.Positive; - import javax.validation.constraints.Max; import javax.validation.constraints.NotNull; +import javax.validation.constraints.Positive; import javax.validation.constraints.PositiveOrZero; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + @Getter @NoArgsConstructor @AllArgsConstructor public class TournamentResultReqDto { - @Positive - @NotNull(message = "gameId 는 필수 값입니다.") - private Long gameId; - @NotNull(message = "myTeamId 는 필수 값입니다.") - @javax.validation.constraints.Positive - private Long myTeamId; - @NotNull(message = "myTeamScore 는 필수 값입니다.") - @PositiveOrZero - @Max(2) - private int myTeamScore; - @NotNull(message = "enemyTeamId 는 필수 값입니다.") - @javax.validation.constraints.Positive - private Long enemyTeamId; - @NotNull(message = "enemyTeamScore 는 필수 값입니다.") - @PositiveOrZero - @Max(2) - private int enemyTeamScore; + @Positive + @NotNull(message = "gameId 는 필수 값입니다.") + private Long gameId; + @NotNull(message = "myTeamId 는 필수 값입니다.") + @javax.validation.constraints.Positive + private Long myTeamId; + @NotNull(message = "myTeamScore 는 필수 값입니다.") + @PositiveOrZero + @Max(2) + private int myTeamScore; + @NotNull(message = "enemyTeamId 는 필수 값입니다.") + @javax.validation.constraints.Positive + private Long enemyTeamId; + @NotNull(message = "enemyTeamScore 는 필수 값입니다.") + @PositiveOrZero + @Max(2) + private int enemyTeamScore; } diff --git a/src/main/java/com/gg/server/domain/game/exception/GameAlreadyExistException.java b/src/main/java/com/gg/server/domain/game/exception/GameAlreadyExistException.java index f9f879b12..029767308 100644 --- a/src/main/java/com/gg/server/domain/game/exception/GameAlreadyExistException.java +++ b/src/main/java/com/gg/server/domain/game/exception/GameAlreadyExistException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.DuplicationException; public class GameAlreadyExistException extends DuplicationException { - public GameAlreadyExistException() { - super("게임이 이미 생성되었습니다.", ErrorCode.GAME_DUPLICATION_EXCEPTION); - } + public GameAlreadyExistException() { + super("게임이 이미 생성되었습니다.", ErrorCode.GAME_DUPLICATION_EXCEPTION); + } } diff --git a/src/main/java/com/gg/server/domain/game/exception/GameDataConsistencyException.java b/src/main/java/com/gg/server/domain/game/exception/GameDataConsistencyException.java index b9e0acdb2..ee9db4070 100644 --- a/src/main/java/com/gg/server/domain/game/exception/GameDataConsistencyException.java +++ b/src/main/java/com/gg/server/domain/game/exception/GameDataConsistencyException.java @@ -1,11 +1,10 @@ package com.gg.server.domain.game.exception; import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.CustomRuntimeException; import com.gg.server.global.exception.custom.DBConsistencyException; public class GameDataConsistencyException extends DBConsistencyException { - public GameDataConsistencyException() { - super("game db 가 올바르지 않습니다.", ErrorCode.GAME_DB_NOT_VALID); - } + public GameDataConsistencyException() { + super("game db 가 올바르지 않습니다.", ErrorCode.GAME_DB_NOT_VALID); + } } diff --git a/src/main/java/com/gg/server/domain/game/exception/GameNotExistException.java b/src/main/java/com/gg/server/domain/game/exception/GameNotExistException.java index 37f69d0c4..94e51f9a7 100644 --- a/src/main/java/com/gg/server/domain/game/exception/GameNotExistException.java +++ b/src/main/java/com/gg/server/domain/game/exception/GameNotExistException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class GameNotExistException extends NotExistException { - public GameNotExistException() { - super("game 이 존재하지 않습니다.", ErrorCode.GAME_NOT_FOUND); - } + public GameNotExistException() { + super("game 이 존재하지 않습니다.", ErrorCode.GAME_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/game/exception/GameStatusNotMatchedException.java b/src/main/java/com/gg/server/domain/game/exception/GameStatusNotMatchedException.java index a101bfc4b..ce667e58d 100644 --- a/src/main/java/com/gg/server/domain/game/exception/GameStatusNotMatchedException.java +++ b/src/main/java/com/gg/server/domain/game/exception/GameStatusNotMatchedException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.BusinessException; public class GameStatusNotMatchedException extends BusinessException { - public GameStatusNotMatchedException() { - super("게임 상태 오류입니다.", ErrorCode.GAME_STATUS_NOT_MATCHED); - } + public GameStatusNotMatchedException() { + super("게임 상태 오류입니다.", ErrorCode.GAME_STATUS_NOT_MATCHED); + } } diff --git a/src/main/java/com/gg/server/domain/game/exception/ScoreAlreadyEnteredException.java b/src/main/java/com/gg/server/domain/game/exception/ScoreAlreadyEnteredException.java index 14492f0c7..621845147 100644 --- a/src/main/java/com/gg/server/domain/game/exception/ScoreAlreadyEnteredException.java +++ b/src/main/java/com/gg/server/domain/game/exception/ScoreAlreadyEnteredException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.DuplicationException; public class ScoreAlreadyEnteredException extends DuplicationException { - public ScoreAlreadyEnteredException(String message, ErrorCode errorCode) { - super(message, errorCode); - } + public ScoreAlreadyEnteredException(String message, ErrorCode errorCode) { + super(message, errorCode); + } } diff --git a/src/main/java/com/gg/server/domain/game/exception/ScoreNotInvalidException.java b/src/main/java/com/gg/server/domain/game/exception/ScoreNotInvalidException.java index 614e8b7aa..232bbf0bd 100644 --- a/src/main/java/com/gg/server/domain/game/exception/ScoreNotInvalidException.java +++ b/src/main/java/com/gg/server/domain/game/exception/ScoreNotInvalidException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.InvalidParameterException; public class ScoreNotInvalidException extends InvalidParameterException { - public ScoreNotInvalidException() { - super(ErrorCode.SCORE_NOT_INVALID.getMessage(), ErrorCode.SCORE_NOT_INVALID); - } + public ScoreNotInvalidException() { + super(ErrorCode.SCORE_NOT_INVALID.getMessage(), ErrorCode.SCORE_NOT_INVALID); + } } diff --git a/src/main/java/com/gg/server/domain/game/exception/ScoreNotMatchedException.java b/src/main/java/com/gg/server/domain/game/exception/ScoreNotMatchedException.java index f2d48afbf..be4a42d8e 100644 --- a/src/main/java/com/gg/server/domain/game/exception/ScoreNotMatchedException.java +++ b/src/main/java/com/gg/server/domain/game/exception/ScoreNotMatchedException.java @@ -2,10 +2,9 @@ import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.DuplicationException; -import com.gg.server.global.exception.custom.InvalidParameterException; public class ScoreNotMatchedException extends DuplicationException { - public ScoreNotMatchedException() { - super(ErrorCode.SCORE_NOT_MATCHED.getMessage(), ErrorCode.SCORE_NOT_MATCHED); - } + public ScoreNotMatchedException() { + super(ErrorCode.SCORE_NOT_MATCHED.getMessage(), ErrorCode.SCORE_NOT_MATCHED); + } } diff --git a/src/main/java/com/gg/server/domain/game/service/GameFindService.java b/src/main/java/com/gg/server/domain/game/service/GameFindService.java index 3c7d45904..da10217ce 100644 --- a/src/main/java/com/gg/server/domain/game/service/GameFindService.java +++ b/src/main/java/com/gg/server/domain/game/service/GameFindService.java @@ -1,5 +1,15 @@ package com.gg.server.domain.game.service; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.dto.GameListResDto; @@ -8,134 +18,144 @@ import com.gg.server.domain.game.exception.GameNotExistException; import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.game.type.StatusType; -import lombok.RequiredArgsConstructor; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Slice; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class GameFindService { - private final GameRepository gameRepository; + private final GameRepository gameRepository; + + /** + * 특정 User의 NORMAL 모드의 END 상태의 게임 목록 조회 + * @param pageable + * @param intra - 조회할 유저의 intraId + * @return GameListResDto - games isLast + */ + @Transactional(readOnly = true) + @Cacheable(value = "normalGameListByIntra", cacheManager = "gameCacheManager") + public GameListResDto normalGameListByIntra(Pageable pageable, String intra) { + Slice games = gameRepository.findGamesByUserAndModeAndStatus(intra, Mode.NORMAL.name(), + StatusType.END.name(), pageable); + return new GameListResDto(getNormalGameResultList(games.getContent()), games.isLast()); + } + + /** + * NORMAL 모드의 END 상태의 게임 목록 조회 + * @param pageable + * @return + */ + @Transactional(readOnly = true) + @Cacheable(value = "normalGameList", cacheManager = "gameCacheManager") + public GameListResDto getNormalGameList(Pageable pageable) { + Slice games = gameRepository.findAllByModeAndStatus(Mode.NORMAL, StatusType.END, pageable); + return new GameListResDto( + getNormalGameResultList(games.getContent().stream().map(Game::getId).collect(Collectors.toList())), + games.isLast()); + } - /** - * 특정 User의 NORMAL 모드의 END 상태의 게임 목록 조회 - * @param pageable - * @param intra - 조회할 유저의 intraId - * @return GameListResDto - games isLast - */ - @Transactional(readOnly = true) - @Cacheable(value = "normalGameListByIntra", cacheManager = "gameCacheManager") - public GameListResDto normalGameListByIntra(Pageable pageable, String intra) { - Slice games = gameRepository.findGamesByUserAndModeAndStatus(intra, Mode.NORMAL.name(), StatusType.END.name(), pageable); - return new GameListResDto(getNormalGameResultList(games.getContent()), games.isLast()); - } + /** + * 특정 User의 RANK 모드의 END 상태의 게임 목록 조회 + * @param pageable + * @param seasonId - 조회할 시즌의 id + * @param intra - 조회할 유저의 intraId + * @return GameListResDto - games isLast + */ + @Transactional(readOnly = true) + @Cacheable(value = "rankGameListByIntra", cacheManager = "gameCacheManager") + public GameListResDto rankGameListByIntra(Pageable pageable, Long seasonId, String intra) { + Slice games = gameRepository.findGamesByUserAndModeAndSeason(intra, Mode.RANK.name(), seasonId, + StatusType.END.name(), pageable); + return new GameListResDto(getGameResultList(games.getContent()), games.isLast()); + } - /** - * NORMAL 모드의 END 상태의 게임 목록 조회 - * @param pageable - * @return - */ - @Transactional(readOnly = true) - @Cacheable(value = "normalGameList", cacheManager = "gameCacheManager") - public GameListResDto getNormalGameList(Pageable pageable) { - Slice games = gameRepository.findAllByModeAndStatus(Mode.NORMAL, StatusType.END, pageable); - return new GameListResDto(getNormalGameResultList(games.getContent().stream().map(Game::getId).collect(Collectors.toList())), games.isLast()); - } + /** + * RANK 모드의 END 상태의 게임 목록 조회 + * @param pageable + * @param seasonId - 조회할 시즌의 id + * @return GameListResDto - games isLast + */ + @Transactional(readOnly = true) + @Cacheable(value = "rankGameList", cacheManager = "gameCacheManager") + public GameListResDto rankGameList(Pageable pageable, Long seasonId) { + Slice games = gameRepository.findAllByModeAndStatusAndSeasonId(Mode.RANK, StatusType.END, seasonId, + pageable); + return new GameListResDto( + getGameResultList(games.getContent().stream().map(Game::getId).collect(Collectors.toList())), + games.isLast()); + } - /** - * 특정 User의 RANK 모드의 END 상태의 게임 목록 조회 - * @param pageable - * @param seasonId - 조회할 시즌의 id - * @param intra - 조회할 유저의 intraId - * @return GameListResDto - games isLast - */ - @Transactional(readOnly = true) - @Cacheable(value = "rankGameListByIntra", cacheManager = "gameCacheManager") - public GameListResDto rankGameListByIntra(Pageable pageable, Long seasonId, String intra) { - Slice games = gameRepository.findGamesByUserAndModeAndSeason(intra, Mode.RANK.name(), seasonId, StatusType.END.name(), pageable); - return new GameListResDto(getGameResultList(games.getContent()), games.isLast()); - } + /** + * NORMAL, RANDOM 모드의 게임 목록 조회 + *

+ * status가 "LIVE" -> 진행중인 게임도 포함해서 조회 (END, LIVE, WAIT)
+ * status가 null -> 종료된 게임만 조회 (END) + *

+ * @param pageable + * @param status - "LIVE" or null + * @return GameListResDto - games isLast + */ + @Transactional(readOnly = true) + @Cacheable(value = "allGameList", + cacheManager = "gameCacheManager", + key = "#pageable.pageNumber + #pageable.pageSize + #pageable.sort.toString() + #status") + public GameListResDto allGameList(Pageable pageable, String status) { + Slice games; + if (status != null && status.equals("LIVE")) { + games = gameRepository.findAllByModeInAndStatusIn(Arrays.asList(Mode.RANK, Mode.NORMAL), + Arrays.asList(StatusType.END, StatusType.LIVE, StatusType.WAIT), pageable); + } else { + games = gameRepository.findAllByModeInAndStatus(Arrays.asList(Mode.RANK, Mode.NORMAL), StatusType.END, + pageable); + } + return new GameListResDto( + getGameResultList(games.getContent().stream().map(Game::getId).collect(Collectors.toList())), + games.isLast()); + } - /** - * RANK 모드의 END 상태의 게임 목록 조회 - * @param pageable - * @param seasonId - 조회할 시즌의 id - * @return GameListResDto - games isLast - */ - @Transactional(readOnly = true) - @Cacheable(value = "rankGameList", cacheManager = "gameCacheManager") - public GameListResDto rankGameList(Pageable pageable, Long seasonId) { - Slice games = gameRepository.findAllByModeAndStatusAndSeasonId(Mode.RANK, StatusType.END, seasonId, pageable); - return new GameListResDto(getGameResultList(games.getContent().stream().map(Game::getId).collect(Collectors.toList())), games.isLast()); - } + /** + * allGameList()와 동일한 로직 + intraId로 조회 + * @param pageable + * @param intra - 조회할 intraId + * @param status - "LIVE" or null + * @return GameListResDto - games isLast + * @throws GameNotExistException - intraId로 조회한 게임이 없을 경우 + */ + @Transactional(readOnly = true) + @Cacheable(value = "allGameListByUser", + cacheManager = "gameCacheManager", + key = "#pageable.pageNumber + #pageable.pageSize + #pageable.sort.toString() + #status + #intra") + public GameListResDto allGameListUser(Pageable pageable, String intra, String status) { + List statusTypes = Arrays.asList(StatusType.END.name()); + if (status != null && status.equals("LIVE")) { + statusTypes.add(StatusType.LIVE.name()); + statusTypes.add(StatusType.WAIT.name()); + } + Slice games = gameRepository.findGamesByUserAndModeInAndStatusIn(intra, + Arrays.asList(Mode.RANK.name(), Mode.NORMAL.name()), statusTypes, pageable); + return new GameListResDto(getGameResultList(games.getContent()), games.isLast()); + } - /** - * NORMAL, RANDOM 모드의 게임 목록 조회 - *

- * status가 "LIVE" -> 진행중인 게임도 포함해서 조회 (END, LIVE, WAIT)
- * status가 null -> 종료된 게임만 조회 (END) - *

- * @param pageable - * @param status - "LIVE" or null - * @return GameListResDto - games isLast - */ - @Transactional(readOnly = true) - @Cacheable(value = "allGameList", cacheManager = "gameCacheManager", key = "#pageable.pageNumber + #pageable.pageSize + #pageable.sort.toString() + #status") - public GameListResDto allGameList(Pageable pageable, String status) { - Slice games; - if (status != null && status.equals("LIVE")) { - games = gameRepository.findAllByModeInAndStatusIn(Arrays.asList(Mode.RANK, Mode.NORMAL), Arrays.asList(StatusType.END, StatusType.LIVE, StatusType.WAIT), pageable); - } else { - games = gameRepository.findAllByModeInAndStatus(Arrays.asList(Mode.RANK, Mode.NORMAL), StatusType.END, pageable); - } - return new GameListResDto(getGameResultList(games.getContent().stream().map(Game::getId).collect(Collectors.toList())), games.isLast()); - } + public Game findByGameId(Long gameId) { + return gameRepository.findById(gameId) + .orElseThrow(GameNotExistException::new); + } - /** - * allGameList()와 동일한 로직 + intraId로 조회 - * @param pageable - * @param intra - 조회할 intraId - * @param status - "LIVE" or null - * @return GameListResDto - games isLast - * @throws GameNotExistException - intraId로 조회한 게임이 없을 경우 - */ - @Transactional(readOnly = true) - @Cacheable(value = "allGameListByUser", cacheManager = "gameCacheManager", key = "#pageable.pageNumber + #pageable.pageSize + #pageable.sort.toString() + #status + #intra") - public GameListResDto allGameListUser(Pageable pageable, String intra, String status) { - List statusTypes = Arrays.asList(StatusType.END.name()); - if (status != null && status.equals("LIVE")) { - statusTypes.add(StatusType.LIVE.name()); - statusTypes.add(StatusType.WAIT.name()); - } - Slice games = gameRepository.findGamesByUserAndModeInAndStatusIn(intra, Arrays.asList(Mode.RANK.name(), Mode.NORMAL.name()), statusTypes, pageable); - return new GameListResDto(getGameResultList(games.getContent()), games.isLast()); - } - public Game findByGameId(Long gameId) { - return gameRepository.findById(gameId) - .orElseThrow(GameNotExistException::new); - } + public Game findGameWithPessimisticLockById(Long id) { + return gameRepository.findWithPessimisticLockById(id) + .orElseThrow(GameNotExistException::new); + } - public Game findGameWithPessimisticLockById(Long id) { - return gameRepository.findWithPessimisticLockById(id) - .orElseThrow(GameNotExistException::new); - } + /** + * private method + */ + private List getGameResultList(List games) { + List teamViews = gameRepository.findTeamsByGameIsIn(games); + return teamViews.stream().map(GameResultResDto::new).collect(Collectors.toList()); + } - /** - * private method - */ - private List getGameResultList(List games) { - List teamViews = gameRepository.findTeamsByGameIsIn(games); - return teamViews.stream().map(GameResultResDto::new).collect(Collectors.toList()); - } - private List getNormalGameResultList(List games) { - List teamViews = gameRepository.findTeamsByGameIsInAndNormalMode(games); - return teamViews.stream().map(GameResultResDto::new).collect(Collectors.toList()); - } + private List getNormalGameResultList(List games) { + List teamViews = gameRepository.findTeamsByGameIsInAndNormalMode(games); + return teamViews.stream().map(GameResultResDto::new).collect(Collectors.toList()); + } } diff --git a/src/main/java/com/gg/server/domain/game/service/GameService.java b/src/main/java/com/gg/server/domain/game/service/GameService.java index b74f62f9d..47979637a 100644 --- a/src/main/java/com/gg/server/domain/game/service/GameService.java +++ b/src/main/java/com/gg/server/domain/game/service/GameService.java @@ -1,293 +1,307 @@ -package com.gg.server.domain.game.service; - -import com.gg.server.domain.coin.dto.UserGameCoinResultDto; -import com.gg.server.domain.coin.service.UserCoinChangeService; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.*; -import com.gg.server.domain.game.dto.request.NormalResultReqDto; -import com.gg.server.domain.game.dto.request.RankResultReqDto; -import com.gg.server.domain.game.dto.request.TournamentResultReqDto; -import com.gg.server.domain.game.exception.GameNotExistException; -import com.gg.server.domain.game.exception.GameStatusNotMatchedException; -import com.gg.server.domain.game.exception.ScoreAlreadyEnteredException; -import com.gg.server.domain.match.service.MatchTournamentService; -import com.gg.server.domain.match.type.TournamentMatchStatus; -import com.gg.server.domain.pchange.data.PChange; -import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.pchange.exception.PChangeNotExistException; -import com.gg.server.domain.pchange.service.PChangeService; -import com.gg.server.domain.rank.redis.RankRedisService; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.team.exception.TeamIdNotMatchException; -import com.gg.server.domain.tier.service.TierService; -import com.gg.server.domain.tournament.data.*; -import com.gg.server.domain.tournament.exception.TournamentGameNotFoundException; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.InvalidParameterException; -import com.gg.server.global.utils.ExpLevelCalculator; -import lombok.RequiredArgsConstructor; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Caching; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.*; - -@Service -@RequiredArgsConstructor -public class GameService { - private final GameRepository gameRepository; - private final TeamUserRepository teamUserRepository; - private final RankRedisService rankRedisService; - private final PChangeService pChangeService; - private final PChangeRepository pChangeRepository; - private final GameFindService gameFindService; - private final UserCoinChangeService userCoinChangeService; - private final TierService tierService; - private final TournamentGameRepository tournamentGameRepository; - private final MatchTournamentService matchTournamentService; - - /** - * 게임 정보를 가져온다. - * - * @param gameId - * @param userId - * @return GameTeamInfo 게임 정보 - * @throws GameNotExistException 게임이 존재하지 않음 - */ - @Transactional(readOnly = true) - public GameTeamInfo getUserGameInfo(Long gameId, Long userId) { - List infos = gameRepository.findTeamGameUser(gameId); - if (infos.isEmpty()) { - throw new GameNotExistException(); - } - return new GameTeamInfo(infos, userId); - } - - /** - * rank 게임 결과를 입력한다. - * WAIT, LIVE 상태일 때만 입력 가능 - * @return Boolean 입력 성공 여부 - */ - @Transactional - @Caching(evict = { - @CacheEvict(value = "rankGameListByIntra", allEntries = true), - @CacheEvict(value = "rankGameList", allEntries = true), - @CacheEvict(value = "allGameList", allEntries = true), - @CacheEvict(value = "allGameListByUser", allEntries = true), - @CacheEvict(value = "ranking", allEntries = true), - @CacheEvict(value = "expRanking", allEntries = true) - }) - public Boolean createRankResult(RankResultReqDto scoreDto, Long userId) { - // 현재 게임 id - Game game = gameFindService.findGameWithPessimisticLockById(scoreDto.getGameId()); - if (game.getStatus() != StatusType.WAIT && game.getStatus() != StatusType.LIVE) { - return false; - } - return updateRankGameScore(game, scoreDto, userId); - } - - /** - * tournament 게임 결과 등록 - * @param scoreDto 요청 Dto - * @param userId 사용자 Id - * @exception GameStatusNotMatchedException 게임 상태가 WAIT, LIVE가 아닐 경우 - * @return Boolean 입력 성공 여부 - */ - @Transactional - public void createTournamentGameResult(TournamentResultReqDto scoreDto, Long userId) { - Game game = gameFindService.findGameWithPessimisticLockById(scoreDto.getGameId()); - if (game.getStatus() != StatusType.WAIT && game.getStatus() != StatusType.LIVE) { - throw new GameStatusNotMatchedException(); - } - updateTournamentGameScore(game, scoreDto, userId); - if (TournamentMatchStatus.POSSIBLE.equals(matchTournamentService.checkTournamentGame(game))) { - TournamentGame tournamentGame = tournamentGameRepository.findByGameId(game.getId()) - .orElseThrow(TournamentGameNotFoundException::new); - Tournament tournament = tournamentGame.getTournament(); - matchTournamentService.matchGames(tournament, tournamentGame.getTournamentRound().getNextRound()); - } - } - - /** - * normal 게임을 종료하고 exp(경험치)를 부여한다. - * @return Boolean 입력 성공 여부: false - * @throws InvalidParameterException team 정보가 잘못되었을 때 - * @throws PChangeNotExistException pchange 정보가 없을 때 - */ - @Transactional - @Caching(evict = { - @CacheEvict(value = "normalGameListByIntra", allEntries = true), - @CacheEvict(value = "normalGameList", allEntries = true), - @CacheEvict(value = "allGameList", allEntries = true), - @CacheEvict(value = "allGameListByUser", allEntries = true), - @CacheEvict(value = "ranking", allEntries = true), - @CacheEvict(value = "expRanking", allEntries = true) - }) - public Boolean normalExpResult(NormalResultReqDto normalResultReqDto, Long loginUserId) { - Game game = gameFindService.findGameWithPessimisticLockById(normalResultReqDto.getGameId()); - List teamUsers = teamUserRepository.findAllByGameId(game.getId()); - if (teamUsers.size() == 2 && - (game.getStatus() == StatusType.WAIT || game.getStatus() == StatusType.LIVE)) { - expUpdates(game, teamUsers); - savePChange(game, teamUsers, loginUserId); - return true; - } else if (teamUsers.size() == 2 && game.getStatus() == StatusType.END) { - updatePchangeIsChecked(game, loginUserId); - return true; - } else if (teamUsers.size() != 2) { - throw new InvalidParameterException("team 이 잘못되었습니다.", ErrorCode.VALID_FAILED); - } - // BEFORE 상태일 때 false - return false; - } - - /** - * normal 게임에 대한 exp 변화 결과를 가져온다. - * @param gameId - * @param userId - * @return GamePChangeResultResDto 경험치 변화 결과 - */ - @Transactional - public GamePChangeResultResDto expChangeResult(Long gameId, Long userId) { - List pChanges = pChangeService.findExpChangeHistory(gameId, userId); - UserGameCoinResultDto userGameCoinResultDto = userCoinChangeService.addNormalGameCoin(userId); - - if (pChanges.size() == 1) { - return new GamePChangeResultResDto(0, pChanges.get(0).getExp(), userGameCoinResultDto); - } else { - return new GamePChangeResultResDto(pChanges.get(1).getExp(), pChanges.get(0).getExp(), userGameCoinResultDto); - } - } - - /** - * rank 게임에 대한 exp, ppp 변화 결과를 가져온다. - * @param gameId 게임 id - * @param userId 게임에 참여한 유저 id - * @return GamePPPChangeResultResDto 경험치 변화 결과 - * @throws PChangeNotExistException - */ - @Transactional - public GamePPPChangeResultResDto pppChangeResult(Long gameId, Long userId) throws PChangeNotExistException { - Season season = gameFindService.findByGameId(gameId).getSeason(); - List pppHistory = pChangeService.findPPPChangeHistory(gameId, userId, season.getId()); - List expHistory = pChangeService.findExpChangeHistory(gameId, userId); - UserGameCoinResultDto userGameCoinResultDto = userCoinChangeService.addRankGameCoin(gameId, userId); - return new GamePPPChangeResultResDto(expHistory.size() <= 1 ? 0 : expHistory.get(1).getExp(), - pppHistory.get(0).getExp(), - pppHistory.size() <= 1 ? season.getStartPpp() : pppHistory.get(1).getPppResult(), - pppHistory.get(0).getPppResult(), userGameCoinResultDto); - } - - public void expUpdates(Game game, List teamUsers) { - LocalDateTime time = getToday(game.getStartTime()); - for (TeamUser tu : - teamUsers) { - expUpdate(tu, time); - } - if (game.getStatus() == StatusType.LIVE) { - game.updateStatus(); - } - game.updateStatus(); - } - - /** - * PRIVATE METHOD - */ - private void updatePchangeIsChecked(Game game, Long loginUserId) { - pChangeRepository.findPChangeByUserIdAndGameId(loginUserId, game.getId()) - .ifPresentOrElse(pChange -> { - pChange.checkPChange(); - pChangeRepository.save(pChange); - }, () -> { - throw new PChangeNotExistException(); - }); - } - - public void savePChange(Game game, List teamUsers, Long loginUserId) { - if (!pChangeRepository.findPChangesByGameId(game.getId()).isEmpty()){ - return ; - } - Long team1UserId = teamUsers.get(0).getUser().getId(); - Long team2UserId = teamUsers.get(1).getUser().getId(); - pChangeService.addPChange(game, teamUsers.get(0).getUser(), - rankRedisService.getUserPpp(team1UserId, game.getSeason().getId()), team1UserId.equals(loginUserId)); - pChangeService.addPChange(game, teamUsers.get(1).getUser(), - rankRedisService.getUserPpp(team2UserId, game.getSeason().getId()), team2UserId.equals(loginUserId)); - } - - private void expUpdate(TeamUser teamUser, LocalDateTime time) { - Integer gamePerDay = teamUserRepository.findByDateAndUser(time, teamUser.getUser().getId()); - teamUser.getUser().addExp(ExpLevelCalculator.getExpPerGame() + (ExpLevelCalculator.getExpBonus() * gamePerDay)); - } - - private static LocalDateTime getToday(LocalDateTime gameTime) { - return LocalDateTime.of(gameTime.getYear(), gameTime.getMonthValue(), gameTime.getDayOfMonth(), 0, 0); - } - - private void setTeamScore(TeamUser tu, int teamScore, Boolean isWin) { - tu.getTeam().updateScore(teamScore, isWin); - } - - private TeamUser findTeamId(Long teamId, List teamUsers) { - for (TeamUser tu : - teamUsers) { - if (tu.getTeam().getId().equals(teamId)) { - return tu; - } - } - throw new TeamIdNotMatchException(); - } - - private Boolean updateRankGameScore(Game game, RankResultReqDto scoreDto, Long userId) { - List teams = teamUserRepository.findAllByGameId(game.getId()); - TeamUser myTeam = findTeamId(scoreDto.getMyTeamId(), teams); - TeamUser enemyTeam = findTeamId(scoreDto.getEnemyTeamId(), teams); - if (!myTeam.getUser().getId().equals(userId)) { - throw new InvalidParameterException("team user 정보 불일치.", ErrorCode.VALID_FAILED); - } else { - if (myTeam.getTeam().getScore().equals(-1) && enemyTeam.getTeam().getScore().equals(-1)){ - setTeamScore(myTeam, scoreDto.getMyTeamScore(), scoreDto.getMyTeamScore() > scoreDto.getEnemyTeamScore()); - setTeamScore(enemyTeam, scoreDto.getEnemyTeamScore(), scoreDto.getMyTeamScore() < scoreDto.getEnemyTeamScore()); - expUpdates(game, teams); - rankRedisService.updateRankRedis(myTeam, enemyTeam, game); - tierService.updateAllTier(game.getSeason()); - } else { - // score 가 이미 입력됨 - return false; - } - return true; - } - } - - /** - * 토너먼트 게임 결과 업데이트 메소드 - * @param game - * @param scoreDto - * @param userId - * @exception InvalidParameterException 파라미터로 받은 userId가 myTeam의 userId와 일치하지 않을 경우 - * @exception ScoreAlreadyEnteredException 게임 점수가 이미 작성되어 있을 경우 - */ - private void updateTournamentGameScore(Game game, TournamentResultReqDto scoreDto, Long userId) { - List teams = teamUserRepository.findAllByGameId(game.getId()); - TeamUser myTeam = findTeamId(scoreDto.getMyTeamId(), teams); - TeamUser enemyTeam = findTeamId(scoreDto.getEnemyTeamId(), teams); - if (!myTeam.getUser().getId().equals(userId)) { - throw new InvalidParameterException("team user 정보가 일치하지 않습니다.", ErrorCode.VALID_FAILED); - } - if (myTeam.getTeam().getScore().equals(-1) && enemyTeam.getTeam().getScore().equals(-1)){ - setTeamScore(myTeam, scoreDto.getMyTeamScore(), scoreDto.getMyTeamScore() > scoreDto.getEnemyTeamScore()); - setTeamScore(enemyTeam, scoreDto.getEnemyTeamScore(), scoreDto.getMyTeamScore() < scoreDto.getEnemyTeamScore()); - expUpdates(game, teams); - savePChange(game, teams, userId); - } else { - // score 가 이미 입력됨 - throw new ScoreAlreadyEnteredException(ErrorCode.SCORE_ALREADY_ENTERED.getMessage(), ErrorCode.SCORE_ALREADY_ENTERED); - } - } -} \ No newline at end of file +package com.gg.server.domain.game.service; + +import java.time.LocalDateTime; +import java.util.List; + +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Caching; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.domain.coin.dto.UserGameCoinResultDto; +import com.gg.server.domain.coin.service.UserCoinChangeService; +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.data.GameRepository; +import com.gg.server.domain.game.dto.GamePChangeResultResDto; +import com.gg.server.domain.game.dto.GamePPPChangeResultResDto; +import com.gg.server.domain.game.dto.GameTeamInfo; +import com.gg.server.domain.game.dto.GameTeamUserInfo; +import com.gg.server.domain.game.dto.request.NormalResultReqDto; +import com.gg.server.domain.game.dto.request.RankResultReqDto; +import com.gg.server.domain.game.dto.request.TournamentResultReqDto; +import com.gg.server.domain.game.exception.GameNotExistException; +import com.gg.server.domain.game.exception.GameStatusNotMatchedException; +import com.gg.server.domain.game.exception.ScoreAlreadyEnteredException; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.match.service.MatchTournamentService; +import com.gg.server.domain.match.type.TournamentMatchStatus; +import com.gg.server.domain.pchange.data.PChange; +import com.gg.server.domain.pchange.data.PChangeRepository; +import com.gg.server.domain.pchange.exception.PChangeNotExistException; +import com.gg.server.domain.pchange.service.PChangeService; +import com.gg.server.domain.rank.redis.RankRedisService; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.team.data.TeamUser; +import com.gg.server.domain.team.data.TeamUserRepository; +import com.gg.server.domain.team.exception.TeamIdNotMatchException; +import com.gg.server.domain.tier.service.TierService; +import com.gg.server.domain.tournament.data.Tournament; +import com.gg.server.domain.tournament.data.TournamentGame; +import com.gg.server.domain.tournament.data.TournamentGameRepository; +import com.gg.server.domain.tournament.exception.TournamentGameNotFoundException; +import com.gg.server.global.exception.ErrorCode; +import com.gg.server.global.exception.custom.InvalidParameterException; +import com.gg.server.global.utils.ExpLevelCalculator; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class GameService { + private final GameRepository gameRepository; + private final TeamUserRepository teamUserRepository; + private final RankRedisService rankRedisService; + private final PChangeService pChangeService; + private final PChangeRepository pChangeRepository; + private final GameFindService gameFindService; + private final UserCoinChangeService userCoinChangeService; + private final TierService tierService; + private final TournamentGameRepository tournamentGameRepository; + private final MatchTournamentService matchTournamentService; + + /** + * 게임 정보를 가져온다. + * + * @param gameId + * @param userId + * @return GameTeamInfo 게임 정보 + * @throws GameNotExistException 게임이 존재하지 않음 + */ + @Transactional(readOnly = true) + public GameTeamInfo getUserGameInfo(Long gameId, Long userId) { + List infos = gameRepository.findTeamGameUser(gameId); + if (infos.isEmpty()) { + throw new GameNotExistException(); + } + return new GameTeamInfo(infos, userId); + } + + /** + * rank 게임 결과를 입력한다. + * WAIT, LIVE 상태일 때만 입력 가능 + * @return Boolean 입력 성공 여부 + */ + @Transactional + @Caching(evict = { + @CacheEvict(value = "rankGameListByIntra", allEntries = true), + @CacheEvict(value = "rankGameList", allEntries = true), + @CacheEvict(value = "allGameList", allEntries = true), + @CacheEvict(value = "allGameListByUser", allEntries = true), + @CacheEvict(value = "ranking", allEntries = true), + @CacheEvict(value = "expRanking", allEntries = true) + }) + public Boolean createRankResult(RankResultReqDto scoreDto, Long userId) { + // 현재 게임 id + Game game = gameFindService.findGameWithPessimisticLockById(scoreDto.getGameId()); + if (game.getStatus() != StatusType.WAIT && game.getStatus() != StatusType.LIVE) { + return false; + } + return updateRankGameScore(game, scoreDto, userId); + } + + /** + * tournament 게임 결과 등록 + * @param scoreDto 요청 Dto + * @param userId 사용자 Id + * @exception GameStatusNotMatchedException 게임 상태가 WAIT, LIVE가 아닐 경우 + * @return Boolean 입력 성공 여부 + */ + @Transactional + public void createTournamentGameResult(TournamentResultReqDto scoreDto, Long userId) { + Game game = gameFindService.findGameWithPessimisticLockById(scoreDto.getGameId()); + if (game.getStatus() != StatusType.WAIT && game.getStatus() != StatusType.LIVE) { + throw new GameStatusNotMatchedException(); + } + updateTournamentGameScore(game, scoreDto, userId); + if (TournamentMatchStatus.POSSIBLE.equals(matchTournamentService.checkTournamentGame(game))) { + TournamentGame tournamentGame = tournamentGameRepository.findByGameId(game.getId()) + .orElseThrow(TournamentGameNotFoundException::new); + Tournament tournament = tournamentGame.getTournament(); + matchTournamentService.matchGames(tournament, tournamentGame.getTournamentRound().getNextRound()); + } + } + + /** + * normal 게임을 종료하고 exp(경험치)를 부여한다. + * @return Boolean 입력 성공 여부: false + * @throws InvalidParameterException team 정보가 잘못되었을 때 + * @throws PChangeNotExistException pchange 정보가 없을 때 + */ + @Transactional + @Caching(evict = { + @CacheEvict(value = "normalGameListByIntra", allEntries = true), + @CacheEvict(value = "normalGameList", allEntries = true), + @CacheEvict(value = "allGameList", allEntries = true), + @CacheEvict(value = "allGameListByUser", allEntries = true), + @CacheEvict(value = "ranking", allEntries = true), + @CacheEvict(value = "expRanking", allEntries = true) + }) + public Boolean normalExpResult(NormalResultReqDto normalResultReqDto, Long loginUserId) { + Game game = gameFindService.findGameWithPessimisticLockById(normalResultReqDto.getGameId()); + List teamUsers = teamUserRepository.findAllByGameId(game.getId()); + if (teamUsers.size() == 2 + && (game.getStatus() == StatusType.WAIT || game.getStatus() == StatusType.LIVE)) { + expUpdates(game, teamUsers); + savePChange(game, teamUsers, loginUserId); + return true; + } else if (teamUsers.size() == 2 && game.getStatus() == StatusType.END) { + updatePchangeIsChecked(game, loginUserId); + return true; + } else if (teamUsers.size() != 2) { + throw new InvalidParameterException("team 이 잘못되었습니다.", ErrorCode.VALID_FAILED); + } + // BEFORE 상태일 때 false + return false; + } + + /** + * normal 게임에 대한 exp 변화 결과를 가져온다. + * @param gameId + * @param userId + * @return GamePChangeResultResDto 경험치 변화 결과 + */ + @Transactional + public GamePChangeResultResDto expChangeResult(Long gameId, Long userId) { + List pChanges = pChangeService.findExpChangeHistory(gameId, userId); + UserGameCoinResultDto userGameCoinResultDto = userCoinChangeService.addNormalGameCoin(userId); + + if (pChanges.size() == 1) { + return new GamePChangeResultResDto(0, pChanges.get(0).getExp(), userGameCoinResultDto); + } else { + return new GamePChangeResultResDto(pChanges.get(1).getExp(), pChanges.get(0).getExp(), + userGameCoinResultDto); + } + } + + /** + * rank 게임에 대한 exp, ppp 변화 결과를 가져온다. + * @param gameId 게임 id + * @param userId 게임에 참여한 유저 id + * @return GamePPPChangeResultResDto 경험치 변화 결과 + * @throws PChangeNotExistException + */ + @Transactional + public GamePPPChangeResultResDto pppChangeResult(Long gameId, Long userId) throws PChangeNotExistException { + Season season = gameFindService.findByGameId(gameId).getSeason(); + List pppHistory = pChangeService.findPPPChangeHistory(gameId, userId, season.getId()); + List expHistory = pChangeService.findExpChangeHistory(gameId, userId); + UserGameCoinResultDto userGameCoinResultDto = userCoinChangeService.addRankGameCoin(gameId, userId); + return new GamePPPChangeResultResDto(expHistory.size() <= 1 ? 0 : expHistory.get(1).getExp(), + pppHistory.get(0).getExp(), + pppHistory.size() <= 1 ? season.getStartPpp() : pppHistory.get(1).getPppResult(), + pppHistory.get(0).getPppResult(), userGameCoinResultDto); + } + + public void expUpdates(Game game, List teamUsers) { + LocalDateTime time = getToday(game.getStartTime()); + for (TeamUser tu : + teamUsers) { + expUpdate(tu, time); + } + if (game.getStatus() == StatusType.LIVE) { + game.updateStatus(); + } + game.updateStatus(); + } + + /** + * PRIVATE METHOD + */ + private void updatePchangeIsChecked(Game game, Long loginUserId) { + pChangeRepository.findPChangeByUserIdAndGameId(loginUserId, game.getId()) + .ifPresentOrElse( + pChange -> { + pChange.checkPChange(); + pChangeRepository.save(pChange); + }, + () -> { + throw new PChangeNotExistException(); + }); + } + + public void savePChange(Game game, List teamUsers, Long loginUserId) { + if (!pChangeRepository.findPChangesByGameId(game.getId()).isEmpty()) { + return; + } + Long team1UserId = teamUsers.get(0).getUser().getId(); + Long team2UserId = teamUsers.get(1).getUser().getId(); + pChangeService.addPChange(game, teamUsers.get(0).getUser(), + rankRedisService.getUserPpp(team1UserId, game.getSeason().getId()), team1UserId.equals(loginUserId)); + pChangeService.addPChange(game, teamUsers.get(1).getUser(), + rankRedisService.getUserPpp(team2UserId, game.getSeason().getId()), team2UserId.equals(loginUserId)); + } + + private void expUpdate(TeamUser teamUser, LocalDateTime time) { + Integer gamePerDay = teamUserRepository.findByDateAndUser(time, teamUser.getUser().getId()); + teamUser.getUser().addExp(ExpLevelCalculator.getExpPerGame() + (ExpLevelCalculator.getExpBonus() * gamePerDay)); + } + + private static LocalDateTime getToday(LocalDateTime gameTime) { + return LocalDateTime.of(gameTime.getYear(), gameTime.getMonthValue(), gameTime.getDayOfMonth(), 0, 0); + } + + private void setTeamScore(TeamUser tu, int teamScore, Boolean isWin) { + tu.getTeam().updateScore(teamScore, isWin); + } + + private TeamUser findTeamId(Long teamId, List teamUsers) { + for (TeamUser tu : + teamUsers) { + if (tu.getTeam().getId().equals(teamId)) { + return tu; + } + } + throw new TeamIdNotMatchException(); + } + + private Boolean updateRankGameScore(Game game, RankResultReqDto scoreDto, Long userId) { + List teams = teamUserRepository.findAllByGameId(game.getId()); + TeamUser myTeam = findTeamId(scoreDto.getMyTeamId(), teams); + TeamUser enemyTeam = findTeamId(scoreDto.getEnemyTeamId(), teams); + if (!myTeam.getUser().getId().equals(userId)) { + throw new InvalidParameterException("team user 정보 불일치.", ErrorCode.VALID_FAILED); + } else { + if (myTeam.getTeam().getScore().equals(-1) && enemyTeam.getTeam().getScore().equals(-1)) { + setTeamScore(myTeam, scoreDto.getMyTeamScore(), + scoreDto.getMyTeamScore() > scoreDto.getEnemyTeamScore()); + setTeamScore(enemyTeam, scoreDto.getEnemyTeamScore(), + scoreDto.getMyTeamScore() < scoreDto.getEnemyTeamScore()); + expUpdates(game, teams); + rankRedisService.updateRankRedis(myTeam, enemyTeam, game); + tierService.updateAllTier(game.getSeason()); + } else { + // score 가 이미 입력됨 + return false; + } + return true; + } + } + + /** + * 토너먼트 게임 결과 업데이트 메소드 + * @param game + * @param scoreDto + * @param userId + * @exception InvalidParameterException 파라미터로 받은 userId가 myTeam의 userId와 일치하지 않을 경우 + * @exception ScoreAlreadyEnteredException 게임 점수가 이미 작성되어 있을 경우 + */ + private void updateTournamentGameScore(Game game, TournamentResultReqDto scoreDto, Long userId) { + List teams = teamUserRepository.findAllByGameId(game.getId()); + TeamUser myTeam = findTeamId(scoreDto.getMyTeamId(), teams); + TeamUser enemyTeam = findTeamId(scoreDto.getEnemyTeamId(), teams); + if (!myTeam.getUser().getId().equals(userId)) { + throw new InvalidParameterException("team user 정보가 일치하지 않습니다.", ErrorCode.VALID_FAILED); + } + if (myTeam.getTeam().getScore().equals(-1) && enemyTeam.getTeam().getScore().equals(-1)) { + setTeamScore(myTeam, scoreDto.getMyTeamScore(), scoreDto.getMyTeamScore() > scoreDto.getEnemyTeamScore()); + setTeamScore(enemyTeam, scoreDto.getEnemyTeamScore(), + scoreDto.getMyTeamScore() < scoreDto.getEnemyTeamScore()); + expUpdates(game, teams); + savePChange(game, teams, userId); + } else { + // score 가 이미 입력됨 + throw new ScoreAlreadyEnteredException(ErrorCode.SCORE_ALREADY_ENTERED.getMessage(), + ErrorCode.SCORE_ALREADY_ENTERED); + } + } +} diff --git a/src/main/java/com/gg/server/domain/game/service/GameStatusService.java b/src/main/java/com/gg/server/domain/game/service/GameStatusService.java index 67e1f66bf..899319685 100644 --- a/src/main/java/com/gg/server/domain/game/service/GameStatusService.java +++ b/src/main/java/com/gg/server/domain/game/service/GameStatusService.java @@ -1,5 +1,13 @@ package com.gg.server.domain.game.service; +import java.time.LocalDateTime; +import java.util.List; + +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Caching; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.exception.GameDataConsistencyException; @@ -14,89 +22,86 @@ import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; import com.gg.server.domain.team.dto.GameUser; import com.gg.server.domain.user.service.UserService; + import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.aspectj.weaver.patterns.ConcreteCflowPointcut.Slot; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.Caching; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; -import java.util.List; @Service @RequiredArgsConstructor @Slf4j public class GameStatusService { - private final GameRepository gameRepository; - private final SnsNotiService snsNotiService; - private final NotiService notiService; - private final UserService userService; - private final SlotManagementRepository slotManagementRepository; + private final GameRepository gameRepository; + private final SnsNotiService snsNotiService; + private final NotiService notiService; + private final UserService userService; + private final SlotManagementRepository slotManagementRepository; - @Transactional - @Caching(evict = { - @CacheEvict(value = "allGameList", allEntries = true), - }) - public void updateBeforeToLiveStatus() { - // game before 중에 현재 시작 시간인 경우 LIVE로 update - List game = gameRepository.findAllByStatusAndStartTimeLessThanEqual(StatusType.BEFORE, getTime(0)); - if (!game.isEmpty()) { - cacheDelete(); - } - for (Game g : game) { - g.updateStatus(); - } - } + @Transactional + @Caching(evict = { + @CacheEvict(value = "allGameList", allEntries = true), + }) + public void updateBeforeToLiveStatus() { + // game before 중에 현재 시작 시간인 경우 LIVE로 update + List game = gameRepository.findAllByStatusAndStartTimeLessThanEqual(StatusType.BEFORE, getTime(0)); + if (!game.isEmpty()) { + cacheDelete(); + } + for (Game g : game) { + g.updateStatus(); + } + } - void cacheDelete() {} + void cacheDelete() { + } - @Transactional - @Caching(evict = { - @CacheEvict(value = "allGameList", allEntries = true), - }) - public void updateLiveToWaitStatus() { - // game live 중에 종료 시간인 경우 wait 로 update - LocalDateTime endTime = getTime(1); - List game = gameRepository.findAllByStatusAndEndTimeLessThanEqual(StatusType.LIVE, endTime); - if (!game.isEmpty()) { - cacheDelete(); - } - for (Game g : game) { - g.updateStatus(); - } - } + @Transactional + @Caching(evict = { + @CacheEvict(value = "allGameList", allEntries = true), + }) + public void updateLiveToWaitStatus() { + // game live 중에 종료 시간인 경우 wait 로 update + LocalDateTime endTime = getTime(1); + List game = gameRepository.findAllByStatusAndEndTimeLessThanEqual(StatusType.LIVE, endTime); + if (!game.isEmpty()) { + cacheDelete(); + } + for (Game g : game) { + g.updateStatus(); + } + } - @Transactional - public void imminentGame() { - SlotManagement slotManagement = slotManagementRepository.findCurrent(LocalDateTime.now()) - .orElseThrow(SlotNotFoundException::new); - List games = gameRepository.findAllByStartTimeLessThanEqual(getTime(slotManagement.getOpenMinute())); - if (games.size() > 2) { - log.error("imminent game size is not 2 -> size: " + games.size() + ", check time: " + getTime(slotManagement.getOpenMinute())); - throw new GameDataConsistencyException(); - } else if (games.isEmpty()) { - log.info("시작 " + slotManagement.getOpenMinute() + "분 전인 게임이 존재하지 않습니다."); - return; - } else { - notiProcess(games.get(0), games.get(1).getIntraId(), slotManagement.getOpenMinute()); - notiProcess(games.get(1), games.get(0).getIntraId(), slotManagement.getOpenMinute()); - } - } + @Transactional + public void imminentGame() { + SlotManagement slotManagement = slotManagementRepository.findCurrent(LocalDateTime.now()) + .orElseThrow(SlotNotFoundException::new); + List games = gameRepository.findAllByStartTimeLessThanEqual(getTime(slotManagement.getOpenMinute())); + if (games.size() > 2) { + log.error("imminent game size is not 2 -> size: " + games.size() + ", check time: " + getTime( + slotManagement.getOpenMinute())); + throw new GameDataConsistencyException(); + } else if (games.isEmpty()) { + log.info("시작 " + slotManagement.getOpenMinute() + "분 전인 게임이 존재하지 않습니다."); + return; + } else { + notiProcess(games.get(0), games.get(1).getIntraId(), slotManagement.getOpenMinute()); + notiProcess(games.get(1), games.get(0).getIntraId(), slotManagement.getOpenMinute()); + } + } - /** - * private method - */ - private void notiProcess(GameUser game, String enemyIntra, Integer gameOpenMinute) { - Noti noti = notiService.createImminentNoti(userService.getUser(game.getUserId()), enemyIntra, NotiType.IMMINENT, gameOpenMinute); - snsNotiService.sendSnsNotification(noti, new UserNotiDto(game)); - } + /** + * private method + */ + private void notiProcess(GameUser game, String enemyIntra, Integer gameOpenMinute) { + Noti noti = notiService.createImminentNoti(userService.getUser(game.getUserId()), enemyIntra, NotiType.IMMINENT, + gameOpenMinute); + snsNotiService.sendSnsNotification(noti, new UserNotiDto(game)); + } - private LocalDateTime getTime(int plusMiniute) { - LocalDateTime now = LocalDateTime.now(); - LocalDateTime endTime = LocalDateTime.of(now.getYear(), now.getMonthValue(), now.getDayOfMonth(), - now.getHour(), now.getMinute(), 10); - return endTime.plusMinutes(plusMiniute); - } + private LocalDateTime getTime(int plusMiniute) { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime endTime = LocalDateTime.of(now.getYear(), now.getMonthValue(), now.getDayOfMonth(), + now.getHour(), now.getMinute(), 10); + return endTime.plusMinutes(plusMiniute); + } } diff --git a/src/main/java/com/gg/server/domain/game/type/Mode.java b/src/main/java/com/gg/server/domain/game/type/Mode.java index 1af186b63..9445a3377 100644 --- a/src/main/java/com/gg/server/domain/game/type/Mode.java +++ b/src/main/java/com/gg/server/domain/game/type/Mode.java @@ -1,42 +1,43 @@ package com.gg.server.domain.game.type; +import java.util.List; +import java.util.Locale; + import com.fasterxml.jackson.annotation.JsonCreator; import com.gg.server.domain.match.data.RedisMatchUser; import com.gg.server.domain.match.type.Option; -import java.util.List; + import lombok.Getter; import lombok.RequiredArgsConstructor; -import java.util.Locale; - @Getter @RequiredArgsConstructor public enum Mode { - NORMAL("normal"), RANK("rank"), TOURNAMENT("tournament"); - private final String code; + NORMAL("normal"), RANK("rank"), TOURNAMENT("tournament"); + private final String code; - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static Mode getEnumValue(String code) { - for(Mode e : values()) { - if(e.code.equals(code)) { - return e; - } - else if (e.code.toUpperCase(Locale.ROOT).equals(code.toUpperCase(Locale.ROOT))) - return e; - } - return null; - } + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Mode getEnumValue(String code) { + for (Mode e : values()) { + if (e.code.equals(code)) { + return e; + } else if (e.code.toUpperCase(Locale.ROOT).equals(code.toUpperCase(Locale.ROOT))) { + return e; + } + } + return null; + } - public static Mode ofPlayers(List players, Integer pppGap) { - if (players.stream().allMatch(player -> player.getOption().equals(Option.BOTH))) { - if (Math.abs(players.get(0).getPpp() - players.get(1).getPpp()) <= pppGap) { - return Mode.RANK; - } - return Mode.NORMAL; - } - if (!players.get(0).getOption().equals(Option.BOTH)) { - return Mode.getEnumValue(players.get(0).getOption().getCode()); - } - return Mode.getEnumValue(players.get(1).getOption().getCode()); - } + public static Mode ofPlayers(List players, Integer pppGap) { + if (players.stream().allMatch(player -> player.getOption().equals(Option.BOTH))) { + if (Math.abs(players.get(0).getPpp() - players.get(1).getPpp()) <= pppGap) { + return Mode.RANK; + } + return Mode.NORMAL; + } + if (!players.get(0).getOption().equals(Option.BOTH)) { + return Mode.getEnumValue(players.get(0).getOption().getCode()); + } + return Mode.getEnumValue(players.get(1).getOption().getCode()); + } } diff --git a/src/main/java/com/gg/server/domain/game/type/StatusType.java b/src/main/java/com/gg/server/domain/game/type/StatusType.java index af6d4c199..5ba5b094d 100644 --- a/src/main/java/com/gg/server/domain/game/type/StatusType.java +++ b/src/main/java/com/gg/server/domain/game/type/StatusType.java @@ -1,33 +1,33 @@ package com.gg.server.domain.game.type; +import java.util.Locale; + import com.fasterxml.jackson.annotation.JsonCreator; + import lombok.Getter; import lombok.RequiredArgsConstructor; -import java.util.Locale; - @Getter @RequiredArgsConstructor public enum StatusType { - BEFORE("before", "게임 시작 전"), - LIVE("live", "게임 진행 중"), - WAIT("wait", "게임 끝나고 점수입력 기다리는 상태"), - END("end", "게임이 끝나고 점수입력도 완료"); + BEFORE("before", "게임 시작 전"), + LIVE("live", "게임 진행 중"), + WAIT("wait", "게임 끝나고 점수입력 기다리는 상태"), + END("end", "게임이 끝나고 점수입력도 완료"); - private final String code; - private final String desc; + private final String code; + private final String desc; - @JsonCreator - public static StatusType getEnumFromValue(String value) { - for(StatusType e : values()) { - if(e.name().equals(value)) { - return e; - } - else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { - return e; - } - } - return null; - } + @JsonCreator + public static StatusType getEnumFromValue(String value) { + for (StatusType e : values()) { + if (e.name().equals(value)) { + return e; + } else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { + return e; + } + } + return null; + } } diff --git a/src/main/java/com/gg/server/domain/item/controller/ItemController.java b/src/main/java/com/gg/server/domain/item/controller/ItemController.java index 9b3d7df3a..c410e357e 100644 --- a/src/main/java/com/gg/server/domain/item/controller/ItemController.java +++ b/src/main/java/com/gg/server/domain/item/controller/ItemController.java @@ -1,5 +1,20 @@ package com.gg.server.domain.item.controller; +import javax.validation.Valid; + +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import com.gg.server.domain.item.dto.ItemGiftRequestDto; import com.gg.server.domain.item.dto.ItemStoreListResponseDto; import com.gg.server.domain.item.dto.UserItemListResponseDto; @@ -7,50 +22,43 @@ import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.dto.PageRequestDto; import com.gg.server.global.utils.argumentresolver.Login; + import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; @RestController @RequiredArgsConstructor @RequestMapping("/pingpong/items") public class ItemController { - private final ItemService itemService; - - @GetMapping("/store") - public ItemStoreListResponseDto getAllItems() { - return itemService.getAllItems(); - } - - @PostMapping("/purchases/{itemId}") - public ResponseEntity purchaseItem(@PathVariable Long itemId, - @Parameter(hidden = true) @Login UserDto userDto) { - itemService.purchaseItem(itemId, userDto); - return new ResponseEntity(HttpStatus.CREATED); - } - - @PostMapping("/gift/{itemId}") - public ResponseEntity giftItem(@PathVariable Long itemId, - @RequestBody ItemGiftRequestDto recipient, - @Parameter(hidden = true) @Login UserDto userDto) { - itemService.giftItem(itemId, recipient.getOwnerId(), userDto); - return new ResponseEntity(HttpStatus.CREATED); - } - - @GetMapping - public UserItemListResponseDto getItemByUser(@ModelAttribute @Valid PageRequestDto req, - @Parameter(hidden = true) @Login UserDto userDto) { - Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize(), - Sort.by("createdAt").descending()); - return itemService.getItemByUser(userDto, pageable); - } + private final ItemService itemService; + + @GetMapping("/store") + public ItemStoreListResponseDto getAllItems() { + return itemService.getAllItems(); + } + + @PostMapping("/purchases/{itemId}") + public ResponseEntity purchaseItem(@PathVariable Long itemId, + @Parameter(hidden = true) @Login UserDto userDto) { + itemService.purchaseItem(itemId, userDto); + return new ResponseEntity(HttpStatus.CREATED); + } + + @PostMapping("/gift/{itemId}") + public ResponseEntity giftItem(@PathVariable Long itemId, + @RequestBody ItemGiftRequestDto recipient, + @Parameter(hidden = true) @Login UserDto userDto) { + itemService.giftItem(itemId, recipient.getOwnerId(), userDto); + return new ResponseEntity(HttpStatus.CREATED); + } + + @GetMapping + public UserItemListResponseDto getItemByUser(@ModelAttribute @Valid PageRequestDto req, + @Parameter(hidden = true) @Login UserDto userDto) { + Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize(), + Sort.by("createdAt").descending()); + return itemService.getItemByUser(userDto, pageable); + } } diff --git a/src/main/java/com/gg/server/domain/item/data/Item.java b/src/main/java/com/gg/server/domain/item/data/Item.java index 651de5fb6..6f5e5a56b 100644 --- a/src/main/java/com/gg/server/domain/item/data/Item.java +++ b/src/main/java/com/gg/server/domain/item/data/Item.java @@ -1,111 +1,121 @@ package com.gg.server.domain.item.data; +import java.time.LocalDateTime; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.validation.constraints.NotNull; + import com.gg.server.admin.item.dto.ItemUpdateRequestDto; import com.gg.server.domain.item.type.ItemType; -import lombok.*; -import javax.persistence.*; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; @Entity @Getter @NoArgsConstructor public class Item { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "name", length = 30) - private String name; - - @Column(name = "main_content", length = 255) - private String mainContent; - - @Column(name = "sub_content", length = 255) - private String subContent; - - @Column(name = "image_uri", length = 255) - private String imageUri; - - @NotNull - @Column(name = "price") - private Integer price; - - @NotNull - @Column(name = "is_visible") - private Boolean isVisible; - - @Column(name = "discount") - private Integer discount; - - @NotNull - @Enumerated(EnumType.STRING) - @Column(name = "type") - private ItemType type; - - @NotNull - @Column(name = "created_at") - private LocalDateTime createdAt; - - @NotNull - @Column(name = "creator_intra_id", length = 10) - private String creatorIntraId; - - @Column(name = "deleter_intra_id", length = 10) - private String deleterIntraId; - - public Item(String name, String mainContent, String subContent, String imageUri, Integer price, - Boolean isVisible, Integer discount, ItemType type, LocalDateTime createdAt, String creatorIntraId) { - this.name = name; - this.mainContent = mainContent; - this.subContent = subContent; - this.imageUri = imageUri; - this.price = price; - this.isVisible = isVisible; - this.discount = discount; - this.type = type; - this.createdAt = createdAt; - this.creatorIntraId = creatorIntraId; - } - - @Builder - public Item(ItemUpdateRequestDto updateRequestDto, String creatorIntraId, String itemImageUri) { - this.name = updateRequestDto.getName(); - this.mainContent = updateRequestDto.getMainContent(); - this.subContent = updateRequestDto.getSubContent(); - this.imageUri = itemImageUri; - this.price = updateRequestDto.getPrice(); - this.discount = updateRequestDto.getDiscount(); - this.isVisible = true; - this.creatorIntraId = creatorIntraId; - this.createdAt = LocalDateTime.now(); - this.type = updateRequestDto.getItemType(); - } - - public void imageUpdate(String imageUri) { - this.imageUri = imageUri; - } - - public void setVisibility(String intraId) { - this.isVisible = false; - this.deleterIntraId = intraId; - } - - @Override - public String toString() { - return "Item{" + - "id=" + id + - ", name='" + name + '\'' + - ", mainContent='" + mainContent + '\'' + - ", subContent='" + subContent + '\'' + - ", imageUri='" + imageUri + '\'' + - ", price=" + price + - ", isVisible=" + isVisible + - ", discount=" + discount + - ", createdAt=" + createdAt + - ", creatorIntraId='" + creatorIntraId + '\'' + - ", deleterIntraId='" + deleterIntraId + '\'' + - '}'; - } -} \ No newline at end of file + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "name", length = 30) + private String name; + + @Column(name = "main_content", length = 255) + private String mainContent; + + @Column(name = "sub_content", length = 255) + private String subContent; + + @Column(name = "image_uri", length = 255) + private String imageUri; + + @NotNull + @Column(name = "price") + private Integer price; + + @NotNull + @Column(name = "is_visible") + private Boolean isVisible; + + @Column(name = "discount") + private Integer discount; + + @NotNull + @Enumerated(EnumType.STRING) + @Column(name = "type") + private ItemType type; + + @NotNull + @Column(name = "created_at") + private LocalDateTime createdAt; + + @NotNull + @Column(name = "creator_intra_id", length = 10) + private String creatorIntraId; + + @Column(name = "deleter_intra_id", length = 10) + private String deleterIntraId; + + public Item(String name, String mainContent, String subContent, String imageUri, Integer price, + Boolean isVisible, Integer discount, ItemType type, LocalDateTime createdAt, String creatorIntraId) { + this.name = name; + this.mainContent = mainContent; + this.subContent = subContent; + this.imageUri = imageUri; + this.price = price; + this.isVisible = isVisible; + this.discount = discount; + this.type = type; + this.createdAt = createdAt; + this.creatorIntraId = creatorIntraId; + } + + @Builder + public Item(ItemUpdateRequestDto updateRequestDto, String creatorIntraId, String itemImageUri) { + this.name = updateRequestDto.getName(); + this.mainContent = updateRequestDto.getMainContent(); + this.subContent = updateRequestDto.getSubContent(); + this.imageUri = itemImageUri; + this.price = updateRequestDto.getPrice(); + this.discount = updateRequestDto.getDiscount(); + this.isVisible = true; + this.creatorIntraId = creatorIntraId; + this.createdAt = LocalDateTime.now(); + this.type = updateRequestDto.getItemType(); + } + + public void imageUpdate(String imageUri) { + this.imageUri = imageUri; + } + + public void setVisibility(String intraId) { + this.isVisible = false; + this.deleterIntraId = intraId; + } + + @Override + public String toString() { + return "Item{" + + "id=" + id + + ", name='" + name + '\'' + + ", mainContent='" + mainContent + '\'' + + ", subContent='" + subContent + '\'' + + ", imageUri='" + imageUri + '\'' + + ", price=" + price + + ", isVisible=" + isVisible + + ", discount=" + discount + + ", createdAt=" + createdAt + + ", creatorIntraId='" + creatorIntraId + '\'' + + ", deleterIntraId='" + deleterIntraId + '\'' + + '}'; + } +} diff --git a/src/main/java/com/gg/server/domain/item/data/ItemRepository.java b/src/main/java/com/gg/server/domain/item/data/ItemRepository.java index ef6f26fd8..3623e681c 100644 --- a/src/main/java/com/gg/server/domain/item/data/ItemRepository.java +++ b/src/main/java/com/gg/server/domain/item/data/ItemRepository.java @@ -1,10 +1,11 @@ package com.gg.server.domain.item.data; +import java.util.List; + import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import java.util.List; public interface ItemRepository extends JpaRepository { - @Query("SELECT i FROM Item i WHERE i.isVisible = true ORDER BY i.createdAt DESC") - List findAllByCreatedAtDesc(); + @Query("SELECT i FROM Item i WHERE i.isVisible = true ORDER BY i.createdAt DESC") + List findAllByCreatedAtDesc(); } diff --git a/src/main/java/com/gg/server/domain/item/data/UserItemRepository.java b/src/main/java/com/gg/server/domain/item/data/UserItemRepository.java index 6fcab5174..444594917 100644 --- a/src/main/java/com/gg/server/domain/item/data/UserItemRepository.java +++ b/src/main/java/com/gg/server/domain/item/data/UserItemRepository.java @@ -1,15 +1,16 @@ package com.gg.server.domain.item.data; -import com.gg.server.domain.receipt.data.Receipt; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import com.gg.server.domain.receipt.data.Receipt; + public interface UserItemRepository extends JpaRepository { - @Query("select r from Receipt r where r.ownerIntraId = :intraId " + - "and (r.status = 'BEFORE' or r.status = 'USING' or r.status = 'WAITING') order by r.createdAt desc") - Page findByOwnerIntraId(@Param("intraId") String intraId, Pageable pageable); + @Query("select r from Receipt r where r.ownerIntraId = :intraId " + + "and (r.status = 'BEFORE' or r.status = 'USING' or r.status = 'WAITING') order by r.createdAt desc") + Page findByOwnerIntraId(@Param("intraId") String intraId, Pageable pageable); } diff --git a/src/main/java/com/gg/server/domain/item/dto/ItemGiftRequestDto.java b/src/main/java/com/gg/server/domain/item/dto/ItemGiftRequestDto.java index 4085b5eac..8a252d9ab 100644 --- a/src/main/java/com/gg/server/domain/item/dto/ItemGiftRequestDto.java +++ b/src/main/java/com/gg/server/domain/item/dto/ItemGiftRequestDto.java @@ -8,5 +8,5 @@ @AllArgsConstructor @NoArgsConstructor public class ItemGiftRequestDto { - private String ownerId; -} \ No newline at end of file + private String ownerId; +} diff --git a/src/main/java/com/gg/server/domain/item/dto/ItemStoreListResponseDto.java b/src/main/java/com/gg/server/domain/item/dto/ItemStoreListResponseDto.java index 702ac6950..49802e579 100644 --- a/src/main/java/com/gg/server/domain/item/dto/ItemStoreListResponseDto.java +++ b/src/main/java/com/gg/server/domain/item/dto/ItemStoreListResponseDto.java @@ -1,16 +1,16 @@ package com.gg.server.domain.item.dto; +import java.util.List; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @NoArgsConstructor @Getter public class ItemStoreListResponseDto { - private List itemList; + private List itemList; - public ItemStoreListResponseDto(List itemList){ - this.itemList = itemList; - } + public ItemStoreListResponseDto(List itemList) { + this.itemList = itemList; + } } diff --git a/src/main/java/com/gg/server/domain/item/dto/ItemStoreResponseDto.java b/src/main/java/com/gg/server/domain/item/dto/ItemStoreResponseDto.java index 4ecc4bb46..fa0b1eb47 100644 --- a/src/main/java/com/gg/server/domain/item/dto/ItemStoreResponseDto.java +++ b/src/main/java/com/gg/server/domain/item/dto/ItemStoreResponseDto.java @@ -2,6 +2,7 @@ import com.gg.server.domain.item.data.Item; import com.gg.server.domain.item.type.ItemType; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -10,25 +11,25 @@ @AllArgsConstructor @NoArgsConstructor public class ItemStoreResponseDto { - private Long itemId; - private String itemName; - private String mainContent; - private String subContent; - private ItemType itemType; - private String imageUri; - private Integer originalPrice; - private Integer discount; - private Integer salePrice; + private Long itemId; + private String itemName; + private String mainContent; + private String subContent; + private ItemType itemType; + private String imageUri; + private Integer originalPrice; + private Integer discount; + private Integer salePrice; - public ItemStoreResponseDto(Item item) { - this.itemId = item.getId(); - this.itemName = item.getName(); - this.mainContent = item.getMainContent(); - this.subContent = item.getSubContent(); - this.itemType = item.getType(); - this.imageUri = item.getImageUri(); - this.originalPrice = item.getPrice(); - this.discount = item.getDiscount(); - this.salePrice = this.originalPrice - (this.originalPrice * this.discount / 100); - } + public ItemStoreResponseDto(Item item) { + this.itemId = item.getId(); + this.itemName = item.getName(); + this.mainContent = item.getMainContent(); + this.subContent = item.getSubContent(); + this.itemType = item.getType(); + this.imageUri = item.getImageUri(); + this.originalPrice = item.getPrice(); + this.discount = item.getDiscount(); + this.salePrice = this.originalPrice - (this.originalPrice * this.discount / 100); + } } diff --git a/src/main/java/com/gg/server/domain/item/dto/UserItemListResponseDto.java b/src/main/java/com/gg/server/domain/item/dto/UserItemListResponseDto.java index 230d00524..9cfb4dc7b 100644 --- a/src/main/java/com/gg/server/domain/item/dto/UserItemListResponseDto.java +++ b/src/main/java/com/gg/server/domain/item/dto/UserItemListResponseDto.java @@ -1,19 +1,19 @@ package com.gg.server.domain.item.dto; +import java.util.List; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @Getter @NoArgsConstructor public class UserItemListResponseDto { - private List storageItemList; - private Integer totalPage; + private List storageItemList; + private Integer totalPage; - public UserItemListResponseDto(List storageItemList, Integer totalPage){ - this.storageItemList = storageItemList; - this.totalPage = totalPage; - } + public UserItemListResponseDto(List storageItemList, Integer totalPage) { + this.storageItemList = storageItemList; + this.totalPage = totalPage; + } -} \ No newline at end of file +} diff --git a/src/main/java/com/gg/server/domain/item/dto/UserItemResponseDto.java b/src/main/java/com/gg/server/domain/item/dto/UserItemResponseDto.java index a2e5d49bd..dbd4e1ca9 100644 --- a/src/main/java/com/gg/server/domain/item/dto/UserItemResponseDto.java +++ b/src/main/java/com/gg/server/domain/item/dto/UserItemResponseDto.java @@ -4,6 +4,7 @@ import com.gg.server.domain.item.type.ItemType; import com.gg.server.domain.receipt.data.Receipt; import com.gg.server.domain.receipt.type.ItemStatus; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -12,21 +13,21 @@ @AllArgsConstructor @NoArgsConstructor public class UserItemResponseDto { - private Long receiptId; - private String itemName; - private String imageUri; - private String purchaserIntra; - private ItemStatus itemStatus; - private ItemType itemType; + private Long receiptId; + private String itemName; + private String imageUri; + private String purchaserIntra; + private ItemStatus itemStatus; + private ItemType itemType; - public UserItemResponseDto(Receipt receipt) { - Item item = receipt.getItem(); - this.receiptId = receipt.getId(); - this.itemName = item.getName(); - this.imageUri = item.getImageUri(); - this.purchaserIntra = receipt.getPurchaserIntraId(); - this.itemStatus = receipt.getStatus(); - this.itemType = item.getType(); - } + public UserItemResponseDto(Receipt receipt) { + Item item = receipt.getItem(); + this.receiptId = receipt.getId(); + this.itemName = item.getName(); + this.imageUri = item.getImageUri(); + this.purchaserIntra = receipt.getPurchaserIntraId(); + this.itemStatus = receipt.getStatus(); + this.itemType = item.getType(); + } -} \ No newline at end of file +} diff --git a/src/main/java/com/gg/server/domain/item/exception/InsufficientGgcoinException.java b/src/main/java/com/gg/server/domain/item/exception/InsufficientGgcoinException.java index aefb4d198..3cb20a373 100644 --- a/src/main/java/com/gg/server/domain/item/exception/InsufficientGgcoinException.java +++ b/src/main/java/com/gg/server/domain/item/exception/InsufficientGgcoinException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.BusinessException; public class InsufficientGgcoinException extends BusinessException { - public InsufficientGgcoinException() { - super("GGcoin이 부족합니다.", ErrorCode.INSUFFICIENT_GGCOIN); - } + public InsufficientGgcoinException() { + super("GGcoin이 부족합니다.", ErrorCode.INSUFFICIENT_GGCOIN); + } } diff --git a/src/main/java/com/gg/server/domain/item/exception/ItemImageLargeException.java b/src/main/java/com/gg/server/domain/item/exception/ItemImageLargeException.java index 8c8dd7561..f2e488e69 100644 --- a/src/main/java/com/gg/server/domain/item/exception/ItemImageLargeException.java +++ b/src/main/java/com/gg/server/domain/item/exception/ItemImageLargeException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.FileException; public class ItemImageLargeException extends FileException { - public ItemImageLargeException() { - super("이미지 파일 50KB 초과", ErrorCode.USER_IMAGE_TOO_LARGE); - } + public ItemImageLargeException() { + super("이미지 파일 50KB 초과", ErrorCode.USER_IMAGE_TOO_LARGE); + } } diff --git a/src/main/java/com/gg/server/domain/item/exception/ItemImageTypeException.java b/src/main/java/com/gg/server/domain/item/exception/ItemImageTypeException.java index 34955934f..dc2e5f3d0 100644 --- a/src/main/java/com/gg/server/domain/item/exception/ItemImageTypeException.java +++ b/src/main/java/com/gg/server/domain/item/exception/ItemImageTypeException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.FileException; public class ItemImageTypeException extends FileException { - public ItemImageTypeException() { - super("이미지 타입이 올바르지 않습니다", ErrorCode.ITEM_IMAGE_WRONG_TYPE); - } + public ItemImageTypeException() { + super("이미지 타입이 올바르지 않습니다", ErrorCode.ITEM_IMAGE_WRONG_TYPE); + } } diff --git a/src/main/java/com/gg/server/domain/item/exception/ItemNotAvailableException.java b/src/main/java/com/gg/server/domain/item/exception/ItemNotAvailableException.java index ab807ed84..2f276a6f8 100644 --- a/src/main/java/com/gg/server/domain/item/exception/ItemNotAvailableException.java +++ b/src/main/java/com/gg/server/domain/item/exception/ItemNotAvailableException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.FileException; public class ItemNotAvailableException extends FileException { - public ItemNotAvailableException() { - super("아이템 접근이 불가합니다", ErrorCode.ITEM_NOT_AVAILABLE); - } + public ItemNotAvailableException() { + super("아이템 접근이 불가합니다", ErrorCode.ITEM_NOT_AVAILABLE); + } } diff --git a/src/main/java/com/gg/server/domain/item/exception/ItemNotFoundException.java b/src/main/java/com/gg/server/domain/item/exception/ItemNotFoundException.java index 88e74d13f..2e5fc703c 100644 --- a/src/main/java/com/gg/server/domain/item/exception/ItemNotFoundException.java +++ b/src/main/java/com/gg/server/domain/item/exception/ItemNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class ItemNotFoundException extends NotExistException { - public ItemNotFoundException() { - super("해당 아이템이 없습니다.", ErrorCode.ITEM_NOT_FOUND); - } -} \ No newline at end of file + public ItemNotFoundException() { + super("해당 아이템이 없습니다.", ErrorCode.ITEM_NOT_FOUND); + } +} diff --git a/src/main/java/com/gg/server/domain/item/exception/ItemNotPurchasableException.java b/src/main/java/com/gg/server/domain/item/exception/ItemNotPurchasableException.java index 170bfc7b5..6b181ab5d 100644 --- a/src/main/java/com/gg/server/domain/item/exception/ItemNotPurchasableException.java +++ b/src/main/java/com/gg/server/domain/item/exception/ItemNotPurchasableException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.BusinessException; public class ItemNotPurchasableException extends BusinessException { - public ItemNotPurchasableException() { - super("지금은 구매할 수 없는 아이템 입니다.", ErrorCode.ITEM_NOT_PURCHASABLE); - } -} \ No newline at end of file + public ItemNotPurchasableException() { + super("지금은 구매할 수 없는 아이템 입니다.", ErrorCode.ITEM_NOT_PURCHASABLE); + } +} diff --git a/src/main/java/com/gg/server/domain/item/exception/ItemTypeException.java b/src/main/java/com/gg/server/domain/item/exception/ItemTypeException.java index 4e39acfe5..5e9320142 100644 --- a/src/main/java/com/gg/server/domain/item/exception/ItemTypeException.java +++ b/src/main/java/com/gg/server/domain/item/exception/ItemTypeException.java @@ -4,5 +4,7 @@ import com.gg.server.global.exception.custom.BusinessException; public class ItemTypeException extends BusinessException { - public ItemTypeException() {super("아이템 타입 오류입니다.", ErrorCode.ITEM_TYPE_NOT_MATCHED);} + public ItemTypeException() { + super("아이템 타입 오류입니다.", ErrorCode.ITEM_TYPE_NOT_MATCHED); + } } diff --git a/src/main/java/com/gg/server/domain/item/exception/KakaoGiftException.java b/src/main/java/com/gg/server/domain/item/exception/KakaoGiftException.java index e85c4190e..6aa0cf2f3 100644 --- a/src/main/java/com/gg/server/domain/item/exception/KakaoGiftException.java +++ b/src/main/java/com/gg/server/domain/item/exception/KakaoGiftException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.BusinessException; public class KakaoGiftException extends BusinessException { - public KakaoGiftException() { - super("카카오 게스트는 선물할 수 없습니다.", ErrorCode.GUEST_ROLE_GIFT_FORBIDDEN); - } + public KakaoGiftException() { + super("카카오 게스트는 선물할 수 없습니다.", ErrorCode.GUEST_ROLE_GIFT_FORBIDDEN); + } } diff --git a/src/main/java/com/gg/server/domain/item/exception/KakaoPurchaseException.java b/src/main/java/com/gg/server/domain/item/exception/KakaoPurchaseException.java index 2164fb165..53541f2a1 100644 --- a/src/main/java/com/gg/server/domain/item/exception/KakaoPurchaseException.java +++ b/src/main/java/com/gg/server/domain/item/exception/KakaoPurchaseException.java @@ -4,8 +4,8 @@ import com.gg.server.global.exception.custom.BusinessException; public class KakaoPurchaseException extends BusinessException { - public KakaoPurchaseException() { - super("카카오 게스트는 구매할 수 없습니다.", ErrorCode.GUEST_ROLE_PURCHASE_FORBIDDEN); - } + public KakaoPurchaseException() { + super("카카오 게스트는 구매할 수 없습니다.", ErrorCode.GUEST_ROLE_PURCHASE_FORBIDDEN); + } } diff --git a/src/main/java/com/gg/server/domain/item/service/ItemService.java b/src/main/java/com/gg/server/domain/item/service/ItemService.java index 71268b568..3c8a4177b 100644 --- a/src/main/java/com/gg/server/domain/item/service/ItemService.java +++ b/src/main/java/com/gg/server/domain/item/service/ItemService.java @@ -1,5 +1,14 @@ package com.gg.server.domain.item.service; +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.domain.coin.service.UserCoinChangeService; import com.gg.server.domain.item.data.Item; import com.gg.server.domain.item.data.ItemRepository; @@ -8,7 +17,11 @@ import com.gg.server.domain.item.dto.ItemStoreResponseDto; import com.gg.server.domain.item.dto.UserItemListResponseDto; import com.gg.server.domain.item.dto.UserItemResponseDto; -import com.gg.server.domain.item.exception.*; +import com.gg.server.domain.item.exception.ItemNotFoundException; +import com.gg.server.domain.item.exception.ItemNotPurchasableException; +import com.gg.server.domain.item.exception.ItemTypeException; +import com.gg.server.domain.item.exception.KakaoGiftException; +import com.gg.server.domain.item.exception.KakaoPurchaseException; import com.gg.server.domain.item.type.ItemType; import com.gg.server.domain.noti.service.NotiService; import com.gg.server.domain.receipt.data.Receipt; @@ -21,129 +34,128 @@ import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; import com.gg.server.domain.user.type.RoleType; -import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class ItemService { - private final ItemRepository itemRepository; - private final ReceiptRepository receiptRepository; - private final UserRepository userRepository; - private final UserItemRepository userItemRepository; - private final NotiService notiService; - private final UserCoinChangeService userCoinChangeService; - - @Transactional(readOnly = true) - public ItemStoreListResponseDto getAllItems() { - - List itemStoreListResponseDto = itemRepository.findAllByCreatedAtDesc() - .stream().map(ItemStoreResponseDto::new).collect(Collectors.toList()); - return new ItemStoreListResponseDto(itemStoreListResponseDto); - } - - @Transactional - public void purchaseItem(Long itemId, UserDto userDto) { - Item item = itemRepository.findById(itemId) - .orElseThrow(() -> { - throw new ItemNotFoundException(); - }); - if (!item.getIsVisible()) { - throw new ItemNotPurchasableException(); - } - - //세일가격 존재할때 세일가로 결정 - Integer finalPrice; - if (item.getDiscount() != null && item.getDiscount() > 0) { - finalPrice = item.getPrice() - (item.getPrice() * item.getDiscount() / 100); - } else { - finalPrice = item.getPrice(); - } - - User payUser = userRepository.findById(userDto.getId()) - .orElseThrow(() -> new UserNotFoundException()); - - if (payUser.getRoleType() == RoleType.GUEST) { - throw new KakaoPurchaseException(); - } - - userCoinChangeService.purchaseItemCoin(item, finalPrice, userDto.getId()); - - Receipt receipt = new Receipt(item, userDto.getIntraId(), userDto.getIntraId(), - ItemStatus.BEFORE, LocalDateTime.now()); - receiptRepository.save(receipt); - } - - @Transactional - public void giftItem(Long itemId, String ownerId, UserDto userDto) { - Item item = itemRepository.findById(itemId) - .orElseThrow(() -> { - throw new ItemNotFoundException(); - }); - if (!item.getIsVisible()) { - throw new ItemNotPurchasableException(); - } - - //세일가격 존재할때 세일가로 결정 - Integer finalPrice; - if (item.getDiscount() != null && item.getDiscount() > 0) { - finalPrice = item.getPrice() - (item.getPrice() * item.getDiscount() / 100); - } else { - finalPrice = item.getPrice(); - } - - User payUser = userRepository.findById(userDto.getId()) - .orElseThrow(UserNotFoundException::new); - - if (payUser.getRoleType() == RoleType.GUEST) { - throw new KakaoPurchaseException(); - } - - User owner = userRepository.findByIntraId(ownerId) - .orElseThrow(UserNotFoundException::new); - - if (owner.getRoleType() == RoleType.GUEST) { - throw new KakaoGiftException(); - } - - userCoinChangeService.giftItemCoin(item, finalPrice, payUser, owner); - - Receipt receipt = new Receipt(item, userDto.getIntraId(), ownerId, - ItemStatus.BEFORE, LocalDateTime.now()); - receiptRepository.save(receipt); - notiService.createGiftNoti(owner, payUser, item.getName()); - } - - @Transactional(readOnly = true) - public UserItemListResponseDto getItemByUser(UserDto userDto, Pageable pageable) { - Page receipts = userItemRepository.findByOwnerIntraId(userDto.getIntraId(), pageable); - Page responseDtos = receipts.map(UserItemResponseDto::new); - return new UserItemListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); - } - - public void checkItemOwner(User loginUser, Receipt receipt) { - if (!receipt.getOwnerIntraId().equals(loginUser.getIntraId())) - throw new ReceiptNotOwnerException(); - } - - public void checkItemType(Receipt receipt, ItemType itemType) { - if (!receipt.getItem().getType().equals(itemType)) - throw new ItemTypeException(); - } - - public void checkItemStatus(Receipt receipt) { - if (receipt.getItem().getType().equals(ItemType.MEGAPHONE)) { - if (!(receipt.getStatus().equals(ItemStatus.WAITING) || receipt.getStatus().equals(ItemStatus.USING))) throw new ItemStatusException(); - } else { - if (!receipt.getStatus().equals(ItemStatus.BEFORE)) throw new ItemStatusException(); - } - } + private final ItemRepository itemRepository; + private final ReceiptRepository receiptRepository; + private final UserRepository userRepository; + private final UserItemRepository userItemRepository; + private final NotiService notiService; + private final UserCoinChangeService userCoinChangeService; + + @Transactional(readOnly = true) + public ItemStoreListResponseDto getAllItems() { + + List itemStoreListResponseDto = itemRepository.findAllByCreatedAtDesc() + .stream().map(ItemStoreResponseDto::new).collect(Collectors.toList()); + return new ItemStoreListResponseDto(itemStoreListResponseDto); + } + + @Transactional + public void purchaseItem(Long itemId, UserDto userDto) { + Item item = itemRepository.findById(itemId) + .orElseThrow(() -> { + throw new ItemNotFoundException(); + }); + if (!item.getIsVisible()) { + throw new ItemNotPurchasableException(); + } + + //세일가격 존재할때 세일가로 결정 + Integer finalPrice; + if (item.getDiscount() != null && item.getDiscount() > 0) { + finalPrice = item.getPrice() - (item.getPrice() * item.getDiscount() / 100); + } else { + finalPrice = item.getPrice(); + } + + User payUser = userRepository.findById(userDto.getId()) + .orElseThrow(() -> new UserNotFoundException()); + + if (payUser.getRoleType() == RoleType.GUEST) { + throw new KakaoPurchaseException(); + } + + userCoinChangeService.purchaseItemCoin(item, finalPrice, userDto.getId()); + + Receipt receipt = new Receipt(item, userDto.getIntraId(), userDto.getIntraId(), + ItemStatus.BEFORE, LocalDateTime.now()); + receiptRepository.save(receipt); + } + + @Transactional + public void giftItem(Long itemId, String ownerId, UserDto userDto) { + Item item = itemRepository.findById(itemId) + .orElseThrow(() -> { + throw new ItemNotFoundException(); + }); + if (!item.getIsVisible()) { + throw new ItemNotPurchasableException(); + } + + //세일가격 존재할때 세일가로 결정 + Integer finalPrice; + if (item.getDiscount() != null && item.getDiscount() > 0) { + finalPrice = item.getPrice() - (item.getPrice() * item.getDiscount() / 100); + } else { + finalPrice = item.getPrice(); + } + + User payUser = userRepository.findById(userDto.getId()) + .orElseThrow(UserNotFoundException::new); + + if (payUser.getRoleType() == RoleType.GUEST) { + throw new KakaoPurchaseException(); + } + + User owner = userRepository.findByIntraId(ownerId) + .orElseThrow(UserNotFoundException::new); + + if (owner.getRoleType() == RoleType.GUEST) { + throw new KakaoGiftException(); + } + + userCoinChangeService.giftItemCoin(item, finalPrice, payUser, owner); + + Receipt receipt = new Receipt(item, userDto.getIntraId(), ownerId, + ItemStatus.BEFORE, LocalDateTime.now()); + receiptRepository.save(receipt); + notiService.createGiftNoti(owner, payUser, item.getName()); + } + + @Transactional(readOnly = true) + public UserItemListResponseDto getItemByUser(UserDto userDto, Pageable pageable) { + Page receipts = userItemRepository.findByOwnerIntraId(userDto.getIntraId(), pageable); + Page responseDtos = receipts.map(UserItemResponseDto::new); + return new UserItemListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); + } + + public void checkItemOwner(User loginUser, Receipt receipt) { + if (!receipt.getOwnerIntraId().equals(loginUser.getIntraId())) { + throw new ReceiptNotOwnerException(); + } + } + + public void checkItemType(Receipt receipt, ItemType itemType) { + if (!receipt.getItem().getType().equals(itemType)) { + throw new ItemTypeException(); + } + } + + public void checkItemStatus(Receipt receipt) { + if (receipt.getItem().getType().equals(ItemType.MEGAPHONE)) { + if (!(receipt.getStatus().equals(ItemStatus.WAITING) || receipt.getStatus().equals(ItemStatus.USING))) { + throw new ItemStatusException(); + } + } else { + if (!receipt.getStatus().equals(ItemStatus.BEFORE)) { + throw new ItemStatusException(); + } + } + } } diff --git a/src/main/java/com/gg/server/domain/item/type/ItemType.java b/src/main/java/com/gg/server/domain/item/type/ItemType.java index 1bfafaae1..77fd7d812 100644 --- a/src/main/java/com/gg/server/domain/item/type/ItemType.java +++ b/src/main/java/com/gg/server/domain/item/type/ItemType.java @@ -4,6 +4,6 @@ @RequiredArgsConstructor public enum ItemType { - MEGAPHONE, BACKGROUND, EDGE, TEXT_COLOR, PROFILE_IMAGE + MEGAPHONE, BACKGROUND, EDGE, TEXT_COLOR, PROFILE_IMAGE } diff --git a/src/main/java/com/gg/server/domain/match/controller/MatchController.java b/src/main/java/com/gg/server/domain/match/controller/MatchController.java index afbc4bade..ca93a142a 100644 --- a/src/main/java/com/gg/server/domain/match/controller/MatchController.java +++ b/src/main/java/com/gg/server/domain/match/controller/MatchController.java @@ -1,21 +1,12 @@ package com.gg.server.domain.match.controller; -import com.gg.server.domain.match.dto.MatchRequestDto; -import com.gg.server.domain.match.dto.MatchStatusResponseListDto; -import com.gg.server.domain.match.dto.SlotStatusResponseListDto; -import com.gg.server.domain.match.service.MatchService; -import com.gg.server.domain.match.service.MatchFindService; -import com.gg.server.domain.match.type.Option; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.utils.argumentresolver.Login; -import io.swagger.v3.oas.annotations.Parameter; import java.time.LocalDateTime; + import javax.validation.Valid; -import lombok.RequiredArgsConstructor; + import org.springframework.format.annotation.DateTimeFormat; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -24,48 +15,61 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import com.gg.server.domain.match.dto.MatchRequestDto; +import com.gg.server.domain.match.dto.MatchStatusResponseListDto; +import com.gg.server.domain.match.dto.SlotStatusResponseListDto; +import com.gg.server.domain.match.service.MatchFindService; +import com.gg.server.domain.match.service.MatchService; +import com.gg.server.domain.match.type.Option; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.utils.argumentresolver.Login; + +import io.swagger.v3.oas.annotations.Parameter; +import lombok.RequiredArgsConstructor; + @RestController @RequiredArgsConstructor @RequestMapping("/pingpong/match") public class MatchController { - private final MatchService matchService; - private final MatchFindService matchFindService; + private final MatchService matchService; + private final MatchFindService matchFindService; + + /** + * 유저 슬롯 입장 요청 API (== 매칭 요청 API) + * @param matchRequestDto + * @param user 매칭 요청한 유저 + * @return 201 (Created) + */ + @PostMapping + public ResponseEntity createUserMatch(@RequestBody @Valid MatchRequestDto matchRequestDto, + @Parameter(hidden = true) @Login UserDto user) { + matchService.makeMatch(user, matchRequestDto.getOption(), matchRequestDto.getStartTime()); + return ResponseEntity.status(HttpStatus.CREATED).build(); + } - /** - * 유저 슬롯 입장 요청 API (== 매칭 요청 API) - * @param matchRequestDto - * @param user 매칭 요청한 유저 - * @return 201 (Created) - */ - @PostMapping - public ResponseEntity createUserMatch(@RequestBody @Valid MatchRequestDto matchRequestDto, - @Parameter(hidden = true) @Login UserDto user) { - matchService.makeMatch(user, matchRequestDto.getOption(), matchRequestDto.getStartTime()); - return ResponseEntity.status(HttpStatus.CREATED).build(); - } - @DeleteMapping - public ResponseEntity deleteUserMatch(@RequestParam("startTime") - @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm") LocalDateTime startTime, - @Parameter(hidden = true) @Login UserDto user) { - matchService.cancelMatch(user, startTime); - return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); - } + @DeleteMapping + public ResponseEntity deleteUserMatch( + @RequestParam("startTime") @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm") LocalDateTime startTime, + @Parameter(hidden = true) @Login UserDto user) { + matchService.cancelMatch(user, startTime); + return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); + } - /** - * 특정 시간대의 경기 매칭 가능 상태 조회 API - * @param mode : BOTH, NORMAL, RANK - * @param user - * @return - */ - @GetMapping("/time/scope") - public SlotStatusResponseListDto getMatchTimeScope(@RequestParam (required = true) String mode, - @Parameter(hidden = true) @Login UserDto user){ - return matchFindService.getAllMatchStatus(user, Option.getEnumValue(mode)); - } + /** + * 특정 시간대의 경기 매칭 가능 상태 조회 API + * @param mode : BOTH, NORMAL, RANK + * @param user + * @return + */ + @GetMapping("/time/scope") + public SlotStatusResponseListDto getMatchTimeScope(@RequestParam(required = true) String mode, + @Parameter(hidden = true) @Login UserDto user) { + return matchFindService.getAllMatchStatus(user, Option.getEnumValue(mode)); + } - @GetMapping - public MatchStatusResponseListDto getCurrentMatch(@Parameter(hidden = true) @Login UserDto user) { - return matchFindService.getCurrentMatch(user); - } + @GetMapping + public MatchStatusResponseListDto getCurrentMatch(@Parameter(hidden = true) @Login UserDto user) { + return matchFindService.getCurrentMatch(user); + } } diff --git a/src/main/java/com/gg/server/domain/match/data/RedisMatchTime.java b/src/main/java/com/gg/server/domain/match/data/RedisMatchTime.java index 8d9f887a7..ed3b7d068 100644 --- a/src/main/java/com/gg/server/domain/match/data/RedisMatchTime.java +++ b/src/main/java/com/gg/server/domain/match/data/RedisMatchTime.java @@ -1,30 +1,34 @@ package com.gg.server.domain.match.data; +import java.io.Serializable; +import java.time.LocalDateTime; + +import javax.persistence.Id; + +import org.springframework.data.redis.core.RedisHash; + import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import com.gg.server.domain.match.type.Option; -import java.io.Serializable; -import java.time.LocalDateTime; -import javax.persistence.Id; + import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; -import org.springframework.data.redis.core.RedisHash; @Getter @RedisHash("matchTime") @NoArgsConstructor(access = AccessLevel.PROTECTED) public class RedisMatchTime implements Serializable { - @Id - @JsonSerialize(using = LocalDateTimeSerializer.class) - @JsonDeserialize(using = LocalDateTimeDeserializer.class) - private LocalDateTime startTime; - private Option option; + @Id + @JsonSerialize(using = LocalDateTimeSerializer.class) + @JsonDeserialize(using = LocalDateTimeDeserializer.class) + private LocalDateTime startTime; + private Option option; - public RedisMatchTime(LocalDateTime startTime, Option option) { - this.startTime = startTime; - this.option = option; - } + public RedisMatchTime(LocalDateTime startTime, Option option) { + this.startTime = startTime; + this.option = option; + } } diff --git a/src/main/java/com/gg/server/domain/match/data/RedisMatchTimeRepository.java b/src/main/java/com/gg/server/domain/match/data/RedisMatchTimeRepository.java index 5e4bf8dd3..e8deea3d9 100644 --- a/src/main/java/com/gg/server/domain/match/data/RedisMatchTimeRepository.java +++ b/src/main/java/com/gg/server/domain/match/data/RedisMatchTimeRepository.java @@ -1,51 +1,53 @@ package com.gg.server.domain.match.data; -import com.gg.server.domain.match.type.MatchKey; -import com.gg.server.domain.user.exception.UserNotFoundException; import java.time.Duration; import java.time.LocalDateTime; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import lombok.RequiredArgsConstructor; -import org.springframework.boot.autoconfigure.cache.CacheProperties.Redis; + import org.springframework.data.redis.core.ListOperations; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; +import com.gg.server.domain.match.type.MatchKey; + +import lombok.RequiredArgsConstructor; + @Repository @RequiredArgsConstructor public class RedisMatchTimeRepository { - private final RedisTemplate redisTemplate; - - public void addMatchUser(LocalDateTime startTime, RedisMatchUser redisMatchUser) { - redisTemplate.opsForList().rightPush(MatchKey.getTime(startTime), redisMatchUser); - } - public List getAllMatchUsers(LocalDateTime startTime) { - ListOperations listOperations = redisTemplate.opsForList(); - return listOperations.range(MatchKey.getTime(startTime), 0, - 1); - } - - public void setMatchTimeWithExpiry(LocalDateTime startTime) { - LocalDateTime now = LocalDateTime.now(); - Duration duration = Duration.between(now, startTime); - redisTemplate.expire(MatchKey.getTime(startTime), duration.getSeconds(), TimeUnit.SECONDS); - } - - public void deleteMatchTime(LocalDateTime startTime) {//매칭이 되거나 시간이 지나면 key를 지워준다. - redisTemplate.delete(MatchKey.getTime(startTime)); - } - - public void deleteMatchUser(LocalDateTime startTime, RedisMatchUser matchUser) { - redisTemplate.opsForList().remove(MatchKey.getTime(startTime),0, matchUser); - } - - public Set getAllEnrolledStartTimes() { - Set keys = redisTemplate.keys(MatchKey.getAllTime() + "*"); - Integer prefixIdx = MatchKey.getAllTime().length(); - return keys.stream().map(str -> LocalDateTime.parse(str.substring(prefixIdx))) - .collect(Collectors.toSet()); - } + private final RedisTemplate redisTemplate; + + public void addMatchUser(LocalDateTime startTime, RedisMatchUser redisMatchUser) { + redisTemplate.opsForList().rightPush(MatchKey.getTime(startTime), redisMatchUser); + } + + public List getAllMatchUsers(LocalDateTime startTime) { + ListOperations listOperations = redisTemplate.opsForList(); + return listOperations.range(MatchKey.getTime(startTime), 0, -1); + } + + public void setMatchTimeWithExpiry(LocalDateTime startTime) { + LocalDateTime now = LocalDateTime.now(); + Duration duration = Duration.between(now, startTime); + redisTemplate.expire(MatchKey.getTime(startTime), duration.getSeconds(), TimeUnit.SECONDS); + } + + public void deleteMatchTime(LocalDateTime startTime) { //매칭이 되거나 시간이 지나면 key를 지워준다. + redisTemplate.delete(MatchKey.getTime(startTime)); + } + + public void deleteMatchUser(LocalDateTime startTime, RedisMatchUser matchUser) { + redisTemplate.opsForList().remove(MatchKey.getTime(startTime), 0, matchUser); + } + + public Set getAllEnrolledStartTimes() { + Set keys = redisTemplate.keys(MatchKey.getAllTime() + "*"); + Integer prefixIdx = MatchKey.getAllTime().length(); + return keys.stream().map(str -> LocalDateTime.parse(str.substring(prefixIdx))) + .collect(Collectors.toSet()); + } } diff --git a/src/main/java/com/gg/server/domain/match/data/RedisMatchUser.java b/src/main/java/com/gg/server/domain/match/data/RedisMatchUser.java index fddaee444..1e9f71af3 100644 --- a/src/main/java/com/gg/server/domain/match/data/RedisMatchUser.java +++ b/src/main/java/com/gg/server/domain/match/data/RedisMatchUser.java @@ -1,25 +1,29 @@ package com.gg.server.domain.match.data; -import com.gg.server.domain.match.type.Option; import java.io.Serializable; + import javax.persistence.Id; + +import org.springframework.data.redis.core.RedisHash; + +import com.gg.server.domain.match.type.Option; + import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; -import org.springframework.data.redis.core.RedisHash; @Getter @RedisHash("matchUser") @NoArgsConstructor(access = AccessLevel.PROTECTED) public class RedisMatchUser implements Serializable { - @Id - private Long userId; - private Integer ppp; - private Option option; + @Id + private Long userId; + private Integer ppp; + private Option option; - public RedisMatchUser(Long userId, Integer ppp, Option option) { - this.userId = userId; - this.ppp = ppp; - this.option = option; - } + public RedisMatchUser(Long userId, Integer ppp, Option option) { + this.userId = userId; + this.ppp = ppp; + this.option = option; + } } diff --git a/src/main/java/com/gg/server/domain/match/data/RedisMatchUserRepository.java b/src/main/java/com/gg/server/domain/match/data/RedisMatchUserRepository.java index 198bcd39d..511012a23 100644 --- a/src/main/java/com/gg/server/domain/match/data/RedisMatchUserRepository.java +++ b/src/main/java/com/gg/server/domain/match/data/RedisMatchUserRepository.java @@ -1,55 +1,60 @@ package com.gg.server.domain.match.data; -import com.gg.server.domain.match.exception.PastSlotException; -import com.gg.server.domain.match.type.MatchKey; -import com.gg.server.domain.match.type.Option; import java.time.Duration; import java.time.LocalDateTime; import java.util.Optional; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import lombok.RequiredArgsConstructor; + import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; +import com.gg.server.domain.match.exception.PastSlotException; +import com.gg.server.domain.match.type.MatchKey; +import com.gg.server.domain.match.type.Option; + +import lombok.RequiredArgsConstructor; + @Repository @RequiredArgsConstructor public class RedisMatchUserRepository { - private final RedisTemplate redisTemplate; - - /** - * key : userId : startTime - * value : startTime - * slot의 startTime 각각의 만료기한 설정 - * **/ - public void addMatchTime(Long userId, LocalDateTime startTime, Option option) { - Duration duration = Duration.between(LocalDateTime.now(), startTime); - if (duration.isNegative()) { - throw new PastSlotException(); - } - redisTemplate.opsForValue().set(MatchKey.getUserTime(userId, startTime), - new RedisMatchTime(startTime, option), duration.getSeconds(), TimeUnit.SECONDS); - - } - public void deleteMatchUser(Long userId) { - Set keys = redisTemplate.keys(MatchKey.getUser(userId) + "*"); - keys.stream().forEach(key -> redisTemplate.delete(key)); - } - - public void deleteMatchTime(Long userId, LocalDateTime startTime) { - redisTemplate.delete(MatchKey.getUserTime(userId, startTime)); - } - public int countMatchTime(Long userId) { - return redisTemplate.keys(MatchKey.getUser(userId) + "*").size(); - } - - public Set getAllMatchTime(Long userId){ - Set keys = redisTemplate.keys(MatchKey.getUser(userId) + "*"); - return keys.stream().map(key -> redisTemplate.opsForValue().get(key)).collect(Collectors.toSet()); - } - - public Optional getUserTime(Long userId, LocalDateTime startTime) { - return Optional.ofNullable(redisTemplate.opsForValue().get(MatchKey.getUserTime(userId, startTime))); - } + private final RedisTemplate redisTemplate; + + /** + * key : userId : startTime + * value : startTime + * slot의 startTime 각각의 만료기한 설정 + * **/ + public void addMatchTime(Long userId, LocalDateTime startTime, Option option) { + Duration duration = Duration.between(LocalDateTime.now(), startTime); + if (duration.isNegative()) { + throw new PastSlotException(); + } + redisTemplate.opsForValue().set(MatchKey.getUserTime(userId, startTime), + new RedisMatchTime(startTime, option), duration.getSeconds(), TimeUnit.SECONDS); + + } + + public void deleteMatchUser(Long userId) { + Set keys = redisTemplate.keys(MatchKey.getUser(userId) + "*"); + keys.stream().forEach(key -> redisTemplate.delete(key)); + } + + public void deleteMatchTime(Long userId, LocalDateTime startTime) { + redisTemplate.delete(MatchKey.getUserTime(userId, startTime)); + } + + public int countMatchTime(Long userId) { + return redisTemplate.keys(MatchKey.getUser(userId) + "*").size(); + } + + public Set getAllMatchTime(Long userId) { + Set keys = redisTemplate.keys(MatchKey.getUser(userId) + "*"); + return keys.stream().map(key -> redisTemplate.opsForValue().get(key)).collect(Collectors.toSet()); + } + + public Optional getUserTime(Long userId, LocalDateTime startTime) { + return Optional.ofNullable(redisTemplate.opsForValue().get(MatchKey.getUserTime(userId, startTime))); + } } diff --git a/src/main/java/com/gg/server/domain/match/dto/GameAddDto.java b/src/main/java/com/gg/server/domain/match/dto/GameAddDto.java index 1b49f0054..1b1d6921f 100644 --- a/src/main/java/com/gg/server/domain/match/dto/GameAddDto.java +++ b/src/main/java/com/gg/server/domain/match/dto/GameAddDto.java @@ -1,31 +1,32 @@ package com.gg.server.domain.match.dto; +import java.time.LocalDateTime; +import java.util.List; + import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.match.data.RedisMatchUser; import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.user.dto.UserDto; -import java.time.LocalDateTime; -import java.util.List; + import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @Getter -@NoArgsConstructor (access = AccessLevel.PROTECTED) +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class GameAddDto { - private LocalDateTime startTime; - private Season season; - private Long playerId; - private Long enemyId; - private Mode mode; + private LocalDateTime startTime; + private Season season; + private Long playerId; + private Long enemyId; + private Mode mode; - public GameAddDto(LocalDateTime startTime, Season season, RedisMatchUser player, - RedisMatchUser enemy) { - this.startTime = startTime; - this.season = season; - this.playerId = player.getUserId(); - this.enemyId = enemy.getUserId(); - this.mode = Mode.ofPlayers(List.of(player, enemy), season.getPppGap()); - } + public GameAddDto(LocalDateTime startTime, Season season, RedisMatchUser player, + RedisMatchUser enemy) { + this.startTime = startTime; + this.season = season; + this.playerId = player.getUserId(); + this.enemyId = enemy.getUserId(); + this.mode = Mode.ofPlayers(List.of(player, enemy), season.getPppGap()); + } } diff --git a/src/main/java/com/gg/server/domain/match/dto/MatchRequestDto.java b/src/main/java/com/gg/server/domain/match/dto/MatchRequestDto.java index 6ccf4a96c..0207507cb 100644 --- a/src/main/java/com/gg/server/domain/match/dto/MatchRequestDto.java +++ b/src/main/java/com/gg/server/domain/match/dto/MatchRequestDto.java @@ -1,27 +1,30 @@ package com.gg.server.domain.match.dto; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.gg.server.domain.match.type.Option; import java.time.LocalDateTime; + import javax.validation.constraints.NotNull; + +import org.springframework.format.annotation.DateTimeFormat; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.gg.server.domain.match.type.Option; + import lombok.AccessLevel; -import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import org.springframework.format.annotation.DateTimeFormat; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) public class MatchRequestDto { - @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm") - private LocalDateTime startTime; - @NotNull - @JsonProperty("mode") - private Option option; + @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm") + private LocalDateTime startTime; + @NotNull + @JsonProperty("mode") + private Option option; - public MatchRequestDto(LocalDateTime startTime, Option option) { - this.startTime = startTime; - this.option = option; - } + public MatchRequestDto(LocalDateTime startTime, Option option) { + this.startTime = startTime; + this.option = option; + } } diff --git a/src/main/java/com/gg/server/domain/match/dto/MatchStatusDto.java b/src/main/java/com/gg/server/domain/match/dto/MatchStatusDto.java index d5fd38774..5a423fce7 100644 --- a/src/main/java/com/gg/server/domain/match/dto/MatchStatusDto.java +++ b/src/main/java/com/gg/server/domain/match/dto/MatchStatusDto.java @@ -1,59 +1,61 @@ -package com.gg.server.domain.match.dto; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.match.data.RedisMatchTime; -import com.gg.server.domain.slotmanagement.SlotManagement; - -import java.time.LocalDateTime; -import java.util.List; - -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class MatchStatusDto { - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm", timezone = "Asia/Seoul") - private LocalDateTime startTime; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm", timezone = "Asia/Seoul") - private LocalDateTime endTime; - private Boolean isMatched; - private Boolean isImminent; - private List myTeam; - private List enemyTeam; - - public MatchStatusDto(Game game, String userIntraId, String enemyIntraId, SlotManagement slotManagement) { - this.startTime = game.getStartTime(); - this.endTime = game.getEndTime(); - this.isMatched = true; - this.isImminent = game.getStartTime().minusMinutes(slotManagement.getOpenMinute()) - .isBefore(LocalDateTime.now()); - if (game.getMode() == Mode.TOURNAMENT) isImminent = true; - this.myTeam = List.of(userIntraId); - this.enemyTeam = List.of(enemyIntraId); - - } - - public MatchStatusDto(RedisMatchTime redisMatchTime, Integer interval) { - this.startTime = redisMatchTime.getStartTime(); - this.endTime = redisMatchTime.getStartTime().plusMinutes(interval); - this.isMatched = false; - this.isImminent = false; - this.myTeam = List.of(); - this.enemyTeam = List.of(); - } - - @Override - public String toString() { - return "CurrentMatchResponseDto{" + - "startTime=" + startTime + - "endTIme=" + endTime + - ", myTeam=" + myTeam + - ", enemyTeam=" + enemyTeam + - ", isMatched=" + isMatched + - '}'; - } -} +package com.gg.server.domain.match.dto; + +import java.time.LocalDateTime; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.match.data.RedisMatchTime; +import com.gg.server.domain.slotmanagement.SlotManagement; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class MatchStatusDto { + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm", timezone = "Asia/Seoul") + private LocalDateTime startTime; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm", timezone = "Asia/Seoul") + private LocalDateTime endTime; + private Boolean isMatched; + private Boolean isImminent; + private List myTeam; + private List enemyTeam; + + public MatchStatusDto(Game game, String userIntraId, String enemyIntraId, SlotManagement slotManagement) { + this.startTime = game.getStartTime(); + this.endTime = game.getEndTime(); + this.isMatched = true; + this.isImminent = game.getStartTime().minusMinutes(slotManagement.getOpenMinute()) + .isBefore(LocalDateTime.now()); + if (game.getMode() == Mode.TOURNAMENT) { + isImminent = true; + } + this.myTeam = List.of(userIntraId); + this.enemyTeam = List.of(enemyIntraId); + + } + + public MatchStatusDto(RedisMatchTime redisMatchTime, Integer interval) { + this.startTime = redisMatchTime.getStartTime(); + this.endTime = redisMatchTime.getStartTime().plusMinutes(interval); + this.isMatched = false; + this.isImminent = false; + this.myTeam = List.of(); + this.enemyTeam = List.of(); + } + + @Override + public String toString() { + return "CurrentMatchResponseDto{" + + "startTime=" + startTime + + "endTIme=" + endTime + + ", myTeam=" + myTeam + + ", enemyTeam=" + enemyTeam + + ", isMatched=" + isMatched + + '}'; + } +} diff --git a/src/main/java/com/gg/server/domain/match/dto/MatchStatusResponseListDto.java b/src/main/java/com/gg/server/domain/match/dto/MatchStatusResponseListDto.java index d7e149071..3249e2269 100644 --- a/src/main/java/com/gg/server/domain/match/dto/MatchStatusResponseListDto.java +++ b/src/main/java/com/gg/server/domain/match/dto/MatchStatusResponseListDto.java @@ -1,24 +1,24 @@ package com.gg.server.domain.match.dto; import java.util.List; + import lombok.AccessLevel; -import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter public class MatchStatusResponseListDto { - private List match; + private List match; - @Override - public String toString() { - return "MatchStatusResponseListDto{" + - "match=" + match + - '}'; - } + @Override + public String toString() { + return "MatchStatusResponseListDto{" + + "match=" + match + + '}'; + } - public MatchStatusResponseListDto(List match) { - this.match = match; - } + public MatchStatusResponseListDto(List match) { + this.match = match; + } } diff --git a/src/main/java/com/gg/server/domain/match/dto/SlotStatusDto.java b/src/main/java/com/gg/server/domain/match/dto/SlotStatusDto.java index 01e42d247..52af02224 100644 --- a/src/main/java/com/gg/server/domain/match/dto/SlotStatusDto.java +++ b/src/main/java/com/gg/server/domain/match/dto/SlotStatusDto.java @@ -1,8 +1,10 @@ package com.gg.server.domain.match.dto; +import java.time.LocalDateTime; + import com.fasterxml.jackson.annotation.JsonFormat; import com.gg.server.domain.match.type.SlotStatus; -import java.time.LocalDateTime; + import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -10,30 +12,30 @@ @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) public class SlotStatusDto { - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm", timezone = "Asia/Seoul") - private LocalDateTime startTime; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm", timezone = "Asia/Seoul") - private LocalDateTime endTime; - private String status; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm", timezone = "Asia/Seoul") + private LocalDateTime startTime; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm", timezone = "Asia/Seoul") + private LocalDateTime endTime; + private String status; - public SlotStatusDto(LocalDateTime startTime, LocalDateTime endTime, SlotStatus status) { - this.startTime = startTime; - this.endTime = endTime; - this.status = status.getCode(); - } + public SlotStatusDto(LocalDateTime startTime, LocalDateTime endTime, SlotStatus status) { + this.startTime = startTime; + this.endTime = endTime; + this.status = status.getCode(); + } - public SlotStatusDto(LocalDateTime startTime, SlotStatus status, Integer interval) { - this.startTime = startTime; - this.endTime = startTime.plusMinutes(interval); - this.status = status.getCode(); - } + public SlotStatusDto(LocalDateTime startTime, SlotStatus status, Integer interval) { + this.startTime = startTime; + this.endTime = startTime.plusMinutes(interval); + this.status = status.getCode(); + } - @Override - public String toString() { - return "SlotStatusDto{" + - "startTime = " + startTime + - "endTime = " + endTime + - "status = " + status + - "}"; - } + @Override + public String toString() { + return "SlotStatusDto{" + + "startTime = " + startTime + + "endTime = " + endTime + + "status = " + status + + "}"; + } } diff --git a/src/main/java/com/gg/server/domain/match/dto/SlotStatusResponseListDto.java b/src/main/java/com/gg/server/domain/match/dto/SlotStatusResponseListDto.java index e315c4736..f489825d4 100644 --- a/src/main/java/com/gg/server/domain/match/dto/SlotStatusResponseListDto.java +++ b/src/main/java/com/gg/server/domain/match/dto/SlotStatusResponseListDto.java @@ -1,25 +1,24 @@ package com.gg.server.domain.match.dto; import java.util.List; + import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) public class SlotStatusResponseListDto { - private List> matchBoards; + private List> matchBoards; - @Override - public String toString() { - return "MatchStatusResponseListDto{" + - "matchBoards=" + matchBoards + - '}'; - } + @Override + public String toString() { + return "MatchStatusResponseListDto{" + + "matchBoards=" + matchBoards + + '}'; + } - public SlotStatusResponseListDto(List> matchBoards) { - this.matchBoards = matchBoards; - } + public SlotStatusResponseListDto(List> matchBoards) { + this.matchBoards = matchBoards; + } } diff --git a/src/main/java/com/gg/server/domain/match/exception/EnrolledSlotException.java b/src/main/java/com/gg/server/domain/match/exception/EnrolledSlotException.java index 630dec02e..0374ffa1f 100644 --- a/src/main/java/com/gg/server/domain/match/exception/EnrolledSlotException.java +++ b/src/main/java/com/gg/server/domain/match/exception/EnrolledSlotException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.DuplicationException; public class EnrolledSlotException extends DuplicationException { - public EnrolledSlotException() { - super("이미 등록된 슬롯입니다.", ErrorCode.SLOT_ENROLLED); - } + public EnrolledSlotException() { + super("이미 등록된 슬롯입니다.", ErrorCode.SLOT_ENROLLED); + } } diff --git a/src/main/java/com/gg/server/domain/match/exception/LosingTeamNotFoundException.java b/src/main/java/com/gg/server/domain/match/exception/LosingTeamNotFoundException.java index c751aab43..f42fc21e3 100644 --- a/src/main/java/com/gg/server/domain/match/exception/LosingTeamNotFoundException.java +++ b/src/main/java/com/gg/server/domain/match/exception/LosingTeamNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class LosingTeamNotFoundException extends NotExistException { - public LosingTeamNotFoundException() { - super(ErrorCode.LOSING_TEAM_NOT_FOUND.getMessage(), ErrorCode.LOSING_TEAM_NOT_FOUND); - } + public LosingTeamNotFoundException() { + super(ErrorCode.LOSING_TEAM_NOT_FOUND.getMessage(), ErrorCode.LOSING_TEAM_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/match/exception/OptionInvalidException.java b/src/main/java/com/gg/server/domain/match/exception/OptionInvalidException.java index a55b9ae83..7405cf513 100644 --- a/src/main/java/com/gg/server/domain/match/exception/OptionInvalidException.java +++ b/src/main/java/com/gg/server/domain/match/exception/OptionInvalidException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.InvalidParameterException; public class OptionInvalidException extends InvalidParameterException { - public OptionInvalidException() { - super("존재하지 않은 mode 입니다", ErrorCode.MODE_INVALID); - } + public OptionInvalidException() { + super("존재하지 않은 mode 입니다", ErrorCode.MODE_INVALID); + } } diff --git a/src/main/java/com/gg/server/domain/match/exception/PastSlotException.java b/src/main/java/com/gg/server/domain/match/exception/PastSlotException.java index 256e289f8..b495d92f6 100644 --- a/src/main/java/com/gg/server/domain/match/exception/PastSlotException.java +++ b/src/main/java/com/gg/server/domain/match/exception/PastSlotException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.ExpiredException; public class PastSlotException extends ExpiredException { - public PastSlotException() { - super("현재 시각 이전 슬롯은 등록할 수 없습니다.", ErrorCode.SLOT_PAST); - } + public PastSlotException() { + super("현재 시각 이전 슬롯은 등록할 수 없습니다.", ErrorCode.SLOT_PAST); + } } diff --git a/src/main/java/com/gg/server/domain/match/exception/PenaltyUserSlotException.java b/src/main/java/com/gg/server/domain/match/exception/PenaltyUserSlotException.java index 6f024302f..65467eadf 100644 --- a/src/main/java/com/gg/server/domain/match/exception/PenaltyUserSlotException.java +++ b/src/main/java/com/gg/server/domain/match/exception/PenaltyUserSlotException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.BusinessException; public class PenaltyUserSlotException extends BusinessException { - public PenaltyUserSlotException() { - super("패널티 받은 유저는 게임을 등록할 수 없습니다.", ErrorCode.PENALTY_USER_ENROLLED); - } + public PenaltyUserSlotException() { + super("패널티 받은 유저는 게임을 등록할 수 없습니다.", ErrorCode.PENALTY_USER_ENROLLED); + } } diff --git a/src/main/java/com/gg/server/domain/match/exception/SlotCountException.java b/src/main/java/com/gg/server/domain/match/exception/SlotCountException.java index ec13b9825..b8c7758b8 100644 --- a/src/main/java/com/gg/server/domain/match/exception/SlotCountException.java +++ b/src/main/java/com/gg/server/domain/match/exception/SlotCountException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.BusinessException; public class SlotCountException extends BusinessException { - public SlotCountException() { - super("슬롯 등록 횟수 3회를 초과했습니다.", ErrorCode.SLOT_COUNT_EXCEEDED); - } + public SlotCountException() { + super("슬롯 등록 횟수 3회를 초과했습니다.", ErrorCode.SLOT_COUNT_EXCEEDED); + } } diff --git a/src/main/java/com/gg/server/domain/match/exception/SlotNotFoundException.java b/src/main/java/com/gg/server/domain/match/exception/SlotNotFoundException.java index e54043199..e881e3929 100644 --- a/src/main/java/com/gg/server/domain/match/exception/SlotNotFoundException.java +++ b/src/main/java/com/gg/server/domain/match/exception/SlotNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class SlotNotFoundException extends NotExistException { - public SlotNotFoundException() { - super("유저가 등록한 슬롯이 없습니다.", ErrorCode.SLOT_NOT_FOUND); - } + public SlotNotFoundException() { + super("유저가 등록한 슬롯이 없습니다.", ErrorCode.SLOT_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/match/exception/WinningTeamNotFoundException.java b/src/main/java/com/gg/server/domain/match/exception/WinningTeamNotFoundException.java index 4b296b88f..e5d2da068 100644 --- a/src/main/java/com/gg/server/domain/match/exception/WinningTeamNotFoundException.java +++ b/src/main/java/com/gg/server/domain/match/exception/WinningTeamNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class WinningTeamNotFoundException extends NotExistException { - public WinningTeamNotFoundException() { - super(ErrorCode.WINNING_TEAM_NOT_FOUND.getMessage(), ErrorCode.WINNING_TEAM_NOT_FOUND); - } + public WinningTeamNotFoundException() { + super(ErrorCode.WINNING_TEAM_NOT_FOUND.getMessage(), ErrorCode.WINNING_TEAM_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/match/service/GameUpdateService.java b/src/main/java/com/gg/server/domain/match/service/GameUpdateService.java index 2876bae0b..66142ac21 100644 --- a/src/main/java/com/gg/server/domain/match/service/GameUpdateService.java +++ b/src/main/java/com/gg/server/domain/match/service/GameUpdateService.java @@ -1,5 +1,10 @@ package com.gg.server.domain.match.service; +import java.time.LocalDateTime; +import java.util.List; + +import org.springframework.stereotype.Service; + import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.match.dto.GameAddDto; @@ -17,62 +22,60 @@ import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; -import java.time.LocalDateTime; -import java.util.List; + import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class GameUpdateService { - private final GameRepository gameRepository; - private final TeamRepository teamRepository; - private final UserRepository userRepository; - private final TeamUserRepository teamUserRepository; - private final SlotManagementRepository slotManagementRepository; - private final NotiService notiService; - private final SnsNotiService snsNotiService; + private final GameRepository gameRepository; + private final TeamRepository teamRepository; + private final UserRepository userRepository; + private final TeamUserRepository teamUserRepository; + private final SlotManagementRepository slotManagementRepository; + private final NotiService notiService; + private final SnsNotiService snsNotiService; - /** - * 게임 생성 메서드 - * 1) 게임 취소했을 경우, 2) 게임 매칭됐을 경우, 3) 토너먼트 게임 생성 - * @param addDto 게임 생성에 필요한 정보 - * @param recoveredUserId 게임 취소 당한 유저의 id, -1이면 무의미함 - */ - public void make(GameAddDto addDto, Long recoveredUserId) { - SlotManagement slotManagement = slotManagementRepository.findCurrent(LocalDateTime.now()) - .orElseThrow(SlotNotFoundException::new); - Game game = new Game(addDto, slotManagement.getGameInterval()); - gameRepository.save(game); - Team enemyTeam = new Team(game, -1, false); - Team myTeam = new Team(game, -1, false); - List matchPair = List.of(enemyTeam, myTeam); - teamRepository.saveAll(matchPair); - User playerUser = userRepository.findById(addDto.getPlayerId()).orElseThrow(UserNotFoundException::new); - User enemyUser = userRepository.findById(addDto.getEnemyId()).orElseThrow(UserNotFoundException::new); - TeamUser myTeamUser = new TeamUser(myTeam, playerUser); - TeamUser enemyTeamUser = new TeamUser(enemyTeam, enemyUser); - List matchTeamUser = List.of(enemyTeamUser, myTeamUser); - teamUserRepository.saveAll(matchTeamUser); - if (!playerUser.getId().equals(recoveredUserId)) { - Noti playerNoti = notiService.createMatched(playerUser, addDto.getStartTime()); - snsNotiService.sendSnsNotification(playerNoti, UserDto.from(playerUser)); - } - if (!enemyUser.getId().equals(recoveredUserId)) { - Noti enemyNoti = notiService.createMatched(enemyUser, addDto.getStartTime()); - snsNotiService.sendSnsNotification(enemyNoti, UserDto.from(enemyUser)); - } - } + /** + * 게임 생성 메서드 + * 1) 게임 취소했을 경우, 2) 게임 매칭됐을 경우, 3) 토너먼트 게임 생성 + * @param addDto 게임 생성에 필요한 정보 + * @param recoveredUserId 게임 취소 당한 유저의 id, -1이면 무의미함 + */ + public void make(GameAddDto addDto, Long recoveredUserId) { + SlotManagement slotManagement = slotManagementRepository.findCurrent(LocalDateTime.now()) + .orElseThrow(SlotNotFoundException::new); + Game game = new Game(addDto, slotManagement.getGameInterval()); + gameRepository.save(game); + Team enemyTeam = new Team(game, -1, false); + Team myTeam = new Team(game, -1, false); + List matchPair = List.of(enemyTeam, myTeam); + teamRepository.saveAll(matchPair); + User playerUser = userRepository.findById(addDto.getPlayerId()).orElseThrow(UserNotFoundException::new); + User enemyUser = userRepository.findById(addDto.getEnemyId()).orElseThrow(UserNotFoundException::new); + TeamUser myTeamUser = new TeamUser(myTeam, playerUser); + TeamUser enemyTeamUser = new TeamUser(enemyTeam, enemyUser); + List matchTeamUser = List.of(enemyTeamUser, myTeamUser); + teamUserRepository.saveAll(matchTeamUser); + if (!playerUser.getId().equals(recoveredUserId)) { + Noti playerNoti = notiService.createMatched(playerUser, addDto.getStartTime()); + snsNotiService.sendSnsNotification(playerNoti, UserDto.from(playerUser)); + } + if (!enemyUser.getId().equals(recoveredUserId)) { + Noti enemyNoti = notiService.createMatched(enemyUser, addDto.getStartTime()); + snsNotiService.sendSnsNotification(enemyNoti, UserDto.from(enemyUser)); + } + } - public void delete(Game game, List enemyTeam) { - enemyTeam.forEach(enemy -> { - Noti noti = notiService.createMatchCancel(enemy, game.getStartTime()); - snsNotiService.sendSnsNotification(noti, UserDto.from(enemy)); - }); - gameRepository.delete(game); - } + public void delete(Game game, List enemyTeam) { + enemyTeam.forEach(enemy -> { + Noti noti = notiService.createMatchCancel(enemy, game.getStartTime()); + snsNotiService.sendSnsNotification(noti, UserDto.from(enemy)); + }); + gameRepository.delete(game); + } - public void delete(Game game) { - gameRepository.delete(game); - } + public void delete(Game game) { + gameRepository.delete(game); + } } diff --git a/src/main/java/com/gg/server/domain/match/service/MatchFindService.java b/src/main/java/com/gg/server/domain/match/service/MatchFindService.java index 3a8bddf2f..7cd274edc 100644 --- a/src/main/java/com/gg/server/domain/match/service/MatchFindService.java +++ b/src/main/java/com/gg/server/domain/match/service/MatchFindService.java @@ -1,5 +1,15 @@ package com.gg.server.domain.match.service; +import java.time.LocalDateTime; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.type.StatusType; @@ -23,109 +33,102 @@ import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.type.TournamentStatus; import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.type.RoleType; -import java.time.LocalDateTime; -import java.util.Comparator; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; + import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor public class MatchFindService { - private final SlotManagementRepository slotManagementRepository; - private final GameRepository gameRepository; - private final UserRepository userRepository; - private final RedisMatchUserRepository redisMatchUserRepository; - private final SeasonFindService seasonFindService; - private final RankRedisRepository rankRedisRepository; - private final RedisMatchTimeRepository redisMatchTimeRepository; - private final TierRepository tierRepository; + private final SlotManagementRepository slotManagementRepository; + private final GameRepository gameRepository; + private final UserRepository userRepository; + private final RedisMatchUserRepository redisMatchUserRepository; + private final SeasonFindService seasonFindService; + private final RankRedisRepository rankRedisRepository; + private final RedisMatchTimeRepository redisMatchTimeRepository; + private final TierRepository tierRepository; + @Transactional(readOnly = true) + public MatchStatusResponseListDto getCurrentMatch(UserDto userDto) { + SlotManagement slotManagement = slotManagementRepository.findCurrent(LocalDateTime.now()) + .orElseThrow(SlotNotFoundException::new); + Optional myGame = gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, userDto.getId()); + if (myGame.isPresent()) { + List enemyTeam = userRepository.findEnemyByGameAndUser(myGame.get().getId(), userDto.getId()); + return new MatchStatusResponseListDto(List.of(new MatchStatusDto( + myGame.get(), userDto.getIntraId(), enemyTeam.get(0).getIntraId(), slotManagement + ))); + } + Set enrolledSlots = redisMatchUserRepository.getAllMatchTime(userDto.getId()); + List dtos = enrolledSlots.stream() + .map(e -> new MatchStatusDto(e, slotManagement.getGameInterval())) + .sorted(Comparator.comparing(MatchStatusDto::getStartTime)) + .collect(Collectors.toList()); + return new MatchStatusResponseListDto(dtos); + } - @Transactional(readOnly = true) - public MatchStatusResponseListDto getCurrentMatch(UserDto userDto) { - SlotManagement slotManagement = slotManagementRepository.findCurrent(LocalDateTime.now()) - .orElseThrow(SlotNotFoundException::new); - Optional myGame = gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, userDto.getId()); - if (myGame.isPresent()) { - List enemyTeam = userRepository.findEnemyByGameAndUser(myGame.get().getId(), userDto.getId()); - return new MatchStatusResponseListDto(List.of(new MatchStatusDto( - myGame.get(), userDto.getIntraId(), enemyTeam.get(0).getIntraId(), slotManagement - ))); - } - Set enrolledSlots = redisMatchUserRepository.getAllMatchTime(userDto.getId()); - List dtos = enrolledSlots.stream() - .map(e -> new MatchStatusDto(e, slotManagement.getGameInterval())) - .sorted(Comparator.comparing(MatchStatusDto::getStartTime)) - .collect(Collectors.toList()); - return new MatchStatusResponseListDto(dtos); - } + @Transactional(readOnly = true) + public SlotStatusResponseListDto getAllMatchStatus(UserDto userDto, Option option) { + SlotManagement slotManagement = slotManagementRepository.findCurrent(LocalDateTime.now()) + .orElseThrow(SlotNotFoundException::new); + Season season = seasonFindService.findCurrentSeason(LocalDateTime.now()); + Tier tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); + RankRedis user; + if (userDto.getRoleType().equals(RoleType.GUEST)) { + user = RankRedis.from(userDto, season.getStartPpp(), tier.getImageUri()); + } else { + user = rankRedisRepository + .findRankByUserId(RedisKeyManager.getHashKey(season.getId()), userDto.getId()); + } + SlotGenerator slotGenerator = new SlotGenerator(user, slotManagement, season, option); + List games = gameRepository.findAllBetween(slotGenerator.getNow(), slotGenerator.getMaxTime()); + slotGenerator.addPastSlots(); + slotGenerator.addMatchedSlots(games); - @Transactional(readOnly = true) - public SlotStatusResponseListDto getAllMatchStatus(UserDto userDto, Option option) { - SlotManagement slotManagement = slotManagementRepository.findCurrent(LocalDateTime.now()) - .orElseThrow(SlotNotFoundException::new); - Season season = seasonFindService.findCurrentSeason(LocalDateTime.now()); - Tier tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); - RankRedis user; - if (userDto.getRoleType().equals(RoleType.GUEST)) { - user = RankRedis.from(userDto, season.getStartPpp(), tier.getImageUri()); - } else { - user = rankRedisRepository. - findRankByUserId(RedisKeyManager.getHashKey(season.getId()), userDto.getId()); - } - SlotGenerator slotGenerator = new SlotGenerator(user, slotManagement, season, option); - List games = gameRepository.findAllBetween(slotGenerator.getNow(), slotGenerator.getMaxTime()); - slotGenerator.addPastSlots(); - slotGenerator.addMatchedSlots(games); + Optional myGame = gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, userDto.getId()); + Set gameTimes = games.stream().map(Game::getStartTime).collect(Collectors.toSet()); + if (myGame.isPresent()) { + groupEnrolledSlots(slotGenerator, myGame.get(), gameTimes); + } else { + groupEnrolledSlots(slotGenerator, gameTimes); + } + return slotGenerator.getResponseListDto(); + } - Optional myGame = gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, userDto.getId()); - Set gameTimes = games.stream().map(Game::getStartTime).collect(Collectors.toSet()); - if (myGame.isPresent()) { - groupEnrolledSlots(slotGenerator, myGame.get(), gameTimes); - } else { - groupEnrolledSlots(slotGenerator, gameTimes); - } - return slotGenerator.getResponseListDto(); - } + private void groupEnrolledSlots(SlotGenerator slotGenerator, Game myGame, Set gameTimes) { + Set enrolledTimes = redisMatchTimeRepository.getAllEnrolledStartTimes(); + slotGenerator.addMySlots(myGame); + Set notMyEnrolledTimes = enrolledTimes.stream() + .filter(e -> !e.equals(myGame.getStartTime()) && !gameTimes.contains(e)) + .collect(Collectors.toSet()); + notMyEnrolledTimes.stream() + .forEach( + time -> { + List allMatchUsers = redisMatchTimeRepository.getAllMatchUsers(time); + slotGenerator.groupEnrolledSlot(time, allMatchUsers); + } + ); + } - private void groupEnrolledSlots(SlotGenerator slotGenerator, Game myGame, Set gameTimes) { - Set enrolledTimes = redisMatchTimeRepository.getAllEnrolledStartTimes(); - slotGenerator.addMySlots(myGame); - Set notMyEnrolledTimes = enrolledTimes.stream() - .filter(e -> !e.equals(myGame.getStartTime()) && !gameTimes.contains(e)) - .collect(Collectors.toSet()); - notMyEnrolledTimes.stream().forEach(time -> { - List allMatchUsers = redisMatchTimeRepository.getAllMatchUsers(time); - slotGenerator.groupEnrolledSlot(time, allMatchUsers); - } - ); - } - private void groupEnrolledSlots(SlotGenerator slotGenerator, Set gameTimes) { - Set enrolledTimes = redisMatchTimeRepository.getAllEnrolledStartTimes(); - Set allMatchTime = redisMatchUserRepository.getAllMatchTime(slotGenerator.getMatchUser().getUserId()); - slotGenerator.addMySlots(allMatchTime); - Set times = allMatchTime.stream().map(RedisMatchTime::getStartTime) - .collect(Collectors.toSet()); - Set notMyEnrolledTimes = enrolledTimes.stream() - .filter(e -> !times.contains(e) && !gameTimes.contains(e)) - .collect(Collectors.toSet()); - notMyEnrolledTimes.stream().forEach( - time -> { - List allMatchUsers = redisMatchTimeRepository.getAllMatchUsers(time); - slotGenerator.groupEnrolledSlot(time, allMatchUsers); - } - ); - } + private void groupEnrolledSlots(SlotGenerator slotGenerator, Set gameTimes) { + Set enrolledTimes = redisMatchTimeRepository.getAllEnrolledStartTimes(); + Set allMatchTime = redisMatchUserRepository.getAllMatchTime( + slotGenerator.getMatchUser().getUserId()); + slotGenerator.addMySlots(allMatchTime); + Set times = allMatchTime.stream().map(RedisMatchTime::getStartTime) + .collect(Collectors.toSet()); + Set notMyEnrolledTimes = enrolledTimes.stream() + .filter(e -> !times.contains(e) && !gameTimes.contains(e)) + .collect(Collectors.toSet()); + notMyEnrolledTimes.stream().forEach( + time -> { + List allMatchUsers = redisMatchTimeRepository.getAllMatchUsers(time); + slotGenerator.groupEnrolledSlot(time, allMatchUsers); + } + ); + } } diff --git a/src/main/java/com/gg/server/domain/match/service/MatchService.java b/src/main/java/com/gg/server/domain/match/service/MatchService.java index 8734f66d5..6e87a1775 100644 --- a/src/main/java/com/gg/server/domain/match/service/MatchService.java +++ b/src/main/java/com/gg/server/domain/match/service/MatchService.java @@ -1,5 +1,14 @@ package com.gg.server.domain.match.service; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.exception.GameAlreadyExistException; @@ -33,196 +42,191 @@ import com.gg.server.domain.user.exception.UserNotFoundException; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.BusinessException; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; + import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor public class MatchService { - private final RedisMatchTimeRepository redisMatchTimeRepository; - private final RedisMatchUserRepository redisMatchUserRepository; - private final SeasonFindService seasonFindService; - private final RankRedisRepository rankRedisRepository; - private final GameRepository gameRepository; - private final PenaltyService penaltyService; - private final GameUpdateService gameUpdateService; - private final UserRepository userRepository; - private final TournamentRepository tournamentRepository; - private final SlotManagementRepository slotManagementRepository; + private final RedisMatchTimeRepository redisMatchTimeRepository; + private final RedisMatchUserRepository redisMatchUserRepository; + private final SeasonFindService seasonFindService; + private final RankRedisRepository rankRedisRepository; + private final GameRepository gameRepository; + private final PenaltyService penaltyService; + private final GameUpdateService gameUpdateService; + private final UserRepository userRepository; + private final TournamentRepository tournamentRepository; + private final SlotManagementRepository slotManagementRepository; - /** - * 1) 매칭 가능한 유저 있을 경우 : 게임 생성 - * 2) 매칭 가능한 유저 없을 경우 : 유저를 큐에 넣어줌 - */ - @Transactional - public synchronized void makeMatch(UserDto userDto, Option option, LocalDateTime startTime) { - checkValid(userDto, startTime); - Season season = seasonFindService.findCurrentSeason(startTime); - RankRedis rank = rankRedisRepository - .findRankByUserId(RedisKeyManager.getHashKey(season.getId()), userDto.getId()); - RedisMatchUser player = new RedisMatchUser(userDto.getId(), rank.getPpp(), option); - List allMatchUsers = redisMatchTimeRepository.getAllMatchUsers(startTime); - MatchCalculator matchCalculator = new MatchCalculator(season.getPppGap(), player); - Optional enemy = matchCalculator.findEnemy(allMatchUsers); - if (enemy.isPresent()) { - GameAddDto gameDto = new GameAddDto(startTime, season, player, enemy.get()); - gameUpdateService.make(gameDto, -1L); - redisMatchTimeRepository.addMatchUser(startTime, player); - cancelEnrolledSlots(List.of(enemy.get(), player), startTime); - } else { - addUserToQueue(startTime, player, option); - } - } + /** + * 1) 매칭 가능한 유저 있을 경우 : 게임 생성 + * 2) 매칭 가능한 유저 없을 경우 : 유저를 큐에 넣어줌 + */ + @Transactional + public synchronized void makeMatch(UserDto userDto, Option option, LocalDateTime startTime) { + checkValid(userDto, startTime); + Season season = seasonFindService.findCurrentSeason(startTime); + RankRedis rank = rankRedisRepository + .findRankByUserId(RedisKeyManager.getHashKey(season.getId()), userDto.getId()); + RedisMatchUser player = new RedisMatchUser(userDto.getId(), rank.getPpp(), option); + List allMatchUsers = redisMatchTimeRepository.getAllMatchUsers(startTime); + MatchCalculator matchCalculator = new MatchCalculator(season.getPppGap(), player); + Optional enemy = matchCalculator.findEnemy(allMatchUsers); + if (enemy.isPresent()) { + GameAddDto gameDto = new GameAddDto(startTime, season, player, enemy.get()); + gameUpdateService.make(gameDto, -1L); + redisMatchTimeRepository.addMatchUser(startTime, player); + cancelEnrolledSlots(List.of(enemy.get(), player), startTime); + } else { + addUserToQueue(startTime, player, option); + } + } - /** - * 1) 매칭되어 게임 생성된 후 : 게임 삭제하고 알림 전송, 취소한 유저 패널티 부과 - * 복귀 유저는 매칭 가능한 상대 존재하면 다시 매칭해주고 아니면 취소 알림 보내고 큐에 등록 시킴 - * 2) 매칭 전 : 큐에서 유저 삭제 - * game 매칭된 user 이외에 다른 user가 취소할 경우, 에러 발생 - */ - @Transactional - public synchronized void cancelMatch(UserDto userDto, LocalDateTime startTime) { - Optional game = gameRepository.findByStartTime(startTime); - if (game.isPresent()) { - List enemyTeam = userRepository.findEnemyByGameAndUser(game.get().getId(), userDto.getId()); - if (enemyTeam.size() > 1) { - throw new SlotNotFoundException(); - } - if (game.get().getMode().equals(Mode.TOURNAMENT)) { - throw new BusinessException(ErrorCode.TOURNAMENT_GAME_CAN_NOT_CANCELED); - } - cancelGame(userDto, startTime, game.get(), enemyTeam); - } else { - deleteUserFromQueue(userDto, startTime); - } - } + /** + * 1) 매칭되어 게임 생성된 후 : 게임 삭제하고 알림 전송, 취소한 유저 패널티 부과 + * 복귀 유저는 매칭 가능한 상대 존재하면 다시 매칭해주고 아니면 취소 알림 보내고 큐에 등록 시킴 + * 2) 매칭 전 : 큐에서 유저 삭제 + * game 매칭된 user 이외에 다른 user가 취소할 경우, 에러 발생 + */ + @Transactional + public synchronized void cancelMatch(UserDto userDto, LocalDateTime startTime) { + Optional game = gameRepository.findByStartTime(startTime); + if (game.isPresent()) { + List enemyTeam = userRepository.findEnemyByGameAndUser(game.get().getId(), userDto.getId()); + if (enemyTeam.size() > 1) { + throw new SlotNotFoundException(); + } + if (game.get().getMode().equals(Mode.TOURNAMENT)) { + throw new BusinessException(ErrorCode.TOURNAMENT_GAME_CAN_NOT_CANCELED); + } + cancelGame(userDto, startTime, game.get(), enemyTeam); + } else { + deleteUserFromQueue(userDto, startTime); + } + } - private void cancelGame(UserDto userDto, LocalDateTime startTime, Game game, List enemyTeam) { - /*취소한 유저 큐에서 삭제 후 패널티 부과*/ - Long recoveredUserId = enemyTeam.get(0).getId(); - List allMatchUsers = redisMatchTimeRepository.getAllMatchUsers(startTime); - RedisMatchUser penaltyUser = allMatchUsers.stream() - .filter(ele -> ele.getUserId().equals(userDto.getId())) - .findFirst() - .orElseThrow(UserNotFoundException::new); - RedisMatchUser recoveredUser = allMatchUsers.stream() - .filter(ele -> ele.getUserId().equals(recoveredUserId)) - .findFirst() - .orElseThrow(UserNotFoundException::new); - redisMatchTimeRepository.deleteMatchUser(startTime, penaltyUser); - penaltyService.givePenalty(userDto, 30); - /*취소 당한 유저 매칭 상대 찾고 있으면 다시 게임 생성 아니면 취소 알림*/ - Season season = seasonFindService.findCurrentSeason(startTime); - MatchCalculator matchCalculator = new MatchCalculator(season.getPppGap(), recoveredUser); - List targetPlayers = allMatchUsers.stream() - .filter(ele -> !ele.getUserId().equals(userDto.getId()) - && !ele.getUserId().equals(recoveredUserId)) - .collect(Collectors.toList()); - Optional enemy = matchCalculator.findEnemy(targetPlayers); - if (enemy.isPresent()) { - gameUpdateService.delete(game); - GameAddDto gameDto = new GameAddDto(startTime, season, recoveredUser, enemy.get()); - gameUpdateService.make(gameDto, recoveredUserId); - } else { - gameUpdateService.delete(game, enemyTeam); - redisMatchUserRepository.addMatchTime(recoveredUserId, startTime, recoveredUser.getOption()); - } - } + private void cancelGame(UserDto userDto, LocalDateTime startTime, Game game, List enemyTeam) { + /*취소한 유저 큐에서 삭제 후 패널티 부과*/ + Long recoveredUserId = enemyTeam.get(0).getId(); + List allMatchUsers = redisMatchTimeRepository.getAllMatchUsers(startTime); + RedisMatchUser penaltyUser = allMatchUsers.stream() + .filter(ele -> ele.getUserId().equals(userDto.getId())) + .findFirst() + .orElseThrow(UserNotFoundException::new); + RedisMatchUser recoveredUser = allMatchUsers.stream() + .filter(ele -> ele.getUserId().equals(recoveredUserId)) + .findFirst() + .orElseThrow(UserNotFoundException::new); + redisMatchTimeRepository.deleteMatchUser(startTime, penaltyUser); + penaltyService.givePenalty(userDto, 30); + /*취소 당한 유저 매칭 상대 찾고 있으면 다시 게임 생성 아니면 취소 알림*/ + Season season = seasonFindService.findCurrentSeason(startTime); + MatchCalculator matchCalculator = new MatchCalculator(season.getPppGap(), recoveredUser); + List targetPlayers = allMatchUsers.stream() + .filter(ele -> !ele.getUserId().equals(userDto.getId()) + && !ele.getUserId().equals(recoveredUserId)) + .collect(Collectors.toList()); + Optional enemy = matchCalculator.findEnemy(targetPlayers); + if (enemy.isPresent()) { + gameUpdateService.delete(game); + GameAddDto gameDto = new GameAddDto(startTime, season, recoveredUser, enemy.get()); + gameUpdateService.make(gameDto, recoveredUserId); + } else { + gameUpdateService.delete(game, enemyTeam); + redisMatchUserRepository.addMatchTime(recoveredUserId, startTime, recoveredUser.getOption()); + } + } - /** - * 매칭 요청 시 유효성 검사 - * @param userDto 매칭 요청한 유저 - * @param startTime 매칭 요청 시간 - * @throws PenaltyUserSlotException 패널티 유저일 경우 - * @throws TournamentConflictException 토너먼트가 존재할 경우 - * @throws GameAlreadyExistException 게임이 이미 존재할 경우 - * @throws EnrolledSlotException 매칭된 게임이 이미 있을 경우 || 유저 이미 큐에 등록할 경우 - * @throws SlotCountException 4번 이상 매치 넣을 경우 - * - */ - private void checkValid(UserDto userDto, LocalDateTime startTime) { - if (penaltyService.isPenaltyUser(userDto.getIntraId())) { - throw new PenaltyUserSlotException(); - } - if (isExistTournamentNotEnded(startTime)) { - throw new TournamentConflictException(); - } - if (gameRepository.findByStartTime(startTime).isPresent()) { - throw new GameAlreadyExistException(); - } - if (gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, userDto.getId()).isPresent()) { - throw new EnrolledSlotException(); - } - //유저 이미 큐에 등록 시 예외 처리 - if (redisMatchUserRepository.getUserTime(userDto.getId(), startTime).isPresent()) { - throw new EnrolledSlotException(); - } - //4번 이상 매치 넣을 시 예외 처리 - if (redisMatchUserRepository.countMatchTime(userDto.getId()) >= 3) { - throw new SlotCountException(); - } - } + /** + * 매칭 요청 시 유효성 검사 + * @param userDto 매칭 요청한 유저 + * @param startTime 매칭 요청 시간 + * @throws PenaltyUserSlotException 패널티 유저일 경우 + * @throws TournamentConflictException 토너먼트가 존재할 경우 + * @throws GameAlreadyExistException 게임이 이미 존재할 경우 + * @throws EnrolledSlotException 매칭된 게임이 이미 있을 경우 || 유저 이미 큐에 등록할 경우 + * @throws SlotCountException 4번 이상 매치 넣을 경우 + * + */ + private void checkValid(UserDto userDto, LocalDateTime startTime) { + if (penaltyService.isPenaltyUser(userDto.getIntraId())) { + throw new PenaltyUserSlotException(); + } + if (isExistTournamentNotEnded(startTime)) { + throw new TournamentConflictException(); + } + if (gameRepository.findByStartTime(startTime).isPresent()) { + throw new GameAlreadyExistException(); + } + if (gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, userDto.getId()).isPresent()) { + throw new EnrolledSlotException(); + } + //유저 이미 큐에 등록 시 예외 처리 + if (redisMatchUserRepository.getUserTime(userDto.getId(), startTime).isPresent()) { + throw new EnrolledSlotException(); + } + //4번 이상 매치 넣을 시 예외 처리 + if (redisMatchUserRepository.countMatchTime(userDto.getId()) >= 3) { + throw new SlotCountException(); + } + } - private void addUserToQueue(LocalDateTime startTime, RedisMatchUser matchUser, Option option) { - redisMatchTimeRepository.addMatchUser(startTime, matchUser); - redisMatchTimeRepository.setMatchTimeWithExpiry(startTime); - redisMatchUserRepository.addMatchTime(matchUser.getUserId(), startTime, option); - } + private void addUserToQueue(LocalDateTime startTime, RedisMatchUser matchUser, Option option) { + redisMatchTimeRepository.addMatchUser(startTime, matchUser); + redisMatchTimeRepository.setMatchTimeWithExpiry(startTime); + redisMatchUserRepository.addMatchTime(matchUser.getUserId(), startTime, option); + } - private void cancelEnrolledSlots(List players, LocalDateTime targetTIme) { - for (RedisMatchUser player : players) { - Set matchTimes = redisMatchUserRepository - .getAllMatchTime(player.getUserId()) - .stream() - .filter(ele -> !ele.getStartTime().equals(targetTIme)) - .collect(Collectors.toSet()); - matchTimes.forEach(ele -> redisMatchTimeRepository.deleteMatchUser(ele.getStartTime(), player)); - redisMatchUserRepository.deleteMatchUser(player.getUserId()); - } - } + private void cancelEnrolledSlots(List players, LocalDateTime targetTIme) { + for (RedisMatchUser player : players) { + Set matchTimes = redisMatchUserRepository + .getAllMatchTime(player.getUserId()) + .stream() + .filter( + ele -> !ele.getStartTime().equals(targetTIme)) + .collect(Collectors.toSet()); + matchTimes.forEach(ele -> redisMatchTimeRepository.deleteMatchUser(ele.getStartTime(), player)); + redisMatchUserRepository.deleteMatchUser(player.getUserId()); + } + } - private void deleteUserFromQueue(UserDto userDto, LocalDateTime startTime) { - if (redisMatchUserRepository.getUserTime(userDto.getId(), startTime).isEmpty()) { - throw new SlotNotFoundException(); - } - redisMatchUserRepository.deleteMatchTime(userDto.getId(), startTime); - List allMatchUsers = redisMatchTimeRepository.getAllMatchUsers(startTime); - for (RedisMatchUser matchUser : allMatchUsers) { - if (matchUser.getUserId().equals(userDto.getId())) { - redisMatchTimeRepository.deleteMatchUser(startTime, matchUser); - break; - } - } - } + private void deleteUserFromQueue(UserDto userDto, LocalDateTime startTime) { + if (redisMatchUserRepository.getUserTime(userDto.getId(), startTime).isEmpty()) { + throw new SlotNotFoundException(); + } + redisMatchUserRepository.deleteMatchTime(userDto.getId(), startTime); + List allMatchUsers = redisMatchTimeRepository.getAllMatchUsers(startTime); + for (RedisMatchUser matchUser : allMatchUsers) { + if (matchUser.getUserId().equals(userDto.getId())) { + redisMatchTimeRepository.deleteMatchUser(startTime, matchUser); + break; + } + } + } - /** - * LIVE, BEFORE 상태인 토너먼트와 진행 시간이 겹치지 않으면 true, 겹치면 false - * @param startTime 현재 시간 - * @return 종료되지 않은 토너먼트 있으면 true, 없으면 false - * @throws SlotNotFoundException 현재 시간에 해당하는 슬롯이 없을 경우 - */ - private boolean isExistTournamentNotEnded(LocalDateTime startTime) { - List tournamentList = tournamentRepository.findAllByStatusIsNot(TournamentStatus.END); - int gameInterval = slotManagementRepository.findCurrent(startTime) - .orElseThrow(SlotNotFoundException::new) - .getGameInterval(); - LocalDateTime endTime = startTime.plusMinutes(gameInterval); - for (Tournament tournament : tournamentList) { - if (startTime.isAfter(tournament.getStartTime()) && startTime.isBefore(tournament.getEndTime()) || - endTime.isAfter(tournament.getStartTime()) && endTime.isBefore(tournament.getEndTime())) { - return true; - } - if (startTime.isEqual(tournament.getStartTime()) || endTime.isEqual(tournament.getEndTime()) || - endTime.isEqual(tournament.getStartTime()) || startTime.isEqual(tournament.getEndTime())) { - return true; - } - } - return false; - } + /** + * LIVE, BEFORE 상태인 토너먼트와 진행 시간이 겹치지 않으면 true, 겹치면 false + * @param startTime 현재 시간 + * @return 종료되지 않은 토너먼트 있으면 true, 없으면 false + * @throws SlotNotFoundException 현재 시간에 해당하는 슬롯이 없을 경우 + */ + private boolean isExistTournamentNotEnded(LocalDateTime startTime) { + List tournamentList = tournamentRepository.findAllByStatusIsNot(TournamentStatus.END); + int gameInterval = slotManagementRepository.findCurrent(startTime) + .orElseThrow(SlotNotFoundException::new) + .getGameInterval(); + LocalDateTime endTime = startTime.plusMinutes(gameInterval); + for (Tournament tournament : tournamentList) { + if (startTime.isAfter(tournament.getStartTime()) && startTime.isBefore(tournament.getEndTime()) + || endTime.isAfter(tournament.getStartTime()) && endTime.isBefore(tournament.getEndTime())) { + return true; + } + if (startTime.isEqual(tournament.getStartTime()) || endTime.isEqual(tournament.getEndTime()) + || endTime.isEqual(tournament.getStartTime()) || startTime.isEqual(tournament.getEndTime())) { + return true; + } + } + return false; + } } diff --git a/src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java b/src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java index 376b7fc4a..77d19d20c 100644 --- a/src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java +++ b/src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java @@ -1,5 +1,20 @@ package com.gg.server.domain.match.service; +import static com.gg.server.domain.match.type.TournamentMatchStatus.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.stream.Collectors; + +import javax.transaction.Transactional; + +import org.springframework.stereotype.Service; + import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; import com.gg.server.admin.noti.service.NotiAdminService; import com.gg.server.domain.game.data.Game; @@ -8,6 +23,7 @@ import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.match.exception.EnrolledSlotException; import com.gg.server.domain.match.exception.LosingTeamNotFoundException; +import com.gg.server.domain.match.exception.SlotNotFoundException; import com.gg.server.domain.match.exception.WinningTeamNotFoundException; import com.gg.server.domain.match.type.TournamentMatchStatus; import com.gg.server.domain.noti.type.NotiType; @@ -25,242 +41,240 @@ import com.gg.server.domain.tournament.type.TournamentRound; import com.gg.server.domain.tournament.type.TournamentStatus; import com.gg.server.domain.user.data.User; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -import com.gg.server.domain.match.exception.SlotNotFoundException; - -import javax.transaction.Transactional; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - -import static com.gg.server.domain.match.type.TournamentMatchStatus.*; +import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class MatchTournamentService { - private final TournamentGameRepository tournamentGameRepository; - private final GameRepository gameRepository; - private final SlotManagementRepository slotManagementRepository; - private final SeasonFindService seasonFindService; - private final NotiAdminService notiAdminService; + private final TournamentGameRepository tournamentGameRepository; + private final GameRepository gameRepository; + private final SlotManagementRepository slotManagementRepository; + private final SeasonFindService seasonFindService; + private final NotiAdminService notiAdminService; - /** - * 토너먼트 진행중 다음 라운드 게임 매칭이 필요한지 확인 - *

결승전 점수 입력 후 토너먼트 END 상태로 업데이트

- * @param game 토너먼트 게임 - * @return TournamentMatchStatus - 매칭 가능 여부 - * @throws TournamentGameNotFoundException 토너먼트 게임이 존재하지 않을 경우 - */ - @Transactional - public TournamentMatchStatus checkTournamentGame(Game game) { - TournamentGame tournamentGame = tournamentGameRepository.findByGameId(game.getId()) - .orElseThrow(TournamentGameNotFoundException::new); + /** + * 토너먼트 진행중 다음 라운드 게임 매칭이 필요한지 확인 + *

결승전 점수 입력 후 토너먼트 END 상태로 업데이트

+ * @param game 토너먼트 게임 + * @return TournamentMatchStatus - 매칭 가능 여부 + * @throws TournamentGameNotFoundException 토너먼트 게임이 존재하지 않을 경우 + */ + @Transactional + public TournamentMatchStatus checkTournamentGame(Game game) { + TournamentGame tournamentGame = tournamentGameRepository.findByGameId(game.getId()) + .orElseThrow(TournamentGameNotFoundException::new); - // 토너먼트 결승전 게임일 경우, 토너먼트 상태 END로 변경 - if (TournamentRound.THE_FINAL.equals(tournamentGame.getTournamentRound())) { - closeTournament(tournamentGame.getTournament(), game); - return IMPOSSIBLE; - } + // 토너먼트 결승전 게임일 경우, 토너먼트 상태 END로 변경 + if (TournamentRound.THE_FINAL.equals(tournamentGame.getTournamentRound())) { + closeTournament(tournamentGame.getTournament(), game); + return IMPOSSIBLE; + } - // 같은 round의 모든 게임이 END인 경우, 다음 round의 토너먼트 게임 매칭 가능 - TournamentRound round = tournamentGame.getTournamentRound(); - List tournamentGames = tournamentGameRepository.findAllByTournamentId(tournamentGame.getTournament().getId()); - List sameRoundGames = tournamentGames.stream() - .filter(tg -> tg.getTournamentRound().getRoundNumber() == round.getRoundNumber()) - .collect(Collectors.toList()); - for (TournamentGame tg : sameRoundGames) { - if (!StatusType.END.equals(tg.getGame().getStatus())) { - return IMPOSSIBLE; - } - } - if (isAlreadyExistMatchedGame(tournamentGame.getTournament(), round.getNextRound())) { - return ALREADY_MATCHED; - } - return POSSIBLE; - } + // 같은 round의 모든 게임이 END인 경우, 다음 round의 토너먼트 게임 매칭 가능 + TournamentRound round = tournamentGame.getTournamentRound(); + List tournamentGames = tournamentGameRepository.findAllByTournamentId( + tournamentGame.getTournament().getId()); + List sameRoundGames = tournamentGames.stream() + .filter(tg -> tg.getTournamentRound().getRoundNumber() == round.getRoundNumber()) + .collect(Collectors.toList()); + for (TournamentGame tg : sameRoundGames) { + if (!StatusType.END.equals(tg.getGame().getStatus())) { + return IMPOSSIBLE; + } + } + if (isAlreadyExistMatchedGame(tournamentGame.getTournament(), round.getNextRound())) { + return ALREADY_MATCHED; + } + return POSSIBLE; + } - /** - * 토너먼트 게임 매칭 - * @param tournament 토너먼트 - * @param round 새로 매칭할 토너먼트 라운드 - * @throws EnrolledSlotException 이미 매칭된 게임이 존재할 경우 - * @throws SlotNotFoundException 슬롯이 존재하지 않을 경우 - */ - @Transactional - public void matchGames(Tournament tournament, TournamentRound round) { - if (isAlreadyExistMatchedGame(tournament, round)) { - throw new EnrolledSlotException(); - } - Season season = seasonFindService.findCurrentSeason(tournament.getStartTime()); - SlotManagement slotManagement = slotManagementRepository.findCurrent(tournament.getStartTime()) - .orElseThrow(SlotNotFoundException::new); - int gameInterval = slotManagement.getGameInterval(); - List allTournamentGames = tournamentGameRepository.findAllByTournamentId(tournament.getId()); - List tournamentGames = findSameRoundGames(allTournamentGames, round.getRoundNumber()); - List players = findSortedPlayers(tournament, round); - LocalDateTime startTime = calculateStartTime(tournament, round, gameInterval); + /** + * 토너먼트 게임 매칭 + * @param tournament 토너먼트 + * @param round 새로 매칭할 토너먼트 라운드 + * @throws EnrolledSlotException 이미 매칭된 게임이 존재할 경우 + * @throws SlotNotFoundException 슬롯이 존재하지 않을 경우 + */ + @Transactional + public void matchGames(Tournament tournament, TournamentRound round) { + if (isAlreadyExistMatchedGame(tournament, round)) { + throw new EnrolledSlotException(); + } + Season season = seasonFindService.findCurrentSeason(tournament.getStartTime()); + SlotManagement slotManagement = slotManagementRepository.findCurrent(tournament.getStartTime()) + .orElseThrow(SlotNotFoundException::new); + int gameInterval = slotManagement.getGameInterval(); + List allTournamentGames = tournamentGameRepository.findAllByTournamentId(tournament.getId()); + List tournamentGames = findSameRoundGames(allTournamentGames, round.getRoundNumber()); + List players = findSortedPlayers(tournament, round); + LocalDateTime startTime = calculateStartTime(tournament, round, gameInterval); - for (int i = 0; i < tournamentGames.size(); ++i) { - Game game = new Game(season, StatusType.BEFORE, Mode.TOURNAMENT, startTime, startTime.plusMinutes(gameInterval)); - Team team1 = new Team(game, -1, false); - Team team2 = new Team(game, -1, false); - User user1 = players.get(i * 2); - User user2 = players.get(i * 2 + 1); - new TeamUser(team1, user1); - new TeamUser(team2, user2); - gameRepository.save(game); - tournamentGames.get(i).updateGame(game); - startTime = startTime.plusMinutes((long) gameInterval); - } - players.stream().distinct() - .forEach(user -> notiAdminService.sendAnnounceNotiToUser(new SendNotiAdminRequestDto(user.getIntraId(), NotiType.TOURNAMENT_GAME_MATCHED.getMessage()))); - } + for (int i = 0; i < tournamentGames.size(); ++i) { + Game game = new Game(season, StatusType.BEFORE, Mode.TOURNAMENT, startTime, + startTime.plusMinutes(gameInterval)); + Team team1 = new Team(game, -1, false); + Team team2 = new Team(game, -1, false); + User user1 = players.get(i * 2); + User user2 = players.get(i * 2 + 1); + new TeamUser(team1, user1); + new TeamUser(team2, user2); + gameRepository.save(game); + tournamentGames.get(i).updateGame(game); + startTime = startTime.plusMinutes((long)gameInterval); + } + players.stream().distinct() + .forEach(user -> notiAdminService.sendAnnounceNotiToUser( + new SendNotiAdminRequestDto(user.getIntraId(), NotiType.TOURNAMENT_GAME_MATCHED.getMessage()))); + } - /** - * 토너먼트 게임의 승자를 토너먼트 다음 라운드의 게임 플레이어로 업데이트 - * @param modifiedGame 경기 결과가 수정된 토너먼트 게임 - * @param nextMatchedGame 수정된 우승자로 수정할 다음 게임 - * @throws WinningTeamNotFoundException 우승팀이 존재하지 않을 경우 - */ - @Transactional - public void updateMatchedGameUser(Game modifiedGame, Game nextMatchedGame) { - User winner = getWinningTeam(modifiedGame).getTeamUsers().get(0).getUser(); - User loser = getLosingTeam(modifiedGame).getTeamUsers().get(0).getUser(); - List players = modifiedGame.getTeams().stream() - .map(team -> team.getTeamUsers().get(0).getUser()) - .collect(Collectors.toList()); - List nextMatchedGameTeamUsers = nextMatchedGame.getTeams().stream() - .map(team -> team.getTeamUsers().get(0)) - .collect(Collectors.toList()); - for (TeamUser nextGameTeamUser : nextMatchedGameTeamUsers) { - if (players.contains(nextGameTeamUser.getUser())) { - nextGameTeamUser.updateUser(winner); - break; - } - } - notiAdminService.sendAnnounceNotiToUser(new SendNotiAdminRequestDto(winner.getIntraId(), NotiType.TOURNAMENT_GAME_MATCHED.getMessage())); - notiAdminService.sendAnnounceNotiToUser(new SendNotiAdminRequestDto(loser.getIntraId(), NotiType.TOURNAMENT_GAME_CANCELED.getMessage())); - } + /** + * 토너먼트 게임의 승자를 토너먼트 다음 라운드의 게임 플레이어로 업데이트 + * @param modifiedGame 경기 결과가 수정된 토너먼트 게임 + * @param nextMatchedGame 수정된 우승자로 수정할 다음 게임 + * @throws WinningTeamNotFoundException 우승팀이 존재하지 않을 경우 + */ + @Transactional + public void updateMatchedGameUser(Game modifiedGame, Game nextMatchedGame) { + User winner = getWinningTeam(modifiedGame).getTeamUsers().get(0).getUser(); + User loser = getLosingTeam(modifiedGame).getTeamUsers().get(0).getUser(); + List players = modifiedGame.getTeams().stream() + .map(team -> team.getTeamUsers().get(0).getUser()) + .collect(Collectors.toList()); + List nextMatchedGameTeamUsers = nextMatchedGame.getTeams().stream() + .map(team -> team.getTeamUsers().get(0)) + .collect(Collectors.toList()); + for (TeamUser nextGameTeamUser : nextMatchedGameTeamUsers) { + if (players.contains(nextGameTeamUser.getUser())) { + nextGameTeamUser.updateUser(winner); + break; + } + } + notiAdminService.sendAnnounceNotiToUser( + new SendNotiAdminRequestDto(winner.getIntraId(), NotiType.TOURNAMENT_GAME_MATCHED.getMessage())); + notiAdminService.sendAnnounceNotiToUser( + new SendNotiAdminRequestDto(loser.getIntraId(), NotiType.TOURNAMENT_GAME_CANCELED.getMessage())); + } - /** - * @param tournament 토너먼트 - * @param round 토너먼트 라운드 - * @param gameInterval 경기 간격 - * @return 마지막 경기 종료 시간 + interval - *

8강의 경우 토너먼트 시작 시간

- *

4강, 결승일 경우 이전 라운드의 마지막 경기 종료 시간 + 15분

- */ - private LocalDateTime calculateStartTime(Tournament tournament, TournamentRound round, int gameInterval) { - if (TournamentRound.QUARTER_FINAL_1.getRoundNumber() == round.getRoundNumber()) { - return tournament.getStartTime(); - } - List previousRoundTournamentGames = findSameRoundGames(tournament.getTournamentGames(), TournamentRound.getPreviousRoundNumber(round)); - TournamentGame lastGame = previousRoundTournamentGames.get(previousRoundTournamentGames.size() - 1); - return lastGame.getGame().getEndTime().plusMinutes(gameInterval); - } + /** + * @param tournament 토너먼트 + * @param round 토너먼트 라운드 + * @param gameInterval 경기 간격 + * @return 마지막 경기 종료 시간 + interval + *

8강의 경우 토너먼트 시작 시간

+ *

4강, 결승일 경우 이전 라운드의 마지막 경기 종료 시간 + 15분

+ */ + private LocalDateTime calculateStartTime(Tournament tournament, TournamentRound round, int gameInterval) { + if (TournamentRound.QUARTER_FINAL_1.getRoundNumber() == round.getRoundNumber()) { + return tournament.getStartTime(); + } + List previousRoundTournamentGames = findSameRoundGames(tournament.getTournamentGames(), + TournamentRound.getPreviousRoundNumber(round)); + TournamentGame lastGame = previousRoundTournamentGames.get(previousRoundTournamentGames.size() - 1); + return lastGame.getGame().getEndTime().plusMinutes(gameInterval); + } - /** - * 토너먼트 라운드에 매칭될 플레이어를 찾는다. - * @param tournament 토너먼트 - * @param round 매칭할 토너먼트 라운드 - * @return 토너먼트 라운드에 매칭될 플레이어 List (정렬된 상태) - */ - private List findSortedPlayers(Tournament tournament, TournamentRound round) { - List players = new ArrayList<>(); + /** + * 토너먼트 라운드에 매칭될 플레이어를 찾는다. + * @param tournament 토너먼트 + * @param round 매칭할 토너먼트 라운드 + * @return 토너먼트 라운드에 매칭될 플레이어 List (정렬된 상태) + */ + private List findSortedPlayers(Tournament tournament, TournamentRound round) { + List players = new ArrayList<>(); - if (TournamentRound.QUARTER_FINAL_1.getRoundNumber() == round.getRoundNumber()) { - Map randomNumbers = new LinkedHashMap<>(); - Random random = new Random(); - while (randomNumbers.size() < Tournament.ALLOWED_JOINED_NUMBER) { - int randomNumber = random.nextInt(Tournament.ALLOWED_JOINED_NUMBER); - if (!randomNumbers.containsValue(randomNumber)) { - randomNumbers.put(randomNumbers.size(), randomNumber); - } - } - for (Integer randomNumber : randomNumbers.values()) { - List tournamentUsers = tournament.getTournamentUsers(); - User user = tournamentUsers.get(randomNumber).getUser(); - players.add(user); - } - } else { - List previousRoundTournamentGames = findSameRoundGames(tournament.getTournamentGames(), TournamentRound.getPreviousRoundNumber(round)); - int roundNum = round.getRoundNumber(); - for (int i = 0; i < roundNum; ++i) { - User user = getWinningTeam(previousRoundTournamentGames.get(i).getGame()) - .getTeamUsers().get(0).getUser(); - players.add(user); - } - } - return players; - } + if (TournamentRound.QUARTER_FINAL_1.getRoundNumber() == round.getRoundNumber()) { + Map randomNumbers = new LinkedHashMap<>(); + Random random = new Random(); + while (randomNumbers.size() < Tournament.ALLOWED_JOINED_NUMBER) { + int randomNumber = random.nextInt(Tournament.ALLOWED_JOINED_NUMBER); + if (!randomNumbers.containsValue(randomNumber)) { + randomNumbers.put(randomNumbers.size(), randomNumber); + } + } + for (Integer randomNumber : randomNumbers.values()) { + List tournamentUsers = tournament.getTournamentUsers(); + User user = tournamentUsers.get(randomNumber).getUser(); + players.add(user); + } + } else { + List previousRoundTournamentGames = findSameRoundGames(tournament.getTournamentGames(), + TournamentRound.getPreviousRoundNumber(round)); + int roundNum = round.getRoundNumber(); + for (int i = 0; i < roundNum; ++i) { + User user = getWinningTeam(previousRoundTournamentGames.get(i).getGame()) + .getTeamUsers().get(0).getUser(); + players.add(user); + } + } + return players; + } - /** - * round에 매칭된 게임이 이미 존재하는지 확인 - * @param tournament 토너먼트 - * @param round 토너먼트 라운드 - * @return true - 매칭된 게임이 존재, false - 아직 매칭된 게임이 존재하지 않음 - * @throws TournamentGameNotFoundException 토너먼트 게임이 존재하지 않을 경우 - */ - private boolean isAlreadyExistMatchedGame(Tournament tournament, TournamentRound round) { - TournamentGame tournamentGame = tournamentGameRepository.findByTournamentIdAndTournamentRound(tournament.getId(), round) - .orElseThrow(TournamentGameNotFoundException::new); - return tournamentGame.getGame() != null; - } + /** + * round에 매칭된 게임이 이미 존재하는지 확인 + * @param tournament 토너먼트 + * @param round 토너먼트 라운드 + * @return true - 매칭된 게임이 존재, false - 아직 매칭된 게임이 존재하지 않음 + * @throws TournamentGameNotFoundException 토너먼트 게임이 존재하지 않을 경우 + */ + private boolean isAlreadyExistMatchedGame(Tournament tournament, TournamentRound round) { + TournamentGame tournamentGame = tournamentGameRepository.findByTournamentIdAndTournamentRound( + tournament.getId(), round) + .orElseThrow(TournamentGameNotFoundException::new); + return tournamentGame.getGame() != null; + } - /** - * 토너먼트 종료시키는 함수 - *

토너먼트 상태 END로 업데이트

- *

토너먼트 winner 업데이트

- * @param tournament 종료할 토너먼트 - * @param finalGame 토너먼트의 마지막 게임 - * @throws WinningTeamNotFoundException 우승팀이 존재하지 않을 경우 - */ - private void closeTournament(Tournament tournament, Game finalGame) { - User winner = getWinningTeam(finalGame) - .getTeamUsers().get(0).getUser(); - tournament.updateStatus(TournamentStatus.END); - tournament.updateEndTime(finalGame.getEndTime()); - tournament.updateWinner(winner); + /** + * 토너먼트 종료시키는 함수 + *

토너먼트 상태 END로 업데이트

+ *

토너먼트 winner 업데이트

+ * @param tournament 종료할 토너먼트 + * @param finalGame 토너먼트의 마지막 게임 + * @throws WinningTeamNotFoundException 우승팀이 존재하지 않을 경우 + */ + private void closeTournament(Tournament tournament, Game finalGame) { + User winner = getWinningTeam(finalGame) + .getTeamUsers().get(0).getUser(); + tournament.updateStatus(TournamentStatus.END); + tournament.updateEndTime(finalGame.getEndTime()); + tournament.updateWinner(winner); - } + } - /** - * 같은 round의 토너먼트 게임을 찾는다. - * @param tournamentGames 토너먼트 게임 List - * @param roundNum 토너먼트 라운드 number (2, 4, 8, ...) (잘못된 roundNum일 경우 Empty List 반환한다.) - * @return tournamentGames 중 roundNum과 동일한 roundNum을 가진 round 순으로 정렬된 tournamentGame List 반환 - */ - private List findSameRoundGames(List tournamentGames, int roundNum) { - return tournamentGames.stream() - .filter(tournamentGame -> roundNum == tournamentGame.getTournamentRound().getRoundNumber()) - .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) - .collect(Collectors.toList()); - } + /** + * 같은 round의 토너먼트 게임을 찾는다. + * @param tournamentGames 토너먼트 게임 List + * @param roundNum 토너먼트 라운드 number (2, 4, 8, ...) (잘못된 roundNum일 경우 Empty List 반환한다.) + * @return tournamentGames 중 roundNum과 동일한 roundNum을 가진 round 순으로 정렬된 tournamentGame List 반환 + */ + private List findSameRoundGames(List tournamentGames, int roundNum) { + return tournamentGames.stream() + .filter(tournamentGame -> roundNum == tournamentGame.getTournamentRound().getRoundNumber()) + .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) + .collect(Collectors.toList()); + } - /** - * game의 승자를 찾는다. - * @param game - * @return - */ - private Team getWinningTeam(Game game) { - return game.getTeams().stream() - .filter(team -> Boolean.TRUE.equals(team.getWin())) - .findAny() - .orElseThrow(WinningTeamNotFoundException::new); - } + /** + * game의 승자를 찾는다. + * @param game + * @return + */ + private Team getWinningTeam(Game game) { + return game.getTeams().stream() + .filter(team -> Boolean.TRUE.equals(team.getWin())) + .findAny() + .orElseThrow(WinningTeamNotFoundException::new); + } - /** - * game의 패자를 찾는다. - * @param game - * @return - */ - private Team getLosingTeam(Game game) { - return game.getTeams().stream() - .filter(team -> Boolean.FALSE.equals(team.getWin())) - .findAny() - .orElseThrow(LosingTeamNotFoundException::new); - } + /** + * game의 패자를 찾는다. + * @param game + * @return + */ + private Team getLosingTeam(Game game) { + return game.getTeams().stream() + .filter(team -> Boolean.FALSE.equals(team.getWin())) + .findAny() + .orElseThrow(LosingTeamNotFoundException::new); + } } diff --git a/src/main/java/com/gg/server/domain/match/type/MatchKey.java b/src/main/java/com/gg/server/domain/match/type/MatchKey.java index 95854d051..eb9899f9b 100644 --- a/src/main/java/com/gg/server/domain/match/type/MatchKey.java +++ b/src/main/java/com/gg/server/domain/match/type/MatchKey.java @@ -1,27 +1,28 @@ package com.gg.server.domain.match.type; import java.time.LocalDateTime; + import lombok.Getter; @Getter public class MatchKey { - public static final String USER = "MATCH:USER:"; - public static final String TIME = "MATCH:TIME:"; - private static final String conjunctive = ":"; + public static final String USER = "MATCH:USER:"; + public static final String TIME = "MATCH:TIME:"; + private static final String conjunctive = ":"; - public static String getUserTime(Long userId, LocalDateTime startTime) { - return USER + userId + conjunctive + startTime; - } + public static String getUserTime(Long userId, LocalDateTime startTime) { + return USER + userId + conjunctive + startTime; + } - public static String getUser(Long userId) { - return USER + userId; - } + public static String getUser(Long userId) { + return USER + userId; + } - public static String getTime(LocalDateTime startTime) { - return TIME + startTime; - } + public static String getTime(LocalDateTime startTime) { + return TIME + startTime; + } - public static String getAllTime() { - return TIME; - } + public static String getAllTime() { + return TIME; + } } diff --git a/src/main/java/com/gg/server/domain/match/type/Option.java b/src/main/java/com/gg/server/domain/match/type/Option.java index 567ffe1c6..c4afa31ea 100644 --- a/src/main/java/com/gg/server/domain/match/type/Option.java +++ b/src/main/java/com/gg/server/domain/match/type/Option.java @@ -1,35 +1,37 @@ package com.gg.server.domain.match.type; + +import java.util.Locale; + import com.fasterxml.jackson.annotation.JsonCreator; import com.gg.server.domain.match.exception.OptionInvalidException; -import java.util.Locale; + import lombok.Getter; import lombok.RequiredArgsConstructor; @Getter @RequiredArgsConstructor public enum Option { - //match에서는 Both를 써서 자료형 따로 만듬 - BOTH(0,"both"), - NORMAL(1,"normal"), - RANK(2,"rank"), - TOURNAMENT(3,"tournament"); - - // 모드는 4가지가 있음. - - private final Integer value; - private final String code; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static Option getEnumValue(String code) { - for(Option e : values()) { - if(e.code.equals(code)) { - return e; - } - else if (e.code.toUpperCase(Locale.ROOT).equals(code.toUpperCase(Locale.ROOT))) - return e; - } - throw new OptionInvalidException(); - } + //match에서는 Both를 써서 자료형 따로 만듬 + BOTH(0, "both"), + NORMAL(1, "normal"), + RANK(2, "rank"), + TOURNAMENT(3, "tournament"); + + // 모드는 4가지가 있음. + + private final Integer value; + private final String code; + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Option getEnumValue(String code) { + for (Option e : values()) { + if (e.code.equals(code)) { + return e; + } else if (e.code.toUpperCase(Locale.ROOT).equals(code.toUpperCase(Locale.ROOT))) { + return e; + } + } + throw new OptionInvalidException(); + } } diff --git a/src/main/java/com/gg/server/domain/match/type/SlotStatus.java b/src/main/java/com/gg/server/domain/match/type/SlotStatus.java index 7d168f548..4dce03a4f 100644 --- a/src/main/java/com/gg/server/domain/match/type/SlotStatus.java +++ b/src/main/java/com/gg/server/domain/match/type/SlotStatus.java @@ -1,28 +1,30 @@ package com.gg.server.domain.match.type; -import com.fasterxml.jackson.annotation.JsonCreator; import java.util.Locale; + +import com.fasterxml.jackson.annotation.JsonCreator; + import lombok.Getter; import lombok.RequiredArgsConstructor; @Getter @RequiredArgsConstructor public enum SlotStatus { - OPEN("open"), - CLOSE("close"), - MYTABLE("mytable"), - MATCH("match"); - private final String code; - @JsonCreator - public static SlotStatus getEnumFromValue(String value) { - for (SlotStatus e : values()) { - if(e.code.equals(value)) { - return e; - } - else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { - return e; - } - } - return null; - } + OPEN("open"), + CLOSE("close"), + MYTABLE("mytable"), + MATCH("match"); + private final String code; + + @JsonCreator + public static SlotStatus getEnumFromValue(String value) { + for (SlotStatus e : values()) { + if (e.code.equals(value)) { + return e; + } else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { + return e; + } + } + return null; + } } diff --git a/src/main/java/com/gg/server/domain/match/type/TournamentMatchStatus.java b/src/main/java/com/gg/server/domain/match/type/TournamentMatchStatus.java index 849d31d92..b2e5e29bd 100644 --- a/src/main/java/com/gg/server/domain/match/type/TournamentMatchStatus.java +++ b/src/main/java/com/gg/server/domain/match/type/TournamentMatchStatus.java @@ -1,20 +1,16 @@ package com.gg.server.domain.match.type; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.gg.server.domain.match.exception.OptionInvalidException; import lombok.Getter; import lombok.RequiredArgsConstructor; -import java.util.Locale; - @Getter @RequiredArgsConstructor public enum TournamentMatchStatus { - // 토너먼트 매치 상태 - IMPOSSIBLE(0, "매칭 불가능"), - POSSIBLE(1, "매칭 가능"), - ALREADY_MATCHED(2, "이미 매칭됨"); + // 토너먼트 매치 상태 + IMPOSSIBLE(0, "매칭 불가능"), + POSSIBLE(1, "매칭 가능"), + ALREADY_MATCHED(2, "이미 매칭됨"); - private final Integer value; - private final String code; + private final Integer value; + private final String code; } diff --git a/src/main/java/com/gg/server/domain/match/utils/MatchCalculator.java b/src/main/java/com/gg/server/domain/match/utils/MatchCalculator.java index 98da3f58b..8d9a08af8 100644 --- a/src/main/java/com/gg/server/domain/match/utils/MatchCalculator.java +++ b/src/main/java/com/gg/server/domain/match/utils/MatchCalculator.java @@ -1,92 +1,92 @@ package com.gg.server.domain.match.utils; +import java.util.List; +import java.util.Optional; + import com.gg.server.domain.match.data.RedisMatchUser; import com.gg.server.domain.match.type.Option; import com.gg.server.domain.match.type.SlotStatus; -import java.util.List; -import java.util.Optional; public class MatchCalculator { - private final Integer pppGap; - private final RedisMatchUser matchUser; - + private final Integer pppGap; + private final RedisMatchUser matchUser; - public MatchCalculator(Integer pppGap, RedisMatchUser matchUser) { - this.pppGap = pppGap; - this.matchUser = matchUser; - } + public MatchCalculator(Integer pppGap, RedisMatchUser matchUser) { + this.pppGap = pppGap; + this.matchUser = matchUser; + } - /**유저들이 입장할 때마다 Queue 매칭 검사 - * 마지막으로 입장한 유저랑 그전 유저들만 비교하면 된다. - * 마지막 입장 유저가 both : normal 입장 유저와 경기 가능한 rank 입장 유저 매칭 - * 마지막 입장 유저가 normal : normal user 탐색 - * 마지막 입장 유저가 rank : 경기 가능한 rank 입장 유저 매칭 - * 이때 탐색 우선 위는 먼저 들어온 사람부터**/ - public Optional findEnemy(List allMatchUsers) { - if (allMatchUsers.size() == 0) { - return Optional.empty(); - } - if (matchUser.getOption().equals(Option.NORMAL)) { - return allMatchUsers.stream() - .filter(player -> player.getOption().equals(Option.NORMAL) || - player.getOption().equals(Option.BOTH)) - .findFirst(); - } - if (matchUser.getOption().equals(Option.RANK)) { - return allMatchUsers.stream() - .filter(player -> (player.getOption().equals(Option.RANK) || - player.getOption().equals(Option.BOTH)) - && Math.abs(player.getPpp() - matchUser.getPpp()) <= pppGap) - .findFirst(); - } - return allMatchUsers.stream() - .filter(player -> player.getOption().equals(Option.NORMAL) || - player.getOption().equals(Option.BOTH) || - (player.getOption().equals(Option.RANK) && - Math.abs(player.getPpp() - matchUser.getPpp())<= pppGap)) - .findFirst(); - } + /**유저들이 입장할 때마다 Queue 매칭 검사 + * 마지막으로 입장한 유저랑 그전 유저들만 비교하면 된다. + * 마지막 입장 유저가 both : normal 입장 유저와 경기 가능한 rank 입장 유저 매칭 + * 마지막 입장 유저가 normal : normal user 탐색 + * 마지막 입장 유저가 rank : 경기 가능한 rank 입장 유저 매칭 + * 이때 탐색 우선 위는 먼저 들어온 사람부터**/ + public Optional findEnemy(List allMatchUsers) { + if (allMatchUsers.size() == 0) { + return Optional.empty(); + } + if (matchUser.getOption().equals(Option.NORMAL)) { + return allMatchUsers.stream() + .filter(player -> player.getOption().equals(Option.NORMAL) + || player.getOption().equals(Option.BOTH)) + .findFirst(); + } + if (matchUser.getOption().equals(Option.RANK)) { + return allMatchUsers.stream() + .filter(player -> (player.getOption().equals(Option.RANK) + || player.getOption().equals(Option.BOTH)) + && Math.abs(player.getPpp() - matchUser.getPpp()) <= pppGap) + .findFirst(); + } + return allMatchUsers.stream() + .filter(player -> player.getOption().equals(Option.NORMAL) + || player.getOption().equals(Option.BOTH) + || (player.getOption().equals(Option.RANK) + && Math.abs(player.getPpp() - matchUser.getPpp()) <= pppGap)) + .findFirst(); + } - /** - * - * @param allMatchUsers : 큐에 들어있는 플레이어들 - * @return 1) 매칭가능한 상대가 있는 경우: SlotStatus.MATCH - * 2) 매칭가능한 상대가 없는 경우: SlotStatus.OPEN - */ - public SlotStatus findEnemyStatus(List allMatchUsers) - { - if (matchUser.getOption().equals(Option.NORMAL)) { - return getNormalSlotStatus(allMatchUsers); - } - if (matchUser.getOption().equals(Option.RANK)) { - return getRankSlotStatus(allMatchUsers); - } - return getBothSlotStatus(allMatchUsers); - } + /** + * + * @param allMatchUsers : 큐에 들어있는 플레이어들 + * @return 1) 매칭가능한 상대가 있는 경우: SlotStatus.MATCH + * 2) 매칭가능한 상대가 없는 경우: SlotStatus.OPEN + */ + public SlotStatus findEnemyStatus(List allMatchUsers) { + if (matchUser.getOption().equals(Option.NORMAL)) { + return getNormalSlotStatus(allMatchUsers); + } + if (matchUser.getOption().equals(Option.RANK)) { + return getRankSlotStatus(allMatchUsers); + } + return getBothSlotStatus(allMatchUsers); + } - private SlotStatus getRankSlotStatus(List allMatchUsers) { - if (allMatchUsers.stream().anyMatch(e -> (e.getOption().equals(Option.RANK) - || e.getOption().equals(Option.BOTH)) && (e.getPpp() - matchUser.getPpp()) <= pppGap)) { - return SlotStatus.MATCH; - } - return SlotStatus.OPEN; - } + private SlotStatus getRankSlotStatus(List allMatchUsers) { + if (allMatchUsers.stream().anyMatch(e -> (e.getOption().equals(Option.RANK) + || e.getOption().equals(Option.BOTH)) && (e.getPpp() - matchUser.getPpp()) <= pppGap)) { + return SlotStatus.MATCH; + } + return SlotStatus.OPEN; + } - private SlotStatus getNormalSlotStatus(List allMatchUsers) { - if (allMatchUsers.stream().anyMatch(e -> e.getOption().equals(Option.NORMAL) || - e.getOption().equals(Option.BOTH))) { - return SlotStatus.MATCH; - } - return SlotStatus.OPEN; - } + private SlotStatus getNormalSlotStatus(List allMatchUsers) { + if (allMatchUsers.stream().anyMatch(e -> e.getOption().equals(Option.NORMAL) + || e.getOption().equals(Option.BOTH))) { + return SlotStatus.MATCH; + } + return SlotStatus.OPEN; + } - private SlotStatus getBothSlotStatus(List allMatchUsers) { - if (allMatchUsers.stream().anyMatch(e -> - e.getOption().equals(Option.NORMAL) || e.getOption().equals(Option.BOTH) - || (e.getOption().equals(Option.RANK) && - e.getPpp() - matchUser.getPpp() <= pppGap))) { - return SlotStatus.MATCH; - } - return SlotStatus.OPEN; - } + private SlotStatus getBothSlotStatus(List allMatchUsers) { + if (allMatchUsers.stream().anyMatch(e -> + e.getOption().equals(Option.NORMAL) + || e.getOption().equals(Option.BOTH) + || (e.getOption().equals(Option.RANK) + && e.getPpp() - matchUser.getPpp() <= pppGap))) { + return SlotStatus.MATCH; + } + return SlotStatus.OPEN; + } } diff --git a/src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java b/src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java index f9272111c..d1210791a 100644 --- a/src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java +++ b/src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java @@ -1,5 +1,11 @@ package com.gg.server.domain.match.utils; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Set; + import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.match.data.RedisMatchTime; @@ -11,107 +17,102 @@ import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.season.data.Season; import com.gg.server.domain.slotmanagement.SlotManagement; -import java.time.LocalDateTime; -import java.util.*; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.type.TournamentStatus; import lombok.Getter; - @Getter public class SlotGenerator { - /** - * minTime ~ maxTime : 슬롯이 보여지는 시간 범위 - * matchUser : 현재 유저 정보 - * matchCalculator : 매칭 관련 슬롯 상태 결정 - * option : 유저가 현재 선택한 mode(random, normal, both) - */ - private final HashMap slots; - private final Integer interval; - private final LocalDateTime minTime; - private final LocalDateTime now; - private final LocalDateTime maxTime; - private final RedisMatchUser matchUser; - private final MatchCalculator matchCalculator; - private final Option option; + /** + * minTime ~ maxTime : 슬롯이 보여지는 시간 범위 + * matchUser : 현재 유저 정보 + * matchCalculator : 매칭 관련 슬롯 상태 결정 + * option : 유저가 현재 선택한 mode(random, normal, both) + */ + private final HashMap slots; + private final Integer interval; + private final LocalDateTime minTime; + private final LocalDateTime now; + private final LocalDateTime maxTime; + private final RedisMatchUser matchUser; + private final MatchCalculator matchCalculator; + private final Option option; + + public SlotGenerator(RankRedis user, SlotManagement slotManagement, Season season, Option option) { + this.interval = slotManagement.getGameInterval(); + this.now = LocalDateTime.now(); + this.minTime = LocalDateTime.of( + now.getYear(), now.getMonth(), now.getDayOfMonth(), now.getHour(), 0) + .minusHours(slotManagement.getPastSlotTime()); + this.maxTime = setMaxTime(slotManagement); + this.option = option; + this.slots = new HashMap(); + this.matchUser = new RedisMatchUser(user.getUserId(), user.getPpp(), option); + this.matchCalculator = new MatchCalculator(season.getPppGap(), matchUser); + } - public SlotGenerator(RankRedis user, SlotManagement slotManagement, Season season, Option option) { - this.interval = slotManagement.getGameInterval(); - this.now = LocalDateTime.now(); - this.minTime = LocalDateTime.of( - now.getYear(), now.getMonth(), now.getDayOfMonth(), now.getHour(), 0) - .minusHours(slotManagement.getPastSlotTime()); - this.maxTime = setMaxTime(slotManagement); - this.option = option; - this.slots = new HashMap(); - this.matchUser = new RedisMatchUser(user.getUserId(), user.getPpp(), option); - this.matchCalculator = new MatchCalculator(season.getPppGap(), matchUser); - } + public void addPastSlots() { + for (LocalDateTime time = minTime; time.isBefore(now); time = time.plusMinutes(interval)) { + slots.put(time, new SlotStatusDto(time, SlotStatus.CLOSE, interval)); + } + } - public void addPastSlots() { - for (LocalDateTime time = minTime; time.isBefore(now); time = time.plusMinutes(interval)) { - slots.put(time, new SlotStatusDto(time, SlotStatus.CLOSE, interval)); - } - } + public void addMatchedSlots(List games) { + games.stream().forEach(e -> slots.put(e.getStartTime(), + new SlotStatusDto(e.getStartTime(), SlotStatus.CLOSE, interval))); + } - public void addMatchedSlots(List games) { - games.stream().forEach(e -> slots.put(e.getStartTime(), - new SlotStatusDto(e.getStartTime(), SlotStatus.CLOSE, interval))); - } + public void addMySlots(Game myGame) { + slots.put(myGame.getStartTime(), + new SlotStatusDto(myGame.getStartTime(), myGame.getEndTime(), + getMySlotStatus(myGame.getMode(), option))); + } - public void addMySlots(Game myGame) { - slots.put(myGame.getStartTime(), - new SlotStatusDto(myGame.getStartTime(), myGame.getEndTime(), - getMySlotStatus(myGame.getMode(), option))); - } - public void addMySlots(Set allMatchTime) { - allMatchTime.stream().forEach(match -> slots.put(match.getStartTime(), - new SlotStatusDto(match.getStartTime(), - getMySlotStatus(match.getOption(), option), interval))); - } + public void addMySlots(Set allMatchTime) { + allMatchTime.stream().forEach(match -> slots.put(match.getStartTime(), + new SlotStatusDto(match.getStartTime(), + getMySlotStatus(match.getOption(), option), interval))); + } - private SlotStatus getMySlotStatus(Option myOption, Option viewOption) { - if (myOption.equals(viewOption)) { - return SlotStatus.MYTABLE; - } - return SlotStatus.CLOSE; - } + private SlotStatus getMySlotStatus(Option myOption, Option viewOption) { + if (myOption.equals(viewOption)) { + return SlotStatus.MYTABLE; + } + return SlotStatus.CLOSE; + } - private SlotStatus getMySlotStatus(Mode myMode, Option viewOption) { - if (myMode.getCode().equals(viewOption.getCode())) { - return SlotStatus.MYTABLE; - } - return SlotStatus.CLOSE; - } + private SlotStatus getMySlotStatus(Mode myMode, Option viewOption) { + if (myMode.getCode().equals(viewOption.getCode())) { + return SlotStatus.MYTABLE; + } + return SlotStatus.CLOSE; + } - public void groupEnrolledSlot(LocalDateTime startTime, List players) { - slots.put(startTime, new SlotStatusDto(startTime, matchCalculator.findEnemyStatus(players), interval)); - } + public void groupEnrolledSlot(LocalDateTime startTime, List players) { + slots.put(startTime, new SlotStatusDto(startTime, matchCalculator.findEnemyStatus(players), interval)); + } - public SlotStatusResponseListDto getResponseListDto() { - long slotCountPerHour = 60 / interval; - List> matchBoards = new ArrayList>(); - for (LocalDateTime time = minTime ; time.isBefore(maxTime) ; time = time.plusHours(1)) { - List hourBoard = new ArrayList(); - for (long i = 0; i < slotCountPerHour; i++) { - SlotStatusDto dto = slots.getOrDefault(time.plusMinutes(i * interval), - new SlotStatusDto(time.plusMinutes(i * interval), SlotStatus.OPEN, interval)); - hourBoard.add(dto); - } - matchBoards.add(hourBoard); - } - return new SlotStatusResponseListDto(matchBoards); - } + public SlotStatusResponseListDto getResponseListDto() { + long slotCountPerHour = 60 / interval; + List> matchBoards = new ArrayList>(); + for (LocalDateTime time = minTime; time.isBefore(maxTime); time = time.plusHours(1)) { + List hourBoard = new ArrayList(); + for (long i = 0; i < slotCountPerHour; i++) { + SlotStatusDto dto = slots.getOrDefault(time.plusMinutes(i * interval), + new SlotStatusDto(time.plusMinutes(i * interval), SlotStatus.OPEN, interval)); + hourBoard.add(dto); + } + matchBoards.add(hourBoard); + } + return new SlotStatusResponseListDto(matchBoards); + } - private LocalDateTime setMaxTime(SlotManagement slotManagement) { - LocalDateTime compared = LocalDateTime.of( - now.getYear(), now.getMonth(), now.getDayOfMonth(), now.getHour(), 0) - .plusHours(slotManagement.getFutureSlotTime()); - if (slotManagement.getEndTime() != null && slotManagement.getEndTime().isBefore(compared)) { - return slotManagement.getEndTime(); - } - return compared; - } + private LocalDateTime setMaxTime(SlotManagement slotManagement) { + LocalDateTime compared = LocalDateTime.of( + now.getYear(), now.getMonth(), now.getDayOfMonth(), now.getHour(), 0) + .plusHours(slotManagement.getFutureSlotTime()); + if (slotManagement.getEndTime() != null && slotManagement.getEndTime().isBefore(compared)) { + return slotManagement.getEndTime(); + } + return compared; + } } diff --git a/src/main/java/com/gg/server/domain/megaphone/controller/MegaphoneController.java b/src/main/java/com/gg/server/domain/megaphone/controller/MegaphoneController.java index e088b9946..f1781c597 100644 --- a/src/main/java/com/gg/server/domain/megaphone/controller/MegaphoneController.java +++ b/src/main/java/com/gg/server/domain/megaphone/controller/MegaphoneController.java @@ -1,47 +1,58 @@ package com.gg.server.domain.megaphone.controller; +import java.util.List; + +import javax.validation.Valid; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import com.gg.server.domain.megaphone.dto.MegaphoneDetailResponseDto; import com.gg.server.domain.megaphone.dto.MegaphoneTodayListResponseDto; import com.gg.server.domain.megaphone.dto.MegaphoneUseRequestDto; import com.gg.server.domain.megaphone.service.MegaphoneService; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.utils.argumentresolver.Login; + import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.List; @RestController @RequiredArgsConstructor @RequestMapping("/pingpong/megaphones") public class MegaphoneController { - private final MegaphoneService megaphoneService; - - @PostMapping() - public ResponseEntity useMegaphone(@RequestBody @Valid MegaphoneUseRequestDto megaphoneUseRequestDto, - @Parameter(hidden = true) @Login UserDto user) { - megaphoneService.useMegaphone(megaphoneUseRequestDto, user); - return ResponseEntity.status(HttpStatus.CREATED).build(); - } - - @DeleteMapping("/{megaphoneId}") - public ResponseEntity deleteMegaphone(@PathVariable Long megaphoneId, - @Parameter(hidden = true) @Login UserDto user) { - megaphoneService.deleteMegaphone(megaphoneId, user); - return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); - } - - @GetMapping("/receipt/{receiptId}") - public ResponseEntity getMegaphoneDetail(@PathVariable Long receiptId, @Parameter(hidden = true) @Login UserDto user) { - return ResponseEntity.ok(megaphoneService.getMegaphoneDetail(receiptId, user)); - } - - @GetMapping() - public ResponseEntity> getMegaphoneTodayList(@Parameter(hidden = true) @Login UserDto user) { - return ResponseEntity.ok(megaphoneService.getMegaphoneTodayList()); - } + private final MegaphoneService megaphoneService; + + @PostMapping() + public ResponseEntity useMegaphone(@RequestBody @Valid MegaphoneUseRequestDto megaphoneUseRequestDto, + @Parameter(hidden = true) @Login UserDto user) { + megaphoneService.useMegaphone(megaphoneUseRequestDto, user); + return ResponseEntity.status(HttpStatus.CREATED).build(); + } + + @DeleteMapping("/{megaphoneId}") + public ResponseEntity deleteMegaphone(@PathVariable Long megaphoneId, + @Parameter(hidden = true) @Login UserDto user) { + megaphoneService.deleteMegaphone(megaphoneId, user); + return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); + } + + @GetMapping("/receipt/{receiptId}") + public ResponseEntity getMegaphoneDetail(@PathVariable Long receiptId, + @Parameter(hidden = true) @Login UserDto user) { + return ResponseEntity.ok(megaphoneService.getMegaphoneDetail(receiptId, user)); + } + + @GetMapping() + public ResponseEntity> getMegaphoneTodayList( + @Parameter(hidden = true) @Login UserDto user) { + return ResponseEntity.ok(megaphoneService.getMegaphoneTodayList()); + } } diff --git a/src/main/java/com/gg/server/domain/megaphone/data/Megaphone.java b/src/main/java/com/gg/server/domain/megaphone/data/Megaphone.java index a5715c44d..2ed2d0247 100644 --- a/src/main/java/com/gg/server/domain/megaphone/data/Megaphone.java +++ b/src/main/java/com/gg/server/domain/megaphone/data/Megaphone.java @@ -1,44 +1,53 @@ -package com.gg.server.domain.megaphone.data; - -import com.gg.server.domain.receipt.data.Receipt; -import com.gg.server.domain.user.data.User; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import javax.persistence.*; -import javax.validation.constraints.NotNull; -import java.time.LocalDate; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@Entity -public class Megaphone { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "receipt_id") - private Receipt receipt; - - @Column(name = "content", length = 30) - private String content; - - @NotNull - @Column(name = "used_at") - private LocalDate usedAt; - - public Megaphone(User user, Receipt receipt, String content, LocalDate usedAt) { - this.user = user; - this.receipt = receipt; - this.content = content; - this.usedAt = usedAt; - } -} +package com.gg.server.domain.megaphone.data; + +import java.time.LocalDate; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.validation.constraints.NotNull; + +import com.gg.server.domain.receipt.data.Receipt; +import com.gg.server.domain.user.data.User; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Entity +public class Megaphone { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "receipt_id") + private Receipt receipt; + + @Column(name = "content", length = 30) + private String content; + + @NotNull + @Column(name = "used_at") + private LocalDate usedAt; + + public Megaphone(User user, Receipt receipt, String content, LocalDate usedAt) { + this.user = user; + this.receipt = receipt; + this.content = content; + this.usedAt = usedAt; + } +} diff --git a/src/main/java/com/gg/server/domain/megaphone/data/MegaphoneRepository.java b/src/main/java/com/gg/server/domain/megaphone/data/MegaphoneRepository.java index 3c3f33087..39d42c843 100644 --- a/src/main/java/com/gg/server/domain/megaphone/data/MegaphoneRepository.java +++ b/src/main/java/com/gg/server/domain/megaphone/data/MegaphoneRepository.java @@ -1,17 +1,18 @@ package com.gg.server.domain.megaphone.data; -import com.gg.server.domain.receipt.data.Receipt; -import com.gg.server.domain.receipt.type.ItemStatus; -import org.springframework.data.jpa.repository.JpaRepository; - import java.time.LocalDate; import java.util.List; import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; + +import com.gg.server.domain.receipt.data.Receipt; +import com.gg.server.domain.receipt.type.ItemStatus; + public interface MegaphoneRepository extends JpaRepository { - List findAllByUsedAtAndReceiptStatus(LocalDate date, ItemStatus itemStatus); + List findAllByUsedAtAndReceiptStatus(LocalDate date, ItemStatus itemStatus); - Megaphone findFirstByOrderByIdDesc(); + Megaphone findFirstByOrderByIdDesc(); - Optional findByReceipt(Receipt receipt); + Optional findByReceipt(Receipt receipt); } diff --git a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneDetailResponseDto.java b/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneDetailResponseDto.java index 25237287b..e3247796f 100644 --- a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneDetailResponseDto.java +++ b/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneDetailResponseDto.java @@ -1,19 +1,20 @@ package com.gg.server.domain.megaphone.dto; import com.gg.server.domain.megaphone.data.Megaphone; + import lombok.Getter; import lombok.NoArgsConstructor; @Getter @NoArgsConstructor public class MegaphoneDetailResponseDto { - private Long megaphoneId; - private String content; - private String usedAt; + private Long megaphoneId; + private String content; + private String usedAt; - public MegaphoneDetailResponseDto(Megaphone megaphone) { - this.megaphoneId = megaphone.getId(); - this.content = megaphone.getContent(); - this.usedAt = megaphone.getUsedAt().toString(); - } + public MegaphoneDetailResponseDto(Megaphone megaphone) { + this.megaphoneId = megaphone.getId(); + this.content = megaphone.getContent(); + this.usedAt = megaphone.getUsedAt().toString(); + } } diff --git a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneTodayListResponseDto.java b/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneTodayListResponseDto.java index 67e0c33fa..fec51363e 100644 --- a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneTodayListResponseDto.java +++ b/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneTodayListResponseDto.java @@ -1,19 +1,20 @@ package com.gg.server.domain.megaphone.dto; import com.gg.server.domain.megaphone.redis.MegaphoneRedis; + import lombok.Getter; import lombok.NoArgsConstructor; @Getter @NoArgsConstructor public class MegaphoneTodayListResponseDto { - private Long megaphoneId; - private String content; - private String intraId; + private Long megaphoneId; + private String content; + private String intraId; - public MegaphoneTodayListResponseDto(MegaphoneRedis megaphoneRedis) { - this.megaphoneId = megaphoneRedis.getId(); - this.content = megaphoneRedis.getContent(); - this.intraId = megaphoneRedis.getIntraId(); - } + public MegaphoneTodayListResponseDto(MegaphoneRedis megaphoneRedis) { + this.megaphoneId = megaphoneRedis.getId(); + this.content = megaphoneRedis.getContent(); + this.intraId = megaphoneRedis.getIntraId(); + } } diff --git a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneUseRequestDto.java b/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneUseRequestDto.java index 8b44b6175..2d73e13b4 100644 --- a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneUseRequestDto.java +++ b/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneUseRequestDto.java @@ -1,18 +1,19 @@ package com.gg.server.domain.megaphone.dto; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - @Getter @NoArgsConstructor @AllArgsConstructor public class MegaphoneUseRequestDto { - @NotNull(message = "receiptId는 null이 될 수 없습니다.") - private Long receiptId; - @NotNull(message = "content는 null이 될 수 없습니다.") @Size(max = 30) - private String content; + @NotNull(message = "receiptId는 null이 될 수 없습니다.") + private Long receiptId; + @NotNull(message = "content는 null이 될 수 없습니다.") + @Size(max = 30) + private String content; } diff --git a/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneContentException.java b/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneContentException.java index 8022d7bef..307573a2b 100644 --- a/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneContentException.java +++ b/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneContentException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.BusinessException; public class MegaphoneContentException extends BusinessException { - public MegaphoneContentException() { - super("확성기 내용이 없습니다.", ErrorCode.MEGAPHONE_CONTENT); - } + public MegaphoneContentException() { + super("확성기 내용이 없습니다.", ErrorCode.MEGAPHONE_CONTENT); + } } diff --git a/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneNotFoundException.java b/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneNotFoundException.java index accd2759d..1ac2c29a2 100644 --- a/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneNotFoundException.java +++ b/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneNotFoundException.java @@ -4,5 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class MegaphoneNotFoundException extends NotExistException { - public MegaphoneNotFoundException() {super("확성기를 찾을 수 없습니다.", ErrorCode.MEGAPHONE_TIME);} + public MegaphoneNotFoundException() { + super("확성기를 찾을 수 없습니다.", ErrorCode.MEGAPHONE_TIME); + } } diff --git a/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneTimeException.java b/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneTimeException.java index f11bd29f3..e4bd72074 100644 --- a/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneTimeException.java +++ b/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneTimeException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.BusinessException; public class MegaphoneTimeException extends BusinessException { - public MegaphoneTimeException() { - super("확성기 사용이 불가능한 시간입니다.", ErrorCode.MEGAPHONE_TIME); - } + public MegaphoneTimeException() { + super("확성기 사용이 불가능한 시간입니다.", ErrorCode.MEGAPHONE_TIME); + } } diff --git a/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedis.java b/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedis.java index bd560df0b..eed95626c 100644 --- a/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedis.java +++ b/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedis.java @@ -1,17 +1,20 @@ package com.gg.server.domain.megaphone.redis; +import java.time.LocalDateTime; + +import javax.persistence.Id; + +import org.springframework.data.redis.core.RedisHash; + import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import org.springframework.data.redis.core.RedisHash; - -import javax.persistence.Id; -import java.time.LocalDateTime; @RedisHash("megaphone") @Getter @@ -19,12 +22,12 @@ @AllArgsConstructor @NoArgsConstructor public class MegaphoneRedis { - @Id - private Long id; - private String intraId; - private String content; + @Id + private Long id; + private String intraId; + private String content; - @JsonSerialize(using = LocalDateTimeSerializer.class) - @JsonDeserialize(using = LocalDateTimeDeserializer.class) - private LocalDateTime usedAt; + @JsonSerialize(using = LocalDateTimeSerializer.class) + @JsonDeserialize(using = LocalDateTimeDeserializer.class) + private LocalDateTime usedAt; } diff --git a/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedisRepository.java b/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedisRepository.java index d1fd99ed3..55517bdfc 100644 --- a/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedisRepository.java +++ b/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedisRepository.java @@ -1,33 +1,33 @@ package com.gg.server.domain.megaphone.redis; -import lombok.RequiredArgsConstructor; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Repository; - import java.time.Duration; import java.util.List; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Repository; + +import lombok.RequiredArgsConstructor; @Repository @RequiredArgsConstructor public class MegaphoneRedisRepository { - private final RedisTemplate redisTemplate; + private final RedisTemplate redisTemplate; - public void addMegaphone(MegaphoneRedis megaphoneRedis) { - Duration duration = Duration.between(megaphoneRedis.getUsedAt(), megaphoneRedis.getUsedAt().plusDays(1)); - redisTemplate.opsForValue().set("megaphone" + megaphoneRedis.getId(), megaphoneRedis, duration); - } + public void addMegaphone(MegaphoneRedis megaphoneRedis) { + Duration duration = Duration.between(megaphoneRedis.getUsedAt(), megaphoneRedis.getUsedAt().plusDays(1)); + redisTemplate.opsForValue().set("megaphone" + megaphoneRedis.getId(), megaphoneRedis, duration); + } - public List getAllMegaphone() { - return redisTemplate.opsForValue().multiGet(redisTemplate.keys("megaphone*")); - } + public List getAllMegaphone() { + return redisTemplate.opsForValue().multiGet(redisTemplate.keys("megaphone*")); + } - public void deleteAllMegaphone() { - redisTemplate.delete(redisTemplate.keys("megaphone*")); - } + public void deleteAllMegaphone() { + redisTemplate.delete(redisTemplate.keys("megaphone*")); + } - public void deleteMegaphoneById(Long id) { - redisTemplate.delete("megaphone" + id); - } + public void deleteMegaphoneById(Long id) { + redisTemplate.delete("megaphone" + id); + } } diff --git a/src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java b/src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java index d3f258dde..6d6b93238 100644 --- a/src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java +++ b/src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java @@ -1,5 +1,14 @@ package com.gg.server.domain.megaphone.service; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.List; +import java.util.stream.Collectors; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.domain.item.service.ItemService; import com.gg.server.domain.item.type.ItemType; import com.gg.server.domain.megaphone.data.Megaphone; @@ -22,83 +31,84 @@ import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; import com.gg.server.domain.user.type.RoleType; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.util.List; -import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class MegaphoneService { - private final UserRepository userRepository; - private final ReceiptRepository receiptRepository; - private final MegaphoneRepository megaphoneRepository; - private final MegaphoneRedisRepository megaphoneRedisRepository; - private final ItemService itemService; + private final UserRepository userRepository; + private final ReceiptRepository receiptRepository; + private final MegaphoneRepository megaphoneRepository; + private final MegaphoneRedisRepository megaphoneRedisRepository; + private final ItemService itemService; - @Transactional - public void useMegaphone(MegaphoneUseRequestDto megaphoneUseRequestDto, UserDto user) { - User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); - if (LocalTime.now().isAfter(LocalTime.of(23, 55)) || LocalTime.now().isBefore(LocalTime.of(0, 5))) { - throw new MegaphoneTimeException(); - } - Receipt receipt = receiptRepository.findById(megaphoneUseRequestDto.getReceiptId()).orElseThrow(ReceiptNotFoundException::new); - itemService.checkItemType(receipt, ItemType.MEGAPHONE); - itemService.checkItemOwner(loginUser, receipt); - if (!receipt.getStatus().equals(ItemStatus.BEFORE)) { - throw new ItemStatusException(); - } - if (megaphoneUseRequestDto.getContent().length() == 0) { - throw new MegaphoneContentException(); - } - receipt.updateStatus(ItemStatus.WAITING); - Megaphone megaphone = new Megaphone(loginUser, receipt, megaphoneUseRequestDto.getContent(), LocalDate.now().plusDays(1)); - megaphoneRepository.save(megaphone); - } + @Transactional + public void useMegaphone(MegaphoneUseRequestDto megaphoneUseRequestDto, UserDto user) { + User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); + if (LocalTime.now().isAfter(LocalTime.of(23, 55)) || LocalTime.now().isBefore(LocalTime.of(0, 5))) { + throw new MegaphoneTimeException(); + } + Receipt receipt = receiptRepository.findById(megaphoneUseRequestDto.getReceiptId()) + .orElseThrow(ReceiptNotFoundException::new); + itemService.checkItemType(receipt, ItemType.MEGAPHONE); + itemService.checkItemOwner(loginUser, receipt); + if (!receipt.getStatus().equals(ItemStatus.BEFORE)) { + throw new ItemStatusException(); + } + if (megaphoneUseRequestDto.getContent().length() == 0) { + throw new MegaphoneContentException(); + } + receipt.updateStatus(ItemStatus.WAITING); + Megaphone megaphone = new Megaphone(loginUser, receipt, megaphoneUseRequestDto.getContent(), + LocalDate.now().plusDays(1)); + megaphoneRepository.save(megaphone); + } - @Transactional - public void setMegaphoneList(LocalDate today) { - megaphoneRepository.findAllByUsedAtAndReceiptStatus(today, ItemStatus.USING).forEach(megaphone -> megaphone.getReceipt().updateStatus(ItemStatus.USED)); - megaphoneRedisRepository.deleteAllMegaphone(); - List megaphones = megaphoneRepository.findAllByUsedAtAndReceiptStatus(today.plusDays(1), ItemStatus.WAITING); - for (Megaphone megaphone : megaphones) { - megaphone.getReceipt().updateStatus(ItemStatus.USING); - megaphoneRedisRepository.addMegaphone(new MegaphoneRedis(megaphone.getId(), megaphone.getUser().getIntraId(), megaphone.getContent(), - LocalDateTime.of(megaphone.getUsedAt(), LocalTime.of(0, 0)))); - } - } + @Transactional + public void setMegaphoneList(LocalDate today) { + megaphoneRepository.findAllByUsedAtAndReceiptStatus(today, ItemStatus.USING) + .forEach(megaphone -> megaphone.getReceipt().updateStatus(ItemStatus.USED)); + megaphoneRedisRepository.deleteAllMegaphone(); + List megaphones = megaphoneRepository.findAllByUsedAtAndReceiptStatus(today.plusDays(1), + ItemStatus.WAITING); + for (Megaphone megaphone : megaphones) { + megaphone.getReceipt().updateStatus(ItemStatus.USING); + megaphoneRedisRepository.addMegaphone( + new MegaphoneRedis(megaphone.getId(), megaphone.getUser().getIntraId(), megaphone.getContent(), + LocalDateTime.of(megaphone.getUsedAt(), LocalTime.of(0, 0)))); + } + } - @Transactional - public void deleteMegaphone(Long megaphoneId, UserDto user) { - User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); - Megaphone megaphone = megaphoneRepository.findById(megaphoneId).orElseThrow(MegaphoneNotFoundException::new); - Receipt receipt = megaphone.getReceipt(); - if (!user.getRoleType().equals(RoleType.ADMIN)) { - itemService.checkItemOwner(loginUser, receipt); - } - itemService.checkItemStatus(receipt); - if (receipt.getStatus().equals(ItemStatus.USING)) { - megaphoneRedisRepository.deleteMegaphoneById(megaphone.getId()); - } - receipt.updateStatus(ItemStatus.DELETED); - } + @Transactional + public void deleteMegaphone(Long megaphoneId, UserDto user) { + User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); + Megaphone megaphone = megaphoneRepository.findById(megaphoneId).orElseThrow(MegaphoneNotFoundException::new); + Receipt receipt = megaphone.getReceipt(); + if (!user.getRoleType().equals(RoleType.ADMIN)) { + itemService.checkItemOwner(loginUser, receipt); + } + itemService.checkItemStatus(receipt); + if (receipt.getStatus().equals(ItemStatus.USING)) { + megaphoneRedisRepository.deleteMegaphoneById(megaphone.getId()); + } + receipt.updateStatus(ItemStatus.DELETED); + } - public MegaphoneDetailResponseDto getMegaphoneDetail(Long receiptId, UserDto user) { - User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); - Receipt receipt = receiptRepository.findById(receiptId).orElseThrow(ReceiptNotFoundException::new); - itemService.checkItemType(receipt, ItemType.MEGAPHONE); - itemService.checkItemOwner(loginUser, receipt); - itemService.checkItemStatus(receipt); - Megaphone megaphone = megaphoneRepository.findByReceipt(receipt).orElseThrow(MegaphoneNotFoundException::new); - return new MegaphoneDetailResponseDto(megaphone); - } + public MegaphoneDetailResponseDto getMegaphoneDetail(Long receiptId, UserDto user) { + User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); + Receipt receipt = receiptRepository.findById(receiptId).orElseThrow(ReceiptNotFoundException::new); + itemService.checkItemType(receipt, ItemType.MEGAPHONE); + itemService.checkItemOwner(loginUser, receipt); + itemService.checkItemStatus(receipt); + Megaphone megaphone = megaphoneRepository.findByReceipt(receipt).orElseThrow(MegaphoneNotFoundException::new); + return new MegaphoneDetailResponseDto(megaphone); + } - public List getMegaphoneTodayList() { - return megaphoneRedisRepository.getAllMegaphone().stream().map(MegaphoneTodayListResponseDto::new).collect(Collectors.toList()); - } + public List getMegaphoneTodayList() { + return megaphoneRedisRepository.getAllMegaphone() + .stream() + .map(MegaphoneTodayListResponseDto::new) + .collect(Collectors.toList()); + } } diff --git a/src/main/java/com/gg/server/domain/noti/controller/NotiController.java b/src/main/java/com/gg/server/domain/noti/controller/NotiController.java index 240633968..859cbeb02 100644 --- a/src/main/java/com/gg/server/domain/noti/controller/NotiController.java +++ b/src/main/java/com/gg/server/domain/noti/controller/NotiController.java @@ -1,38 +1,43 @@ package com.gg.server.domain.noti.controller; -import com.gg.server.domain.noti.dto.NotiDto; +import java.util.List; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import com.gg.server.domain.noti.dto.NotiListResponseDto; import com.gg.server.domain.noti.dto.NotiResponseDto; import com.gg.server.domain.noti.service.NotiService; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.utils.argumentresolver.Login; -import lombok.AllArgsConstructor; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; -import java.util.List; +import lombok.AllArgsConstructor; @RestController @AllArgsConstructor @RequestMapping(value = "/pingpong/notifications") public class NotiController { - private final NotiService notiService; - - @GetMapping - public NotiListResponseDto notiFindByUser(@Login UserDto user) { - List notiResponseDtoList = notiService.findNotiByUser(user); - return new NotiListResponseDto(notiResponseDtoList); - } - - @PutMapping(value = "/check") - public ResponseEntity checkNotiByUser(@Login UserDto user) { - notiService.modifyNotiCheckedByUser(user); - return ResponseEntity.status(204).build(); - } - - @DeleteMapping - public ResponseEntity notiRemoveAll(@Login UserDto user) { - notiService.removeAllNotisByUser(user); - return ResponseEntity.status(204).build(); - } + private final NotiService notiService; + + @GetMapping + public NotiListResponseDto notiFindByUser(@Login UserDto user) { + List notiResponseDtoList = notiService.findNotiByUser(user); + return new NotiListResponseDto(notiResponseDtoList); + } + + @PutMapping(value = "/check") + public ResponseEntity checkNotiByUser(@Login UserDto user) { + notiService.modifyNotiCheckedByUser(user); + return ResponseEntity.status(204).build(); + } + + @DeleteMapping + public ResponseEntity notiRemoveAll(@Login UserDto user) { + notiService.removeAllNotisByUser(user); + return ResponseEntity.status(204).build(); + } } diff --git a/src/main/java/com/gg/server/domain/noti/data/Noti.java b/src/main/java/com/gg/server/domain/noti/data/Noti.java index bcaff10a7..dab870760 100644 --- a/src/main/java/com/gg/server/domain/noti/data/Noti.java +++ b/src/main/java/com/gg/server/domain/noti/data/Noti.java @@ -1,53 +1,65 @@ -package com.gg.server.domain.noti.data; - -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.global.utils.BaseTimeEntity; -import lombok.*; - -import javax.persistence.*; -import javax.validation.constraints.NotNull; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Entity -public class Noti extends BaseTimeEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - @NotNull - @Column(name = "noti_type", length = 30) - @Enumerated(EnumType.STRING) - private NotiType type; - - @Column(name = "message", length = 255) - private String message; - - @NotNull - @Column(name = "is_checked") - private Boolean isChecked; - - public Noti(User user, NotiType type, String message, Boolean isChecked) { - this.user = user; - this.type = type; - this.message = message; - this.isChecked = isChecked; - } - - public void update(User user, NotiType type, String message, Boolean isChecked) { - this.user = user; - this.type = type; - this.message = message; - this.isChecked = isChecked; - } - - public void modifyIsChecked(Boolean isChecked) { - this.isChecked = isChecked; - } -} +package com.gg.server.domain.noti.data; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.validation.constraints.NotNull; + +import com.gg.server.domain.noti.type.NotiType; +import com.gg.server.domain.user.data.User; +import com.gg.server.global.utils.BaseTimeEntity; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Entity +public class Noti extends BaseTimeEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @NotNull + @Column(name = "noti_type", length = 30) + @Enumerated(EnumType.STRING) + private NotiType type; + + @Column(name = "message", length = 255) + private String message; + + @NotNull + @Column(name = "is_checked") + private Boolean isChecked; + + public Noti(User user, NotiType type, String message, Boolean isChecked) { + this.user = user; + this.type = type; + this.message = message; + this.isChecked = isChecked; + } + + public void update(User user, NotiType type, String message, Boolean isChecked) { + this.user = user; + this.type = type; + this.message = message; + this.isChecked = isChecked; + } + + public void modifyIsChecked(Boolean isChecked) { + this.isChecked = isChecked; + } +} diff --git a/src/main/java/com/gg/server/domain/noti/data/NotiRepository.java b/src/main/java/com/gg/server/domain/noti/data/NotiRepository.java index fb291af76..a25a6ff95 100644 --- a/src/main/java/com/gg/server/domain/noti/data/NotiRepository.java +++ b/src/main/java/com/gg/server/domain/noti/data/NotiRepository.java @@ -1,14 +1,20 @@ -package com.gg.server.domain.noti.data; - -import com.gg.server.domain.user.data.User; -import org.springframework.data.jpa.repository.JpaRepository; -import java.util.List; -import java.util.Optional; - -public interface NotiRepository extends JpaRepository, NotiRepositoryCustom { - List findByUser(User user); - Optional findByIdAndUser(Long notiId, User user); - List findAllByUser(User user); - List findAllByUserOrderByIdDesc(User user); - void deleteAllByUser(User user); -} +package com.gg.server.domain.noti.data; + +import java.util.List; +import java.util.Optional; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.gg.server.domain.user.data.User; + +public interface NotiRepository extends JpaRepository, NotiRepositoryCustom { + List findByUser(User user); + + Optional findByIdAndUser(Long notiId, User user); + + List findAllByUser(User user); + + List findAllByUserOrderByIdDesc(User user); + + void deleteAllByUser(User user); +} diff --git a/src/main/java/com/gg/server/domain/noti/data/NotiRepositoryCustom.java b/src/main/java/com/gg/server/domain/noti/data/NotiRepositoryCustom.java index 1fa0e6599..8d484d880 100644 --- a/src/main/java/com/gg/server/domain/noti/data/NotiRepositoryCustom.java +++ b/src/main/java/com/gg/server/domain/noti/data/NotiRepositoryCustom.java @@ -1,5 +1,5 @@ package com.gg.server.domain.noti.data; public interface NotiRepositoryCustom { - int countNotCheckedNotiByUser(Long userId); + int countNotCheckedNotiByUser(Long userId); } diff --git a/src/main/java/com/gg/server/domain/noti/data/NotiRepositoryImpl.java b/src/main/java/com/gg/server/domain/noti/data/NotiRepositoryImpl.java index fda2ac825..f29e107e6 100644 --- a/src/main/java/com/gg/server/domain/noti/data/NotiRepositoryImpl.java +++ b/src/main/java/com/gg/server/domain/noti/data/NotiRepositoryImpl.java @@ -1,19 +1,19 @@ package com.gg.server.domain.noti.data; -import lombok.RequiredArgsConstructor; - import javax.persistence.EntityManager; +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor -public class NotiRepositoryImpl implements NotiRepositoryCustom{ - private final EntityManager em; - @Override - public int countNotCheckedNotiByUser(Long userId) { - String sql = "select count(n) from Noti n where n.isChecked=false and user.id =: userId"; - Long cntNoti = em.createQuery(sql, Long.class) - .setParameter("userId", userId) - .getSingleResult(); - return cntNoti.intValue(); - } +public class NotiRepositoryImpl implements NotiRepositoryCustom { + private final EntityManager em; + + @Override + public int countNotCheckedNotiByUser(Long userId) { + String sql = "select count(n) from Noti n where n.isChecked=false and user.id =: userId"; + Long cntNoti = em.createQuery(sql, Long.class) + .setParameter("userId", userId) + .getSingleResult(); + return cntNoti.intValue(); + } } diff --git a/src/main/java/com/gg/server/domain/noti/dto/NotiDto.java b/src/main/java/com/gg/server/domain/noti/dto/NotiDto.java index f39187d0e..38a38dbc2 100644 --- a/src/main/java/com/gg/server/domain/noti/dto/NotiDto.java +++ b/src/main/java/com/gg/server/domain/noti/dto/NotiDto.java @@ -1,68 +1,68 @@ package com.gg.server.domain.noti.dto; +import java.time.LocalDateTime; +import java.util.Objects; + import com.gg.server.domain.noti.data.Noti; -import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.noti.type.NotiType; +import com.gg.server.domain.user.dto.UserDto; + import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; -import java.util.Objects; - @Getter @Builder public class NotiDto { - private Long id; - private UserDto user; - private NotiType type; - private Boolean isChecked; - private String message; - private LocalDateTime createdAt; + private Long id; + private UserDto user; + private NotiType type; + private Boolean isChecked; + private String message; + private LocalDateTime createdAt; - static public NotiDto from (Noti noti) - { - NotiDto notiDto; - if (noti == null) - notiDto = null; - else { - notiDto = NotiDto.builder() - .id(noti.getId()) - .user(UserDto.from(noti.getUser())) - .type(noti.getType()) - .isChecked(noti.getIsChecked()) - .message(noti.getMessage()) - .createdAt(noti.getCreatedAt()) - .build(); - } - return notiDto; - } + public static NotiDto from(Noti noti) { + NotiDto notiDto; + if (noti == null) { + notiDto = null; + } else { + notiDto = NotiDto.builder() + .id(noti.getId()) + .user(UserDto.from(noti.getUser())) + .type(noti.getType()) + .isChecked(noti.getIsChecked()) + .message(noti.getMessage()) + .createdAt(noti.getCreatedAt()) + .build(); + } + return notiDto; + } - @Override - public String toString() { - return "NotiDto{" + - "id=" + id + - ", user=" + user + - ", type=" + type + - ", isChecked=" + isChecked + - ", message='" + message + '\'' + - ", createdDate=" + createdAt + - '}'; - } + @Override + public String toString() { + return "NotiDto{" + + "id=" + id + + ", user=" + user + + ", type=" + type + + ", isChecked=" + isChecked + + ", message='" + message + '\'' + + ", createdDate=" + createdAt + + '}'; + } - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (!(o instanceof NotiDto)) { - return false; - } - NotiDto other = (NotiDto) o; - return Objects.equals(id, other.id) - && Objects.equals(user, other.user) - && Objects.equals(type, other.type) - && Objects.equals(isChecked, other.isChecked) - && Objects.equals(message, other.message) - && Objects.equals(createdAt, other.createdAt); - } + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof NotiDto)) { + return false; + } + NotiDto other = (NotiDto)obj; + return Objects.equals(id, other.id) + && Objects.equals(user, other.user) + && Objects.equals(type, other.type) + && Objects.equals(isChecked, other.isChecked) + && Objects.equals(message, other.message) + && Objects.equals(createdAt, other.createdAt); + } } diff --git a/src/main/java/com/gg/server/domain/noti/dto/NotiListResponseDto.java b/src/main/java/com/gg/server/domain/noti/dto/NotiListResponseDto.java index 7ff7ba7b4..830e258d2 100644 --- a/src/main/java/com/gg/server/domain/noti/dto/NotiListResponseDto.java +++ b/src/main/java/com/gg/server/domain/noti/dto/NotiListResponseDto.java @@ -1,29 +1,34 @@ package com.gg.server.domain.noti.dto; +import java.util.List; +import java.util.Objects; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; -import java.util.Objects; - @Getter @AllArgsConstructor @NoArgsConstructor public class NotiListResponseDto { - private List notifications; - @Override - public String toString() { - return "NotiResponseDto{" + - "notifications=" + notifications + - '}'; - } + private List notifications; + + @Override + public String toString() { + return "NotiResponseDto{" + + "notifications=" + notifications + + '}'; + } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - NotiListResponseDto other = (NotiListResponseDto) o; - return Objects.equals(notifications, other.notifications); - } -} \ No newline at end of file + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + NotiListResponseDto other = (NotiListResponseDto)obj; + return Objects.equals(notifications, other.notifications); + } +} diff --git a/src/main/java/com/gg/server/domain/noti/dto/NotiResponseDto.java b/src/main/java/com/gg/server/domain/noti/dto/NotiResponseDto.java index 1586cbb05..0a9425f38 100644 --- a/src/main/java/com/gg/server/domain/noti/dto/NotiResponseDto.java +++ b/src/main/java/com/gg/server/domain/noti/dto/NotiResponseDto.java @@ -1,69 +1,67 @@ package com.gg.server.domain.noti.dto; +import java.time.LocalDateTime; +import java.util.Objects; + import com.gg.server.domain.noti.data.Noti; import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.user.dto.UserDto; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Objects; - @Getter @AllArgsConstructor @NoArgsConstructor @Builder public class NotiResponseDto { - private Long id; - private NotiType type; - private Boolean isChecked; - private String message; - private LocalDateTime createdAt; + private Long id; + private NotiType type; + private Boolean isChecked; + private String message; + private LocalDateTime createdAt; - static public NotiResponseDto from (Noti noti) - { - NotiResponseDto notiResponseDto; - if (noti == null) - notiResponseDto = null; - else { - notiResponseDto = NotiResponseDto.builder() - .id(noti.getId()) - .type(noti.getType()) - .isChecked(noti.getIsChecked()) - .message(noti.getMessage()) - .createdAt(noti.getCreatedAt()) - .build(); - } - return notiResponseDto; - } + public static NotiResponseDto from(Noti noti) { + NotiResponseDto notiResponseDto; + if (noti == null) { + notiResponseDto = null; + } else { + notiResponseDto = NotiResponseDto.builder() + .id(noti.getId()) + .type(noti.getType()) + .isChecked(noti.getIsChecked()) + .message(noti.getMessage()) + .createdAt(noti.getCreatedAt()) + .build(); + } + return notiResponseDto; + } - @Override - public String toString() { - return "NotiDto{" + - "id=" + id + - ", type=" + type + - ", isChecked=" + isChecked + - ", message='" + message + '\'' + - ", createdDate=" + createdAt + - '}'; - } + @Override + public String toString() { + return "NotiDto{" + + "id=" + id + + ", type=" + type + + ", isChecked=" + isChecked + + ", message='" + message + '\'' + + ", createdDate=" + createdAt + + '}'; + } - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (!(o instanceof NotiResponseDto)) { - return false; - } - NotiResponseDto other = (NotiResponseDto) o; - return Objects.equals(id, other.id) - && Objects.equals(type, other.type) - && Objects.equals(isChecked, other.isChecked) - && Objects.equals(message, other.message) - && Objects.equals(createdAt, other.createdAt); - } -} \ No newline at end of file + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof NotiResponseDto)) { + return false; + } + NotiResponseDto other = (NotiResponseDto)obj; + return Objects.equals(id, other.id) + && Objects.equals(type, other.type) + && Objects.equals(isChecked, other.isChecked) + && Objects.equals(message, other.message) + && Objects.equals(createdAt, other.createdAt); + } +} diff --git a/src/main/java/com/gg/server/domain/noti/dto/UserNotiDto.java b/src/main/java/com/gg/server/domain/noti/dto/UserNotiDto.java index f3b127aba..4c9c2b78e 100644 --- a/src/main/java/com/gg/server/domain/noti/dto/UserNotiDto.java +++ b/src/main/java/com/gg/server/domain/noti/dto/UserNotiDto.java @@ -2,21 +2,22 @@ import com.gg.server.domain.team.dto.GameUser; import com.gg.server.domain.user.type.SnsType; + import lombok.Getter; @Getter public class UserNotiDto { - private Long userId; - private Long gameId; - private String intraId; - private SnsType snsNotiOpt; - private String email; + private Long userId; + private Long gameId; + private String intraId; + private SnsType snsNotiOpt; + private String email; - public UserNotiDto(GameUser gameUser) { - this.gameId = gameUser.getGameId(); - this.userId = gameUser.getUserId(); - this.intraId = gameUser.getIntraId(); - this.email = gameUser.getEmail(); - this.snsNotiOpt = gameUser.getSnsNotiOpt(); - } + public UserNotiDto(GameUser gameUser) { + this.gameId = gameUser.getGameId(); + this.userId = gameUser.getUserId(); + this.intraId = gameUser.getIntraId(); + this.email = gameUser.getEmail(); + this.snsNotiOpt = gameUser.getSnsNotiOpt(); + } } diff --git a/src/main/java/com/gg/server/domain/noti/exception/SlackJsonParseException.java b/src/main/java/com/gg/server/domain/noti/exception/SlackJsonParseException.java index 3bdf62972..108cdfc32 100644 --- a/src/main/java/com/gg/server/domain/noti/exception/SlackJsonParseException.java +++ b/src/main/java/com/gg/server/domain/noti/exception/SlackJsonParseException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.ParseException; public class SlackJsonParseException extends ParseException { - public SlackJsonParseException() { - super("json parse error in getDmChannelId()", ErrorCode.SLACK_JSON_PARSE_ERR); - } + public SlackJsonParseException() { + super("json parse error in getDmChannelId()", ErrorCode.SLACK_JSON_PARSE_ERR); + } } diff --git a/src/main/java/com/gg/server/domain/noti/exception/SlackSendException.java b/src/main/java/com/gg/server/domain/noti/exception/SlackSendException.java index 703f82189..b4e83e773 100644 --- a/src/main/java/com/gg/server/domain/noti/exception/SlackSendException.java +++ b/src/main/java/com/gg/server/domain/noti/exception/SlackSendException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.SendException; public class SlackSendException extends SendException { - public SlackSendException() { - super("fail to send notification", ErrorCode.SLACK_SEND_FAIL); - } + public SlackSendException() { + super("fail to send notification", ErrorCode.SLACK_SEND_FAIL); + } } diff --git a/src/main/java/com/gg/server/domain/noti/exception/SlackUserGetFailedException.java b/src/main/java/com/gg/server/domain/noti/exception/SlackUserGetFailedException.java index 454e751ee..a06e99b4a 100644 --- a/src/main/java/com/gg/server/domain/noti/exception/SlackUserGetFailedException.java +++ b/src/main/java/com/gg/server/domain/noti/exception/SlackUserGetFailedException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class SlackUserGetFailedException extends NotExistException { - public SlackUserGetFailedException() { - super("fail to get slack user info", ErrorCode.SLACK_USER_NOT_FOUND); - } + public SlackUserGetFailedException() { + super("fail to get slack user info", ErrorCode.SLACK_USER_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/noti/service/NotiService.java b/src/main/java/com/gg/server/domain/noti/service/NotiService.java index f1a019265..6ad3dc340 100644 --- a/src/main/java/com/gg/server/domain/noti/service/NotiService.java +++ b/src/main/java/com/gg/server/domain/noti/service/NotiService.java @@ -1,106 +1,114 @@ -package com.gg.server.domain.noti.service; - -import com.gg.server.domain.noti.data.Noti; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.noti.dto.NotiDto; -import com.gg.server.domain.noti.dto.NotiResponseDto; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; -import lombok.AllArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.List; -import java.util.stream.Collectors; - -@Service -@AllArgsConstructor -public class NotiService { - private final NotiRepository notiRepository; - private final UserRepository userRepository; - private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); - - @Transactional(readOnly = true) - public List findNotiByUser(UserDto userDto) { - User user = userRepository.findById(userDto.getId()).orElseThrow(UserNotFoundException::new); - List notiList = notiRepository.findAllByUserOrderByIdDesc(user); - List notiResponseDtoList = notiList.stream().map(NotiResponseDto::from).collect(Collectors.toList()); - return notiResponseDtoList; - } - - @Transactional - public NotiDto findNotiByIdAndUser(UserDto userDto, Long notiId) { - User user = userRepository.findById(userDto.getId()).orElseThrow(UserNotFoundException::new); - Noti noti = notiRepository.findByIdAndUser(notiId, user).orElseThrow(() -> new NotExistException("요청한 알림을 찾을 수 없습니다.", ErrorCode.NOT_FOUND)); - return NotiDto.from(noti); - } - - @Transactional - public void modifyNotiCheckedByUser(UserDto userDto) { - User user = userRepository.findById(userDto.getId()).orElseThrow(UserNotFoundException::new); - List notis = notiRepository.findAllByUser(user); - notis.forEach(noti -> {noti.modifyIsChecked(true);}); - } - - @Transactional - public void removeNotiById(Long notiId) { - notiRepository.deleteById(notiId); - } - - @Transactional - public void removeAllNotisByUser(UserDto userDto) { - User user = userRepository.findById(userDto.getId()).orElseThrow(UserNotFoundException::new); - notiRepository.deleteAllByUser(user); - } - - @Transactional - public Noti createMatched(User user, LocalDateTime startTime) { - String notiMessage = startTime.format(DateTimeFormatter.ofPattern("HH:mm")) + "에 신청한 매칭이 성사되었습니다."; - Noti noti = new Noti(user, NotiType.MATCHED, notiMessage, false); - notiRepository.save(noti); - return noti; - } - - @Transactional - public Noti createMatchCancel(User user, LocalDateTime startTime) { - String notiMessage = startTime.format(DateTimeFormatter.ofPattern("HH:mm")) + "에 신청한 매칭이 상대에 의해 취소되었습니다."; - Noti noti = new Noti(user, NotiType.CANCELEDBYMAN, notiMessage, false); - notiRepository.save(noti); - return noti; - } - - @Transactional - public Noti createGiftNoti(User ownerUser, User payUser, String itemName) { - String notiMessage = "ଘ(੭ˊᵕˋ)੭* ੈ✩ " + payUser.getIntraId() + "님에게 " + itemName + " 아이템을 선물받았어요!"; - Noti noti = new Noti(ownerUser, NotiType.GIFT, notiMessage, false); - notiRepository.save(noti); - return noti; - } - - public Noti createImminentNoti(User user, String enemyIntra, NotiType notiType, Integer gameOpenMinute) { - String msg = "님과 경기 " + gameOpenMinute + "분 전 입니다. 서두르세요!"; - return notiRepository.save(new Noti(user, notiType, msg, false)); - } - - public String getMessage(Noti noti) { - String message; - if (noti.getType() != NotiType.ANNOUNCE) { - message = notiMsg(noti.getType()); - } else { - message = "🧚: \"새로운 알림이 도착했핑.\"\n" + "🧚: \"" + noti.getType().getMessage() + "\"\n\n공지사항: " - + noti.getMessage() + "\n\n 🏓42GG와 함께하는 행복한 탁구생활🏓" + "\n$$지금 즉시 접속$$ ----> https://42gg.kr"; - } - return message; - } - public String notiMsg(NotiType notiType) { - return "🧚: \"새로운 알림이 도착했핑.\"\n" + "🧚: \"" + notiType.getMessage() + "\"\n\n 🏓42GG와 함께하는 행복한 탁구생활🏓" + - "\n$$지금 즉시 접속$$ ----> https://42gg.kr"; - } -} +package com.gg.server.domain.noti.service; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.stream.Collectors; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.domain.noti.data.Noti; +import com.gg.server.domain.noti.data.NotiRepository; +import com.gg.server.domain.noti.dto.NotiDto; +import com.gg.server.domain.noti.dto.NotiResponseDto; +import com.gg.server.domain.noti.type.NotiType; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.exception.UserNotFoundException; +import com.gg.server.global.exception.ErrorCode; +import com.gg.server.global.exception.custom.NotExistException; + +import lombok.AllArgsConstructor; + +@Service +@AllArgsConstructor +public class NotiService { + private final NotiRepository notiRepository; + private final UserRepository userRepository; + private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); + + @Transactional(readOnly = true) + public List findNotiByUser(UserDto userDto) { + User user = userRepository.findById(userDto.getId()).orElseThrow(UserNotFoundException::new); + List notiList = notiRepository.findAllByUserOrderByIdDesc(user); + List notiResponseDtoList = notiList.stream() + .map(NotiResponseDto::from) + .collect(Collectors.toList()); + return notiResponseDtoList; + } + + @Transactional + public NotiDto findNotiByIdAndUser(UserDto userDto, Long notiId) { + User user = userRepository.findById(userDto.getId()).orElseThrow(UserNotFoundException::new); + Noti noti = notiRepository.findByIdAndUser(notiId, user) + .orElseThrow(() -> new NotExistException("요청한 알림을 찾을 수 없습니다.", ErrorCode.NOT_FOUND)); + return NotiDto.from(noti); + } + + @Transactional + public void modifyNotiCheckedByUser(UserDto userDto) { + User user = userRepository.findById(userDto.getId()).orElseThrow(UserNotFoundException::new); + List notis = notiRepository.findAllByUser(user); + notis.forEach(noti -> { + noti.modifyIsChecked(true); + }); + } + + @Transactional + public void removeNotiById(Long notiId) { + notiRepository.deleteById(notiId); + } + + @Transactional + public void removeAllNotisByUser(UserDto userDto) { + User user = userRepository.findById(userDto.getId()).orElseThrow(UserNotFoundException::new); + notiRepository.deleteAllByUser(user); + } + + @Transactional + public Noti createMatched(User user, LocalDateTime startTime) { + String notiMessage = startTime.format(DateTimeFormatter.ofPattern("HH:mm")) + "에 신청한 매칭이 성사되었습니다."; + Noti noti = new Noti(user, NotiType.MATCHED, notiMessage, false); + notiRepository.save(noti); + return noti; + } + + @Transactional + public Noti createMatchCancel(User user, LocalDateTime startTime) { + String notiMessage = startTime.format(DateTimeFormatter.ofPattern("HH:mm")) + "에 신청한 매칭이 상대에 의해 취소되었습니다."; + Noti noti = new Noti(user, NotiType.CANCELEDBYMAN, notiMessage, false); + notiRepository.save(noti); + return noti; + } + + @Transactional + public Noti createGiftNoti(User ownerUser, User payUser, String itemName) { + String notiMessage = "ଘ(੭ˊᵕˋ)੭* ੈ✩ " + payUser.getIntraId() + "님에게 " + itemName + " 아이템을 선물받았어요!"; + Noti noti = new Noti(ownerUser, NotiType.GIFT, notiMessage, false); + notiRepository.save(noti); + return noti; + } + + public Noti createImminentNoti(User user, String enemyIntra, NotiType notiType, Integer gameOpenMinute) { + String msg = "님과 경기 " + gameOpenMinute + "분 전 입니다. 서두르세요!"; + return notiRepository.save(new Noti(user, notiType, msg, false)); + } + + public String getMessage(Noti noti) { + String message; + if (noti.getType() != NotiType.ANNOUNCE) { + message = notiMsg(noti.getType()); + } else { + message = "🧚: \"새로운 알림이 도착했핑.\"\n" + "🧚: \"" + noti.getType().getMessage() + "\"\n\n공지사항: " + + noti.getMessage() + "\n\n 🏓42GG와 함께하는 행복한 탁구생활🏓" + "\n$$지금 즉시 접속$$ ----> https://42gg.kr"; + } + return message; + } + + public String notiMsg(NotiType notiType) { + return "🧚: \"새로운 알림이 도착했핑.\"\n" + "🧚: \"" + notiType.getMessage() + "\"\n\n 🏓42GG와 함께하는 행복한 탁구생활🏓" + + "\n$$지금 즉시 접속$$ ----> https://42gg.kr"; + } +} diff --git a/src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java b/src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java index 726758068..e0b0cc0ae 100644 --- a/src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java +++ b/src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java @@ -1,55 +1,59 @@ package com.gg.server.domain.noti.service; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.domain.noti.data.Noti; import com.gg.server.domain.noti.dto.UserNotiDto; import com.gg.server.domain.noti.service.sns.NotiMailSender; import com.gg.server.domain.noti.service.sns.SlackbotService; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.type.SnsType; + import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service @Slf4j public class SnsNotiService { - private final NotiMailSender notiMailSender; - private final SlackbotService slackbotService; + private final NotiMailSender notiMailSender; + private final SlackbotService slackbotService; - public SnsNotiService(NotiMailSender notiMailSender, SlackbotService slackbotService) { - this.notiMailSender = notiMailSender; - this.slackbotService = slackbotService; - } + public SnsNotiService(NotiMailSender notiMailSender, SlackbotService slackbotService) { + this.notiMailSender = notiMailSender; + this.slackbotService = slackbotService; + } - @Transactional(readOnly = true) - public void sendSnsNotification(Noti noti, UserNotiDto user) { - log.info("Send Sns Noti"); - SnsType userSnsNotiOpt = user.getSnsNotiOpt(); - if (userSnsNotiOpt == SnsType.NONE) - return; - if(userSnsNotiOpt == SnsType.EMAIL) - notiMailSender.send(user, noti); - else if (userSnsNotiOpt == SnsType.SLACK) - slackbotService.send(user, noti); - else if (userSnsNotiOpt == SnsType.BOTH) { - notiMailSender.send(user, noti); - slackbotService.send(user, noti); - } - } + @Transactional(readOnly = true) + public void sendSnsNotification(Noti noti, UserNotiDto user) { + log.info("Send Sns Noti"); + SnsType userSnsNotiOpt = user.getSnsNotiOpt(); + if (userSnsNotiOpt == SnsType.NONE) { + return; + } + if (userSnsNotiOpt == SnsType.EMAIL) { + notiMailSender.send(user, noti); + } else if (userSnsNotiOpt == SnsType.SLACK) { + slackbotService.send(user, noti); + } else if (userSnsNotiOpt == SnsType.BOTH) { + notiMailSender.send(user, noti); + slackbotService.send(user, noti); + } + } - @Transactional(readOnly = true) - public void sendSnsNotification(Noti noti, UserDto user) { - log.info("Send Sns Noti"); - SnsType userSnsNotiOpt = user.getSnsNotiOpt(); - if (userSnsNotiOpt == SnsType.NONE) - return; - if(userSnsNotiOpt == SnsType.EMAIL) - notiMailSender.send(user, noti); - else if (userSnsNotiOpt == SnsType.SLACK) - slackbotService.send(user, noti); - else if (userSnsNotiOpt == SnsType.BOTH) { - notiMailSender.send(user, noti); - slackbotService.send(user, noti); - } - } + @Transactional(readOnly = true) + public void sendSnsNotification(Noti noti, UserDto user) { + log.info("Send Sns Noti"); + SnsType userSnsNotiOpt = user.getSnsNotiOpt(); + if (userSnsNotiOpt == SnsType.NONE) { + return; + } + if (userSnsNotiOpt == SnsType.EMAIL) { + notiMailSender.send(user, noti); + } else if (userSnsNotiOpt == SnsType.SLACK) { + slackbotService.send(user, noti); + } else if (userSnsNotiOpt == SnsType.BOTH) { + notiMailSender.send(user, noti); + slackbotService.send(user, noti); + } + } } diff --git a/src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java b/src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java index 4e04b1c62..cf441c614 100644 --- a/src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java +++ b/src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java @@ -1,55 +1,56 @@ package com.gg.server.domain.noti.service.sns; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; + +import org.springframework.mail.javamail.JavaMailSender; +import org.springframework.mail.javamail.MimeMessageHelper; +import org.springframework.stereotype.Component; + import com.gg.server.domain.noti.data.Noti; import com.gg.server.domain.noti.dto.UserNotiDto; import com.gg.server.domain.noti.service.NotiService; -import com.gg.server.domain.noti.service.SnsNotiService; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.utils.AsyncMailSender; + import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.mail.javamail.JavaMailSender; -import org.springframework.mail.javamail.MimeMessageHelper; -import org.springframework.stereotype.Component; - -import javax.mail.MessagingException; -import javax.mail.internet.MimeMessage; @Component @RequiredArgsConstructor @Slf4j public class NotiMailSender { - private final JavaMailSender javaMailSender; - private final AsyncMailSender asyncMailSender; - private final NotiService notiService; + private final JavaMailSender javaMailSender; + private final AsyncMailSender asyncMailSender; + private final NotiService notiService; - public void send(UserNotiDto user, Noti noti) { - MimeMessage message = javaMailSender.createMimeMessage(); - MimeMessageHelper helper = new MimeMessageHelper(message); - try { - helper.setSubject("핑퐁요정🧚으로부터 도착한 편지"); - log.info(user.getEmail()); - helper.setTo(user.getEmail()); - helper.setText(notiService.getMessage(noti)); - } catch (MessagingException e) { - log.error("MessagingException message = {}", e.getMessage()); - } - log.info("Email send {}", user.getUserId()); - asyncMailSender.send(message); - } + public void send(UserNotiDto user, Noti noti) { + MimeMessage message = javaMailSender.createMimeMessage(); + MimeMessageHelper helper = new MimeMessageHelper(message); + try { + helper.setSubject("핑퐁요정🧚으로부터 도착한 편지"); + log.info(user.getEmail()); + helper.setTo(user.getEmail()); + helper.setText(notiService.getMessage(noti)); + } catch (MessagingException e) { + log.error("MessagingException message = {}", e.getMessage()); + } + log.info("Email send {}", user.getUserId()); + asyncMailSender.send(message); + } - public void send(UserDto user, Noti noti) { - MimeMessage message = javaMailSender.createMimeMessage(); - MimeMessageHelper helper = new MimeMessageHelper(message); - try { - helper.setSubject("핑퐁요정🧚으로부터 도착한 편지"); - log.info(user.getEMail()); - helper.setTo(user.getEMail()); - helper.setText(notiService.getMessage(noti)); - } catch (MessagingException e) { - log.error("MessagingException message = {}", e.getMessage()); - } - log.info("Email send {}", user.getId()); - asyncMailSender.send(message); - } + public void send(UserDto user, Noti noti) { + MimeMessage message = javaMailSender.createMimeMessage(); + MimeMessageHelper helper = new MimeMessageHelper(message); + try { + helper.setSubject("핑퐁요정🧚으로부터 도착한 편지"); + log.info(user.getEMail()); + helper.setTo(user.getEMail()); + helper.setText(notiService.getMessage(noti)); + } catch (MessagingException e) { + log.error("MessagingException message = {}", e.getMessage()); + } + log.info("Email send {}", user.getId()); + asyncMailSender.send(message); + } } diff --git a/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java b/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java index 76d77ed76..8f3985b9d 100644 --- a/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java +++ b/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java @@ -1,5 +1,24 @@ package com.gg.server.domain.noti.service.sns; +import static com.gg.server.domain.noti.service.sns.SlackbotUtils.*; + +import java.util.HashMap; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.gg.server.domain.noti.data.Noti; @@ -9,150 +28,141 @@ import com.gg.server.domain.noti.exception.SlackUserGetFailedException; import com.gg.server.domain.noti.service.NotiService; import com.gg.server.domain.user.dto.UserDto; + import lombok.Getter; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.http.*; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import java.util.HashMap; -import java.util.Map; - -import static com.gg.server.domain.noti.service.sns.SlackbotUtils.*; @Component @Slf4j public class SlackbotService { - @Value("${slack.xoxbToken}") - private String authenticationToken; - - private final RestTemplate restTemplate; - private final ObjectMapper objectMapper; - private final NotiService notiService; - public SlackbotService(RestTemplateBuilder builder, ObjectMapper objectMapper, NotiService notiService) { - this.restTemplate = builder.build(); - this.objectMapper = objectMapper; - this.notiService = notiService; - } - - private String getSlackUserId(String intraId) throws SlackUserGetFailedException { - String userEmail = intraId + intraEmailSuffix; - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - headers.add(HttpHeaders.AUTHORIZATION, authenticationPrefix + authenticationToken); - - MultiValueMap parameters = new LinkedMultiValueMap<>(); - parameters.add("email", userEmail); - - HttpEntity> request = new HttpEntity<>(parameters, headers); - - ResponseEntity responseEntity = restTemplate - .exchange(userIdGetUrl, HttpMethod.POST, request, SlackUserInfoResponse.class); - if (!responseEntity.getBody().ok) - throw new SlackUserGetFailedException(); - return responseEntity.getBody().user.id; - } - - private String getDmChannelId(String slackUserId) throws SlackJsonParseException { - HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.add(HttpHeaders.AUTHORIZATION, - authenticationPrefix + authenticationToken); - httpHeaders.setContentType(MediaType.APPLICATION_JSON); - - Map map = new HashMap<>(); - map.put("users", slackUserId); - String contentBody = null; - try { - contentBody = objectMapper.writeValueAsString(map); - } catch (JsonProcessingException e) { - throw new SlackJsonParseException(); - } - - HttpEntity entity = new HttpEntity<>(contentBody, httpHeaders); - - ResponseEntity responseEntity = restTemplate - .exchange(conversationsUrl, HttpMethod.POST, entity, ConversationResponse.class); - if(!responseEntity.getBody().ok) { - log.error("fail to get user dm channel id"); - throw new SlackUserGetFailedException(); - } - return responseEntity.getBody().channel.id; - } - - @Async("asyncExecutor") - public void send(UserNotiDto user, Noti noti) { - log.info("slack alarm send"); - try { - startSendNoti(user.getIntraId(), noti); - } catch (SlackSendException e) { - log.error("SlackSendException message = {}", e.getMessage()); - } - } - - @Async("asyncExecutor") - public void send(UserDto user, Noti noti) { - log.info("slack alarm send"); - try { - startSendNoti(user.getIntraId(), noti); - } catch (SlackSendException e) { - log.error("SlackSendException message = {}", e.getMessage()); - } - } - - private void startSendNoti(String intraId, Noti noti) throws SlackSendException { - String slackUserId = getSlackUserId(intraId); - String slackChannelId = getDmChannelId(slackUserId); - String message = notiService.getMessage(noti); - - HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.add(HttpHeaders.AUTHORIZATION, - authenticationPrefix + authenticationToken); - httpHeaders.setContentType(MediaType.APPLICATION_JSON); - - Map map = new HashMap<>(); - map.put("channel",slackChannelId); - map.put("text", message); - String contentBody = null; - try { - contentBody = objectMapper.writeValueAsString(map); - } catch (JsonProcessingException e) { - log.error("start send Slack Noti", e); - throw new SlackJsonParseException(); - } - - HttpEntity entity = new HttpEntity<>(contentBody, httpHeaders); - - ResponseEntity respEntity = restTemplate - .exchange(sendMessageUrl, HttpMethod.POST, entity, String.class); - if(respEntity.getStatusCode() != HttpStatus.OK) - throw new SlackSendException(); - } - - @Getter - static class ConversationResponse { - private Boolean ok; - private Channel channel; - - @Getter - static class Channel { - private String id; - } - - } - - @Getter - static class SlackUserInfoResponse { - private Boolean ok; - private SlackUser user; - - @Getter - static class SlackUser{ - private String id; - } - } + @Value("${slack.xoxbToken}") + private String authenticationToken; + + private final RestTemplate restTemplate; + private final ObjectMapper objectMapper; + private final NotiService notiService; + + public SlackbotService(RestTemplateBuilder builder, ObjectMapper objectMapper, NotiService notiService) { + this.restTemplate = builder.build(); + this.objectMapper = objectMapper; + this.notiService = notiService; + } + + private String getSlackUserId(String intraId) throws SlackUserGetFailedException { + String userEmail = intraId + intraEmailSuffix; + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + headers.add(HttpHeaders.AUTHORIZATION, authenticationPrefix + authenticationToken); + + MultiValueMap parameters = new LinkedMultiValueMap<>(); + parameters.add("email", userEmail); + + HttpEntity> request = new HttpEntity<>(parameters, headers); + + ResponseEntity responseEntity = restTemplate + .exchange(userIdGetUrl, HttpMethod.POST, request, SlackUserInfoResponse.class); + if (!responseEntity.getBody().ok) { + throw new SlackUserGetFailedException(); + } + return responseEntity.getBody().user.id; + } + + private String getDmChannelId(String slackUserId) throws SlackJsonParseException { + HttpHeaders httpHeaders = new HttpHeaders(); + httpHeaders.add(HttpHeaders.AUTHORIZATION, + authenticationPrefix + authenticationToken); + httpHeaders.setContentType(MediaType.APPLICATION_JSON); + + Map map = new HashMap<>(); + map.put("users", slackUserId); + String contentBody = null; + try { + contentBody = objectMapper.writeValueAsString(map); + } catch (JsonProcessingException e) { + throw new SlackJsonParseException(); + } + + HttpEntity entity = new HttpEntity<>(contentBody, httpHeaders); + + ResponseEntity responseEntity = restTemplate + .exchange(conversationsUrl, HttpMethod.POST, entity, ConversationResponse.class); + if (!responseEntity.getBody().ok) { + log.error("fail to get user dm channel id"); + throw new SlackUserGetFailedException(); + } + return responseEntity.getBody().channel.id; + } + + @Async("asyncExecutor") + public void send(UserNotiDto user, Noti noti) { + log.info("slack alarm send"); + try { + startSendNoti(user.getIntraId(), noti); + } catch (SlackSendException e) { + log.error("SlackSendException message = {}", e.getMessage()); + } + } + + @Async("asyncExecutor") + public void send(UserDto user, Noti noti) { + log.info("slack alarm send"); + try { + startSendNoti(user.getIntraId(), noti); + } catch (SlackSendException e) { + log.error("SlackSendException message = {}", e.getMessage()); + } + } + + private void startSendNoti(String intraId, Noti noti) throws SlackSendException { + String slackUserId = getSlackUserId(intraId); + String slackChannelId = getDmChannelId(slackUserId); + String message = notiService.getMessage(noti); + + HttpHeaders httpHeaders = new HttpHeaders(); + httpHeaders.add(HttpHeaders.AUTHORIZATION, + authenticationPrefix + authenticationToken); + httpHeaders.setContentType(MediaType.APPLICATION_JSON); + + Map map = new HashMap<>(); + map.put("channel", slackChannelId); + map.put("text", message); + String contentBody = null; + try { + contentBody = objectMapper.writeValueAsString(map); + } catch (JsonProcessingException e) { + log.error("start send Slack Noti", e); + throw new SlackJsonParseException(); + } + + HttpEntity entity = new HttpEntity<>(contentBody, httpHeaders); + + ResponseEntity respEntity = restTemplate + .exchange(sendMessageUrl, HttpMethod.POST, entity, String.class); + if (respEntity.getStatusCode() != HttpStatus.OK) { + throw new SlackSendException(); + } + } + + @Getter + static class ConversationResponse { + private Boolean ok; + private Channel channel; + + @Getter + static class Channel { + private String id; + } + + } + + @Getter + static class SlackUserInfoResponse { + private Boolean ok; + private SlackUser user; + + @Getter + static class SlackUser { + private String id; + } + } } diff --git a/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotUtils.java b/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotUtils.java index 747824b1f..5580a656d 100644 --- a/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotUtils.java +++ b/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotUtils.java @@ -1,9 +1,9 @@ package com.gg.server.domain.noti.service.sns; public class SlackbotUtils { - public static String conversationsUrl = "https://slack.com/api/conversations.open"; - public static String sendMessageUrl = "https://slack.com/api/chat.postMessage"; - public static String userIdGetUrl = "https://slack.com/api/users.lookupByEmail"; - public static String authenticationPrefix = "Bearer "; - public static String intraEmailSuffix = "@student.42seoul.kr"; + public static String conversationsUrl = "https://slack.com/api/conversations.open"; + public static String sendMessageUrl = "https://slack.com/api/chat.postMessage"; + public static String userIdGetUrl = "https://slack.com/api/users.lookupByEmail"; + public static String authenticationPrefix = "Bearer "; + public static String intraEmailSuffix = "@student.42seoul.kr"; } diff --git a/src/main/java/com/gg/server/domain/noti/type/NotiType.java b/src/main/java/com/gg/server/domain/noti/type/NotiType.java index 5cca542d7..a74fe2bfb 100644 --- a/src/main/java/com/gg/server/domain/noti/type/NotiType.java +++ b/src/main/java/com/gg/server/domain/noti/type/NotiType.java @@ -1,46 +1,46 @@ package com.gg.server.domain.noti.type; +import java.util.Arrays; +import java.util.Locale; + import com.fasterxml.jackson.annotation.JsonCreator; + import lombok.Getter; import lombok.RequiredArgsConstructor; -import java.util.Arrays; -import java.util.Locale; - @Getter @RequiredArgsConstructor public enum NotiType { - MATCHED("matched", "매칭이 성사되었퐁."), - CANCELEDBYMAN("canceledbyman", "매칭이 취소되었퐁."), - CANCELEDBYTIME("canceledbytime", "매칭이 상대 없음으로 취소되었퐁."), - IMMINENT("imminent", "매치가 곧 시작될퐁."), - ANNOUNCE("announce", "공지사항이 도착했퐁."), - GIFT("gift", "새로운 선물이 도착했퐁."), - TOURNAMENT_CANCELED("tournament canceled", "참가 신청한 토너먼트가 신청 인원 미달로 취소되었퐁."), - TOURNAMENT_GAME_MATCHED("tournament game matched", "토너먼트 게임이 성사되었퐁."), - TOURNAMENT_GAME_CANCELED("tournament game canceled", "토너먼트 매칭이 취소되었퐁."); - - private final String code; - private final String message; - - public static NotiType of(String code) { - return Arrays.stream(NotiType.values()) - .filter(notiType-> notiType.getCode().equals(code)) - .findAny() - .orElse(ANNOUNCE); - } - - @JsonCreator - public static NotiType getEnumFromValue(String value) { - for(NotiType e : values()) { - if(e.code.equals(value)) { - return e; - } - else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { - return e; - } - } - return null; - } + MATCHED("matched", "매칭이 성사되었퐁."), + CANCELEDBYMAN("canceledbyman", "매칭이 취소되었퐁."), + CANCELEDBYTIME("canceledbytime", "매칭이 상대 없음으로 취소되었퐁."), + IMMINENT("imminent", "매치가 곧 시작될퐁."), + ANNOUNCE("announce", "공지사항이 도착했퐁."), + GIFT("gift", "새로운 선물이 도착했퐁."), + TOURNAMENT_CANCELED("tournament canceled", "참가 신청한 토너먼트가 신청 인원 미달로 취소되었퐁."), + TOURNAMENT_GAME_MATCHED("tournament game matched", "토너먼트 게임이 성사되었퐁."), + TOURNAMENT_GAME_CANCELED("tournament game canceled", "토너먼트 매칭이 취소되었퐁."); + + private final String code; + private final String message; + + public static NotiType of(String code) { + return Arrays.stream(NotiType.values()) + .filter(notiType -> notiType.getCode().equals(code)) + .findAny() + .orElse(ANNOUNCE); + } + + @JsonCreator + public static NotiType getEnumFromValue(String value) { + for (NotiType e : values()) { + if (e.code.equals(value)) { + return e; + } else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { + return e; + } + } + return null; + } } diff --git a/src/main/java/com/gg/server/domain/pchange/data/PChange.java b/src/main/java/com/gg/server/domain/pchange/data/PChange.java index ce47f4107..cf6bc3811 100644 --- a/src/main/java/com/gg/server/domain/pchange/data/PChange.java +++ b/src/main/java/com/gg/server/domain/pchange/data/PChange.java @@ -1,68 +1,79 @@ -package com.gg.server.domain.pchange.data; - -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.user.data.User; -import com.gg.server.global.utils.BaseTimeEntity; -import lombok.*; - -import javax.persistence.*; -import javax.validation.constraints.NotNull; - -@NoArgsConstructor -@AllArgsConstructor -@Entity -@Getter -public class PChange extends BaseTimeEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "game_id") - private Game game; - - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - @NotNull - @Column(name = "ppp_result") - private Integer pppResult; - - @NotNull - @Column(name = "exp") - private Integer exp; - - @NotNull - @Column(name = "is_checked") - private Boolean isChecked; - - public PChange(Game game, User user, Integer pppResult, Boolean isChecked) { - this.game = game; - this.user = user; - this.pppResult = pppResult; - this.exp = user.getTotalExp(); - this.isChecked = isChecked; - } - - public void checkPChange() { - this.isChecked = true; - } - public void updatePPP(Integer ppp) { - this.pppResult = ppp; - } - - @Override - public String toString() { - return "PChange{" + - "id=" + id + - ", game=" + game + - ", user=" + user + - ", pppResult=" + pppResult + - ", exp=" + exp + - ", isChecked=" + isChecked + - '}'; - } -} +package com.gg.server.domain.pchange.data; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.validation.constraints.NotNull; + +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.user.data.User; +import com.gg.server.global.utils.BaseTimeEntity; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Entity +@Getter +public class PChange extends BaseTimeEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "game_id") + private Game game; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @NotNull + @Column(name = "ppp_result") + private Integer pppResult; + + @NotNull + @Column(name = "exp") + private Integer exp; + + @NotNull + @Column(name = "is_checked") + private Boolean isChecked; + + public PChange(Game game, User user, Integer pppResult, Boolean isChecked) { + this.game = game; + this.user = user; + this.pppResult = pppResult; + this.exp = user.getTotalExp(); + this.isChecked = isChecked; + } + + public void checkPChange() { + this.isChecked = true; + } + + public void updatePPP(Integer ppp) { + this.pppResult = ppp; + } + + @Override + public String toString() { + return "PChange{" + + "id=" + id + + ", game=" + game + + ", user=" + user + + ", pppResult=" + pppResult + + ", exp=" + exp + + ", isChecked=" + isChecked + + '}'; + } +} diff --git a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepository.java b/src/main/java/com/gg/server/domain/pchange/data/PChangeRepository.java index d3b72b09f..9cb907299 100644 --- a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepository.java +++ b/src/main/java/com/gg/server/domain/pchange/data/PChangeRepository.java @@ -1,26 +1,32 @@ package com.gg.server.domain.pchange.data; -import com.gg.server.domain.game.type.Mode; +import java.util.List; +import java.util.Optional; + import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import java.util.List; -import java.util.Optional; +import com.gg.server.domain.game.type.Mode; + +public interface PChangeRepository extends JpaRepository, PChangeRepositoryCustom { -public interface PChangeRepository extends JpaRepository , PChangeRepositoryCustom{ + @Query(value = "SELECT pc FROM PChange pc join fetch pc.user " + + "WHERE pc.user.intraId LIKE %:intraId% " + + "order by pc.user.intraId asc, pc.id desc") + List findPChangesByUser_IntraId(@Param("intraId") String intraId); - @Query(value = "SELECT pc FROM PChange pc join fetch pc.user WHERE pc.user.intraId LIKE %:intraId% order by pc.user.intraId asc, pc.id desc") - List findPChangesByUser_IntraId(@Param("intraId") String intraId); + @Query(value = "SELECT pc FROM PChange pc join fetch pc.user WHERE pc.user.id =:userId order by pc.id desc") + List findAllByUserId(@Param("userId") Long userId); - @Query(value = "SELECT pc FROM PChange pc join fetch pc.user WHERE pc.user.id =:userId order by pc.id desc") - List findAllByUserId(@Param("userId") Long userId); + @Query(value = "SELECT pc FROM PChange pc join fetch pc.user join fetch pc.game " + + "WHERE pc.user.id = :userId and pc.game.mode in :modes " + + "order by pc.id desc") + List findAllByUserIdGameModeIn(@Param("userId") Long userId, @Param("modes") List modes); - @Query(value = "SELECT pc FROM PChange pc join fetch pc.user join fetch pc.game WHERE pc.user.id = :userId and pc.game.mode in :modes order by pc.id desc") - List findAllByUserIdGameModeIn(@Param("userId") Long userId, @Param("modes") List modes); - Optional findByUserIdAndGameId(Long userId, Long gameId); + Optional findByUserIdAndGameId(Long userId, Long gameId); - Optional findPChangeByUserIdAndGameId(Long userId, Long gameId); + Optional findPChangeByUserIdAndGameId(Long userId, Long gameId); - List findPChangesByGameId(Long gameId); + List findPChangesByGameId(Long gameId); } diff --git a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryCustom.java b/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryCustom.java index 9f2e132d1..0b2bff37b 100644 --- a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryCustom.java +++ b/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryCustom.java @@ -3,7 +3,9 @@ import java.util.List; public interface PChangeRepositoryCustom { - List findPChangesHistory(String intraId, Long seasonId); - List findExpHistory(Long userId, Long gameId); - List findPPPHistory(Long userId, Long gameId, Long seasonId); + List findPChangesHistory(String intraId, Long seasonId); + + List findExpHistory(Long userId, Long gameId); + + List findPPPHistory(Long userId, Long gameId, Long seasonId); } diff --git a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryImpl.java b/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryImpl.java index 7b4c79fd9..ad51b95ed 100644 --- a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryImpl.java +++ b/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryImpl.java @@ -1,53 +1,57 @@ package com.gg.server.domain.pchange.data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Repository; +import java.util.List; import javax.persistence.EntityManager; -import java.util.List; + +import org.springframework.stereotype.Repository; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; @Repository @RequiredArgsConstructor @Slf4j -public class PChangeRepositoryImpl implements PChangeRepositoryCustom{ - private final EntityManager em; - @Override - public List findPChangesHistory(String intraId, Long seasonId) { - String sql = "select p from PChange p join p.game g join p.user u join g.season s where u.intraId = " + - ":intra_id and s.id = :season_id and g.mode = 'RANK' order by p.createdAt desc"; - return em.createQuery(sql, PChange.class) - .setParameter("intra_id", intraId) - .setParameter("season_id", seasonId) - .setFirstResult(0) - .setMaxResults(10) - .getResultList(); - } - - @Override - public List findExpHistory(Long userId, Long gameId) { - String sql = "select p from PChange p join p.game g where p.user.id = " + - ":userId and p.id <= (select p2.id from PChange p2 where p2.game.id = :gameId and p2.user.id = :userId) order by p.createdAt desc"; - return em.createQuery(sql, PChange.class) - .setParameter("userId", userId) - .setParameter("gameId", gameId) - .setFirstResult(0) - .setMaxResults(2) - .getResultList(); - } - - @Override - public List findPPPHistory(Long userId, Long gameId, Long seasonId) { - String sql = "select p from PChange p join p.game g join g.season s where p.user.id = " + - ":userId and p.id <= (select p2.id from PChange p2 where p2.game.id = :gameId and p2.user.id =:userId) " + - "and p.game.mode = 'RANK' and s.id = :season_id " + - "order by p.createdAt desc"; - return em.createQuery(sql, PChange.class) - .setParameter("userId", userId) - .setParameter("gameId", gameId) - .setParameter("season_id", seasonId) - .setFirstResult(0) - .setMaxResults(2) - .getResultList(); - } +public class PChangeRepositoryImpl implements PChangeRepositoryCustom { + private final EntityManager em; + + @Override + public List findPChangesHistory(String intraId, Long seasonId) { + String sql = "select p from PChange p join p.game g join p.user u join g.season s where u.intraId = " + + ":intra_id and s.id = :season_id and g.mode = 'RANK' order by p.createdAt desc"; + return em.createQuery(sql, PChange.class) + .setParameter("intra_id", intraId) + .setParameter("season_id", seasonId) + .setFirstResult(0) + .setMaxResults(10) + .getResultList(); + } + + @Override + public List findExpHistory(Long userId, Long gameId) { + String sql = "select p from PChange p join p.game g where p.user.id = " + + ":userId and p.id <= (select p2.id from PChange p2 where p2.game.id = :gameId and p2.user.id = :userId) " + + "order by p.createdAt desc"; + return em.createQuery(sql, PChange.class) + .setParameter("userId", userId) + .setParameter("gameId", gameId) + .setFirstResult(0) + .setMaxResults(2) + .getResultList(); + } + + @Override + public List findPPPHistory(Long userId, Long gameId, Long seasonId) { + String sql = "select p from PChange p join p.game g join g.season s where p.user.id = " + + ":userId and p.id <= (select p2.id from PChange p2 where p2.game.id = :gameId and p2.user.id =:userId) " + + "and p.game.mode = 'RANK' and s.id = :season_id " + + "order by p.createdAt desc"; + return em.createQuery(sql, PChange.class) + .setParameter("userId", userId) + .setParameter("gameId", gameId) + .setParameter("season_id", seasonId) + .setFirstResult(0) + .setMaxResults(2) + .getResultList(); + } } diff --git a/src/main/java/com/gg/server/domain/pchange/exception/PChangeNotExistException.java b/src/main/java/com/gg/server/domain/pchange/exception/PChangeNotExistException.java index 1f3d00e77..c3d036011 100644 --- a/src/main/java/com/gg/server/domain/pchange/exception/PChangeNotExistException.java +++ b/src/main/java/com/gg/server/domain/pchange/exception/PChangeNotExistException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class PChangeNotExistException extends NotExistException { - public PChangeNotExistException() { - super("이전 exp 히스토리가 존재하지 않습니다.", ErrorCode.PCHANGE_NOT_FOUND); - } + public PChangeNotExistException() { + super("이전 exp 히스토리가 존재하지 않습니다.", ErrorCode.PCHANGE_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/pchange/service/PChangeService.java b/src/main/java/com/gg/server/domain/pchange/service/PChangeService.java index 968f2755a..211992afa 100644 --- a/src/main/java/com/gg/server/domain/pchange/service/PChangeService.java +++ b/src/main/java/com/gg/server/domain/pchange/service/PChangeService.java @@ -1,39 +1,41 @@ -package com.gg.server.domain.pchange.service; - -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.pchange.data.PChange; -import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.user.data.User; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.pchange.exception.PChangeNotExistException; -import java.util.List; - -@Service -@RequiredArgsConstructor -public class PChangeService { - private final PChangeRepository pChangeRepository; - - @Transactional - public void addPChange(Game game, User user, Integer pppResult, Boolean isChecked) { - pChangeRepository.save(new PChange(game, user, pppResult, isChecked)); - } - - public List findExpChangeHistory(Long gameId, Long userId) { - List pChanges = pChangeRepository.findExpHistory(userId, gameId); - if (pChanges.isEmpty()) { - throw new PChangeNotExistException(); - } - return pChanges; - } - - public List findPPPChangeHistory(Long gameId, Long userId, Long seasonId) { - List pChanges = pChangeRepository.findPPPHistory(userId, gameId, seasonId); - if (pChanges.isEmpty()) { - throw new PChangeNotExistException(); - } - return pChanges; - } -} +package com.gg.server.domain.pchange.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.pchange.data.PChange; +import com.gg.server.domain.pchange.data.PChangeRepository; +import com.gg.server.domain.pchange.exception.PChangeNotExistException; +import com.gg.server.domain.user.data.User; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class PChangeService { + private final PChangeRepository pChangeRepository; + + @Transactional + public void addPChange(Game game, User user, Integer pppResult, Boolean isChecked) { + pChangeRepository.save(new PChange(game, user, pppResult, isChecked)); + } + + public List findExpChangeHistory(Long gameId, Long userId) { + List pChanges = pChangeRepository.findExpHistory(userId, gameId); + if (pChanges.isEmpty()) { + throw new PChangeNotExistException(); + } + return pChanges; + } + + public List findPPPChangeHistory(Long gameId, Long userId, Long seasonId) { + List pChanges = pChangeRepository.findPPPHistory(userId, gameId, seasonId); + if (pChanges.isEmpty()) { + throw new PChangeNotExistException(); + } + return pChanges; + } +} diff --git a/src/main/java/com/gg/server/domain/penalty/data/Penalty.java b/src/main/java/com/gg/server/domain/penalty/data/Penalty.java index f187edfb4..566cc7494 100644 --- a/src/main/java/com/gg/server/domain/penalty/data/Penalty.java +++ b/src/main/java/com/gg/server/domain/penalty/data/Penalty.java @@ -1,54 +1,65 @@ -package com.gg.server.domain.penalty.data; - -import com.gg.server.domain.penalty.type.PenaltyType; -import com.gg.server.domain.user.data.User; -import com.gg.server.global.utils.BaseTimeEntity; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import javax.persistence.*; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@Entity -public class Penalty extends BaseTimeEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - @NotNull - @Column(name = "penalty_type", length = 20) - @Enumerated(EnumType.STRING) - private PenaltyType type; - - @Column(name = "message", length = 100) - private String message; - - @NotNull - @Column(name = "start_time") - private LocalDateTime startTime; - - @NotNull - @Column(name = "penalty_time") - private Integer penaltyTime; - - public Penalty(User user, PenaltyType type, String message, LocalDateTime startTime, Integer penaltyTime) { - this.user = user; - this.type = type; - this.message = message; - this.startTime = startTime; - this.penaltyTime = penaltyTime; - } - - public void updateStartTime(LocalDateTime startTime) { - this.startTime = startTime; - } -} +package com.gg.server.domain.penalty.data; + +import java.time.LocalDateTime; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.validation.constraints.NotNull; + +import com.gg.server.domain.penalty.type.PenaltyType; +import com.gg.server.domain.user.data.User; +import com.gg.server.global.utils.BaseTimeEntity; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Entity +public class Penalty extends BaseTimeEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @NotNull + @Column(name = "penalty_type", length = 20) + @Enumerated(EnumType.STRING) + private PenaltyType type; + + @Column(name = "message", length = 100) + private String message; + + @NotNull + @Column(name = "start_time") + private LocalDateTime startTime; + + @NotNull + @Column(name = "penalty_time") + private Integer penaltyTime; + + public Penalty(User user, PenaltyType type, String message, LocalDateTime startTime, Integer penaltyTime) { + this.user = user; + this.type = type; + this.message = message; + this.startTime = startTime; + this.penaltyTime = penaltyTime; + } + + public void updateStartTime(LocalDateTime startTime) { + this.startTime = startTime; + } +} diff --git a/src/main/java/com/gg/server/domain/penalty/data/PenaltyRepository.java b/src/main/java/com/gg/server/domain/penalty/data/PenaltyRepository.java index f68ba781f..69efc952f 100644 --- a/src/main/java/com/gg/server/domain/penalty/data/PenaltyRepository.java +++ b/src/main/java/com/gg/server/domain/penalty/data/PenaltyRepository.java @@ -1,6 +1,5 @@ package com.gg.server.domain.penalty.data; - import org.springframework.data.jpa.repository.JpaRepository; public interface PenaltyRepository extends JpaRepository { diff --git a/src/main/java/com/gg/server/domain/penalty/exception/PenaltyExpiredException.java b/src/main/java/com/gg/server/domain/penalty/exception/PenaltyExpiredException.java index 3670e1d4c..5a909074d 100644 --- a/src/main/java/com/gg/server/domain/penalty/exception/PenaltyExpiredException.java +++ b/src/main/java/com/gg/server/domain/penalty/exception/PenaltyExpiredException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.ExpiredException; public class PenaltyExpiredException extends ExpiredException { - public PenaltyExpiredException() { - super("이미 만료된 패널티입니다.", ErrorCode.PENALTY_EXPIRED); - } + public PenaltyExpiredException() { + super("이미 만료된 패널티입니다.", ErrorCode.PENALTY_EXPIRED); + } } diff --git a/src/main/java/com/gg/server/domain/penalty/exception/PenaltyNotFoundException.java b/src/main/java/com/gg/server/domain/penalty/exception/PenaltyNotFoundException.java index b0440907f..5e69d28cb 100644 --- a/src/main/java/com/gg/server/domain/penalty/exception/PenaltyNotFoundException.java +++ b/src/main/java/com/gg/server/domain/penalty/exception/PenaltyNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class PenaltyNotFoundException extends NotExistException { - public PenaltyNotFoundException() { - super("해당 패널티가 없습니다.", ErrorCode.PENALTY_NOT_FOUND); - } + public PenaltyNotFoundException() { + super("해당 패널티가 없습니다.", ErrorCode.PENALTY_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/penalty/exception/RedisPenaltyUserNotFoundException.java b/src/main/java/com/gg/server/domain/penalty/exception/RedisPenaltyUserNotFoundException.java index 7ed319666..cbc585251 100644 --- a/src/main/java/com/gg/server/domain/penalty/exception/RedisPenaltyUserNotFoundException.java +++ b/src/main/java/com/gg/server/domain/penalty/exception/RedisPenaltyUserNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class RedisPenaltyUserNotFoundException extends NotExistException { - public RedisPenaltyUserNotFoundException() { - super("Redis에 Penalty User 데이터가 없습니다.", ErrorCode.REDIS_PENALTY_USER_NOT_FOUND); - } + public RedisPenaltyUserNotFoundException() { + super("Redis에 Penalty User 데이터가 없습니다.", ErrorCode.REDIS_PENALTY_USER_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/penalty/redis/PenaltyUserRedisRepository.java b/src/main/java/com/gg/server/domain/penalty/redis/PenaltyUserRedisRepository.java index efaf3cffc..986aee9f9 100644 --- a/src/main/java/com/gg/server/domain/penalty/redis/PenaltyUserRedisRepository.java +++ b/src/main/java/com/gg/server/domain/penalty/redis/PenaltyUserRedisRepository.java @@ -1,30 +1,31 @@ package com.gg.server.domain.penalty.redis; -import com.gg.server.admin.penalty.type.PenaltyKey; import java.time.Duration; import java.time.LocalDateTime; -import java.util.List; import java.util.Optional; -import java.util.Set; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import lombok.RequiredArgsConstructor; + import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; +import com.gg.server.admin.penalty.type.PenaltyKey; + +import lombok.RequiredArgsConstructor; + @Repository @RequiredArgsConstructor public class PenaltyUserRedisRepository { - private final RedisTemplate redisTemplate; + private final RedisTemplate redisTemplate; + + public void addPenaltyUser(RedisPenaltyUser penaltyUser, LocalDateTime releaseTime) { + LocalDateTime now = LocalDateTime.now(); + Duration duration = Duration.between(now, releaseTime); + redisTemplate.opsForValue().set(PenaltyKey.USER_ADMIN + penaltyUser.getIntraId(), penaltyUser, + duration.getSeconds(), TimeUnit.SECONDS); + } - public void addPenaltyUser(RedisPenaltyUser penaltyUser, LocalDateTime releaseTime) { - LocalDateTime now = LocalDateTime.now(); - Duration duration = Duration.between(now, releaseTime); - redisTemplate.opsForValue().set(PenaltyKey.USER_ADMIN + penaltyUser.getIntraId(), penaltyUser, - duration.getSeconds(), TimeUnit.SECONDS); - } - public Optional findByIntraId(String intraId) { - RedisPenaltyUser penaltyUser = redisTemplate.opsForValue().get(PenaltyKey.USER_ADMIN + intraId); - return Optional.ofNullable(penaltyUser); - } + public Optional findByIntraId(String intraId) { + RedisPenaltyUser penaltyUser = redisTemplate.opsForValue().get(PenaltyKey.USER_ADMIN + intraId); + return Optional.ofNullable(penaltyUser); + } } diff --git a/src/main/java/com/gg/server/domain/penalty/redis/RedisPenaltyUser.java b/src/main/java/com/gg/server/domain/penalty/redis/RedisPenaltyUser.java index eb12c011c..a688fb428 100644 --- a/src/main/java/com/gg/server/domain/penalty/redis/RedisPenaltyUser.java +++ b/src/main/java/com/gg/server/domain/penalty/redis/RedisPenaltyUser.java @@ -1,42 +1,44 @@ package com.gg.server.domain.penalty.redis; +import java.time.LocalDateTime; + +import javax.persistence.Id; + import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import java.time.LocalDateTime; -import javax.persistence.Id; + import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.RequiredArgsConstructor; @Getter @NoArgsConstructor public class RedisPenaltyUser { - @Id - private String id; - private String intraId; - private Integer penaltyTime; - @JsonSerialize(using = LocalDateTimeSerializer.class) - @JsonDeserialize(using = LocalDateTimeDeserializer.class) - private LocalDateTime releaseTime; - - @JsonSerialize(using = LocalDateTimeSerializer.class) - @JsonDeserialize(using = LocalDateTimeDeserializer.class) - private LocalDateTime startTime; - private String reason; - - public RedisPenaltyUser(String intraId, Integer penaltyTime, LocalDateTime releaseTime, LocalDateTime startTime, - String reason) { - this.intraId = intraId; - this.penaltyTime = penaltyTime; - this.releaseTime = releaseTime; - this.startTime = startTime; - this.reason = reason; - } - - public void updateReleaseTime(LocalDateTime releaseTime, Integer penaltyTime) { - this.releaseTime = releaseTime; - this.penaltyTime = penaltyTime; - } + @Id + private String id; + private String intraId; + private Integer penaltyTime; + @JsonSerialize(using = LocalDateTimeSerializer.class) + @JsonDeserialize(using = LocalDateTimeDeserializer.class) + private LocalDateTime releaseTime; + + @JsonSerialize(using = LocalDateTimeSerializer.class) + @JsonDeserialize(using = LocalDateTimeDeserializer.class) + private LocalDateTime startTime; + private String reason; + + public RedisPenaltyUser(String intraId, Integer penaltyTime, LocalDateTime releaseTime, LocalDateTime startTime, + String reason) { + this.intraId = intraId; + this.penaltyTime = penaltyTime; + this.releaseTime = releaseTime; + this.startTime = startTime; + this.reason = reason; + } + + public void updateReleaseTime(LocalDateTime releaseTime, Integer penaltyTime) { + this.releaseTime = releaseTime; + this.penaltyTime = penaltyTime; + } } diff --git a/src/main/java/com/gg/server/domain/penalty/service/PenaltyService.java b/src/main/java/com/gg/server/domain/penalty/service/PenaltyService.java index ed680721d..1d6ea1280 100644 --- a/src/main/java/com/gg/server/domain/penalty/service/PenaltyService.java +++ b/src/main/java/com/gg/server/domain/penalty/service/PenaltyService.java @@ -1,53 +1,57 @@ -package com.gg.server.domain.penalty.service; - -import com.gg.server.domain.penalty.data.Penalty; -import com.gg.server.domain.penalty.data.PenaltyRepository; -import com.gg.server.domain.penalty.redis.PenaltyUserRedisRepository; -import com.gg.server.domain.penalty.redis.RedisPenaltyUser; -import com.gg.server.domain.penalty.type.PenaltyType; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.service.UserFindService; - -import java.time.LocalDateTime; -import java.util.Optional; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class PenaltyService { - private final PenaltyRepository penaltyRepository; - private final PenaltyUserRedisRepository penaltyUserRedisRepository; - private final UserFindService userFindService; - - /** - * penalty 1분 부여 - * **/ - public void givePenalty(UserDto userDto, Integer penaltyMinutes) { - - User user = userFindService.findUserById(userDto.getId()); - Optional redisPenaltyUser = penaltyUserRedisRepository - .findByIntraId(userDto.getIntraId()); - LocalDateTime releaseTime; - RedisPenaltyUser penaltyUser; - Penalty penalty; - LocalDateTime now = LocalDateTime.now(); - if (redisPenaltyUser.isPresent()) { - releaseTime = redisPenaltyUser.get().getReleaseTime().plusMinutes(penaltyMinutes); - penaltyUser = new RedisPenaltyUser(userDto.getIntraId(), redisPenaltyUser.get().getPenaltyTime() + penaltyMinutes, - releaseTime, redisPenaltyUser.get().getStartTime(), "[AUTO] 매칭 취소"); - penalty = new Penalty(user, PenaltyType.CANCEL, "[AUTO] 매칭 취소", redisPenaltyUser.get().getReleaseTime(), penaltyMinutes); - } else { - releaseTime = now.plusMinutes(penaltyMinutes); - penaltyUser = new RedisPenaltyUser(user.getIntraId(), penaltyMinutes, releaseTime, now, "[AUTO] 매칭 취소"); - penalty = new Penalty(user, PenaltyType.CANCEL, "[AUTO] 매칭 취소", now, penaltyMinutes); - } - penaltyRepository.save(penalty); - penaltyUserRedisRepository.addPenaltyUser(penaltyUser, releaseTime); - } - - public Boolean isPenaltyUser(String intraId) { - return penaltyUserRedisRepository.findByIntraId(intraId).isPresent(); - } -} +package com.gg.server.domain.penalty.service; + +import java.time.LocalDateTime; +import java.util.Optional; + +import org.springframework.stereotype.Service; + +import com.gg.server.domain.penalty.data.Penalty; +import com.gg.server.domain.penalty.data.PenaltyRepository; +import com.gg.server.domain.penalty.redis.PenaltyUserRedisRepository; +import com.gg.server.domain.penalty.redis.RedisPenaltyUser; +import com.gg.server.domain.penalty.type.PenaltyType; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.service.UserFindService; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class PenaltyService { + private final PenaltyRepository penaltyRepository; + private final PenaltyUserRedisRepository penaltyUserRedisRepository; + private final UserFindService userFindService; + + /** + * penalty 1분 부여 + * **/ + public void givePenalty(UserDto userDto, Integer penaltyMinutes) { + + User user = userFindService.findUserById(userDto.getId()); + Optional redisPenaltyUser = penaltyUserRedisRepository + .findByIntraId(userDto.getIntraId()); + LocalDateTime releaseTime; + RedisPenaltyUser penaltyUser; + Penalty penalty; + LocalDateTime now = LocalDateTime.now(); + if (redisPenaltyUser.isPresent()) { + releaseTime = redisPenaltyUser.get().getReleaseTime().plusMinutes(penaltyMinutes); + penaltyUser = new RedisPenaltyUser(userDto.getIntraId(), + redisPenaltyUser.get().getPenaltyTime() + penaltyMinutes, + releaseTime, redisPenaltyUser.get().getStartTime(), "[AUTO] 매칭 취소"); + penalty = new Penalty(user, PenaltyType.CANCEL, "[AUTO] 매칭 취소", redisPenaltyUser.get().getReleaseTime(), + penaltyMinutes); + } else { + releaseTime = now.plusMinutes(penaltyMinutes); + penaltyUser = new RedisPenaltyUser(user.getIntraId(), penaltyMinutes, releaseTime, now, "[AUTO] 매칭 취소"); + penalty = new Penalty(user, PenaltyType.CANCEL, "[AUTO] 매칭 취소", now, penaltyMinutes); + } + penaltyRepository.save(penalty); + penaltyUserRedisRepository.addPenaltyUser(penaltyUser, releaseTime); + } + + public Boolean isPenaltyUser(String intraId) { + return penaltyUserRedisRepository.findByIntraId(intraId).isPresent(); + } +} diff --git a/src/main/java/com/gg/server/domain/penalty/type/PenaltyType.java b/src/main/java/com/gg/server/domain/penalty/type/PenaltyType.java index 98f584803..b84d760a0 100644 --- a/src/main/java/com/gg/server/domain/penalty/type/PenaltyType.java +++ b/src/main/java/com/gg/server/domain/penalty/type/PenaltyType.java @@ -1,38 +1,38 @@ package com.gg.server.domain.penalty.type; +import java.util.Arrays; +import java.util.Locale; + import com.fasterxml.jackson.annotation.JsonCreator; + import lombok.Getter; import lombok.RequiredArgsConstructor; -import java.util.Arrays; -import java.util.Locale; - @Getter @RequiredArgsConstructor public enum PenaltyType { - NONE("none"), - NOSHOW("noshow"), - CANCEL("cancel"); + NONE("none"), + NOSHOW("noshow"), + CANCEL("cancel"); - private final String code; + private final String code; - public static PenaltyType of(String code) { - return Arrays.stream(PenaltyType.values()) - .filter(penaltyType-> penaltyType.getCode().equals(code)) - .findAny() - .orElse(NONE); - } + public static PenaltyType of(String code) { + return Arrays.stream(PenaltyType.values()) + .filter(penaltyType -> penaltyType.getCode().equals(code)) + .findAny() + .orElse(NONE); + } - @JsonCreator - public static PenaltyType getEnumFromValue(String value) { - for(PenaltyType e : values()) { - if(e.code.equals(value)) { - return e; - } - else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { - return e; - } - } - return null; - } + @JsonCreator + public static PenaltyType getEnumFromValue(String value) { + for (PenaltyType e : values()) { + if (e.code.equals(value)) { + return e; + } else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { + return e; + } + } + return null; + } } diff --git a/src/main/java/com/gg/server/domain/rank/controller/RankController.java b/src/main/java/com/gg/server/domain/rank/controller/RankController.java index 6fc5d3806..92cacd8c6 100644 --- a/src/main/java/com/gg/server/domain/rank/controller/RankController.java +++ b/src/main/java/com/gg/server/domain/rank/controller/RankController.java @@ -1,47 +1,52 @@ package com.gg.server.domain.rank.controller; +import javax.validation.Valid; + +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; import com.gg.server.domain.rank.dto.RankPageResponseDto; import com.gg.server.domain.rank.service.RankService; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.dto.PageRequestDto; import com.gg.server.global.utils.argumentresolver.Login; + import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.validation.Valid; @RestController @RequiredArgsConstructor @RequestMapping("/pingpong") public class RankController { - private final RankService rankService; - @GetMapping("/exp") - public ExpRankPageResponseDto getExpRankPage(@Valid PageRequestDto pageRequestDto, @Parameter(hidden = true) @Login UserDto user) { - PageRequest pageRequest = PageRequest.of(pageRequestDto.getPage() - 1, pageRequestDto.getSize(), - Sort.by("totalExp").descending().and(Sort.by("intraId"))); - return rankService.getExpRankPageByRedis(pageRequest, user); - } - - /** - * - * @param pageRequestDto - * @param user - * @param season - * @param gameType - * - * gameType는 single로 고정되어 오고있는데 현재 rank게임은 single만 구현되어있어서 사용 안하기로 - */ - @GetMapping("/ranks/{gameType}") - public RankPageResponseDto getRankPage(@Valid PageRequestDto pageRequestDto, @Parameter(hidden = true) @Login UserDto user, - Long season, String gameType){ - PageRequest pageRequest = PageRequest.of(pageRequestDto.getPage() - 1, pageRequestDto.getSize()); - return rankService.getRankPage(pageRequest, user, season); - } + private final RankService rankService; + + @GetMapping("/exp") + public ExpRankPageResponseDto getExpRankPage(@Valid PageRequestDto pageRequestDto, + @Parameter(hidden = true) @Login UserDto user) { + PageRequest pageRequest = PageRequest.of(pageRequestDto.getPage() - 1, pageRequestDto.getSize(), + Sort.by("totalExp").descending().and(Sort.by("intraId"))); + return rankService.getExpRankPageByRedis(pageRequest, user); + } + + /** + * + * @param pageRequestDto + * @param user + * @param season + * @param gameType + * + * gameType는 single로 고정되어 오고있는데 현재 rank게임은 single만 구현되어있어서 사용 안하기로 + */ + @GetMapping("/ranks/{gameType}") + public RankPageResponseDto getRankPage(@Valid PageRequestDto pageRequestDto, + @Parameter(hidden = true) @Login UserDto user, + Long season, String gameType) { + PageRequest pageRequest = PageRequest.of(pageRequestDto.getPage() - 1, pageRequestDto.getSize()); + return rankService.getRankPage(pageRequest, user, season); + } } diff --git a/src/main/java/com/gg/server/domain/rank/controller/RankV2Controller.java b/src/main/java/com/gg/server/domain/rank/controller/RankV2Controller.java index 1e4081e52..8839d09d7 100644 --- a/src/main/java/com/gg/server/domain/rank/controller/RankV2Controller.java +++ b/src/main/java/com/gg/server/domain/rank/controller/RankV2Controller.java @@ -1,14 +1,7 @@ package com.gg.server.domain.rank.controller; -import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; -import com.gg.server.domain.rank.dto.RankPageResponseDto; -import com.gg.server.domain.rank.service.RankService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.dto.PageRequestDto; -import com.gg.server.global.utils.argumentresolver.Login; -import io.swagger.v3.oas.annotations.Parameter; import javax.validation.Valid; -import lombok.RequiredArgsConstructor; + import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.web.bind.annotation.GetMapping; @@ -17,30 +10,44 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; +import com.gg.server.domain.rank.dto.RankPageResponseDto; +import com.gg.server.domain.rank.service.RankService; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.dto.PageRequestDto; +import com.gg.server.global.utils.argumentresolver.Login; + +import io.swagger.v3.oas.annotations.Parameter; +import lombok.RequiredArgsConstructor; + @RestController @RequiredArgsConstructor @RequestMapping("/pingpong/v2") public class RankV2Controller { - private final RankService rankService; - @GetMapping("/exp") - public ExpRankPageResponseDto getExpRankPage(@Valid PageRequestDto pageRequestDto, @Parameter(hidden = true) @Login UserDto user) { - PageRequest pageRequest = PageRequest.of(pageRequestDto.getPage() - 1, pageRequestDto.getSize(), - Sort.by("totalExp").descending().and(Sort.by("intraId"))); - return rankService.getExpRankPage(pageRequest, user); - } - /** - * - * @param pageRequestDto - * @param user - * @param season - * @param gameType - * - * gameType는 single로 고정되어 오고있는데 현재 rank게임은 single만 구현되어있어서 사용 안하기로 - */ - @GetMapping("/ranks/{gameType}") - public RankPageResponseDto getRankPage(@Valid PageRequestDto pageRequestDto, @Parameter(hidden = true) @Login UserDto user, - @RequestParam Long season, @PathVariable String gameType){ - PageRequest pageRequest = PageRequest.of(pageRequestDto.getPage() - 1, pageRequestDto.getSize()); - return rankService.getRankPageV2(pageRequest, user, season); - } + private final RankService rankService; + + @GetMapping("/exp") + public ExpRankPageResponseDto getExpRankPage(@Valid PageRequestDto pageRequestDto, + @Parameter(hidden = true) @Login UserDto user) { + PageRequest pageRequest = PageRequest.of(pageRequestDto.getPage() - 1, pageRequestDto.getSize(), + Sort.by("totalExp").descending().and(Sort.by("intraId"))); + return rankService.getExpRankPage(pageRequest, user); + } + + /** + * + * @param pageRequestDto + * @param user + * @param season + * @param gameType + * + * gameType는 single로 고정되어 오고있는데 현재 rank게임은 single만 구현되어있어서 사용 안하기로 + */ + @GetMapping("/ranks/{gameType}") + public RankPageResponseDto getRankPage(@Valid PageRequestDto pageRequestDto, + @Parameter(hidden = true) @Login UserDto user, + @RequestParam Long season, @PathVariable String gameType) { + PageRequest pageRequest = PageRequest.of(pageRequestDto.getPage() - 1, pageRequestDto.getSize()); + return rankService.getRankPageV2(pageRequest, user, season); + } } diff --git a/src/main/java/com/gg/server/domain/rank/data/Rank.java b/src/main/java/com/gg/server/domain/rank/data/Rank.java index 35c69fff2..d40b40bb0 100644 --- a/src/main/java/com/gg/server/domain/rank/data/Rank.java +++ b/src/main/java/com/gg/server/domain/rank/data/Rank.java @@ -1,103 +1,112 @@ -package com.gg.server.domain.rank.data; - -import com.gg.server.admin.user.dto.UserUpdateAdminRequestDto; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.tier.data.Tier; -import com.gg.server.domain.user.data.User; -import com.gg.server.global.utils.BaseTimeEntity; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import javax.persistence.*; -import javax.validation.constraints.NotNull; -import java.io.Serializable; - -import org.hibernate.annotations.DynamicUpdate; - -@Entity -@Getter -@Builder -@NoArgsConstructor -@AllArgsConstructor -@Table(name="ranks") -@DynamicUpdate -public class Rank extends BaseTimeEntity implements Serializable { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "season_id") - private Season season; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "tier_id") - private Tier tier; - - @NotNull - @Column(name = "ppp") - private Integer ppp; - - @NotNull - @Column(name = "wins") - private Integer wins; - - @NotNull - @Column(name = "losses") - private Integer losses; - - @Column(name = "status_message", length = 30) - private String statusMessage; - - - public static Rank from (User user, Season season, Integer ppp, Tier tier) { - return Rank.builder() - .user(user) - .ppp(ppp) - .season(season) - .wins(0) - .losses(0) - .statusMessage("") - .tier(tier) - .build(); - } - - @Builder - public Rank(User user, Season season, Integer ppp, Integer wins, - Integer losses, String statusMessage, Tier tier) { - this.user = user; - this.season = season; - this.ppp = ppp; - this.wins = wins; - this.losses = losses; - this.statusMessage = statusMessage; - this.tier = tier; - } - - public void setStatusMessage(String statusMessage) { - this.statusMessage = statusMessage; - } - - public void modifyUserRank(UserUpdateAdminRequestDto userUpdateAdminRequestDto) { - this.ppp = userUpdateAdminRequestDto.getPpp(); - this.wins = userUpdateAdminRequestDto.getWins(); - this.losses = userUpdateAdminRequestDto.getLosses(); - } - - public void modifyUserRank(Integer ppp, int wins, int losses) { - this.ppp = ppp; - this.wins = wins; - this.losses = losses; - } - - public void updateTier(Tier tier) { - this.tier = tier; - } -} +package com.gg.server.domain.rank.data; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; + +import org.hibernate.annotations.DynamicUpdate; + +import com.gg.server.admin.user.dto.UserUpdateAdminRequestDto; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.tier.data.Tier; +import com.gg.server.domain.user.data.User; +import com.gg.server.global.utils.BaseTimeEntity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Table(name = "ranks") +@DynamicUpdate +public class Rank extends BaseTimeEntity implements Serializable { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "season_id") + private Season season; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "tier_id") + private Tier tier; + + @NotNull + @Column(name = "ppp") + private Integer ppp; + + @NotNull + @Column(name = "wins") + private Integer wins; + + @NotNull + @Column(name = "losses") + private Integer losses; + + @Column(name = "status_message", length = 30) + private String statusMessage; + + public static Rank from(User user, Season season, Integer ppp, Tier tier) { + return Rank.builder() + .user(user) + .ppp(ppp) + .season(season) + .wins(0) + .losses(0) + .statusMessage("") + .tier(tier) + .build(); + } + + @Builder + public Rank(User user, Season season, Integer ppp, Integer wins, + Integer losses, String statusMessage, Tier tier) { + this.user = user; + this.season = season; + this.ppp = ppp; + this.wins = wins; + this.losses = losses; + this.statusMessage = statusMessage; + this.tier = tier; + } + + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + + public void modifyUserRank(UserUpdateAdminRequestDto userUpdateAdminRequestDto) { + this.ppp = userUpdateAdminRequestDto.getPpp(); + this.wins = userUpdateAdminRequestDto.getWins(); + this.losses = userUpdateAdminRequestDto.getLosses(); + } + + public void modifyUserRank(Integer ppp, int wins, int losses) { + this.ppp = ppp; + this.wins = wins; + this.losses = losses; + } + + public void updateTier(Tier tier) { + this.tier = tier; + } +} diff --git a/src/main/java/com/gg/server/domain/rank/data/RankRepository.java b/src/main/java/com/gg/server/domain/rank/data/RankRepository.java index a453cd817..90ac36dff 100644 --- a/src/main/java/com/gg/server/domain/rank/data/RankRepository.java +++ b/src/main/java/com/gg/server/domain/rank/data/RankRepository.java @@ -1,6 +1,8 @@ package com.gg.server.domain.rank.data; -import com.gg.server.domain.rank.dto.RankV2Dto; +import java.util.List; +import java.util.Optional; + import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; @@ -8,68 +10,68 @@ import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; -import java.util.List; -import java.util.Optional; +import com.gg.server.domain.rank.dto.RankV2Dto; @Repository public interface RankRepository extends JpaRepository { - Optional findByUserIdAndSeasonId(Long userId, Long seasonId); + Optional findByUserIdAndSeasonId(Long userId, Long seasonId); - @Modifying(clearAutomatically = true) - @Query("delete from Rank r where r.season.id=:seasonId") - void deleteAllBySeasonId(@Param("seasonId") Long seasonId); + @Modifying(clearAutomatically = true) + @Query("delete from Rank r where r.season.id=:seasonId") + void deleteAllBySeasonId(@Param("seasonId") Long seasonId); - Optional findFirstByOrderByCreatedAtDesc(); + Optional findFirstByOrderByCreatedAtDesc(); - @EntityGraph(attributePaths = {"user", "tier"}) - List findAllBySeasonId(Long seasonId); + @EntityGraph(attributePaths = {"user", "tier"}) + List findAllBySeasonId(Long seasonId); - List findAllBySeasonIdOrderByPppDesc(Long seasonId); + List findAllBySeasonIdOrderByPppDesc(Long seasonId); - @Query(value = "select count(r) from Rank r where r.season.id=:seasonId and not (r.wins = 0 and r.losses = 0)") - Long countRealRankPlayers(@Param("seasonId") Long seasonId); + @Query(value = "select count(r) from Rank r where r.season.id=:seasonId and not (r.wins = 0 and r.losses = 0)") + Long countRealRankPlayers(@Param("seasonId") Long seasonId); - @Query(value = "SELECT u.intra_id intraId, r.status_message statusMessage, r.ppp, " - + "t.image_uri tierImageUri, u.text_color textColor, " - + "RANK() OVER(ORDER BY r.ppp DESC, pg.created_at ASC, u.total_exp DESC) AS ranking " - + "FROM Ranks r " - + "INNER JOIN Tier t " - + "ON r.tier_id = t.id " - + "INNER JOIN User u " - + "ON r.user_id = u.id " - + "INNER JOIN (SELECT MAX(p.created_at) created_at, p.user_id user_id " - + " FROM PChange p" - + " INNER JOIN Game g" - + " ON p.game_id = g.id" - + " WHERE g.season_id = :seasonId" - + " GROUP BY p.user_id) pg " - + "ON pg.user_id = u.id " - + "WHERE r.season_id = :seasonId AND (r.losses > 0 OR r.wins > 0) " - + "LIMIT :limit OFFSET :offset ", nativeQuery = true) - List findPppRankBySeasonId(@Param("offset")int offset, @Param("limit")int limit, @Param("seasonId") Long seasonId); + @Query(value = "SELECT u.intra_id intraId, r.status_message statusMessage, r.ppp, " + + "t.image_uri tierImageUri, u.text_color textColor, " + + "RANK() OVER(ORDER BY r.ppp DESC, pg.created_at ASC, u.total_exp DESC) AS ranking " + + "FROM Ranks r " + + "INNER JOIN Tier t " + + "ON r.tier_id = t.id " + + "INNER JOIN User u " + + "ON r.user_id = u.id " + + "INNER JOIN (SELECT MAX(p.created_at) created_at, p.user_id user_id " + + " FROM PChange p" + + " INNER JOIN Game g" + + " ON p.game_id = g.id" + + " WHERE g.season_id = :seasonId" + + " GROUP BY p.user_id) pg " + + "ON pg.user_id = u.id " + + "WHERE r.season_id = :seasonId AND (r.losses > 0 OR r.wins > 0) " + + "LIMIT :limit OFFSET :offset ", nativeQuery = true) + List findPppRankBySeasonId(@Param("offset") int offset, @Param("limit") int limit, + @Param("seasonId") Long seasonId); - @Query(value = "SELECT count(*) " - + "FROM Ranks r " - + "INNER JOIN User u " - + "ON r.user_id = u.id " - + "WHERE r.season_id = :seasonId AND (r.losses > 0 OR r.wins > 0) ", nativeQuery = true) - int countRankUserBySeasonId(@Param("seasonId")Long seasonId); + @Query(value = "SELECT count(*) " + + "FROM Ranks r " + + "INNER JOIN User u " + + "ON r.user_id = u.id " + + "WHERE r.season_id = :seasonId AND (r.losses > 0 OR r.wins > 0) ", nativeQuery = true) + int countRankUserBySeasonId(@Param("seasonId") Long seasonId); - @Query(value = "SELECT ranked.ranking " - + "FROM (" - + "SELECT u.id userId, RANK() OVER(ORDER BY r.ppp DESC, pg.created_at ASC, u.total_exp DESC) AS ranking " - + "FROM Ranks r " - + "INNER JOIN User u " - + "ON r.user_id = u.id " - + "INNER JOIN (SELECT MAX(p.created_at) created_at, p.user_id user_id " - + " FROM PChange p" - + " INNER JOIN Game g" - + " ON p.game_id = g.id" - + " WHERE g.season_id = :seasonId" - + " GROUP BY p.user_id) pg " - + "ON pg.user_id = u.id " - + "WHERE r.season_id = :seasonId AND (r.losses > 0 OR r.wins > 0) " - + ") ranked " - + "WHERE ranked.userId = :userId", nativeQuery = true) - Optional findRankByUserIdAndSeasonId(@Param("userId")Long userId, @Param("seasonId")Long seasonId); + @Query(value = "SELECT ranked.ranking " + + "FROM (" + + "SELECT u.id userId, RANK() OVER(ORDER BY r.ppp DESC, pg.created_at ASC, u.total_exp DESC) AS ranking " + + "FROM Ranks r " + + "INNER JOIN User u " + + "ON r.user_id = u.id " + + "INNER JOIN (SELECT MAX(p.created_at) created_at, p.user_id user_id " + + " FROM PChange p" + + " INNER JOIN Game g" + + " ON p.game_id = g.id" + + " WHERE g.season_id = :seasonId" + + " GROUP BY p.user_id) pg " + + "ON pg.user_id = u.id " + + "WHERE r.season_id = :seasonId AND (r.losses > 0 OR r.wins > 0) " + + ") ranked " + + "WHERE ranked.userId = :userId", nativeQuery = true) + Optional findRankByUserIdAndSeasonId(@Param("userId") Long userId, @Param("seasonId") Long seasonId); } diff --git a/src/main/java/com/gg/server/domain/rank/dto/ExpRankDto.java b/src/main/java/com/gg/server/domain/rank/dto/ExpRankDto.java index fd2896def..e60833a81 100644 --- a/src/main/java/com/gg/server/domain/rank/dto/ExpRankDto.java +++ b/src/main/java/com/gg/server/domain/rank/dto/ExpRankDto.java @@ -1,47 +1,49 @@ -package com.gg.server.domain.rank.dto; - -import com.gg.server.domain.user.data.User; -import com.gg.server.global.utils.ExpLevelCalculator; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@Builder -@AllArgsConstructor -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class ExpRankDto { - private String intraId; - private Integer rank; - private String statusMessage; - private Integer level; - private Integer exp; - private String userImageUri; - private String textColor; - - public static ExpRankDto from (User user, Integer rank, String statusMessage){ - ExpRankDto dto = ExpRankDto.builder() - .intraId(user.getIntraId()) - .rank(user.getTotalExp() == 0 ? -1 : rank) - .statusMessage(statusMessage) - .level(ExpLevelCalculator.getLevel(user.getTotalExp())) - .exp(user.getTotalExp()) - .userImageUri(user.getImageUri()) - .textColor(user.getTextColor()) - .build(); - return dto; - } - public static ExpRankDto from(ExpRankV2Dto dto) { - return ExpRankDto.builder() - .intraId(dto.getIntraId()) - .rank(dto.getRanking()) - .statusMessage(dto.getStatusMessage()) - .level(ExpLevelCalculator.getLevel(dto.getTotalExp())) - .exp(dto.getTotalExp()) - .userImageUri(dto.getImageUri()) - .textColor(dto.getTextColor()) - .build(); - } -} \ No newline at end of file +package com.gg.server.domain.rank.dto; + +import com.gg.server.domain.user.data.User; +import com.gg.server.global.utils.ExpLevelCalculator; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Builder +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class ExpRankDto { + private String intraId; + private Integer rank; + private String statusMessage; + private Integer level; + private Integer exp; + private String userImageUri; + private String textColor; + + public static ExpRankDto from(User user, Integer rank, String statusMessage) { + ExpRankDto dto = ExpRankDto.builder() + .intraId(user.getIntraId()) + .rank(user.getTotalExp() == 0 ? -1 : rank) + .statusMessage(statusMessage) + .level(ExpLevelCalculator.getLevel(user.getTotalExp())) + .exp(user.getTotalExp()) + .userImageUri(user.getImageUri()) + .textColor(user.getTextColor()) + .build(); + return dto; + } + + public static ExpRankDto from(ExpRankV2Dto dto) { + return ExpRankDto.builder() + .intraId(dto.getIntraId()) + .rank(dto.getRanking()) + .statusMessage(dto.getStatusMessage()) + .level(ExpLevelCalculator.getLevel(dto.getTotalExp())) + .exp(dto.getTotalExp()) + .userImageUri(dto.getImageUri()) + .textColor(dto.getTextColor()) + .build(); + } +} diff --git a/src/main/java/com/gg/server/domain/rank/dto/ExpRankPageResponseDto.java b/src/main/java/com/gg/server/domain/rank/dto/ExpRankPageResponseDto.java index e645f9dee..fe4e0e5a5 100644 --- a/src/main/java/com/gg/server/domain/rank/dto/ExpRankPageResponseDto.java +++ b/src/main/java/com/gg/server/domain/rank/dto/ExpRankPageResponseDto.java @@ -1,17 +1,18 @@ package com.gg.server.domain.rank.dto; +import java.util.List; + import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.List; import lombok.NoArgsConstructor; @AllArgsConstructor @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) public class ExpRankPageResponseDto { - private int myRank; - private int currentPage; - private int totalPage; - private List rankList; + private int myRank; + private int currentPage; + private int totalPage; + private List rankList; } diff --git a/src/main/java/com/gg/server/domain/rank/dto/ExpRankV2Dto.java b/src/main/java/com/gg/server/domain/rank/dto/ExpRankV2Dto.java index ec2958f13..299139f4e 100644 --- a/src/main/java/com/gg/server/domain/rank/dto/ExpRankV2Dto.java +++ b/src/main/java/com/gg/server/domain/rank/dto/ExpRankV2Dto.java @@ -1,11 +1,16 @@ package com.gg.server.domain.rank.dto; public interface ExpRankV2Dto { - String getIntraId(); - String getStatusMessage(); - Integer getTotalExp(); - String getImageUri(); - String getTextColor(); - Integer getRanking(); + String getIntraId(); + + String getStatusMessage(); + + Integer getTotalExp(); + + String getImageUri(); + + String getTextColor(); + + Integer getRanking(); } diff --git a/src/main/java/com/gg/server/domain/rank/dto/RankDto.java b/src/main/java/com/gg/server/domain/rank/dto/RankDto.java index d31e9190c..626361002 100644 --- a/src/main/java/com/gg/server/domain/rank/dto/RankDto.java +++ b/src/main/java/com/gg/server/domain/rank/dto/RankDto.java @@ -2,6 +2,7 @@ import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.user.data.User; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -12,33 +13,33 @@ @NoArgsConstructor @Builder public class RankDto { - private String intraId; - private int rank; - private int ppp; - private String statusMessage; - private String tierImageUri; - private String textColor; + private String intraId; + private int rank; + private int ppp; + private String statusMessage; + private String tierImageUri; + private String textColor; + public static RankDto from(User user, RankRedis rankRedis, Integer rank) { + RankDto dto = RankDto.builder() + .intraId(user.getIntraId()) + .rank(rank) + .ppp(rankRedis.getPpp()) + .statusMessage(rankRedis.getStatusMessage()) + .tierImageUri(rankRedis.getTierImageUri()) + .textColor(user.getTextColor()) + .build(); + return dto; + } - public static RankDto from(User user, RankRedis rankRedis, Integer rank) { - RankDto dto = RankDto.builder() - .intraId(user.getIntraId()) - .rank(rank) - .ppp(rankRedis.getPpp()) - .statusMessage(rankRedis.getStatusMessage()) - .tierImageUri(rankRedis.getTierImageUri()) - .textColor(user.getTextColor()) - .build(); - return dto; - } - public static RankDto from(RankV2Dto dto) { - return RankDto.builder() - .intraId(dto.getIntraId()) - .rank(dto.getRanking()) - .ppp(dto.getPpp()) - .statusMessage(dto.getStatusMessage()) - .tierImageUri(dto.getTierImageUri()) - .textColor(dto.getTextColor()) - .build(); - } + public static RankDto from(RankV2Dto dto) { + return RankDto.builder() + .intraId(dto.getIntraId()) + .rank(dto.getRanking()) + .ppp(dto.getPpp()) + .statusMessage(dto.getStatusMessage()) + .tierImageUri(dto.getTierImageUri()) + .textColor(dto.getTextColor()) + .build(); + } } diff --git a/src/main/java/com/gg/server/domain/rank/dto/RankPageResponseDto.java b/src/main/java/com/gg/server/domain/rank/dto/RankPageResponseDto.java index 3bd4a4dee..2be8d1b3d 100644 --- a/src/main/java/com/gg/server/domain/rank/dto/RankPageResponseDto.java +++ b/src/main/java/com/gg/server/domain/rank/dto/RankPageResponseDto.java @@ -1,17 +1,17 @@ package com.gg.server.domain.rank.dto; +import java.util.List; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @Getter @AllArgsConstructor @NoArgsConstructor public class RankPageResponseDto { - private int myRank; - private int currentPage; - private int totalPage; - private List rankList; + private int myRank; + private int currentPage; + private int totalPage; + private List rankList; } diff --git a/src/main/java/com/gg/server/domain/rank/dto/RankV2Dto.java b/src/main/java/com/gg/server/domain/rank/dto/RankV2Dto.java index 9f84562ad..463977f2f 100644 --- a/src/main/java/com/gg/server/domain/rank/dto/RankV2Dto.java +++ b/src/main/java/com/gg/server/domain/rank/dto/RankV2Dto.java @@ -2,11 +2,16 @@ public interface RankV2Dto { - String getIntraId(); - String getStatusMessage(); - Integer getPpp(); - String getTierImageUri(); - String getTextColor(); - Integer getRanking(); + String getIntraId(); + + String getStatusMessage(); + + Integer getPpp(); + + String getTierImageUri(); + + String getTextColor(); + + Integer getRanking(); } diff --git a/src/main/java/com/gg/server/domain/rank/exception/RankNotFoundException.java b/src/main/java/com/gg/server/domain/rank/exception/RankNotFoundException.java index 92b552fe2..cae345c39 100644 --- a/src/main/java/com/gg/server/domain/rank/exception/RankNotFoundException.java +++ b/src/main/java/com/gg/server/domain/rank/exception/RankNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class RankNotFoundException extends NotExistException { - public RankNotFoundException() { - super("랭크 테이블에 없는 유저입니다.", ErrorCode.RANK_NOT_FOUND); - } + public RankNotFoundException() { + super("랭크 테이블에 없는 유저입니다.", ErrorCode.RANK_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/rank/exception/RankUpdateException.java b/src/main/java/com/gg/server/domain/rank/exception/RankUpdateException.java index 524a68a2c..92206f740 100644 --- a/src/main/java/com/gg/server/domain/rank/exception/RankUpdateException.java +++ b/src/main/java/com/gg/server/domain/rank/exception/RankUpdateException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.InvalidParameterException; public class RankUpdateException extends InvalidParameterException { - public RankUpdateException() { - super("Ppp를 수정 할 수 없습니다", ErrorCode.RANK_UPDATE_FAIL); - } + public RankUpdateException() { + super("Ppp를 수정 할 수 없습니다", ErrorCode.RANK_UPDATE_FAIL); + } } diff --git a/src/main/java/com/gg/server/domain/rank/exception/RedisDataNotFoundException.java b/src/main/java/com/gg/server/domain/rank/exception/RedisDataNotFoundException.java index 32e7fbe98..a885d15ab 100644 --- a/src/main/java/com/gg/server/domain/rank/exception/RedisDataNotFoundException.java +++ b/src/main/java/com/gg/server/domain/rank/exception/RedisDataNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class RedisDataNotFoundException extends NotExistException { - public RedisDataNotFoundException() { - super("Redis에 데이터가 없습니다.", ErrorCode.REDIS_RANK_NOT_FOUND); - } + public RedisDataNotFoundException() { + super("Redis에 데이터가 없습니다.", ErrorCode.REDIS_RANK_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/rank/redis/RankRedis.java b/src/main/java/com/gg/server/domain/rank/redis/RankRedis.java index eb0590c35..8f00453f4 100644 --- a/src/main/java/com/gg/server/domain/rank/redis/RankRedis.java +++ b/src/main/java/com/gg/server/domain/rank/redis/RankRedis.java @@ -1,86 +1,92 @@ -package com.gg.server.domain.rank.redis; - -import com.gg.server.domain.rank.data.Rank; -import com.gg.server.domain.user.dto.UserDto; -import lombok.*; -import org.springframework.data.redis.core.RedisHash; - -import java.io.Serializable; - -@RedisHash("rank") -@Getter -@Builder -@AllArgsConstructor -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class RankRedis implements Serializable { - private Long userId; - private String intraId; - private int ppp; - private int wins; - private int losses; - private String statusMessage; - private String tierImageUri; - private String textColor; - - public void updateRank(int changePpp, int wins, int losses) { - this.ppp += changePpp; - this.wins = wins; - this.losses = losses; - } - - public void updateTierImage(String tierImageUri) { - this.tierImageUri = tierImageUri; - } - - public void changedRank(int ppp, int wins, int losses) { - this.ppp = ppp; - this.wins = wins; - this.losses = losses; - } - - public void setStatusMessage(String msg) { - this.statusMessage = msg; - } - - public static RankRedis from(UserDto user, Integer ppp, String tierImageUri) { - RankRedis rankRedis = RankRedis.builder() - .userId(user.getId()) - .intraId(user.getIntraId()) - .ppp(ppp) - .wins(0) - .losses(0) - .statusMessage("") - .tierImageUri(tierImageUri) - .textColor(user.getTextColor()) - .build(); - return rankRedis; - } - - public static RankRedis from(Rank rank) { - RankRedis rankRedis = RankRedis.builder() - .userId(rank.getUser().getId()) - .intraId(rank.getUser().getIntraId()) - .ppp(rank.getPpp()) - .wins(rank.getWins()) - .losses(rank.getLosses()) - .statusMessage(rank.getStatusMessage()) - .tierImageUri(rank.getTier().getImageUri()) - .textColor(rank.getUser().getTextColor()) - .build(); - return rankRedis; - } - - @Override - public String toString() { - return "RankRedis{" + - "userId=" + userId + - ", intraId='" + intraId + '\'' + - ", ppp=" + ppp + - ", wins=" + wins + - ", losses=" + losses + - ", statusMessage='" + statusMessage + '\'' + - ", tierImageUri='" + tierImageUri + '\'' + - ", textColor='" + textColor + '\'' + - '}'; - } -} \ No newline at end of file +package com.gg.server.domain.rank.redis; + +import java.io.Serializable; + +import org.springframework.data.redis.core.RedisHash; + +import com.gg.server.domain.rank.data.Rank; +import com.gg.server.domain.user.dto.UserDto; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@RedisHash("rank") +@Getter +@Builder +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class RankRedis implements Serializable { + private Long userId; + private String intraId; + private int ppp; + private int wins; + private int losses; + private String statusMessage; + private String tierImageUri; + private String textColor; + + public void updateRank(int changePpp, int wins, int losses) { + this.ppp += changePpp; + this.wins = wins; + this.losses = losses; + } + + public void updateTierImage(String tierImageUri) { + this.tierImageUri = tierImageUri; + } + + public void changedRank(int ppp, int wins, int losses) { + this.ppp = ppp; + this.wins = wins; + this.losses = losses; + } + + public void setStatusMessage(String msg) { + this.statusMessage = msg; + } + + public static RankRedis from(UserDto user, Integer ppp, String tierImageUri) { + RankRedis rankRedis = RankRedis.builder() + .userId(user.getId()) + .intraId(user.getIntraId()) + .ppp(ppp) + .wins(0) + .losses(0) + .statusMessage("") + .tierImageUri(tierImageUri) + .textColor(user.getTextColor()) + .build(); + return rankRedis; + } + + public static RankRedis from(Rank rank) { + RankRedis rankRedis = RankRedis.builder() + .userId(rank.getUser().getId()) + .intraId(rank.getUser().getIntraId()) + .ppp(rank.getPpp()) + .wins(rank.getWins()) + .losses(rank.getLosses()) + .statusMessage(rank.getStatusMessage()) + .tierImageUri(rank.getTier().getImageUri()) + .textColor(rank.getUser().getTextColor()) + .build(); + return rankRedis; + } + + @Override + public String toString() { + return "RankRedis{" + + "userId=" + userId + + ", intraId='" + intraId + '\'' + + ", ppp=" + ppp + + ", wins=" + wins + + ", losses=" + losses + + ", statusMessage='" + statusMessage + '\'' + + ", tierImageUri='" + tierImageUri + '\'' + + ", textColor='" + textColor + '\'' + + '}'; + } +} diff --git a/src/main/java/com/gg/server/domain/rank/redis/RankRedisRepository.java b/src/main/java/com/gg/server/domain/rank/redis/RankRedisRepository.java index a64fce40f..80911b2a7 100644 --- a/src/main/java/com/gg/server/domain/rank/redis/RankRedisRepository.java +++ b/src/main/java/com/gg/server/domain/rank/redis/RankRedisRepository.java @@ -1,218 +1,224 @@ package com.gg.server.domain.rank.redis; -import com.gg.server.domain.rank.exception.RedisDataNotFoundException; +import java.util.Comparator; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ZSetOperations; import org.springframework.stereotype.Repository; -import org.springframework.transaction.annotation.Transactional; -import java.util.Comparator; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; +import com.gg.server.domain.rank.exception.RedisDataNotFoundException; @Repository public class RankRedisRepository { - private final ZSetOperations zSetOps; - private final HashOperations hashOps; - private final RedisTemplate redisTemplate; - - public RankRedisRepository(RedisTemplate redisTemplate) { - this.zSetOps = redisTemplate.opsForZSet(); - this.hashOps = redisTemplate.opsForHash(); - this.redisTemplate = redisTemplate; - } - - /** - * - * @param key - * @param userId - * @param ppp - * - * ZSET에 user를 추가하는 메서드 - */ - public void addToZSet(String key, Long userId, int ppp) { - zSetOps.add(key, userId.toString(), ppp); - } - - /** - * - * @param key - * @param userId - * @param ppp - * - * ZSET에서 user의 ppp 증가시키는 메서드 - */ - public void incrementScoreInZSet(String key, Long userId, int ppp) { - zSetOps.incrementScore(key, userId.toString(), ppp); - - } - - - /** - * - * @param key - * @param userId - * @param ppp - * - * ZSET에서 user의 ppp를 감소시키는 메서드 - */ - public void decrementScoreInZSet(String key, Long userId, int ppp) { - zSetOps.incrementScore(key, userId.toString(), -ppp); - } - - /** - * - * @param key - * @param userId - * - * ZSET에서 user를 삭제하는 메서드 - */ - public void deleteFromZSet(String key, Long userId) { - zSetOps.remove(key, userId.toString()); - } - - /** - * - * @param key - * @param userId - * @return 0 -> 1등 - * - * ZSET에서 user의 순위(rank)를 조회하는 메서드 ppp가 높은순 - */ - public Long getRankInZSet(String key, Long userId) { - Long result = zSetOps.reverseRank(key, userId.toString()); - if(result == null) - throw new RedisDataNotFoundException(); - return result; - } - - - /** - * - * @param key - * @param userId - * - * ZSET에서 user의 ppp를 가져오는 메서드 - */ - public Long getScoreInZSet(String key, Long userId) { - Double result = zSetOps.score(key, userId.toString()); - if(result == null) - throw new RedisDataNotFoundException(); - return result.longValue(); - } - - /** - * - * @param key - * @param startRank - * @param endRank - * - * Zset에서 user의 랭킹 범위를 지정하여 그 범위 내의 userId들을 가져오는 메소드 - * startRank -> 0부터 시작 - */ - public List getUserIdsByRangeFromZSet(String key, long startRank, long endRank) { - Set result = zSetOps.reverseRange(key, startRank, endRank); - List stringList = result.stream().map(Object::toString).collect(Collectors.toList()); - if (result == null) - throw new RedisDataNotFoundException(); - return stringList.stream() - .map(Long::parseLong).collect(Collectors.toList()); - } - - - - /** - * - * @param key - * @param userId - * @param userRank - * redis hash에 user rank데이터를 추가하는 메소드 - */ - public void addRankData(String key, Long userId, RankRedis userRank){ - hashOps.put(key, userId.toString(), userRank); - } - - /** - * - * @param key - * @param userId - * - * 해당 유저의 rank데이터를 조회하는 메소드 - */ - public RankRedis findRankByUserId(String key, Long userId) { - Object result = hashOps.get(key, userId.toString()); - if (result == null) - throw new RedisDataNotFoundException(); - return RankRedis.class.cast(result); - } - - /** - * - * @param key - * @param userId - * @param userRank - * - * 해당 유저의 rank데이터를 업데이트하는 메소드 - */ - public void updateRankData(String key, Long userId, RankRedis userRank) { - hashOps.put(key, userId.toString(), userRank); - } - - /** - * - * @param key - * @param userId - * - * 해당 유저의 rank데이터를 삭제하는 메소드 - */ - public void deleteRankData(String key, Long userId) { - hashOps.delete(key, userId.toString()); - } - - - /** - * - * @param key - * @param userIds - * - * 해당 유저들의 rank데이터를 조회하는 메소드 - */ - public List findRanksByUserIds(String key, List userIds) { - List userIdsStr = userIds.stream().map(String::valueOf).collect(Collectors.toList()); - List objects = hashOps.multiGet(key, userIdsStr); - if(objects == null) - throw new RedisDataNotFoundException(); - return objects.stream().map(RankRedis.class::cast).collect(Collectors.toList()); - } - - public List findAllRanksOrderByPppDesc(String key) { - List objects = hashOps.values(key); - if(objects == null) - throw new RedisDataNotFoundException(); - return objects.stream().map(RankRedis.class::cast).sorted(Comparator.comparing(RankRedis::getPpp).reversed()).collect(Collectors.toList()); - } - - public Long countTotalRank(String zSetKey) { - Long result = zSetOps.size(zSetKey); - if(result == null) - throw new RedisDataNotFoundException(); - return result; - } - - public void deleteAll(){ - redisTemplate.delete(redisTemplate.keys("*")); - } - public void deleteZSetKey(String key) { - redisTemplate.delete(key); - } - - public void deleteHashKey(String key) { - redisTemplate.delete(key); - } - - public Boolean isEmpty(String hashKey) { - return hashOps.size(hashKey) == 0; - } + private final ZSetOperations zSetOps; + private final HashOperations hashOps; + private final RedisTemplate redisTemplate; + + public RankRedisRepository(RedisTemplate redisTemplate) { + this.zSetOps = redisTemplate.opsForZSet(); + this.hashOps = redisTemplate.opsForHash(); + this.redisTemplate = redisTemplate; + } + + /** + * + * @param key + * @param userId + * @param ppp + * + * ZSET에 user를 추가하는 메서드 + */ + public void addToZSet(String key, Long userId, int ppp) { + zSetOps.add(key, userId.toString(), ppp); + } + + /** + * + * @param key + * @param userId + * @param ppp + * + * ZSET에서 user의 ppp 증가시키는 메서드 + */ + public void incrementScoreInZSet(String key, Long userId, int ppp) { + zSetOps.incrementScore(key, userId.toString(), ppp); + + } + + /** + * + * @param key + * @param userId + * @param ppp + * + * ZSET에서 user의 ppp를 감소시키는 메서드 + */ + public void decrementScoreInZSet(String key, Long userId, int ppp) { + zSetOps.incrementScore(key, userId.toString(), -ppp); + } + + /** + * + * @param key + * @param userId + * + * ZSET에서 user를 삭제하는 메서드 + */ + public void deleteFromZSet(String key, Long userId) { + zSetOps.remove(key, userId.toString()); + } + + /** + * + * @param key + * @param userId + * @return 0 -> 1등 + * + * ZSET에서 user의 순위(rank)를 조회하는 메서드 ppp가 높은순 + */ + public Long getRankInZSet(String key, Long userId) { + Long result = zSetOps.reverseRank(key, userId.toString()); + if (result == null) { + throw new RedisDataNotFoundException(); + } + return result; + } + + /** + * + * @param key + * @param userId + * + * ZSET에서 user의 ppp를 가져오는 메서드 + */ + public Long getScoreInZSet(String key, Long userId) { + Double result = zSetOps.score(key, userId.toString()); + if (result == null) { + throw new RedisDataNotFoundException(); + } + return result.longValue(); + } + + /** + * + * @param key + * @param startRank + * @param endRank + * + * Zset에서 user의 랭킹 범위를 지정하여 그 범위 내의 userId들을 가져오는 메소드 + * startRank -> 0부터 시작 + */ + public List getUserIdsByRangeFromZSet(String key, long startRank, long endRank) { + Set result = zSetOps.reverseRange(key, startRank, endRank); + List stringList = result.stream().map(Object::toString).collect(Collectors.toList()); + if (result == null) { + throw new RedisDataNotFoundException(); + } + return stringList.stream() + .map(Long::parseLong).collect(Collectors.toList()); + } + + /** + * + * @param key + * @param userId + * @param userRank + * redis hash에 user rank데이터를 추가하는 메소드 + */ + public void addRankData(String key, Long userId, RankRedis userRank) { + hashOps.put(key, userId.toString(), userRank); + } + + /** + * + * @param key + * @param userId + * + * 해당 유저의 rank데이터를 조회하는 메소드 + */ + public RankRedis findRankByUserId(String key, Long userId) { + Object result = hashOps.get(key, userId.toString()); + if (result == null) { + throw new RedisDataNotFoundException(); + } + return RankRedis.class.cast(result); + } + + /** + * + * @param key + * @param userId + * @param userRank + * + * 해당 유저의 rank데이터를 업데이트하는 메소드 + */ + public void updateRankData(String key, Long userId, RankRedis userRank) { + hashOps.put(key, userId.toString(), userRank); + } + + /** + * + * @param key + * @param userId + * + * 해당 유저의 rank데이터를 삭제하는 메소드 + */ + public void deleteRankData(String key, Long userId) { + hashOps.delete(key, userId.toString()); + } + + /** + * + * @param key + * @param userIds + * + * 해당 유저들의 rank데이터를 조회하는 메소드 + */ + public List findRanksByUserIds(String key, List userIds) { + List userIdsStr = userIds.stream().map(String::valueOf).collect(Collectors.toList()); + List objects = hashOps.multiGet(key, userIdsStr); + if (objects == null) { + throw new RedisDataNotFoundException(); + } + return objects.stream().map(RankRedis.class::cast).collect(Collectors.toList()); + } + + public List findAllRanksOrderByPppDesc(String key) { + List objects = hashOps.values(key); + if (objects == null) { + throw new RedisDataNotFoundException(); + } + return objects.stream() + .map(RankRedis.class::cast) + .sorted(Comparator.comparing(RankRedis::getPpp).reversed()) + .collect(Collectors.toList()); + } + + public Long countTotalRank(String zSetKey) { + Long result = zSetOps.size(zSetKey); + if (result == null) { + throw new RedisDataNotFoundException(); + } + return result; + } + + public void deleteAll() { + redisTemplate.delete(redisTemplate.keys("*")); + } + + public void deleteZSetKey(String key) { + redisTemplate.delete(key); + } + + public void deleteHashKey(String key) { + redisTemplate.delete(key); + } + + public Boolean isEmpty(String hashKey) { + return hashOps.size(hashKey) == 0; + } } diff --git a/src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java b/src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java index 29b17219a..d3009187a 100644 --- a/src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java +++ b/src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java @@ -1,5 +1,13 @@ package com.gg.server.domain.rank.redis; +import java.util.List; + +import javax.persistence.EntityManager; + +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.domain.game.data.Game; import com.gg.server.domain.pchange.service.PChangeService; import com.gg.server.domain.rank.data.Rank; @@ -13,155 +21,152 @@ import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.NotExistException; import com.gg.server.global.utils.EloRating; + import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.List; - -import javax.persistence.EntityManager; @Service @RequiredArgsConstructor @Slf4j public class RankRedisService { - private final RankRedisRepository rankRedisRepository; - private final TierRepository tierRepository; - private final PChangeService pChangeService; - private final RankRepository rankRepository; - private final SeasonFindService seasonFindService; - private final EntityManager entityManager; + private final RankRedisRepository rankRedisRepository; + private final TierRepository tierRepository; + private final PChangeService pChangeService; + private final RankRepository rankRepository; + private final SeasonFindService seasonFindService; + private final EntityManager entityManager; + + public Integer getUserPpp(Long userId, Long seasonId) { + String hashKey = RedisKeyManager.getHashKey(seasonId); + return rankRedisRepository.findRankByUserId(hashKey, userId).getPpp(); + } + + public void updateAdminRankData(TeamUser myTeamUser, TeamUser enemyTeamUser, Game game, RankRedis myTeam, + RankRedis enemyTeam) { + // 단식 -> 2명 기준 + String key = RedisKeyManager.getHashKey(game.getSeason().getId()); + String zsetKey = RedisKeyManager.getZSetKey(game.getSeason().getId()); + Integer myPPP = myTeam.getPpp(); + Integer enemyPPP = enemyTeam.getPpp(); + updatePPP(myTeamUser, myTeam, enemyTeamUser.getTeam().getScore(), myPPP, enemyPPP, game.getSeason().getId()); + updatePPP(enemyTeamUser, enemyTeam, myTeamUser.getTeam().getScore(), enemyPPP, myPPP, game.getSeason().getId()); + updateRankUser(key, zsetKey, myTeamUser.getUser().getId(), myTeam); + updateRankUser(key, zsetKey, enemyTeamUser.getUser().getId(), enemyTeam); + pChangeService.addPChange(game, myTeamUser.getUser(), myTeam.getPpp(), false); + pChangeService.addPChange(game, enemyTeamUser.getUser(), enemyTeam.getPpp(), false); + } - public Integer getUserPpp(Long userId, Long seasonId) { - String hashKey = RedisKeyManager.getHashKey(seasonId); - return rankRedisRepository.findRankByUserId(hashKey, userId).getPpp(); - } - public void updateAdminRankData(TeamUser myTeamUser, TeamUser enemyTeamUser, Game game, RankRedis myTeam, RankRedis enemyTeam) { - // 단식 -> 2명 기준 - String key = RedisKeyManager.getHashKey(game.getSeason().getId()); - String zsetKey = RedisKeyManager.getZSetKey(game.getSeason().getId()); - Integer myPPP = myTeam.getPpp(); - Integer enemyPPP = enemyTeam.getPpp(); - updatePPP(myTeamUser, myTeam, enemyTeamUser.getTeam().getScore(), myPPP, enemyPPP, game.getSeason().getId()); - updatePPP(enemyTeamUser, enemyTeam, myTeamUser.getTeam().getScore(), enemyPPP, myPPP, game.getSeason().getId()); - updateRankUser(key, zsetKey, myTeamUser.getUser().getId(), myTeam); - updateRankUser(key, zsetKey, enemyTeamUser.getUser().getId(), enemyTeam); - pChangeService.addPChange(game, myTeamUser.getUser(), myTeam.getPpp(), false); - pChangeService.addPChange(game, enemyTeamUser.getUser(), enemyTeam.getPpp(), false); - } - public void updateRankRedis(TeamUser myTeamUser, TeamUser enemyTeamUser, Game game) { - // 단식 -> 2명 기준 - String key = RedisKeyManager.getHashKey(game.getSeason().getId()); - String zsetKey = RedisKeyManager.getZSetKey(game.getSeason().getId()); - RankRedis myTeam = rankRedisRepository.findRankByUserId(key, myTeamUser.getUser().getId()); - RankRedis enemyTeam = rankRedisRepository.findRankByUserId(key, enemyTeamUser.getUser().getId()); - Integer myPPP = myTeam.getPpp(); - Integer enemyPPP = enemyTeam.getPpp(); - updatePPP(myTeamUser, myTeam, enemyTeamUser.getTeam().getScore(), myPPP, enemyPPP, game.getSeason().getId()); - updatePPP(enemyTeamUser, enemyTeam, myTeamUser.getTeam().getScore(), enemyPPP, myPPP, game.getSeason().getId()); - updateRankUser(key, zsetKey, myTeamUser.getUser().getId(), myTeam); - updateRankUser(key, zsetKey, enemyTeamUser.getUser().getId(), enemyTeam); - pChangeService.addPChange(game, myTeamUser.getUser(), myTeam.getPpp(), true); - pChangeService.addPChange(game, enemyTeamUser.getUser(), enemyTeam.getPpp(), false); - } + public void updateRankRedis(TeamUser myTeamUser, TeamUser enemyTeamUser, Game game) { + // 단식 -> 2명 기준 + String key = RedisKeyManager.getHashKey(game.getSeason().getId()); + String zsetKey = RedisKeyManager.getZSetKey(game.getSeason().getId()); + RankRedis myTeam = rankRedisRepository.findRankByUserId(key, myTeamUser.getUser().getId()); + RankRedis enemyTeam = rankRedisRepository.findRankByUserId(key, enemyTeamUser.getUser().getId()); + Integer myPPP = myTeam.getPpp(); + Integer enemyPPP = enemyTeam.getPpp(); + updatePPP(myTeamUser, myTeam, enemyTeamUser.getTeam().getScore(), myPPP, enemyPPP, game.getSeason().getId()); + updatePPP(enemyTeamUser, enemyTeam, myTeamUser.getTeam().getScore(), enemyPPP, myPPP, game.getSeason().getId()); + updateRankUser(key, zsetKey, myTeamUser.getUser().getId(), myTeam); + updateRankUser(key, zsetKey, enemyTeamUser.getUser().getId(), enemyTeam); + pChangeService.addPChange(game, myTeamUser.getUser(), myTeam.getPpp(), true); + pChangeService.addPChange(game, enemyTeamUser.getUser(), enemyTeam.getPpp(), false); + } - private void updateRankUser(String hashKey, String zsetKey, Long userId, RankRedis userRank) { - rankRedisRepository.updateRankData(hashKey, userId, userRank); - rankRedisRepository.deleteFromZSet(zsetKey, userId); - rankRedisRepository.addToZSet(zsetKey, userId, userRank.getPpp()); - } + private void updateRankUser(String hashKey, String zsetKey, Long userId, RankRedis userRank) { + rankRedisRepository.updateRankData(hashKey, userId, userRank); + rankRedisRepository.deleteFromZSet(zsetKey, userId); + rankRedisRepository.addToZSet(zsetKey, userId, userRank.getPpp()); + } - @Transactional - public void updatePPP(TeamUser teamuser, RankRedis myTeam, int enemyScore, Integer myPPP, Integer enemyPPP, Long seasonId) { - // rank table 수정 - Rank rank = rankRepository.findByUserIdAndSeasonId(myTeam.getUserId(), seasonId) - .orElseThrow(() -> new NotExistException("rank 정보가 없습니다.", ErrorCode.NOT_FOUND)); - int win = teamuser.getTeam().getWin() ? rank.getWins() + 1 : rank.getWins(); - int losses = !teamuser.getTeam().getWin() ? rank.getLosses() + 1: rank.getLosses(); - Integer changedPpp = EloRating.pppChange(myPPP, enemyPPP, - teamuser.getTeam().getWin(), - Math.abs(teamuser.getTeam().getScore() - enemyScore) == 2); - log.info("update before: intraId: " + teamuser.getUser().getIntraId() + ", win: db(" + rank.getWins() - + "), redis(" + myTeam.getWins() + "), losses: db(" + rank.getLosses() - + "), redis(" + myTeam.getLosses() + ")"); - rank.modifyUserRank(rank.getPpp() + changedPpp, win, losses); - myTeam.updateRank(changedPpp, - win, losses); - log.info("update after: intraId: " + teamuser.getUser().getIntraId() + ", win: db(" + rank.getWins() - + "), redis(" + myTeam.getWins() + "), losses: db(" + rank.getLosses() - + "), redis(" + myTeam.getLosses() + ")"); - } + @Transactional + public void updatePPP(TeamUser teamuser, RankRedis myTeam, int enemyScore, Integer myPPP, Integer enemyPPP, + Long seasonId) { + // rank table 수정 + Rank rank = rankRepository.findByUserIdAndSeasonId(myTeam.getUserId(), seasonId) + .orElseThrow(() -> new NotExistException("rank 정보가 없습니다.", ErrorCode.NOT_FOUND)); + int win = teamuser.getTeam().getWin() ? rank.getWins() + 1 : rank.getWins(); + int losses = !teamuser.getTeam().getWin() ? rank.getLosses() + 1 : rank.getLosses(); + Integer changedPpp = EloRating.pppChange(myPPP, enemyPPP, + teamuser.getTeam().getWin(), + Math.abs(teamuser.getTeam().getScore() - enemyScore) == 2); + log.info("update before: intraId: " + teamuser.getUser().getIntraId() + ", win: db(" + rank.getWins() + + "), redis(" + myTeam.getWins() + "), losses: db(" + rank.getLosses() + + "), redis(" + myTeam.getLosses() + ")"); + rank.modifyUserRank(rank.getPpp() + changedPpp, win, losses); + myTeam.updateRank(changedPpp, + win, losses); + log.info("update after: intraId: " + teamuser.getUser().getIntraId() + ", win: db(" + rank.getWins() + + "), redis(" + myTeam.getWins() + "), losses: db(" + rank.getLosses() + + "), redis(" + myTeam.getLosses() + ")"); + } - @Transactional - public void updateAllTier(Long gameId) { - // 전체 레디스 랭크 티어 새로고침하는 로직 - Season targetSeason = seasonFindService.findSeasonByGameId(gameId); - String key = RedisKeyManager.getHashKey(targetSeason.getId()); - String zSetKey = RedisKeyManager.getZSetKey(targetSeason.getId()); - List rankRedisList = rankRedisRepository.findAllRanksOrderByPppDesc(key); - Long totalRankPlayers = rankRepository.countRealRankPlayers(targetSeason.getId()); - List tierList = tierRepository.findAll(Sort.by(Sort.Direction.ASC, "id")); + @Transactional + public void updateAllTier(Long gameId) { + // 전체 레디스 랭크 티어 새로고침하는 로직 + Season targetSeason = seasonFindService.findSeasonByGameId(gameId); + String key = RedisKeyManager.getHashKey(targetSeason.getId()); + String zSetKey = RedisKeyManager.getZSetKey(targetSeason.getId()); + List rankRedisList = rankRedisRepository.findAllRanksOrderByPppDesc(key); + Long totalRankPlayers = rankRepository.countRealRankPlayers(targetSeason.getId()); + List tierList = tierRepository.findAll(Sort.by(Sort.Direction.ASC, "id")); - int top30percentPpp = rankRedisList.get((int) (totalRankPlayers * 0.3)).getPpp(); - int top10percentPpp = rankRedisList.get((int) (totalRankPlayers * 0.1)).getPpp(); + int top30percentPpp = rankRedisList.get((int)(totalRankPlayers * 0.3)).getPpp(); + int top10percentPpp = rankRedisList.get((int)(totalRankPlayers * 0.1)).getPpp(); - for (int i = 0; i < rankRedisList.size(); i++) { - RankRedis rankRedis = rankRedisList.get(i); - if (rankRedis.getWins() == 0 && rankRedis.getLosses() == 0) { - rankRedis.updateTierImage(tierList.get(0).getImageUri()); - } else { - if (i < 3) { - rankRedis.updateTierImage(tierList.get(6).getImageUri()); - updateRankUser(key, zSetKey, rankRedis.getUserId(), rankRedis); - continue; - } - if (rankRedis.getPpp() < 970) { - // 970 미만 - rankRedis.updateTierImage(tierList.get(1).getImageUri()); - } else if (rankRedis.getPpp() < 1010) { - // 970 ~ 1009 - rankRedis.updateTierImage(tierList.get(2).getImageUri()); - } else if (rankRedis.getPpp() < 1050) { - // 1010 ~ 1049 - rankRedis.updateTierImage(tierList.get(3).getImageUri()); - } else { - if ((rankRedis.getPpp() >= top30percentPpp) && (rankRedis.getPpp() < top10percentPpp)) { - // 1050 이상, 30% 이상, 10% 미만 - rankRedis.updateTierImage(tierList.get(4).getImageUri()); - } else if (rankRedis.getPpp() >= top10percentPpp) { - // 1050 이상, 10% 이상 - rankRedis.updateTierImage(tierList.get(5).getImageUri()); - } else { - // 1050 이상, 30% 미만 - rankRedis.updateTierImage(tierList.get(3).getImageUri()); - } - } - updateRankUser(key, zSetKey, rankRedis.getUserId(), rankRedis); - } - } - } + for (int i = 0; i < rankRedisList.size(); i++) { + RankRedis rankRedis = rankRedisList.get(i); + if (rankRedis.getWins() == 0 && rankRedis.getLosses() == 0) { + rankRedis.updateTierImage(tierList.get(0).getImageUri()); + } else { + if (i < 3) { + rankRedis.updateTierImage(tierList.get(6).getImageUri()); + updateRankUser(key, zSetKey, rankRedis.getUserId(), rankRedis); + continue; + } + if (rankRedis.getPpp() < 970) { + // 970 미만 + rankRedis.updateTierImage(tierList.get(1).getImageUri()); + } else if (rankRedis.getPpp() < 1010) { + // 970 ~ 1009 + rankRedis.updateTierImage(tierList.get(2).getImageUri()); + } else if (rankRedis.getPpp() < 1050) { + // 1010 ~ 1049 + rankRedis.updateTierImage(tierList.get(3).getImageUri()); + } else { + if ((rankRedis.getPpp() >= top30percentPpp) && (rankRedis.getPpp() < top10percentPpp)) { + // 1050 이상, 30% 이상, 10% 미만 + rankRedis.updateTierImage(tierList.get(4).getImageUri()); + } else if (rankRedis.getPpp() >= top10percentPpp) { + // 1050 이상, 10% 이상 + rankRedis.updateTierImage(tierList.get(5).getImageUri()); + } else { + // 1050 이상, 30% 미만 + rankRedis.updateTierImage(tierList.get(3).getImageUri()); + } + } + updateRankUser(key, zSetKey, rankRedis.getUserId(), rankRedis); + } + } + } - @Transactional - public RankRedis rollbackRank(TeamUser teamUser, int ppp, Long seasonId) { - String hashkey = RedisKeyManager.getHashKey(seasonId); - RankRedis myTeam = rankRedisRepository.findRankByUserId(hashkey, teamUser.getUser().getId()); - Rank rank = rankRepository.findByUserIdAndSeasonId(myTeam.getUserId(), seasonId) - .orElseThrow(RankNotFoundException::new); - int win = teamUser.getTeam().getWin() ? rank.getWins() - 1 : rank.getWins(); - int losses = !teamUser.getTeam().getWin() ? rank.getLosses() - 1: rank.getLosses(); - log.info("Before: userId: " + teamUser.getUser().getIntraId() + ", " + "ppp: rank(" - + rank.getPpp() + "), redis(" + myTeam.getPpp() + "), win: " + myTeam.getWins() - + ", losses: " + myTeam.getLosses()); - rank.modifyUserRank(ppp, win, losses); - myTeam.changedRank(ppp, win, losses); - updateRankUser(hashkey, RedisKeyManager.getZSetKey(seasonId), teamUser.getUser().getId(), myTeam); - entityManager.flush(); - log.info("After: userId: " + teamUser.getUser().getIntraId() + ", " + "ppp: rank(" - + rank.getPpp() + "), redis(" + myTeam.getPpp() + "), win: " + myTeam.getWins() - + ", losses: " + myTeam.getLosses()); - return myTeam; - } + @Transactional + public RankRedis rollbackRank(TeamUser teamUser, int ppp, Long seasonId) { + String hashkey = RedisKeyManager.getHashKey(seasonId); + RankRedis myTeam = rankRedisRepository.findRankByUserId(hashkey, teamUser.getUser().getId()); + Rank rank = rankRepository.findByUserIdAndSeasonId(myTeam.getUserId(), seasonId) + .orElseThrow(RankNotFoundException::new); + int win = teamUser.getTeam().getWin() ? rank.getWins() - 1 : rank.getWins(); + int losses = !teamUser.getTeam().getWin() ? rank.getLosses() - 1 : rank.getLosses(); + log.info("Before: userId: " + teamUser.getUser().getIntraId() + ", " + "ppp: rank(" + + rank.getPpp() + "), redis(" + myTeam.getPpp() + "), win: " + myTeam.getWins() + + ", losses: " + myTeam.getLosses()); + rank.modifyUserRank(ppp, win, losses); + myTeam.changedRank(ppp, win, losses); + updateRankUser(hashkey, RedisKeyManager.getZSetKey(seasonId), teamUser.getUser().getId(), myTeam); + entityManager.flush(); + log.info("After: userId: " + teamUser.getUser().getIntraId() + ", " + "ppp: rank(" + + rank.getPpp() + "), redis(" + myTeam.getPpp() + "), win: " + myTeam.getWins() + + ", losses: " + myTeam.getLosses()); + return myTeam; + } } diff --git a/src/main/java/com/gg/server/domain/rank/redis/RedisKeyManager.java b/src/main/java/com/gg/server/domain/rank/redis/RedisKeyManager.java index ebff0d996..cb55ca29f 100644 --- a/src/main/java/com/gg/server/domain/rank/redis/RedisKeyManager.java +++ b/src/main/java/com/gg/server/domain/rank/redis/RedisKeyManager.java @@ -1,19 +1,19 @@ package com.gg.server.domain.rank.redis; public class RedisKeyManager { - private static final String ZSetKeyPrefix = "rank:ZSet:"; - private static final String HashKeyPrefix = "rank:hash:"; - private static final String RefKeyPrefix = "refresh:token:"; + private static final String ZSetKeyPrefix = "rank:ZSet:"; + private static final String HashKeyPrefix = "rank:hash:"; + private static final String RefKeyPrefix = "refresh:token:"; - public static String getZSetKey(Long seasonId) { - return ZSetKeyPrefix + seasonId; - } + public static String getZSetKey(Long seasonId) { + return ZSetKeyPrefix + seasonId; + } - public static String getHashKey(Long seasonId) { - return HashKeyPrefix + seasonId; - } + public static String getHashKey(Long seasonId) { + return HashKeyPrefix + seasonId; + } - public static String getRefKey(Long id) { - return RefKeyPrefix + id.toString(); - } + public static String getRefKey(Long id) { + return RefKeyPrefix + id.toString(); + } } diff --git a/src/main/java/com/gg/server/domain/rank/service/RankFindService.java b/src/main/java/com/gg/server/domain/rank/service/RankFindService.java index f6e7e1f87..d71e2aa95 100644 --- a/src/main/java/com/gg/server/domain/rank/service/RankFindService.java +++ b/src/main/java/com/gg/server/domain/rank/service/RankFindService.java @@ -1,19 +1,19 @@ package com.gg.server.domain.rank.service; +import org.springframework.stereotype.Service; + import com.gg.server.domain.rank.data.Rank; import com.gg.server.domain.rank.data.RankRepository; import com.gg.server.domain.rank.exception.RankNotFoundException; -import com.gg.server.global.exception.ErrorCode; + import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor public class RankFindService { - private final RankRepository rankRepository; + private final RankRepository rankRepository; - public Rank findByUserIdAndSeasonId(Long userId, Long seasonId){ - return rankRepository.findByUserIdAndSeasonId(userId, seasonId).orElseThrow(() -> new RankNotFoundException()); - } + public Rank findByUserIdAndSeasonId(Long userId, Long seasonId) { + return rankRepository.findByUserIdAndSeasonId(userId, seasonId).orElseThrow(() -> new RankNotFoundException()); + } } diff --git a/src/main/java/com/gg/server/domain/rank/service/RankService.java b/src/main/java/com/gg/server/domain/rank/service/RankService.java index 4042287a1..bdad84a73 100644 --- a/src/main/java/com/gg/server/domain/rank/service/RankService.java +++ b/src/main/java/com/gg/server/domain/rank/service/RankService.java @@ -1,198 +1,210 @@ -package com.gg.server.domain.rank.service; - -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.dto.ExpRankDto; -import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; -import com.gg.server.domain.rank.dto.ExpRankV2Dto; -import com.gg.server.domain.rank.dto.RankDto; -import com.gg.server.domain.rank.dto.RankPageResponseDto; -import com.gg.server.domain.rank.dto.RankV2Dto; -import com.gg.server.domain.rank.exception.RedisDataNotFoundException; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.PageNotFoundException; -import lombok.RequiredArgsConstructor; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -@Service -@RequiredArgsConstructor -public class RankService { - private final UserRepository userRepository; - private final RankRedisRepository redisRepository; - private final SeasonFindService seasonFindService; - private final RankRepository rankRepository; - - @Transactional(readOnly = true) - public ExpRankPageResponseDto getExpRankPageByRedis(PageRequest pageRequest, UserDto curUser) { - - Long myRank = curUser.getTotalExp() == 0 ? -1 : userRepository.findExpRankingByIntraId(curUser.getIntraId()); - Page users = userRepository.findAllByTotalExpGreaterThan(pageRequest, 0); - if(pageRequest.getPageNumber() + 1 > users.getTotalPages()) - throw new PageNotFoundException("페이지가 존재하지 않습니다.", ErrorCode.PAGE_NOT_FOUND); - - List userIds = users.getContent().stream().map(user -> user.getId()).collect(Collectors.toList()); - Season curSeason = seasonFindService.findCurrentSeason(LocalDateTime.now()); - - String hashKey = RedisKeyManager.getHashKey(curSeason.getId()); - List ranks = redisRepository.findRanksByUserIds(hashKey, userIds); - - Integer startRank = pageRequest.getPageSize() * pageRequest.getPageNumber() + 1; - List expRankDtos = new ArrayList<>(); - for(int i = 0; i < ranks.size(); i++) { - RankRedis rank = ranks.get(i); - User user = users.getContent().get(i); - expRankDtos.add(ExpRankDto.from(user, startRank + i, rank.getStatusMessage())); - } - - return new ExpRankPageResponseDto(myRank.intValue(), pageRequest.getPageNumber() + 1, users.getTotalPages(), expRankDtos); - } - - /** - * ExpRankPage v2 (redis 조회 제거 - db 조회로만 하는 기능) - * @param pageRequest - * @param curUser - * @return - */ - @Transactional(readOnly = true) - public ExpRankPageResponseDto getExpRankPage(PageRequest pageRequest, UserDto curUser) { - - Long myRank = curUser.getTotalExp() == 0 ? -1 : userRepository.findExpRankingByIntraId(curUser.getIntraId()); - Page users = userRepository.findAllByTotalExpGreaterThan(pageRequest, 0); - if(pageRequest.getPageNumber() + 1 > users.getTotalPages()) - throw new PageNotFoundException(); - List expRankDtos = getExpRankList(pageRequest); - - return new ExpRankPageResponseDto(myRank.intValue(), - pageRequest.getPageNumber() + 1, - users.getTotalPages(), - expRankDtos); - } - - @Cacheable(value = "expRanking", cacheManager = "gameCacheManager", - key = "#pageRequest.pageNumber + #pageRequest.pageSize.toString()") - public List getExpRankList(PageRequest pageRequest) { - Season curSeason = seasonFindService.findCurrentSeason(LocalDateTime.now()); - int pageOffset = pageRequest.getPageNumber() * pageRequest.getPageSize(); - List expRankV2Dtos = userRepository.findExpRank(pageOffset, pageRequest.getPageSize(), curSeason.getId()); - return expRankV2Dtos.stream().map(ExpRankDto::from).collect(Collectors.toList()); - } - - /** - * rank 페이지 조회 v2 - * @param pageRequest - * @param curUser - * @param seasonId - * @return - */ - @Transactional(readOnly = true) - @Cacheable(value = "ranking", cacheManager = "gameCacheManager", - key = "#pageRequest.pageSize.toString() + #pageRequest.pageNumber + #curUser.id + #seasonId") - public RankPageResponseDto getRankPageV2(PageRequest pageRequest, UserDto curUser, Long seasonId) { - Season season; - if (seasonId == null || seasonId == 0) { - season = seasonFindService.findCurrentSeason(LocalDateTime.now()); - } else { - season = seasonFindService.findSeasonById(seasonId); - } - int totalPage = calcTotalPageV2(season, pageRequest.getPageSize()); - if (totalPage == 0) - return returnEmptyRankPage(); - if (pageRequest.getPageNumber() + 1 > totalPage) - throw new PageNotFoundException(); - - int myRank = rankRepository.findRankByUserIdAndSeasonId(curUser.getId(), season.getId()) - .orElse(-1); - int pageOffset = pageRequest.getPageNumber() * pageRequest.getPageSize(); - List rankList = rankRepository.findPppRankBySeasonId(pageOffset, pageRequest.getPageSize(), season.getId()) - .stream().map(RankDto::from).collect(Collectors.toList()); - return new RankPageResponseDto(myRank, pageRequest.getPageNumber() + 1, totalPage, rankList); - } - - @Transactional(readOnly = true) - public RankPageResponseDto getRankPage(PageRequest pageRequest, UserDto curUser, Long seasonId) { - Season season; - if (seasonId == null || seasonId == 0) { - season = seasonFindService.findCurrentSeason(LocalDateTime.now()); - } else { - season = seasonFindService.findSeasonById(seasonId); - } - int totalPage = calcTotalPage(season, pageRequest.getPageSize()); - if (totalPage == 0) - return returnEmptyRankPage(); - if (pageRequest.getPageNumber() + 1 > totalPage) - throw new PageNotFoundException("페이지가 존재하지 않습니다.", ErrorCode.PAGE_NOT_FOUND); - - int myRank = findMyRank(curUser, season); - int startRank = pageRequest.getPageNumber() * pageRequest.getPageSize(); - int endRank = startRank + pageRequest.getPageSize() - 1; - List rankList = createRankList(startRank, endRank, season); - return new RankPageResponseDto(myRank, pageRequest.getPageNumber() + 1, totalPage, rankList); - } - - private RankPageResponseDto returnEmptyRankPage() { - return new RankPageResponseDto(-1, 1, 1, new ArrayList<>()); - } - private int findMyRank(UserDto curUser, Season season) { - String zSetKey = RedisKeyManager.getZSetKey(season.getId()); - try { - Long myRank = redisRepository.getRankInZSet(zSetKey, curUser.getId()); - return myRank.intValue() + 1; - } catch (RedisDataNotFoundException e) { - return -1; - } - } - private int calcTotalPage(Season season, int pageSize) { - String zSetKey = RedisKeyManager.getZSetKey(season.getId()); - try{ - Long totalUserCount = redisRepository.countTotalRank(zSetKey); - return (int) Math.ceil((double) totalUserCount / pageSize); - } catch (RedisDataNotFoundException e) { - return 0; - } - } - private int calcTotalPageV2(Season season, int pageSize) { - try{ - Integer totalUserCount = rankRepository.countRankUserBySeasonId(season.getId()); - return (int) Math.ceil((double) totalUserCount / pageSize); - } catch (RedisDataNotFoundException e) { - return 0; - } - } - private List createRankList(int startRank, int endRank, Season season) { - String zSetKey = RedisKeyManager.getZSetKey(season.getId()); - String hashKey = RedisKeyManager.getHashKey(season.getId()); - - List userIds = redisRepository.getUserIdsByRangeFromZSet(zSetKey, startRank, endRank); - List userRanks = redisRepository.findRanksByUserIds(hashKey, userIds); - List rankList = new ArrayList<>(); - - for (int i = 0; i < userRanks.size(); i++) { - User user = userRepository.findById(userIds.get(i)).orElseThrow(UserNotFoundException::new); - rankList.add(RankDto.from(user, userRanks.get(i), ++startRank)); - } -// for (RankRedis userRank : userRanks) { -// rankList.add(RankDto.from()) -// rankList.add(RankDto.from(userRank, ++startRank)); -// } - return rankList; - } -} \ No newline at end of file +package com.gg.server.domain.rank.service; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.domain.rank.data.RankRepository; +import com.gg.server.domain.rank.dto.ExpRankDto; +import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; +import com.gg.server.domain.rank.dto.ExpRankV2Dto; +import com.gg.server.domain.rank.dto.RankDto; +import com.gg.server.domain.rank.dto.RankPageResponseDto; +import com.gg.server.domain.rank.exception.RedisDataNotFoundException; +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.rank.redis.RedisKeyManager; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.service.SeasonFindService; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.exception.UserNotFoundException; +import com.gg.server.global.exception.ErrorCode; +import com.gg.server.global.exception.custom.PageNotFoundException; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class RankService { + private final UserRepository userRepository; + private final RankRedisRepository redisRepository; + private final SeasonFindService seasonFindService; + private final RankRepository rankRepository; + + @Transactional(readOnly = true) + public ExpRankPageResponseDto getExpRankPageByRedis(PageRequest pageRequest, UserDto curUser) { + + Long myRank = curUser.getTotalExp() == 0 ? -1 : userRepository.findExpRankingByIntraId(curUser.getIntraId()); + Page users = userRepository.findAllByTotalExpGreaterThan(pageRequest, 0); + if (pageRequest.getPageNumber() + 1 > users.getTotalPages()) { + throw new PageNotFoundException("페이지가 존재하지 않습니다.", ErrorCode.PAGE_NOT_FOUND); + } + + List userIds = users.getContent().stream().map(user -> user.getId()).collect(Collectors.toList()); + Season curSeason = seasonFindService.findCurrentSeason(LocalDateTime.now()); + + String hashKey = RedisKeyManager.getHashKey(curSeason.getId()); + List ranks = redisRepository.findRanksByUserIds(hashKey, userIds); + + Integer startRank = pageRequest.getPageSize() * pageRequest.getPageNumber() + 1; + List expRankDtos = new ArrayList<>(); + for (int i = 0; i < ranks.size(); i++) { + RankRedis rank = ranks.get(i); + User user = users.getContent().get(i); + expRankDtos.add(ExpRankDto.from(user, startRank + i, rank.getStatusMessage())); + } + + return new ExpRankPageResponseDto(myRank.intValue(), pageRequest.getPageNumber() + 1, users.getTotalPages(), + expRankDtos); + } + + /** + * ExpRankPage v2 (redis 조회 제거 - db 조회로만 하는 기능) + * @param pageRequest + * @param curUser + * @return + */ + @Transactional(readOnly = true) + public ExpRankPageResponseDto getExpRankPage(PageRequest pageRequest, UserDto curUser) { + + Long myRank = curUser.getTotalExp() == 0 ? -1 : userRepository.findExpRankingByIntraId(curUser.getIntraId()); + Page users = userRepository.findAllByTotalExpGreaterThan(pageRequest, 0); + if (pageRequest.getPageNumber() + 1 > users.getTotalPages()) { + throw new PageNotFoundException(); + } + List expRankDtos = getExpRankList(pageRequest); + + return new ExpRankPageResponseDto(myRank.intValue(), + pageRequest.getPageNumber() + 1, + users.getTotalPages(), + expRankDtos); + } + + @Cacheable(value = "expRanking", cacheManager = "gameCacheManager", + key = "#pageRequest.pageNumber + #pageRequest.pageSize.toString()") + public List getExpRankList(PageRequest pageRequest) { + Season curSeason = seasonFindService.findCurrentSeason(LocalDateTime.now()); + int pageOffset = pageRequest.getPageNumber() * pageRequest.getPageSize(); + List expRankV2Dtos = userRepository.findExpRank(pageOffset, pageRequest.getPageSize(), + curSeason.getId()); + return expRankV2Dtos.stream().map(ExpRankDto::from).collect(Collectors.toList()); + } + + /** + * rank 페이지 조회 v2 + * @param pageRequest + * @param curUser + * @param seasonId + * @return + */ + @Transactional(readOnly = true) + @Cacheable(value = "ranking", cacheManager = "gameCacheManager", + key = "#pageRequest.pageSize.toString() + #pageRequest.pageNumber + #curUser.id + #seasonId") + public RankPageResponseDto getRankPageV2(PageRequest pageRequest, UserDto curUser, Long seasonId) { + Season season; + if (seasonId == null || seasonId == 0) { + season = seasonFindService.findCurrentSeason(LocalDateTime.now()); + } else { + season = seasonFindService.findSeasonById(seasonId); + } + int totalPage = calcTotalPageV2(season, pageRequest.getPageSize()); + if (totalPage == 0) { + return returnEmptyRankPage(); + } + if (pageRequest.getPageNumber() + 1 > totalPage) { + throw new PageNotFoundException(); + } + + int myRank = rankRepository.findRankByUserIdAndSeasonId(curUser.getId(), season.getId()) + .orElse(-1); + int pageOffset = pageRequest.getPageNumber() * pageRequest.getPageSize(); + List rankList = rankRepository.findPppRankBySeasonId(pageOffset, pageRequest.getPageSize(), + season.getId()) + .stream().map(RankDto::from).collect(Collectors.toList()); + return new RankPageResponseDto(myRank, pageRequest.getPageNumber() + 1, totalPage, rankList); + } + + @Transactional(readOnly = true) + public RankPageResponseDto getRankPage(PageRequest pageRequest, UserDto curUser, Long seasonId) { + Season season; + if (seasonId == null || seasonId == 0) { + season = seasonFindService.findCurrentSeason(LocalDateTime.now()); + } else { + season = seasonFindService.findSeasonById(seasonId); + } + int totalPage = calcTotalPage(season, pageRequest.getPageSize()); + if (totalPage == 0) { + return returnEmptyRankPage(); + } + if (pageRequest.getPageNumber() + 1 > totalPage) { + throw new PageNotFoundException("페이지가 존재하지 않습니다.", ErrorCode.PAGE_NOT_FOUND); + } + + int myRank = findMyRank(curUser, season); + int startRank = pageRequest.getPageNumber() * pageRequest.getPageSize(); + int endRank = startRank + pageRequest.getPageSize() - 1; + List rankList = createRankList(startRank, endRank, season); + return new RankPageResponseDto(myRank, pageRequest.getPageNumber() + 1, totalPage, rankList); + } + + private RankPageResponseDto returnEmptyRankPage() { + return new RankPageResponseDto(-1, 1, 1, new ArrayList<>()); + } + + private int findMyRank(UserDto curUser, Season season) { + String zSetKey = RedisKeyManager.getZSetKey(season.getId()); + try { + Long myRank = redisRepository.getRankInZSet(zSetKey, curUser.getId()); + return myRank.intValue() + 1; + } catch (RedisDataNotFoundException e) { + return -1; + } + } + + private int calcTotalPage(Season season, int pageSize) { + String zSetKey = RedisKeyManager.getZSetKey(season.getId()); + try { + Long totalUserCount = redisRepository.countTotalRank(zSetKey); + return (int)Math.ceil((double)totalUserCount / pageSize); + } catch (RedisDataNotFoundException e) { + return 0; + } + } + + private int calcTotalPageV2(Season season, int pageSize) { + try { + Integer totalUserCount = rankRepository.countRankUserBySeasonId(season.getId()); + return (int)Math.ceil((double)totalUserCount / pageSize); + } catch (RedisDataNotFoundException e) { + return 0; + } + } + + private List createRankList(int startRank, int endRank, Season season) { + String zSetKey = RedisKeyManager.getZSetKey(season.getId()); + String hashKey = RedisKeyManager.getHashKey(season.getId()); + + List userIds = redisRepository.getUserIdsByRangeFromZSet(zSetKey, startRank, endRank); + List userRanks = redisRepository.findRanksByUserIds(hashKey, userIds); + List rankList = new ArrayList<>(); + + for (int i = 0; i < userRanks.size(); i++) { + User user = userRepository.findById(userIds.get(i)).orElseThrow(UserNotFoundException::new); + rankList.add(RankDto.from(user, userRanks.get(i), ++startRank)); + } + // for (RankRedis userRank : userRanks) { + // rankList.add(RankDto.from()) + // rankList.add(RankDto.from(userRank, ++startRank)); + // } + return rankList; + } +} diff --git a/src/main/java/com/gg/server/domain/rank/service/RedisUploadService.java b/src/main/java/com/gg/server/domain/rank/service/RedisUploadService.java index 35c47c883..19a6c2a02 100644 --- a/src/main/java/com/gg/server/domain/rank/service/RedisUploadService.java +++ b/src/main/java/com/gg/server/domain/rank/service/RedisUploadService.java @@ -1,73 +1,77 @@ package com.gg.server.domain.rank.service; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.data.SeasonRepository; -import lombok.RequiredArgsConstructor; +import java.time.LocalDateTime; + +import javax.annotation.PostConstruct; + import org.springframework.data.redis.core.RedisCallback; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.annotation.PostConstruct; -import java.time.LocalDateTime; +import com.gg.server.domain.rank.data.RankRepository; +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.rank.redis.RedisKeyManager; +import com.gg.server.domain.season.data.SeasonRepository; + +import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class RedisUploadService { - private final RankRedisRepository redisRepository; - private final SeasonRepository seasonRepository; - private final RankRepository rankRepository; - private final RedisTemplate redisTemplate; + private final RankRedisRepository redisRepository; + private final SeasonRepository seasonRepository; + private final RankRepository rankRepository; + private final RedisTemplate redisTemplate; - @PostConstruct - @Transactional - public void uploadRedis() { - seasonRepository.findCurrentSeason(LocalDateTime.now()).ifPresent( currentSeason -> { - String hashKey = RedisKeyManager.getHashKey(currentSeason.getId()); - if(redisRepository.isEmpty(hashKey)) upload(); - }); - } + @PostConstruct + @Transactional + public void uploadRedis() { + seasonRepository.findCurrentSeason(LocalDateTime.now()).ifPresent(currentSeason -> { + String hashKey = RedisKeyManager.getHashKey(currentSeason.getId()); + if (redisRepository.isEmpty(hashKey)) { + upload(); + } + }); + } - private void upload() { + private void upload() { - redisTemplate.executePipelined((RedisCallback) connection ->{ - seasonRepository.findAll().forEach(season -> { - String hashKey = RedisKeyManager.getHashKey(season.getId()); - String zSetKey = RedisKeyManager.getZSetKey(season.getId()); - rankRepository.findAllBySeasonId(season.getId()).forEach(rank -> { - RankRedis rankRedis = RankRedis.from(rank); - connection.hSet(keySerializer().serialize(hashKey), - hashKeySerializer().serialize(rank.getUser().getId().toString()), - hashValueSerializer().serialize(rankRedis)); - if (rank.getWins() + rankRedis.getLosses() != 0){ - connection.zAdd(keySerializer().serialize(zSetKey), rank.getPpp(), - valueSerializer().serialize(rank.getUser().getId().toString())); - } - }); - }); - return null; - }); - } + redisTemplate.executePipelined((RedisCallback)connection -> { + seasonRepository.findAll().forEach(season -> { + String hashKey = RedisKeyManager.getHashKey(season.getId()); + String zSetKey = RedisKeyManager.getZSetKey(season.getId()); + rankRepository.findAllBySeasonId(season.getId()).forEach(rank -> { + RankRedis rankRedis = RankRedis.from(rank); + connection.hSet(keySerializer().serialize(hashKey), + hashKeySerializer().serialize(rank.getUser().getId().toString()), + hashValueSerializer().serialize(rankRedis)); + if (rank.getWins() + rankRedis.getLosses() != 0) { + connection.zAdd(keySerializer().serialize(zSetKey), rank.getPpp(), + valueSerializer().serialize(rank.getUser().getId().toString())); + } + }); + }); + return null; + }); + } - private RedisSerializer valueSerializer() { - return redisTemplate.getValueSerializer(); - } + private RedisSerializer valueSerializer() { + return redisTemplate.getValueSerializer(); + } - private RedisSerializer hashValueSerializer() { - return redisTemplate.getHashValueSerializer(); - } + private RedisSerializer hashValueSerializer() { + return redisTemplate.getHashValueSerializer(); + } - private RedisSerializer hashKeySerializer() { - return redisTemplate.getHashKeySerializer(); - } + private RedisSerializer hashKeySerializer() { + return redisTemplate.getHashKeySerializer(); + } - private RedisSerializer keySerializer() { - return redisTemplate.getKeySerializer(); - } + private RedisSerializer keySerializer() { + return redisTemplate.getKeySerializer(); + } } diff --git a/src/main/java/com/gg/server/domain/receipt/data/Receipt.java b/src/main/java/com/gg/server/domain/receipt/data/Receipt.java index 33df458ca..f7c1f03a8 100644 --- a/src/main/java/com/gg/server/domain/receipt/data/Receipt.java +++ b/src/main/java/com/gg/server/domain/receipt/data/Receipt.java @@ -1,67 +1,78 @@ -package com.gg.server.domain.receipt.data; - -import com.gg.server.domain.item.data.Item; -import com.gg.server.domain.receipt.type.ItemStatus; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import javax.persistence.*; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - -@Getter -@NoArgsConstructor -@AllArgsConstructor -@Entity -public class Receipt { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "item_id") - private Item item; - - @NotNull - @Column(name = "purchaser_intra_id") - private String purchaserIntraId; - - @NotNull - @Column(name = "owner_intra_id") - private String ownerIntraId; - - @NotNull - @Enumerated(EnumType.STRING) - private ItemStatus status; - - @NotNull - @Column(name = "created_at") - private LocalDateTime createdAt; - - public Receipt(Item item, String purchaserIntraId, String ownerIntraId, - ItemStatus status, LocalDateTime purchasedAt) { - this.item = item; - this.purchaserIntraId = purchaserIntraId; - this.ownerIntraId = ownerIntraId; - this.status = status; - this.createdAt = purchasedAt; - } - - @Override - public String toString() { - return "Receipt{" + - "id=" + id + - ", item=" + item + - ", purchaserIntraId='" + purchaserIntraId + '\'' + - ", ownerIntraId='" + ownerIntraId + '\'' + - ", status=" + status + - ", purchasedAt=" + createdAt + - '}'; - } - - public void updateStatus(ItemStatus status) { - this.status = status; - } -} \ No newline at end of file +package com.gg.server.domain.receipt.data; + +import java.time.LocalDateTime; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.validation.constraints.NotNull; + +import com.gg.server.domain.item.data.Item; +import com.gg.server.domain.receipt.type.ItemStatus; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +@Entity +public class Receipt { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "item_id") + private Item item; + + @NotNull + @Column(name = "purchaser_intra_id") + private String purchaserIntraId; + + @NotNull + @Column(name = "owner_intra_id") + private String ownerIntraId; + + @NotNull + @Enumerated(EnumType.STRING) + private ItemStatus status; + + @NotNull + @Column(name = "created_at") + private LocalDateTime createdAt; + + public Receipt(Item item, String purchaserIntraId, String ownerIntraId, + ItemStatus status, LocalDateTime purchasedAt) { + this.item = item; + this.purchaserIntraId = purchaserIntraId; + this.ownerIntraId = ownerIntraId; + this.status = status; + this.createdAt = purchasedAt; + } + + @Override + public String toString() { + return "Receipt{" + + "id=" + id + + ", item=" + item + + ", purchaserIntraId='" + purchaserIntraId + '\'' + + ", ownerIntraId='" + ownerIntraId + '\'' + + ", status=" + status + + ", purchasedAt=" + createdAt + + '}'; + } + + public void updateStatus(ItemStatus status) { + this.status = status; + } +} diff --git a/src/main/java/com/gg/server/domain/receipt/exception/ItemStatusException.java b/src/main/java/com/gg/server/domain/receipt/exception/ItemStatusException.java index 102c8f46f..1dbace282 100644 --- a/src/main/java/com/gg/server/domain/receipt/exception/ItemStatusException.java +++ b/src/main/java/com/gg/server/domain/receipt/exception/ItemStatusException.java @@ -4,5 +4,7 @@ import com.gg.server.global.exception.custom.BusinessException; public class ItemStatusException extends BusinessException { - public ItemStatusException() {super("아이템 상태 오류입니다.", ErrorCode.RECEIPT_STATUS_NOT_MATCHED);} + public ItemStatusException() { + super("아이템 상태 오류입니다.", ErrorCode.RECEIPT_STATUS_NOT_MATCHED); + } } diff --git a/src/main/java/com/gg/server/domain/receipt/exception/ReceiptNotFoundException.java b/src/main/java/com/gg/server/domain/receipt/exception/ReceiptNotFoundException.java index 711812ea4..8e90fca5b 100644 --- a/src/main/java/com/gg/server/domain/receipt/exception/ReceiptNotFoundException.java +++ b/src/main/java/com/gg/server/domain/receipt/exception/ReceiptNotFoundException.java @@ -4,5 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class ReceiptNotFoundException extends NotExistException { - public ReceiptNotFoundException() {super("해당 거래내역이 없습니다.", ErrorCode.RECEIPT_NOT_FOUND);} + public ReceiptNotFoundException() { + super("해당 거래내역이 없습니다.", ErrorCode.RECEIPT_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/receipt/exception/ReceiptNotOwnerException.java b/src/main/java/com/gg/server/domain/receipt/exception/ReceiptNotOwnerException.java index 6441cd4ef..b758dbd01 100644 --- a/src/main/java/com/gg/server/domain/receipt/exception/ReceiptNotOwnerException.java +++ b/src/main/java/com/gg/server/domain/receipt/exception/ReceiptNotOwnerException.java @@ -4,5 +4,7 @@ import com.gg.server.global.exception.custom.ForbiddenException; public class ReceiptNotOwnerException extends ForbiddenException { - public ReceiptNotOwnerException() {super("아이템의 소유자가 아닙니다.", ErrorCode.RECEIPT_NOT_OWNER);} + public ReceiptNotOwnerException() { + super("아이템의 소유자가 아닙니다.", ErrorCode.RECEIPT_NOT_OWNER); + } } diff --git a/src/main/java/com/gg/server/domain/receipt/type/ItemStatus.java b/src/main/java/com/gg/server/domain/receipt/type/ItemStatus.java index de03b6551..fdcae3e08 100644 --- a/src/main/java/com/gg/server/domain/receipt/type/ItemStatus.java +++ b/src/main/java/com/gg/server/domain/receipt/type/ItemStatus.java @@ -1,16 +1,16 @@ -package com.gg.server.domain.receipt.type; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor -public enum ItemStatus { - BEFORE("사용 전"), - WAITING("사용 대기"), - USING("사용 중"), - USED("사용 완료"), - DELETED("삭제"); - - private final String description; -} \ No newline at end of file +package com.gg.server.domain.receipt.type; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum ItemStatus { + BEFORE("사용 전"), + WAITING("사용 대기"), + USING("사용 중"), + USED("사용 완료"), + DELETED("삭제"); + + private final String description; +} diff --git a/src/main/java/com/gg/server/domain/season/SeasonController.java b/src/main/java/com/gg/server/domain/season/SeasonController.java index f300817fe..4c02bdacc 100644 --- a/src/main/java/com/gg/server/domain/season/SeasonController.java +++ b/src/main/java/com/gg/server/domain/season/SeasonController.java @@ -1,20 +1,23 @@ package com.gg.server.domain.season; -import com.gg.server.domain.season.dto.SeasonListResDto; -import com.gg.server.domain.season.service.SeasonService; -import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.gg.server.domain.season.dto.SeasonListResDto; +import com.gg.server.domain.season.service.SeasonService; + +import lombok.RequiredArgsConstructor; + @RequiredArgsConstructor @RestController @RequestMapping("/pingpong/") public class SeasonController { - private final SeasonService seasonService; - @GetMapping("seasons") - public SeasonListResDto seasonList() { - return new SeasonListResDto(seasonService.seasonList()); - } + private final SeasonService seasonService; + + @GetMapping("seasons") + public SeasonListResDto seasonList() { + return new SeasonListResDto(seasonService.seasonList()); + } } diff --git a/src/main/java/com/gg/server/domain/season/data/Season.java b/src/main/java/com/gg/server/domain/season/data/Season.java index 96b2c4c7d..27f4c8ac0 100644 --- a/src/main/java/com/gg/server/domain/season/data/Season.java +++ b/src/main/java/com/gg/server/domain/season/data/Season.java @@ -1,60 +1,70 @@ package com.gg.server.domain.season.data; -import com.gg.server.admin.season.dto.SeasonCreateRequestDto; -import lombok.*; +import java.time.LocalDateTime; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; + +import com.gg.server.admin.season.dto.SeasonCreateRequestDto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; @NoArgsConstructor @AllArgsConstructor @Entity @Getter public class Season { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Setter - @NotNull - @Column(name = "season_name", length = 20) - private String seasonName; - - @Setter - @NotNull - @Column(name = "start_time") - private LocalDateTime startTime; - - @Setter - @NotNull - @Column(name = "end_time") - private LocalDateTime endTime; - - @Setter - @NotNull - @Column(name = "start_ppp") - private Integer startPpp; - - @Setter - @NotNull - @Column(name = "ppp_gap") - private Integer pppGap; - - @Builder - public Season(String seasonName, LocalDateTime startTime, LocalDateTime endTime, Integer startPpp, Integer pppGap) { - this.seasonName = seasonName; - this.startTime = startTime; - this.endTime = endTime; - this.startPpp = startPpp; - this.pppGap = pppGap; - } - - @Builder - public Season(SeasonCreateRequestDto createDto) { - this.seasonName = createDto.getSeasonName(); - this.startTime = createDto.getStartTime(); - this.startPpp = createDto.getStartPpp(); - this.pppGap = createDto.getPppGap(); - } + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Setter + @NotNull + @Column(name = "season_name", length = 20) + private String seasonName; + + @Setter + @NotNull + @Column(name = "start_time") + private LocalDateTime startTime; + + @Setter + @NotNull + @Column(name = "end_time") + private LocalDateTime endTime; + + @Setter + @NotNull + @Column(name = "start_ppp") + private Integer startPpp; + + @Setter + @NotNull + @Column(name = "ppp_gap") + private Integer pppGap; + + @Builder + public Season(String seasonName, LocalDateTime startTime, LocalDateTime endTime, Integer startPpp, Integer pppGap) { + this.seasonName = seasonName; + this.startTime = startTime; + this.endTime = endTime; + this.startPpp = startPpp; + this.pppGap = pppGap; + } + + @Builder + public Season(SeasonCreateRequestDto createDto) { + this.seasonName = createDto.getSeasonName(); + this.startTime = createDto.getStartTime(); + this.startPpp = createDto.getStartPpp(); + this.pppGap = createDto.getPppGap(); + } } diff --git a/src/main/java/com/gg/server/domain/season/data/SeasonRepository.java b/src/main/java/com/gg/server/domain/season/data/SeasonRepository.java index ae6625826..39833da0a 100644 --- a/src/main/java/com/gg/server/domain/season/data/SeasonRepository.java +++ b/src/main/java/com/gg/server/domain/season/data/SeasonRepository.java @@ -1,25 +1,24 @@ package com.gg.server.domain.season.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; import java.util.Optional; -public interface SeasonRepository extends JpaRepository { - @Query("select s from Season s where s.startTime <= :now and s.endTime >= :now") - Optional findCurrentSeason(@Param("now") LocalDateTime now); +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +public interface SeasonRepository extends JpaRepository { + @Query("select s from Season s where s.startTime <= :now and s.endTime >= :now") + Optional findCurrentSeason(@Param("now") LocalDateTime now); - @Query("select s from Season s where s.startTime <= :now") - List findActiveSeasons(@Param("now") LocalDateTime now); + @Query("select s from Season s where s.startTime <= :now") + List findActiveSeasons(@Param("now") LocalDateTime now); - @Query("select s from Season s where s.startTime <= :now order by s.startTime desc") - List findActiveSeasonsDesc(@Param("now") LocalDateTime now); + @Query("select s from Season s where s.startTime <= :now order by s.startTime desc") + List findActiveSeasonsDesc(@Param("now") LocalDateTime now); - @Query("select s from Season s where s.startTime <= :now and s.endTime >= :now or s.startTime > :now") - List findCurrentAndNewSeason(@Param("now") LocalDateTime now); + @Query("select s from Season s where s.startTime <= :now and s.endTime >= :now or s.startTime > :now") + List findCurrentAndNewSeason(@Param("now") LocalDateTime now); } diff --git a/src/main/java/com/gg/server/domain/season/dto/CurSeason.java b/src/main/java/com/gg/server/domain/season/dto/CurSeason.java index 6648a57ac..2cc8dbe50 100644 --- a/src/main/java/com/gg/server/domain/season/dto/CurSeason.java +++ b/src/main/java/com/gg/server/domain/season/dto/CurSeason.java @@ -1,25 +1,26 @@ package com.gg.server.domain.season.dto; +import java.time.LocalDateTime; + import com.gg.server.domain.season.data.Season; -import lombok.Getter; -import java.time.LocalDateTime; +import lombok.Getter; @Getter public class CurSeason { - private Long id; - private String seasonName; - private LocalDateTime startTime; - private LocalDateTime endTime; - private Integer startPpp; - private Integer pppGap; + private Long id; + private String seasonName; + private LocalDateTime startTime; + private LocalDateTime endTime; + private Integer startPpp; + private Integer pppGap; - public CurSeason(Season season) { - this.id = season.getId(); - this.seasonName = season.getSeasonName(); - this.startTime = season.getStartTime(); - this.endTime = season.getEndTime(); - this.startPpp = season.getStartPpp(); - this.pppGap = season.getPppGap(); - } + public CurSeason(Season season) { + this.id = season.getId(); + this.seasonName = season.getSeasonName(); + this.startTime = season.getStartTime(); + this.endTime = season.getEndTime(); + this.startPpp = season.getStartPpp(); + this.pppGap = season.getPppGap(); + } } diff --git a/src/main/java/com/gg/server/domain/season/dto/SeasonListResDto.java b/src/main/java/com/gg/server/domain/season/dto/SeasonListResDto.java index 07938c015..57dd8cb7a 100644 --- a/src/main/java/com/gg/server/domain/season/dto/SeasonListResDto.java +++ b/src/main/java/com/gg/server/domain/season/dto/SeasonListResDto.java @@ -1,16 +1,16 @@ package com.gg.server.domain.season.dto; +import java.util.List; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @Getter @NoArgsConstructor public class SeasonListResDto { - List seasonList; + List seasonList; - public SeasonListResDto(List seasonList) { - this.seasonList = seasonList; - } + public SeasonListResDto(List seasonList) { + this.seasonList = seasonList; + } } diff --git a/src/main/java/com/gg/server/domain/season/dto/SeasonResDto.java b/src/main/java/com/gg/server/domain/season/dto/SeasonResDto.java index 82e87a497..c36cc03cf 100644 --- a/src/main/java/com/gg/server/domain/season/dto/SeasonResDto.java +++ b/src/main/java/com/gg/server/domain/season/dto/SeasonResDto.java @@ -1,6 +1,7 @@ package com.gg.server.domain.season.dto; import com.gg.server.domain.season.data.Season; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -9,19 +10,19 @@ @AllArgsConstructor @NoArgsConstructor public class SeasonResDto { - private Long id; - private String name; + private Long id; + private String name; - public SeasonResDto(Season season) { - this.id = season.getId(); - this.name = season.getSeasonName(); - } + public SeasonResDto(Season season) { + this.id = season.getId(); + this.name = season.getSeasonName(); + } - @Override - public String toString() { - return "SeasonResDto{" + - "id=" + id + - ", name='" + name + '\'' + - '}'; - } + @Override + public String toString() { + return "SeasonResDto{" + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } } diff --git a/src/main/java/com/gg/server/domain/season/exception/SeasonForbiddenException.java b/src/main/java/com/gg/server/domain/season/exception/SeasonForbiddenException.java index 939003572..3152b6584 100644 --- a/src/main/java/com/gg/server/domain/season/exception/SeasonForbiddenException.java +++ b/src/main/java/com/gg/server/domain/season/exception/SeasonForbiddenException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.ForbiddenException; public class SeasonForbiddenException extends ForbiddenException { - public SeasonForbiddenException() { - super(ErrorCode.SEASON_FORBIDDEN.getMessage(), ErrorCode.SEASON_FORBIDDEN); - } + public SeasonForbiddenException() { + super(ErrorCode.SEASON_FORBIDDEN.getMessage(), ErrorCode.SEASON_FORBIDDEN); + } } diff --git a/src/main/java/com/gg/server/domain/season/exception/SeasonNotFoundException.java b/src/main/java/com/gg/server/domain/season/exception/SeasonNotFoundException.java index f71457df0..7275c06b5 100644 --- a/src/main/java/com/gg/server/domain/season/exception/SeasonNotFoundException.java +++ b/src/main/java/com/gg/server/domain/season/exception/SeasonNotFoundException.java @@ -4,10 +4,11 @@ import com.gg.server.global.exception.custom.NotExistException; public class SeasonNotFoundException extends NotExistException { - public SeasonNotFoundException() { - super("시즌이 없습니다.", ErrorCode.SEASON_NOT_FOUND); - } - public SeasonNotFoundException(String message) { - super(message, ErrorCode.SEASON_NOT_FOUND); - } + public SeasonNotFoundException() { + super("시즌이 없습니다.", ErrorCode.SEASON_NOT_FOUND); + } + + public SeasonNotFoundException(String message) { + super(message, ErrorCode.SEASON_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/season/exception/SeasonTimeBeforeException.java b/src/main/java/com/gg/server/domain/season/exception/SeasonTimeBeforeException.java index c367e6d31..60e08cb4f 100644 --- a/src/main/java/com/gg/server/domain/season/exception/SeasonTimeBeforeException.java +++ b/src/main/java/com/gg/server/domain/season/exception/SeasonTimeBeforeException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.ForbiddenException; public class SeasonTimeBeforeException extends ForbiddenException { - public SeasonTimeBeforeException() { - super(ErrorCode.SEASON_TIME_BEFORE.getMessage(), ErrorCode.SEASON_TIME_BEFORE); - } + public SeasonTimeBeforeException() { + super(ErrorCode.SEASON_TIME_BEFORE.getMessage(), ErrorCode.SEASON_TIME_BEFORE); + } } diff --git a/src/main/java/com/gg/server/domain/season/service/SeasonFindService.java b/src/main/java/com/gg/server/domain/season/service/SeasonFindService.java index d20216078..061d6ce62 100644 --- a/src/main/java/com/gg/server/domain/season/service/SeasonFindService.java +++ b/src/main/java/com/gg/server/domain/season/service/SeasonFindService.java @@ -1,38 +1,39 @@ package com.gg.server.domain.season.service; +import java.time.LocalDateTime; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.exception.GameNotExistException; import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.data.SeasonRepository; import com.gg.server.domain.season.exception.SeasonNotFoundException; -import com.gg.server.global.exception.ErrorCode; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; +import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class SeasonFindService { - private final SeasonRepository seasonRepository; - private final GameRepository gameRepository; - - @Transactional(readOnly = true) - public Season findCurrentSeason(LocalDateTime now){ - return seasonRepository.findCurrentSeason(now).orElseThrow(() -> new SeasonNotFoundException()); - } - - @Transactional(readOnly = true) - public Season findSeasonById(Long seasonId){ - return seasonRepository.findById(seasonId).orElseThrow(() -> new SeasonNotFoundException()); - } - - @Transactional(readOnly = true) - public Season findSeasonByGameId(Long gameId){ - Game game = gameRepository.findById(gameId).orElseThrow(() -> new GameNotExistException()); - return game.getSeason(); - } + private final SeasonRepository seasonRepository; + private final GameRepository gameRepository; + + @Transactional(readOnly = true) + public Season findCurrentSeason(LocalDateTime now) { + return seasonRepository.findCurrentSeason(now).orElseThrow(() -> new SeasonNotFoundException()); + } + + @Transactional(readOnly = true) + public Season findSeasonById(Long seasonId) { + return seasonRepository.findById(seasonId).orElseThrow(() -> new SeasonNotFoundException()); + } + + @Transactional(readOnly = true) + public Season findSeasonByGameId(Long gameId) { + Game game = gameRepository.findById(gameId).orElseThrow(() -> new GameNotExistException()); + return game.getSeason(); + } } diff --git a/src/main/java/com/gg/server/domain/season/service/SeasonService.java b/src/main/java/com/gg/server/domain/season/service/SeasonService.java index 769dc5473..d16de8b41 100644 --- a/src/main/java/com/gg/server/domain/season/service/SeasonService.java +++ b/src/main/java/com/gg/server/domain/season/service/SeasonService.java @@ -1,30 +1,30 @@ package com.gg.server.domain.season.service; +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +import org.springframework.stereotype.Service; + import com.gg.server.domain.season.data.SeasonRepository; import com.gg.server.domain.season.dto.CurSeason; import com.gg.server.domain.season.dto.SeasonResDto; import com.gg.server.domain.season.exception.SeasonNotFoundException; -import com.gg.server.global.exception.ErrorCode; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; @Service @RequiredArgsConstructor public class SeasonService { - private final SeasonRepository seasonRepository; + private final SeasonRepository seasonRepository; - public List seasonList() { - return seasonRepository.findActiveSeasonsDesc(LocalDateTime.now()) - .stream().map(SeasonResDto::new).collect(Collectors.toList()); - } + public List seasonList() { + return seasonRepository.findActiveSeasonsDesc(LocalDateTime.now()) + .stream().map(SeasonResDto::new).collect(Collectors.toList()); + } - public CurSeason getCurSeason() { - return new CurSeason(seasonRepository.findCurrentSeason(LocalDateTime.now()) - .orElseThrow(() -> new SeasonNotFoundException("현재 시즌이 존재하지 않습니다."))); - } + public CurSeason getCurSeason() { + return new CurSeason(seasonRepository.findCurrentSeason(LocalDateTime.now()) + .orElseThrow(() -> new SeasonNotFoundException("현재 시즌이 존재하지 않습니다."))); + } } diff --git a/src/main/java/com/gg/server/domain/slotmanagement/SlotManagement.java b/src/main/java/com/gg/server/domain/slotmanagement/SlotManagement.java index 5f7ab0106..6192c4185 100644 --- a/src/main/java/com/gg/server/domain/slotmanagement/SlotManagement.java +++ b/src/main/java/com/gg/server/domain/slotmanagement/SlotManagement.java @@ -1,79 +1,87 @@ package com.gg.server.domain.slotmanagement; +import java.time.LocalDateTime; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.validation.constraints.NotNull; + import com.gg.server.admin.slotmanagement.dto.SlotCreateRequestDto; import com.gg.server.domain.slotmanagement.exception.SlotManagementForbiddenException; import com.gg.server.global.utils.BaseTimeEntity; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import javax.persistence.*; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; - @Getter @Entity @NoArgsConstructor @AllArgsConstructor public class SlotManagement extends BaseTimeEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; - @NotNull - @Column(name = "past_slot_time") - private Integer pastSlotTime; + @NotNull + @Column(name = "past_slot_time") + private Integer pastSlotTime; - @NotNull - @Column(name = "future_slot_time") - private Integer futureSlotTime; + @NotNull + @Column(name = "future_slot_time") + private Integer futureSlotTime; - @NotNull - @Column(name = "open_minute") - private Integer openMinute; + @NotNull + @Column(name = "open_minute") + private Integer openMinute; - @NotNull - @Column(name = "game_interval") - private Integer gameInterval; + @NotNull + @Column(name = "game_interval") + private Integer gameInterval; - @NotNull - @Column(name = "start_time") - private LocalDateTime startTime; + @NotNull + @Column(name = "start_time") + private LocalDateTime startTime; - @Column(name = "end_time") - private LocalDateTime endTime; + @Column(name = "end_time") + private LocalDateTime endTime; - @Builder - public SlotManagement(Integer pastSlotTime, Integer futureSlotTime, Integer openMinute, Integer gameInterval, - LocalDateTime startTime, LocalDateTime endTime) { - this.pastSlotTime = pastSlotTime; - this.futureSlotTime = futureSlotTime; - this.openMinute = openMinute; - this.gameInterval = gameInterval; - this.startTime = startTime; - this.endTime = endTime; - } + @Builder + public SlotManagement(Integer pastSlotTime, Integer futureSlotTime, Integer openMinute, Integer gameInterval, + LocalDateTime startTime, LocalDateTime endTime) { + this.pastSlotTime = pastSlotTime; + this.futureSlotTime = futureSlotTime; + this.openMinute = openMinute; + this.gameInterval = gameInterval; + this.startTime = startTime; + this.endTime = endTime; + } - @Builder - public SlotManagement(SlotCreateRequestDto requestDto) { - this.pastSlotTime = requestDto.getPastSlotTime(); - this.futureSlotTime = requestDto.getFutureSlotTime(); - this.openMinute = requestDto.getOpenMinute(); - this.gameInterval = requestDto.getInterval(); - this.startTime = requestDto.getStartTime(); - this.endTime = null; - } + @Builder + public SlotManagement(SlotCreateRequestDto requestDto) { + this.pastSlotTime = requestDto.getPastSlotTime(); + this.futureSlotTime = requestDto.getFutureSlotTime(); + this.openMinute = requestDto.getOpenMinute(); + this.gameInterval = requestDto.getInterval(); + this.startTime = requestDto.getStartTime(); + this.endTime = null; + } - public void updateEndTime(LocalDateTime endTime) { - if (this.endTime != null) - throw new SlotManagementForbiddenException(); - this.endTime = endTime; - } + public void updateEndTime(LocalDateTime endTime) { + if (this.endTime != null) { + throw new SlotManagementForbiddenException(); + } + this.endTime = endTime; + } - public void setNullEndTime() { - if (this.endTime == null) - throw new SlotManagementForbiddenException(); - this.endTime = null; - } + public void setNullEndTime() { + if (this.endTime == null) { + throw new SlotManagementForbiddenException(); + } + this.endTime = null; + } } diff --git a/src/main/java/com/gg/server/domain/slotmanagement/data/SlotManagementRepository.java b/src/main/java/com/gg/server/domain/slotmanagement/data/SlotManagementRepository.java index 158537c35..947559edf 100644 --- a/src/main/java/com/gg/server/domain/slotmanagement/data/SlotManagementRepository.java +++ b/src/main/java/com/gg/server/domain/slotmanagement/data/SlotManagementRepository.java @@ -1,23 +1,24 @@ package com.gg.server.domain.slotmanagement.data; -import com.gg.server.domain.slotmanagement.SlotManagement; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; + import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -public interface SlotManagementRepository - extends JpaRepository { - @Query("select sm from SlotManagement sm where sm.endTime > :now or sm.endTime is null") - List findAfter(@Param("now") LocalDateTime now); +import com.gg.server.domain.slotmanagement.SlotManagement; - @Query("select sm from SlotManagement sm where (sm.endTime is null" - + " or sm.endTime > :now) and sm.startTime <=:now") - Optional findCurrent(@Param("now") LocalDateTime now); +public interface SlotManagementRepository + extends JpaRepository { + @Query("select sm from SlotManagement sm where sm.endTime > :now or sm.endTime is null") + List findAfter(@Param("now") LocalDateTime now); - SlotManagement findFirstByOrderByCreatedAtDesc(); + @Query("select sm from SlotManagement sm where (sm.endTime is null" + + " or sm.endTime > :now) and sm.startTime <=:now") + Optional findCurrent(@Param("now") LocalDateTime now); + SlotManagement findFirstByOrderByCreatedAtDesc(); } diff --git a/src/main/java/com/gg/server/domain/slotmanagement/exception/SlotManagementForbiddenException.java b/src/main/java/com/gg/server/domain/slotmanagement/exception/SlotManagementForbiddenException.java index accb87ccb..9ecf487f6 100644 --- a/src/main/java/com/gg/server/domain/slotmanagement/exception/SlotManagementForbiddenException.java +++ b/src/main/java/com/gg/server/domain/slotmanagement/exception/SlotManagementForbiddenException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.ForbiddenException; public class SlotManagementForbiddenException extends ForbiddenException { - public SlotManagementForbiddenException() { - super(ErrorCode.SLOTMANAGEMENT_FORBIDDEN.getMessage(), ErrorCode.SLOTMANAGEMENT_FORBIDDEN); - } + public SlotManagementForbiddenException() { + super(ErrorCode.SLOTMANAGEMENT_FORBIDDEN.getMessage(), ErrorCode.SLOTMANAGEMENT_FORBIDDEN); + } } diff --git a/src/main/java/com/gg/server/domain/slotmanagement/exception/SlotManagementNotFoundException.java b/src/main/java/com/gg/server/domain/slotmanagement/exception/SlotManagementNotFoundException.java index 7e1060154..8b89318be 100644 --- a/src/main/java/com/gg/server/domain/slotmanagement/exception/SlotManagementNotFoundException.java +++ b/src/main/java/com/gg/server/domain/slotmanagement/exception/SlotManagementNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class SlotManagementNotFoundException extends NotExistException { - public SlotManagementNotFoundException() { - super(ErrorCode.SLOTMANAGEMENT_NOT_FOUND.getMessage(), ErrorCode.SLOTMANAGEMENT_NOT_FOUND); - } + public SlotManagementNotFoundException() { + super(ErrorCode.SLOTMANAGEMENT_NOT_FOUND.getMessage(), ErrorCode.SLOTMANAGEMENT_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/team/data/Team.java b/src/main/java/com/gg/server/domain/team/data/Team.java index dfb2ce647..225c41e39 100644 --- a/src/main/java/com/gg/server/domain/team/data/Team.java +++ b/src/main/java/com/gg/server/domain/team/data/Team.java @@ -1,10 +1,8 @@ package com.gg.server.domain.team.data; -import com.gg.server.domain.game.data.Game; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.utils.BusinessChecker; import java.util.ArrayList; import java.util.List; + import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -19,6 +17,10 @@ import org.hibernate.annotations.DynamicUpdate; +import com.gg.server.domain.game.data.Game; +import com.gg.server.global.exception.ErrorCode; +import com.gg.server.global.utils.BusinessChecker; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -29,40 +31,40 @@ @Getter @DynamicUpdate public class Team { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "game_id") - private Game game; + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "game_id") + private Game game; - @Column(name = "score") - private Integer score; + @Column(name = "score") + private Integer score; - @Column(name = "win") - private Boolean win; + @Column(name = "win") + private Boolean win; - @OneToMany(mappedBy = "team", cascade = CascadeType.ALL) - private List teamUsers = new ArrayList<>(); + @OneToMany(mappedBy = "team", cascade = CascadeType.ALL) + private List teamUsers = new ArrayList<>(); - public Team(Game game, Integer score, Boolean win) { - this.game = game; - this.score = score; - this.win = win; - game.addTeam(this); - } + public Team(Game game, Integer score, Boolean win) { + this.game = game; + this.score = score; + this.win = win; + game.addTeam(this); + } - public void updateScore(int score, Boolean win) { - this.score = score; - this.win = win; - } + public void updateScore(int score, Boolean win) { + this.score = score; + this.win = win; + } - public void addTeamUser(TeamUser teamUser) { - BusinessChecker.mustNotNull(teamUser, ErrorCode.NULL_POINT); - BusinessChecker.mustNotExceed(1, teamUsers, ErrorCode.TEAM_USER_EXCEED); - BusinessChecker.mustNotContains(teamUser, teamUsers, ErrorCode.TEAM_USER_ALREADY_EXIST); - this.teamUsers.add(teamUser); - } + public void addTeamUser(TeamUser teamUser) { + BusinessChecker.mustNotNull(teamUser, ErrorCode.NULL_POINT); + BusinessChecker.mustNotExceed(1, teamUsers, ErrorCode.TEAM_USER_EXCEED); + BusinessChecker.mustNotContains(teamUser, teamUsers, ErrorCode.TEAM_USER_ALREADY_EXIST); + this.teamUsers.add(teamUser); + } } diff --git a/src/main/java/com/gg/server/domain/team/data/TeamRepository.java b/src/main/java/com/gg/server/domain/team/data/TeamRepository.java index bdba99df3..483699ebb 100644 --- a/src/main/java/com/gg/server/domain/team/data/TeamRepository.java +++ b/src/main/java/com/gg/server/domain/team/data/TeamRepository.java @@ -1,14 +1,12 @@ package com.gg.server.domain.team.data; -import java.time.LocalDateTime; import java.util.List; -import com.gg.server.domain.team.dto.GameUser; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; public interface TeamRepository extends JpaRepository { - @Query("select t from Team t where t.game.id=:gameId") - List findAllBy(@Param("gameId") Long gameId); + @Query("select t from Team t where t.game.id=:gameId") + List findAllBy(@Param("gameId") Long gameId); } diff --git a/src/main/java/com/gg/server/domain/team/data/TeamUser.java b/src/main/java/com/gg/server/domain/team/data/TeamUser.java index 81fe3ab42..08cc3c63b 100644 --- a/src/main/java/com/gg/server/domain/team/data/TeamUser.java +++ b/src/main/java/com/gg/server/domain/team/data/TeamUser.java @@ -1,41 +1,52 @@ -package com.gg.server.domain.team.data; - -import com.gg.server.domain.user.data.User; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.utils.BusinessChecker; -import lombok.*; - -import javax.persistence.*; -import javax.validation.constraints.NotNull; - -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor -@Entity -@Getter -@ToString -public class TeamUser { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "team_id") - private Team team; - - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - public TeamUser(Team team, User user) { - this.team = team; - this.user = user; - team.addTeamUser(this); - } - - public void updateUser(User user) { - BusinessChecker.mustNotNull(user, ErrorCode.NULL_POINT); - this.user = user; - } -} \ No newline at end of file +package com.gg.server.domain.team.data; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.validation.constraints.NotNull; + +import com.gg.server.domain.user.data.User; +import com.gg.server.global.exception.ErrorCode; +import com.gg.server.global.utils.BusinessChecker; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +@Entity +@Getter +@ToString +public class TeamUser { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "team_id") + private Team team; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + public TeamUser(Team team, User user) { + this.team = team; + this.user = user; + team.addTeamUser(this); + } + + public void updateUser(User user) { + BusinessChecker.mustNotNull(user, ErrorCode.NULL_POINT); + this.user = user; + } +} diff --git a/src/main/java/com/gg/server/domain/team/data/TeamUserRepository.java b/src/main/java/com/gg/server/domain/team/data/TeamUserRepository.java index 50edb7052..0c5e67700 100644 --- a/src/main/java/com/gg/server/domain/team/data/TeamUserRepository.java +++ b/src/main/java/com/gg/server/domain/team/data/TeamUserRepository.java @@ -1,20 +1,20 @@ package com.gg.server.domain.team.data; +import java.time.LocalDateTime; +import java.util.List; + 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 { - @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 findAllByGameId(@Param("gid")Long gid); + @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 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); + @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); } diff --git a/src/main/java/com/gg/server/domain/team/dto/GameUser.java b/src/main/java/com/gg/server/domain/team/dto/GameUser.java index d92e8cef8..59dc9a953 100644 --- a/src/main/java/com/gg/server/domain/team/dto/GameUser.java +++ b/src/main/java/com/gg/server/domain/team/dto/GameUser.java @@ -3,9 +3,13 @@ import com.gg.server.domain.user.type.SnsType; public interface GameUser { - Long getGameId(); - Long getUserId(); - String getIntraId(); - String getEmail(); - SnsType getSnsNotiOpt(); + Long getGameId(); + + Long getUserId(); + + String getIntraId(); + + String getEmail(); + + SnsType getSnsNotiOpt(); } diff --git a/src/main/java/com/gg/server/domain/team/dto/MatchTeamsInfoDto.java b/src/main/java/com/gg/server/domain/team/dto/MatchTeamsInfoDto.java index 7d20996be..212beaa03 100644 --- a/src/main/java/com/gg/server/domain/team/dto/MatchTeamsInfoDto.java +++ b/src/main/java/com/gg/server/domain/team/dto/MatchTeamsInfoDto.java @@ -1,44 +1,48 @@ package com.gg.server.domain.team.dto; +import java.util.List; + import com.gg.server.domain.game.dto.GameTeamUserInfo; + import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; -import java.util.List; - @Getter @NoArgsConstructor @ToString public class MatchTeamsInfoDto { - private TeamInfo myTeam; - private TeamInfo enemyTeam; + private TeamInfo myTeam; + private TeamInfo enemyTeam; + + public MatchTeamsInfoDto(List infos, Long teamId) { + if (teamId == null) { + return; + } + myTeam = new TeamInfo(); + enemyTeam = new TeamInfo(); + for (GameTeamUserInfo info : + infos) { + if (teamId.equals(info.getTeamId())) { + myTeam.setTeam(info.getTeamId(), info.getScore()); + myTeam.addPlayer(info); + } else { + enemyTeam.setTeam(info.getTeamId(), info.getScore()); + enemyTeam.addPlayer(info); + } + } + } - public MatchTeamsInfoDto(List infos, Long teamId) { - if (teamId == null) return; - myTeam = new TeamInfo(); - enemyTeam = new TeamInfo(); - for (GameTeamUserInfo info : - infos) { - if (teamId.equals(info.getTeamId())) { - myTeam.setTeam(info.getTeamId(), info.getScore()); - myTeam.addPlayer(info); - } else { - enemyTeam.setTeam(info.getTeamId(), info.getScore()); - enemyTeam.addPlayer(info); - } - } - } - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (!(obj instanceof MatchTeamsInfoDto)) { - return false; - } else { - MatchTeamsInfoDto other = (MatchTeamsInfoDto) obj; - return this.myTeam.equals(other.getMyTeam()) - && this.enemyTeam.equals(other.getEnemyTeam()); - } - } + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (!(obj instanceof MatchTeamsInfoDto)) { + return false; + } else { + MatchTeamsInfoDto other = (MatchTeamsInfoDto)obj; + return this.myTeam.equals(other.getMyTeam()) + && this.enemyTeam.equals(other.getEnemyTeam()); + } + } } diff --git a/src/main/java/com/gg/server/domain/team/dto/TeamInfo.java b/src/main/java/com/gg/server/domain/team/dto/TeamInfo.java index 36e4e6eb9..0f12f64b5 100644 --- a/src/main/java/com/gg/server/domain/team/dto/TeamInfo.java +++ b/src/main/java/com/gg/server/domain/team/dto/TeamInfo.java @@ -1,43 +1,44 @@ package com.gg.server.domain.team.dto; +import java.util.ArrayList; +import java.util.List; + import com.gg.server.domain.game.dto.GameTeamUserInfo; + import lombok.Getter; import lombok.ToString; -import java.util.ArrayList; -import java.util.List; - @Getter @ToString public class TeamInfo { - private Integer teamScore; - private Long teamId; - private List players; - - public TeamInfo() { - this.players = new ArrayList<>(); - } - - public void setTeam(Long teamId, Integer teamScore) { - this.teamId = teamId; - this.teamScore = teamScore; - } - - public void addPlayer(GameTeamUserInfo info) { - this.players.add(new TeamUserInfoDto(info.getIntraId(), info.getImage(), info.getExp(), null, null)); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (!(obj instanceof TeamInfo)) { - return false; - } else { - TeamInfo other = (TeamInfo) obj; - return this.teamScore.equals(other.getTeamScore()) - && this.teamId.equals(other.getTeamId()) - && this.players.equals(other.getPlayers()); - } - } -} \ No newline at end of file + private Integer teamScore; + private Long teamId; + private List players; + + public TeamInfo() { + this.players = new ArrayList<>(); + } + + public void setTeam(Long teamId, Integer teamScore) { + this.teamId = teamId; + this.teamScore = teamScore; + } + + public void addPlayer(GameTeamUserInfo info) { + this.players.add(new TeamUserInfoDto(info.getIntraId(), info.getImage(), info.getExp(), null, null)); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (!(obj instanceof TeamInfo)) { + return false; + } else { + TeamInfo other = (TeamInfo)obj; + return this.teamScore.equals(other.getTeamScore()) + && this.teamId.equals(other.getTeamId()) + && this.players.equals(other.getPlayers()); + } + } +} diff --git a/src/main/java/com/gg/server/domain/team/dto/TeamReqDto.java b/src/main/java/com/gg/server/domain/team/dto/TeamReqDto.java index b8a6b610a..ae2bbf06e 100644 --- a/src/main/java/com/gg/server/domain/team/dto/TeamReqDto.java +++ b/src/main/java/com/gg/server/domain/team/dto/TeamReqDto.java @@ -1,35 +1,35 @@ package com.gg.server.domain.team.dto; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) public class TeamReqDto { - @NotNull - private Long teamId; + @NotNull + private Long teamId; - @NotNull - @Max(value = 2, message = "점수는 최대 2점 입니다.") - @Min(value = 0, message = "점수는 최소 0점 입니다.") - private int score; + @NotNull + @Max(value = 2, message = "점수는 최대 2점 입니다.") + @Min(value = 0, message = "점수는 최소 0점 입니다.") + private int score; - public TeamReqDto(Long teamId, int score) { - this.teamId = teamId; - this.score = score; - } + public TeamReqDto(Long teamId, int score) { + this.teamId = teamId; + this.score = score; + } - @Override - public String toString() { - return "TeamReqDto{" + - "teamId=" + teamId + - ", score=" + score + - '}'; - } + @Override + public String toString() { + return "TeamReqDto{" + + "teamId=" + teamId + + ", score=" + score + + '}'; + } } diff --git a/src/main/java/com/gg/server/domain/team/dto/TeamUserInfoDto.java b/src/main/java/com/gg/server/domain/team/dto/TeamUserInfoDto.java index 5df76377f..1e22b72b4 100644 --- a/src/main/java/com/gg/server/domain/team/dto/TeamUserInfoDto.java +++ b/src/main/java/com/gg/server/domain/team/dto/TeamUserInfoDto.java @@ -1,53 +1,52 @@ package com.gg.server.domain.team.dto; import com.fasterxml.jackson.annotation.JsonInclude; -import com.gg.server.domain.game.dto.GameListResDto; import com.gg.server.global.utils.ExpLevelCalculator; -import lombok.Builder; + import lombok.Getter; import lombok.NoArgsConstructor; @Getter @NoArgsConstructor public class TeamUserInfoDto { - private String intraId; - private String userImageUri; - private Integer level; - @JsonInclude(JsonInclude.Include.NON_NULL) - private Integer wins; - @JsonInclude(JsonInclude.Include.NON_NULL) - private Integer losses; + private String intraId; + private String userImageUri; + private Integer level; + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer wins; + @JsonInclude(JsonInclude.Include.NON_NULL) + private Integer losses; - public TeamUserInfoDto(String intraId, String userImageUri, Integer exp, Integer wins, Integer losses) { - this.intraId = intraId; - this.userImageUri = userImageUri; - this.level = ExpLevelCalculator.getLevel(exp); - this.wins = wins; - this.losses = losses; - } + public TeamUserInfoDto(String intraId, String userImageUri, Integer exp, Integer wins, Integer losses) { + this.intraId = intraId; + this.userImageUri = userImageUri; + this.level = ExpLevelCalculator.getLevel(exp); + this.wins = wins; + this.losses = losses; + } - @Override - public String toString() { - return "TeamUserInfoDto{" + - "intraId='" + intraId + '\'' + - ", userImageUri='" + userImageUri + '\'' + - ", level=" + level + - '}'; - } + @Override + public String toString() { + return "TeamUserInfoDto{" + + "intraId='" + intraId + '\'' + + ", userImageUri='" + userImageUri + '\'' + + ", level=" + level + + '}'; + } - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (!(obj instanceof TeamUserInfoDto)) { - return false; - } else { - TeamUserInfoDto other = (TeamUserInfoDto) obj; - return this.intraId.equals(other.getIntraId()) - && this.level.equals(other.getLevel()) - && this.userImageUri.equals(other.getUserImageUri()) - && (this.wins == other.getWins() || this.wins.equals(other.getWins())) - && (this.losses == other.getLosses() || this.losses.equals(other.getLosses())); - } - } + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (!(obj instanceof TeamUserInfoDto)) { + return false; + } else { + TeamUserInfoDto other = (TeamUserInfoDto)obj; + return this.intraId.equals(other.getIntraId()) + && this.level.equals(other.getLevel()) + && this.userImageUri.equals(other.getUserImageUri()) + && (this.wins == other.getWins() || this.wins.equals(other.getWins())) + && (this.losses == other.getLosses() || this.losses.equals(other.getLosses())); + } + } } diff --git a/src/main/java/com/gg/server/domain/team/dto/TeamUserListDto.java b/src/main/java/com/gg/server/domain/team/dto/TeamUserListDto.java index 5eeb81aae..23c2590eb 100644 --- a/src/main/java/com/gg/server/domain/team/dto/TeamUserListDto.java +++ b/src/main/java/com/gg/server/domain/team/dto/TeamUserListDto.java @@ -1,55 +1,55 @@ package com.gg.server.domain.team.dto; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonInclude; -import com.gg.server.domain.game.dto.GameListResDto; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @Getter @NoArgsConstructor public class TeamUserListDto { - Long teamId; - - List players; - - @JsonInclude(JsonInclude.Include.NON_NULL) - Boolean isWin; - @JsonInclude(JsonInclude.Include.NON_NULL) - Integer score; - - public TeamUserListDto(List players, Boolean isWin, Integer score) { - this.isWin = isWin; - this.score = score; - this.players = players; - } - - public TeamUserListDto(Long teamId, List players, Boolean isWin, Integer score) { - this.teamId = teamId; - this.players = players; - this.isWin = isWin; - this.score = score == -1? null : score; - } - - @Override - public String toString() { - return "TeamUserListDto{" + - "players=" + players + - '}'; - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (!(obj instanceof TeamUserListDto)) { - return false; - } else { - TeamUserListDto other = (TeamUserListDto) obj; - return (isWin == other.getIsWin() || this.isWin.equals(other.getIsWin())) - && (score == other.getScore() || this.score.equals(other.getScore())) - && this.players.equals(other.getPlayers()); - } - } + Long teamId; + + List players; + + @JsonInclude(JsonInclude.Include.NON_NULL) + Boolean isWin; + @JsonInclude(JsonInclude.Include.NON_NULL) + Integer score; + + public TeamUserListDto(List players, Boolean isWin, Integer score) { + this.isWin = isWin; + this.score = score; + this.players = players; + } + + public TeamUserListDto(Long teamId, List players, Boolean isWin, Integer score) { + this.teamId = teamId; + this.players = players; + this.isWin = isWin; + this.score = score == -1 ? null : score; + } + + @Override + public String toString() { + return "TeamUserListDto{" + + "players=" + players + + '}'; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (!(obj instanceof TeamUserListDto)) { + return false; + } else { + TeamUserListDto other = (TeamUserListDto)obj; + return (isWin == other.getIsWin() || this.isWin.equals(other.getIsWin())) + && (score == other.getScore() || this.score.equals(other.getScore())) + && this.players.equals(other.getPlayers()); + } + } } diff --git a/src/main/java/com/gg/server/domain/team/exception/TeamIdNotMatchException.java b/src/main/java/com/gg/server/domain/team/exception/TeamIdNotMatchException.java index 5737d7538..6b11160e7 100644 --- a/src/main/java/com/gg/server/domain/team/exception/TeamIdNotMatchException.java +++ b/src/main/java/com/gg/server/domain/team/exception/TeamIdNotMatchException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class TeamIdNotMatchException extends NotExistException { - public TeamIdNotMatchException() { - super(ErrorCode.TEAM_ID_NOT_MATCH.getMessage(), ErrorCode.TEAM_ID_NOT_MATCH); - } + public TeamIdNotMatchException() { + super(ErrorCode.TEAM_ID_NOT_MATCH.getMessage(), ErrorCode.TEAM_ID_NOT_MATCH); + } } diff --git a/src/main/java/com/gg/server/domain/team/exception/TeamNotFoundException.java b/src/main/java/com/gg/server/domain/team/exception/TeamNotFoundException.java index 48e05d1d4..588095905 100644 --- a/src/main/java/com/gg/server/domain/team/exception/TeamNotFoundException.java +++ b/src/main/java/com/gg/server/domain/team/exception/TeamNotFoundException.java @@ -5,7 +5,7 @@ public class TeamNotFoundException extends NotExistException { - public TeamNotFoundException() { - super(ErrorCode.TEAM_NOT_FOUND.getMessage(), ErrorCode.TEAM_NOT_FOUND); - } + public TeamNotFoundException() { + super(ErrorCode.TEAM_NOT_FOUND.getMessage(), ErrorCode.TEAM_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/tier/data/Tier.java b/src/main/java/com/gg/server/domain/tier/data/Tier.java index f367e7071..f18205386 100644 --- a/src/main/java/com/gg/server/domain/tier/data/Tier.java +++ b/src/main/java/com/gg/server/domain/tier/data/Tier.java @@ -1,28 +1,33 @@ -package com.gg.server.domain.tier.data; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import javax.persistence.*; -import java.io.Serializable; - -@Entity -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class Tier implements Serializable { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "image_uri") - private String imageUri; - - @Column(name = "name") - private String name; - - public Tier(String imageUri) { - this.imageUri = imageUri; - } -} \ No newline at end of file +package com.gg.server.domain.tier.data; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class Tier implements Serializable { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "image_uri") + private String imageUri; + + @Column(name = "name") + private String name; + + public Tier(String imageUri) { + this.imageUri = imageUri; + } +} diff --git a/src/main/java/com/gg/server/domain/tier/data/TierRepository.java b/src/main/java/com/gg/server/domain/tier/data/TierRepository.java index 1dd5b0561..26f5c9ce2 100644 --- a/src/main/java/com/gg/server/domain/tier/data/TierRepository.java +++ b/src/main/java/com/gg/server/domain/tier/data/TierRepository.java @@ -1,14 +1,14 @@ package com.gg.server.domain.tier.data; +import java.util.Optional; + import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import java.util.Optional; - public interface TierRepository extends JpaRepository { - @Query("SELECT t FROM Tier t WHERE t.id = (SELECT MIN(t.id) FROM Tier t)") - Optional findStartTier(); + @Query("SELECT t FROM Tier t WHERE t.id = (SELECT MIN(t.id) FROM Tier t)") + Optional findStartTier(); - Optional findByName(String name); -} \ No newline at end of file + Optional findByName(String name); +} diff --git a/src/main/java/com/gg/server/domain/tier/exception/TierNotFoundException.java b/src/main/java/com/gg/server/domain/tier/exception/TierNotFoundException.java index fe13c392b..39a094aca 100644 --- a/src/main/java/com/gg/server/domain/tier/exception/TierNotFoundException.java +++ b/src/main/java/com/gg/server/domain/tier/exception/TierNotFoundException.java @@ -4,8 +4,8 @@ import com.gg.server.global.exception.custom.NotExistException; public class TierNotFoundException extends NotExistException { - public TierNotFoundException() { - super("해당 티어가 존재하지 않습니다.", ErrorCode.TIER_NOT_FOUND); - } + public TierNotFoundException() { + super("해당 티어가 존재하지 않습니다.", ErrorCode.TIER_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/tier/service/TierService.java b/src/main/java/com/gg/server/domain/tier/service/TierService.java index 8821003d7..220c5cb7f 100644 --- a/src/main/java/com/gg/server/domain/tier/service/TierService.java +++ b/src/main/java/com/gg/server/domain/tier/service/TierService.java @@ -1,63 +1,65 @@ package com.gg.server.domain.tier.service; +import java.util.List; + +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.domain.rank.data.Rank; import com.gg.server.domain.rank.data.RankRepository; import com.gg.server.domain.season.data.Season; import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.util.List; +import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class TierService { - private final TierRepository tierRepository; - private final RankRepository rankRepository; - - @Transactional - public void updateAllTier(Season season) { - List rankList = rankRepository.findAllBySeasonIdOrderByPppDesc(season.getId()); - Long totalRankPlayers = rankRepository.countRealRankPlayers(season.getId()); - List tierList = tierRepository.findAll(Sort.by(Sort.Direction.ASC, "id")); - - int top30percentPpp = rankList.get((int) (totalRankPlayers * 0.3)).getPpp(); - int top10percentPpp = rankList.get((int) (totalRankPlayers * 0.1)).getPpp(); - - for (int i = 0; i < rankList.size(); i++) { - Rank rank = rankList.get(i); - if (rank.getWins() == 0 && rank.getLosses() == 0) { - rank.updateTier(tierList.get(0)); - } else { - if (i < 3) { - rank.updateTier(tierList.get(6)); - continue; - } - if (rank.getPpp() < 970) { - // 970 미만 - rank.updateTier(tierList.get(1)); - } else if (rank.getPpp() < 1010) { - // 970 - 1009 - rank.updateTier(tierList.get(2)); - } else if (rank.getPpp() < 1050) { - // 1010 - 1049 - rank.updateTier(tierList.get(3)); - } else if (rank.getPpp() >= 1050) { - if (rank.getPpp() >= top30percentPpp && rank.getPpp() < top10percentPpp) { - // 1050 이상, 30% 이상, 10% 미만 - rank.updateTier(tierList.get(4)); - } else if (rank.getPpp() >= top10percentPpp) { - // 1050 이상, 10% 이상 - rank.updateTier(tierList.get(5)); - } else { - // 1050 이상, 30% 미만 - rank.updateTier(tierList.get(3)); - } - } - } - } - } + private final TierRepository tierRepository; + private final RankRepository rankRepository; + + @Transactional + public void updateAllTier(Season season) { + List rankList = rankRepository.findAllBySeasonIdOrderByPppDesc(season.getId()); + Long totalRankPlayers = rankRepository.countRealRankPlayers(season.getId()); + List tierList = tierRepository.findAll(Sort.by(Sort.Direction.ASC, "id")); + + int top30percentPpp = rankList.get((int)(totalRankPlayers * 0.3)).getPpp(); + int top10percentPpp = rankList.get((int)(totalRankPlayers * 0.1)).getPpp(); + + for (int i = 0; i < rankList.size(); i++) { + Rank rank = rankList.get(i); + if (rank.getWins() == 0 && rank.getLosses() == 0) { + rank.updateTier(tierList.get(0)); + } else { + if (i < 3) { + rank.updateTier(tierList.get(6)); + continue; + } + if (rank.getPpp() < 970) { + // 970 미만 + rank.updateTier(tierList.get(1)); + } else if (rank.getPpp() < 1010) { + // 970 - 1009 + rank.updateTier(tierList.get(2)); + } else if (rank.getPpp() < 1050) { + // 1010 - 1049 + rank.updateTier(tierList.get(3)); + } else if (rank.getPpp() >= 1050) { + if (rank.getPpp() >= top30percentPpp && rank.getPpp() < top10percentPpp) { + // 1050 이상, 30% 이상, 10% 미만 + rank.updateTier(tierList.get(4)); + } else if (rank.getPpp() >= top10percentPpp) { + // 1050 이상, 10% 이상 + rank.updateTier(tierList.get(5)); + } else { + // 1050 이상, 30% 미만 + rank.updateTier(tierList.get(3)); + } + } + } + } + } } diff --git a/src/main/java/com/gg/server/domain/tournament/controller/TournamentController.java b/src/main/java/com/gg/server/domain/tournament/controller/TournamentController.java index 42859da36..013e2bbd5 100644 --- a/src/main/java/com/gg/server/domain/tournament/controller/TournamentController.java +++ b/src/main/java/com/gg/server/domain/tournament/controller/TournamentController.java @@ -1,95 +1,110 @@ package com.gg.server.domain.tournament.controller; -import com.gg.server.domain.tournament.dto.*; -import com.gg.server.domain.tournament.service.TournamentService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.utils.argumentresolver.Login; -import io.swagger.v3.oas.annotations.Parameter; -import lombok.RequiredArgsConstructor; +import javax.validation.Valid; import javax.validation.constraints.Positive; + import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import org.springframework.http.HttpStatus; import org.springframework.data.domain.Sort; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.validation.Valid; +import com.gg.server.domain.tournament.dto.TournamentFilterRequestDto; +import com.gg.server.domain.tournament.dto.TournamentGameListResponseDto; +import com.gg.server.domain.tournament.dto.TournamentListResponseDto; +import com.gg.server.domain.tournament.dto.TournamentResponseDto; +import com.gg.server.domain.tournament.dto.TournamentUserRegistrationResponseDto; +import com.gg.server.domain.tournament.service.TournamentService; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.utils.argumentresolver.Login; + +import io.swagger.v3.oas.annotations.Parameter; +import lombok.RequiredArgsConstructor; @RestController @RequiredArgsConstructor @RequestMapping("/pingpong/tournaments") public class TournamentController { - private final TournamentService tournamentService; + private final TournamentService tournamentService; - /** - * 토너먼트 리스트 조회 - * @param tournamentFilterRequestDto Enum 필터 정보 (page, size, type, status) - * @return 토너먼트 리스트 - */ - @GetMapping - public ResponseEntity getAllTournamentList(@ModelAttribute @Valid TournamentFilterRequestDto tournamentFilterRequestDto){ - Pageable pageRequest = PageRequest.of(tournamentFilterRequestDto.getPage() - 1, tournamentFilterRequestDto.getSize(), Sort.by("startTime").ascending()); - return ResponseEntity.status(HttpStatus.OK). - body(tournamentService.getAllTournamentList(pageRequest, tournamentFilterRequestDto.getType(), tournamentFilterRequestDto.getStatus())); - } + /** + * 토너먼트 리스트 조회 + * @param tournamentFilterRequestDto Enum 필터 정보 (page, size, type, status) + * @return 토너먼트 리스트 + */ + @GetMapping + public ResponseEntity getAllTournamentList( + @ModelAttribute @Valid TournamentFilterRequestDto tournamentFilterRequestDto) { + Pageable pageRequest = PageRequest.of(tournamentFilterRequestDto.getPage() - 1, + tournamentFilterRequestDto.getSize(), Sort.by("startTime").ascending()); + return ResponseEntity.status(HttpStatus.OK) + .body(tournamentService.getAllTournamentList(pageRequest, tournamentFilterRequestDto.getType(), + tournamentFilterRequestDto.getStatus())); + } - /** - *

유저 해당 토너먼트 참여 여부 확인 매서드

- * @param tournamentId 타겟 토너먼트 - * @param user 확인하고자 하는 유저(로그인한 유저 본인) - * @return - */ - @GetMapping("/{tournamentId}/users") - ResponseEntity getUserStatusInTournament(@PathVariable Long tournamentId, @Parameter(hidden = true) @Login UserDto user) { + /** + *

유저 해당 토너먼트 참여 여부 확인 매서드

+ * @param tournamentId 타겟 토너먼트 + * @param user 확인하고자 하는 유저(로그인한 유저 본인) + * @return + */ + @GetMapping("/{tournamentId}/users") + ResponseEntity getUserStatusInTournament(@PathVariable Long tournamentId, + @Parameter(hidden = true) @Login UserDto user) { - return ResponseEntity.status(HttpStatus.OK).body(tournamentService.getUserStatusInTournament(tournamentId, user)); - } + return ResponseEntity.status(HttpStatus.OK) + .body(tournamentService.getUserStatusInTournament(tournamentId, user)); + } - /** - * 토너먼트 단일 조회 - * @param tournamentId 토너먼트 id - * @return 토너먼트 - */ - @GetMapping("/{tournamentId}") - public ResponseEntity getTournnament(@PathVariable @Positive Long tournamentId) { - TournamentResponseDto tournamentResponseDto = tournamentService.getTournament(tournamentId); - return ResponseEntity.status(HttpStatus.OK).body(tournamentResponseDto); - } + /** + * 토너먼트 단일 조회 + * @param tournamentId 토너먼트 id + * @return 토너먼트 + */ + @GetMapping("/{tournamentId}") + public ResponseEntity getTournnament(@PathVariable @Positive Long tournamentId) { + TournamentResponseDto tournamentResponseDto = tournamentService.getTournament(tournamentId); + return ResponseEntity.status(HttpStatus.OK).body(tournamentResponseDto); + } - @DeleteMapping("/{tournamentId}/users") - ResponseEntity cancelTournamentUserRegistration(@PathVariable Long tournamentId, @Parameter(hidden = true) @Login UserDto user) { + @DeleteMapping("/{tournamentId}/users") + ResponseEntity cancelTournamentUserRegistration( + @PathVariable Long tournamentId, @Parameter(hidden = true) @Login UserDto user) { - return ResponseEntity.status(HttpStatus.OK).body(tournamentService.cancelTournamentUserRegistration(tournamentId, user)); - } + return ResponseEntity.status(HttpStatus.OK) + .body(tournamentService.cancelTournamentUserRegistration(tournamentId, user)); + } - /** - * 토너먼트 게임 리스트 조회 - * @param tournamentId 토너먼트 id - * @return 토너먼트 게임 리스트 - */ - @GetMapping("/{tournamentId}/games") - public ResponseEntity getTournamentGames(@PathVariable @Positive Long tournamentId){ - return ResponseEntity.status(HttpStatus.OK).body(tournamentService.getTournamentGames(tournamentId)); - } + /** + * 토너먼트 게임 리스트 조회 + * @param tournamentId 토너먼트 id + * @return 토너먼트 게임 리스트 + */ + @GetMapping("/{tournamentId}/games") + public ResponseEntity getTournamentGames(@PathVariable @Positive Long tournamentId) { + return ResponseEntity.status(HttpStatus.OK).body(tournamentService.getTournamentGames(tournamentId)); + } - /** - *

토너먼트 참가 신청

- *

토너먼트 최대 인원보다 이미 많이 신청했다면 대기자로 들어간다

- * @param tournamentId 타겟 토너먼트 id - * @param user 신청 유저(본인) - * @return - */ - @PostMapping("/{tournamentId}/users") - ResponseEntity registerTournamentUser(@PathVariable Long tournamentId, @Parameter(hidden = true) @Login UserDto user) { + /** + *

토너먼트 참가 신청

+ *

토너먼트 최대 인원보다 이미 많이 신청했다면 대기자로 들어간다

+ * @param tournamentId 타겟 토너먼트 id + * @param user 신청 유저(본인) + * @return + */ + @PostMapping("/{tournamentId}/users") + ResponseEntity registerTournamentUser(@PathVariable Long tournamentId, + @Parameter(hidden = true) @Login UserDto user) { - return ResponseEntity.status(HttpStatus.CREATED) - .body(tournamentService.registerTournamentUser(tournamentId, user)); - } + return ResponseEntity.status(HttpStatus.CREATED) + .body(tournamentService.registerTournamentUser(tournamentId, user)); + } } diff --git a/src/main/java/com/gg/server/domain/tournament/data/Tournament.java b/src/main/java/com/gg/server/domain/tournament/data/Tournament.java index a81736da4..eb554d47a 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/Tournament.java +++ b/src/main/java/com/gg/server/domain/tournament/data/Tournament.java @@ -1,22 +1,12 @@ package com.gg.server.domain.tournament.data; import static com.gg.server.global.exception.ErrorCode.*; -import static com.gg.server.global.exception.ErrorCode.TOURNAMENT_GAME_EXCEED; -import static com.gg.server.global.utils.BusinessChecker.mustContains; -import static com.gg.server.global.utils.BusinessChecker.mustNotContains; -import static com.gg.server.global.utils.BusinessChecker.mustNotExceed; -import static com.gg.server.global.utils.BusinessChecker.mustNotNull; +import static com.gg.server.global.utils.BusinessChecker.*; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; -import com.gg.server.domain.user.data.User; -import com.gg.server.global.utils.BaseTimeEntity; import java.time.LocalDateTime; import java.util.ArrayList; -import java.util.Comparator; import java.util.List; -import java.util.stream.Collectors; -import javax.persistence.*; + import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -30,128 +20,133 @@ import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.validation.constraints.NotNull; + +import com.gg.server.domain.tournament.type.TournamentStatus; +import com.gg.server.domain.tournament.type.TournamentType; +import com.gg.server.domain.user.data.User; +import com.gg.server.global.utils.BaseTimeEntity; + import lombok.AccessLevel; -import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.ToString; @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter @Entity public class Tournament extends BaseTimeEntity { - // 토너먼트 참가자 수 => 현재는 8강 고정 - public static final int ALLOWED_JOINED_NUMBER = 8; - // 토너먼트 최소 시작 날짜 (n일 후) - public static final int ALLOWED_MINIMAL_START_DAYS = 2; - // 토너먼트 최소 진행 시간 (n시간) - public static final int MINIMUM_TOURNAMENT_DURATION = 2; - - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @NotNull - @Column(name = "title", length = 30) - private String title; - - @NotNull - @Column(name = "contents", length = 3000) - private String contents; - - @NotNull - @Column(name = "start_time") - private LocalDateTime startTime; - - @NotNull - @Column(name = "end_time") - private LocalDateTime endTime; - - @NotNull - @Enumerated(EnumType.STRING) - @Column(name = "type") - private TournamentType type; - - @NotNull - @Column(name = "status") - @Enumerated(EnumType.STRING) - private TournamentStatus status; - - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "winner_id") - private User winner; - - @OneToMany(mappedBy = "tournament", cascade = CascadeType.ALL) - private List tournamentGames = new ArrayList<>(); - - @OneToMany(mappedBy = "tournament", cascade = CascadeType.ALL) - private List tournamentUsers = new ArrayList<>(); - - /** - * winner는 생성시점에 존재하지 않음. - */ - @Builder - public Tournament(String title, String contents, LocalDateTime startTime, LocalDateTime endTime, - TournamentType type, TournamentStatus status) { - this.title = title; - this.contents = contents; - this.startTime = startTime; - this.endTime = endTime; - this.type = type; - this.status = status; - this.winner = null; - } - - public void update(String title, String contents, LocalDateTime startTime, - LocalDateTime endTime, TournamentType type, TournamentStatus status) { - this.title = title; - this.contents = contents; - this.startTime = startTime; - this.endTime = endTime; - this.type = type; - this.status = status; - } - - /** - * TournamentGame 에서 호출하는 연관관계 편의 메서드, 기타 호출 금지. - */ - protected void addTournamentGame(TournamentGame tournamentGame) { - mustNotNull(tournamentGame, NULL_POINT); - mustNotExceed(ALLOWED_JOINED_NUMBER - 2, tournamentGames, TOURNAMENT_GAME_EXCEED); - mustNotContains(tournamentGame, tournamentGames, TOURNAMENT_GAME_DUPLICATION); - this.tournamentGames.add(tournamentGame); - } - - /** - * TournamentUser 에서 호출하는 연관관계 편의 메서드, 기타 호출 금지. - */ - protected void addTournamentUser(@NotNull TournamentUser tournamentUser) { - mustNotNull(tournamentUser, NULL_POINT); - mustNotContains(tournamentUser, tournamentUsers, TOURNAMENT_USER_DUPLICATION); - this.tournamentUsers.add(tournamentUser); - } - - /** - * TournamentGame 에서 호출하는 연관관계 편의 메서드, 기타 호출 금지. - */ - protected void deleteTournamentUser(TournamentUser tournamentUser) { - mustNotNull(tournamentUser, NULL_POINT); - mustContains(tournamentUser, tournamentUsers, TOURNAMENT_USER_NOT_FOUND); - this.tournamentUsers.remove(tournamentUser); - } - - public void updateWinner(User winner) { - mustNotNull(winner, NULL_POINT); - this.winner = winner; - } - - public void updateStatus(TournamentStatus status) { - mustNotNull(status, NULL_POINT); - this.status = status; - } - - public void updateEndTime(LocalDateTime endTime) { - mustNotNull(endTime, NULL_POINT); - this.endTime = endTime; - } + // 토너먼트 참가자 수 => 현재는 8강 고정 + public static final int ALLOWED_JOINED_NUMBER = 8; + // 토너먼트 최소 시작 날짜 (n일 후) + public static final int ALLOWED_MINIMAL_START_DAYS = 2; + // 토너먼트 최소 진행 시간 (n시간) + public static final int MINIMUM_TOURNAMENT_DURATION = 2; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull + @Column(name = "title", length = 30) + private String title; + + @NotNull + @Column(name = "contents", length = 3000) + private String contents; + + @NotNull + @Column(name = "start_time") + private LocalDateTime startTime; + + @NotNull + @Column(name = "end_time") + private LocalDateTime endTime; + + @NotNull + @Enumerated(EnumType.STRING) + @Column(name = "type") + private TournamentType type; + + @NotNull + @Column(name = "status") + @Enumerated(EnumType.STRING) + private TournamentStatus status; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "winner_id") + private User winner; + + @OneToMany(mappedBy = "tournament", cascade = CascadeType.ALL) + private List tournamentGames = new ArrayList<>(); + + @OneToMany(mappedBy = "tournament", cascade = CascadeType.ALL) + private List tournamentUsers = new ArrayList<>(); + + /** + * winner는 생성시점에 존재하지 않음. + */ + @Builder + public Tournament(String title, String contents, LocalDateTime startTime, LocalDateTime endTime, + TournamentType type, TournamentStatus status) { + this.title = title; + this.contents = contents; + this.startTime = startTime; + this.endTime = endTime; + this.type = type; + this.status = status; + this.winner = null; + } + + public void update(String title, String contents, LocalDateTime startTime, + LocalDateTime endTime, TournamentType type, TournamentStatus status) { + this.title = title; + this.contents = contents; + this.startTime = startTime; + this.endTime = endTime; + this.type = type; + this.status = status; + } + + /** + * TournamentGame 에서 호출하는 연관관계 편의 메서드, 기타 호출 금지. + */ + protected void addTournamentGame(TournamentGame tournamentGame) { + mustNotNull(tournamentGame, NULL_POINT); + mustNotExceed(ALLOWED_JOINED_NUMBER - 2, tournamentGames, TOURNAMENT_GAME_EXCEED); + mustNotContains(tournamentGame, tournamentGames, TOURNAMENT_GAME_DUPLICATION); + this.tournamentGames.add(tournamentGame); + } + + /** + * TournamentUser 에서 호출하는 연관관계 편의 메서드, 기타 호출 금지. + */ + protected void addTournamentUser(@NotNull TournamentUser tournamentUser) { + mustNotNull(tournamentUser, NULL_POINT); + mustNotContains(tournamentUser, tournamentUsers, TOURNAMENT_USER_DUPLICATION); + this.tournamentUsers.add(tournamentUser); + } + + /** + * TournamentGame 에서 호출하는 연관관계 편의 메서드, 기타 호출 금지. + */ + protected void deleteTournamentUser(TournamentUser tournamentUser) { + mustNotNull(tournamentUser, NULL_POINT); + mustContains(tournamentUser, tournamentUsers, TOURNAMENT_USER_NOT_FOUND); + this.tournamentUsers.remove(tournamentUser); + } + + public void updateWinner(User winner) { + mustNotNull(winner, NULL_POINT); + this.winner = winner; + } + + public void updateStatus(TournamentStatus status) { + mustNotNull(status, NULL_POINT); + this.status = status; + } + + public void updateEndTime(LocalDateTime endTime) { + mustNotNull(endTime, NULL_POINT); + this.endTime = endTime; + } } diff --git a/src/main/java/com/gg/server/domain/tournament/data/TournamentGame.java b/src/main/java/com/gg/server/domain/tournament/data/TournamentGame.java index d4e25d948..22886c0c4 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/TournamentGame.java +++ b/src/main/java/com/gg/server/domain/tournament/data/TournamentGame.java @@ -1,60 +1,73 @@ package com.gg.server.domain.tournament.data; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToOne; +import javax.validation.constraints.NotNull; + import com.gg.server.domain.game.data.Game; import com.gg.server.domain.tournament.type.TournamentRound; import com.gg.server.global.utils.BaseTimeEntity; -import javax.persistence.*; -import javax.validation.constraints.NotNull; - -import lombok.*; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter @Entity public class TournamentGame extends BaseTimeEntity { - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "game_id") - private Game game; - - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "tournament_id") - private Tournament tournament; - - @NotNull - @Column(name = "round", length = 30) - @Enumerated(EnumType.STRING) - private TournamentRound tournamentRound; - - - /** - * id 값 제외한 생성자. - *

- * 생성에 따른 Tournament 연관관계 설정을 담당 - *

- * @param game - * @param tournament - * @param tournamentRound - */ - @Builder - public TournamentGame(Game game, Tournament tournament, TournamentRound tournamentRound) { - tournament.addTournamentGame(this); - this.game = game; - this.tournament = tournament; - this.tournamentRound = tournamentRound; - } - - /** - * TournamentGame의 게임 정보를 업데이트한다. - * @param game - */ - public void updateGame(Game game) { - this.game = game; - } + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "game_id") + private Game game; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "tournament_id") + private Tournament tournament; + + @NotNull + @Column(name = "round", length = 30) + @Enumerated(EnumType.STRING) + private TournamentRound tournamentRound; + + /** + * id 값 제외한 생성자. + *

+ * 생성에 따른 Tournament 연관관계 설정을 담당 + *

+ * @param game + * @param tournament + * @param tournamentRound + */ + @Builder + public TournamentGame(Game game, Tournament tournament, TournamentRound tournamentRound) { + tournament.addTournamentGame(this); + this.game = game; + this.tournament = tournament; + this.tournamentRound = tournamentRound; + } + + /** + * TournamentGame의 게임 정보를 업데이트한다. + * @param game + */ + public void updateGame(Game game) { + this.game = game; + } } diff --git a/src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java b/src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java index c072ca4a4..3e9f94e9a 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java +++ b/src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java @@ -1,15 +1,16 @@ package com.gg.server.domain.tournament.data; -import com.gg.server.domain.tournament.type.TournamentRound; -import org.springframework.data.jpa.repository.JpaRepository; - import java.util.List; import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; + +import com.gg.server.domain.tournament.type.TournamentRound; + public interface TournamentGameRepository extends JpaRepository { - List findAllByTournamentId(Long tournamentId); + List findAllByTournamentId(Long tournamentId); - Optional findByTournamentIdAndTournamentRound(Long id, TournamentRound tournamentRound); + Optional findByTournamentIdAndTournamentRound(Long id, TournamentRound tournamentRound); - Optional findByGameId(Long gameId); + Optional findByGameId(Long gameId); } diff --git a/src/main/java/com/gg/server/domain/tournament/data/TournamentRepository.java b/src/main/java/com/gg/server/domain/tournament/data/TournamentRepository.java index 0b54b4555..5a85a3a33 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/TournamentRepository.java +++ b/src/main/java/com/gg/server/domain/tournament/data/TournamentRepository.java @@ -1,33 +1,39 @@ package com.gg.server.domain.tournament.data; -import com.gg.server.domain.tournament.type.TournamentStatus; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; -import com.gg.server.domain.tournament.type.TournamentType; + +import javax.validation.constraints.NotNull; + import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; - -import javax.validation.constraints.NotNull; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import com.gg.server.domain.tournament.type.TournamentStatus; +import com.gg.server.domain.tournament.type.TournamentType; + public interface TournamentRepository extends JpaRepository { - List findAllByStatusIsNot(TournamentStatus status); - Optional findByTitle(String title); + List findAllByStatusIsNot(TournamentStatus status); + + Optional findByTitle(String title); + + Page findAllByTypeAndStatus(@NotNull TournamentType type, @NotNull TournamentStatus status, + Pageable pageable); - Page findAllByTypeAndStatus(@NotNull TournamentType type, @NotNull TournamentStatus status, Pageable pageable); + Page findAllByStatus(@NotNull TournamentStatus status, Pageable pageable); - Page findAllByStatus(@NotNull TournamentStatus status, Pageable pageable); - List findAllByStatus(@NotNull TournamentStatus status); + List findAllByStatus(@NotNull TournamentStatus status); - Page findAllByType(@NotNull TournamentType type, Pageable pageable); + Page findAllByType(@NotNull TournamentType type, Pageable pageable); - @Query(value = "select t from Tournament t where (t.startTime between :startTime and :endTime) " - + "or (t.endTime between :startTime and :endTime) " - + "or (:startTime between t.startTime and t.endTime) " - + "or (:endTime between t.startTime and t.endTime)") - List findAllBetween(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime); + @Query(value = "select t from Tournament t where (t.startTime between :startTime and :endTime) " + + "or (t.endTime between :startTime and :endTime) " + + "or (:startTime between t.startTime and t.endTime) " + + "or (:endTime between t.startTime and t.endTime)") + List findAllBetween(@Param("startTime") LocalDateTime startTime, + @Param("endTime") LocalDateTime endTime); } diff --git a/src/main/java/com/gg/server/domain/tournament/data/TournamentUser.java b/src/main/java/com/gg/server/domain/tournament/data/TournamentUser.java index dc0cb614a..3b8679f17 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/TournamentUser.java +++ b/src/main/java/com/gg/server/domain/tournament/data/TournamentUser.java @@ -1,8 +1,7 @@ package com.gg.server.domain.tournament.data; -import com.gg.server.domain.user.data.User; -import com.gg.server.global.utils.BaseTimeEntity; import java.time.LocalDateTime; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -12,6 +11,10 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; + +import com.gg.server.domain.user.data.User; +import com.gg.server.global.utils.BaseTimeEntity; + import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -21,48 +24,49 @@ @Getter @Entity public class TournamentUser extends BaseTimeEntity { - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "tournament_id") - private Tournament tournament; + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "tournament_id") + private Tournament tournament; - @NotNull - @Column(name = "is_joined") - private Boolean isJoined; + @NotNull + @Column(name = "is_joined") + private Boolean isJoined; - @NotNull - @Column(name = "register_time") - private LocalDateTime registerTime; + @NotNull + @Column(name = "register_time") + private LocalDateTime registerTime; - /** - * 생성자이며, 빌더이자, 생성 연관관계를 담당한다. - */ - @Builder - public TournamentUser(User user, Tournament tournament, boolean isJoined, LocalDateTime registerTime) { - tournament.addTournamentUser(this); - this.user = user; - this.tournament = tournament; - this.isJoined = isJoined; - this.registerTime = registerTime; - } + /** + * 생성자이며, 빌더이자, 생성 연관관계를 담당한다. + */ + @Builder + public TournamentUser(User user, Tournament tournament, boolean isJoined, LocalDateTime registerTime) { + tournament.addTournamentUser(this); + this.user = user; + this.tournament = tournament; + this.isJoined = isJoined; + this.registerTime = registerTime; + } - /** - * 연관관계 편의 메서드, 삭제 책임을 가진다. - */ - public void deleteTournament() { - tournament.deleteTournamentUser(this); - this.tournament = null; - } + /** + * 연관관계 편의 메서드, 삭제 책임을 가진다. + */ + public void deleteTournament() { + tournament.deleteTournamentUser(this); + this.tournament = null; + } - public void updateIsJoined(boolean isJoined) { - this.isJoined = isJoined; - } + public void updateIsJoined(boolean isJoined) { + this.isJoined = isJoined; + } } diff --git a/src/main/java/com/gg/server/domain/tournament/data/TournamentUserRepository.java b/src/main/java/com/gg/server/domain/tournament/data/TournamentUserRepository.java index d7b421a9a..768ebf1b0 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/TournamentUserRepository.java +++ b/src/main/java/com/gg/server/domain/tournament/data/TournamentUserRepository.java @@ -1,21 +1,23 @@ package com.gg.server.domain.tournament.data; -import com.gg.server.domain.user.data.User; import java.util.List; import java.util.Optional; + import org.springframework.data.jpa.repository.JpaRepository; +import com.gg.server.domain.user.data.User; + public interface TournamentUserRepository extends JpaRepository { - int countByTournamentAndIsJoined(Tournament tournament, boolean isJoined); + int countByTournamentAndIsJoined(Tournament tournament, boolean isJoined); - List findAllByTournament(Tournament tournament); + List findAllByTournament(Tournament tournament); - List findAllByTournamentAndIsJoined(Tournament tournament, boolean isJoined); + List findAllByTournamentAndIsJoined(Tournament tournament, boolean isJoined); - List findAllByTournamentId(Long tournamentId); + List findAllByTournamentId(Long tournamentId); - Optional findByTournamentIdAndUserId(Long tournamentId, Long userId); + Optional findByTournamentIdAndUserId(Long tournamentId, Long userId); - List findAllByUser(User user); + List findAllByUser(User user); } diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentFilterRequestDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentFilterRequestDto.java index 370a0d5ff..1307697b1 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentFilterRequestDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentFilterRequestDto.java @@ -3,18 +3,19 @@ import com.gg.server.domain.tournament.type.TournamentStatus; import com.gg.server.domain.tournament.type.TournamentType; import com.gg.server.global.dto.PageRequestDto; + import lombok.Getter; @Getter public class TournamentFilterRequestDto extends PageRequestDto { - private TournamentType type; + private TournamentType type; - private TournamentStatus status; + private TournamentStatus status; - public TournamentFilterRequestDto(Integer page, Integer size, TournamentType type, TournamentStatus status) { - super(page, size); - this.type = type; - this.status = status; - } + public TournamentFilterRequestDto(Integer page, Integer size, TournamentType type, TournamentStatus status) { + super(page, size); + this.type = type; + this.status = status; + } } diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameListResponseDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameListResponseDto.java index faa450578..105df0017 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameListResponseDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameListResponseDto.java @@ -1,27 +1,27 @@ package com.gg.server.domain.tournament.dto; +import java.util.List; + import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) public class TournamentGameListResponseDto { - private Long tournamentId; - private List games; + private Long tournamentId; + private List games; - public TournamentGameListResponseDto(Long tournamentId, List games) { - this.tournamentId = tournamentId; - this.games = games; - } + public TournamentGameListResponseDto(Long tournamentId, List games) { + this.tournamentId = tournamentId; + this.games = games; + } - @Override - public String toString() { - return "TournamentGameListResponseDto{" + - "tournamentId=" + tournamentId + - ", games=" + games.toString() + - '}'; - } + @Override + public String toString() { + return "TournamentGameListResponseDto{" + + "tournamentId=" + tournamentId + + ", games=" + games.toString() + + '}'; + } } diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameResDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameResDto.java index 961dee647..ec70f4f27 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameResDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameResDto.java @@ -1,10 +1,10 @@ package com.gg.server.domain.tournament.dto; -import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.dto.GameResultResDto; import com.gg.server.domain.game.dto.GameTeamUser; import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.type.TournamentRound; + import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -13,25 +13,26 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class TournamentGameResDto { - private Long tournamentGameId; - private Long nextTournamentGameId; - private TournamentRound tournamentRound; - private GameResultResDto game; + private Long tournamentGameId; + private Long nextTournamentGameId; + private TournamentRound tournamentRound; + private GameResultResDto game; - public TournamentGameResDto(TournamentGame tournamentGame, GameTeamUser game, TournamentRound tournamentRound, TournamentGame nextTournamentGame){ - this.tournamentGameId = tournamentGame.getId(); - this.game = game == null? null : new GameResultResDto(game); - this.tournamentRound = tournamentRound; - this.nextTournamentGameId = nextTournamentGame == null? null : nextTournamentGame.getId(); - } + public TournamentGameResDto(TournamentGame tournamentGame, GameTeamUser game, TournamentRound tournamentRound, + TournamentGame nextTournamentGame) { + this.tournamentGameId = tournamentGame.getId(); + this.game = game == null ? null : new GameResultResDto(game); + this.tournamentRound = tournamentRound; + this.nextTournamentGameId = nextTournamentGame == null ? null : nextTournamentGame.getId(); + } - @Override - public String toString() { - return "TournamentGameResDto{" + - "tournamentGameId=" + tournamentGameId + - ", NextTournamentGameId=" + nextTournamentGameId + - ", tournamentRound='" + tournamentRound + '\'' + - ", gameId=" + game.getGameId() + - '}'; - } + @Override + public String toString() { + return "TournamentGameResDto{" + + "tournamentGameId=" + tournamentGameId + + ", NextTournamentGameId=" + nextTournamentGameId + + ", tournamentRound='" + tournamentRound + '\'' + + ", gameId=" + game.getGameId() + + '}'; + } } diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentListResponseDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentListResponseDto.java index c6ce1ca25..9185defe0 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentListResponseDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentListResponseDto.java @@ -1,17 +1,16 @@ package com.gg.server.domain.tournament.dto; +import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @AllArgsConstructor @NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) @Getter public class TournamentListResponseDto { - private List tournaments; - private int totalPage; + private List tournaments; + private int totalPage; } diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java index 791d1e1d8..ae1360059 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java @@ -1,46 +1,46 @@ package com.gg.server.domain.tournament.dto; +import java.time.LocalDateTime; import com.gg.server.domain.tournament.data.Tournament; import com.gg.server.domain.tournament.type.TournamentStatus; import com.gg.server.domain.tournament.type.TournamentType; import com.gg.server.domain.user.dto.UserImageDto; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; - @AllArgsConstructor @NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) @Getter public class TournamentResponseDto { - private Long tournamentId; - private String title; - private String contents; - private LocalDateTime startTime; - private LocalDateTime endTime; - private TournamentType type; - private TournamentStatus status; - private String winnerIntraId; - private String winnerImageUrl; - private int playerCnt; + private Long tournamentId; + private String title; + private String contents; + private LocalDateTime startTime; + private LocalDateTime endTime; + private TournamentType type; + private TournamentStatus status; + private String winnerIntraId; + private String winnerImageUrl; + private int playerCnt; - public TournamentResponseDto (Tournament tournament, UserImageDto winner, int playerCnt) { - this.tournamentId = tournament.getId(); - this.title = tournament.getTitle(); - this.contents = tournament.getContents(); - this.startTime = tournament.getStartTime(); - this.endTime = tournament.getEndTime(); - this.type = tournament.getType(); - this.status = tournament.getStatus(); - this.winnerIntraId = winner.getIntraId(); - this.winnerImageUrl = winner.getImageUri(); - this.playerCnt = playerCnt; - } + public TournamentResponseDto(Tournament tournament, UserImageDto winner, int playerCnt) { + this.tournamentId = tournament.getId(); + this.title = tournament.getTitle(); + this.contents = tournament.getContents(); + this.startTime = tournament.getStartTime(); + this.endTime = tournament.getEndTime(); + this.type = tournament.getType(); + this.status = tournament.getStatus(); + this.winnerIntraId = winner.getIntraId(); + this.winnerImageUrl = winner.getImageUri(); + this.playerCnt = playerCnt; + } - public void update_player_cnt(int playerCnt) { - this.playerCnt = playerCnt; - } + public void update_player_cnt(int playerCnt) { + this.playerCnt = playerCnt; + } } diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserListResponseDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserListResponseDto.java index b08fee116..1ed2c6629 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserListResponseDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserListResponseDto.java @@ -1,24 +1,25 @@ package com.gg.server.domain.tournament.dto; -import com.gg.server.domain.tournament.data.TournamentUser; -import lombok.Getter; -import lombok.NoArgsConstructor; - import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import com.gg.server.domain.tournament.data.TournamentUser; + +import lombok.Getter; +import lombok.NoArgsConstructor; + @NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) @Getter public class TournamentUserListResponseDto { - private List users; + private List users; - public TournamentUserListResponseDto(List tournamentUsers){ - users = new ArrayList<>(); - for (TournamentUser tournamentUser : tournamentUsers) { - users.add(new TournamentUserResponseDto(tournamentUser)); - } - users.sort(Comparator.comparing(TournamentUserResponseDto::getIsJoined).reversed(). - thenComparing(TournamentUserResponseDto::getRegisteredDate)); - } + public TournamentUserListResponseDto(List tournamentUsers) { + users = new ArrayList<>(); + for (TournamentUser tournamentUser : tournamentUsers) { + users.add(new TournamentUserResponseDto(tournamentUser)); + } + users.sort(Comparator.comparing(TournamentUserResponseDto::getIsJoined).reversed() + .thenComparing(TournamentUserResponseDto::getRegisteredDate)); + } } diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserRegistrationResponseDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserRegistrationResponseDto.java index 21fee5f4a..c7c05b683 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserRegistrationResponseDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserRegistrationResponseDto.java @@ -1,7 +1,7 @@ package com.gg.server.domain.tournament.dto; - import com.gg.server.domain.tournament.type.TournamentUserStatus; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -10,5 +10,5 @@ @NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) @Getter public class TournamentUserRegistrationResponseDto { - private TournamentUserStatus status; + private TournamentUserStatus status; } diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserResponseDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserResponseDto.java index 198a26f74..4b02bba3e 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserResponseDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserResponseDto.java @@ -1,25 +1,26 @@ package com.gg.server.domain.tournament.dto; +import java.time.LocalDateTime; + import com.gg.server.domain.tournament.data.TournamentUser; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; - @AllArgsConstructor @NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) @Getter public class TournamentUserResponseDto { - private Long userId; - private String intraId; - private Boolean isJoined; - private LocalDateTime registeredDate; + private Long userId; + private String intraId; + private Boolean isJoined; + private LocalDateTime registeredDate; - public TournamentUserResponseDto(TournamentUser tournamentUser) { - this.userId = tournamentUser.getUser().getId(); - this.intraId = tournamentUser.getUser().getIntraId(); - this.isJoined = tournamentUser.getIsJoined(); - this.registeredDate = tournamentUser.getRegisterTime(); - } + public TournamentUserResponseDto(TournamentUser tournamentUser) { + this.userId = tournamentUser.getUser().getId(); + this.intraId = tournamentUser.getUser().getIntraId(); + this.isJoined = tournamentUser.getIsJoined(); + this.registeredDate = tournamentUser.getRegisterTime(); + } } diff --git a/src/main/java/com/gg/server/domain/tournament/exception/TournamentConflictException.java b/src/main/java/com/gg/server/domain/tournament/exception/TournamentConflictException.java index a300c0a14..e9bbd20c5 100644 --- a/src/main/java/com/gg/server/domain/tournament/exception/TournamentConflictException.java +++ b/src/main/java/com/gg/server/domain/tournament/exception/TournamentConflictException.java @@ -4,10 +4,11 @@ import com.gg.server.global.exception.custom.DuplicationException; public class TournamentConflictException extends DuplicationException { - public TournamentConflictException() { - super(ErrorCode.TOURNAMENT_CONFLICT.getMessage(), ErrorCode.TOURNAMENT_CONFLICT); - } - public TournamentConflictException(ErrorCode errorCode) { - super(errorCode.getMessage(), errorCode); - } + public TournamentConflictException() { + super(ErrorCode.TOURNAMENT_CONFLICT.getMessage(), ErrorCode.TOURNAMENT_CONFLICT); + } + + public TournamentConflictException(ErrorCode errorCode) { + super(errorCode.getMessage(), errorCode); + } } diff --git a/src/main/java/com/gg/server/domain/tournament/exception/TournamentGameNotFoundException.java b/src/main/java/com/gg/server/domain/tournament/exception/TournamentGameNotFoundException.java index 9ea98a589..6105469c2 100644 --- a/src/main/java/com/gg/server/domain/tournament/exception/TournamentGameNotFoundException.java +++ b/src/main/java/com/gg/server/domain/tournament/exception/TournamentGameNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class TournamentGameNotFoundException extends NotExistException { - public TournamentGameNotFoundException() { - super(ErrorCode.TOURNAMENT_GAME_NOT_FOUND.getMessage(), ErrorCode.TOURNAMENT_GAME_NOT_FOUND); - } + public TournamentGameNotFoundException() { + super(ErrorCode.TOURNAMENT_GAME_NOT_FOUND.getMessage(), ErrorCode.TOURNAMENT_GAME_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/tournament/exception/TournamentNotFoundException.java b/src/main/java/com/gg/server/domain/tournament/exception/TournamentNotFoundException.java index a63fcb1f6..6a5c1f8eb 100644 --- a/src/main/java/com/gg/server/domain/tournament/exception/TournamentNotFoundException.java +++ b/src/main/java/com/gg/server/domain/tournament/exception/TournamentNotFoundException.java @@ -4,10 +4,11 @@ import com.gg.server.global.exception.custom.NotExistException; public class TournamentNotFoundException extends NotExistException { - public TournamentNotFoundException() { - super(ErrorCode.TOURNAMENT_NOT_FOUND.getMessage(), ErrorCode.TOURNAMENT_NOT_FOUND); - } - public TournamentNotFoundException(ErrorCode errorCode) { - super(errorCode.getMessage(), errorCode); - } + public TournamentNotFoundException() { + super(ErrorCode.TOURNAMENT_NOT_FOUND.getMessage(), ErrorCode.TOURNAMENT_NOT_FOUND); + } + + public TournamentNotFoundException(ErrorCode errorCode) { + super(errorCode.getMessage(), errorCode); + } } diff --git a/src/main/java/com/gg/server/domain/tournament/exception/TournamentUpdateException.java b/src/main/java/com/gg/server/domain/tournament/exception/TournamentUpdateException.java index d1f9c6e80..b0b30faee 100644 --- a/src/main/java/com/gg/server/domain/tournament/exception/TournamentUpdateException.java +++ b/src/main/java/com/gg/server/domain/tournament/exception/TournamentUpdateException.java @@ -4,10 +4,11 @@ import com.gg.server.global.exception.custom.ForbiddenException; public class TournamentUpdateException extends ForbiddenException { - public TournamentUpdateException() { - super(ErrorCode.TOURNAMENT_CAN_NOT_UPDATE.getMessage(), ErrorCode.TOURNAMENT_CAN_NOT_UPDATE); - } - public TournamentUpdateException(ErrorCode errorCode) { - super(errorCode.getMessage(), errorCode); - } + public TournamentUpdateException() { + super(ErrorCode.TOURNAMENT_CAN_NOT_UPDATE.getMessage(), ErrorCode.TOURNAMENT_CAN_NOT_UPDATE); + } + + public TournamentUpdateException(ErrorCode errorCode) { + super(errorCode.getMessage(), errorCode); + } } diff --git a/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java b/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java index 5d4368b8f..4f3d9b0e3 100644 --- a/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java +++ b/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java @@ -1,21 +1,35 @@ package com.gg.server.domain.tournament.service; +import static com.gg.server.domain.tournament.type.TournamentRound.*; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; import com.gg.server.admin.noti.service.NotiAdminService; import com.gg.server.domain.game.data.GameRepository; +import com.gg.server.domain.game.dto.GameTeamUser; import com.gg.server.domain.match.service.MatchTournamentService; import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.tournament.data.*; import com.gg.server.domain.tournament.data.Tournament; +import com.gg.server.domain.tournament.data.TournamentGame; +import com.gg.server.domain.tournament.data.TournamentGameRepository; import com.gg.server.domain.tournament.data.TournamentRepository; import com.gg.server.domain.tournament.data.TournamentUser; import com.gg.server.domain.tournament.data.TournamentUserRepository; -import com.gg.server.domain.tournament.dto.TournamentUserRegistrationResponseDto; -import com.gg.server.domain.game.dto.GameTeamUser; import com.gg.server.domain.tournament.dto.TournamentGameListResponseDto; import com.gg.server.domain.tournament.dto.TournamentGameResDto; import com.gg.server.domain.tournament.dto.TournamentListResponseDto; import com.gg.server.domain.tournament.dto.TournamentResponseDto; +import com.gg.server.domain.tournament.dto.TournamentUserRegistrationResponseDto; import com.gg.server.domain.tournament.exception.TournamentConflictException; import com.gg.server.domain.tournament.exception.TournamentNotFoundException; import com.gg.server.domain.tournament.exception.TournamentUpdateException; @@ -30,274 +44,279 @@ import com.gg.server.domain.user.exception.UserNotFoundException; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.BusinessException; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Optional; -import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDate; -import java.util.ArrayList; -import static com.gg.server.domain.tournament.type.TournamentRound.*; +import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor public class TournamentService { - private final TournamentRepository tournamentRepository; - private final TournamentUserRepository tournamentUserRepository; - private final UserRepository userRepository; - private final TournamentGameRepository tournamentGameRepository; - private final GameRepository gameRepository; - private final MatchTournamentService matchTournamentService; - private final NotiAdminService notiAdminService; - - /** - * 토너먼트 리스트 조회 - * @param pageRequest 페이지 정보 - * @param type 토너먼트 타입 - * @param status 토너먼트 상태 - * @return 토너먼트 리스트 - */ - public TournamentListResponseDto getAllTournamentList(Pageable pageRequest, TournamentType type, TournamentStatus status) { + private final TournamentRepository tournamentRepository; + private final TournamentUserRepository tournamentUserRepository; + private final UserRepository userRepository; + private final TournamentGameRepository tournamentGameRepository; + private final GameRepository gameRepository; + private final MatchTournamentService matchTournamentService; + private final NotiAdminService notiAdminService; - Page tournaments; - if (type == null && status == null) { - tournaments = tournamentRepository.findAll(pageRequest). - map(o-> new TournamentResponseDto(o, findTournamentWinner(o), findJoinedPlayerCnt(o))); - } else if (type == null){ - tournaments = tournamentRepository.findAllByStatus(status, pageRequest). - map(o-> new TournamentResponseDto(o, findTournamentWinner(o), findJoinedPlayerCnt(o))); - } else if (status == null) { - tournaments = tournamentRepository.findAllByType(type, pageRequest). - map(o-> new TournamentResponseDto(o, findTournamentWinner(o), findJoinedPlayerCnt(o))); - } else { - tournaments = tournamentRepository.findAllByTypeAndStatus(type, status, pageRequest). - map(o-> new TournamentResponseDto(o, findTournamentWinner(o), findJoinedPlayerCnt(o))); - } - return new TournamentListResponseDto(tournaments.getContent(), tournaments.getTotalPages()); - } + /** + * 토너먼트 리스트 조회 + * @param pageRequest 페이지 정보 + * @param type 토너먼트 타입 + * @param status 토너먼트 상태 + * @return 토너먼트 리스트 + */ + public TournamentListResponseDto getAllTournamentList(Pageable pageRequest, TournamentType type, + TournamentStatus status) { - /** - * 토너먼트 단일 조회 - * @param tournamentId - * @return 토너먼트 - */ - public TournamentResponseDto getTournament(long tournamentId) { - Tournament tournament = tournamentRepository.findById(tournamentId).orElseThrow(TournamentNotFoundException::new); - return (new TournamentResponseDto(tournament, findTournamentWinner(tournament), findJoinedPlayerCnt(tournament))); - } + Page tournaments; + if (type == null && status == null) { + tournaments = tournamentRepository.findAll(pageRequest) + .map(o -> new TournamentResponseDto(o, findTournamentWinner(o), findJoinedPlayerCnt(o))); + } else if (type == null) { + tournaments = tournamentRepository.findAllByStatus(status, pageRequest) + .map(o -> new TournamentResponseDto(o, findTournamentWinner(o), findJoinedPlayerCnt(o))); + } else if (status == null) { + tournaments = tournamentRepository.findAllByType(type, pageRequest) + .map(o -> new TournamentResponseDto(o, findTournamentWinner(o), findJoinedPlayerCnt(o))); + } else { + tournaments = tournamentRepository.findAllByTypeAndStatus(type, status, pageRequest) + .map(o -> new TournamentResponseDto(o, findTournamentWinner(o), findJoinedPlayerCnt(o))); + } + return new TournamentListResponseDto(tournaments.getContent(), tournaments.getTotalPages()); + } - /** - *

유저 해당 토너먼트 참여 여부 확인 매서드

- * @param tournamentId 타겟 토너먼트 - * @param user 해당 유저 - * @return TournamentUserRegistrationResponseDto [ BEFORE || WAIT || PLAYER ] - * @throws TournamentNotFoundException 타겟 토너먼트 없음 - */ - public TournamentUserRegistrationResponseDto getUserStatusInTournament(Long tournamentId, UserDto user) { - Tournament targetTournament = tournamentRepository.findById(tournamentId).orElseThrow(TournamentNotFoundException::new); + /** + * 토너먼트 단일 조회 + * @param tournamentId + * @return 토너먼트 + */ + public TournamentResponseDto getTournament(long tournamentId) { + Tournament tournament = tournamentRepository.findById(tournamentId) + .orElseThrow(TournamentNotFoundException::new); + return (new TournamentResponseDto(tournament, findTournamentWinner(tournament), + findJoinedPlayerCnt(tournament))); + } - TournamentUserStatus tournamentUserStatus = TournamentUserStatus.BEFORE; - Optional tournamentUser = tournamentUserRepository.findByTournamentIdAndUserId(tournamentId, user.getId()); - if (tournamentUser.isPresent()) { - tournamentUserStatus = tournamentUser.get().getIsJoined() ? TournamentUserStatus.PLAYER : TournamentUserStatus.WAIT; - } - return new TournamentUserRegistrationResponseDto(tournamentUserStatus); - } + /** + *

유저 해당 토너먼트 참여 여부 확인 매서드

+ * @param tournamentId 타겟 토너먼트 + * @param user 해당 유저 + * @return TournamentUserRegistrationResponseDto [ BEFORE || WAIT || PLAYER ] + * @throws TournamentNotFoundException 타겟 토너먼트 없음 + */ + public TournamentUserRegistrationResponseDto getUserStatusInTournament(Long tournamentId, UserDto user) { + Tournament targetTournament = tournamentRepository.findById(tournamentId) + .orElseThrow(TournamentNotFoundException::new); - /** - *

토너먼트 참가 신청 매서드

- *

이미 신청한 토너먼트 중 BEFORE || LIVE인 경우가 존재한다면 신청 불가능 하다.

- * @param tournamentId 타겟 토너먼트 Id - * @param user 신청 유저(로그인한 본인) - * @return TournamentUserRegistrationResponseDto [ WAIT || PLAYER ] - * @throws TournamentNotFoundException 타겟 토너먼트 없음 - * @throws UserNotFoundException 유저 없음 - * @throws TournamentConflictException 이미 신청한 토너먼트 존재(BEFORE || LIVE인 토너먼트) - */ - @Transactional - public TournamentUserRegistrationResponseDto registerTournamentUser(Long tournamentId, UserDto user) { - Tournament targetTournament = tournamentRepository.findById(tournamentId).orElseThrow(TournamentNotFoundException::new); - if (!targetTournament.getStatus().equals(TournamentStatus.BEFORE)) { - throw new TournamentUpdateException(); - } - User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); + TournamentUserStatus tournamentUserStatus = TournamentUserStatus.BEFORE; + Optional tournamentUser = tournamentUserRepository.findByTournamentIdAndUserId(tournamentId, + user.getId()); + if (tournamentUser.isPresent()) { + tournamentUserStatus = + tournamentUser.get().getIsJoined() ? TournamentUserStatus.PLAYER : TournamentUserStatus.WAIT; + } + return new TournamentUserRegistrationResponseDto(tournamentUserStatus); + } - List tournamentUserList = targetTournament.getTournamentUsers(); - tournamentUserRepository.findAllByUser(loginUser).stream() - .filter(tu->tu.getTournament().getStatus().equals(TournamentStatus.BEFORE) || tu.getTournament().getStatus().equals(TournamentStatus.LIVE)) - .findAny() - .ifPresent(a->{throw new TournamentConflictException(ErrorCode.TOURNAMENT_ALREADY_PARTICIPANT);}); - TournamentUser tournamentUser = new TournamentUser(loginUser, targetTournament, - tournamentUserList.size() < Tournament.ALLOWED_JOINED_NUMBER, LocalDateTime.now()); - TournamentUserStatus tournamentUserStatus = tournamentUser.getIsJoined() ? TournamentUserStatus.PLAYER : TournamentUserStatus.WAIT; - return new TournamentUserRegistrationResponseDto(tournamentUserStatus); - } + /** + *

토너먼트 참가 신청 매서드

+ *

이미 신청한 토너먼트 중 BEFORE || LIVE인 경우가 존재한다면 신청 불가능 하다.

+ * @param tournamentId 타겟 토너먼트 Id + * @param user 신청 유저(로그인한 본인) + * @return TournamentUserRegistrationResponseDto [ WAIT || PLAYER ] + * @throws TournamentNotFoundException 타겟 토너먼트 없음 + * @throws UserNotFoundException 유저 없음 + * @throws TournamentConflictException 이미 신청한 토너먼트 존재(BEFORE || LIVE인 토너먼트) + */ + @Transactional + public TournamentUserRegistrationResponseDto registerTournamentUser(Long tournamentId, UserDto user) { + Tournament targetTournament = tournamentRepository.findById(tournamentId) + .orElseThrow(TournamentNotFoundException::new); + if (!targetTournament.getStatus().equals(TournamentStatus.BEFORE)) { + throw new TournamentUpdateException(); + } + User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); - /** - *

유저 토너먼트 참가 신청 취소 매서드

- *

참가자가 WAIT 이거나 PLAYER 로 해당 토너먼트에 신청을 한 상태일때만 취소해 준다.

- * @param tournamentId 타겟 토너먼트 - * @param user 타겟 유저(사용자 본인) - * @throws TournamentNotFoundException 타겟 토너먼트 없음 || 타겟 토너먼트 신청자가 아님 - * @return - */ - @Transactional - public TournamentUserRegistrationResponseDto cancelTournamentUserRegistration(Long tournamentId, UserDto user) { - Tournament targetTournament = tournamentRepository.findById(tournamentId).orElseThrow(TournamentNotFoundException::new); - if (!targetTournament.getStatus().equals(TournamentStatus.BEFORE)) { - throw new TournamentUpdateException(); - } + List tournamentUserList = targetTournament.getTournamentUsers(); + tournamentUserRepository.findAllByUser(loginUser).stream() + .filter(tu -> tu.getTournament().getStatus().equals(TournamentStatus.BEFORE) || tu.getTournament() + .getStatus() + .equals(TournamentStatus.LIVE)) + .findAny() + .ifPresent(a -> { + throw new TournamentConflictException(ErrorCode.TOURNAMENT_ALREADY_PARTICIPANT); + }); + TournamentUser tournamentUser = new TournamentUser(loginUser, targetTournament, + tournamentUserList.size() < Tournament.ALLOWED_JOINED_NUMBER, LocalDateTime.now()); + TournamentUserStatus tournamentUserStatus = + tournamentUser.getIsJoined() ? TournamentUserStatus.PLAYER : TournamentUserStatus.WAIT; + return new TournamentUserRegistrationResponseDto(tournamentUserStatus); + } - List tournamentUserList = targetTournament.getTournamentUsers(); - TournamentUser targetTournamentUser = tournamentUserList.stream() - .filter(tu -> (tu.getUser().getId().equals(user.getId()))) - .findAny() - .orElseThrow(()-> new TournamentNotFoundException(ErrorCode.TOURNAMENT_NOT_PARTICIPANT)); - tournamentUserList.remove(targetTournamentUser); - if (targetTournamentUser.getIsJoined() && tournamentUserList.size() >= Tournament.ALLOWED_JOINED_NUMBER) { - tournamentUserList.get(Tournament.ALLOWED_JOINED_NUMBER - 1).updateIsJoined(true); - } - tournamentUserRepository.delete(targetTournamentUser); - return new TournamentUserRegistrationResponseDto(TournamentUserStatus.BEFORE); - } + /** + *

유저 토너먼트 참가 신청 취소 매서드

+ *

참가자가 WAIT 이거나 PLAYER 로 해당 토너먼트에 신청을 한 상태일때만 취소해 준다.

+ * @param tournamentId 타겟 토너먼트 + * @param user 타겟 유저(사용자 본인) + * @throws TournamentNotFoundException 타겟 토너먼트 없음 || 타겟 토너먼트 신청자가 아님 + * @return + */ + @Transactional + public TournamentUserRegistrationResponseDto cancelTournamentUserRegistration(Long tournamentId, UserDto user) { + Tournament targetTournament = tournamentRepository.findById(tournamentId) + .orElseThrow(TournamentNotFoundException::new); + if (!targetTournament.getStatus().equals(TournamentStatus.BEFORE)) { + throw new TournamentUpdateException(); + } - /** - * 진행중인 토너먼트 유무 확인 - * @param time 현재 시간 - * @return 종료되지 않은 토너먼트 있으면 true, 없으면 false - */ - public boolean isNotEndedTournament(LocalDateTime time) { - List tournamentList = tournamentRepository.findAllByStatusIsNot(TournamentStatus.END); - for (Tournament tournament : tournamentList) { - if (time.isAfter(tournament.getStartTime()) && - time.isBefore(tournament.getEndTime())) { - return false; - } - } - return true; - } + List tournamentUserList = targetTournament.getTournamentUsers(); + TournamentUser targetTournamentUser = tournamentUserList.stream() + .filter(tu -> (tu.getUser().getId().equals(user.getId()))) + .findAny() + .orElseThrow(() -> new TournamentNotFoundException(ErrorCode.TOURNAMENT_NOT_PARTICIPANT)); + tournamentUserList.remove(targetTournamentUser); + if (targetTournamentUser.getIsJoined() && tournamentUserList.size() >= Tournament.ALLOWED_JOINED_NUMBER) { + tournamentUserList.get(Tournament.ALLOWED_JOINED_NUMBER - 1).updateIsJoined(true); + } + tournamentUserRepository.delete(targetTournamentUser); + return new TournamentUserRegistrationResponseDto(TournamentUserStatus.BEFORE); + } - /** - * 오늘 시작하는 토너먼트가 있으면 해당 토너먼트 status를 LIVE로 변경하고 8강 경기 매칭 - * 참가자가 ALLOWED_JOINED_NUMBER보다 적으면 토너먼트 취소 - */ - @Transactional - public void startTournament() { - LocalDate date = LocalDate.now(); - List imminentTournaments = findImminentTournament(date); - for (Tournament imminentTournament : imminentTournaments) { - List tournamentUsers = imminentTournament.getTournamentUsers(); - if (tournamentUsers.size() < Tournament.ALLOWED_JOINED_NUMBER) { - for (TournamentUser tournamentUser : tournamentUsers) { - if (tournamentUser.getIsJoined().equals(true)) { - notiAdminService.sendAnnounceNotiToUser(new SendNotiAdminRequestDto(tournamentUser.getUser().getIntraId(), NotiType.TOURNAMENT_CANCELED.getMessage())); - } - } - tournamentRepository.delete(imminentTournament); - return; - } - imminentTournament.updateStatus(TournamentStatus.LIVE); - matchTournamentService.matchGames(imminentTournament, QUARTER_FINAL_1); - } - } + /** + * 진행중인 토너먼트 유무 확인 + * @param time 현재 시간 + * @return 종료되지 않은 토너먼트 있으면 true, 없으면 false + */ + public boolean isNotEndedTournament(LocalDateTime time) { + List tournamentList = tournamentRepository.findAllByStatusIsNot(TournamentStatus.END); + for (Tournament tournament : tournamentList) { + if (time.isAfter(tournament.getStartTime()) + && time.isBefore(tournament.getEndTime())) { + return false; + } + } + return true; + } - /** - * 시작 임박한(오늘 시작하는) 토너먼트 조회 - * @param date 조회하려는 토너먼트의 시작 날짜 - * @return date 날짜에 시작하는 토너먼트 - */ - private List findImminentTournament(LocalDate date) { - List tournaments = tournamentRepository.findAllByStatus(TournamentStatus.BEFORE); - List imminentTournaments = new ArrayList<>(); + /** + * 오늘 시작하는 토너먼트가 있으면 해당 토너먼트 status를 LIVE로 변경하고 8강 경기 매칭 + * 참가자가 ALLOWED_JOINED_NUMBER보다 적으면 토너먼트 취소 + */ + @Transactional + public void startTournament() { + LocalDate date = LocalDate.now(); + List imminentTournaments = findImminentTournament(date); + for (Tournament imminentTournament : imminentTournaments) { + List tournamentUsers = imminentTournament.getTournamentUsers(); + if (tournamentUsers.size() < Tournament.ALLOWED_JOINED_NUMBER) { + for (TournamentUser tournamentUser : tournamentUsers) { + if (tournamentUser.getIsJoined().equals(true)) { + notiAdminService.sendAnnounceNotiToUser( + new SendNotiAdminRequestDto(tournamentUser.getUser().getIntraId(), + NotiType.TOURNAMENT_CANCELED.getMessage())); + } + } + tournamentRepository.delete(imminentTournament); + return; + } + imminentTournament.updateStatus(TournamentStatus.LIVE); + matchTournamentService.matchGames(imminentTournament, QUARTER_FINAL_1); + } + } - for (Tournament tournament : tournaments) { - LocalDate startDate = tournament.getStartTime().toLocalDate(); - if (startDate.isEqual(date)) { - imminentTournaments.add(tournament); - } - } - return imminentTournaments; - } + /** + * 시작 임박한(오늘 시작하는) 토너먼트 조회 + * @param date 조회하려는 토너먼트의 시작 날짜 + * @return date 날짜에 시작하는 토너먼트 + */ + private List findImminentTournament(LocalDate date) { + List tournaments = tournamentRepository.findAllByStatus(TournamentStatus.BEFORE); + List imminentTournaments = new ArrayList<>(); + for (Tournament tournament : tournaments) { + LocalDate startDate = tournament.getStartTime().toLocalDate(); + if (startDate.isEqual(date)) { + imminentTournaments.add(tournament); + } + } + return imminentTournaments; + } - /** - * 토너먼트 우승자 조회 - * @param tournament 토너먼트 - * @return 토너먼트 우승자 정보 - */ - private UserImageDto findTournamentWinner(Tournament tournament) { - User winner = tournament.getWinner(); - return new UserImageDto(winner); - } + /** + * 토너먼트 우승자 조회 + * @param tournament 토너먼트 + * @return 토너먼트 우승자 정보 + */ + private UserImageDto findTournamentWinner(Tournament tournament) { + User winner = tournament.getWinner(); + return new UserImageDto(winner); + } - /** - * 토너먼트 참가자 수 조회 - * @param tournament 토너먼트 - * @return 토너먼트 참가자 수 - */ - private int findJoinedPlayerCnt(Tournament tournament) { - return tournamentUserRepository.countByTournamentAndIsJoined(tournament, true); - } + /** + * 토너먼트 참가자 수 조회 + * @param tournament 토너먼트 + * @return 토너먼트 참가자 수 + */ + private int findJoinedPlayerCnt(Tournament tournament) { + return tournamentUserRepository.countByTournamentAndIsJoined(tournament, true); + } - /** - * 토너먼트 게임 목록 조회 - * @param tournamentId 토너먼트 id - * @return 토너먼트 게임 목록 - */ - public TournamentGameListResponseDto getTournamentGames(Long tournamentId) { - List tournamentGameResDtoList = getTournamentGameResDtoList(tournamentId); - return new TournamentGameListResponseDto(tournamentId, tournamentGameResDtoList); - } + /** + * 토너먼트 게임 목록 조회 + * @param tournamentId 토너먼트 id + * @return 토너먼트 게임 목록 + */ + public TournamentGameListResponseDto getTournamentGames(Long tournamentId) { + List tournamentGameResDtoList = getTournamentGameResDtoList(tournamentId); + return new TournamentGameListResponseDto(tournamentId, tournamentGameResDtoList); + } - /** - * TournamentGameResDto list 반환 - * @param tournamentId 토너먼트 id - * @return List - * - tournamentGameId: 토너먼트 게임 id - * - NextTournamentGameId: 다음 토너먼트 게임 id - * - tournamentRound: 토너먼트 라운드 - * - game: 게임 정보 - */ - private List getTournamentGameResDtoList(Long tournamentId){ - List tournamentGames = tournamentGameRepository.findAllByTournamentId(tournamentId); - List tournamentGameResDtoList = new ArrayList<>(); - for (TournamentGame tournamentGame : tournamentGames) { - TournamentGame nextTournamentGame = findNextTournamentGame(tournamentGames, tournamentGame); - GameTeamUser gameTeamUser = null; - if (tournamentGame.getGame() != null) { - gameTeamUser = gameRepository.findTeamsByGameId(tournamentGame.getGame().getId()) - .orElseThrow(() -> new BusinessException(ErrorCode.TEAM_USER_NOT_FOUND)); - } - tournamentGameResDtoList.add(new TournamentGameResDto(tournamentGame, gameTeamUser, tournamentGame.getTournamentRound(), nextTournamentGame)); - } - tournamentGameResDtoList.sort((o1, o2) -> { - if (o1.getTournamentRound().getRoundNumber() < o2.getTournamentRound().getRoundNumber()) { - return 1; - } - if (o1.getTournamentRound().getRoundOrder() > o2.getTournamentRound().getRoundOrder()) { - return 1; - } - return -1; - }); - return tournamentGameResDtoList; - } + /** + * TournamentGameResDto list 반환 + * @param tournamentId 토너먼트 id + * @return List + * - tournamentGameId: 토너먼트 게임 id + * - NextTournamentGameId: 다음 토너먼트 게임 id + * - tournamentRound: 토너먼트 라운드 + * - game: 게임 정보 + */ + private List getTournamentGameResDtoList(Long tournamentId) { + List tournamentGames = tournamentGameRepository.findAllByTournamentId(tournamentId); + List tournamentGameResDtoList = new ArrayList<>(); + for (TournamentGame tournamentGame : tournamentGames) { + TournamentGame nextTournamentGame = findNextTournamentGame(tournamentGames, tournamentGame); + GameTeamUser gameTeamUser = null; + if (tournamentGame.getGame() != null) { + gameTeamUser = gameRepository.findTeamsByGameId(tournamentGame.getGame().getId()) + .orElseThrow(() -> new BusinessException(ErrorCode.TEAM_USER_NOT_FOUND)); + } + tournamentGameResDtoList.add( + new TournamentGameResDto(tournamentGame, gameTeamUser, tournamentGame.getTournamentRound(), + nextTournamentGame)); + } + tournamentGameResDtoList.sort((o1, o2) -> { + if (o1.getTournamentRound().getRoundNumber() < o2.getTournamentRound().getRoundNumber()) { + return 1; + } + if (o1.getTournamentRound().getRoundOrder() > o2.getTournamentRound().getRoundOrder()) { + return 1; + } + return -1; + }); + return tournamentGameResDtoList; + } - /** - * 다음 토너먼트 게임 조회 - * @param tournamentGames tournamentGames 토너먼트 게임 리스트 - * @param tournamentGame 현재 토너먼트 게임 - * @return 다음 토너먼트 게임 - */ - private TournamentGame findNextTournamentGame(List tournamentGames, TournamentGame tournamentGame) { - TournamentRound tournamentRound = tournamentGame.getTournamentRound(); - return tournamentGames.stream() - .filter(tournamentGame1 -> tournamentGame1.getTournamentRound().equals(tournamentRound.getNextRound())) - .findFirst() - .orElse(null); - } -} \ No newline at end of file + /** + * 다음 토너먼트 게임 조회 + * @param tournamentGames tournamentGames 토너먼트 게임 리스트 + * @param tournamentGame 현재 토너먼트 게임 + * @return 다음 토너먼트 게임 + */ + private TournamentGame findNextTournamentGame(List tournamentGames, TournamentGame tournamentGame) { + TournamentRound tournamentRound = tournamentGame.getTournamentRound(); + return tournamentGames.stream() + .filter(tournamentGame1 -> tournamentGame1.getTournamentRound().equals(tournamentRound.getNextRound())) + .findFirst() + .orElse(null); + } +} diff --git a/src/main/java/com/gg/server/domain/tournament/type/TournamentRound.java b/src/main/java/com/gg/server/domain/tournament/type/TournamentRound.java index 89645d5c9..8952ffaa5 100644 --- a/src/main/java/com/gg/server/domain/tournament/type/TournamentRound.java +++ b/src/main/java/com/gg/server/domain/tournament/type/TournamentRound.java @@ -1,51 +1,51 @@ package com.gg.server.domain.tournament.type; import java.util.ArrayList; +import java.util.List; + import lombok.Getter; import lombok.RequiredArgsConstructor; -import java.util.List; - @RequiredArgsConstructor @Getter public enum TournamentRound { - // the final -> 결승 - // semi final -> 4강 - // quarter final -> 8강 - // ordinal()로 sorting 사용되고 있으므로 순서 중요 -> 이후에 리팩토링으로 해결하겠습니다. - THE_FINAL(null, 2, 1), - SEMI_FINAL_1(THE_FINAL, 4, 1), - SEMI_FINAL_2(THE_FINAL, 4, 2), - QUARTER_FINAL_1(SEMI_FINAL_1, 8, 1), - QUARTER_FINAL_2( SEMI_FINAL_1, 8, 2), - QUARTER_FINAL_3(SEMI_FINAL_2, 8, 3), - QUARTER_FINAL_4(SEMI_FINAL_2, 8, 4); + // the final -> 결승 + // semi final -> 4강 + // quarter final -> 8강 + // ordinal()로 sorting 사용되고 있으므로 순서 중요 -> 이후에 리팩토링으로 해결하겠습니다. + THE_FINAL(null, 2, 1), + SEMI_FINAL_1(THE_FINAL, 4, 1), + SEMI_FINAL_2(THE_FINAL, 4, 2), + QUARTER_FINAL_1(SEMI_FINAL_1, 8, 1), + QUARTER_FINAL_2(SEMI_FINAL_1, 8, 2), + QUARTER_FINAL_3(SEMI_FINAL_2, 8, 3), + QUARTER_FINAL_4(SEMI_FINAL_2, 8, 4); - private final TournamentRound nextRound; - private final int roundNumber; - private final int roundOrder; + private final TournamentRound nextRound; + private final int roundNumber; + private final int roundOrder; - public static List getSameRounds(TournamentRound round) { - List sameRounds = new ArrayList<>(); - for (TournamentRound e : values()) { - if (e.roundNumber == round.roundNumber) { - sameRounds.add(e); - } - } - return sameRounds; - } + public static List getSameRounds(TournamentRound round) { + List sameRounds = new ArrayList<>(); + for (TournamentRound e : values()) { + if (e.roundNumber == round.roundNumber) { + sameRounds.add(e); + } + } + return sameRounds; + } - /** - * 이전 TournamentRound의 roundNum를 반환한다. - * @param round - 현재 라운드 - * @return 이전 라운드의 roundNum, 없을 경우 -1 반환 - */ - public static int getPreviousRoundNumber(TournamentRound round) { - for (TournamentRound e : values()) { - if (e.nextRound == round) { - return e.roundNumber; - } - } - return -1; - } + /** + * 이전 TournamentRound의 roundNum를 반환한다. + * @param round - 현재 라운드 + * @return 이전 라운드의 roundNum, 없을 경우 -1 반환 + */ + public static int getPreviousRoundNumber(TournamentRound round) { + for (TournamentRound e : values()) { + if (e.nextRound == round) { + return e.roundNumber; + } + } + return -1; + } } diff --git a/src/main/java/com/gg/server/domain/tournament/type/TournamentStatus.java b/src/main/java/com/gg/server/domain/tournament/type/TournamentStatus.java index 644054125..df0d2360c 100644 --- a/src/main/java/com/gg/server/domain/tournament/type/TournamentStatus.java +++ b/src/main/java/com/gg/server/domain/tournament/type/TournamentStatus.java @@ -1,32 +1,34 @@ package com.gg.server.domain.tournament.type; +import java.util.Locale; + import com.fasterxml.jackson.annotation.JsonCreator; + import lombok.Getter; import lombok.RequiredArgsConstructor; -import java.util.Locale; - @Getter @RequiredArgsConstructor public enum TournamentStatus { - BEFORE("before", "토너먼트 시작 전"), - LIVE("live", "토너먼트 진행 중"), - END("end", "토너먼트 종료"); - - private final String code; - private final String desc; + BEFORE("before", "토너먼트 시작 전"), + LIVE("live", "토너먼트 진행 중"), + END("end", "토너먼트 종료"); + private final String code; + private final String desc; - @JsonCreator - public static TournamentStatus getEnumFromValue(String value) { - if (value == null) return null; - for(TournamentStatus e : values()) { - if (e.name().equals(value)) { - return e; - } else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { - return e; - } - } - return null; - } + @JsonCreator + public static TournamentStatus getEnumFromValue(String value) { + if (value == null) { + return null; + } + for (TournamentStatus e : values()) { + if (e.name().equals(value)) { + return e; + } else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { + return e; + } + } + return null; + } } diff --git a/src/main/java/com/gg/server/domain/tournament/type/TournamentType.java b/src/main/java/com/gg/server/domain/tournament/type/TournamentType.java index ffe08f5e1..7bfd1d923 100644 --- a/src/main/java/com/gg/server/domain/tournament/type/TournamentType.java +++ b/src/main/java/com/gg/server/domain/tournament/type/TournamentType.java @@ -1,32 +1,34 @@ package com.gg.server.domain.tournament.type; +import java.util.Locale; + import com.fasterxml.jackson.annotation.JsonCreator; + import lombok.Getter; import lombok.RequiredArgsConstructor; -import java.util.Locale; - @Getter @RequiredArgsConstructor public enum TournamentType { - ROOKIE("rookie", "초보"), - MASTER("master", "고수"), - CUSTOM("custom", "커스텀"); - - private final String code; - private final String desc; + ROOKIE("rookie", "초보"), + MASTER("master", "고수"), + CUSTOM("custom", "커스텀"); + private final String code; + private final String desc; - @JsonCreator - public static TournamentType getEnumFromValue(String value) { - if (value == null) return null; - for(TournamentType e : values()) { - if (e.name().equals(value)) { - return e; - } else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { - return e; - } - } - return null; - } + @JsonCreator + public static TournamentType getEnumFromValue(String value) { + if (value == null) { + return null; + } + for (TournamentType e : values()) { + if (e.name().equals(value)) { + return e; + } else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { + return e; + } + } + return null; + } } diff --git a/src/main/java/com/gg/server/domain/tournament/type/TournamentUserStatus.java b/src/main/java/com/gg/server/domain/tournament/type/TournamentUserStatus.java index fda394de9..931ba307a 100644 --- a/src/main/java/com/gg/server/domain/tournament/type/TournamentUserStatus.java +++ b/src/main/java/com/gg/server/domain/tournament/type/TournamentUserStatus.java @@ -6,10 +6,10 @@ @Getter @RequiredArgsConstructor public enum TournamentUserStatus { - PLAYER("player", "토너먼트 참가자"), - WAIT("wait", "토너먼트 대기자"), - BEFORE("before", "토너먼트 신청 전"); + PLAYER("player", "토너먼트 참가자"), + WAIT("wait", "토너먼트 대기자"), + BEFORE("before", "토너먼트 신청 전"); - private final String code; - private final String desc; + private final String code; + private final String desc; } diff --git a/src/main/java/com/gg/server/domain/user/controller/UserController.java b/src/main/java/com/gg/server/domain/user/controller/UserController.java index 10b54143b..c4f5ec477 100644 --- a/src/main/java/com/gg/server/domain/user/controller/UserController.java +++ b/src/main/java/com/gg/server/domain/user/controller/UserController.java @@ -1,161 +1,197 @@ package com.gg.server.domain.user.controller; +import java.io.IOException; +import java.util.List; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; + +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.user.dto.*; +import com.gg.server.domain.user.dto.UserAccessTokenDto; +import com.gg.server.domain.user.dto.UserAttendanceResponseDto; +import com.gg.server.domain.user.dto.UserBackgroundDto; +import com.gg.server.domain.user.dto.UserCoinHistoryListResponseDto; +import com.gg.server.domain.user.dto.UserCoinResponseDto; +import com.gg.server.domain.user.dto.UserDetailResponseDto; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.dto.UserEdgeDto; +import com.gg.server.domain.user.dto.UserHistoryResponseDto; +import com.gg.server.domain.user.dto.UserImageResponseDto; +import com.gg.server.domain.user.dto.UserLiveResponseDto; +import com.gg.server.domain.user.dto.UserModifyRequestDto; +import com.gg.server.domain.user.dto.UserNormalDetailResponseDto; +import com.gg.server.domain.user.dto.UserOauthDto; +import com.gg.server.domain.user.dto.UserProfileImageRequestDto; +import com.gg.server.domain.user.dto.UserRankResponseDto; +import com.gg.server.domain.user.dto.UserSearchResponseDto; +import com.gg.server.domain.user.dto.UserTextColorDto; import com.gg.server.domain.user.exception.KakaoOauth2AlreadyExistException; -import com.gg.server.domain.user.exception.TokenNotValidException; -import com.gg.server.domain.user.service.*; +import com.gg.server.domain.user.service.UserAuthenticationService; +import com.gg.server.domain.user.service.UserCoinService; +import com.gg.server.domain.user.service.UserService; import com.gg.server.domain.user.type.OauthType; import com.gg.server.domain.user.type.RoleType; import com.gg.server.global.dto.PageRequestDto; import com.gg.server.global.security.cookie.CookieUtil; import com.gg.server.global.security.jwt.utils.TokenHeaders; import com.gg.server.global.utils.argumentresolver.Login; + import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.io.IOException; -import java.util.List; - @RestController @RequiredArgsConstructor @RequestMapping("/pingpong/users") public class UserController { - private final UserService userService; - private final UserAuthenticationService userAuthenticationService; - private final CookieUtil cookieUtil; - private final UserCoinService userCoinService; - - @PostMapping("/accesstoken") - public ResponseEntity generateAccessToken(@RequestParam String refreshToken) { - String accessToken = userAuthenticationService.regenerate(refreshToken); - return new ResponseEntity<>(new UserAccessTokenDto(accessToken), HttpStatus.CREATED); - } - - @GetMapping - UserNormalDetailResponseDto getUserNormalDetail(@Parameter(hidden = true) @Login UserDto user){ - return userService.getUserNormalDetail(user); - } - - @GetMapping("/live") - UserLiveResponseDto getUserLiveDetail(@Parameter(hidden = true) @Login UserDto user) { - return userService.getUserLiveDetail(user); - } - - @GetMapping("/searches") - UserSearchResponseDto searchUsers(@RequestParam String intraId){ - List intraIds = userService.findByPartOfIntraId(intraId); - return new UserSearchResponseDto(intraIds); - } - - @GetMapping("/{intraId}") - public UserDetailResponseDto getUserDetail(@PathVariable String intraId){ - return userService.getUserDetail(intraId); - } - - @GetMapping("/{intraId}/rank") - public UserRankResponseDto getUserRank(@PathVariable String intraId, @RequestParam Long season){ - return userService.getUserRankDetail(intraId, season); - } - - @GetMapping("/{intraId}/historics") - public UserHistoryResponseDto getUserHistory(@PathVariable String intraId, @RequestParam Long season) { - return userService.getUserHistory(intraId, season); - } - - @PutMapping("{intraId}") - public ResponseEntity doModifyUser (@Valid @RequestBody UserModifyRequestDto userModifyRequestDto, - @PathVariable String intraId, @Parameter(hidden = true) @Login UserDto loginUser) { - if (!loginUser.getIntraId().equals(intraId)) { - return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); - } - userService.updateUser(userModifyRequestDto.getRacketType(), userModifyRequestDto.getStatusMessage(), - userModifyRequestDto.getSnsNotiOpt(), intraId); - return ResponseEntity.noContent().build(); - } - - @PostMapping("/logout") - public void logout(HttpServletResponse response) { - cookieUtil.deleteCookie(response, TokenHeaders.REFRESH_TOKEN); - } - - /** - * 42user 카카오 로그인 연동 해제 - */ - @DeleteMapping("/oauth/kakao") - public void deleteOauthKakao(@Parameter(hidden = true) @Login UserDto user) { - if (user.getRoleType().equals(RoleType.GUEST) || user.getKakaoId() == null) { - throw new KakaoOauth2AlreadyExistException(); - } - userService.deleteKakaoId(user.getId()); - } - - @GetMapping("/oauth") - public UserOauthDto getUserOauth2Information(@Parameter(hidden = true) @Login UserDto user) { - return new UserOauthDto(OauthType.of(user.getRoleType(), user.getKakaoId()).getCode()); - } - - @GetMapping("/top3") - public UserImageResponseDto getUserImage(@RequestParam(required = false) Long seasonId, Mode mode) { - if (mode == Mode.RANK) - return userService.getRankedUserImagesByPPP(seasonId); - else{ - PageRequest pageRequest = PageRequest.of(0, 3, Sort.by(Sort.Direction.DESC, "totalExp")); - return userService.getRankedUserImagesByExp(pageRequest); - } - } - - @PatchMapping("/text-color") - public ResponseEntity updateTextColor(@RequestBody @Valid UserTextColorDto textColorDto, @Parameter(hidden = true) @Login UserDto user) { - userService.updateTextColor(user.getId() ,textColorDto); - return ResponseEntity.noContent().build(); - } - - @PostMapping("/attendance") - public UserAttendanceResponseDto attendUser(@Parameter(hidden = true) @Login UserDto user) { - return userService.attendUser(user.getId()); - } - - @PatchMapping("/edge") - public String updateEdge(@RequestBody @Valid UserEdgeDto userEdgeDto, @Parameter(hidden = true) @Login UserDto user) { - String edge = userService.updateEdge(user, userEdgeDto); - return "{\"edge\": " + "\"" + edge + "\"" +"}"; - } - - @GetMapping("/coin") - public UserCoinResponseDto getUserCoin(@Parameter(hidden = true) @Login UserDto user) { - return userCoinService.getUserCoin(user.getIntraId()); - } - - @PatchMapping("/background") - public String updateBackground(@RequestBody @Valid UserBackgroundDto userBackgroundDto, @Parameter(hidden = true) @Login UserDto user) { - String background = userService.updateBackground(user, userBackgroundDto); - return "{\"background\": " + "\"" + background + "\"" +"}"; - } - - @GetMapping("/coinhistory") - public UserCoinHistoryListResponseDto getUserCoinHistory(@ModelAttribute @Valid PageRequestDto coReq, @Parameter(hidden = true) @Login UserDto user) { - Pageable pageable = PageRequest.of(coReq.getPage() - 1, coReq.getSize(), Sort.by("createdAt").descending()); - - return userCoinService.getUserCoinHistory(pageable ,user.getIntraId()); - } - - @PostMapping(path = "/profile-image", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.APPLICATION_JSON_VALUE}) - public ResponseEntity updateUserProfileImage(@RequestPart(required = false) MultipartFile profileImage, - @RequestPart @Valid UserProfileImageRequestDto userProfileImageRequestDto, - @Parameter(hidden = true) @Login UserDto user) throws IOException { - userService.updateUserProfileImage(user, userProfileImageRequestDto, profileImage); - return ResponseEntity.noContent().build(); - } + private final UserService userService; + private final UserAuthenticationService userAuthenticationService; + private final CookieUtil cookieUtil; + private final UserCoinService userCoinService; + + @PostMapping("/accesstoken") + public ResponseEntity generateAccessToken(@RequestParam String refreshToken) { + String accessToken = userAuthenticationService.regenerate(refreshToken); + return new ResponseEntity<>(new UserAccessTokenDto(accessToken), HttpStatus.CREATED); + } + + @GetMapping + UserNormalDetailResponseDto getUserNormalDetail(@Parameter(hidden = true) @Login UserDto user) { + return userService.getUserNormalDetail(user); + } + + @GetMapping("/live") + UserLiveResponseDto getUserLiveDetail(@Parameter(hidden = true) @Login UserDto user) { + return userService.getUserLiveDetail(user); + } + + @GetMapping("/searches") + UserSearchResponseDto searchUsers(@RequestParam String intraId) { + List intraIds = userService.findByPartOfIntraId(intraId); + return new UserSearchResponseDto(intraIds); + } + + @GetMapping("/{intraId}") + public UserDetailResponseDto getUserDetail(@PathVariable String intraId) { + return userService.getUserDetail(intraId); + } + + @GetMapping("/{intraId}/rank") + public UserRankResponseDto getUserRank(@PathVariable String intraId, @RequestParam Long season) { + return userService.getUserRankDetail(intraId, season); + } + + @GetMapping("/{intraId}/historics") + public UserHistoryResponseDto getUserHistory(@PathVariable String intraId, @RequestParam Long season) { + return userService.getUserHistory(intraId, season); + } + + @PutMapping("{intraId}") + public ResponseEntity doModifyUser(@Valid @RequestBody UserModifyRequestDto userModifyRequestDto, + @PathVariable String intraId, @Parameter(hidden = true) @Login UserDto loginUser) { + if (!loginUser.getIntraId().equals(intraId)) { + return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); + } + userService.updateUser(userModifyRequestDto.getRacketType(), userModifyRequestDto.getStatusMessage(), + userModifyRequestDto.getSnsNotiOpt(), intraId); + return ResponseEntity.noContent().build(); + } + + @PostMapping("/logout") + public void logout(HttpServletResponse response) { + cookieUtil.deleteCookie(response, TokenHeaders.REFRESH_TOKEN); + } + + /** + * 42user 카카오 로그인 연동 해제 + */ + @DeleteMapping("/oauth/kakao") + public void deleteOauthKakao(@Parameter(hidden = true) @Login UserDto user) { + if (user.getRoleType().equals(RoleType.GUEST) || user.getKakaoId() == null) { + throw new KakaoOauth2AlreadyExistException(); + } + userService.deleteKakaoId(user.getId()); + } + + @GetMapping("/oauth") + public UserOauthDto getUserOauth2Information(@Parameter(hidden = true) @Login UserDto user) { + return new UserOauthDto(OauthType.of(user.getRoleType(), user.getKakaoId()).getCode()); + } + + @GetMapping("/top3") + public UserImageResponseDto getUserImage(@RequestParam(required = false) Long seasonId, Mode mode) { + if (mode == Mode.RANK) { + return userService.getRankedUserImagesByPPP(seasonId); + } else { + PageRequest pageRequest = PageRequest.of(0, 3, Sort.by(Sort.Direction.DESC, "totalExp")); + return userService.getRankedUserImagesByExp(pageRequest); + } + } + + @PatchMapping("/text-color") + public ResponseEntity updateTextColor(@RequestBody @Valid UserTextColorDto textColorDto, + @Parameter(hidden = true) @Login UserDto user) { + userService.updateTextColor(user.getId(), textColorDto); + return ResponseEntity.noContent().build(); + } + + @PostMapping("/attendance") + public UserAttendanceResponseDto attendUser(@Parameter(hidden = true) @Login UserDto user) { + return userService.attendUser(user.getId()); + } + + @PatchMapping("/edge") + public String updateEdge(@RequestBody @Valid UserEdgeDto userEdgeDto, + @Parameter(hidden = true) @Login UserDto user) { + String edge = userService.updateEdge(user, userEdgeDto); + return "{\"edge\": " + "\"" + edge + "\"" + "}"; + } + + @GetMapping("/coin") + public UserCoinResponseDto getUserCoin(@Parameter(hidden = true) @Login UserDto user) { + return userCoinService.getUserCoin(user.getIntraId()); + } + + @PatchMapping("/background") + public String updateBackground(@RequestBody @Valid UserBackgroundDto userBackgroundDto, + @Parameter(hidden = true) @Login UserDto user) { + String background = userService.updateBackground(user, userBackgroundDto); + return "{\"background\": " + "\"" + background + "\"" + "}"; + } + + @GetMapping("/coinhistory") + public UserCoinHistoryListResponseDto getUserCoinHistory(@ModelAttribute @Valid PageRequestDto coReq, + @Parameter(hidden = true) @Login UserDto user) { + Pageable pageable = PageRequest.of(coReq.getPage() - 1, coReq.getSize(), Sort.by("createdAt").descending()); + + return userCoinService.getUserCoinHistory(pageable, user.getIntraId()); + } + + @PostMapping(path = "/profile-image", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, + MediaType.APPLICATION_JSON_VALUE}) + public ResponseEntity updateUserProfileImage(@RequestPart(required = false) MultipartFile profileImage, + @RequestPart @Valid UserProfileImageRequestDto userProfileImageRequestDto, + @Parameter(hidden = true) @Login UserDto user) throws IOException { + userService.updateUserProfileImage(user, userProfileImageRequestDto, profileImage); + return ResponseEntity.noContent().build(); + } } diff --git a/src/main/java/com/gg/server/domain/user/data/User.java b/src/main/java/com/gg/server/domain/user/data/User.java index fc4a3e4d4..68b77c36a 100644 --- a/src/main/java/com/gg/server/domain/user/data/User.java +++ b/src/main/java/com/gg/server/domain/user/data/User.java @@ -1,135 +1,150 @@ -package com.gg.server.domain.user.data; - -import com.gg.server.admin.user.dto.UserUpdateAdminRequestDto; -import com.gg.server.domain.item.exception.InsufficientGgcoinException; -import com.gg.server.domain.user.type.*; -import com.gg.server.global.utils.BaseTimeEntity; -import lombok.*; - -import javax.persistence.*; -import javax.validation.constraints.NotNull; -import java.io.Serializable; - -import org.hibernate.annotations.DynamicUpdate; - -@Entity -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@DynamicUpdate -public class User extends BaseTimeEntity implements Serializable { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @NotNull - @Column(name = "intra_id", length = 30) - private String intraId; - - @Column(name = "e_mail", length = 60) - private String eMail; - - @Column(name = "image_uri") - private String imageUri; - - @Enumerated(EnumType.STRING) - @Column(name = "racket_type", length = 10) - private RacketType racketType; - - @NotNull - @Enumerated(EnumType.STRING) - @Column(name = "role_type", length = 10) - private RoleType roleType; - - @Column(name = "total_exp") - private Integer totalExp; - - @Column(name = "sns_noti_opt", length = 10) - @Enumerated(EnumType.STRING) - private SnsType snsNotiOpt; - - @Column(name = "kakao_id") - private Long kakaoId; - - @Column(name = "gg_coin") - private Integer ggCoin; - - @Column(name = "background") - @Enumerated(EnumType.STRING) - private BackgroundType background; - - @Column(name = "text_color", length = 10) - private String textColor; - - @Column(name = "edge") - @Enumerated(EnumType.STRING) - private EdgeType edge; - - @Builder - public User(String intraId, String eMail, String imageUri, RacketType racketType, - RoleType roleType, Integer totalExp, SnsType snsNotiOpt, Long kakaoId) { - this.intraId = intraId; - this.eMail = eMail; - this.imageUri = imageUri; - this.racketType = racketType; - this.roleType = roleType; - this.totalExp = totalExp; - this.snsNotiOpt = snsNotiOpt; - this.kakaoId = kakaoId; - this.background = BackgroundType.BASIC; - this.textColor = "#000000"; - this.edge = EdgeType.BASIC; - this.ggCoin = 0; - } - - public void modifyUserDetail(UserUpdateAdminRequestDto updateReq) { - this.eMail = updateReq.getEmail(); - this.racketType = updateReq.getRacketType(); - this.roleType = RoleType.of(updateReq.getRoleType()); - this.ggCoin = updateReq.getCoin(); - } - - public void updateImageUri(String imageUri) { - this.imageUri = imageUri; - } - - public void updateTypes(RacketType racketType, SnsType snsType) { - this.racketType = racketType; - this.snsNotiOpt = snsType; - } - - public void addExp(int plus) { - this.totalExp += plus; - } - - public void updateExp(int beforeExp) { - this.totalExp = beforeExp; - } - - public void updateKakaoId(Long kakaoId) { - this.kakaoId = kakaoId; - } - - public void updateTextColor(String textColor) { - this.textColor = textColor; - } - - public void updateEdge(EdgeType edge) { - this.edge = edge; - } - - public int addGgCoin(int plus) { - this.ggCoin += plus; - return this.ggCoin; - } - - public void payGgCoin(int amount) { - if (this.ggCoin < amount) { - throw new InsufficientGgcoinException(); // 사용자의 ggCoin이 필요한 금액보다 적을 경우 예외를 발생 - } - this.ggCoin = this.ggCoin - amount; - } - - public void updateBackground(BackgroundType background) { - this.background = background; - } -} \ No newline at end of file +package com.gg.server.domain.user.data; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.validation.constraints.NotNull; + +import org.hibernate.annotations.DynamicUpdate; + +import com.gg.server.admin.user.dto.UserUpdateAdminRequestDto; +import com.gg.server.domain.item.exception.InsufficientGgcoinException; +import com.gg.server.domain.user.type.BackgroundType; +import com.gg.server.domain.user.type.EdgeType; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.global.utils.BaseTimeEntity; + +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@DynamicUpdate +public class User extends BaseTimeEntity implements Serializable { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull + @Column(name = "intra_id", length = 30) + private String intraId; + + @Column(name = "e_mail", length = 60) + private String eMail; + + @Column(name = "image_uri") + private String imageUri; + + @Enumerated(EnumType.STRING) + @Column(name = "racket_type", length = 10) + private RacketType racketType; + + @NotNull + @Enumerated(EnumType.STRING) + @Column(name = "role_type", length = 10) + private RoleType roleType; + + @Column(name = "total_exp") + private Integer totalExp; + + @Column(name = "sns_noti_opt", length = 10) + @Enumerated(EnumType.STRING) + private SnsType snsNotiOpt; + + @Column(name = "kakao_id") + private Long kakaoId; + + @Column(name = "gg_coin") + private Integer ggCoin; + + @Column(name = "background") + @Enumerated(EnumType.STRING) + private BackgroundType background; + + @Column(name = "text_color", length = 10) + private String textColor; + + @Column(name = "edge") + @Enumerated(EnumType.STRING) + private EdgeType edge; + + @Builder + public User(String intraId, String eMail, String imageUri, RacketType racketType, + RoleType roleType, Integer totalExp, SnsType snsNotiOpt, Long kakaoId) { + this.intraId = intraId; + this.eMail = eMail; + this.imageUri = imageUri; + this.racketType = racketType; + this.roleType = roleType; + this.totalExp = totalExp; + this.snsNotiOpt = snsNotiOpt; + this.kakaoId = kakaoId; + this.background = BackgroundType.BASIC; + this.textColor = "#000000"; + this.edge = EdgeType.BASIC; + this.ggCoin = 0; + } + + public void modifyUserDetail(UserUpdateAdminRequestDto updateReq) { + this.eMail = updateReq.getEmail(); + this.racketType = updateReq.getRacketType(); + this.roleType = RoleType.of(updateReq.getRoleType()); + this.ggCoin = updateReq.getCoin(); + } + + public void updateImageUri(String imageUri) { + this.imageUri = imageUri; + } + + public void updateTypes(RacketType racketType, SnsType snsType) { + this.racketType = racketType; + this.snsNotiOpt = snsType; + } + + public void addExp(int plus) { + this.totalExp += plus; + } + + public void updateExp(int beforeExp) { + this.totalExp = beforeExp; + } + + public void updateKakaoId(Long kakaoId) { + this.kakaoId = kakaoId; + } + + public void updateTextColor(String textColor) { + this.textColor = textColor; + } + + public void updateEdge(EdgeType edge) { + this.edge = edge; + } + + public int addGgCoin(int plus) { + this.ggCoin += plus; + return this.ggCoin; + } + + public void payGgCoin(int amount) { + if (this.ggCoin < amount) { + throw new InsufficientGgcoinException(); // 사용자의 ggCoin이 필요한 금액보다 적을 경우 예외를 발생 + } + this.ggCoin = this.ggCoin - amount; + } + + public void updateBackground(BackgroundType background) { + this.background = background; + } +} diff --git a/src/main/java/com/gg/server/domain/user/data/UserImage.java b/src/main/java/com/gg/server/domain/user/data/UserImage.java index 8cd0bf920..604441701 100644 --- a/src/main/java/com/gg/server/domain/user/data/UserImage.java +++ b/src/main/java/com/gg/server/domain/user/data/UserImage.java @@ -1,56 +1,65 @@ package com.gg.server.domain.user.data; +import java.time.LocalDateTime; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + import com.sun.istack.NotNull; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import javax.persistence.*; -import java.time.LocalDateTime; - @NoArgsConstructor @AllArgsConstructor @Entity @Getter public class UserImage { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - @NotNull - @Column(name = "image_uri") - private String imageUri; - - @NotNull - @Column(name = "created_at") - private LocalDateTime createdAt; - - @Column(name = "deleted_at") - private LocalDateTime deletedAt; - - @NotNull - @Column(name = "is_current") - private Boolean isCurrent; - - public UserImage(User user, String imageUri, LocalDateTime createdAt, LocalDateTime deletedAt, Boolean isCurrent) { - this.user = user; - this.imageUri = imageUri; - this.createdAt = createdAt; - this.deletedAt = deletedAt; - this.isCurrent = isCurrent; - } - - public void updateIsCurrent() { - this.isCurrent = !this.isCurrent; - } - - public void updateDeletedAt(LocalDateTime deletedAt) { - this.deletedAt = deletedAt; - updateIsCurrent(); - } -} \ No newline at end of file + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @NotNull + @Column(name = "image_uri") + private String imageUri; + + @NotNull + @Column(name = "created_at") + private LocalDateTime createdAt; + + @Column(name = "deleted_at") + private LocalDateTime deletedAt; + + @NotNull + @Column(name = "is_current") + private Boolean isCurrent; + + public UserImage(User user, String imageUri, LocalDateTime createdAt, LocalDateTime deletedAt, Boolean isCurrent) { + this.user = user; + this.imageUri = imageUri; + this.createdAt = createdAt; + this.deletedAt = deletedAt; + this.isCurrent = isCurrent; + } + + public void updateIsCurrent() { + this.isCurrent = !this.isCurrent; + } + + public void updateDeletedAt(LocalDateTime deletedAt) { + this.deletedAt = deletedAt; + updateIsCurrent(); + } +} diff --git a/src/main/java/com/gg/server/domain/user/data/UserImageRepository.java b/src/main/java/com/gg/server/domain/user/data/UserImageRepository.java index 660805a63..79a0538cd 100644 --- a/src/main/java/com/gg/server/domain/user/data/UserImageRepository.java +++ b/src/main/java/com/gg/server/domain/user/data/UserImageRepository.java @@ -1,9 +1,9 @@ package com.gg.server.domain.user.data; -import org.springframework.data.jpa.repository.JpaRepository; - import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; + public interface UserImageRepository extends JpaRepository { - Optional findTopByUserAndIsCurrentIsTrueOrderByIdDesc(User user); + Optional findTopByUserAndIsCurrentIsTrueOrderByIdDesc(User user); } diff --git a/src/main/java/com/gg/server/domain/user/data/UserRepository.java b/src/main/java/com/gg/server/domain/user/data/UserRepository.java index f6750bb6a..b497bd43d 100644 --- a/src/main/java/com/gg/server/domain/user/data/UserRepository.java +++ b/src/main/java/com/gg/server/domain/user/data/UserRepository.java @@ -1,51 +1,54 @@ -package com.gg.server.domain.user.data; - -import com.gg.server.domain.rank.dto.ExpRankV2Dto; -import java.util.List; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; - -import java.util.Optional; - -public interface UserRepository extends JpaRepository { - Optional findByIntraId(String intraId); - - Optional getUserByIntraId(String IntraId); - - Page findByIntraIdContains(Pageable pageable, String intraId); - - Page findAllByTotalExpGreaterThan(Pageable pageable, Integer exp); - - Optional findByKakaoId(Long kakaoId); - - @Query(nativeQuery = true, value = "select ranking from " + - "(select intra_id, row_number() over (order by total_exp desc, intra_id asc) as ranking from user) ranked where intra_id=:intraId") - Long findExpRankingByIntraId(@Param("intraId") String intraId); - Page findAll(Pageable pageable); - - @Query("select tu.user from User u, TeamUser tu, Team t, Game g" + - " where g.id=:gameId and t.game.id =g.id and tu.team.id = t.id " - + "and u.id = tu.user.id and u.id !=:userId") - List findEnemyByGameAndUser(@Param("gameId") Long gameId, @Param("userId") Long userId); - - List findUsersByIdIn(List userIds); - - @Modifying(clearAutomatically = true) - @Query("update User u set u.imageUri = :imageUri where u.id = :id") - void updateUserImage(Long id, String imageUri); - - @Query(value = "SELECT u.intra_id intraId, r.status_message statusMessage, u.total_exp totalExp, " - + "u.image_uri imageUri, u.text_color textColor, " - + "RANK() OVER(ORDER BY u.total_exp DESC, r.modified_at DESC, r.ppp DESC) ranking " - + "FROM User u LEFT JOIN Ranks r " - + "ON u.id = r.user_id " - + "WHERE r.season_id = :seasonId AND u.total_exp > 0 " - + "LIMIT :limit OFFSET :offset", nativeQuery = true) - List findExpRank(@Param("offset")int offset, @Param("limit")int limit, @Param("seasonId")Long seasonId); - -} +package com.gg.server.domain.user.data; + +import java.util.List; +import java.util.Optional; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +import com.gg.server.domain.rank.dto.ExpRankV2Dto; + +public interface UserRepository extends JpaRepository { + Optional findByIntraId(String intraId); + + Optional getUserByIntraId(String intraId); + + Page findByIntraIdContains(Pageable pageable, String intraId); + + Page findAllByTotalExpGreaterThan(Pageable pageable, Integer exp); + + Optional findByKakaoId(Long kakaoId); + + @Query(nativeQuery = true, value = "select ranking from " + + "(select intra_id, row_number() over (order by total_exp desc, intra_id asc) as ranking from user) ranked " + + "where intra_id=:intraId") + Long findExpRankingByIntraId(@Param("intraId") String intraId); + + Page findAll(Pageable pageable); + + @Query("select tu.user from User u, TeamUser tu, Team t, Game g" + + " where g.id=:gameId and t.game.id =g.id and tu.team.id = t.id " + + "and u.id = tu.user.id and u.id !=:userId") + List findEnemyByGameAndUser(@Param("gameId") Long gameId, @Param("userId") Long userId); + + List findUsersByIdIn(List userIds); + + @Modifying(clearAutomatically = true) + @Query("update User u set u.imageUri = :imageUri where u.id = :id") + void updateUserImage(Long id, String imageUri); + + @Query(value = "SELECT u.intra_id intraId, r.status_message statusMessage, u.total_exp totalExp, " + + "u.image_uri imageUri, u.text_color textColor, " + + "RANK() OVER(ORDER BY u.total_exp DESC, r.modified_at DESC, r.ppp DESC) ranking " + + "FROM User u LEFT JOIN Ranks r " + + "ON u.id = r.user_id " + + "WHERE r.season_id = :seasonId AND u.total_exp > 0 " + + "LIMIT :limit OFFSET :offset", nativeQuery = true) + List findExpRank(@Param("offset") int offset, @Param("limit") int limit, + @Param("seasonId") Long seasonId); + +} diff --git a/src/main/java/com/gg/server/domain/user/dto/CoinHistoryResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/CoinHistoryResponseDto.java index 74066fb9f..1f6b3024e 100644 --- a/src/main/java/com/gg/server/domain/user/dto/CoinHistoryResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/CoinHistoryResponseDto.java @@ -1,22 +1,22 @@ package com.gg.server.domain.user.dto; +import java.time.LocalDateTime; + import com.gg.server.domain.coin.data.CoinHistory; -import com.gg.server.domain.coin.data.CoinHistoryRepository; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; - @Getter @NoArgsConstructor public class CoinHistoryResponseDto { - private String history; - private int amount; - private LocalDateTime createdAt; + private String history; + private int amount; + private LocalDateTime createdAt; - public CoinHistoryResponseDto(CoinHistory coinHistory) { - this.history = coinHistory.getHistory(); - this.amount = coinHistory.getAmount(); - this.createdAt = coinHistory.getCreatedAt(); - } + public CoinHistoryResponseDto(CoinHistory coinHistory) { + this.history = coinHistory.getHistory(); + this.amount = coinHistory.getAmount(); + this.createdAt = coinHistory.getCreatedAt(); + } } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserAccessTokenDto.java b/src/main/java/com/gg/server/domain/user/dto/UserAccessTokenDto.java index ff4a79fb2..44a9d837a 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserAccessTokenDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserAccessTokenDto.java @@ -6,5 +6,5 @@ @AllArgsConstructor @Getter public class UserAccessTokenDto { - private String accessToken; + private String accessToken; } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserAttendanceResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/UserAttendanceResponseDto.java index c9f7b2ea6..878b7a0d5 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserAttendanceResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserAttendanceResponseDto.java @@ -8,7 +8,7 @@ @AllArgsConstructor @NoArgsConstructor public class UserAttendanceResponseDto { - private int beforeCoin; - private int afterCoin; - private int coinIncrement; + private int beforeCoin; + private int afterCoin; + private int coinIncrement; } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserBackgroundDto.java b/src/main/java/com/gg/server/domain/user/dto/UserBackgroundDto.java index 38065e6d8..8420de4ea 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserBackgroundDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserBackgroundDto.java @@ -1,15 +1,15 @@ -package com.gg.server.domain.user.dto; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; - -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class UserBackgroundDto { - @NotNull - private Long receiptId; -} +package com.gg.server.domain.user.dto; + +import javax.validation.constraints.NotNull; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class UserBackgroundDto { + @NotNull + private Long receiptId; +} diff --git a/src/main/java/com/gg/server/domain/user/dto/UserCoinHistoryListResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/UserCoinHistoryListResponseDto.java index 0c80b4a71..0cff36e9d 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserCoinHistoryListResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserCoinHistoryListResponseDto.java @@ -1,17 +1,15 @@ package com.gg.server.domain.user.dto; -import com.gg.server.admin.coin.dto.CoinPolicyAdminResponseDto; -import com.gg.server.domain.coin.data.CoinHistory; +import java.util.List; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @AllArgsConstructor @NoArgsConstructor @Getter public class UserCoinHistoryListResponseDto { - private List useCoinList; - private int totalPage; + private List useCoinList; + private int totalPage; } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserCoinResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/UserCoinResponseDto.java index fa5e130ad..9ce90ec28 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserCoinResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserCoinResponseDto.java @@ -6,9 +6,9 @@ @NoArgsConstructor @Getter public class UserCoinResponseDto { - private int coin; + private int coin; - public UserCoinResponseDto(int userCoin) { - this.coin = userCoin; - } + public UserCoinResponseDto(int userCoin) { + this.coin = userCoin; + } } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserDetailResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/UserDetailResponseDto.java index 1fb6b72ec..7379affcc 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserDetailResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserDetailResponseDto.java @@ -1,50 +1,53 @@ -package com.gg.server.domain.user.dto; - -import com.gg.server.domain.tier.data.Tier; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.BackgroundType; -import com.gg.server.domain.user.type.EdgeType; -import com.gg.server.domain.user.type.SnsType; -import com.gg.server.global.utils.ExpLevelCalculator; -import lombok.*; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class UserDetailResponseDto { - private String intraId; - private String userImageUri; - private String racketType; - private String statusMessage; - private Integer level; - private Integer currentExp; - private Integer maxExp; - private Double expRate; - private SnsType snsNotiOpt; - private BackgroundType background; - private String textColor; - private EdgeType edge; - private String tierName; - private String tierImageUri; - - public UserDetailResponseDto(User user, String statusMessage, Tier tier) { - this.intraId = user.getIntraId(); - this.racketType = user.getRacketType().getCode(); - this.userImageUri = user.getImageUri(); - this.statusMessage = statusMessage; - this.snsNotiOpt = user.getSnsNotiOpt(); - this.background= user.getBackground(); - this.textColor = user.getTextColor(); - this.edge = user.getEdge(); - this.tierName = tier.getName(); - this.tierImageUri = tier.getImageUri(); - calculateExpAndLevel(user); - } - - private void calculateExpAndLevel(User user) { - this.currentExp = ExpLevelCalculator.getCurrentLevelMyExp(user.getTotalExp()); - this.maxExp = ExpLevelCalculator.getLevelMaxExp(ExpLevelCalculator.getLevel(user.getTotalExp())); - this.level = ExpLevelCalculator.getLevel(user.getTotalExp()); - this.expRate = (double)(currentExp * 10000 / maxExp) / 100; - } - -} +package com.gg.server.domain.user.dto; + +import com.gg.server.domain.tier.data.Tier; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.type.BackgroundType; +import com.gg.server.domain.user.type.EdgeType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.global.utils.ExpLevelCalculator; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class UserDetailResponseDto { + private String intraId; + private String userImageUri; + private String racketType; + private String statusMessage; + private Integer level; + private Integer currentExp; + private Integer maxExp; + private Double expRate; + private SnsType snsNotiOpt; + private BackgroundType background; + private String textColor; + private EdgeType edge; + private String tierName; + private String tierImageUri; + + public UserDetailResponseDto(User user, String statusMessage, Tier tier) { + this.intraId = user.getIntraId(); + this.racketType = user.getRacketType().getCode(); + this.userImageUri = user.getImageUri(); + this.statusMessage = statusMessage; + this.snsNotiOpt = user.getSnsNotiOpt(); + this.background = user.getBackground(); + this.textColor = user.getTextColor(); + this.edge = user.getEdge(); + this.tierName = tier.getName(); + this.tierImageUri = tier.getImageUri(); + calculateExpAndLevel(user); + } + + private void calculateExpAndLevel(User user) { + this.currentExp = ExpLevelCalculator.getCurrentLevelMyExp(user.getTotalExp()); + this.maxExp = ExpLevelCalculator.getLevelMaxExp(ExpLevelCalculator.getLevel(user.getTotalExp())); + this.level = ExpLevelCalculator.getLevel(user.getTotalExp()); + this.expRate = (double)(currentExp * 10000 / maxExp) / 100; + } + +} diff --git a/src/main/java/com/gg/server/domain/user/dto/UserDto.java b/src/main/java/com/gg/server/domain/user/dto/UserDto.java index 393aeaa6a..d87ac08b5 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserDto.java @@ -1,57 +1,58 @@ -package com.gg.server.domain.user.dto; - -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; -import lombok.Builder; -import lombok.Getter; - -@Getter -@Builder -public class UserDto { - private Long id; - private String intraId; - private String eMail; - private RacketType racketType; - private RoleType roleType; - private Integer totalExp; - private SnsType snsNotiOpt; - private Long kakaoId; - private String textColor; - private Integer ggCoin; - - static public UserDto from (User user) { - UserDto userDto; - if (user == null) { - userDto = null; - } else { - userDto = UserDto.builder() - .id(user.getId()) - .intraId(user.getIntraId()) - .eMail(user.getEMail()) - .racketType(user.getRacketType()) - .roleType(user.getRoleType()) - .totalExp(user.getTotalExp()) - .snsNotiOpt(user.getSnsNotiOpt()) - .kakaoId(user.getKakaoId()) - .ggCoin(user.getGgCoin()) - .build(); - } - return userDto; - } - - @Override - public String toString() { - return "UserDto{" + - "id=" + id + - ", intraId='" + intraId + '\'' + - ", eMail='" + eMail + '\'' + - ", racketType=" + racketType + - ", roleType=" + roleType + - ", totalExp=" + totalExp + - ", snsNotiOpt=" + snsNotiOpt + - ", kakaoId=" + kakaoId + - '}'; - } -} +package com.gg.server.domain.user.dto; + +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class UserDto { + private Long id; + private String intraId; + private String eMail; + private RacketType racketType; + private RoleType roleType; + private Integer totalExp; + private SnsType snsNotiOpt; + private Long kakaoId; + private String textColor; + private Integer ggCoin; + + public static UserDto from(User user) { + UserDto userDto; + if (user == null) { + userDto = null; + } else { + userDto = UserDto.builder() + .id(user.getId()) + .intraId(user.getIntraId()) + .eMail(user.getEMail()) + .racketType(user.getRacketType()) + .roleType(user.getRoleType()) + .totalExp(user.getTotalExp()) + .snsNotiOpt(user.getSnsNotiOpt()) + .kakaoId(user.getKakaoId()) + .ggCoin(user.getGgCoin()) + .build(); + } + return userDto; + } + + @Override + public String toString() { + return "UserDto{" + + "id=" + id + + ", intraId='" + intraId + '\'' + + ", eMail='" + eMail + '\'' + + ", racketType=" + racketType + + ", roleType=" + roleType + + ", totalExp=" + totalExp + + ", snsNotiOpt=" + snsNotiOpt + + ", kakaoId=" + kakaoId + + '}'; + } +} diff --git a/src/main/java/com/gg/server/domain/user/dto/UserEdgeDto.java b/src/main/java/com/gg/server/domain/user/dto/UserEdgeDto.java index e333aed27..be6be50be 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserEdgeDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserEdgeDto.java @@ -1,15 +1,15 @@ -package com.gg.server.domain.user.dto; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotNull; - -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class UserEdgeDto { - @NotNull - private Long receiptId; -} +package com.gg.server.domain.user.dto; + +import javax.validation.constraints.NotNull; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class UserEdgeDto { + @NotNull + private Long receiptId; +} diff --git a/src/main/java/com/gg/server/domain/user/dto/UserHistoryData.java b/src/main/java/com/gg/server/domain/user/dto/UserHistoryData.java index 26e3587fc..1161d0223 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserHistoryData.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserHistoryData.java @@ -1,19 +1,20 @@ package com.gg.server.domain.user.dto; +import java.time.LocalDateTime; + import com.gg.server.domain.pchange.data.PChange; + import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDateTime; - @Getter @NoArgsConstructor public class UserHistoryData { - private int ppp; - private LocalDateTime date; + private int ppp; + private LocalDateTime date; - public UserHistoryData(PChange pChange){ - this.ppp = pChange.getPppResult(); - this.date = pChange.getCreatedAt(); - } + public UserHistoryData(PChange pChange) { + this.ppp = pChange.getPppResult(); + this.date = pChange.getCreatedAt(); + } } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserHistoryResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/UserHistoryResponseDto.java index 4df716096..792ec9e76 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserHistoryResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserHistoryResponseDto.java @@ -1,14 +1,14 @@ package com.gg.server.domain.user.dto; +import java.util.List; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @AllArgsConstructor @NoArgsConstructor @Getter public class UserHistoryResponseDto { - private List historics; + private List historics; } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserImageDto.java b/src/main/java/com/gg/server/domain/user/dto/UserImageDto.java index 19762a1df..4796d2efd 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserImageDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserImageDto.java @@ -2,31 +2,27 @@ import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.type.EdgeType; -import lombok.AllArgsConstructor; + import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.ToString; - -import java.time.LocalDateTime; - @Getter @NoArgsConstructor public class UserImageDto { - private String intraId; - private String imageUri; - private EdgeType edge; - private String tierImage; + private String intraId; + private String imageUri; + private EdgeType edge; + private String tierImage; - public UserImageDto(String intraId, String imageUri, EdgeType edge, String tierImage) { - this.intraId = intraId; - this.imageUri = imageUri; - this.edge = edge; - this.tierImage = tierImage; - } + public UserImageDto(String intraId, String imageUri, EdgeType edge, String tierImage) { + this.intraId = intraId; + this.imageUri = imageUri; + this.edge = edge; + this.tierImage = tierImage; + } - public UserImageDto(User user){ - this.intraId = (user == null)? null : user.getIntraId(); - this.imageUri = (user == null)? null : user.getImageUri(); - } + public UserImageDto(User user) { + this.intraId = (user == null) ? null : user.getIntraId(); + this.imageUri = (user == null) ? null : user.getImageUri(); + } } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserImageResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/UserImageResponseDto.java index dc5f46628..f12164c40 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserImageResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserImageResponseDto.java @@ -1,15 +1,15 @@ package com.gg.server.domain.user.dto; +import java.util.List; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @Getter @NoArgsConstructor @AllArgsConstructor public class UserImageResponseDto { - List userImages; + List userImages; } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserLiveResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/UserLiveResponseDto.java index 906ffe54f..6aa8a0c59 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserLiveResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserLiveResponseDto.java @@ -1,6 +1,7 @@ package com.gg.server.domain.user.dto; import com.gg.server.domain.game.type.Mode; + import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -10,8 +11,8 @@ @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) public class UserLiveResponseDto { - private int notiCount; - private String event; - private Mode currentMatchMode; - private Long gameId; + private int notiCount; + private String event; + private Mode currentMatchMode; + private Long gameId; } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserModifyRequestDto.java b/src/main/java/com/gg/server/domain/user/dto/UserModifyRequestDto.java index 0cac21747..3e140a02b 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserModifyRequestDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserModifyRequestDto.java @@ -2,6 +2,7 @@ import com.gg.server.domain.user.type.RacketType; import com.gg.server.domain.user.type.SnsType; + import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -12,7 +13,7 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class UserModifyRequestDto { - private RacketType racketType; - private String statusMessage; - private SnsType snsNotiOpt; + private RacketType racketType; + private String statusMessage; + private SnsType snsNotiOpt; } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserNormalDetailResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/UserNormalDetailResponseDto.java index 259c3db39..32c13a1d7 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserNormalDetailResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserNormalDetailResponseDto.java @@ -1,6 +1,7 @@ package com.gg.server.domain.user.dto; import com.gg.server.domain.user.type.EdgeType; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -9,12 +10,12 @@ @AllArgsConstructor @NoArgsConstructor public class UserNormalDetailResponseDto { - private String intraId; - private String userImageUri; - private Boolean isAdmin; - private Boolean isAttended; - private EdgeType edgeType; - private String tierName; - private String tierImageUri; - private Integer level; + private String intraId; + private String userImageUri; + private Boolean isAdmin; + private Boolean isAttended; + private EdgeType edgeType; + private String tierName; + private String tierImageUri; + private Integer level; } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserOauthDto.java b/src/main/java/com/gg/server/domain/user/dto/UserOauthDto.java index c48286706..a9c84dd98 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserOauthDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserOauthDto.java @@ -1,12 +1,10 @@ package com.gg.server.domain.user.dto; -import com.gg.server.domain.user.type.OauthType; -import com.gg.server.domain.user.type.RoleType; import lombok.AllArgsConstructor; import lombok.Getter; @AllArgsConstructor @Getter public class UserOauthDto { - private String oauthType; + private String oauthType; } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserProfileImageRequestDto.java b/src/main/java/com/gg/server/domain/user/dto/UserProfileImageRequestDto.java index 7666b2afe..603d80690 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserProfileImageRequestDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserProfileImageRequestDto.java @@ -1,15 +1,15 @@ package com.gg.server.domain.user.dto; +import javax.validation.constraints.NotNull; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotNull; - @Getter @AllArgsConstructor @NoArgsConstructor public class UserProfileImageRequestDto { - @NotNull - private Long receiptId; + @NotNull + private Long receiptId; } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserRankResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/UserRankResponseDto.java index 3baa2b8fe..7e421e67a 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserRankResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserRankResponseDto.java @@ -11,9 +11,9 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @ToString public class UserRankResponseDto { - private int rank; - private int ppp; - private int wins; - private int losses; - private double winRate; + private int rank; + private int ppp; + private int wins; + private int losses; + private double winRate; } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserSearchResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/UserSearchResponseDto.java index f604fed73..a6e1b31d3 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserSearchResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserSearchResponseDto.java @@ -1,14 +1,14 @@ package com.gg.server.domain.user.dto; +import java.util.List; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.List; - @Getter @AllArgsConstructor @NoArgsConstructor public class UserSearchResponseDto { - private List users; + private List users; } diff --git a/src/main/java/com/gg/server/domain/user/dto/UserTextColorDto.java b/src/main/java/com/gg/server/domain/user/dto/UserTextColorDto.java index 3629792c2..32e93061f 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserTextColorDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserTextColorDto.java @@ -1,16 +1,17 @@ -package com.gg.server.domain.user.dto; - -import com.sun.istack.NotNull; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor -@AllArgsConstructor -public class UserTextColorDto { - @NotNull - private Long receiptId; - @NotNull - private String textColor; -} +package com.gg.server.domain.user.dto; + +import com.sun.istack.NotNull; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class UserTextColorDto { + @NotNull + private Long receiptId; + @NotNull + private String textColor; +} diff --git a/src/main/java/com/gg/server/domain/user/exception/KakaoOauth2AlreadyExistException.java b/src/main/java/com/gg/server/domain/user/exception/KakaoOauth2AlreadyExistException.java index 1fe3bfb2c..030bf0d1d 100644 --- a/src/main/java/com/gg/server/domain/user/exception/KakaoOauth2AlreadyExistException.java +++ b/src/main/java/com/gg/server/domain/user/exception/KakaoOauth2AlreadyExistException.java @@ -2,10 +2,9 @@ import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.InvalidParameterException; -import com.gg.server.global.exception.custom.NotExistException; public class KakaoOauth2AlreadyExistException extends InvalidParameterException { - public KakaoOauth2AlreadyExistException() { - super("kakao user already exists", ErrorCode.KAKAO_OAUTH2_DUPLICATE); - } + public KakaoOauth2AlreadyExistException() { + super("kakao user already exists", ErrorCode.KAKAO_OAUTH2_DUPLICATE); + } } diff --git a/src/main/java/com/gg/server/domain/user/exception/KakaoOauth2NotFoundException.java b/src/main/java/com/gg/server/domain/user/exception/KakaoOauth2NotFoundException.java index bd53b5ba5..7f838e05d 100644 --- a/src/main/java/com/gg/server/domain/user/exception/KakaoOauth2NotFoundException.java +++ b/src/main/java/com/gg/server/domain/user/exception/KakaoOauth2NotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class KakaoOauth2NotFoundException extends NotExistException { - public KakaoOauth2NotFoundException() { - super("Kakao oauth2 is not found", ErrorCode.KAKAO_OAUTH2_NOT_FOUND); - } + public KakaoOauth2NotFoundException() { + super("Kakao oauth2 is not found", ErrorCode.KAKAO_OAUTH2_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/user/exception/TokenNotValidException.java b/src/main/java/com/gg/server/domain/user/exception/TokenNotValidException.java index 29f9cb4f3..680283d55 100644 --- a/src/main/java/com/gg/server/domain/user/exception/TokenNotValidException.java +++ b/src/main/java/com/gg/server/domain/user/exception/TokenNotValidException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.AuthenticationException; public class TokenNotValidException extends AuthenticationException { - public TokenNotValidException() { - super("Authentication error", ErrorCode.UNAUTHORIZED); - } + public TokenNotValidException() { + super("Authentication error", ErrorCode.UNAUTHORIZED); + } } diff --git a/src/main/java/com/gg/server/domain/user/exception/UserAlreadyAttendanceException.java b/src/main/java/com/gg/server/domain/user/exception/UserAlreadyAttendanceException.java index 3e3ce132e..897187efd 100644 --- a/src/main/java/com/gg/server/domain/user/exception/UserAlreadyAttendanceException.java +++ b/src/main/java/com/gg/server/domain/user/exception/UserAlreadyAttendanceException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.DuplicationException; public class UserAlreadyAttendanceException extends DuplicationException { - public UserAlreadyAttendanceException() { - super("이미 출석한 유저입니다.", ErrorCode.USER_ALREADY_ATTENDANCE); - } + public UserAlreadyAttendanceException() { + super("이미 출석한 유저입니다.", ErrorCode.USER_ALREADY_ATTENDANCE); + } } diff --git a/src/main/java/com/gg/server/domain/user/exception/UserImageLargeException.java b/src/main/java/com/gg/server/domain/user/exception/UserImageLargeException.java index fa68d2f27..47549630b 100644 --- a/src/main/java/com/gg/server/domain/user/exception/UserImageLargeException.java +++ b/src/main/java/com/gg/server/domain/user/exception/UserImageLargeException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.FileException; public class UserImageLargeException extends FileException { - public UserImageLargeException() { - super("이미지 파일 50KB 초과", ErrorCode.USER_IMAGE_TOO_LARGE); - } + public UserImageLargeException() { + super("이미지 파일 50KB 초과", ErrorCode.USER_IMAGE_TOO_LARGE); + } } diff --git a/src/main/java/com/gg/server/domain/user/exception/UserImageNullException.java b/src/main/java/com/gg/server/domain/user/exception/UserImageNullException.java index b7e8b8598..3ee71b583 100644 --- a/src/main/java/com/gg/server/domain/user/exception/UserImageNullException.java +++ b/src/main/java/com/gg/server/domain/user/exception/UserImageNullException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.FileException; public class UserImageNullException extends FileException { - public UserImageNullException() { - super("이미지 파일이 없습니다.", ErrorCode.USER_IMAGE_NOT_FOUND); - } + public UserImageNullException() { + super("이미지 파일이 없습니다.", ErrorCode.USER_IMAGE_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/user/exception/UserImageTypeException.java b/src/main/java/com/gg/server/domain/user/exception/UserImageTypeException.java index 328cf4d42..dc705942a 100644 --- a/src/main/java/com/gg/server/domain/user/exception/UserImageTypeException.java +++ b/src/main/java/com/gg/server/domain/user/exception/UserImageTypeException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.FileException; public class UserImageTypeException extends FileException { - public UserImageTypeException() { - super("이미지 타입이 올바르지 않습니다", ErrorCode.USER_IMAGE_WRONG_TYPE); - } + public UserImageTypeException() { + super("이미지 타입이 올바르지 않습니다", ErrorCode.USER_IMAGE_WRONG_TYPE); + } } diff --git a/src/main/java/com/gg/server/domain/user/exception/UserNotFoundException.java b/src/main/java/com/gg/server/domain/user/exception/UserNotFoundException.java index 5748340d7..d66034161 100644 --- a/src/main/java/com/gg/server/domain/user/exception/UserNotFoundException.java +++ b/src/main/java/com/gg/server/domain/user/exception/UserNotFoundException.java @@ -4,7 +4,7 @@ import com.gg.server.global.exception.custom.NotExistException; public class UserNotFoundException extends NotExistException { - public UserNotFoundException() { - super("해당 유저가 없습니다.", ErrorCode.USER_NOT_FOUND); - } + public UserNotFoundException() { + super("해당 유저가 없습니다.", ErrorCode.USER_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/domain/user/exception/UserTextColorException.java b/src/main/java/com/gg/server/domain/user/exception/UserTextColorException.java index c1c40abea..49e846ed8 100644 --- a/src/main/java/com/gg/server/domain/user/exception/UserTextColorException.java +++ b/src/main/java/com/gg/server/domain/user/exception/UserTextColorException.java @@ -1,10 +1,10 @@ -package com.gg.server.domain.user.exception; - -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.CustomRuntimeException; - -public class UserTextColorException extends CustomRuntimeException { - public UserTextColorException() { - super("user text color code is not valid", ErrorCode.USER_TEXT_COLOR_WRONG_TYPE); - } -} +package com.gg.server.domain.user.exception; + +import com.gg.server.global.exception.ErrorCode; +import com.gg.server.global.exception.custom.CustomRuntimeException; + +public class UserTextColorException extends CustomRuntimeException { + public UserTextColorException() { + super("user text color code is not valid", ErrorCode.USER_TEXT_COLOR_WRONG_TYPE); + } +} diff --git a/src/main/java/com/gg/server/domain/user/service/UserAuthenticationService.java b/src/main/java/com/gg/server/domain/user/service/UserAuthenticationService.java index b30a7aa58..9010b08a1 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserAuthenticationService.java +++ b/src/main/java/com/gg/server/domain/user/service/UserAuthenticationService.java @@ -1,21 +1,24 @@ package com.gg.server.domain.user.service; +import org.springframework.stereotype.Service; + import com.gg.server.domain.user.exception.TokenNotValidException; import com.gg.server.global.security.jwt.repository.JwtRedisRepository; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; + import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class UserAuthenticationService { - private final JwtRedisRepository jwtRedisRepository; - private final AuthTokenProvider tokenProvider; + private final JwtRedisRepository jwtRedisRepository; + private final AuthTokenProvider tokenProvider; - public String regenerate(String refreshToken) { - Long userId = jwtRedisRepository.getUserIdFromRefToken(refreshToken); - if (userId == null) - throw new TokenNotValidException(); - return tokenProvider.createToken(userId); - } + public String regenerate(String refreshToken) { + Long userId = jwtRedisRepository.getUserIdFromRefToken(refreshToken); + if (userId == null) { + throw new TokenNotValidException(); + } + return tokenProvider.createToken(userId); + } } diff --git a/src/main/java/com/gg/server/domain/user/service/UserCoinService.java b/src/main/java/com/gg/server/domain/user/service/UserCoinService.java index 58fcf7407..5ab77b438 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserCoinService.java +++ b/src/main/java/com/gg/server/domain/user/service/UserCoinService.java @@ -1,45 +1,44 @@ package com.gg.server.domain.user.service; -import com.gg.server.admin.feedback.dto.FeedbackAdminResponseDto; -import com.gg.server.admin.feedback.dto.FeedbackListAdminResponseDto; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.domain.coin.data.CoinHistory; import com.gg.server.domain.coin.data.CoinHistoryRepository; -import com.gg.server.domain.feedback.data.Feedback; import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.CoinHistoryResponseDto; import com.gg.server.domain.user.dto.UserCoinHistoryListResponseDto; import com.gg.server.domain.user.dto.UserCoinResponseDto; -import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; + import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @RequiredArgsConstructor @Service public class UserCoinService { - private final UserRepository userRepository; - private final CoinHistoryRepository coinHistoryRepository; + private final UserRepository userRepository; + private final CoinHistoryRepository coinHistoryRepository; - @Transactional(readOnly = true) - public UserCoinResponseDto getUserCoin(String intraId) { - int userCoin = userRepository.findByIntraId(intraId).orElseThrow(() -> new UserNotFoundException()).getGgCoin(); + @Transactional(readOnly = true) + public UserCoinResponseDto getUserCoin(String intraId) { + int userCoin = userRepository.findByIntraId(intraId).orElseThrow(() -> new UserNotFoundException()).getGgCoin(); - return new UserCoinResponseDto(userCoin); - } + return new UserCoinResponseDto(userCoin); + } - @Transactional(readOnly = true) - public UserCoinHistoryListResponseDto getUserCoinHistory(Pageable pageable, String intraId) { - User user = userRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); + @Transactional(readOnly = true) + public UserCoinHistoryListResponseDto getUserCoinHistory(Pageable pageable, String intraId) { + User user = userRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); - Page coinHistories = coinHistoryRepository.findAllByUserOrderByIdDesc(user, pageable); - Page coinHistoryResponseDtos = coinHistories.map(CoinHistoryResponseDto::new); - UserCoinHistoryListResponseDto responseDto = new UserCoinHistoryListResponseDto(coinHistoryResponseDtos.getContent(), - coinHistoryResponseDtos.getTotalPages()); + Page coinHistories = coinHistoryRepository.findAllByUserOrderByIdDesc(user, pageable); + Page coinHistoryResponseDtos = coinHistories.map(CoinHistoryResponseDto::new); + UserCoinHistoryListResponseDto responseDto = new UserCoinHistoryListResponseDto( + coinHistoryResponseDtos.getContent(), + coinHistoryResponseDtos.getTotalPages()); - return responseDto; - } + return responseDto; + } } diff --git a/src/main/java/com/gg/server/domain/user/service/UserFindService.java b/src/main/java/com/gg/server/domain/user/service/UserFindService.java index 59515de0f..e2f2e042e 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserFindService.java +++ b/src/main/java/com/gg/server/domain/user/service/UserFindService.java @@ -1,46 +1,48 @@ -package com.gg.server.domain.user.service; - -import com.gg.server.domain.rank.exception.RedisDataNotFoundException; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.exception.UserNotFoundException; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; - -@Service -@RequiredArgsConstructor -public class UserFindService { - private final UserRepository userRepository; - private final SeasonFindService seasonFindService; - private final RankRedisRepository rankRedisRepository; - - @Transactional(readOnly = true) - public User findUserById(Long userId) { - return userRepository.findById(userId).orElseThrow(UserNotFoundException::new); - } - - @Transactional(readOnly = true) - public User findByIntraId(String intraId){ - return userRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); - } - - @Transactional(readOnly = true) - public String getUserStatusMessage(User targetUser) { - Season currentSeason = seasonFindService.findCurrentSeason(LocalDateTime.now()); - String hashKey = RedisKeyManager.getHashKey(currentSeason.getId()); - try{ - RankRedis userRank = rankRedisRepository.findRankByUserId(hashKey, targetUser.getId()); - return userRank.getStatusMessage(); - }catch (RedisDataNotFoundException e){ - return ""; - } - } -} +package com.gg.server.domain.user.service; + +import java.time.LocalDateTime; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.domain.rank.exception.RedisDataNotFoundException; +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.rank.redis.RedisKeyManager; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.service.SeasonFindService; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.exception.UserNotFoundException; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class UserFindService { + private final UserRepository userRepository; + private final SeasonFindService seasonFindService; + private final RankRedisRepository rankRedisRepository; + + @Transactional(readOnly = true) + public User findUserById(Long userId) { + return userRepository.findById(userId).orElseThrow(UserNotFoundException::new); + } + + @Transactional(readOnly = true) + public User findByIntraId(String intraId) { + return userRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); + } + + @Transactional(readOnly = true) + public String getUserStatusMessage(User targetUser) { + Season currentSeason = seasonFindService.findCurrentSeason(LocalDateTime.now()); + String hashKey = RedisKeyManager.getHashKey(currentSeason.getId()); + try { + RankRedis userRank = rankRedisRepository.findRankByUserId(hashKey, targetUser.getId()); + return userRank.getStatusMessage(); + } catch (RedisDataNotFoundException e) { + return ""; + } + } +} diff --git a/src/main/java/com/gg/server/domain/user/service/UserService.java b/src/main/java/com/gg/server/domain/user/service/UserService.java index 619dec023..702881e57 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserService.java +++ b/src/main/java/com/gg/server/domain/user/service/UserService.java @@ -1,356 +1,399 @@ -package com.gg.server.domain.user.service; - -import com.gg.server.domain.coin.service.CoinHistoryService; -import com.gg.server.domain.coin.service.UserCoinChangeService; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.item.service.ItemService; -import com.gg.server.domain.item.type.ItemType; -import com.gg.server.domain.match.data.RedisMatchUserRepository; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.pchange.data.PChange; -import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.pchange.exception.PChangeNotExistException; -import com.gg.server.domain.rank.data.Rank; -import com.gg.server.domain.rank.exception.RankNotFoundException; -import com.gg.server.domain.rank.exception.RedisDataNotFoundException; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.rank.service.RankFindService; -import com.gg.server.domain.receipt.data.Receipt; -import com.gg.server.domain.receipt.data.ReceiptRepository; -import com.gg.server.domain.receipt.exception.ReceiptNotFoundException; -import com.gg.server.domain.receipt.type.ItemStatus; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.tier.data.Tier; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserImage; -import com.gg.server.domain.user.data.UserImageRepository; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.*; -import com.gg.server.domain.user.exception.*; -import com.gg.server.domain.user.type.*; -import com.gg.server.global.utils.aws.AsyncNewUserImageUploader; -import com.gg.server.global.utils.ExpLevelCalculator; -import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -@Service -@RequiredArgsConstructor -public class UserService { - - private final UserFindService userFindService; - private final UserRepository userRepository; - private final NotiRepository notiRepository; - private final GameRepository gameRepository; - private final RankRedisRepository rankRedisRepository; - private final SeasonFindService seasonFindService; - private final PChangeRepository pChangeRepository; - private final RankFindService rankFindService; - private final RedisMatchUserRepository redisMatchUserRepository; - private final UserCoinChangeService userCoinChangeService; - private final CoinHistoryService coinHistoryService; - private final ReceiptRepository receiptRepository; - private final AsyncNewUserImageUploader asyncNewUserImageUploader; - private final UserImageRepository userImageRepository; - private final ItemService itemService; - private final TierRepository tierRepository; - - /** - * @param intraId - * @return intraId가 포함된 유저들의 intraId를 페이징 관계없이 최대 5개까지 검색하여 List로 return - */ - @Transactional(readOnly = true) - public List findByPartOfIntraId(String intraId) { - Pageable pageable = PageRequest.of(0, 5, Sort.by("intraId").ascending()); - Page pageUsers = userRepository.findByIntraIdContains(pageable, intraId); - return pageUsers.getContent().stream().map(user -> user.getIntraId()) - .collect(Collectors.toList()); - } - - /** - * @param user - event: - * - null → 로그인 유저가 잡힌 매칭이 하나도 없을 때 - * - match → 매칭은 되었으나 게임시작 전일 때 or 매칭중인 경우 - * - game → 유저가 게임이 잡혔고 현재 게임중인 경우 - *

- * - currentMatchMode - * - normal - * - rank - * - null -> 매칭이 안잡혔을 때 or 게임 전 - */ - @Transactional() - public UserLiveResponseDto getUserLiveDetail(UserDto user) { - int notiCnt = notiRepository.countNotCheckedNotiByUser(user.getId()); - Optional optionalGame = gameRepository.getLatestGameByUser(user.getId()); - int userMatchCnt = redisMatchUserRepository.countMatchTime(user.getId()); - if (optionalGame.isPresent()) { - Game game = optionalGame.get(); - if (game.getStatus() == StatusType.LIVE || game.getStatus() == StatusType.WAIT) - return new UserLiveResponseDto(notiCnt, "game", game.getMode(), game.getId()); - else if (game.getStatus() == StatusType.END) { - PChange userPChange = pChangeRepository.findPChangeByUserIdAndGameId(user.getId(), game.getId()).orElseThrow(() -> new PChangeNotExistException()); - if (!userPChange.getIsChecked()) { - userPChange.checkPChange(); - return new UserLiveResponseDto(notiCnt, "game", game.getMode(), game.getId()); - } - } - - if (game.getStatus() == StatusType.BEFORE) - return new UserLiveResponseDto(notiCnt, "match", null, null); - } - if (userMatchCnt > 0) { - return new UserLiveResponseDto(notiCnt, "match", null, null); - } - return new UserLiveResponseDto(notiCnt, null, null, null); - } - - @Transactional(readOnly = true) - public UserDetailResponseDto getUserDetail(String targetUserIntraId) { - User targetUser = userFindService.findByIntraId(targetUserIntraId); - String statusMessage = userFindService.getUserStatusMessage(targetUser); - Tier tier; - try{ - tier = rankFindService.findByUserIdAndSeasonId(targetUser.getId(), seasonFindService.findCurrentSeason(LocalDateTime.now()).getId()).getTier(); - } catch (RankNotFoundException e) { - tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); - } - return new UserDetailResponseDto(targetUser, statusMessage, tier); - } - - @Transactional - public void updateUser(RacketType racketType, String statusMessage, SnsType snsNotiOpt, String intraId) { - User user = userFindService.findByIntraId(intraId); - Season currentSeason = seasonFindService.findCurrentSeason(LocalDateTime.now()); - updateRedisRankStatusMessage(statusMessage, user, currentSeason); - updateRankTableStatusMessage(user.getId(), statusMessage, currentSeason.getId()); - user.updateTypes(racketType, snsNotiOpt); - } - - private void updateRankTableStatusMessage(Long userId, String statusMessage, Long seasonId) { - Rank rank = rankFindService.findByUserIdAndSeasonId(userId, seasonId); - rank.setStatusMessage(statusMessage); - } - - private void updateRedisRankStatusMessage(String statusMessage, User user, Season currentSeason) { - String hashKey = RedisKeyManager.getHashKey(currentSeason.getId()); - - RankRedis userRank = rankRedisRepository.findRankByUserId(hashKey, user.getId()); - userRank.setStatusMessage(statusMessage); - rankRedisRepository.updateRankData(hashKey, user.getId(), userRank); - } - - /** - * @param intraId - * @param seasonId seasonId == 0 -> current season, else -> 해당 Id를 가진 season의 데이터 - *

- * 기존 쿼리 - * @return 유저의 최근 10개의 랭크 경기 기록 - * @Query(nativeQuery = true, value = "SELECT * FROM pchange " + - * "where game_id in (SELECT id FROM game where season = :season and mode = :mode ) " + - * "AND user_id = :intraId ORDER BY id Desc limit :limit") - * -> Limit에는 10이 기본으로 들어감 - */ - @Transactional(readOnly = true) - public UserHistoryResponseDto getUserHistory(String intraId, Long seasonId) { - Season season; - if (seasonId == 0) { - season = seasonFindService.findCurrentSeason(LocalDateTime.now()); - } else { - season = seasonFindService.findSeasonById(seasonId); - } - List pChanges = pChangeRepository.findPChangesHistory(intraId, season.getId()); - List historyData = pChanges.stream().map(UserHistoryData::new).collect(Collectors.toList()); - Collections.reverse(historyData); - return new UserHistoryResponseDto(historyData); - } - - /** - * @param targetUserIntraId - * @param seasonId seasonId == 0 -> current season, else -> 해당 Id를 가진 season의 데이터 - * @return - */ - @Transactional(readOnly = true) - public UserRankResponseDto getUserRankDetail(String targetUserIntraId, Long seasonId) { - Season season; - if (seasonId == 0) { - season = seasonFindService.findCurrentSeason(LocalDateTime.now()); - } else { - season = seasonFindService.findSeasonById(seasonId); - } - String ZSetKey = RedisKeyManager.getZSetKey(season.getId()); - String hashKey = RedisKeyManager.getHashKey(season.getId()); - User user = userFindService.findByIntraId(targetUserIntraId); - try { - Long userRanking = rankRedisRepository.getRankInZSet(ZSetKey, user.getId()); - userRanking += 1; - RankRedis userRank = rankRedisRepository.findRankByUserId(hashKey, user.getId()); - double winRate = (double) (userRank.getWins() * 10000 / (userRank.getWins() + userRank.getLosses())) / 100; - return new UserRankResponseDto(userRanking.intValue(), userRank.getPpp(), userRank.getWins(), userRank.getLosses(), winRate); - } catch (RedisDataNotFoundException ex) { - return new UserRankResponseDto(-1, season.getStartPpp(), 0, 0, 0); - } catch (ArithmeticException ex2) { - return new UserRankResponseDto(-1, season.getStartPpp(), 0, 0, 0); - } - } - - public User getUser(Long userId) { - return userRepository.findById(userId).orElseThrow(UserNotFoundException::new); - } - - @Transactional - public void deleteKakaoId(Long userId) { - User user = userRepository.findById(userId).orElseThrow(UserNotFoundException::new); - user.updateKakaoId(null); - } - - @Transactional(readOnly = true) - public UserImageResponseDto getRankedUserImagesByPPP(Long seasonId) { - Season targetSeason; - - if (seasonId == 0) - targetSeason = seasonFindService.findCurrentSeason(LocalDateTime.now()); - else - targetSeason = seasonFindService.findSeasonById(seasonId); - try { - String zSetKey = RedisKeyManager.getZSetKey(targetSeason.getId()); - List userIds = rankRedisRepository.getUserIdsByRangeFromZSet(zSetKey, 0, 2); - List users = userRepository.findUsersByIdIn(userIds); - List userImages = new ArrayList<>(); - userIds.forEach(userId -> { - User user = users.stream().filter(u -> u.getId().equals(userId)).findFirst().orElseThrow(UserNotFoundException::new); - Tier tier = rankFindService.findByUserIdAndSeasonId(user.getId(), targetSeason.getId()).getTier(); - userImages.add(new UserImageDto(user.getIntraId(), user.getImageUri(), user.getEdge(), tier.getImageUri())); - }); - return new UserImageResponseDto(userImages); - } catch (RedisDataNotFoundException ex) { - return new UserImageResponseDto(new ArrayList<>()); - } - } - - public UserImageResponseDto getRankedUserImagesByExp(PageRequest pageRequest) { - List users = userRepository.findAll(pageRequest).getContent(); - List userImages = new ArrayList<>(); - for (User user : users) { - Tier tier = rankFindService.findByUserIdAndSeasonId(user.getId(), seasonFindService.findCurrentSeason(LocalDateTime.now()).getId()).getTier(); - userImages.add(new UserImageDto(user.getIntraId(), user.getImageUri(), user.getEdge(), tier.getImageUri())); - } - return new UserImageResponseDto(userImages); - } - - @Transactional - public UserAttendanceResponseDto attendUser(Long userId) { - User user = userRepository.findById(userId).orElseThrow(UserNotFoundException::new); - - int plus = userCoinChangeService.addAttendanceCoin(user); - - return new UserAttendanceResponseDto(user.getGgCoin() - plus, user.getGgCoin(), plus); - } - - @Transactional - public UserNormalDetailResponseDto getUserNormalDetail(UserDto user) { - User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); - Boolean isAdmin = user.getRoleType() == RoleType.ADMIN; - Boolean isAttended = coinHistoryService.hasAttendedToday(loginUser); - Integer level = ExpLevelCalculator.getLevel(user.getTotalExp()); - Tier tier; - try { - tier = rankFindService.findByUserIdAndSeasonId(user.getId(), seasonFindService.findCurrentSeason(LocalDateTime.now()).getId()).getTier(); - } catch (RankNotFoundException ex) { - // 카카오 유저나 Rank가 없는 유저 - tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); - } - return new UserNormalDetailResponseDto(user.getIntraId(), loginUser.getImageUri(), isAdmin, isAttended, loginUser.getEdge(), tier.getName(), tier.getImageUri(), level); - } - - @Transactional() - public void updateTextColor(Long userId, UserTextColorDto textColorDto) { - String textColor = textColorDto.getTextColor(); - Receipt receipt = receiptRepository.findById(textColorDto.getReceiptId()).orElseThrow(ReceiptNotFoundException::new); - User loginUser = userRepository.findById(userId).orElseThrow(UserNotFoundException::new); - - if (!UserTextColorCheckService.check(textColor)) - throw new UserTextColorException(); - - itemService.checkItemType(receipt, ItemType.TEXT_COLOR); - itemService.checkItemOwner(loginUser, receipt); - itemService.checkItemStatus(receipt); - - loginUser.updateTextColor(textColor); - receipt.updateStatus(ItemStatus.USED); - } - - @Transactional - public String updateEdge(UserDto user, UserEdgeDto userEdgeDto) { - User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); - EdgeType edgeType = EdgeType.getRandomEdgeType(); - Receipt receipt = receiptRepository.findById(userEdgeDto.getReceiptId()).orElseThrow(ReceiptNotFoundException::new); - - itemService.checkItemType(receipt, ItemType.EDGE); - itemService.checkItemOwner(loginUser, receipt); - itemService.checkItemStatus(receipt); - - loginUser.updateEdge(edgeType); - receipt.updateStatus(ItemStatus.USED); - - return edgeType.toString(); - } - - @Transactional - public String updateBackground(UserDto user, UserBackgroundDto userBackgroundDto) { - User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); - BackgroundType backgroundType = BackgroundType.getRandomBackgroundType(); - Receipt receipt = receiptRepository.findById(userBackgroundDto.getReceiptId()).orElseThrow(ReceiptNotFoundException::new); - - itemService.checkItemType(receipt, ItemType.BACKGROUND); - itemService.checkItemOwner(loginUser, receipt); - itemService.checkItemStatus(receipt); - - loginUser.updateBackground(backgroundType); - receipt.updateStatus(ItemStatus.USED); - - return backgroundType.toString(); - } - - @Transactional - public void updateUserProfileImage(UserDto user, UserProfileImageRequestDto userProfileImageRequestDto, MultipartFile userImageFile) throws IOException { - User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); - Receipt receipt = receiptRepository.findById(userProfileImageRequestDto.getReceiptId()).orElseThrow(ReceiptNotFoundException::new); - - itemService.checkItemType(receipt, ItemType.PROFILE_IMAGE); - itemService.checkItemOwner(loginUser, receipt); - itemService.checkItemStatus(receipt); - - if (userImageFile == null) - throw new UserImageNullException(); - if (userImageFile.getSize() > 50000) { - throw new UserImageLargeException(); - } else if (userImageFile.getContentType() == null || !userImageFile.getContentType().equals("image/jpeg")) { - throw new UserImageTypeException(); - } - - UserImage userImage = userImageRepository.findTopByUserAndIsCurrentIsTrueOrderByIdDesc(loginUser).orElseThrow(UserImageNullException::new); - userImage.updateIsCurrent(); - asyncNewUserImageUploader.update(user.getIntraId(), userImageFile); - receipt.updateStatus(ItemStatus.USED); - } -} +package com.gg.server.domain.user.service; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import com.gg.server.domain.coin.service.CoinHistoryService; +import com.gg.server.domain.coin.service.UserCoinChangeService; +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.data.GameRepository; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.item.service.ItemService; +import com.gg.server.domain.item.type.ItemType; +import com.gg.server.domain.match.data.RedisMatchUserRepository; +import com.gg.server.domain.noti.data.NotiRepository; +import com.gg.server.domain.pchange.data.PChange; +import com.gg.server.domain.pchange.data.PChangeRepository; +import com.gg.server.domain.pchange.exception.PChangeNotExistException; +import com.gg.server.domain.rank.data.Rank; +import com.gg.server.domain.rank.exception.RankNotFoundException; +import com.gg.server.domain.rank.exception.RedisDataNotFoundException; +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.rank.redis.RedisKeyManager; +import com.gg.server.domain.rank.service.RankFindService; +import com.gg.server.domain.receipt.data.Receipt; +import com.gg.server.domain.receipt.data.ReceiptRepository; +import com.gg.server.domain.receipt.exception.ReceiptNotFoundException; +import com.gg.server.domain.receipt.type.ItemStatus; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.service.SeasonFindService; +import com.gg.server.domain.tier.data.Tier; +import com.gg.server.domain.tier.data.TierRepository; +import com.gg.server.domain.tier.exception.TierNotFoundException; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserImage; +import com.gg.server.domain.user.data.UserImageRepository; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserAttendanceResponseDto; +import com.gg.server.domain.user.dto.UserBackgroundDto; +import com.gg.server.domain.user.dto.UserDetailResponseDto; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.dto.UserEdgeDto; +import com.gg.server.domain.user.dto.UserHistoryData; +import com.gg.server.domain.user.dto.UserHistoryResponseDto; +import com.gg.server.domain.user.dto.UserImageDto; +import com.gg.server.domain.user.dto.UserImageResponseDto; +import com.gg.server.domain.user.dto.UserLiveResponseDto; +import com.gg.server.domain.user.dto.UserNormalDetailResponseDto; +import com.gg.server.domain.user.dto.UserProfileImageRequestDto; +import com.gg.server.domain.user.dto.UserRankResponseDto; +import com.gg.server.domain.user.dto.UserTextColorDto; +import com.gg.server.domain.user.exception.UserImageLargeException; +import com.gg.server.domain.user.exception.UserImageNullException; +import com.gg.server.domain.user.exception.UserImageTypeException; +import com.gg.server.domain.user.exception.UserNotFoundException; +import com.gg.server.domain.user.exception.UserTextColorException; +import com.gg.server.domain.user.type.BackgroundType; +import com.gg.server.domain.user.type.EdgeType; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.global.utils.ExpLevelCalculator; +import com.gg.server.global.utils.aws.AsyncNewUserImageUploader; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class UserService { + + private final UserFindService userFindService; + private final UserRepository userRepository; + private final NotiRepository notiRepository; + private final GameRepository gameRepository; + private final RankRedisRepository rankRedisRepository; + private final SeasonFindService seasonFindService; + private final PChangeRepository pChangeRepository; + private final RankFindService rankFindService; + private final RedisMatchUserRepository redisMatchUserRepository; + private final UserCoinChangeService userCoinChangeService; + private final CoinHistoryService coinHistoryService; + private final ReceiptRepository receiptRepository; + private final AsyncNewUserImageUploader asyncNewUserImageUploader; + private final UserImageRepository userImageRepository; + private final ItemService itemService; + private final TierRepository tierRepository; + + /** + * @param intraId + * @return intraId가 포함된 유저들의 intraId를 페이징 관계없이 최대 5개까지 검색하여 List로 return + */ + @Transactional(readOnly = true) + public List findByPartOfIntraId(String intraId) { + Pageable pageable = PageRequest.of(0, 5, Sort.by("intraId").ascending()); + Page pageUsers = userRepository.findByIntraIdContains(pageable, intraId); + return pageUsers.getContent().stream().map(user -> user.getIntraId()) + .collect(Collectors.toList()); + } + + /** + * @param user - event: + * - null → 로그인 유저가 잡힌 매칭이 하나도 없을 때 + * - match → 매칭은 되었으나 게임시작 전일 때 or 매칭중인 경우 + * - game → 유저가 게임이 잡혔고 현재 게임중인 경우 + *

+ * - currentMatchMode + * - normal + * - rank + * - null -> 매칭이 안잡혔을 때 or 게임 전 + */ + @Transactional() + public UserLiveResponseDto getUserLiveDetail(UserDto user) { + int notiCnt = notiRepository.countNotCheckedNotiByUser(user.getId()); + Optional optionalGame = gameRepository.getLatestGameByUser(user.getId()); + int userMatchCnt = redisMatchUserRepository.countMatchTime(user.getId()); + if (optionalGame.isPresent()) { + Game game = optionalGame.get(); + if (game.getStatus() == StatusType.LIVE || game.getStatus() == StatusType.WAIT) { + return new UserLiveResponseDto(notiCnt, "game", game.getMode(), game.getId()); + } else if (game.getStatus() == StatusType.END) { + PChange userPChange = pChangeRepository.findPChangeByUserIdAndGameId(user.getId(), game.getId()) + .orElseThrow(() -> new PChangeNotExistException()); + if (!userPChange.getIsChecked()) { + userPChange.checkPChange(); + return new UserLiveResponseDto(notiCnt, "game", game.getMode(), game.getId()); + } + } + + if (game.getStatus() == StatusType.BEFORE) { + return new UserLiveResponseDto(notiCnt, "match", null, null); + } + } + if (userMatchCnt > 0) { + return new UserLiveResponseDto(notiCnt, "match", null, null); + } + return new UserLiveResponseDto(notiCnt, null, null, null); + } + + @Transactional(readOnly = true) + public UserDetailResponseDto getUserDetail(String targetUserIntraId) { + User targetUser = userFindService.findByIntraId(targetUserIntraId); + String statusMessage = userFindService.getUserStatusMessage(targetUser); + Tier tier; + try { + tier = rankFindService.findByUserIdAndSeasonId(targetUser.getId(), + seasonFindService.findCurrentSeason(LocalDateTime.now()).getId()).getTier(); + } catch (RankNotFoundException e) { + tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); + } + return new UserDetailResponseDto(targetUser, statusMessage, tier); + } + + @Transactional + public void updateUser(RacketType racketType, String statusMessage, SnsType snsNotiOpt, String intraId) { + User user = userFindService.findByIntraId(intraId); + Season currentSeason = seasonFindService.findCurrentSeason(LocalDateTime.now()); + updateRedisRankStatusMessage(statusMessage, user, currentSeason); + updateRankTableStatusMessage(user.getId(), statusMessage, currentSeason.getId()); + user.updateTypes(racketType, snsNotiOpt); + } + + private void updateRankTableStatusMessage(Long userId, String statusMessage, Long seasonId) { + Rank rank = rankFindService.findByUserIdAndSeasonId(userId, seasonId); + rank.setStatusMessage(statusMessage); + } + + private void updateRedisRankStatusMessage(String statusMessage, User user, Season currentSeason) { + String hashKey = RedisKeyManager.getHashKey(currentSeason.getId()); + + RankRedis userRank = rankRedisRepository.findRankByUserId(hashKey, user.getId()); + userRank.setStatusMessage(statusMessage); + rankRedisRepository.updateRankData(hashKey, user.getId(), userRank); + } + + /** + * @param intraId + * @param seasonId seasonId == 0 -> current season, else -> 해당 Id를 가진 season의 데이터 + *

+ * 기존 쿼리 + * @return 유저의 최근 10개의 랭크 경기 기록 + * @Query(nativeQuery = true, value = "SELECT * FROM pchange " + + * "where game_id in (SELECT id FROM game where season = :season and mode = :mode ) " + + * "AND user_id = :intraId ORDER BY id Desc limit :limit") + * -> Limit에는 10이 기본으로 들어감 + */ + @Transactional(readOnly = true) + public UserHistoryResponseDto getUserHistory(String intraId, Long seasonId) { + Season season; + if (seasonId == 0) { + season = seasonFindService.findCurrentSeason(LocalDateTime.now()); + } else { + season = seasonFindService.findSeasonById(seasonId); + } + List pChanges = pChangeRepository.findPChangesHistory(intraId, season.getId()); + List historyData = pChanges.stream().map(UserHistoryData::new).collect(Collectors.toList()); + Collections.reverse(historyData); + return new UserHistoryResponseDto(historyData); + } + + /** + * @param targetUserIntraId + * @param seasonId seasonId == 0 -> current season, else -> 해당 Id를 가진 season의 데이터 + * @return + */ + @Transactional(readOnly = true) + public UserRankResponseDto getUserRankDetail(String targetUserIntraId, Long seasonId) { + Season season; + if (seasonId == 0) { + season = seasonFindService.findCurrentSeason(LocalDateTime.now()); + } else { + season = seasonFindService.findSeasonById(seasonId); + } + String zSetKey = RedisKeyManager.getZSetKey(season.getId()); + String hashKey = RedisKeyManager.getHashKey(season.getId()); + User user = userFindService.findByIntraId(targetUserIntraId); + try { + Long userRanking = rankRedisRepository.getRankInZSet(zSetKey, user.getId()); + userRanking += 1; + RankRedis userRank = rankRedisRepository.findRankByUserId(hashKey, user.getId()); + double winRate = (double)(userRank.getWins() * 10000 / (userRank.getWins() + userRank.getLosses())) / 100; + return new UserRankResponseDto(userRanking.intValue(), userRank.getPpp(), userRank.getWins(), + userRank.getLosses(), winRate); + } catch (RedisDataNotFoundException ex) { + return new UserRankResponseDto(-1, season.getStartPpp(), 0, 0, 0); + } catch (ArithmeticException ex2) { + return new UserRankResponseDto(-1, season.getStartPpp(), 0, 0, 0); + } + } + + public User getUser(Long userId) { + return userRepository.findById(userId).orElseThrow(UserNotFoundException::new); + } + + @Transactional + public void deleteKakaoId(Long userId) { + User user = userRepository.findById(userId).orElseThrow(UserNotFoundException::new); + user.updateKakaoId(null); + } + + @Transactional(readOnly = true) + public UserImageResponseDto getRankedUserImagesByPPP(Long seasonId) { + Season targetSeason; + + if (seasonId == 0) { + targetSeason = seasonFindService.findCurrentSeason(LocalDateTime.now()); + } else { + targetSeason = seasonFindService.findSeasonById(seasonId); + } + try { + String zSetKey = RedisKeyManager.getZSetKey(targetSeason.getId()); + List userIds = rankRedisRepository.getUserIdsByRangeFromZSet(zSetKey, 0, 2); + List users = userRepository.findUsersByIdIn(userIds); + List userImages = new ArrayList<>(); + userIds.forEach(userId -> { + User user = users.stream() + .filter(u -> u.getId().equals(userId)) + .findFirst() + .orElseThrow(UserNotFoundException::new); + Tier tier = rankFindService.findByUserIdAndSeasonId(user.getId(), targetSeason.getId()).getTier(); + userImages.add( + new UserImageDto(user.getIntraId(), user.getImageUri(), user.getEdge(), tier.getImageUri())); + }); + return new UserImageResponseDto(userImages); + } catch (RedisDataNotFoundException ex) { + return new UserImageResponseDto(new ArrayList<>()); + } + } + + public UserImageResponseDto getRankedUserImagesByExp(PageRequest pageRequest) { + List users = userRepository.findAll(pageRequest).getContent(); + List userImages = new ArrayList<>(); + for (User user : users) { + Tier tier = rankFindService.findByUserIdAndSeasonId(user.getId(), + seasonFindService.findCurrentSeason(LocalDateTime.now()).getId()).getTier(); + userImages.add(new UserImageDto(user.getIntraId(), user.getImageUri(), user.getEdge(), tier.getImageUri())); + } + return new UserImageResponseDto(userImages); + } + + @Transactional + public UserAttendanceResponseDto attendUser(Long userId) { + User user = userRepository.findById(userId).orElseThrow(UserNotFoundException::new); + + int plus = userCoinChangeService.addAttendanceCoin(user); + + return new UserAttendanceResponseDto(user.getGgCoin() - plus, user.getGgCoin(), plus); + } + + @Transactional + public UserNormalDetailResponseDto getUserNormalDetail(UserDto user) { + User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); + Boolean isAdmin = user.getRoleType() == RoleType.ADMIN; + Boolean isAttended = coinHistoryService.hasAttendedToday(loginUser); + Integer level = ExpLevelCalculator.getLevel(user.getTotalExp()); + Tier tier; + try { + tier = rankFindService.findByUserIdAndSeasonId(user.getId(), + seasonFindService.findCurrentSeason(LocalDateTime.now()).getId()).getTier(); + } catch (RankNotFoundException ex) { + // 카카오 유저나 Rank가 없는 유저 + tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); + } + return new UserNormalDetailResponseDto(user.getIntraId(), loginUser.getImageUri(), isAdmin, isAttended, + loginUser.getEdge(), tier.getName(), tier.getImageUri(), level); + } + + @Transactional() + public void updateTextColor(Long userId, UserTextColorDto textColorDto) { + String textColor = textColorDto.getTextColor(); + Receipt receipt = receiptRepository.findById(textColorDto.getReceiptId()) + .orElseThrow(ReceiptNotFoundException::new); + User loginUser = userRepository.findById(userId).orElseThrow(UserNotFoundException::new); + + if (!UserTextColorCheckService.check(textColor)) { + throw new UserTextColorException(); + } + + itemService.checkItemType(receipt, ItemType.TEXT_COLOR); + itemService.checkItemOwner(loginUser, receipt); + itemService.checkItemStatus(receipt); + + loginUser.updateTextColor(textColor); + receipt.updateStatus(ItemStatus.USED); + } + + @Transactional + public String updateEdge(UserDto user, UserEdgeDto userEdgeDto) { + User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); + EdgeType edgeType = EdgeType.getRandomEdgeType(); + Receipt receipt = receiptRepository.findById(userEdgeDto.getReceiptId()) + .orElseThrow(ReceiptNotFoundException::new); + + itemService.checkItemType(receipt, ItemType.EDGE); + itemService.checkItemOwner(loginUser, receipt); + itemService.checkItemStatus(receipt); + + loginUser.updateEdge(edgeType); + receipt.updateStatus(ItemStatus.USED); + + return edgeType.toString(); + } + + @Transactional + public String updateBackground(UserDto user, UserBackgroundDto userBackgroundDto) { + User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); + BackgroundType backgroundType = BackgroundType.getRandomBackgroundType(); + Receipt receipt = receiptRepository.findById(userBackgroundDto.getReceiptId()) + .orElseThrow(ReceiptNotFoundException::new); + + itemService.checkItemType(receipt, ItemType.BACKGROUND); + itemService.checkItemOwner(loginUser, receipt); + itemService.checkItemStatus(receipt); + + loginUser.updateBackground(backgroundType); + receipt.updateStatus(ItemStatus.USED); + + return backgroundType.toString(); + } + + @Transactional + public void updateUserProfileImage(UserDto user, UserProfileImageRequestDto userProfileImageRequestDto, + MultipartFile userImageFile) throws IOException { + User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); + Receipt receipt = receiptRepository.findById(userProfileImageRequestDto.getReceiptId()) + .orElseThrow(ReceiptNotFoundException::new); + + itemService.checkItemType(receipt, ItemType.PROFILE_IMAGE); + itemService.checkItemOwner(loginUser, receipt); + itemService.checkItemStatus(receipt); + + if (userImageFile == null) { + throw new UserImageNullException(); + } + if (userImageFile.getSize() > 50000) { + throw new UserImageLargeException(); + } else if (userImageFile.getContentType() == null || !userImageFile.getContentType().equals("image/jpeg")) { + throw new UserImageTypeException(); + } + + UserImage userImage = userImageRepository.findTopByUserAndIsCurrentIsTrueOrderByIdDesc(loginUser) + .orElseThrow(UserImageNullException::new); + userImage.updateIsCurrent(); + asyncNewUserImageUploader.update(user.getIntraId(), userImageFile); + receipt.updateStatus(ItemStatus.USED); + } +} diff --git a/src/main/java/com/gg/server/domain/user/service/UserTextColorCheckService.java b/src/main/java/com/gg/server/domain/user/service/UserTextColorCheckService.java index 278cc6e5f..1ebafe0d0 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserTextColorCheckService.java +++ b/src/main/java/com/gg/server/domain/user/service/UserTextColorCheckService.java @@ -1,23 +1,29 @@ -package com.gg.server.domain.user.service; - -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class UserTextColorCheckService { - public static boolean check(String textColor) { - if (textColor == null) - return false; - if (textColor.length() != 7) - return false; - if (textColor.charAt(0) != '#') - return false; - for (int i = 1; i < 7; i++) { - char c = textColor.charAt(i); - if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) - return false; - } - return true; - } -} +package com.gg.server.domain.user.service; + +import org.springframework.stereotype.Service; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class UserTextColorCheckService { + public static boolean check(String textColor) { + if (textColor == null) { + return false; + } + if (textColor.length() != 7) { + return false; + } + if (textColor.charAt(0) != '#') { + return false; + } + for (int i = 1; i < 7; i++) { + char charTestColor = textColor.charAt(i); + if (!((charTestColor >= '0' && charTestColor <= '9') || (charTestColor >= 'a' && charTestColor <= 'f') || ( + charTestColor >= 'A' && charTestColor <= 'F'))) { + return false; + } + } + return true; + } +} diff --git a/src/main/java/com/gg/server/domain/user/type/BackgroundType.java b/src/main/java/com/gg/server/domain/user/type/BackgroundType.java index 01629e6fc..67c8b9427 100644 --- a/src/main/java/com/gg/server/domain/user/type/BackgroundType.java +++ b/src/main/java/com/gg/server/domain/user/type/BackgroundType.java @@ -1,51 +1,52 @@ package com.gg.server.domain.user.type; -import lombok.RequiredArgsConstructor; - import java.util.Random; +import lombok.RequiredArgsConstructor; + @RequiredArgsConstructor public enum BackgroundType { - BASIC(0), - COLOR1(1), - COLOR2(2), - COLOR3(3), - COLOR4(4), - COLOR5(5), - COLOR6(6), - COLOR7(7), - COLOR8(8), - COLOR9(9), - COLOR10(10), - COLOR11(11), - COLOR12(12), - COLOR13(13), - COLOR14(14), - COLOR15(15), - COLOR16(16); - - private final Integer code; - - public static BackgroundType getRandomBackgroundType() { - Random random = new Random(); - int tierInt = random.nextInt(100); - int colorInt; - - if (tierInt <= 50) - colorInt = random.nextInt(100) % 4 + 1; - else if (tierInt <= 70) - colorInt = (random.nextInt(99) % 3) + 5; - else if (tierInt <= 85) - colorInt = (random.nextInt(99) % 3) + 8; - else if (tierInt <= 95) - colorInt = (random.nextInt(99) % 3) + 11; - else - colorInt = (random.nextInt(99) % 3) + 14; - - return BackgroundType.values()[colorInt]; - } - - public static BackgroundType of(String code) { - return BackgroundType.valueOf(code); - } -} \ No newline at end of file + BASIC(0), + COLOR1(1), + COLOR2(2), + COLOR3(3), + COLOR4(4), + COLOR5(5), + COLOR6(6), + COLOR7(7), + COLOR8(8), + COLOR9(9), + COLOR10(10), + COLOR11(11), + COLOR12(12), + COLOR13(13), + COLOR14(14), + COLOR15(15), + COLOR16(16); + + private final Integer code; + + public static BackgroundType getRandomBackgroundType() { + Random random = new Random(); + int tierInt = random.nextInt(100); + int colorInt; + + if (tierInt <= 50) { + colorInt = random.nextInt(100) % 4 + 1; + } else if (tierInt <= 70) { + colorInt = (random.nextInt(99) % 3) + 5; + } else if (tierInt <= 85) { + colorInt = (random.nextInt(99) % 3) + 8; + } else if (tierInt <= 95) { + colorInt = (random.nextInt(99) % 3) + 11; + } else { + colorInt = (random.nextInt(99) % 3) + 14; + } + + return BackgroundType.values()[colorInt]; + } + + public static BackgroundType of(String code) { + return BackgroundType.valueOf(code); + } +} diff --git a/src/main/java/com/gg/server/domain/user/type/EdgeType.java b/src/main/java/com/gg/server/domain/user/type/EdgeType.java index e6446216f..744097dfa 100644 --- a/src/main/java/com/gg/server/domain/user/type/EdgeType.java +++ b/src/main/java/com/gg/server/domain/user/type/EdgeType.java @@ -1,51 +1,52 @@ -package com.gg.server.domain.user.type; - -import lombok.RequiredArgsConstructor; - -import java.util.Random; - -@RequiredArgsConstructor -public enum EdgeType { - BASIC(0), - COLOR1(1), - COLOR2(2), - COLOR3(3), - COLOR4(4), - COLOR5(5), - COLOR6(6), - COLOR7(7), - COLOR8(8), - COLOR9(9), - COLOR10(10), - COLOR11(11), - COLOR12(12), - COLOR13(13), - COLOR14(14), - COLOR15(15), - COLOR16(16); - - private final Integer code; - - public static EdgeType getRandomEdgeType() { - Random random = new Random(); - int tierInt = random.nextInt(100); - int colorInt; - - if (tierInt <= 50) - colorInt = random.nextInt(100) % 4 + 1; - else if (tierInt <= 70) - colorInt = (random.nextInt(99) % 3) + 5; - else if (tierInt <= 85) - colorInt = (random.nextInt(99) % 3) + 8; - else if (tierInt <= 95) - colorInt = (random.nextInt(99) % 3) + 11; - else - colorInt = (random.nextInt(99) % 3) + 14; - - return EdgeType.values()[colorInt]; - } - - public static EdgeType of(String code) { - return EdgeType.valueOf(code); - } -} \ No newline at end of file +package com.gg.server.domain.user.type; + +import java.util.Random; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +public enum EdgeType { + BASIC(0), + COLOR1(1), + COLOR2(2), + COLOR3(3), + COLOR4(4), + COLOR5(5), + COLOR6(6), + COLOR7(7), + COLOR8(8), + COLOR9(9), + COLOR10(10), + COLOR11(11), + COLOR12(12), + COLOR13(13), + COLOR14(14), + COLOR15(15), + COLOR16(16); + + private final Integer code; + + public static EdgeType getRandomEdgeType() { + Random random = new Random(); + int tierInt = random.nextInt(100); + int colorInt; + + if (tierInt <= 50) { + colorInt = random.nextInt(100) % 4 + 1; + } else if (tierInt <= 70) { + colorInt = (random.nextInt(99) % 3) + 5; + } else if (tierInt <= 85) { + colorInt = (random.nextInt(99) % 3) + 8; + } else if (tierInt <= 95) { + colorInt = (random.nextInt(99) % 3) + 11; + } else { + colorInt = (random.nextInt(99) % 3) + 14; + } + + return EdgeType.values()[colorInt]; + } + + public static EdgeType of(String code) { + return EdgeType.valueOf(code); + } +} diff --git a/src/main/java/com/gg/server/domain/user/type/OauthType.java b/src/main/java/com/gg/server/domain/user/type/OauthType.java index ad1fcdaa9..c1398cfbc 100644 --- a/src/main/java/com/gg/server/domain/user/type/OauthType.java +++ b/src/main/java/com/gg/server/domain/user/type/OauthType.java @@ -1,40 +1,40 @@ package com.gg.server.domain.user.type; -import com.fasterxml.jackson.annotation.JsonCreator; -import java.util.Arrays; import java.util.Locale; + +import com.fasterxml.jackson.annotation.JsonCreator; + import lombok.Getter; import lombok.RequiredArgsConstructor; @Getter @RequiredArgsConstructor public enum OauthType { - KAKAO("kakao"), - FORTYTWO("fortyTwo"), - BOTH("both"); + KAKAO("kakao"), + FORTYTWO("fortyTwo"), + BOTH("both"); - private final String code; + private final String code; - @JsonCreator - public static OauthType getEnumFromValue(String value) { - for(OauthType e : values()) { - if(e.code.equals(value)) { - return e; - } - else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { - return e; - } - } - return null; - } + @JsonCreator + public static OauthType getEnumFromValue(String value) { + for (OauthType e : values()) { + if (e.code.equals(value)) { + return e; + } else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { + return e; + } + } + return null; + } - public static OauthType of(RoleType roleType, Long kakaoId) { - if (kakaoId == null) { - return OauthType.FORTYTWO; - } - if (roleType.equals(RoleType.GUEST)) { - return OauthType.KAKAO; - } - return OauthType.BOTH; - } + public static OauthType of(RoleType roleType, Long kakaoId) { + if (kakaoId == null) { + return OauthType.FORTYTWO; + } + if (roleType.equals(RoleType.GUEST)) { + return OauthType.KAKAO; + } + return OauthType.BOTH; + } } diff --git a/src/main/java/com/gg/server/domain/user/type/RacketType.java b/src/main/java/com/gg/server/domain/user/type/RacketType.java index c7d32a857..6f3aada53 100644 --- a/src/main/java/com/gg/server/domain/user/type/RacketType.java +++ b/src/main/java/com/gg/server/domain/user/type/RacketType.java @@ -1,32 +1,32 @@ package com.gg.server.domain.user.type; +import java.util.Locale; + import com.fasterxml.jackson.annotation.JsonCreator; + import lombok.Getter; import lombok.RequiredArgsConstructor; -import java.util.Locale; - @Getter @RequiredArgsConstructor public enum RacketType { - PENHOLDER("PENHOLDER"), - SHAKEHAND("SHAKEHAND"), - DUAL("DUAL"), - NONE("NONE"); + PENHOLDER("PENHOLDER"), + SHAKEHAND("SHAKEHAND"), + DUAL("DUAL"), + NONE("NONE"); - private final String code; + private final String code; - @JsonCreator - public static RacketType getEnumFromValue(String value) { - for(RacketType e : values()) { - if(e.code.equals(value)) { - return e; - } - else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { - return e; - } - } - return null; - } + @JsonCreator + public static RacketType getEnumFromValue(String value) { + for (RacketType e : values()) { + if (e.code.equals(value)) { + return e; + } else if (e.code.toUpperCase(Locale.ROOT).equals(value.toUpperCase(Locale.ROOT))) { + return e; + } + } + return null; + } } diff --git a/src/main/java/com/gg/server/domain/user/type/RoleType.java b/src/main/java/com/gg/server/domain/user/type/RoleType.java index 7a64a963f..bb525ae39 100644 --- a/src/main/java/com/gg/server/domain/user/type/RoleType.java +++ b/src/main/java/com/gg/server/domain/user/type/RoleType.java @@ -1,27 +1,26 @@ package com.gg.server.domain.user.type; -import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Arrays; + import lombok.Getter; import lombok.RequiredArgsConstructor; -import java.util.Arrays; - @Getter @RequiredArgsConstructor public enum RoleType { - ADMIN("ROLE_ADMIN", "관리자"), - USER("ROLE_USER", "일반 사용자"), - GUEST("ROLE_GUEST", "게스트"); + ADMIN("ROLE_ADMIN", "관리자"), + USER("ROLE_USER", "일반 사용자"), + GUEST("ROLE_GUEST", "게스트"); - private final String key; - private final String displayName; + private final String key; + private final String displayName; - public static RoleType of(String key) { - return Arrays.stream(RoleType.values()) - .filter(r -> r.getKey().equals(key)) - .findAny() - .orElse(USER); - } + public static RoleType of(String key) { + return Arrays.stream(RoleType.values()) + .filter(r -> r.getKey().equals(key)) + .findAny() + .orElse(USER); + } } diff --git a/src/main/java/com/gg/server/domain/user/type/SnsType.java b/src/main/java/com/gg/server/domain/user/type/SnsType.java index fe08f3652..4060f08b1 100644 --- a/src/main/java/com/gg/server/domain/user/type/SnsType.java +++ b/src/main/java/com/gg/server/domain/user/type/SnsType.java @@ -1,27 +1,27 @@ package com.gg.server.domain.user.type; +import java.util.Arrays; + import lombok.Getter; import lombok.RequiredArgsConstructor; -import java.util.Arrays; - @Getter @RequiredArgsConstructor public enum SnsType { - NONE(0, "NONE"), - SLACK(1, "SLACK"), - EMAIL(2, "EMAIL"), - BOTH(3, "BOTH"); + NONE(0, "NONE"), + SLACK(1, "SLACK"), + EMAIL(2, "EMAIL"), + BOTH(3, "BOTH"); - private final Integer value; - private final String code; + private final Integer value; + private final String code; - public static SnsType of(String code) { - return Arrays.stream(SnsType.values()) - .filter(snsType-> snsType.getCode().equals(code)) - .findAny() - .orElse(SLACK); - } + public static SnsType of(String code) { + return Arrays.stream(SnsType.values()) + .filter(snsType -> snsType.getCode().equals(code)) + .findAny() + .orElse(SLACK); + } } diff --git a/src/main/java/com/gg/server/global/config/AWSConfig.java b/src/main/java/com/gg/server/global/config/AWSConfig.java index d74fd5d1d..ba9e35ab9 100644 --- a/src/main/java/com/gg/server/global/config/AWSConfig.java +++ b/src/main/java/com/gg/server/global/config/AWSConfig.java @@ -1,34 +1,35 @@ package com.gg.server.global.config; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.AWSStaticCredentialsProvider; import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3ClientBuilder; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; @Configuration public class AWSConfig { - @Value("${cloud.aws.credentials.accessKey}") - private String accessKey; + @Value("${cloud.aws.credentials.accessKey}") + private String accessKey; - @Value("${cloud.aws.credentials.secretKey}") - private String secretKey; + @Value("${cloud.aws.credentials.secretKey}") + private String secretKey; - @Value("${cloud.aws.region.static}") - private String region; + @Value("${cloud.aws.region.static}") + private String region; - @Bean - public AmazonS3 amazonS3Client() { - AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); + @Bean + public AmazonS3 amazonS3Client() { + AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); - return AmazonS3ClientBuilder - .standard() - .withCredentials(new AWSStaticCredentialsProvider(credentials)) - .withRegion(region) - .build(); - } + return AmazonS3ClientBuilder + .standard() + .withCredentials(new AWSStaticCredentialsProvider(credentials)) + .withRegion(region) + .build(); + } } diff --git a/src/main/java/com/gg/server/global/config/AsyncConfiguration.java b/src/main/java/com/gg/server/global/config/AsyncConfiguration.java index 7d476e798..dec8efe83 100644 --- a/src/main/java/com/gg/server/global/config/AsyncConfiguration.java +++ b/src/main/java/com/gg/server/global/config/AsyncConfiguration.java @@ -1,5 +1,7 @@ package com.gg.server.global.config; +import java.util.concurrent.Executor; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; @@ -9,30 +11,28 @@ import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import java.util.concurrent.Executor; - @Configuration @EnableAsync public class AsyncConfiguration implements AsyncConfigurer { - private static Logger logger = LoggerFactory.getLogger(AsyncConfiguration.class); + private static Logger logger = LoggerFactory.getLogger(AsyncConfiguration.class); - @Override - @Bean(name = "asyncExecutor") - public Executor getAsyncExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(5); - executor.setMaxPoolSize(20); - executor.setQueueCapacity(100); - executor.setThreadNamePrefix("MailExecutor-"); - executor.initialize(); - return executor; - } + @Override + @Bean(name = "asyncExecutor") + public Executor getAsyncExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(5); + executor.setMaxPoolSize(20); + executor.setQueueCapacity(100); + executor.setThreadNamePrefix("MailExecutor-"); + executor.initialize(); + return executor; + } - @Override - public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { - return (ex, method, params) -> - logger.error("Exception handler for async method '" + method.toGenericString() - + "' threw unexpected exception itself", ex); - } -} \ No newline at end of file + @Override + public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { + return (ex, method, params) -> + logger.error("Exception handler for async method '" + method.toGenericString() + + "' threw unexpected exception itself", ex); + } +} diff --git a/src/main/java/com/gg/server/global/config/ConstantConfig.java b/src/main/java/com/gg/server/global/config/ConstantConfig.java index 858a18adb..fc5299997 100644 --- a/src/main/java/com/gg/server/global/config/ConstantConfig.java +++ b/src/main/java/com/gg/server/global/config/ConstantConfig.java @@ -1,14 +1,10 @@ package com.gg.server.global.config; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.Setter; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; +import lombok.Getter; + /** * ConstantConfig. * @@ -20,9 +16,9 @@ @Component @Getter public class ConstantConfig { - @Value("${constant.allowedMinimalStartDays}") - private int allowedMinimalStartDays; + @Value("${constant.allowedMinimalStartDays}") + private int allowedMinimalStartDays; - @Value("${constant.tournamentSchedule}") - private String tournamentSchedule; + @Value("${constant.tournamentSchedule}") + private String tournamentSchedule; } diff --git a/src/main/java/com/gg/server/global/config/RedisConfig.java b/src/main/java/com/gg/server/global/config/RedisConfig.java index 5efd0d4d2..6663f61d1 100644 --- a/src/main/java/com/gg/server/global/config/RedisConfig.java +++ b/src/main/java/com/gg/server/global/config/RedisConfig.java @@ -1,6 +1,7 @@ package com.gg.server.global.config; import java.time.Duration; + import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.EnableCaching; @@ -28,90 +29,89 @@ @EnableTransactionManagement public class RedisConfig { - /** - * Redis Host - */ - @Value("${spring.redis.host}") - private String host; - - /** - * Redis Port - */ - @Value("${spring.redis.port}") - private int port; + /** + * Redis Host + */ + @Value("${spring.redis.host}") + private String host; - /** - * Redis Connection Factory - *

- * redisConnectionFactory() 메소드를 통해 RedisConnectionFactory 를 생성하고, 이를 통해 RedisTemplate 를 생성한다. 해당 - * 기능은 Spring Boot 에서 자동으로 제공해주지만, RedisConnectionFactory 를 커스터마이징 하기 위해 직접 생성 - * - * @return - */ - @Bean - public RedisConnectionFactory redisConnectionFactory() { - return new LettuceConnectionFactory(host, port); - } + /** + * Redis Port + */ + @Value("${spring.redis.port}") + private int port; - /** - * 캐시 관리자 - *

- * RedisCacheManager 를 통해 Redis 에 대한 캐시를 관리한다. 캐시의 기본 설정을 변경하기 위해 RedisCacheConfiguration 을 사용한다. - * - * @param connectionFactory - * @return - */ - @Bean - public CacheManager gameCacheManager(RedisConnectionFactory connectionFactory) { - RedisCacheManager.RedisCacheManagerBuilder builder = RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory( - redisConnectionFactory()); - RedisCacheConfiguration configuration = RedisCacheConfiguration.defaultCacheConfig() - .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer( - new GenericJackson2JsonRedisSerializer())) // Value Serializer 변경 - .entryTtl(Duration.ofMinutes(30)); // 캐시 수명 - builder.cacheDefaults(configuration); - return builder.build(); - } + /** + * Redis Connection Factory + *

+ * redisConnectionFactory() 메소드를 통해 RedisConnectionFactory 를 생성하고, 이를 통해 RedisTemplate 를 생성한다. 해당 + * 기능은 Spring Boot 에서 자동으로 제공해주지만, RedisConnectionFactory 를 커스터마이징 하기 위해 직접 생성 + * + * @return + */ + @Bean + public RedisConnectionFactory redisConnectionFactory() { + return new LettuceConnectionFactory(host, port); + } + /** + * 캐시 관리자 + *

+ * RedisCacheManager 를 통해 Redis 에 대한 캐시를 관리한다. 캐시의 기본 설정을 변경하기 위해 RedisCacheConfiguration 을 사용한다. + * + * @param connectionFactory + * @return + */ + @Bean + public CacheManager gameCacheManager(RedisConnectionFactory connectionFactory) { + RedisCacheManager.RedisCacheManagerBuilder builder = RedisCacheManager.RedisCacheManagerBuilder + .fromConnectionFactory(redisConnectionFactory()); + RedisCacheConfiguration configuration = RedisCacheConfiguration.defaultCacheConfig() + .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer( + new GenericJackson2JsonRedisSerializer())) // Value Serializer 변경 + .entryTtl(Duration.ofMinutes(30)); // 캐시 수명 + builder.cacheDefaults(configuration); + return builder.build(); + } - @Bean - public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) { - final RedisTemplate redisTemplate = new RedisTemplate<>(); + @Bean + public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) { + final RedisTemplate redisTemplate = new RedisTemplate<>(); - redisTemplate.setConnectionFactory(redisConnectionFactory); - redisTemplate.setKeySerializer(new StringRedisSerializer()); - redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer()); + redisTemplate.setConnectionFactory(redisConnectionFactory); + redisTemplate.setKeySerializer(new StringRedisSerializer()); + redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer()); - redisTemplate.setHashKeySerializer(new GenericJackson2JsonRedisSerializer()); - redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer()); - redisTemplate.setEnableTransactionSupport(true); // <= + redisTemplate.setHashKeySerializer(new GenericJackson2JsonRedisSerializer()); + redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer()); + redisTemplate.setEnableTransactionSupport(true); // <= - return redisTemplate; - } + return redisTemplate; + } - /** - * StringRedisTemplate - *

- * StringRedisTemplate 을 통해 Redis 에 데이터를 저장한다. - * - * @param redisTemplate - * @return - */ - @Bean - public ListOperations redisListTemplate(RedisTemplate redisTemplate) { - return redisTemplate.opsForList(); - } + /** + * StringRedisTemplate + *

+ * StringRedisTemplate 을 통해 Redis 에 데이터를 저장한다. + * + * @param redisTemplate + * @return + */ + @Bean + public ListOperations redisListTemplate(RedisTemplate redisTemplate) { + return redisTemplate.opsForList(); + } - /** - * ConfigureRedisAction - *

- * Elasticache를 사용할 때, CONFIG 명령어 사용이 제한됨으로 인해 발생하는 에러를 방지하기 위해 사용 - * - * @return ConfigureRedisAction - */ - @Bean - public ConfigureRedisAction configureRedisAction() { - return ConfigureRedisAction.NO_OP; - } + /** + * ConfigureRedisAction + *

+ * Elasticache를 사용할 때, CONFIG 명령어 사용이 제한됨으로 인해 발생하는 에러를 방지하기 위해 사용 + * + * @return ConfigureRedisAction + */ + @Bean + public ConfigureRedisAction configureRedisAction() { + return ConfigureRedisAction.NO_OP; + } -} \ No newline at end of file +} diff --git a/src/main/java/com/gg/server/global/config/SwaggerConfig.java b/src/main/java/com/gg/server/global/config/SwaggerConfig.java index faced4d9c..5f13738ca 100644 --- a/src/main/java/com/gg/server/global/config/SwaggerConfig.java +++ b/src/main/java/com/gg/server/global/config/SwaggerConfig.java @@ -1,53 +1,54 @@ package com.gg.server.global.config; +import org.springdoc.core.GroupedOpenApi; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.security.SecurityRequirement; import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.servers.Server; -import org.springdoc.core.GroupedOpenApi; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; @Configuration public class SwaggerConfig { - @Bean - public GroupedOpenApi group1() { - return GroupedOpenApi.builder() - .group("pingpong") - .pathsToMatch("/pingpong/**") - .packagesToScan("com.gg.server.domain") - .build(); - } + @Bean + public GroupedOpenApi group1() { + return GroupedOpenApi.builder() + .group("pingpong") + .pathsToMatch("/pingpong/**") + .packagesToScan("com.gg.server.domain") + .build(); + } - @Bean - public GroupedOpenApi admin_group() { - return GroupedOpenApi.builder() - .group("pingpong admin") - .pathsToMatch("/pingpong/admin/**") - .build(); - } + @Bean + public GroupedOpenApi admin_group() { + return GroupedOpenApi.builder() + .group("pingpong admin") + .pathsToMatch("/pingpong/admin/**") + .build(); + } - @Bean - public OpenAPI springShopOpenAPI() { - String jwtSchemeName = "jwtAuth"; - SecurityRequirement securityRequirement = new SecurityRequirement().addList(jwtSchemeName); - Components components = new Components() - .addSecuritySchemes(jwtSchemeName, new SecurityScheme() - .name(jwtSchemeName) - .type(SecurityScheme.Type.HTTP) - .scheme("Bearer") - .bearerFormat("JWT")); - Server server = new Server(); - server.setUrl("/"); - server.setDescription("test Server url"); - return new OpenAPI() - .info(new Info().title("42GG V2 API") - .description("42GG 백엔드 프로젝트 API 명세서입니다.") - .version("v2.0.0")) - .addServersItem(server) - .addSecurityItem(securityRequirement) - .components(components); - } + @Bean + public OpenAPI springShopOpenAPI() { + String jwtSchemeName = "jwtAuth"; + SecurityRequirement securityRequirement = new SecurityRequirement().addList(jwtSchemeName); + Components components = new Components() + .addSecuritySchemes(jwtSchemeName, new SecurityScheme() + .name(jwtSchemeName) + .type(SecurityScheme.Type.HTTP) + .scheme("Bearer") + .bearerFormat("JWT")); + Server server = new Server(); + server.setUrl("/"); + server.setDescription("test Server url"); + return new OpenAPI() + .info(new Info().title("42GG V2 API") + .description("42GG 백엔드 프로젝트 API 명세서입니다.") + .version("v2.0.0")) + .addServersItem(server) + .addSecurityItem(securityRequirement) + .components(components); + } } diff --git a/src/main/java/com/gg/server/global/config/TimeZoneConfiguration.java b/src/main/java/com/gg/server/global/config/TimeZoneConfiguration.java index 1ee70313d..a71ff7603 100644 --- a/src/main/java/com/gg/server/global/config/TimeZoneConfiguration.java +++ b/src/main/java/com/gg/server/global/config/TimeZoneConfiguration.java @@ -1,15 +1,16 @@ package com.gg.server.global.config; -import org.springframework.context.annotation.Configuration; +import java.util.TimeZone; import javax.annotation.PostConstruct; -import java.util.TimeZone; + +import org.springframework.context.annotation.Configuration; @Configuration public class TimeZoneConfiguration { - @PostConstruct - public void init() { - TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul")); - } + @PostConstruct + public void init() { + TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul")); + } } diff --git a/src/main/java/com/gg/server/global/config/WebConfig.java b/src/main/java/com/gg/server/global/config/WebConfig.java index f7573f428..9924a798a 100644 --- a/src/main/java/com/gg/server/global/config/WebConfig.java +++ b/src/main/java/com/gg/server/global/config/WebConfig.java @@ -1,31 +1,33 @@ -package com.gg.server.global.config; - -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.global.utils.argumentresolver.LoginMemberArgumentResolver; -import com.gg.server.global.utils.querytracker.LoggingInterceptor; -import lombok.RequiredArgsConstructor; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.method.support.HandlerMethodArgumentResolver; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -import java.util.List; - -@Configuration -@RequiredArgsConstructor -public class WebConfig implements WebMvcConfigurer { - private final UserRepository userRepository; - private final AuthTokenProvider tokenProvider; - private final LoggingInterceptor loggingInterceptor; - - @Override - public void addArgumentResolvers(List resolvers) { - resolvers.add(new LoginMemberArgumentResolver(userRepository, tokenProvider)); - } - - @Override - public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(loggingInterceptor); - } -} +package com.gg.server.global.config; + +import java.util.List; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.global.utils.argumentresolver.LoginMemberArgumentResolver; +import com.gg.server.global.utils.querytracker.LoggingInterceptor; + +import lombok.RequiredArgsConstructor; + +@Configuration +@RequiredArgsConstructor +public class WebConfig implements WebMvcConfigurer { + private final UserRepository userRepository; + private final AuthTokenProvider tokenProvider; + private final LoggingInterceptor loggingInterceptor; + + @Override + public void addArgumentResolvers(List resolvers) { + resolvers.add(new LoginMemberArgumentResolver(userRepository, tokenProvider)); + } + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(loggingInterceptor); + } +} diff --git a/src/main/java/com/gg/server/global/dto/PageRequestDto.java b/src/main/java/com/gg/server/global/dto/PageRequestDto.java index 1a4a5ff9a..12a1c5ea6 100644 --- a/src/main/java/com/gg/server/global/dto/PageRequestDto.java +++ b/src/main/java/com/gg/server/global/dto/PageRequestDto.java @@ -1,33 +1,30 @@ package com.gg.server.global.dto; import javax.validation.constraints.Max; +import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.springframework.web.bind.annotation.RequestParam; -import javax.validation.constraints.Min; +import lombok.Getter; import lombok.Setter; -import lombok.ToString; @Getter @Setter public class PageRequestDto { - @Min(value = 1, message = "page must be greater than 0") - @NotNull(message = "page 는 필수 값입니다.") - private Integer page; + @Min(value = 1, message = "page must be greater than 0") + @NotNull(message = "page 는 필수 값입니다.") + private Integer page; - @Min(value = 1, message = "size must be greater than 0") - @Max(value = 30, message = "size must be less than 30") - private Integer size = 20; + @Min(value = 1, message = "size must be greater than 0") + @Max(value = 30, message = "size must be less than 30") + private Integer size = 20; - public PageRequestDto(Integer page, Integer size) { - this.page = page; - if (size == null) - this.size = 20; - else - this.size = size; - } + public PageRequestDto(Integer page, Integer size) { + this.page = page; + if (size == null) { + this.size = 20; + } else { + this.size = size; + } + } } diff --git a/src/main/java/com/gg/server/global/exception/ErrorCode.java b/src/main/java/com/gg/server/global/exception/ErrorCode.java index 799555552..9134e58c5 100644 --- a/src/main/java/com/gg/server/global/exception/ErrorCode.java +++ b/src/main/java/com/gg/server/global/exception/ErrorCode.java @@ -6,159 +6,157 @@ @AllArgsConstructor @Getter public enum ErrorCode { - //common - NULL_POINT(500, "G100", "NULL POINT EXCEPTION"), - - //user - USER_NOT_FOUND(404, "UR100", "USER NOT FOUND"), - USER_IMAGE_NOT_FOUND(404, "UR200", "USER IMAGE NOT FOUND"), - USER_IMAGE_TOO_LARGE(413, "UR401", "USER IMAGE IS TOO LARGE"), - USER_IMAGE_WRONG_TYPE(415, "UR402", "USER IMAGE TYPE IS WRONG"), - KAKAO_OAUTH2_NOT_FOUND(404, "UR101", "KAKAO OAUTH2 NOT FOUND"), - KAKAO_OAUTH2_DUPLICATE(409, "UR300", "KAKAO OAUTH2 ALREADY EXIST"), - USER_TEXT_COLOR_WRONG_TYPE(401, "UR403", "USER TEXT COLOR CODE IS WRONG"), - USER_ALREADY_ATTENDANCE(409, "UR301", "USER ALREADY ATTENDANCE"), - - //announcement - ANNOUNCE_NOT_FOUND(404, "AN100", "ANNOUNCEMENT NOT FOUND"), - ANNOUNCE_DUPLICATE(409, "AN300", "ANNOUNCEMENT DUPLICATION"), - - //coinPolicy - CoinPolicy_NOT_FOUND(404, "CP100", "COINPOLICY NOT FOUND"), - - //coinHistory - COIN_HISTORY_NOT_FOUND(404, "CH100", "COIN HISTORY NOT FOUND"), - - //season - SEASON_NOT_FOUND(404, "SE100", "SEASON NOT FOUND"), - SEASON_FORBIDDEN(400, "SE500", "SEASON FORBIDDEN ERROR"), - SEASON_TIME_BEFORE(400, "SE501", "SEASON TIME BEFORE"), - - //slotmanagement - SLOTMANAGEMENT_NOT_FOUND(404, "SM100", "SLOTMANAGEMENT NOT FOUND"), - SLOTMANAGEMENT_FORBIDDEN(400, "SM500", "SLOTMANAGEMENT FORBIDDEN"), - - //rank - RANK_NOT_FOUND(404, "RK100", "RANK NOT FOUND"), - REDIS_RANK_NOT_FOUND(404, "RK101", "REDIS RANK NOT FOUND"), - RANK_UPDATE_FAIL(400, "RK200", "RANK UPDATE FAIL"), - - //tier - TIER_NOT_FOUND(404, "TR100", "TIER NOT FOUND"), - - //item - ITEM_NOT_FOUND(404, "IT100", "ITEM NOT FOUND"), - ITEM_TYPE_NOT_MATCHED(400, "IT200", "ITEM TYPE NOT MATCHED"), - ITEM_NOT_PURCHASABLE(400, "IT201", "ITEM NOT PURCHASABLE"), - INSUFFICIENT_GGCOIN(400,"IT202","INSUFFICIENT GGCOIN"), - GUEST_ROLE_PURCHASE_FORBIDDEN(403, "IT203", "GUEST ROLE USERS CANNOT PURCHASE ITEMS."), - GUEST_ROLE_GIFT_FORBIDDEN(403, "IT204", "GUEST ROLE USERS CANNOT GIFT ITEMS."), - ITEM_NOT_AVAILABLE(400, "IT205", "ITEM NOT AVAILABLE"), - ITEM_IMAGE_TOO_LARGE(413, "IT401", "ITEM IMAGE IS TOO LARGE"), - ITEM_IMAGE_WRONG_TYPE(415, "IT402", "ITEM IMAGE TYPE IS WRONG"), - - //receipt - RECEIPT_NOT_FOUND(404, "RC100", "RECEIPT NOT FOUND"), - RECEIPT_NOT_OWNER(403, "RC500", "RECEIPT NOT OWNER"), - RECEIPT_STATUS_NOT_MATCHED(400, "RC200", "RECEIPT STATUS NOT MATCHED"), - - //megaphone - MEGAPHONE_NOT_FOUND(404, "ME100", "MEGAPHONE NOT FOUND"), - MEGAPHONE_TIME(400, "ME200", "MEGAPHONE TIME"), - MEGAPHONE_CONTENT(400, "ME201", "MEGAPHONE CONTENT IS EMPTY"), - - /** Penalty **/ - PENALTY_NOT_FOUND(404, "PE100", "PENALTY NOT FOUND"), - REDIS_PENALTY_USER_NOT_FOUND(404, "PE101", "REDIS PENALTY USER NOT FOUND"), - PENALTY_EXPIRED(400, "PE200", "PENALTY EXPIRED"), - - /** team **/ - TEAM_ID_NOT_MATCH(400, "TM201", "TEAM id 가 일치하지 않습니다."), - TEAM_DUPLICATION(409, "TM202", "중복된 Team 이 한 Game 에 존재할 수 없습니다."), - TEAM_SIZE_EXCEED(500, "TM203", "게임 최대 Team 의 수(2)를 초과하였습니다."), - TEAM_NOT_FOUND(404, "TM204", "TEAM이 존재하지 않습니다."), - WINNING_TEAM_NOT_FOUND(404, "TM205", "WINNING TEAM이 존재하지 않습니다."), - LOSING_TEAM_NOT_FOUND(404, "TM206", "LOSING TEAM이 존재하지 않습니다."), - - - /** - * team_user - */ - TEAM_USER_ALREADY_EXIST(409, "TU201", "중복된 TEAM_USER"), - TEAM_USER_EXCEED(500, "TU202", "TeamUser 최대 인원의 수(2)를 초과하였습니다."), - TEAM_USER_NOT_FOUND(404, "TU203", "TeamUser가 없습니다."), - - /** game **/ - GAME_DB_NOT_VALID(500, "GM201", "GAME DB NOT CONSISTENCY"), - SCORE_NOT_MATCHED(400, "GM202", "score 입력이 기존과 다릅니다."), - GAME_NOT_FOUND(404, "GM101", "GAME 이 존재하지 않습니다."), - GAME_NOT_RECENTLY(400, "GM203", "가장 최근 게임이 아닙니다."), - GAME_DUPLICATION_EXCEPTION(409, "GM204", "GAME ALREADY EXISTS"), - GAME_STATUS_NOT_MATCHED(400, "GM205", "게임 상태 오류입니다."), - SCORE_ALREADY_ENTERED(400, "GM206", "점수가 이미 입력되었습니다."), - SCORE_NOT_INVALID(400, "GM205", "score 입력이 유효하지 않습니다."), - GAME_NOT_TOURNAMENT(400, "GM206", "토너먼트 게임이 아닙니다."), - - /** match **/ - SLOT_ENROLLED(400, "MA300", "SLOT ALREADY ENROLLED"), - SLOT_COUNT_EXCEEDED(400, "MA301", "SLOT COUNT MORE THAN THREE"), - SLOT_NOT_FOUND(404, "MA100", "SLOT NOT FOUND"), - PENALTY_USER_ENROLLED(400, "MA302", "PENALTY USER ENROLLED"), - SLOT_PAST(400, "MA303", "PAST SLOT ENROLLED"), - MODE_INVALID(400, "MA200", "MODE INVALID"), - - /** Common **/ - INTERNAL_SERVER_ERR(500, "CM001","INTERNAL SERVER ERROR"), - NOT_FOUND(404, "CM002", "NOT FOUND"), - BAD_REQUEST(400, "CM003", "BAD REQUEST"), - UNAUTHORIZED(401, "CM004", "UNAUTHORIZED"), - METHOD_NOT_ALLOWED(405, "CM005", "METHOD NOT ALLOWED"), - PAGE_NOT_FOUND(404, "CM006", "PAGE NOT FOUND"), - VALID_FAILED(400, "CM007" , "Valid Test Failed."), - BAD_ARGU(400, "ARGUMENT-ERR-400", "잘못된 argument 입니다."), - UNREADABLE_HTTP_MESSAGE(400, "CM008", "유효하지 않은 HTTP 메시지입니다."), - - //Feedback - FEEDBACK_NOT_FOUND(404, "FB100", "FB NOT FOUND"), - - /** - * PChange - **/ - PCHANGE_NOT_FOUND(404, "PC100", "PChange 가 존재하지 않습니다."), - - AWS_S3_ERR(500, "CL001", "AWS S3 Error"), - AWS_SERVER_ERR(500, "CL002", "AWS Error"), - - // SENDER - SLACK_USER_NOT_FOUND(404, "SL001", "fail to get slack user info"), - SLACK_CH_NOT_FOUND(404, "SL002", "fail to get user dm channel id"), - SLACK_JSON_PARSE_ERR(400, "SL002", "json parse error"), - SLACK_SEND_FAIL(400, "SL003","fail to send notification" ), - - // Tournament - TOURNAMENT_INVALID_TIME(400, "TN001", "유효한 토너먼트 기간이 아닙니다."), - TOURNAMENT_CAN_NOT_UPDATE(403, "TN002", "토너먼트를 업데이트 할 수 없는 기간입니다."), - TOURNAMENT_INVALID_SCORE(403, "TN003", "스코어를 업데이트 할 수 없습니다."), - TOURNAMENT_NOT_BEFORE(403, "TN004", "tournament status is not before"), - TOURNAMENT_NOT_LIVE(403, "TN005", "tournament status is not live"), - TOURNAMENT_GAME_CAN_NOT_CANCELED(403, "TN006", "진행중인 토너먼트의 게임은 취소할 수 없습니다."), - TOURNAMENT_NOT_FOUND(404, "TN007", "target tournament not found"), - TOURNAMENT_GAME_NOT_FOUND(404, "TN008", "tournament game not found"), - TOURNAMENT_NOT_PARTICIPANT(404, "TN009", "토너먼트의 신청자가 아닙니다."), - TOURNAMENT_USER_NOT_FOUND(404, "TN010", "target tournament user not found"), - TOURNAMENT_CONFLICT(409, "TN011", "tournament conflicted"), - TOURNAMENT_ALREADY_PARTICIPANT(409, "TN012", "이미 토너먼트의 신청자 입니다."), - TOURNAMENT_CONFLICT_GAME(409, "TN013", "토너먼트 기간 내 대기중인 게임이 존재합니다."), - TOURNAMENT_GAME_DUPLICATION(409, "TN014", "중복된 토너먼트 게임입니다!"), - TOURNAMENT_USER_DUPLICATION(409, "TN015", "중복된 토너먼트 유저입니다!"), - TOURNAMENT_GAME_EXCEED(500, "TN016", "토너먼트 게임 최대 사이즈를 초과하였습니다!"), - TOURNAMENT_IS_BEFORE(403, "TN017", "before인 토너먼트에서 점수 수정할 수 없습니다.") - ; - private final int status; - private final String errCode; - private String message; - - public void setMessage(String msg) { - this.message = msg; - } + //common + NULL_POINT(500, "G100", "NULL POINT EXCEPTION"), + + //user + USER_NOT_FOUND(404, "UR100", "USER NOT FOUND"), + USER_IMAGE_NOT_FOUND(404, "UR200", "USER IMAGE NOT FOUND"), + USER_IMAGE_TOO_LARGE(413, "UR401", "USER IMAGE IS TOO LARGE"), + USER_IMAGE_WRONG_TYPE(415, "UR402", "USER IMAGE TYPE IS WRONG"), + KAKAO_OAUTH2_NOT_FOUND(404, "UR101", "KAKAO OAUTH2 NOT FOUND"), + KAKAO_OAUTH2_DUPLICATE(409, "UR300", "KAKAO OAUTH2 ALREADY EXIST"), + USER_TEXT_COLOR_WRONG_TYPE(401, "UR403", "USER TEXT COLOR CODE IS WRONG"), + USER_ALREADY_ATTENDANCE(409, "UR301", "USER ALREADY ATTENDANCE"), + + //announcement + ANNOUNCE_NOT_FOUND(404, "AN100", "ANNOUNCEMENT NOT FOUND"), + ANNOUNCE_DUPLICATE(409, "AN300", "ANNOUNCEMENT DUPLICATION"), + + //coinPolicy + CoinPolicy_NOT_FOUND(404, "CP100", "COINPOLICY NOT FOUND"), + + //coinHistory + COIN_HISTORY_NOT_FOUND(404, "CH100", "COIN HISTORY NOT FOUND"), + + //season + SEASON_NOT_FOUND(404, "SE100", "SEASON NOT FOUND"), + SEASON_FORBIDDEN(400, "SE500", "SEASON FORBIDDEN ERROR"), + SEASON_TIME_BEFORE(400, "SE501", "SEASON TIME BEFORE"), + + //slotmanagement + SLOTMANAGEMENT_NOT_FOUND(404, "SM100", "SLOTMANAGEMENT NOT FOUND"), + SLOTMANAGEMENT_FORBIDDEN(400, "SM500", "SLOTMANAGEMENT FORBIDDEN"), + + //rank + RANK_NOT_FOUND(404, "RK100", "RANK NOT FOUND"), + REDIS_RANK_NOT_FOUND(404, "RK101", "REDIS RANK NOT FOUND"), + RANK_UPDATE_FAIL(400, "RK200", "RANK UPDATE FAIL"), + + //tier + TIER_NOT_FOUND(404, "TR100", "TIER NOT FOUND"), + + //item + ITEM_NOT_FOUND(404, "IT100", "ITEM NOT FOUND"), + ITEM_TYPE_NOT_MATCHED(400, "IT200", "ITEM TYPE NOT MATCHED"), + ITEM_NOT_PURCHASABLE(400, "IT201", "ITEM NOT PURCHASABLE"), + INSUFFICIENT_GGCOIN(400, "IT202", "INSUFFICIENT GGCOIN"), + GUEST_ROLE_PURCHASE_FORBIDDEN(403, "IT203", "GUEST ROLE USERS CANNOT PURCHASE ITEMS."), + GUEST_ROLE_GIFT_FORBIDDEN(403, "IT204", "GUEST ROLE USERS CANNOT GIFT ITEMS."), + ITEM_NOT_AVAILABLE(400, "IT205", "ITEM NOT AVAILABLE"), + ITEM_IMAGE_TOO_LARGE(413, "IT401", "ITEM IMAGE IS TOO LARGE"), + ITEM_IMAGE_WRONG_TYPE(415, "IT402", "ITEM IMAGE TYPE IS WRONG"), + + //receipt + RECEIPT_NOT_FOUND(404, "RC100", "RECEIPT NOT FOUND"), + RECEIPT_NOT_OWNER(403, "RC500", "RECEIPT NOT OWNER"), + RECEIPT_STATUS_NOT_MATCHED(400, "RC200", "RECEIPT STATUS NOT MATCHED"), + + //megaphone + MEGAPHONE_NOT_FOUND(404, "ME100", "MEGAPHONE NOT FOUND"), + MEGAPHONE_TIME(400, "ME200", "MEGAPHONE TIME"), + MEGAPHONE_CONTENT(400, "ME201", "MEGAPHONE CONTENT IS EMPTY"), + + /** Penalty **/ + PENALTY_NOT_FOUND(404, "PE100", "PENALTY NOT FOUND"), + REDIS_PENALTY_USER_NOT_FOUND(404, "PE101", "REDIS PENALTY USER NOT FOUND"), + PENALTY_EXPIRED(400, "PE200", "PENALTY EXPIRED"), + + /** team **/ + TEAM_ID_NOT_MATCH(400, "TM201", "TEAM id 가 일치하지 않습니다."), + TEAM_DUPLICATION(409, "TM202", "중복된 Team 이 한 Game 에 존재할 수 없습니다."), + TEAM_SIZE_EXCEED(500, "TM203", "게임 최대 Team 의 수(2)를 초과하였습니다."), + TEAM_NOT_FOUND(404, "TM204", "TEAM이 존재하지 않습니다."), + WINNING_TEAM_NOT_FOUND(404, "TM205", "WINNING TEAM이 존재하지 않습니다."), + LOSING_TEAM_NOT_FOUND(404, "TM206", "LOSING TEAM이 존재하지 않습니다."), + + /** + * team_user + */ + TEAM_USER_ALREADY_EXIST(409, "TU201", "중복된 TEAM_USER"), + TEAM_USER_EXCEED(500, "TU202", "TeamUser 최대 인원의 수(2)를 초과하였습니다."), + TEAM_USER_NOT_FOUND(404, "TU203", "TeamUser가 없습니다."), + + /** game **/ + GAME_DB_NOT_VALID(500, "GM201", "GAME DB NOT CONSISTENCY"), + SCORE_NOT_MATCHED(400, "GM202", "score 입력이 기존과 다릅니다."), + GAME_NOT_FOUND(404, "GM101", "GAME 이 존재하지 않습니다."), + GAME_NOT_RECENTLY(400, "GM203", "가장 최근 게임이 아닙니다."), + GAME_DUPLICATION_EXCEPTION(409, "GM204", "GAME ALREADY EXISTS"), + GAME_STATUS_NOT_MATCHED(400, "GM205", "게임 상태 오류입니다."), + SCORE_ALREADY_ENTERED(400, "GM206", "점수가 이미 입력되었습니다."), + SCORE_NOT_INVALID(400, "GM205", "score 입력이 유효하지 않습니다."), + GAME_NOT_TOURNAMENT(400, "GM206", "토너먼트 게임이 아닙니다."), + + /** match **/ + SLOT_ENROLLED(400, "MA300", "SLOT ALREADY ENROLLED"), + SLOT_COUNT_EXCEEDED(400, "MA301", "SLOT COUNT MORE THAN THREE"), + SLOT_NOT_FOUND(404, "MA100", "SLOT NOT FOUND"), + PENALTY_USER_ENROLLED(400, "MA302", "PENALTY USER ENROLLED"), + SLOT_PAST(400, "MA303", "PAST SLOT ENROLLED"), + MODE_INVALID(400, "MA200", "MODE INVALID"), + + /** Common **/ + INTERNAL_SERVER_ERR(500, "CM001", "INTERNAL SERVER ERROR"), + NOT_FOUND(404, "CM002", "NOT FOUND"), + BAD_REQUEST(400, "CM003", "BAD REQUEST"), + UNAUTHORIZED(401, "CM004", "UNAUTHORIZED"), + METHOD_NOT_ALLOWED(405, "CM005", "METHOD NOT ALLOWED"), + PAGE_NOT_FOUND(404, "CM006", "PAGE NOT FOUND"), + VALID_FAILED(400, "CM007", "Valid Test Failed."), + BAD_ARGU(400, "ARGUMENT-ERR-400", "잘못된 argument 입니다."), + UNREADABLE_HTTP_MESSAGE(400, "CM008", "유효하지 않은 HTTP 메시지입니다."), + + //Feedback + FEEDBACK_NOT_FOUND(404, "FB100", "FB NOT FOUND"), + + /** + * PChange + **/ + PCHANGE_NOT_FOUND(404, "PC100", "PChange 가 존재하지 않습니다."), + + AWS_S3_ERR(500, "CL001", "AWS S3 Error"), + AWS_SERVER_ERR(500, "CL002", "AWS Error"), + + // SENDER + SLACK_USER_NOT_FOUND(404, "SL001", "fail to get slack user info"), + SLACK_CH_NOT_FOUND(404, "SL002", "fail to get user dm channel id"), + SLACK_JSON_PARSE_ERR(400, "SL002", "json parse error"), + SLACK_SEND_FAIL(400, "SL003", "fail to send notification"), + + // Tournament + TOURNAMENT_INVALID_TIME(400, "TN001", "유효한 토너먼트 기간이 아닙니다."), + TOURNAMENT_CAN_NOT_UPDATE(403, "TN002", "토너먼트를 업데이트 할 수 없는 기간입니다."), + TOURNAMENT_INVALID_SCORE(403, "TN003", "스코어를 업데이트 할 수 없습니다."), + TOURNAMENT_NOT_BEFORE(403, "TN004", "tournament status is not before"), + TOURNAMENT_NOT_LIVE(403, "TN005", "tournament status is not live"), + TOURNAMENT_GAME_CAN_NOT_CANCELED(403, "TN006", "진행중인 토너먼트의 게임은 취소할 수 없습니다."), + TOURNAMENT_NOT_FOUND(404, "TN007", "target tournament not found"), + TOURNAMENT_GAME_NOT_FOUND(404, "TN008", "tournament game not found"), + TOURNAMENT_NOT_PARTICIPANT(404, "TN009", "토너먼트의 신청자가 아닙니다."), + TOURNAMENT_USER_NOT_FOUND(404, "TN010", "target tournament user not found"), + TOURNAMENT_CONFLICT(409, "TN011", "tournament conflicted"), + TOURNAMENT_ALREADY_PARTICIPANT(409, "TN012", "이미 토너먼트의 신청자 입니다."), + TOURNAMENT_CONFLICT_GAME(409, "TN013", "토너먼트 기간 내 대기중인 게임이 존재합니다."), + TOURNAMENT_GAME_DUPLICATION(409, "TN014", "중복된 토너먼트 게임입니다!"), + TOURNAMENT_USER_DUPLICATION(409, "TN015", "중복된 토너먼트 유저입니다!"), + TOURNAMENT_GAME_EXCEED(500, "TN016", "토너먼트 게임 최대 사이즈를 초과하였습니다!"), + TOURNAMENT_IS_BEFORE(403, "TN017", "before인 토너먼트에서 점수 수정할 수 없습니다."); + private final int status; + private final String errCode; + private String message; + + public void setMessage(String msg) { + this.message = msg; + } } diff --git a/src/main/java/com/gg/server/global/exception/ErrorResponse.java b/src/main/java/com/gg/server/global/exception/ErrorResponse.java index fdf3f3fe6..1caabe9b2 100644 --- a/src/main/java/com/gg/server/global/exception/ErrorResponse.java +++ b/src/main/java/com/gg/server/global/exception/ErrorResponse.java @@ -4,13 +4,13 @@ @Getter public class ErrorResponse { - private int status; - private String message; - private String code; + private int status; + private String message; + private String code; - public ErrorResponse(ErrorCode errorCode) { - this.status = errorCode.getStatus(); - this.message = errorCode.getMessage(); - this.code = errorCode.getErrCode(); - } + public ErrorResponse(ErrorCode errorCode) { + this.status = errorCode.getStatus(); + this.message = errorCode.getMessage(); + this.code = errorCode.getErrCode(); + } } diff --git a/src/main/java/com/gg/server/global/exception/GlobalExceptionHandler.java b/src/main/java/com/gg/server/global/exception/GlobalExceptionHandler.java index fb049e3f9..f99c58373 100644 --- a/src/main/java/com/gg/server/global/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/gg/server/global/exception/GlobalExceptionHandler.java @@ -1,124 +1,132 @@ package com.gg.server.global.exception; -import com.gg.server.global.exception.custom.*; -import com.amazonaws.AmazonServiceException; -import com.amazonaws.SdkClientException; -import lombok.extern.slf4j.Slf4j; -import org.springframework.dao.DataAccessException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.validation.BindException; import org.springframework.web.HttpRequestMethodNotSupportedException; -import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.MissingServletRequestParameterException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; -import java.time.format.DateTimeParseException; +import com.amazonaws.AmazonServiceException; +import com.amazonaws.SdkClientException; +import com.gg.server.global.exception.custom.AuthenticationException; +import com.gg.server.global.exception.custom.CustomRuntimeException; +import com.gg.server.global.exception.custom.DBConsistencyException; +import com.gg.server.global.exception.custom.DuplicationException; +import com.gg.server.global.exception.custom.ForbiddenException; +import com.gg.server.global.exception.custom.NotExistException; +import com.gg.server.global.exception.custom.PageNotFoundException; + +import lombok.extern.slf4j.Slf4j; @Slf4j @ControllerAdvice public class GlobalExceptionHandler { - @ExceptionHandler({BindException.class}) - public ResponseEntity validException(BindException ex) { - log.error("bind error", ex.getBindingResult().getAllErrors().get(0)); - ErrorCode ec = ErrorCode.VALID_FAILED; - ec.setMessage(ex.getBindingResult().getAllErrors().get(0).getDefaultMessage()); - ErrorResponse response = new ErrorResponse(ec); - return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler({MethodArgumentTypeMismatchException.class}) - public ResponseEntity typeErrorException(MethodArgumentTypeMismatchException ex) { - log.error("type error", ex.getMessage()); - ErrorCode ec = ErrorCode.VALID_FAILED; - ec.setMessage(ex.getMessage()); - ErrorResponse response = new ErrorResponse(ec); - return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler({DBConsistencyException.class}) - public ResponseEntity dbConsistencyException(DBConsistencyException ex) { - log.error("db 정합성 오류", ex); - return new ResponseEntity<>(new ErrorResponse(ex.getErrorCode()), HttpStatus.INTERNAL_SERVER_ERROR); - } - - @ExceptionHandler({NotExistException.class, PageNotFoundException.class}) - public ResponseEntity notFoundException(CustomRuntimeException ex) { - log.error("Not Exist", ex); - ErrorResponse response = new ErrorResponse(ex.getErrorCode()); - return new ResponseEntity<>(response, HttpStatus.NOT_FOUND); - } - - @ExceptionHandler({DuplicationException.class}) - public ResponseEntity duplicatedException(DuplicationException ex) { - log.error("Duplicated", ex); - return new ResponseEntity<>(new ErrorResponse(ex.getErrorCode()), HttpStatus.CONFLICT); - } - - @ExceptionHandler({ForbiddenException.class}) - public ResponseEntity forbiddenException(ForbiddenException ex) { - log.error("forbidden", ex); - ErrorResponse response = new ErrorResponse(ex.getErrorCode()); - return new ResponseEntity<>(response, HttpStatus.FORBIDDEN); - } - - @ExceptionHandler({CustomRuntimeException.class}) - public ResponseEntity validException(CustomRuntimeException ex) { - log.error("예외처리된 에러", ex.getMessage(), ex.getErrorCode()); - ErrorResponse response = new ErrorResponse(ex.getErrorCode()); - return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler(AuthenticationException.class) - public ResponseEntity authenticationException(AuthenticationException ex) { - log.error("authentication exception"); - ErrorResponse response = new ErrorResponse(ex.getErrorCode()); - return new ResponseEntity<>(response, HttpStatus.valueOf(response.getStatus())); - } - @ExceptionHandler(AmazonServiceException.class) - protected ResponseEntity httpRequestMethodNotSupportedExceptionHandle(AmazonServiceException ex) { - log.error("AmazonServiceException", ex); - ErrorResponse response = new ErrorResponse(ErrorCode.AWS_S3_ERR); - return new ResponseEntity<>(response, HttpStatus.valueOf(ex.getStatusCode())); - } - - @ExceptionHandler(SdkClientException.class) - protected ResponseEntity httpRequestMethodNotSupportedExceptionHandle(SdkClientException ex) { - log.error("AmazonServiceException", ex.getMessage()); - ErrorResponse response = new ErrorResponse(ErrorCode.AWS_SERVER_ERR); - return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); - } - - @ExceptionHandler({RuntimeException.class}) - public ResponseEntity runtimeException(RuntimeException ex) { - log.error("처리되지 않은 에러입니다.", ex); - ErrorResponse response = new ErrorResponse(ErrorCode.INTERNAL_SERVER_ERR); - return new ResponseEntity<>(response, HttpStatus.valueOf(response.getStatus())); - } - @ExceptionHandler(HttpRequestMethodNotSupportedException.class) - protected ResponseEntity httpRequestMethodNotSupportedExceptionHandle(HttpRequestMethodNotSupportedException ex) { - log.error("지원하지 않는 메소드 요청입니다.", ex.getMethod()); - ErrorResponse response = new ErrorResponse(ErrorCode.METHOD_NOT_ALLOWED); - return new ResponseEntity<>(response, HttpStatus.METHOD_NOT_ALLOWED); - } - @ExceptionHandler(Exception.class) - public ResponseEntity handleException(Exception ex) { - log.error("!!!!!! SERVER ERROR !!!!!!", ex.getMessage()); - ErrorResponse response = new ErrorResponse(ErrorCode.INTERNAL_SERVER_ERR); - return new ResponseEntity<>(response, HttpStatus.valueOf(response.getStatus())); - } - - @ExceptionHandler(HttpMessageNotReadableException.class) - protected ResponseEntity handleException(HttpMessageNotReadableException e) { - return ResponseEntity.badRequest().body(ErrorCode.UNREADABLE_HTTP_MESSAGE.getMessage()); - } - - @ExceptionHandler(MissingServletRequestParameterException.class) - protected ResponseEntity handleException(MissingServletRequestParameterException e) { - return ResponseEntity.badRequest().body(ErrorCode.BAD_ARGU.getMessage()); - } + @ExceptionHandler({BindException.class}) + public ResponseEntity validException(BindException ex) { + log.error("bind error", ex.getBindingResult().getAllErrors().get(0)); + ErrorCode ec = ErrorCode.VALID_FAILED; + ec.setMessage(ex.getBindingResult().getAllErrors().get(0).getDefaultMessage()); + ErrorResponse response = new ErrorResponse(ec); + return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST); + } + + @ExceptionHandler({MethodArgumentTypeMismatchException.class}) + public ResponseEntity typeErrorException(MethodArgumentTypeMismatchException ex) { + log.error("type error", ex.getMessage()); + ErrorCode ec = ErrorCode.VALID_FAILED; + ec.setMessage(ex.getMessage()); + ErrorResponse response = new ErrorResponse(ec); + return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST); + } + + @ExceptionHandler({DBConsistencyException.class}) + public ResponseEntity dbConsistencyException(DBConsistencyException ex) { + log.error("db 정합성 오류", ex); + return new ResponseEntity<>(new ErrorResponse(ex.getErrorCode()), HttpStatus.INTERNAL_SERVER_ERROR); + } + + @ExceptionHandler({NotExistException.class, PageNotFoundException.class}) + public ResponseEntity notFoundException(CustomRuntimeException ex) { + log.error("Not Exist", ex); + ErrorResponse response = new ErrorResponse(ex.getErrorCode()); + return new ResponseEntity<>(response, HttpStatus.NOT_FOUND); + } + + @ExceptionHandler({DuplicationException.class}) + public ResponseEntity duplicatedException(DuplicationException ex) { + log.error("Duplicated", ex); + return new ResponseEntity<>(new ErrorResponse(ex.getErrorCode()), HttpStatus.CONFLICT); + } + + @ExceptionHandler({ForbiddenException.class}) + public ResponseEntity forbiddenException(ForbiddenException ex) { + log.error("forbidden", ex); + ErrorResponse response = new ErrorResponse(ex.getErrorCode()); + return new ResponseEntity<>(response, HttpStatus.FORBIDDEN); + } + + @ExceptionHandler({CustomRuntimeException.class}) + public ResponseEntity validException(CustomRuntimeException ex) { + log.error("예외처리된 에러", ex.getMessage(), ex.getErrorCode()); + ErrorResponse response = new ErrorResponse(ex.getErrorCode()); + return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST); + } + + @ExceptionHandler(AuthenticationException.class) + public ResponseEntity authenticationException(AuthenticationException ex) { + log.error("authentication exception"); + ErrorResponse response = new ErrorResponse(ex.getErrorCode()); + return new ResponseEntity<>(response, HttpStatus.valueOf(response.getStatus())); + } + + @ExceptionHandler(AmazonServiceException.class) + protected ResponseEntity httpRequestMethodNotSupportedExceptionHandle(AmazonServiceException ex) { + log.error("AmazonServiceException", ex); + ErrorResponse response = new ErrorResponse(ErrorCode.AWS_S3_ERR); + return new ResponseEntity<>(response, HttpStatus.valueOf(ex.getStatusCode())); + } + + @ExceptionHandler(SdkClientException.class) + protected ResponseEntity httpRequestMethodNotSupportedExceptionHandle(SdkClientException ex) { + log.error("AmazonServiceException", ex.getMessage()); + ErrorResponse response = new ErrorResponse(ErrorCode.AWS_SERVER_ERR); + return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); + } + + @ExceptionHandler({RuntimeException.class}) + public ResponseEntity runtimeException(RuntimeException ex) { + log.error("처리되지 않은 에러입니다.", ex); + ErrorResponse response = new ErrorResponse(ErrorCode.INTERNAL_SERVER_ERR); + return new ResponseEntity<>(response, HttpStatus.valueOf(response.getStatus())); + } + + @ExceptionHandler(HttpRequestMethodNotSupportedException.class) + protected ResponseEntity httpRequestMethodNotSupportedExceptionHandle( + HttpRequestMethodNotSupportedException ex) { + log.error("지원하지 않는 메소드 요청입니다.", ex.getMethod()); + ErrorResponse response = new ErrorResponse(ErrorCode.METHOD_NOT_ALLOWED); + return new ResponseEntity<>(response, HttpStatus.METHOD_NOT_ALLOWED); + } + + @ExceptionHandler(Exception.class) + public ResponseEntity handleException(Exception ex) { + log.error("!!!!!! SERVER ERROR !!!!!!", ex.getMessage()); + ErrorResponse response = new ErrorResponse(ErrorCode.INTERNAL_SERVER_ERR); + return new ResponseEntity<>(response, HttpStatus.valueOf(response.getStatus())); + } + + @ExceptionHandler(HttpMessageNotReadableException.class) + protected ResponseEntity handleException(HttpMessageNotReadableException exception) { + return ResponseEntity.badRequest().body(ErrorCode.UNREADABLE_HTTP_MESSAGE.getMessage()); + } + + @ExceptionHandler(MissingServletRequestParameterException.class) + protected ResponseEntity handleException(MissingServletRequestParameterException exception) { + return ResponseEntity.badRequest().body(ErrorCode.BAD_ARGU.getMessage()); + } } diff --git a/src/main/java/com/gg/server/global/exception/custom/AuthenticationException.java b/src/main/java/com/gg/server/global/exception/custom/AuthenticationException.java index 0603a8e77..647cc71d8 100644 --- a/src/main/java/com/gg/server/global/exception/custom/AuthenticationException.java +++ b/src/main/java/com/gg/server/global/exception/custom/AuthenticationException.java @@ -3,9 +3,9 @@ import com.gg.server.global.exception.ErrorCode; public class AuthenticationException extends CustomRuntimeException { - private ErrorCode errorCode; + private ErrorCode errorCode; - public AuthenticationException(String message, ErrorCode errorCode) { - super(message, errorCode); - } + public AuthenticationException(String message, ErrorCode errorCode) { + super(message, errorCode); + } } diff --git a/src/main/java/com/gg/server/global/exception/custom/BusinessException.java b/src/main/java/com/gg/server/global/exception/custom/BusinessException.java index 61d8c7ddc..0a1387d5c 100644 --- a/src/main/java/com/gg/server/global/exception/custom/BusinessException.java +++ b/src/main/java/com/gg/server/global/exception/custom/BusinessException.java @@ -2,12 +2,12 @@ import com.gg.server.global.exception.ErrorCode; -public class BusinessException extends CustomRuntimeException{ - public BusinessException(String message, ErrorCode errorCode) { - super(message, errorCode); - } +public class BusinessException extends CustomRuntimeException { + public BusinessException(String message, ErrorCode errorCode) { + super(message, errorCode); + } - public BusinessException(ErrorCode errorCode) { - super(errorCode.getMessage(), errorCode); - } + public BusinessException(ErrorCode errorCode) { + super(errorCode.getMessage(), errorCode); + } } diff --git a/src/main/java/com/gg/server/global/exception/custom/CustomRuntimeException.java b/src/main/java/com/gg/server/global/exception/custom/CustomRuntimeException.java index fea25749c..17b0f4b87 100644 --- a/src/main/java/com/gg/server/global/exception/custom/CustomRuntimeException.java +++ b/src/main/java/com/gg/server/global/exception/custom/CustomRuntimeException.java @@ -1,20 +1,21 @@ package com.gg.server.global.exception.custom; import com.gg.server.global.exception.ErrorCode; + import lombok.Getter; @Getter public class CustomRuntimeException extends RuntimeException { - private ErrorCode errorCode; + private ErrorCode errorCode; - public CustomRuntimeException(String message, ErrorCode errorCode) { - super(message); - this.errorCode = errorCode; - errorCode.setMessage(message); - } + public CustomRuntimeException(String message, ErrorCode errorCode) { + super(message); + this.errorCode = errorCode; + errorCode.setMessage(message); + } - public CustomRuntimeException(ErrorCode errorCode) { - super(errorCode.getMessage()); - this.errorCode = errorCode; - } + public CustomRuntimeException(ErrorCode errorCode) { + super(errorCode.getMessage()); + this.errorCode = errorCode; + } } diff --git a/src/main/java/com/gg/server/global/exception/custom/DBConsistencyException.java b/src/main/java/com/gg/server/global/exception/custom/DBConsistencyException.java index 5fdd937e5..96dfeaf01 100644 --- a/src/main/java/com/gg/server/global/exception/custom/DBConsistencyException.java +++ b/src/main/java/com/gg/server/global/exception/custom/DBConsistencyException.java @@ -1,11 +1,12 @@ package com.gg.server.global.exception.custom; import com.gg.server.global.exception.ErrorCode; + import lombok.Getter; @Getter public class DBConsistencyException extends CustomRuntimeException { - public DBConsistencyException(String message, ErrorCode errorCode) { - super(message, errorCode); - } + public DBConsistencyException(String message, ErrorCode errorCode) { + super(message, errorCode); + } } diff --git a/src/main/java/com/gg/server/global/exception/custom/DuplicationException.java b/src/main/java/com/gg/server/global/exception/custom/DuplicationException.java index c86f160e4..7e3495c0c 100644 --- a/src/main/java/com/gg/server/global/exception/custom/DuplicationException.java +++ b/src/main/java/com/gg/server/global/exception/custom/DuplicationException.java @@ -2,8 +2,8 @@ import com.gg.server.global.exception.ErrorCode; -public class DuplicationException extends CustomRuntimeException{ - public DuplicationException(String message, ErrorCode errorCode) { - super(message, errorCode); - } +public class DuplicationException extends CustomRuntimeException { + public DuplicationException(String message, ErrorCode errorCode) { + super(message, errorCode); + } } diff --git a/src/main/java/com/gg/server/global/exception/custom/ExpiredException.java b/src/main/java/com/gg/server/global/exception/custom/ExpiredException.java index 9931be239..dbc5b137e 100644 --- a/src/main/java/com/gg/server/global/exception/custom/ExpiredException.java +++ b/src/main/java/com/gg/server/global/exception/custom/ExpiredException.java @@ -2,8 +2,8 @@ import com.gg.server.global.exception.ErrorCode; -public class ExpiredException extends CustomRuntimeException{ - public ExpiredException(String message, ErrorCode errorCode) { - super(message, errorCode); - } +public class ExpiredException extends CustomRuntimeException { + public ExpiredException(String message, ErrorCode errorCode) { + super(message, errorCode); + } } diff --git a/src/main/java/com/gg/server/global/exception/custom/FileException.java b/src/main/java/com/gg/server/global/exception/custom/FileException.java index 4acf8d7ae..f6c86f2be 100644 --- a/src/main/java/com/gg/server/global/exception/custom/FileException.java +++ b/src/main/java/com/gg/server/global/exception/custom/FileException.java @@ -2,9 +2,9 @@ import com.gg.server.global.exception.ErrorCode; -public class FileException extends CustomRuntimeException{ +public class FileException extends CustomRuntimeException { - public FileException(String message, ErrorCode errorCode) { - super(message, errorCode); - } + public FileException(String message, ErrorCode errorCode) { + super(message, errorCode); + } } diff --git a/src/main/java/com/gg/server/global/exception/custom/ForbiddenException.java b/src/main/java/com/gg/server/global/exception/custom/ForbiddenException.java index bd2e5b10f..326c34991 100644 --- a/src/main/java/com/gg/server/global/exception/custom/ForbiddenException.java +++ b/src/main/java/com/gg/server/global/exception/custom/ForbiddenException.java @@ -2,8 +2,8 @@ import com.gg.server.global.exception.ErrorCode; -public class ForbiddenException extends CustomRuntimeException{ - public ForbiddenException(String message, ErrorCode errorCode) { - super(message, errorCode); - } +public class ForbiddenException extends CustomRuntimeException { + public ForbiddenException(String message, ErrorCode errorCode) { + super(message, errorCode); + } } diff --git a/src/main/java/com/gg/server/global/exception/custom/InvalidParameterException.java b/src/main/java/com/gg/server/global/exception/custom/InvalidParameterException.java index 763096c42..afd0ccfe0 100644 --- a/src/main/java/com/gg/server/global/exception/custom/InvalidParameterException.java +++ b/src/main/java/com/gg/server/global/exception/custom/InvalidParameterException.java @@ -1,10 +1,9 @@ package com.gg.server.global.exception.custom; import com.gg.server.global.exception.ErrorCode; -import lombok.Getter; -public class InvalidParameterException extends CustomRuntimeException{ - public InvalidParameterException(String message, ErrorCode errorCode) { - super(message, errorCode); - } +public class InvalidParameterException extends CustomRuntimeException { + public InvalidParameterException(String message, ErrorCode errorCode) { + super(message, errorCode); + } } diff --git a/src/main/java/com/gg/server/global/exception/custom/NotExistException.java b/src/main/java/com/gg/server/global/exception/custom/NotExistException.java index 718ec0753..845b1ae72 100644 --- a/src/main/java/com/gg/server/global/exception/custom/NotExistException.java +++ b/src/main/java/com/gg/server/global/exception/custom/NotExistException.java @@ -3,9 +3,9 @@ import com.gg.server.global.exception.ErrorCode; public class NotExistException extends CustomRuntimeException { - private ErrorCode errorCode; + private ErrorCode errorCode; - public NotExistException(String message, ErrorCode errorCode) { - super(message, errorCode); - } + public NotExistException(String message, ErrorCode errorCode) { + super(message, errorCode); + } } diff --git a/src/main/java/com/gg/server/global/exception/custom/PageNotFoundException.java b/src/main/java/com/gg/server/global/exception/custom/PageNotFoundException.java index 08b43d99b..0682d7c60 100644 --- a/src/main/java/com/gg/server/global/exception/custom/PageNotFoundException.java +++ b/src/main/java/com/gg/server/global/exception/custom/PageNotFoundException.java @@ -2,11 +2,12 @@ import com.gg.server.global.exception.ErrorCode; -public class PageNotFoundException extends CustomRuntimeException{ - public PageNotFoundException(String message, ErrorCode errorCode) { - super(message, errorCode); - } - public PageNotFoundException() { - super(ErrorCode.PAGE_NOT_FOUND.getMessage(), ErrorCode.PAGE_NOT_FOUND); - } +public class PageNotFoundException extends CustomRuntimeException { + public PageNotFoundException(String message, ErrorCode errorCode) { + super(message, errorCode); + } + + public PageNotFoundException() { + super(ErrorCode.PAGE_NOT_FOUND.getMessage(), ErrorCode.PAGE_NOT_FOUND); + } } diff --git a/src/main/java/com/gg/server/global/exception/custom/ParseException.java b/src/main/java/com/gg/server/global/exception/custom/ParseException.java index d945be9b0..6edfba853 100644 --- a/src/main/java/com/gg/server/global/exception/custom/ParseException.java +++ b/src/main/java/com/gg/server/global/exception/custom/ParseException.java @@ -3,7 +3,7 @@ import com.gg.server.global.exception.ErrorCode; public class ParseException extends CustomRuntimeException { - public ParseException(String message, ErrorCode errorCode) { - super(message, errorCode); - } + public ParseException(String message, ErrorCode errorCode) { + super(message, errorCode); + } } diff --git a/src/main/java/com/gg/server/global/exception/custom/SendException.java b/src/main/java/com/gg/server/global/exception/custom/SendException.java index 6707269c9..27ab5faf3 100644 --- a/src/main/java/com/gg/server/global/exception/custom/SendException.java +++ b/src/main/java/com/gg/server/global/exception/custom/SendException.java @@ -3,7 +3,7 @@ import com.gg.server.global.exception.ErrorCode; public class SendException extends CustomRuntimeException { - public SendException(String message, ErrorCode errorCode) { - super(message, errorCode); - } + public SendException(String message, ErrorCode errorCode) { + super(message, errorCode); + } } diff --git a/src/main/java/com/gg/server/global/log/aspect/TraceAspect.java b/src/main/java/com/gg/server/global/log/aspect/TraceAspect.java index f98b1fae5..2b5e26916 100644 --- a/src/main/java/com/gg/server/global/log/aspect/TraceAspect.java +++ b/src/main/java/com/gg/server/global/log/aspect/TraceAspect.java @@ -1,9 +1,7 @@ package com.gg.server.global.log.aspect; -import com.gg.server.global.log.domain.TraceStatus; -import com.gg.server.global.log.service.LogTrace; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; +import java.util.Arrays; + import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @@ -11,40 +9,50 @@ import org.aspectj.lang.reflect.MethodSignature; import org.springframework.stereotype.Component; -import java.util.Arrays; +import com.gg.server.global.log.domain.TraceStatus; +import com.gg.server.global.log.service.LogTrace; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; @Slf4j @Aspect @AllArgsConstructor @Component public class TraceAspect { - private final LogTrace logTrace; - - @Pointcut("execution(* com.gg.server.admin..*(..))") - public void allAdmin(){} - - @Pointcut("execution(* com.gg.server.domain..*(..))") - public void allDomain(){} - - @Pointcut("execution(* com.gg.server.global.security..*(..))") - public void securityDomain(){} - - @Pointcut("execution(* com.gg.server.global.scheduler..*(..))") - public void scheduler(){} - - @Around("(allAdmin() || allDomain() || scheduler()) && !securityDomain()") - public Object doLog(ProceedingJoinPoint joinPoint) throws Throwable { - TraceStatus status = null; - MethodSignature method = (MethodSignature)joinPoint.getSignature(); - Object[] methodArgs = joinPoint.getArgs(); - try{ - status = logTrace.begin(method.getDeclaringType().getSimpleName() + "." + method.getName() + "(): arguments = " + Arrays.toString(methodArgs)); - Object result = joinPoint.proceed(); - logTrace.end(status); - return result; - } catch (Exception e) { - logTrace.exception(status, e); - throw e; - } - } + private final LogTrace logTrace; + + @Pointcut("execution(* com.gg.server.admin..*(..))") + public void allAdmin() { + } + + @Pointcut("execution(* com.gg.server.domain..*(..))") + public void allDomain() { + } + + @Pointcut("execution(* com.gg.server.global.security..*(..))") + public void securityDomain() { + } + + @Pointcut("execution(* com.gg.server.global.scheduler..*(..))") + public void scheduler() { + } + + @Around("(allAdmin() || allDomain() || scheduler()) && !securityDomain()") + public Object doLog(ProceedingJoinPoint joinPoint) throws Throwable { + TraceStatus status = null; + MethodSignature method = (MethodSignature)joinPoint.getSignature(); + Object[] methodArgs = joinPoint.getArgs(); + try { + status = logTrace.begin( + method.getDeclaringType().getSimpleName() + "." + method.getName() + "(): arguments = " + + Arrays.toString(methodArgs)); + Object result = joinPoint.proceed(); + logTrace.end(status); + return result; + } catch (Exception e) { + logTrace.exception(status, e); + throw e; + } + } } diff --git a/src/main/java/com/gg/server/global/log/domain/TraceId.java b/src/main/java/com/gg/server/global/log/domain/TraceId.java index e5ef4195d..53985fe51 100644 --- a/src/main/java/com/gg/server/global/log/domain/TraceId.java +++ b/src/main/java/com/gg/server/global/log/domain/TraceId.java @@ -3,40 +3,40 @@ import java.util.UUID; public class TraceId { - private String id; - private int level; - - public TraceId() { - this.id = createId(); - this.level = 0; - } - - private TraceId(String id, int level) { - this.id = id; - this.level = level; - } - - private String createId() { - return UUID.randomUUID().toString().substring(0, 8); - } - - public TraceId createNextId() { - return new TraceId(id, level + 1); - } - - public TraceId createPreviousId() { - return new TraceId(id, level - 1); - } - - public boolean isFirstLevel() { - return level == 0; - } - - public String getId() { - return id; - } - - public int getLevel() { - return level; - } + private String id; + private int level; + + public TraceId() { + this.id = createId(); + this.level = 0; + } + + private TraceId(String id, int level) { + this.id = id; + this.level = level; + } + + private String createId() { + return UUID.randomUUID().toString().substring(0, 8); + } + + public TraceId createNextId() { + return new TraceId(id, level + 1); + } + + public TraceId createPreviousId() { + return new TraceId(id, level - 1); + } + + public boolean isFirstLevel() { + return level == 0; + } + + public String getId() { + return id; + } + + public int getLevel() { + return level; + } } diff --git a/src/main/java/com/gg/server/global/log/domain/TraceStatus.java b/src/main/java/com/gg/server/global/log/domain/TraceStatus.java index 4382d990b..8ccf90140 100644 --- a/src/main/java/com/gg/server/global/log/domain/TraceStatus.java +++ b/src/main/java/com/gg/server/global/log/domain/TraceStatus.java @@ -4,13 +4,13 @@ @Getter public class TraceStatus { - private TraceId traceId; - private Long startTimeMs; - private String message; + private TraceId traceId; + private Long startTimeMs; + private String message; - public TraceStatus(TraceId traceId, Long startTimeMs, String message) { - this.traceId = traceId; - this.startTimeMs = startTimeMs; - this.message = message; - } + public TraceStatus(TraceId traceId, Long startTimeMs, String message) { + this.traceId = traceId; + this.startTimeMs = startTimeMs; + this.message = message; + } } diff --git a/src/main/java/com/gg/server/global/log/pointcut/TracePointcut.java b/src/main/java/com/gg/server/global/log/pointcut/TracePointcut.java index 324274334..2033f77cb 100644 --- a/src/main/java/com/gg/server/global/log/pointcut/TracePointcut.java +++ b/src/main/java/com/gg/server/global/log/pointcut/TracePointcut.java @@ -3,14 +3,17 @@ import org.aspectj.lang.annotation.Pointcut; public class TracePointcut { - @Pointcut("execution(* com.gg.server.domain..*(..))") - public void allDomain(){} + @Pointcut("execution(* com.gg.server.domain..*(..))") + public void allDomain() { + } - //타입 패턴이 *Service - @Pointcut("execution(* *..*Service.*(..))") - public void allService(){} + //타입 패턴이 *Service + @Pointcut("execution(* *..*Service.*(..))") + public void allService() { + } - //allOrder && allService - @Pointcut("allDomain() && allService()") - public void orderAndService(){} + //allOrder && allService + @Pointcut("allDomain() && allService()") + public void orderAndService() { + } } diff --git a/src/main/java/com/gg/server/global/log/service/LogTrace.java b/src/main/java/com/gg/server/global/log/service/LogTrace.java index f8d4f1600..5c4a6436a 100644 --- a/src/main/java/com/gg/server/global/log/service/LogTrace.java +++ b/src/main/java/com/gg/server/global/log/service/LogTrace.java @@ -3,7 +3,9 @@ import com.gg.server.global.log.domain.TraceStatus; public interface LogTrace { - TraceStatus begin(String message); - void end(TraceStatus status); - void exception(TraceStatus status, Exception e); + TraceStatus begin(String message); + + void end(TraceStatus status); + + void exception(TraceStatus status, Exception ex); } diff --git a/src/main/java/com/gg/server/global/log/service/ThreadLocalLogTrace.java b/src/main/java/com/gg/server/global/log/service/ThreadLocalLogTrace.java index a7bab66cd..712b72ae9 100644 --- a/src/main/java/com/gg/server/global/log/service/ThreadLocalLogTrace.java +++ b/src/main/java/com/gg/server/global/log/service/ThreadLocalLogTrace.java @@ -1,75 +1,79 @@ package com.gg.server.global.log.service; +import org.springframework.stereotype.Component; + import com.gg.server.global.log.domain.TraceId; import com.gg.server.global.log.domain.TraceStatus; + import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; @Slf4j @Component public class ThreadLocalLogTrace implements LogTrace { - private static final String START_PREFIX = "-->"; - private static final String COMPLETE_PREFIX = "<--"; - private static final String EX_PREFIX = " traceIdHolder = new ThreadLocal<>(); + private ThreadLocal traceIdHolder = new ThreadLocal<>(); - public TraceStatus begin(String message) { - syncTraceId(); - TraceId logId = traceIdHolder.get(); - Long startTimeMs = System.currentTimeMillis(); - log.info("[{}] {}{}", logId.getId(), addSpace(START_PREFIX, logId.getLevel()), message); + public TraceStatus begin(String message) { + syncTraceId(); + TraceId logId = traceIdHolder.get(); + Long startTimeMs = System.currentTimeMillis(); + log.info("[{}] {}{}", logId.getId(), addSpace(START_PREFIX, logId.getLevel()), message); - return new TraceStatus(logId, startTimeMs, message); - } + return new TraceStatus(logId, startTimeMs, message); + } - public void end(TraceStatus status) { - complete(status, null); - } + public void end(TraceStatus status) { + complete(status, null); + } - public void exception(TraceStatus status, Exception e) { - if (status != null) { - complete(status, e); - } - } + public void exception(TraceStatus status, Exception exception) { + if (status != null) { + complete(status, exception); + } + } - private void complete(TraceStatus status, Exception e) { - Long stopTimeMs = System.currentTimeMillis(); - long resultTimeMs = stopTimeMs - status.getStartTimeMs(); - TraceId traceId = status.getTraceId(); - if (e == null) { - log.info("[{}] {}{} time={}ms", traceId.getId(), addSpace(COMPLETE_PREFIX, traceId.getLevel()), status.getMessage(), resultTimeMs); - } else { - log.info("[{}] {}{} time={}ms ex={}", traceId.getId(), addSpace(EX_PREFIX, traceId.getLevel()), status.getMessage(), resultTimeMs, e.toString()); - } + private void complete(TraceStatus status, Exception exception) { + Long stopTimeMs = System.currentTimeMillis(); + long resultTimeMs = stopTimeMs - status.getStartTimeMs(); + TraceId traceId = status.getTraceId(); + if (exception == null) { + log.info("[{}] {}{} time={}ms", traceId.getId(), addSpace(COMPLETE_PREFIX, traceId.getLevel()), + status.getMessage(), resultTimeMs); + } else { + log.info("[{}] {}{} time={}ms ex={}", traceId.getId(), addSpace(EX_PREFIX, traceId.getLevel()), + status.getMessage(), resultTimeMs, exception.toString()); + } - releaseTraceId(); - } + releaseTraceId(); + } - private void syncTraceId() { - TraceId traceId = traceIdHolder.get(); - if (traceId == null) { - traceIdHolder.set(new TraceId()); - } else { - traceIdHolder.set(traceId.createNextId()); - } - } + private void syncTraceId() { + TraceId traceId = traceIdHolder.get(); + if (traceId == null) { + traceIdHolder.set(new TraceId()); + } else { + traceIdHolder.set(traceId.createNextId()); + } + } - private void releaseTraceId() { - TraceId traceId = traceIdHolder.get(); - if (traceId.isFirstLevel()) { - traceIdHolder.remove();//destroy - } else { - traceIdHolder.set(traceId.createPreviousId()); - } - } + private void releaseTraceId() { + TraceId traceId = traceIdHolder.get(); + if (traceId.isFirstLevel()) { + traceIdHolder.remove(); + } else { + traceIdHolder.set(traceId.createPreviousId()); + } + } - private static String addSpace(String prefix, int level) { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < level; i++) { - sb.append( (i == level - 1) ? "|" + prefix : "| "); - } - return sb.toString(); - } + private static String addSpace(String prefix, int level) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < level; i++) { + sb.append((i == level - 1) ? "|" + prefix : "| "); + } + return sb.toString(); + } } diff --git a/src/main/java/com/gg/server/global/scheduler/AbstractScheduler.java b/src/main/java/com/gg/server/global/scheduler/AbstractScheduler.java index b731faf9c..2d8cc0073 100644 --- a/src/main/java/com/gg/server/global/scheduler/AbstractScheduler.java +++ b/src/main/java/com/gg/server/global/scheduler/AbstractScheduler.java @@ -1,48 +1,49 @@ package com.gg.server.global.scheduler; -import lombok.Getter; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; + import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.scheduling.support.CronTrigger; -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; +import lombok.Getter; public abstract class AbstractScheduler { - private ThreadPoolTaskScheduler scheduler; - @Getter - protected String cron; - @Getter - protected Integer interval; - - public abstract Runnable runnable(); - - public void renewScheduler() { - scheduler.shutdown(); - startScheduler(); - } - - protected void setCron(String cron) { - this.cron = cron; - } - - protected void setInterval(Integer interval) { - this.interval = interval; - } - - @PostConstruct - public void init() { - startScheduler(); - } - - @PreDestroy - public void destroy() { - scheduler.shutdown(); - } - - private void startScheduler() { - scheduler = new ThreadPoolTaskScheduler(); - scheduler.setPoolSize(4); - scheduler.initialize(); - scheduler.schedule(this.runnable(), new CronTrigger(cron)); - } + private ThreadPoolTaskScheduler scheduler; + @Getter + protected String cron; + @Getter + protected Integer interval; + + public abstract Runnable runnable(); + + public void renewScheduler() { + scheduler.shutdown(); + startScheduler(); + } + + protected void setCron(String cron) { + this.cron = cron; + } + + protected void setInterval(Integer interval) { + this.interval = interval; + } + + @PostConstruct + public void init() { + startScheduler(); + } + + @PreDestroy + public void destroy() { + scheduler.shutdown(); + } + + private void startScheduler() { + scheduler = new ThreadPoolTaskScheduler(); + scheduler.setPoolSize(4); + scheduler.initialize(); + scheduler.schedule(this.runnable(), new CronTrigger(cron)); + } } diff --git a/src/main/java/com/gg/server/global/scheduler/GameStatusScheduler.java b/src/main/java/com/gg/server/global/scheduler/GameStatusScheduler.java index 5b152ceff..04204674d 100644 --- a/src/main/java/com/gg/server/global/scheduler/GameStatusScheduler.java +++ b/src/main/java/com/gg/server/global/scheduler/GameStatusScheduler.java @@ -1,29 +1,31 @@ package com.gg.server.global.scheduler; +import org.springframework.stereotype.Component; + import com.gg.server.domain.game.service.GameStatusService; + import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; @Component @Slf4j -public class GameStatusScheduler extends AbstractScheduler{ - private final GameStatusService gameStatusService; +public class GameStatusScheduler extends AbstractScheduler { + private final GameStatusService gameStatusService; - public GameStatusScheduler(GameStatusService gameStatusService) { - this.gameStatusService = gameStatusService; - this.setCron("0 */5 * * * *"); - } + public GameStatusScheduler(GameStatusService gameStatusService) { + this.gameStatusService = gameStatusService; + this.setCron("0 */5 * * * *"); + } - @Override - public Runnable runnable() { - return () -> { - log.info("GameStatusScheduler start"); - // BEFORE -> LIVE - gameStatusService.updateBeforeToLiveStatus(); - // LIVE -> WAIT - gameStatusService.updateLiveToWaitStatus(); - // imminent Noti - gameStatusService.imminentGame(); - }; - } + @Override + public Runnable runnable() { + return () -> { + log.info("GameStatusScheduler start"); + // BEFORE -> LIVE + gameStatusService.updateBeforeToLiveStatus(); + // LIVE -> WAIT + gameStatusService.updateLiveToWaitStatus(); + // imminent Noti + gameStatusService.imminentGame(); + }; + } } diff --git a/src/main/java/com/gg/server/global/scheduler/MegaphoneScheduler.java b/src/main/java/com/gg/server/global/scheduler/MegaphoneScheduler.java index e814d0981..ed98c5548 100644 --- a/src/main/java/com/gg/server/global/scheduler/MegaphoneScheduler.java +++ b/src/main/java/com/gg/server/global/scheduler/MegaphoneScheduler.java @@ -1,26 +1,28 @@ package com.gg.server.global.scheduler; -import com.gg.server.domain.megaphone.service.MegaphoneService; -import lombok.extern.slf4j.Slf4j; +import java.time.LocalDate; + import org.springframework.stereotype.Component; -import java.time.LocalDate; +import com.gg.server.domain.megaphone.service.MegaphoneService; + +import lombok.extern.slf4j.Slf4j; @Component @Slf4j public class MegaphoneScheduler extends AbstractScheduler { - private final MegaphoneService megaphoneService; + private final MegaphoneService megaphoneService; - public MegaphoneScheduler(MegaphoneService megaphoneService) { - this.megaphoneService = megaphoneService; - this.setCron("0 59 23 * * *"); - } + public MegaphoneScheduler(MegaphoneService megaphoneService) { + this.megaphoneService = megaphoneService; + this.setCron("0 59 23 * * *"); + } - @Override - public Runnable runnable() { - return () -> { - log.info("Set Megaphone List "); - megaphoneService.setMegaphoneList(LocalDate.now()); - }; - } + @Override + public Runnable runnable() { + return () -> { + log.info("Set Megaphone List "); + megaphoneService.setMegaphoneList(LocalDate.now()); + }; + } } diff --git a/src/main/java/com/gg/server/global/scheduler/TournamentScheduler.java b/src/main/java/com/gg/server/global/scheduler/TournamentScheduler.java index 3765a137e..d6a9ed249 100644 --- a/src/main/java/com/gg/server/global/scheduler/TournamentScheduler.java +++ b/src/main/java/com/gg/server/global/scheduler/TournamentScheduler.java @@ -1,28 +1,30 @@ package com.gg.server.global.scheduler; +import org.springframework.stereotype.Component; + import com.gg.server.domain.tournament.service.TournamentService; import com.gg.server.global.config.ConstantConfig; + import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; @Component @Slf4j public class TournamentScheduler extends AbstractScheduler { - private final TournamentService tournamentService; + private final TournamentService tournamentService; - private final ConstantConfig constantConfig; + private final ConstantConfig constantConfig; - public TournamentScheduler(TournamentService tournamentService, ConstantConfig constantConfig) { - this.tournamentService = tournamentService; - this.constantConfig = constantConfig; - this.cron = constantConfig.getTournamentSchedule(); // TODO QA 이후 0 0 0 * * * 로 변경 - } + public TournamentScheduler(TournamentService tournamentService, ConstantConfig constantConfig) { + this.tournamentService = tournamentService; + this.constantConfig = constantConfig; + this.cron = constantConfig.getTournamentSchedule(); // TODO QA 이후 0 0 0 * * * 로 변경 + } - @Override - public Runnable runnable() { - return () -> { - log.info("Tournament Scheduler Started"); - tournamentService.startTournament(); - }; - } + @Override + public Runnable runnable() { + return () -> { + log.info("Tournament Scheduler Started"); + tournamentService.startTournament(); + }; + } } diff --git a/src/main/java/com/gg/server/global/security/UserPrincipal.java b/src/main/java/com/gg/server/global/security/UserPrincipal.java index 30eb2236e..92c4c9f81 100644 --- a/src/main/java/com/gg/server/global/security/UserPrincipal.java +++ b/src/main/java/com/gg/server/global/security/UserPrincipal.java @@ -1,81 +1,86 @@ -package com.gg.server.global.security; - -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RoleType; -import lombok.Getter; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.oauth2.core.user.OAuth2User; - -import java.util.*; - -@Getter -public class UserPrincipal implements OAuth2User, UserDetails { - private final Long id; - private final String nickname; - private final Collection authorities; - private Map attributes; - - public UserPrincipal(Long id, String nickname, Collection authorities) { - this.id = id; - this.nickname = nickname; - this.authorities = authorities; - } - - public static UserPrincipal create(User user) { - List authorities = new ArrayList<>(); - if (user.getRoleType().getKey().equals("ROLE_USER")) { - authorities.add(new SimpleGrantedAuthority(RoleType.USER.getKey())); - } else if (user.getRoleType().getKey().equals("ROLE_ADMIN")) { - authorities.add(new SimpleGrantedAuthority(RoleType.USER.getKey())); - authorities.add(new SimpleGrantedAuthority(RoleType.ADMIN.getKey())); - } - return new UserPrincipal(user.getId(), user.getIntraId(), authorities); - } - - public static UserPrincipal create(User user, Map attributes) { - UserPrincipal userPrincipal = UserPrincipal.create(user); - userPrincipal.setAttributes(attributes); - return userPrincipal; - } - - public void setAttributes(Map attributes) { - this.attributes = attributes; - } - - @Override - public String getPassword() { - return null; - } - - @Override - public String getUsername() { - return nickname; - } - - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - return true; - } - - @Override - public boolean isEnabled() { - return true; - } - - @Override - public String getName() { - return String.valueOf(id); - } -} \ No newline at end of file +package com.gg.server.global.security; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.oauth2.core.user.OAuth2User; + +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.type.RoleType; + +import lombok.Getter; + +@Getter +public class UserPrincipal implements OAuth2User, UserDetails { + private final Long id; + private final String nickname; + private final Collection authorities; + private Map attributes; + + public UserPrincipal(Long id, String nickname, Collection authorities) { + this.id = id; + this.nickname = nickname; + this.authorities = authorities; + } + + public static UserPrincipal create(User user) { + List authorities = new ArrayList<>(); + if (user.getRoleType().getKey().equals("ROLE_USER")) { + authorities.add(new SimpleGrantedAuthority(RoleType.USER.getKey())); + } else if (user.getRoleType().getKey().equals("ROLE_ADMIN")) { + authorities.add(new SimpleGrantedAuthority(RoleType.USER.getKey())); + authorities.add(new SimpleGrantedAuthority(RoleType.ADMIN.getKey())); + } + return new UserPrincipal(user.getId(), user.getIntraId(), authorities); + } + + public static UserPrincipal create(User user, Map attributes) { + UserPrincipal userPrincipal = UserPrincipal.create(user); + userPrincipal.setAttributes(attributes); + return userPrincipal; + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + + @Override + public String getPassword() { + return null; + } + + @Override + public String getUsername() { + return nickname; + } + + @Override + public boolean isAccountNonExpired() { + return true; + } + + @Override + public boolean isAccountNonLocked() { + return true; + } + + @Override + public boolean isCredentialsNonExpired() { + return true; + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public String getName() { + return String.valueOf(id); + } +} diff --git a/src/main/java/com/gg/server/global/security/config/RestAuthenticationEntryPoint.java b/src/main/java/com/gg/server/global/security/config/RestAuthenticationEntryPoint.java index f5bb19733..6d5f37d26 100644 --- a/src/main/java/com/gg/server/global/security/config/RestAuthenticationEntryPoint.java +++ b/src/main/java/com/gg/server/global/security/config/RestAuthenticationEntryPoint.java @@ -1,26 +1,28 @@ package com.gg.server.global.security.config; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.web.AuthenticationEntryPoint; +import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; + +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; + +import lombok.extern.slf4j.Slf4j; @Slf4j public class RestAuthenticationEntryPoint implements AuthenticationEntryPoint { - @Override - public void commence( - HttpServletRequest request, - HttpServletResponse response, - AuthenticationException authException - ) throws IOException { - authException.printStackTrace(); - log.info("Responding with unauthorized error. Message := {}", authException.getMessage()); - response.sendError( - HttpServletResponse.SC_UNAUTHORIZED, - authException.getLocalizedMessage() - ); - } -} \ No newline at end of file + @Override + public void commence( + HttpServletRequest request, + HttpServletResponse response, + AuthenticationException authException + ) throws IOException { + authException.printStackTrace(); + log.info("Responding with unauthorized error. Message := {}", authException.getMessage()); + response.sendError( + HttpServletResponse.SC_UNAUTHORIZED, + authException.getLocalizedMessage() + ); + } +} diff --git a/src/main/java/com/gg/server/global/security/config/SecurityConfig.java b/src/main/java/com/gg/server/global/security/config/SecurityConfig.java index 599af2108..6b9bb0710 100644 --- a/src/main/java/com/gg/server/global/security/config/SecurityConfig.java +++ b/src/main/java/com/gg/server/global/security/config/SecurityConfig.java @@ -1,11 +1,7 @@ package com.gg.server.global.security.config; -import com.gg.server.global.security.config.properties.CorsProperties; -import com.gg.server.global.security.handler.OAuthAuthenticationSuccessHandler; -import com.gg.server.global.security.jwt.utils.TokenAuthenticationFilter; -import com.gg.server.global.security.repository.OAuthAuthorizationRequestBasedOnCookieRepository; -import com.gg.server.global.security.service.CustomUserDetailsService; -import lombok.RequiredArgsConstructor; +import java.util.Arrays; + import org.springframework.context.annotation.Bean; import org.springframework.http.HttpMethod; import org.springframework.security.authentication.AuthenticationManager; @@ -18,74 +14,80 @@ import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; -import java.util.Arrays; +import com.gg.server.global.security.config.properties.CorsProperties; +import com.gg.server.global.security.handler.OAuthAuthenticationSuccessHandler; +import com.gg.server.global.security.jwt.utils.TokenAuthenticationFilter; +import com.gg.server.global.security.repository.OAuthAuthorizationRequestBasedOnCookieRepository; +import com.gg.server.global.security.service.CustomUserDetailsService; + +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { - private final CustomUserDetailsService userDetailsService; - private final OAuthAuthenticationSuccessHandler oAuth2AuthenticationSuccessHandler; - private final CorsProperties corsProperties; - private final TokenAuthenticationFilter tokenAuthenticationFilter; - private final OAuthAuthorizationRequestBasedOnCookieRepository oAuth2AuthorizationRequestBasedOnCookieRepository; + private final CustomUserDetailsService userDetailsService; + private final OAuthAuthenticationSuccessHandler oAuth2AuthenticationSuccessHandler; + private final CorsProperties corsProperties; + private final TokenAuthenticationFilter tokenAuthenticationFilter; + private final OAuthAuthorizationRequestBasedOnCookieRepository oAuth2AuthorizationRequestBasedOnCookieRepository; - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.userDetailsService(userDetailsService); - } + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.userDetailsService(userDetailsService); + } - @Bean - @Override - public AuthenticationManager authenticationManagerBean() throws Exception { - return super.authenticationManagerBean(); - } + @Bean + @Override + public AuthenticationManager authenticationManagerBean() throws Exception { + return super.authenticationManagerBean(); + } - @Override - protected void configure(HttpSecurity http) throws Exception { - http - .cors() - .and() - .sessionManagement() - .sessionCreationPolicy(SessionCreationPolicy.STATELESS) - .and() - .authorizeRequests() - .antMatchers("/pingpong/admin/**").hasRole("ADMIN") - .antMatchers(HttpMethod.PUT, "/pingpong/users/{intraId}").hasAnyRole("USER", "ADMIN") - .antMatchers(HttpMethod.POST, "/pingpong/match").hasAnyRole("USER", "ADMIN") - .antMatchers(HttpMethod.POST, "/pingpong/tournaments/{tournamentId}/users").hasAnyRole("USER", "ADMIN") - .antMatchers("/login", "/oauth2/authorization/**", "/","/pingpong/users/oauth/**", - "/pingpong/users/accesstoken", "/actuator/**", - "/swagger-ui/**", "/swagger-ui**", "/v3/api-docs/**", "/v3/api-docs**", "/api-docs").permitAll() - .anyRequest().authenticated() - .and() - .csrf().disable() - .formLogin().disable() - .httpBasic().disable() - .exceptionHandling() - .authenticationEntryPoint(new RestAuthenticationEntryPoint()) - .and() - .oauth2Login() - .authorizationEndpoint() - .baseUri("/oauth2/authorization") - .authorizationRequestRepository(oAuth2AuthorizationRequestBasedOnCookieRepository) - .and() - .successHandler(oAuth2AuthenticationSuccessHandler); + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .cors() + .and() + .sessionManagement() + .sessionCreationPolicy(SessionCreationPolicy.STATELESS) + .and() + .authorizeRequests() + .antMatchers("/pingpong/admin/**").hasRole("ADMIN") + .antMatchers(HttpMethod.PUT, "/pingpong/users/{intraId}").hasAnyRole("USER", "ADMIN") + .antMatchers(HttpMethod.POST, "/pingpong/match").hasAnyRole("USER", "ADMIN") + .antMatchers(HttpMethod.POST, "/pingpong/tournaments/{tournamentId}/users").hasAnyRole("USER", "ADMIN") + .antMatchers("/login", "/oauth2/authorization/**", "/", "/pingpong/users/oauth/**", + "/pingpong/users/accesstoken", "/actuator/**", + "/swagger-ui/**", "/swagger-ui**", "/v3/api-docs/**", "/v3/api-docs**", "/api-docs").permitAll() + .anyRequest().authenticated() + .and() + .csrf().disable() + .formLogin().disable() + .httpBasic().disable() + .exceptionHandling() + .authenticationEntryPoint(new RestAuthenticationEntryPoint()) + .and() + .oauth2Login() + .authorizationEndpoint() + .baseUri("/oauth2/authorization") + .authorizationRequestRepository(oAuth2AuthorizationRequestBasedOnCookieRepository) + .and() + .successHandler(oAuth2AuthenticationSuccessHandler); - http.addFilterBefore(tokenAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); - } + http.addFilterBefore(tokenAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); + } - @Bean - public UrlBasedCorsConfigurationSource corsConfigurationSource() { - UrlBasedCorsConfigurationSource corsConfigSource = new UrlBasedCorsConfigurationSource(); - CorsConfiguration corsConfig = new CorsConfiguration(); - corsConfig.setAllowedHeaders(Arrays.asList(corsProperties.getAllowedHeaders().split(","))); - corsConfig.setAllowedMethods(Arrays.asList(corsProperties.getAllowedMethods().split(","))); - corsConfig.setAllowedOrigins(Arrays.asList(corsProperties.getAllowedOrigins().split(","))); - corsConfig.setAllowCredentials(true); - corsConfig.setMaxAge(corsConfig.getMaxAge()); - corsConfigSource.registerCorsConfiguration("/**", corsConfig); - return corsConfigSource; - } + @Bean + public UrlBasedCorsConfigurationSource corsConfigurationSource() { + UrlBasedCorsConfigurationSource corsConfigSource = new UrlBasedCorsConfigurationSource(); + CorsConfiguration corsConfig = new CorsConfiguration(); + corsConfig.setAllowedHeaders(Arrays.asList(corsProperties.getAllowedHeaders().split(","))); + corsConfig.setAllowedMethods(Arrays.asList(corsProperties.getAllowedMethods().split(","))); + corsConfig.setAllowedOrigins(Arrays.asList(corsProperties.getAllowedOrigins().split(","))); + corsConfig.setAllowCredentials(true); + corsConfig.setMaxAge(corsConfig.getMaxAge()); + corsConfigSource.registerCorsConfiguration("/**", corsConfig); + return corsConfigSource; + } } diff --git a/src/main/java/com/gg/server/global/security/config/properties/AppProperties.java b/src/main/java/com/gg/server/global/security/config/properties/AppProperties.java index c713878f4..4b38ee69b 100644 --- a/src/main/java/com/gg/server/global/security/config/properties/AppProperties.java +++ b/src/main/java/com/gg/server/global/security/config/properties/AppProperties.java @@ -1,44 +1,45 @@ package com.gg.server.global.security.config.properties; +import java.util.ArrayList; +import java.util.List; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -import java.util.ArrayList; -import java.util.List; @Getter @Configuration @ConfigurationProperties(prefix = "app") public class AppProperties { - private final Auth auth = new Auth(); - private final OAuth2 oauth2 = new OAuth2(); - - @Getter - @Setter - @NoArgsConstructor - @AllArgsConstructor - public static class Auth { - private String tokenSecret; - private String refreshTokenSecret; - private long tokenExpiry; - private long refreshTokenExpiry; - } - - public static final class OAuth2 { - private List authorizedRedirectUris = new ArrayList<>(); - - public List getAuthorizedRedirectUris() { - return authorizedRedirectUris; - } - - public OAuth2 authorizedRedirectUris(List authorizedRedirectUris) { - this.authorizedRedirectUris = authorizedRedirectUris; - return this; - } - } + private final Auth auth = new Auth(); + private final OAuth2 oauth2 = new OAuth2(); + + @Getter + @Setter + @NoArgsConstructor + @AllArgsConstructor + public static class Auth { + private String tokenSecret; + private String refreshTokenSecret; + private long tokenExpiry; + private long refreshTokenExpiry; + } + + public static final class OAuth2 { + private List authorizedRedirectUris = new ArrayList<>(); + + public List getAuthorizedRedirectUris() { + return authorizedRedirectUris; + } + + public OAuth2 authorizedRedirectUris(List authorizedRedirectUris) { + this.authorizedRedirectUris = authorizedRedirectUris; + return this; + } + } } diff --git a/src/main/java/com/gg/server/global/security/config/properties/CorsProperties.java b/src/main/java/com/gg/server/global/security/config/properties/CorsProperties.java index 097d77d5f..4efc120f1 100644 --- a/src/main/java/com/gg/server/global/security/config/properties/CorsProperties.java +++ b/src/main/java/com/gg/server/global/security/config/properties/CorsProperties.java @@ -1,17 +1,18 @@ package com.gg.server.global.security.config.properties; -import lombok.Getter; -import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; +import lombok.Getter; +import lombok.Setter; + @Getter @Setter @Configuration @ConfigurationProperties(prefix = "cors") public class CorsProperties { - private String allowedOrigins; - private String allowedMethods; - private String allowedHeaders; - private Long maxAge; + private String allowedOrigins; + private String allowedMethods; + private String allowedHeaders; + private Long maxAge; } diff --git a/src/main/java/com/gg/server/global/security/cookie/CookieUtil.java b/src/main/java/com/gg/server/global/security/cookie/CookieUtil.java index ea837e543..db23b1ce3 100644 --- a/src/main/java/com/gg/server/global/security/cookie/CookieUtil.java +++ b/src/main/java/com/gg/server/global/security/cookie/CookieUtil.java @@ -1,89 +1,90 @@ package com.gg.server.global.security.cookie; +import java.util.Base64; +import java.util.Optional; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; -import com.gg.server.global.security.config.properties.AppProperties; -import com.gg.server.global.utils.ApplicationYmlRead; -import lombok.RequiredArgsConstructor; -import org.springframework.boot.web.server.Cookie.SameSite; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseCookie; import org.springframework.stereotype.Component; import org.springframework.util.SerializationUtils; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.Base64; -import java.util.Optional; +import com.gg.server.global.utils.ApplicationYmlRead; + +import lombok.RequiredArgsConstructor; @Component @RequiredArgsConstructor public class CookieUtil { - private final ApplicationYmlRead applicationYmlRead; - - public Optional getCookie(HttpServletRequest request, String name) { - Cookie[] cookies = request.getCookies(); - - if (cookies != null && cookies.length > 0) { - for (Cookie cookie : cookies) { - if (name.equals(cookie.getName())) { - return Optional.of(cookie); - } - } - } - return Optional.empty(); - } - - public void addCookie(HttpServletResponse response, String name, String value, int maxAge) { - String domain = applicationYmlRead.getDomain(); - ResponseCookie cookie = ResponseCookie.from(name, value) - .maxAge(maxAge) - .domain(domain) - .httpOnly(false) - .path("/") - .secure(true) - .build(); - response.addHeader(HttpHeaders.SET_COOKIE, cookie.toString()); - } - public void deleteCookie(HttpServletResponse response, String name) { - String domain = applicationYmlRead.getDomain(); - ResponseCookie cookie = ResponseCookie.from(name, null) - .maxAge(0) - .domain(domain) - .httpOnly(false) - .path("/") - .secure(true) - .build(); - response.addHeader(HttpHeaders.SET_COOKIE, cookie.toString()); - } - - public void deleteCookie(HttpServletRequest request, HttpServletResponse response, String name) { - Cookie[] cookies = request.getCookies(); - - if (cookies != null && cookies.length > 0) { - for (Cookie cookie : cookies) { - if (name.equals(cookie.getName())) { - cookie.setValue(""); - cookie.setPath("/"); - cookie.setMaxAge(0); - response.addCookie(cookie); - } - } - } - } - - public String serialize(Object obj) { - return Base64.getUrlEncoder() - .encodeToString(SerializationUtils.serialize(obj)); - } - - public T deserialize(Cookie cookie, Class cls) { - return cls.cast( - SerializationUtils.deserialize( - Base64.getUrlDecoder().decode(cookie.getValue()) - ) - ); - } + private final ApplicationYmlRead applicationYmlRead; + + public Optional getCookie(HttpServletRequest request, String name) { + Cookie[] cookies = request.getCookies(); + + if (cookies != null && cookies.length > 0) { + for (Cookie cookie : cookies) { + if (name.equals(cookie.getName())) { + return Optional.of(cookie); + } + } + } + return Optional.empty(); + } + + public void addCookie(HttpServletResponse response, String name, String value, int maxAge) { + String domain = applicationYmlRead.getDomain(); + ResponseCookie cookie = ResponseCookie.from(name, value) + .maxAge(maxAge) + .domain(domain) + .httpOnly(false) + .path("/") + .secure(true) + .build(); + response.addHeader(HttpHeaders.SET_COOKIE, cookie.toString()); + } + + public void deleteCookie(HttpServletResponse response, String name) { + String domain = applicationYmlRead.getDomain(); + ResponseCookie cookie = ResponseCookie.from(name, null) + .maxAge(0) + .domain(domain) + .httpOnly(false) + .path("/") + .secure(true) + .build(); + response.addHeader(HttpHeaders.SET_COOKIE, cookie.toString()); + } + + public void deleteCookie(HttpServletRequest request, HttpServletResponse response, String name) { + Cookie[] cookies = request.getCookies(); + + if (cookies != null && cookies.length > 0) { + for (Cookie cookie : cookies) { + if (name.equals(cookie.getName())) { + cookie.setValue(""); + cookie.setPath("/"); + cookie.setMaxAge(0); + response.addCookie(cookie); + } + } + } + } + + public String serialize(Object obj) { + return Base64.getUrlEncoder() + .encodeToString(SerializationUtils.serialize(obj)); + } + + public T deserialize(Cookie cookie, Class cls) { + return cls.cast( + SerializationUtils.deserialize( + Base64.getUrlDecoder().decode(cookie.getValue()) + ) + ); + } } diff --git a/src/main/java/com/gg/server/global/security/handler/OAuthAuthenticationSuccessHandler.java b/src/main/java/com/gg/server/global/security/handler/OAuthAuthenticationSuccessHandler.java index 50bcf8a21..61b5d38be 100644 --- a/src/main/java/com/gg/server/global/security/handler/OAuthAuthenticationSuccessHandler.java +++ b/src/main/java/com/gg/server/global/security/handler/OAuthAuthenticationSuccessHandler.java @@ -1,130 +1,132 @@ package com.gg.server.global.security.handler; +import java.io.IOException; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.util.UriComponentsBuilder; + import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.exception.UserNotFoundException; import com.gg.server.domain.user.type.RoleType; import com.gg.server.global.security.UserPrincipal; -import com.gg.server.global.security.cookie.CookieUtil; import com.gg.server.global.security.config.properties.AppProperties; +import com.gg.server.global.security.cookie.CookieUtil; import com.gg.server.global.security.jwt.repository.JwtRedisRepository; -import com.gg.server.global.security.jwt.utils.TokenHeaders; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.global.security.jwt.utils.TokenHeaders; import com.gg.server.global.utils.ApplicationYmlRead; -import javax.servlet.http.Cookie; -import lombok.RequiredArgsConstructor; -import org.springframework.security.core.Authentication; -import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.util.UriComponentsBuilder; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; +import lombok.RequiredArgsConstructor; @Component @RequiredArgsConstructor public class OAuthAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler { - private final JwtRedisRepository jwtRedisRepository; - private final UserRepository userRepository; - private final AuthTokenProvider tokenProvider; - private final AppProperties appProperties; - private final ApplicationYmlRead applicationYmlRead; - private final CookieUtil cookieUtil; - - @Transactional - @Override - public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, - Authentication authentication) throws IOException { - String targetUrl; - try{ - targetUrl = determineTargetUrl(request, response, authentication); - } catch (Exception e) { - targetUrl = applicationYmlRead.getFrontUrl(); - } - - if (response.isCommitted()) { - logger.debug("Response has already been committed. Unable to redirect to " + targetUrl); - return; - } - clearAuthenticationAttributes(request, response); - getRedirectStrategy().sendRedirect(request, response, targetUrl); - } - - @Override - protected String determineTargetUrl(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { - - UserPrincipal principal = (UserPrincipal) authentication.getPrincipal(); - Cookie[] cookies = request.getCookies(); - for (Cookie cookie :cookies) { - if (cookie.getName().equals(TokenHeaders.REFRESH_TOKEN) ) { - Long existUserId = jwtRedisRepository.getUserIdFromRefToken(cookie.getValue()); - if (existUserId != null && !existUserId.equals(principal.getId())) { - jwtRedisRepository.deleteRefToken(cookie.getValue()); - return deleteKakaoUser(existUserId, response, authentication); - } - } - } - - // 쿠키 시간 설정 - long refreshTokenExpiry = appProperties.getAuth().getRefreshTokenExpiry(); - - // token 설정 - String accessToken = tokenProvider.createToken(principal.getId()); - String refreshToken = tokenProvider.refreshToken(principal.getId()); - - cookieUtil.addCookie(response, TokenHeaders.REFRESH_TOKEN, refreshToken, - (int)(refreshTokenExpiry / 1000)); - - jwtRedisRepository.addRefToken(refreshToken, refreshTokenExpiry, principal.getId()); - return UriComponentsBuilder.fromUriString(applicationYmlRead.getFrontUrl()) - .queryParam("token", accessToken) - .build().toUriString(); - } - - private String deleteKakaoUser(Long existUserId, HttpServletResponse response, Authentication authentication) { - UserPrincipal principal = (UserPrincipal) authentication.getPrincipal(); - User existUser = userRepository.findById(existUserId).orElseThrow(UserNotFoundException::new); - User newUser = userRepository.findById(principal.getId()).orElseThrow(UserNotFoundException::new); - //kakao 계정 사용자가 42 인증 - if (existUser.getRoleType().equals(RoleType.GUEST)) { - return UriComponentsBuilder.fromUriString(applicationYmlRead.getFrontUrl() + "/users/detail") - .queryParam("intraId", newUser.getIntraId()) - .queryParam("token", saveAndGetUserAccessToken(response, newUser, existUser)) - .build().toUriString(); - } - //기존 user 사용자가 카카오 인증 - if (newUser.getRoleType().equals(RoleType.GUEST)) { - return UriComponentsBuilder.fromUriString(applicationYmlRead.getFrontUrl() + "/users/detail") - .queryParam("intraId", existUser.getIntraId()) - .queryParam("token", saveAndGetUserAccessToken(response, existUser, newUser)) - .build().toUriString(); - } - throw new UserNotFoundException(); - } - - - private String saveAndGetUserAccessToken(HttpServletResponse response, - User remainedUser, User deletedUser) { - remainedUser.updateKakaoId(deletedUser.getKakaoId()); - // 쿠키 시간 설정 - long refreshTokenExpiry = appProperties.getAuth().getRefreshTokenExpiry(); - userRepository.delete(deletedUser); - - // token 설정 - String accessToken = tokenProvider.createToken(remainedUser.getId()); - String refreshToken = tokenProvider.refreshToken(remainedUser.getId()); - jwtRedisRepository.addRefToken(refreshToken, refreshTokenExpiry, remainedUser.getId()); - - cookieUtil.addCookie(response, TokenHeaders.REFRESH_TOKEN, refreshToken, - (int)(refreshTokenExpiry / 1000)); - return accessToken; - } - - private void clearAuthenticationAttributes(HttpServletRequest request, HttpServletResponse response) { - super.clearAuthenticationAttributes(request); - } - + private final JwtRedisRepository jwtRedisRepository; + private final UserRepository userRepository; + private final AuthTokenProvider tokenProvider; + private final AppProperties appProperties; + private final ApplicationYmlRead applicationYmlRead; + private final CookieUtil cookieUtil; + + @Transactional + @Override + public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, + Authentication authentication) throws IOException { + String targetUrl; + try { + targetUrl = determineTargetUrl(request, response, authentication); + } catch (Exception e) { + targetUrl = applicationYmlRead.getFrontUrl(); + } + + if (response.isCommitted()) { + logger.debug("Response has already been committed. Unable to redirect to " + targetUrl); + return; + } + clearAuthenticationAttributes(request, response); + getRedirectStrategy().sendRedirect(request, response, targetUrl); + } + + @Override + protected String determineTargetUrl(HttpServletRequest request, HttpServletResponse response, + Authentication authentication) { + + UserPrincipal principal = (UserPrincipal)authentication.getPrincipal(); + Cookie[] cookies = request.getCookies(); + for (Cookie cookie : cookies) { + if (cookie.getName().equals(TokenHeaders.REFRESH_TOKEN)) { + Long existUserId = jwtRedisRepository.getUserIdFromRefToken(cookie.getValue()); + if (existUserId != null && !existUserId.equals(principal.getId())) { + jwtRedisRepository.deleteRefToken(cookie.getValue()); + return deleteKakaoUser(existUserId, response, authentication); + } + } + } + + // 쿠키 시간 설정 + long refreshTokenExpiry = appProperties.getAuth().getRefreshTokenExpiry(); + + // token 설정 + String accessToken = tokenProvider.createToken(principal.getId()); + String refreshToken = tokenProvider.refreshToken(principal.getId()); + + cookieUtil.addCookie(response, TokenHeaders.REFRESH_TOKEN, refreshToken, + (int)(refreshTokenExpiry / 1000)); + + jwtRedisRepository.addRefToken(refreshToken, refreshTokenExpiry, principal.getId()); + return UriComponentsBuilder.fromUriString(applicationYmlRead.getFrontUrl()) + .queryParam("token", accessToken) + .build().toUriString(); + } + + private String deleteKakaoUser(Long existUserId, HttpServletResponse response, Authentication authentication) { + UserPrincipal principal = (UserPrincipal)authentication.getPrincipal(); + User existUser = userRepository.findById(existUserId).orElseThrow(UserNotFoundException::new); + User newUser = userRepository.findById(principal.getId()).orElseThrow(UserNotFoundException::new); + //kakao 계정 사용자가 42 인증 + if (existUser.getRoleType().equals(RoleType.GUEST)) { + return UriComponentsBuilder.fromUriString(applicationYmlRead.getFrontUrl() + "/users/detail") + .queryParam("intraId", newUser.getIntraId()) + .queryParam("token", saveAndGetUserAccessToken(response, newUser, existUser)) + .build().toUriString(); + } + //기존 user 사용자가 카카오 인증 + if (newUser.getRoleType().equals(RoleType.GUEST)) { + return UriComponentsBuilder.fromUriString(applicationYmlRead.getFrontUrl() + "/users/detail") + .queryParam("intraId", existUser.getIntraId()) + .queryParam("token", saveAndGetUserAccessToken(response, existUser, newUser)) + .build().toUriString(); + } + throw new UserNotFoundException(); + } + + private String saveAndGetUserAccessToken(HttpServletResponse response, + User remainedUser, User deletedUser) { + remainedUser.updateKakaoId(deletedUser.getKakaoId()); + // 쿠키 시간 설정 + long refreshTokenExpiry = appProperties.getAuth().getRefreshTokenExpiry(); + userRepository.delete(deletedUser); + + // token 설정 + String accessToken = tokenProvider.createToken(remainedUser.getId()); + String refreshToken = tokenProvider.refreshToken(remainedUser.getId()); + jwtRedisRepository.addRefToken(refreshToken, refreshTokenExpiry, remainedUser.getId()); + + cookieUtil.addCookie(response, TokenHeaders.REFRESH_TOKEN, refreshToken, + (int)(refreshTokenExpiry / 1000)); + return accessToken; + } + + private void clearAuthenticationAttributes(HttpServletRequest request, HttpServletResponse response) { + super.clearAuthenticationAttributes(request); + } } diff --git a/src/main/java/com/gg/server/global/security/info/OAuthUserInfo.java b/src/main/java/com/gg/server/global/security/info/OAuthUserInfo.java index 9d791b0ac..3701ed585 100644 --- a/src/main/java/com/gg/server/global/security/info/OAuthUserInfo.java +++ b/src/main/java/com/gg/server/global/security/info/OAuthUserInfo.java @@ -1,26 +1,27 @@ package com.gg.server.global.security.info; -import com.gg.server.domain.user.type.RoleType; import java.util.Map; +import com.gg.server.domain.user.type.RoleType; + public abstract class OAuthUserInfo { - protected Map attributes; + protected Map attributes; - public OAuthUserInfo(Map attributes) { - this.attributes = attributes; - } + public OAuthUserInfo(Map attributes) { + this.attributes = attributes; + } - public Map getAttributes() { - return attributes; - } + public Map getAttributes() { + return attributes; + } - public abstract String getIntraId(); + public abstract String getIntraId(); - public abstract String getEmail(); + public abstract String getEmail(); - public abstract String getImageUrl(); + public abstract String getImageUrl(); - public abstract RoleType getRoleType(); + public abstract RoleType getRoleType(); - public abstract Long getKakaoId(); + public abstract Long getKakaoId(); } diff --git a/src/main/java/com/gg/server/global/security/info/OAuthUserInfoFactory.java b/src/main/java/com/gg/server/global/security/info/OAuthUserInfoFactory.java index 54dcd7a31..77fa88fb7 100644 --- a/src/main/java/com/gg/server/global/security/info/OAuthUserInfoFactory.java +++ b/src/main/java/com/gg/server/global/security/info/OAuthUserInfoFactory.java @@ -1,17 +1,20 @@ package com.gg.server.global.security.info; -import com.gg.server.global.security.info.impl.KakaoOAuthUserInfo; import java.util.Map; import com.gg.server.global.security.info.impl.FortyTwoOAuthUserInfo; +import com.gg.server.global.security.info.impl.KakaoOAuthUserInfo; public class OAuthUserInfoFactory { - public static OAuthUserInfo getOAuth2UserInfo(ProviderType providerType, Map attributes) { - switch (providerType) { - case FORTYTWO: return new FortyTwoOAuthUserInfo(attributes); - case KAKAO: return new KakaoOAuthUserInfo(attributes); - //case SLACK: return new FacebookOAuth2UserInfo(attributes); - default: throw new IllegalArgumentException("Invalid Provider Type."); - } - } + public static OAuthUserInfo getOAuth2UserInfo(ProviderType providerType, Map attributes) { + switch (providerType) { + case FORTYTWO: + return new FortyTwoOAuthUserInfo(attributes); + case KAKAO: + return new KakaoOAuthUserInfo(attributes); + //case SLACK: return new FacebookOAuth2UserInfo(attributes); + default: + throw new IllegalArgumentException("Invalid Provider Type."); + } + } } diff --git a/src/main/java/com/gg/server/global/security/info/ProviderType.java b/src/main/java/com/gg/server/global/security/info/ProviderType.java index 0cad81700..8e11f8644 100644 --- a/src/main/java/com/gg/server/global/security/info/ProviderType.java +++ b/src/main/java/com/gg/server/global/security/info/ProviderType.java @@ -4,24 +4,24 @@ @Getter public enum ProviderType { - FORTYTWO("42"), KAKAO("KAKAO"); + FORTYTWO("42"), KAKAO("KAKAO"); - private String key; + private String key; - ProviderType(String key) { - this.key = key; - } + ProviderType(String key) { + this.key = key; + } - public String getKey() { - return key; - } + public String getKey() { + return key; + } - public static ProviderType keyOf(String key) { - for (ProviderType value : ProviderType.values()) { - if (value.key.equalsIgnoreCase(key)) { - return value; - } - } - return null; - } + public static ProviderType keyOf(String key) { + for (ProviderType value : ProviderType.values()) { + if (value.key.equalsIgnoreCase(key)) { + return value; + } + } + return null; + } } diff --git a/src/main/java/com/gg/server/global/security/info/impl/FortyTwoOAuthUserInfo.java b/src/main/java/com/gg/server/global/security/info/impl/FortyTwoOAuthUserInfo.java index 7f4cd88e5..0e8084e39 100644 --- a/src/main/java/com/gg/server/global/security/info/impl/FortyTwoOAuthUserInfo.java +++ b/src/main/java/com/gg/server/global/security/info/impl/FortyTwoOAuthUserInfo.java @@ -1,48 +1,48 @@ package com.gg.server.global.security.info.impl; +import java.util.Map; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.global.security.info.OAuthUserInfo; import org.springframework.beans.factory.annotation.Value; -import java.util.Map; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.global.security.info.OAuthUserInfo; public class FortyTwoOAuthUserInfo extends OAuthUserInfo { - @Value("${info.image.defaultUrl}") - private String defaultImageUrl; - - public FortyTwoOAuthUserInfo(Map attributes) { - super(attributes); - } - - @Override - public String getIntraId() { - return attributes.get("login").toString(); - } - - public String getEmail() { - return attributes.get("email").toString(); - } - - public String getImageUrl() { - Map image = (Map) attributes.get("image"); - if (image == null) { - return defaultImageUrl; - } - if (image.get("link") == null) { - return defaultImageUrl; - } - return image.get("link").toString(); - } - - @Override - public RoleType getRoleType() { - return RoleType.USER; - } - - @Override - public Long getKakaoId() { - return null; - } + @Value("${info.image.defaultUrl}") + private String defaultImageUrl; + + public FortyTwoOAuthUserInfo(Map attributes) { + super(attributes); + } + + @Override + public String getIntraId() { + return attributes.get("login").toString(); + } + + public String getEmail() { + return attributes.get("email").toString(); + } + + public String getImageUrl() { + Map image = (Map)attributes.get("image"); + if (image == null) { + return defaultImageUrl; + } + if (image.get("link") == null) { + return defaultImageUrl; + } + return image.get("link").toString(); + } + + @Override + public RoleType getRoleType() { + return RoleType.USER; + } + + @Override + public Long getKakaoId() { + return null; + } } diff --git a/src/main/java/com/gg/server/global/security/info/impl/KakaoOAuthUserInfo.java b/src/main/java/com/gg/server/global/security/info/impl/KakaoOAuthUserInfo.java index a20c41ff3..760c0b493 100644 --- a/src/main/java/com/gg/server/global/security/info/impl/KakaoOAuthUserInfo.java +++ b/src/main/java/com/gg/server/global/security/info/impl/KakaoOAuthUserInfo.java @@ -1,44 +1,47 @@ package com.gg.server.global.security.info.impl; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.global.security.info.OAuthUserInfo; import java.util.Map; + import org.springframework.beans.factory.annotation.Value; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.global.security.info.OAuthUserInfo; + public class KakaoOAuthUserInfo extends OAuthUserInfo { - @Value("${info.image.defaultUrl}") - private String defaultImageUrl; - - public KakaoOAuthUserInfo(Map attributes) { - super(attributes); - } - - @Override - public String getIntraId() { - return "GUEST" + attributes.get("id").toString(); - } - - @Override - public String getEmail() { - Map kakaoAccount = (Map) attributes.get("kakao_account"); - if (kakaoAccount.get("email") == null) - return null; - return kakaoAccount.get("email").toString(); - } - - @Override - public String getImageUrl() { - Map properties = (Map) attributes.get("properties"); - return properties.get("profile_image").toString(); - } - - @Override - public RoleType getRoleType() { - return RoleType.GUEST; - } - - @Override - public Long getKakaoId() { - return (Long) attributes.get("id"); - } + @Value("${info.image.defaultUrl}") + private String defaultImageUrl; + + public KakaoOAuthUserInfo(Map attributes) { + super(attributes); + } + + @Override + public String getIntraId() { + return "GUEST" + attributes.get("id").toString(); + } + + @Override + public String getEmail() { + Map kakaoAccount = (Map)attributes.get("kakao_account"); + if (kakaoAccount.get("email") == null) { + return null; + } + return kakaoAccount.get("email").toString(); + } + + @Override + public String getImageUrl() { + Map properties = (Map)attributes.get("properties"); + return properties.get("profile_image").toString(); + } + + @Override + public RoleType getRoleType() { + return RoleType.GUEST; + } + + @Override + public Long getKakaoId() { + return (Long)attributes.get("id"); + } } diff --git a/src/main/java/com/gg/server/global/security/jwt/repository/JwtRedisRepository.java b/src/main/java/com/gg/server/global/security/jwt/repository/JwtRedisRepository.java index 51181ae53..bb1e9a260 100644 --- a/src/main/java/com/gg/server/global/security/jwt/repository/JwtRedisRepository.java +++ b/src/main/java/com/gg/server/global/security/jwt/repository/JwtRedisRepository.java @@ -1,28 +1,30 @@ package com.gg.server.global.security.jwt.repository; -import lombok.RequiredArgsConstructor; +import java.util.concurrent.TimeUnit; + import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; -import java.util.concurrent.TimeUnit; +import lombok.RequiredArgsConstructor; @Repository @RequiredArgsConstructor public class JwtRedisRepository { - private final RedisTemplate redisTemplate; + private final RedisTemplate redisTemplate; - public void addRefToken(String refreshToken, long timeOut, Long userId) { - redisTemplate.opsForValue().set(refreshToken, userId.toString(), timeOut, TimeUnit.MILLISECONDS); - } + public void addRefToken(String refreshToken, long timeOut, Long userId) { + redisTemplate.opsForValue().set(refreshToken, userId.toString(), timeOut, TimeUnit.MILLISECONDS); + } - public Long getUserIdFromRefToken(String refToken){ - String userId = redisTemplate.opsForValue().get(refToken); - if (userId == null) - return null; - return Long.valueOf(userId); - } + public Long getUserIdFromRefToken(String refToken) { + String userId = redisTemplate.opsForValue().get(refToken); + if (userId == null) { + return null; + } + return Long.valueOf(userId); + } - public void deleteRefToken(String refToken) { - redisTemplate.delete(refToken); - } + public void deleteRefToken(String refToken) { + redisTemplate.delete(refToken); + } } diff --git a/src/main/java/com/gg/server/global/security/jwt/utils/AuthTokenProvider.java b/src/main/java/com/gg/server/global/security/jwt/utils/AuthTokenProvider.java index f42c81ffd..4a2c75c7c 100644 --- a/src/main/java/com/gg/server/global/security/jwt/utils/AuthTokenProvider.java +++ b/src/main/java/com/gg/server/global/security/jwt/utils/AuthTokenProvider.java @@ -1,80 +1,86 @@ package com.gg.server.global.security.jwt.utils; +import java.security.Key; +import java.util.Date; + +import org.springframework.stereotype.Component; + import com.gg.server.global.security.config.properties.AppProperties; -import com.gg.server.global.security.UserPrincipal; -import io.jsonwebtoken.*; + +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.ExpiredJwtException; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.MalformedJwtException; +import io.jsonwebtoken.UnsupportedJwtException; import io.jsonwebtoken.security.Keys; import lombok.extern.slf4j.Slf4j; -import org.springframework.security.core.Authentication; -import org.springframework.stereotype.Component; - -import java.security.Key; -import java.util.*; @Slf4j @Component public class AuthTokenProvider { - private AppProperties appProperties; - private final Key key; - private final Key refreshKey; + private AppProperties appProperties; + private final Key key; + private final Key refreshKey; + + public AuthTokenProvider(AppProperties appProperties) { + this.appProperties = appProperties; + key = Keys.hmacShaKeyFor(appProperties.getAuth().getTokenSecret().getBytes()); + refreshKey = Keys.hmacShaKeyFor(appProperties.getAuth().getRefreshTokenSecret().getBytes()); + log.info(key.getAlgorithm()); + } - public AuthTokenProvider(AppProperties appProperties) { - this.appProperties = appProperties; - key = Keys.hmacShaKeyFor(appProperties.getAuth().getTokenSecret().getBytes()); - refreshKey = Keys.hmacShaKeyFor(appProperties.getAuth().getRefreshTokenSecret().getBytes()); - log.info(key.getAlgorithm()); - } - 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) - .compact(); - } + 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) + .compact(); + } - public String createToken(Long userId) { - Date now = new Date(); - Date expiryDate = new Date(now.getTime() + - appProperties.getAuth().getTokenExpiry()); - return Jwts.builder() - .setSubject(Long.toString(userId)) - .setIssuedAt(new Date()) - .setExpiration(expiryDate) - .signWith(key) - .compact(); - } + public String createToken(Long userId) { + Date now = new Date(); + Date expiryDate = new Date(now.getTime() + + appProperties.getAuth().getTokenExpiry()); + return Jwts.builder() + .setSubject(Long.toString(userId)) + .setIssuedAt(new Date()) + .setExpiration(expiryDate) + .signWith(key) + .compact(); + } - private Claims getClaims(String token, Key key) { - try { - return Jwts.parserBuilder() - .setSigningKey(key) - .build() - .parseClaimsJws(token) - .getBody(); - } catch (SecurityException e) { - log.info("Invalid JWT signature."); - } catch (MalformedJwtException e) { - log.info("Invalid JWT token."); - } catch (ExpiredJwtException e) { - log.info("Expired JWT token."); - } catch (UnsupportedJwtException e) { - log.info("Unsupported JWT token."); - } catch (IllegalArgumentException e) { - log.info("JWT token compact of handler are invalid."); - } - return null; - } + private Claims getClaims(String token, Key key) { + try { + return Jwts.parserBuilder() + .setSigningKey(key) + .build() + .parseClaimsJws(token) + .getBody(); + } catch (SecurityException e) { + log.info("Invalid JWT signature."); + } catch (MalformedJwtException e) { + log.info("Invalid JWT token."); + } catch (ExpiredJwtException e) { + log.info("Expired JWT token."); + } catch (UnsupportedJwtException e) { + log.info("Unsupported JWT token."); + } catch (IllegalArgumentException e) { + log.info("JWT token compact of handler are invalid."); + } + return null; + } - public Long getUserIdFromAccessToken(String accessToken) { - Claims claims = getClaims(accessToken, key); - if (claims == null) - return null; - return Long.valueOf(claims.getSubject()); - } + public Long getUserIdFromAccessToken(String accessToken) { + Claims claims = getClaims(accessToken, key); + if (claims == null) { + return null; + } + return Long.valueOf(claims.getSubject()); + } } diff --git a/src/main/java/com/gg/server/global/security/jwt/utils/TokenAuthenticationFilter.java b/src/main/java/com/gg/server/global/security/jwt/utils/TokenAuthenticationFilter.java index d0230b893..06b3f9ae9 100644 --- a/src/main/java/com/gg/server/global/security/jwt/utils/TokenAuthenticationFilter.java +++ b/src/main/java/com/gg/server/global/security/jwt/utils/TokenAuthenticationFilter.java @@ -1,12 +1,14 @@ package com.gg.server.global.security.jwt.utils; -import com.gg.server.global.security.config.properties.AppProperties; -import com.gg.server.global.security.cookie.CookieUtil; -import com.gg.server.global.security.service.CustomUserDetailsService; -import com.gg.server.global.utils.HeaderUtil; -import io.jsonwebtoken.Claims; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; +import static org.apache.commons.lang3.StringUtils.*; + +import java.io.IOException; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.apache.http.HttpHeaders; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; @@ -16,50 +18,48 @@ import org.springframework.stereotype.Component; import org.springframework.web.filter.OncePerRequestFilter; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; +import com.gg.server.global.security.service.CustomUserDetailsService; +import com.gg.server.global.utils.HeaderUtil; -import static org.apache.commons.lang3.StringUtils.isEmpty; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; @Slf4j @RequiredArgsConstructor @Component public class TokenAuthenticationFilter extends OncePerRequestFilter { - private final AuthTokenProvider tokenProvider; - private final CustomUserDetailsService customUserDetailsService; + private final AuthTokenProvider tokenProvider; + private final CustomUserDetailsService customUserDetailsService; - @Override - protected void doFilterInternal( - HttpServletRequest request, - HttpServletResponse response, - FilterChain filterChain) throws ServletException, IOException { - try { - String tokenHeader = request.getHeader(HttpHeaders.AUTHORIZATION); - if (isEmpty(tokenHeader) || !tokenHeader.startsWith("Bearer ")) { - filterChain.doFilter(request, response); - return; - } - OAuth2AuthenticationToken authentication = validate(request); - authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); - SecurityContextHolder.getContext().setAuthentication(authentication); - } catch (Exception e) { - log.error("Security Context에서 사용자 인증을 설정할 수 없습니다.", e); - } - filterChain.doFilter(request, response); - } + @Override + protected void doFilterInternal( + HttpServletRequest request, + HttpServletResponse response, + FilterChain filterChain) throws ServletException, IOException { + try { + String tokenHeader = request.getHeader(HttpHeaders.AUTHORIZATION); + if (isEmpty(tokenHeader) || !tokenHeader.startsWith("Bearer ")) { + filterChain.doFilter(request, response); + return; + } + OAuth2AuthenticationToken authentication = validate(request); + authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); + SecurityContextHolder.getContext().setAuthentication(authentication); + } catch (Exception e) { + log.error("Security Context에서 사용자 인증을 설정할 수 없습니다.", e); + } + filterChain.doFilter(request, response); + } - private OAuth2AuthenticationToken validate(HttpServletRequest request) { - String accessToken = HeaderUtil.getAccessToken(request); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - //access token 검증 - if (userId != null){ - UserDetails userDetails = customUserDetailsService.loadUserById(userId); - return new OAuth2AuthenticationToken((OAuth2User) userDetails, userDetails.getAuthorities(), "42"); - } - throw new RuntimeException("token not validated"); - } + private OAuth2AuthenticationToken validate(HttpServletRequest request) { + String accessToken = HeaderUtil.getAccessToken(request); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + //access token 검증 + if (userId != null) { + UserDetails userDetails = customUserDetailsService.loadUserById(userId); + return new OAuth2AuthenticationToken((OAuth2User)userDetails, userDetails.getAuthorities(), "42"); + } + throw new RuntimeException("token not validated"); + } } diff --git a/src/main/java/com/gg/server/global/security/jwt/utils/TokenHeaders.java b/src/main/java/com/gg/server/global/security/jwt/utils/TokenHeaders.java index 72ccbd160..1165fdee8 100644 --- a/src/main/java/com/gg/server/global/security/jwt/utils/TokenHeaders.java +++ b/src/main/java/com/gg/server/global/security/jwt/utils/TokenHeaders.java @@ -1,6 +1,6 @@ package com.gg.server.global.security.jwt.utils; public class TokenHeaders { - public static final String REFRESH_TOKEN = "refresh_token"; - public static final String ACCESS_TOKEN = "access_token"; + public static final String REFRESH_TOKEN = "refresh_token"; + public static final String ACCESS_TOKEN = "access_token"; } diff --git a/src/main/java/com/gg/server/global/security/repository/OAuthAuthorizationRequestBasedOnCookieRepository.java b/src/main/java/com/gg/server/global/security/repository/OAuthAuthorizationRequestBasedOnCookieRepository.java index a18aee3bd..6e30c2f51 100644 --- a/src/main/java/com/gg/server/global/security/repository/OAuthAuthorizationRequestBasedOnCookieRepository.java +++ b/src/main/java/com/gg/server/global/security/repository/OAuthAuthorizationRequestBasedOnCookieRepository.java @@ -1,52 +1,57 @@ package com.gg.server.global.security.repository; - -import com.gg.server.global.security.cookie.CookieUtil; -import com.nimbusds.oauth2.sdk.util.StringUtils; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import lombok.RequiredArgsConstructor; + import org.springframework.security.oauth2.client.web.AuthorizationRequestRepository; import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest; import org.springframework.stereotype.Repository; +import com.gg.server.global.security.cookie.CookieUtil; +import com.nimbusds.oauth2.sdk.util.StringUtils; + +import lombok.RequiredArgsConstructor; + @Repository @RequiredArgsConstructor -public class OAuthAuthorizationRequestBasedOnCookieRepository implements AuthorizationRequestRepository { - - public static final String OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME = "oauth2_auth_request"; - public static final String REDIRECT_URI_PARAM_COOKIE_NAME = "redirect_uri"; - private static final int cookieExpireSeconds = 180; - private final CookieUtil cookieUtil; - - @Override - public OAuth2AuthorizationRequest loadAuthorizationRequest(HttpServletRequest request) { - return cookieUtil.getCookie(request, OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME) - .map(cookie -> cookieUtil.deserialize(cookie, OAuth2AuthorizationRequest.class)) - .orElse(null); - } - - @Override - public void saveAuthorizationRequest(OAuth2AuthorizationRequest authorizationRequest, HttpServletRequest request, HttpServletResponse response) { - if (authorizationRequest == null) { - cookieUtil.deleteCookie(request, response, OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME); - cookieUtil.deleteCookie(request, response, REDIRECT_URI_PARAM_COOKIE_NAME); - return; - } - - cookieUtil.addCookie(response, OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME, cookieUtil.serialize(authorizationRequest), - cookieExpireSeconds); - String redirectUriAfterLogin = request.getParameter(REDIRECT_URI_PARAM_COOKIE_NAME); - if (StringUtils.isNotBlank(redirectUriAfterLogin)) { - cookieUtil.addCookie(response, REDIRECT_URI_PARAM_COOKIE_NAME, redirectUriAfterLogin, - cookieExpireSeconds); - } - } - - @Override - public OAuth2AuthorizationRequest removeAuthorizationRequest(HttpServletRequest request) { - return this.loadAuthorizationRequest(request); - } +public class OAuthAuthorizationRequestBasedOnCookieRepository + implements AuthorizationRequestRepository { + + public static final String OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME = "oauth2_auth_request"; + public static final String REDIRECT_URI_PARAM_COOKIE_NAME = "redirect_uri"; + private static final int cookieExpireSeconds = 180; + private final CookieUtil cookieUtil; + + @Override + public OAuth2AuthorizationRequest loadAuthorizationRequest(HttpServletRequest request) { + return cookieUtil.getCookie(request, OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME) + .map(cookie -> cookieUtil.deserialize(cookie, OAuth2AuthorizationRequest.class)) + .orElse(null); + } + + @Override + public void saveAuthorizationRequest(OAuth2AuthorizationRequest authorizationRequest, HttpServletRequest request, + HttpServletResponse response) { + if (authorizationRequest == null) { + cookieUtil.deleteCookie(request, response, OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME); + cookieUtil.deleteCookie(request, response, REDIRECT_URI_PARAM_COOKIE_NAME); + return; + } + + cookieUtil.addCookie(response, OAUTH2_AUTHORIZATION_REQUEST_COOKIE_NAME, + cookieUtil.serialize(authorizationRequest), + cookieExpireSeconds); + String redirectUriAfterLogin = request.getParameter(REDIRECT_URI_PARAM_COOKIE_NAME); + if (StringUtils.isNotBlank(redirectUriAfterLogin)) { + cookieUtil.addCookie(response, REDIRECT_URI_PARAM_COOKIE_NAME, redirectUriAfterLogin, + cookieExpireSeconds); + } + } + + @Override + public OAuth2AuthorizationRequest removeAuthorizationRequest(HttpServletRequest request) { + return this.loadAuthorizationRequest(request); + } } diff --git a/src/main/java/com/gg/server/global/security/service/CustomOAuth2UserService.java b/src/main/java/com/gg/server/global/security/service/CustomOAuth2UserService.java index a7442973c..570fd6b23 100644 --- a/src/main/java/com/gg/server/global/security/service/CustomOAuth2UserService.java +++ b/src/main/java/com/gg/server/global/security/service/CustomOAuth2UserService.java @@ -1,110 +1,114 @@ -package com.gg.server.global.security.service; - -import com.gg.server.domain.rank.data.Rank; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.tier.data.Tier; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.UserPrincipal; -import com.gg.server.global.security.info.OAuthUserInfo; -import com.gg.server.global.security.info.OAuthUserInfoFactory; -import com.gg.server.global.security.info.ProviderType; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.SnsType; -import com.gg.server.global.utils.aws.AsyncNewUserImageUploader; -import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.security.authentication.InternalAuthenticationServiceException; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.oauth2.client.userinfo.DefaultOAuth2UserService; -import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest; -import org.springframework.security.oauth2.core.OAuth2AuthenticationException; -import org.springframework.security.oauth2.core.user.OAuth2User; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; - -@Service -@RequiredArgsConstructor -@Transactional -public class CustomOAuth2UserService extends DefaultOAuth2UserService { - private final UserRepository userRepository; - private final AsyncNewUserImageUploader asyncNewUserImageUploader; - private final RankRepository rankRepository; - private final SeasonRepository seasonRepository; - private final RankRedisRepository rankRedisRepository; - private final TierRepository tierRepository; - - @Value("${info.image.defaultUrl}") - private String defaultImageUrl; - - @Override - public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException { - OAuth2User user = super.loadUser(userRequest); - - try { - return this.process(userRequest, user); - } catch (AuthenticationException ex) { - throw ex; - } catch (Exception ex) { - ex.printStackTrace(); - throw new InternalAuthenticationServiceException(ex.getMessage(), ex.getCause()); - } - } - - private OAuth2User process(OAuth2UserRequest userRequest, OAuth2User user) { - ProviderType providerType = ProviderType.keyOf(userRequest.getClientRegistration().getRegistrationId().toUpperCase()); - User savedUser; - OAuthUserInfo userInfo = OAuthUserInfoFactory.getOAuth2UserInfo(providerType, user.getAttributes()); - if (providerType.equals(ProviderType.FORTYTWO)) { - savedUser = userRepository.findByIntraId(userInfo.getIntraId()) - .orElse(null); - } else { - savedUser = userRepository.findByKakaoId(userInfo.getKakaoId()) - .orElse(null); - } - if (savedUser == null) { - savedUser = createUser(userInfo); - if (providerType.equals(ProviderType.FORTYTWO)) - createUserRank(savedUser); - if (userInfo.getImageUrl().startsWith("https://cdn.intra.42.fr/")) { - asyncNewUserImageUploader.upload(userInfo.getIntraId(), userInfo.getImageUrl()); - } - } - return UserPrincipal.create(savedUser, user.getAttributes()); - } - - private void createUserRank(User savedUser) { - Tier tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); - seasonRepository.findCurrentAndNewSeason(LocalDateTime.now()).forEach( - season -> { - Rank userRank = Rank.from(savedUser, season, season.getStartPpp(), tier); - rankRepository.save(userRank); - RankRedis rankRedis = RankRedis.from(UserDto.from(savedUser), season.getStartPpp(), tier.getImageUri()); - String hashKey = RedisKeyManager.getHashKey(season.getId()); - rankRedisRepository.addRankData(hashKey, savedUser.getId(), rankRedis); - } - ); - } - - private User createUser(OAuthUserInfo userInfo) { - User user = User.builder() - .intraId(userInfo.getIntraId()) - .roleType(userInfo.getRoleType()) - .kakaoId(userInfo.getKakaoId()) - .snsNotiOpt(SnsType.EMAIL) - .racketType(RacketType.NONE) - .totalExp(0) - .eMail(userInfo.getEmail()) - .build(); - return userRepository.saveAndFlush(user); - } -} +package com.gg.server.global.security.service; + +import java.time.LocalDateTime; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.security.authentication.InternalAuthenticationServiceException; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.oauth2.client.userinfo.DefaultOAuth2UserService; +import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest; +import org.springframework.security.oauth2.core.OAuth2AuthenticationException; +import org.springframework.security.oauth2.core.user.OAuth2User; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.domain.rank.data.Rank; +import com.gg.server.domain.rank.data.RankRepository; +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.rank.redis.RedisKeyManager; +import com.gg.server.domain.season.data.SeasonRepository; +import com.gg.server.domain.tier.data.Tier; +import com.gg.server.domain.tier.data.TierRepository; +import com.gg.server.domain.tier.exception.TierNotFoundException; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.global.security.UserPrincipal; +import com.gg.server.global.security.info.OAuthUserInfo; +import com.gg.server.global.security.info.OAuthUserInfoFactory; +import com.gg.server.global.security.info.ProviderType; +import com.gg.server.global.utils.aws.AsyncNewUserImageUploader; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +@Transactional +public class CustomOAuth2UserService extends DefaultOAuth2UserService { + private final UserRepository userRepository; + private final AsyncNewUserImageUploader asyncNewUserImageUploader; + private final RankRepository rankRepository; + private final SeasonRepository seasonRepository; + private final RankRedisRepository rankRedisRepository; + private final TierRepository tierRepository; + + @Value("${info.image.defaultUrl}") + private String defaultImageUrl; + + @Override + public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException { + OAuth2User user = super.loadUser(userRequest); + + try { + return this.process(userRequest, user); + } catch (AuthenticationException ex) { + throw ex; + } catch (Exception ex) { + ex.printStackTrace(); + throw new InternalAuthenticationServiceException(ex.getMessage(), ex.getCause()); + } + } + + private OAuth2User process(OAuth2UserRequest userRequest, OAuth2User user) { + ProviderType providerType = ProviderType.keyOf( + userRequest.getClientRegistration().getRegistrationId().toUpperCase()); + User savedUser; + OAuthUserInfo userInfo = OAuthUserInfoFactory.getOAuth2UserInfo(providerType, user.getAttributes()); + if (providerType.equals(ProviderType.FORTYTWO)) { + savedUser = userRepository.findByIntraId(userInfo.getIntraId()) + .orElse(null); + } else { + savedUser = userRepository.findByKakaoId(userInfo.getKakaoId()) + .orElse(null); + } + if (savedUser == null) { + savedUser = createUser(userInfo); + if (providerType.equals(ProviderType.FORTYTWO)) { + createUserRank(savedUser); + } + if (userInfo.getImageUrl().startsWith("https://cdn.intra.42.fr/")) { + asyncNewUserImageUploader.upload(userInfo.getIntraId(), userInfo.getImageUrl()); + } + } + return UserPrincipal.create(savedUser, user.getAttributes()); + } + + private void createUserRank(User savedUser) { + Tier tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); + seasonRepository.findCurrentAndNewSeason(LocalDateTime.now()).forEach( + season -> { + Rank userRank = Rank.from(savedUser, season, season.getStartPpp(), tier); + rankRepository.save(userRank); + RankRedis rankRedis = RankRedis.from(UserDto.from(savedUser), season.getStartPpp(), tier.getImageUri()); + String hashKey = RedisKeyManager.getHashKey(season.getId()); + rankRedisRepository.addRankData(hashKey, savedUser.getId(), rankRedis); + } + ); + } + + private User createUser(OAuthUserInfo userInfo) { + User user = User.builder() + .intraId(userInfo.getIntraId()) + .roleType(userInfo.getRoleType()) + .kakaoId(userInfo.getKakaoId()) + .snsNotiOpt(SnsType.EMAIL) + .racketType(RacketType.NONE) + .totalExp(0) + .eMail(userInfo.getEmail()) + .build(); + return userRepository.saveAndFlush(user); + } +} diff --git a/src/main/java/com/gg/server/global/security/service/CustomUserDetailsService.java b/src/main/java/com/gg/server/global/security/service/CustomUserDetailsService.java index a27fd87a2..c58d1921d 100644 --- a/src/main/java/com/gg/server/global/security/service/CustomUserDetailsService.java +++ b/src/main/java/com/gg/server/global/security/service/CustomUserDetailsService.java @@ -1,29 +1,32 @@ -package com.gg.server.global.security.service; - -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.service.UserFindService; -import com.gg.server.global.security.UserPrincipal; -import lombok.RequiredArgsConstructor; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@RequiredArgsConstructor -@Transactional -public class CustomUserDetailsService implements UserDetailsService { - - private final UserFindService userFindService; - @Override - public UserDetails loadUserByUsername(String username) throws UserNotFoundException { - User user = userFindService.findByIntraId(username); - return UserPrincipal.create(user); - } - - public UserDetails loadUserById(Long id) { - User user = userFindService.findUserById(id); - return UserPrincipal.create(user); - } -} +package com.gg.server.global.security.service; + +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.exception.UserNotFoundException; +import com.gg.server.domain.user.service.UserFindService; +import com.gg.server.global.security.UserPrincipal; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +@Transactional +public class CustomUserDetailsService implements UserDetailsService { + + private final UserFindService userFindService; + + @Override + public UserDetails loadUserByUsername(String username) throws UserNotFoundException { + User user = userFindService.findByIntraId(username); + return UserPrincipal.create(user); + } + + public UserDetails loadUserById(Long id) { + User user = userFindService.findUserById(id); + return UserPrincipal.create(user); + } +} diff --git a/src/main/java/com/gg/server/global/utils/ApplicationYmlRead.java b/src/main/java/com/gg/server/global/utils/ApplicationYmlRead.java index 6680c480b..f0838c623 100644 --- a/src/main/java/com/gg/server/global/utils/ApplicationYmlRead.java +++ b/src/main/java/com/gg/server/global/utils/ApplicationYmlRead.java @@ -1,27 +1,27 @@ package com.gg.server.global.utils; -import lombok.Setter; +import java.util.Map; + import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; -import java.util.Map; +import lombok.Setter; @Configuration @Setter @ConfigurationProperties(prefix = "info") public class ApplicationYmlRead { - private Map web; - - public String getFrontUrl() { - return web.get("frontUrl"); - } + private Map web; - public String getDomain(){ - return web.get("domain"); - } + public String getFrontUrl() { + return web.get("frontUrl"); + } + public String getDomain() { + return web.get("domain"); + } - public String getFrontLoginUrl() { - return web.get("frontUrl") + "/login"; - } + public String getFrontLoginUrl() { + return web.get("frontUrl") + "/login"; + } } diff --git a/src/main/java/com/gg/server/global/utils/AsyncMailSender.java b/src/main/java/com/gg/server/global/utils/AsyncMailSender.java index aa5163d27..9a06d1553 100644 --- a/src/main/java/com/gg/server/global/utils/AsyncMailSender.java +++ b/src/main/java/com/gg/server/global/utils/AsyncMailSender.java @@ -1,25 +1,26 @@ package com.gg.server.global.utils; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; +import javax.mail.internet.MimeMessage; + import org.springframework.mail.javamail.JavaMailSender; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; -import javax.mail.internet.MimeMessage; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; @Component @AllArgsConstructor @Slf4j public class AsyncMailSender { - private final JavaMailSender javaMailSender; + private final JavaMailSender javaMailSender; - @Async("asyncExecutor") - public void send(MimeMessage message) { - try { - javaMailSender.send(message); - } catch(Exception ex) { - log.error(ex.getMessage()); - } - } + @Async("asyncExecutor") + public void send(MimeMessage message) { + try { + javaMailSender.send(message); + } catch (Exception ex) { + log.error(ex.getMessage()); + } + } } diff --git a/src/main/java/com/gg/server/global/utils/BaseTimeEntity.java b/src/main/java/com/gg/server/global/utils/BaseTimeEntity.java index 8bef5cfe4..11ff94f14 100644 --- a/src/main/java/com/gg/server/global/utils/BaseTimeEntity.java +++ b/src/main/java/com/gg/server/global/utils/BaseTimeEntity.java @@ -1,22 +1,26 @@ package com.gg.server.global.utils; -import lombok.Getter; +import java.time.LocalDateTime; + +import javax.persistence.Column; +import javax.persistence.EntityListeners; +import javax.persistence.MappedSuperclass; + import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; -import javax.persistence.*; -import java.time.LocalDateTime; +import lombok.Getter; @Getter @MappedSuperclass @EntityListeners(AuditingEntityListener.class) public abstract class BaseTimeEntity { - @CreatedDate - @Column(updatable = false, nullable = false) - private LocalDateTime createdAt; + @CreatedDate + @Column(updatable = false, nullable = false) + private LocalDateTime createdAt; - @LastModifiedDate - private LocalDateTime modifiedAt; + @LastModifiedDate + private LocalDateTime modifiedAt; } diff --git a/src/main/java/com/gg/server/global/utils/BusinessChecker.java b/src/main/java/com/gg/server/global/utils/BusinessChecker.java index 9f7ea08ec..9702b0b2f 100644 --- a/src/main/java/com/gg/server/global/utils/BusinessChecker.java +++ b/src/main/java/com/gg/server/global/utils/BusinessChecker.java @@ -1,8 +1,10 @@ package com.gg.server.global.utils; +import java.util.Collection; + import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.BusinessException; -import java.util.Collection; + import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -16,27 +18,27 @@ */ @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class BusinessChecker { - public static void mustNotNull(Object object, ErrorCode errorCode) { - if (object == null) { - throw new BusinessException(errorCode); - } - } + public static void mustNotNull(Object object, ErrorCode errorCode) { + if (object == null) { + throw new BusinessException(errorCode); + } + } - public static void mustContains(Object object, Collection collection, ErrorCode errorCode) { - if (!collection.contains(object)) { - throw new BusinessException(errorCode); - } - } + public static void mustContains(Object object, Collection collection, ErrorCode errorCode) { + if (!collection.contains(object)) { + throw new BusinessException(errorCode); + } + } - public static void mustNotContains(Object object, Collection collection, ErrorCode errorCode) { - if (collection.contains(object)) { - throw new BusinessException(errorCode); - } - } + public static void mustNotContains(Object object, Collection collection, ErrorCode errorCode) { + if (collection.contains(object)) { + throw new BusinessException(errorCode); + } + } - public static void mustNotExceed(int size, Collection collection, ErrorCode errorCode) { - if (collection.size() > size) { - throw new BusinessException(errorCode); - } - } + public static void mustNotExceed(int size, Collection collection, ErrorCode errorCode) { + if (collection.size() > size) { + throw new BusinessException(errorCode); + } + } } diff --git a/src/main/java/com/gg/server/global/utils/EloRating.java b/src/main/java/com/gg/server/global/utils/EloRating.java index 4de09cc34..d21dc57ed 100644 --- a/src/main/java/com/gg/server/global/utils/EloRating.java +++ b/src/main/java/com/gg/server/global/utils/EloRating.java @@ -1,15 +1,15 @@ package com.gg.server.global.utils; public class EloRating { - public static Integer pppChange(Integer myPPP, Integer opponentPPP, Boolean isWin, Boolean isOneSide) { - Double we = 1.0 / (Math.pow(10.0, (opponentPPP - myPPP) / 400.0) + 1.0); - Double change = 40 * ((isWin ? 1 : 0) - we); - if (isOneSide) { - change = change + change * 0.21; - } - if (change < 0) { - change = change * 0.9; - } - return change.intValue(); - } + public static Integer pppChange(Integer myPPP, Integer opponentPPP, Boolean isWin, Boolean isOneSide) { + Double we = 1.0 / (Math.pow(10.0, (opponentPPP - myPPP) / 400.0) + 1.0); + Double change = 40 * ((isWin ? 1 : 0) - we); + if (isOneSide) { + change = change + change * 0.21; + } + if (change < 0) { + change = change * 0.9; + } + return change.intValue(); + } } diff --git a/src/main/java/com/gg/server/global/utils/ExpLevelCalculator.java b/src/main/java/com/gg/server/global/utils/ExpLevelCalculator.java index 7257dca5a..a6a355c49 100644 --- a/src/main/java/com/gg/server/global/utils/ExpLevelCalculator.java +++ b/src/main/java/com/gg/server/global/utils/ExpLevelCalculator.java @@ -1,46 +1,46 @@ package com.gg.server.global.utils; public class ExpLevelCalculator { - private static Integer expPerGame = 100; - private static Integer expBonus = 10; - private static int[] accumulatedExpForEachLevel = { - 0, 100, 200, 300, 500, 700, 900, 1200, 1500, 1800, - 2200, 2600, 3000, 3400, 3800, 4300, 4800, 5300, 5800, 6300, - 6900, 7500, 8100, 8700, 9300, 10000, 10700, 11400, 12100, 12800, - 13600, 14400, 15200, 16000, 16800, 17700, 18600, 19500, 20400, 21300, - 22300, 25100, Integer.MAX_VALUE - }; + private static Integer expPerGame = 100; + private static Integer expBonus = 10; + private static int[] accumulatedExpForEachLevel = { + 0, 100, 200, 300, 500, 700, 900, 1200, 1500, 1800, + 2200, 2600, 3000, 3400, 3800, 4300, 4800, 5300, 5800, 6300, + 6900, 7500, 8100, 8700, 9300, 10000, 10700, 11400, 12100, 12800, + 13600, 14400, 15200, 16000, 16800, 17700, 18600, 19500, 20400, 21300, + 22300, 25100, Integer.MAX_VALUE + }; - private static int[] expForEachLevel = { - 0, 100, 100, 100, 200, 200, 200, 300, 300, 300, - 400, 400, 400, 400, 400, 500, 500, 500, 500, 500, - 600, 600, 600, 600, 600, 700, 700, 700, 700, 700, - 800, 800, 800, 800, 800, 900, 900, 900, 900, 900, - 1000, 2800, Integer.MAX_VALUE - }; + private static int[] expForEachLevel = { + 0, 100, 100, 100, 200, 200, 200, 300, 300, 300, + 400, 400, 400, 400, 400, 500, 500, 500, 500, 500, + 600, 600, 600, 600, 600, 700, 700, 700, 700, 700, + 800, 800, 800, 800, 800, 900, 900, 900, 900, 900, + 1000, 2800, Integer.MAX_VALUE + }; - public static int getLevel(int total_exp) { - int i = 0; - while (total_exp >= accumulatedExpForEachLevel[i]) { - ++i; - } - return i; - } + public static int getLevel(int totalExp) { + int idx = 0; + while (totalExp >= accumulatedExpForEachLevel[idx]) { + ++idx; + } + return idx; + } - public static int getCurrentLevelMyExp(int total_exp) { - int level = getLevel(total_exp); - return total_exp - accumulatedExpForEachLevel[level - 1]; - } + public static int getCurrentLevelMyExp(int totalExp) { + int level = getLevel(totalExp); + return totalExp - accumulatedExpForEachLevel[level - 1]; + } - public static int getLevelMaxExp(int level) { - return expForEachLevel[level]; - } + public static int getLevelMaxExp(int level) { + return expForEachLevel[level]; + } - public static int getExpPerGame() { - return expPerGame; - } + public static int getExpPerGame() { + return expPerGame; + } - public static int getExpBonus() { - return expBonus; - } + public static int getExpBonus() { + return expBonus; + } } diff --git a/src/main/java/com/gg/server/global/utils/FileDownloader.java b/src/main/java/com/gg/server/global/utils/FileDownloader.java index c01c64a28..aa8746195 100644 --- a/src/main/java/com/gg/server/global/utils/FileDownloader.java +++ b/src/main/java/com/gg/server/global/utils/FileDownloader.java @@ -10,25 +10,25 @@ @Component public class FileDownloader { - private RestTemplate restTemplate; + private RestTemplate restTemplate; - public FileDownloader() { - HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(); - factory.setConnectTimeout(5000); // 타임아웃 설정 5초 - factory.setReadTimeout(5000); // 타임아웃 설정 5초 + public FileDownloader() { + HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(); + factory.setConnectTimeout(5000); // 타임아웃 설정 5초 + factory.setReadTimeout(5000); // 타임아웃 설정 5초 - //Apache HttpComponents : 각 호스트(IP와 Port의 조합)당 커넥션 풀에 생성가능한 커넥션 수 - HttpClient httpClient = HttpClientBuilder.create() - .setMaxConnTotal(50)//최대 커넥션 수 - .setMaxConnPerRoute(20).build(); - factory.setHttpClient(httpClient); + //Apache HttpComponents : 각 호스트(IP와 Port의 조합)당 커넥션 풀에 생성가능한 커넥션 수 + HttpClient httpClient = HttpClientBuilder.create() + .setMaxConnTotal(50)//최대 커넥션 수 + .setMaxConnPerRoute(20).build(); + factory.setHttpClient(httpClient); - // 2. RestTemplate 객체를 생성합니다. - this.restTemplate = new RestTemplate(factory); - } + // 2. RestTemplate 객체를 생성합니다. + this.restTemplate = new RestTemplate(factory); + } - public byte[] downloadFromUrl(String imageUrl) { - UriComponents uri = UriComponentsBuilder.fromHttpUrl(imageUrl).build(false); - return restTemplate.getForObject(uri.toString(), byte[].class); - } -} \ No newline at end of file + public byte[] downloadFromUrl(String imageUrl) { + UriComponents uri = UriComponentsBuilder.fromHttpUrl(imageUrl).build(false); + return restTemplate.getForObject(uri.toString(), byte[].class); + } +} diff --git a/src/main/java/com/gg/server/global/utils/HeaderUtil.java b/src/main/java/com/gg/server/global/utils/HeaderUtil.java index 25f5352e8..d114e3d6a 100644 --- a/src/main/java/com/gg/server/global/utils/HeaderUtil.java +++ b/src/main/java/com/gg/server/global/utils/HeaderUtil.java @@ -4,19 +4,19 @@ public class HeaderUtil { - private final static String HEADER_AUTHORIZATION = "Authorization"; - private final static String TOKEN_PREFIX = "Bearer "; + private static final String HEADER_AUTHORIZATION = "Authorization"; + private static final String TOKEN_PREFIX = "Bearer "; - public static String getAccessToken(HttpServletRequest request) { - String headerValue = request.getHeader(HEADER_AUTHORIZATION); + public static String getAccessToken(HttpServletRequest request) { + String headerValue = request.getHeader(HEADER_AUTHORIZATION); - if (headerValue == null) { - return null; - } + if (headerValue == null) { + return null; + } - if (headerValue.startsWith(TOKEN_PREFIX)) { - return headerValue.substring(TOKEN_PREFIX.length()); - } - return null; - } + if (headerValue.startsWith(TOKEN_PREFIX)) { + return headerValue.substring(TOKEN_PREFIX.length()); + } + return null; + } } diff --git a/src/main/java/com/gg/server/global/utils/ImageResizingUtil.java b/src/main/java/com/gg/server/global/utils/ImageResizingUtil.java index bd114844e..c340af35d 100644 --- a/src/main/java/com/gg/server/global/utils/ImageResizingUtil.java +++ b/src/main/java/com/gg/server/global/utils/ImageResizingUtil.java @@ -1,28 +1,29 @@ package com.gg.server.global.utils; -import javax.imageio.ImageIO; -import java.awt.*; +import java.awt.Image; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import javax.imageio.ImageIO; + public class ImageResizingUtil { - public static byte[] resizeImageBytes(byte[] downloadedImageBytes, double ratio) throws IOException { - InputStream inputStream = new ByteArrayInputStream(downloadedImageBytes); - BufferedImage image = resize(ImageIO.read(inputStream), ratio); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ImageIO.write(image, "jpeg", baos); - return baos.toByteArray(); - } + public static byte[] resizeImageBytes(byte[] downloadedImageBytes, double ratio) throws IOException { + InputStream inputStream = new ByteArrayInputStream(downloadedImageBytes); + BufferedImage image = resize(ImageIO.read(inputStream), ratio); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ImageIO.write(image, "jpeg", baos); + return baos.toByteArray(); + } - private static BufferedImage resize(BufferedImage img, double ratio) { - int newWidth = (int) (img.getWidth() * ratio); - int newHeight = (int) (img.getHeight() * ratio); - Image imageToResize = img.getScaledInstance(newWidth, newHeight, Image.SCALE_SMOOTH); - BufferedImage resizedImage = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_RGB); - resizedImage.getGraphics().drawImage(imageToResize, 0, 0, newWidth, newHeight, null); - return resizedImage; - } + private static BufferedImage resize(BufferedImage img, double ratio) { + int newWidth = (int)(img.getWidth() * ratio); + int newHeight = (int)(img.getHeight() * ratio); + Image imageToResize = img.getScaledInstance(newWidth, newHeight, Image.SCALE_SMOOTH); + BufferedImage resizedImage = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_RGB); + resizedImage.getGraphics().drawImage(imageToResize, 0, 0, newWidth, newHeight, null); + return resizedImage; + } } diff --git a/src/main/java/com/gg/server/global/utils/ItemImageHandler.java b/src/main/java/com/gg/server/global/utils/ItemImageHandler.java index dfcd319c9..e132c2d1e 100644 --- a/src/main/java/com/gg/server/global/utils/ItemImageHandler.java +++ b/src/main/java/com/gg/server/global/utils/ItemImageHandler.java @@ -1,51 +1,53 @@ package com.gg.server.global.utils; +import java.io.IOException; +import java.io.InputStream; +import java.util.UUID; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.model.CannedAccessControlList; import com.amazonaws.services.s3.model.ObjectMetadata; import com.amazonaws.services.s3.model.PutObjectRequest; import com.gg.server.domain.item.data.Item; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.io.InputStream; -import java.util.UUID; @Component public class ItemImageHandler { - private final AmazonS3 amazonS3; - - public ItemImageHandler(AmazonS3 amazonS3) { - this.amazonS3 = amazonS3; - } - - @Value("${cloud.aws.s3.bucket}") - private String bucketName; - - @Value("${cloud.aws.s3.dir}") - private String dir; - - @Value("${info.image.defaultUrl}") - private String defaultImageUrl; - - public String updateAndGetS3ImageUri(MultipartFile multipartFile, Item item) throws IOException { - String itemFileName = item.getName() + "-" + UUID.randomUUID() + ".jpeg"; - if (itemFileName.equals("small_default.jpeg")) - return defaultImageUrl; - else { - String s3ImageUrl = uploadToS3(multipartFile, itemFileName); - return s3ImageUrl; - } - } - - public String uploadToS3(MultipartFile multipartFile, String fileName) throws IOException { - String s3FileName = dir + fileName; - InputStream inputStream = multipartFile.getInputStream(); - ObjectMetadata objMeta = new ObjectMetadata(); - objMeta.setContentLength(multipartFile.getSize()); - amazonS3.putObject(new PutObjectRequest(bucketName, s3FileName, inputStream, objMeta).withCannedAcl(CannedAccessControlList.PublicRead)); - return amazonS3.getUrl(bucketName, s3FileName).toString(); - } + private final AmazonS3 amazonS3; + + public ItemImageHandler(AmazonS3 amazonS3) { + this.amazonS3 = amazonS3; + } + + @Value("${cloud.aws.s3.bucket}") + private String bucketName; + + @Value("${cloud.aws.s3.dir}") + private String dir; + + @Value("${info.image.defaultUrl}") + private String defaultImageUrl; + + public String updateAndGetS3ImageUri(MultipartFile multipartFile, Item item) throws IOException { + String itemFileName = item.getName() + "-" + UUID.randomUUID() + ".jpeg"; + if (itemFileName.equals("small_default.jpeg")) { + return defaultImageUrl; + } else { + String s3ImageUrl = uploadToS3(multipartFile, itemFileName); + return s3ImageUrl; + } + } + + public String uploadToS3(MultipartFile multipartFile, String fileName) throws IOException { + String s3FileName = dir + fileName; + InputStream inputStream = multipartFile.getInputStream(); + ObjectMetadata objMeta = new ObjectMetadata(); + objMeta.setContentLength(multipartFile.getSize()); + amazonS3.putObject(new PutObjectRequest(bucketName, s3FileName, inputStream, objMeta).withCannedAcl( + CannedAccessControlList.PublicRead)); + return amazonS3.getUrl(bucketName, s3FileName).toString(); + } } diff --git a/src/main/java/com/gg/server/global/utils/JpegMultipartFile.java b/src/main/java/com/gg/server/global/utils/JpegMultipartFile.java index 84a8fb806..f7836f4b2 100644 --- a/src/main/java/com/gg/server/global/utils/JpegMultipartFile.java +++ b/src/main/java/com/gg/server/global/utils/JpegMultipartFile.java @@ -1,66 +1,66 @@ package com.gg.server.global.utils; -import org.springframework.web.multipart.MultipartFile; - import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; +import org.springframework.web.multipart.MultipartFile; + public class JpegMultipartFile implements MultipartFile { - private final byte[] bytes; - String name; - String originalFilename; - String contentType; - boolean isEmpty; - long size; + private final byte[] bytes; + String name; + String originalFilename; + String contentType; + boolean isEmpty; + long size; - public JpegMultipartFile(byte[] bytes, String name) { - this.bytes = bytes; - this.name = name; - this.originalFilename = name + ".jpeg"; - this.contentType = "image/jpeg"; - this.size = bytes.length; - this.isEmpty = false; - } + public JpegMultipartFile(byte[] bytes, String name) { + this.bytes = bytes; + this.name = name; + this.originalFilename = name + ".jpeg"; + this.contentType = "image/jpeg"; + this.size = bytes.length; + this.isEmpty = false; + } - @Override - public String getName() { - return name; - } + @Override + public String getName() { + return name; + } - @Override - public String getOriginalFilename() { - return originalFilename; - } + @Override + public String getOriginalFilename() { + return originalFilename; + } - @Override - public String getContentType() { - return contentType; - } + @Override + public String getContentType() { + return contentType; + } - @Override - public boolean isEmpty() { - return isEmpty; - } + @Override + public boolean isEmpty() { + return isEmpty; + } - @Override - public long getSize() { - return size; - } + @Override + public long getSize() { + return size; + } - @Override - public byte[] getBytes() throws IOException { - return bytes; - } + @Override + public byte[] getBytes() throws IOException { + return bytes; + } - @Override - public InputStream getInputStream() { - return new ByteArrayInputStream(bytes); - } + @Override + public InputStream getInputStream() { + return new ByteArrayInputStream(bytes); + } - @Override - public void transferTo(File dest) throws IllegalStateException { - } + @Override + public void transferTo(File dest) throws IllegalStateException { + } } diff --git a/src/main/java/com/gg/server/global/utils/UserImageHandler.java b/src/main/java/com/gg/server/global/utils/UserImageHandler.java index a29e0037d..647f19ea5 100644 --- a/src/main/java/com/gg/server/global/utils/UserImageHandler.java +++ b/src/main/java/com/gg/server/global/utils/UserImageHandler.java @@ -1,78 +1,78 @@ -package com.gg.server.global.utils; - -import com.amazonaws.services.s3.AmazonS3; -import com.amazonaws.services.s3.model.CannedAccessControlList; -import com.amazonaws.services.s3.model.ObjectMetadata; -import com.amazonaws.services.s3.model.PutObjectRequest; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserImage; -import com.gg.server.domain.user.data.UserImageRepository; -import com.gg.server.domain.user.exception.UserImageNullException; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.io.InputStream; -import java.util.UUID; - -@Component -public class UserImageHandler { - private final AmazonS3 amazonS3; - private final FileDownloader fileDownloader; - - public UserImageHandler(AmazonS3 amazonS3, FileDownloader fileDownloader, - UserImageRepository userImageRepository) { - this.amazonS3 = amazonS3; - this.fileDownloader = fileDownloader; - this.userImageRepository = userImageRepository; - } - - @Value("${cloud.aws.s3.bucket}") - private String bucketName; - - @Value("${cloud.aws.s3.dir}") - private String dir; - - @Value("${info.image.defaultUrl}") - private String defaultImageUrl; - private final UserImageRepository userImageRepository; - - public String uploadAndGetS3ImageUri(String intraId, String imageUrl) { - if (!isStringValid(intraId) || !isStringValid(imageUrl)) { - return defaultImageUrl; - } - byte[] downloadedImageBytes = fileDownloader.downloadFromUrl(imageUrl); - try { - byte[] resizedImageBytes = ImageResizingUtil.resizeImageBytes(downloadedImageBytes, 0.5); - MultipartFile multipartFile = new JpegMultipartFile(resizedImageBytes, intraId); - return uploadToS3(multipartFile, multipartFile.getOriginalFilename()); - } catch (IOException e) { - return defaultImageUrl; - } - } - - public String updateAndGetS3ImageUri(MultipartFile multipartFile, User user) throws IOException - { - String updateFileName = user.getIntraId() + "-" + UUID.randomUUID().toString() + ".jpeg"; - if (updateFileName.equals("small_default.jpeg")) - return defaultImageUrl; - else { - String s3ImageUrl = uploadToS3(multipartFile, updateFileName);; - return s3ImageUrl; - } - } - - private Boolean isStringValid(String intraId) { - return intraId != null && intraId.length() != 0; - } - - public String uploadToS3(MultipartFile multipartFile, String fileName) throws IOException{ - String s3FileName = dir + fileName; - InputStream inputStream = multipartFile.getInputStream(); - ObjectMetadata objMeta = new ObjectMetadata(); - objMeta.setContentLength(multipartFile.getSize()); - amazonS3.putObject(new PutObjectRequest(bucketName, s3FileName, inputStream, objMeta).withCannedAcl(CannedAccessControlList.PublicRead)); - return amazonS3.getUrl(bucketName, s3FileName).toString(); - } -} +package com.gg.server.global.utils; + +import java.io.IOException; +import java.io.InputStream; +import java.util.UUID; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.model.CannedAccessControlList; +import com.amazonaws.services.s3.model.ObjectMetadata; +import com.amazonaws.services.s3.model.PutObjectRequest; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserImageRepository; + +@Component +public class UserImageHandler { + private final AmazonS3 amazonS3; + private final FileDownloader fileDownloader; + + public UserImageHandler(AmazonS3 amazonS3, FileDownloader fileDownloader, + UserImageRepository userImageRepository) { + this.amazonS3 = amazonS3; + this.fileDownloader = fileDownloader; + this.userImageRepository = userImageRepository; + } + + @Value("${cloud.aws.s3.bucket}") + private String bucketName; + + @Value("${cloud.aws.s3.dir}") + private String dir; + + @Value("${info.image.defaultUrl}") + private String defaultImageUrl; + private final UserImageRepository userImageRepository; + + public String uploadAndGetS3ImageUri(String intraId, String imageUrl) { + if (!isStringValid(intraId) || !isStringValid(imageUrl)) { + return defaultImageUrl; + } + byte[] downloadedImageBytes = fileDownloader.downloadFromUrl(imageUrl); + try { + byte[] resizedImageBytes = ImageResizingUtil.resizeImageBytes(downloadedImageBytes, 0.5); + MultipartFile multipartFile = new JpegMultipartFile(resizedImageBytes, intraId); + return uploadToS3(multipartFile, multipartFile.getOriginalFilename()); + } catch (IOException e) { + return defaultImageUrl; + } + } + + public String updateAndGetS3ImageUri(MultipartFile multipartFile, User user) throws IOException { + String updateFileName = user.getIntraId() + "-" + UUID.randomUUID().toString() + ".jpeg"; + if (updateFileName.equals("small_default.jpeg")) { + return defaultImageUrl; + } else { + String s3ImageUrl = uploadToS3(multipartFile, updateFileName); + ; + return s3ImageUrl; + } + } + + private Boolean isStringValid(String intraId) { + return intraId != null && intraId.length() != 0; + } + + public String uploadToS3(MultipartFile multipartFile, String fileName) throws IOException { + String s3FileName = dir + fileName; + InputStream inputStream = multipartFile.getInputStream(); + ObjectMetadata objMeta = new ObjectMetadata(); + objMeta.setContentLength(multipartFile.getSize()); + amazonS3.putObject(new PutObjectRequest(bucketName, s3FileName, inputStream, objMeta).withCannedAcl( + CannedAccessControlList.PublicRead)); + return amazonS3.getUrl(bucketName, s3FileName).toString(); + } +} diff --git a/src/main/java/com/gg/server/global/utils/argumentresolver/LoginMemberArgumentResolver.java b/src/main/java/com/gg/server/global/utils/argumentresolver/LoginMemberArgumentResolver.java index 36fabe80f..7052f6c40 100644 --- a/src/main/java/com/gg/server/global/utils/argumentresolver/LoginMemberArgumentResolver.java +++ b/src/main/java/com/gg/server/global/utils/argumentresolver/LoginMemberArgumentResolver.java @@ -1,39 +1,41 @@ -package com.gg.server.global.utils.argumentresolver; - -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.global.utils.HeaderUtil; -import lombok.RequiredArgsConstructor; -import org.springframework.core.MethodParameter; -import org.springframework.web.bind.support.WebDataBinderFactory; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.method.support.HandlerMethodArgumentResolver; -import org.springframework.web.method.support.ModelAndViewContainer; - -import javax.servlet.http.HttpServletRequest; - -@RequiredArgsConstructor -public class LoginMemberArgumentResolver implements HandlerMethodArgumentResolver { - private final UserRepository userRepository; - private final AuthTokenProvider tokenProvider; - - @Override - public boolean supportsParameter(MethodParameter parameter) { - boolean hasLoginAnnotation = parameter.hasParameterAnnotation(Login.class); - boolean hasUserType = UserDto.class.isAssignableFrom(parameter.getParameterType()); - return hasLoginAnnotation && hasUserType; - } - - @Override - public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, - NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { - HttpServletRequest request = (HttpServletRequest)webRequest.getNativeRequest(); - String accessToken = HeaderUtil.getAccessToken(request); - Long loginUserId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.findById(loginUserId).orElseThrow(); - UserDto userDto = UserDto.from(user); - return userDto; - } -} +package com.gg.server.global.utils.argumentresolver; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.core.MethodParameter; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.method.support.ModelAndViewContainer; + +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.global.utils.HeaderUtil; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +public class LoginMemberArgumentResolver implements HandlerMethodArgumentResolver { + private final UserRepository userRepository; + private final AuthTokenProvider tokenProvider; + + @Override + public boolean supportsParameter(MethodParameter parameter) { + boolean hasLoginAnnotation = parameter.hasParameterAnnotation(Login.class); + boolean hasUserType = UserDto.class.isAssignableFrom(parameter.getParameterType()); + return hasLoginAnnotation && hasUserType; + } + + @Override + public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, + NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { + HttpServletRequest request = (HttpServletRequest)webRequest.getNativeRequest(); + String accessToken = HeaderUtil.getAccessToken(request); + Long loginUserId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.findById(loginUserId).orElseThrow(); + UserDto userDto = UserDto.from(user); + return userDto; + } +} diff --git a/src/main/java/com/gg/server/global/utils/aws/AsyncNewItemImageUploader.java b/src/main/java/com/gg/server/global/utils/aws/AsyncNewItemImageUploader.java index 5dcce6806..e092bf97d 100644 --- a/src/main/java/com/gg/server/global/utils/aws/AsyncNewItemImageUploader.java +++ b/src/main/java/com/gg/server/global/utils/aws/AsyncNewItemImageUploader.java @@ -1,33 +1,34 @@ package com.gg.server.global.utils.aws; -import com.gg.server.domain.item.data.Item; -import com.gg.server.global.utils.ItemImageHandler; +import java.io.IOException; + import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; +import com.gg.server.domain.item.data.Item; +import com.gg.server.global.utils.ItemImageHandler; @Component public class AsyncNewItemImageUploader { - private final ItemImageHandler itemImageHandler; + private final ItemImageHandler itemImageHandler; - @Value("${info.image.itemNotFoundUrl}") - private String defaultImageUrl; + @Value("${info.image.itemNotFoundUrl}") + private String defaultImageUrl; - public AsyncNewItemImageUploader(ItemImageHandler itemImageHandler) { - this.itemImageHandler = itemImageHandler; - } + public AsyncNewItemImageUploader(ItemImageHandler itemImageHandler) { + this.itemImageHandler = itemImageHandler; + } - @Transactional - public void upload(Item item, - MultipartFile multipartFile) throws IOException { - String s3ImageUrl = itemImageHandler.updateAndGetS3ImageUri(multipartFile, item); - if (s3ImageUrl == null) { - item.imageUpdate(defaultImageUrl); - } else { - item.imageUpdate(s3ImageUrl); - } - } + @Transactional + public void upload(Item item, + MultipartFile multipartFile) throws IOException { + String s3ImageUrl = itemImageHandler.updateAndGetS3ImageUri(multipartFile, item); + if (s3ImageUrl == null) { + item.imageUpdate(defaultImageUrl); + } else { + item.imageUpdate(s3ImageUrl); + } + } } diff --git a/src/main/java/com/gg/server/global/utils/aws/AsyncNewUserImageUploader.java b/src/main/java/com/gg/server/global/utils/aws/AsyncNewUserImageUploader.java index 72ef157d6..ace0e6e7a 100644 --- a/src/main/java/com/gg/server/global/utils/aws/AsyncNewUserImageUploader.java +++ b/src/main/java/com/gg/server/global/utils/aws/AsyncNewUserImageUploader.java @@ -1,63 +1,66 @@ -package com.gg.server.global.utils.aws; - -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserImage; -import com.gg.server.domain.user.data.UserImageRepository; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.utils.UserImageHandler; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.multipart.MultipartFile; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import java.io.IOException; -import java.time.LocalDateTime; - -@Slf4j -@Component -public class AsyncNewUserImageUploader { - private final UserImageHandler userImageHandler; - private final UserRepository userRepository; - @PersistenceContext - private EntityManager entityManager; - - @Value("${info.image.defaultUrl}") - private String defaultImageUrl; - private final UserImageRepository userImageRepository; - - public AsyncNewUserImageUploader(UserImageHandler userImageHandler, UserRepository userRepository, - UserImageRepository userImageRepository) { - this.userImageHandler = userImageHandler; - this.userRepository = userRepository; - this.userImageRepository = userImageRepository; - } - - @Async("asyncExecutor") - @Transactional - public void upload(String intraId, String imageUrl) { - String s3ImageUrl = userImageHandler.uploadAndGetS3ImageUri(intraId, imageUrl); - if (defaultImageUrl.equals(s3ImageUrl)) { - return ; - } - userRepository.findByIntraId(intraId).ifPresent(user -> { - UserImage userImage = new UserImage(user, (s3ImageUrl != null) ? s3ImageUrl : defaultImageUrl, - LocalDateTime.now(), null, true); - userImageRepository.save(userImage); - userRepository.updateUserImage(user.getId(), userImage.getImageUri()); - }); - } - - @Transactional - public void update(String intraId, MultipartFile multipartFile) throws IOException { - User user = userRepository.findByIntraId(intraId).get(); - String s3ImageUrl = userImageHandler.updateAndGetS3ImageUri(multipartFile, user); - s3ImageUrl = s3ImageUrl == null ? defaultImageUrl : s3ImageUrl; - UserImage userImage = new UserImage(user, s3ImageUrl, LocalDateTime.now(), null, true); - userImageRepository.saveAndFlush(userImage); - user.updateImageUri(s3ImageUrl); - } -} +package com.gg.server.global.utils.aws; + +import java.io.IOException; +import java.time.LocalDateTime; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserImage; +import com.gg.server.domain.user.data.UserImageRepository; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.global.utils.UserImageHandler; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Component +public class AsyncNewUserImageUploader { + private final UserImageHandler userImageHandler; + private final UserRepository userRepository; + @PersistenceContext + private EntityManager entityManager; + + @Value("${info.image.defaultUrl}") + private String defaultImageUrl; + private final UserImageRepository userImageRepository; + + public AsyncNewUserImageUploader(UserImageHandler userImageHandler, UserRepository userRepository, + UserImageRepository userImageRepository) { + this.userImageHandler = userImageHandler; + this.userRepository = userRepository; + this.userImageRepository = userImageRepository; + } + + @Async("asyncExecutor") + @Transactional + public void upload(String intraId, String imageUrl) { + String s3ImageUrl = userImageHandler.uploadAndGetS3ImageUri(intraId, imageUrl); + if (defaultImageUrl.equals(s3ImageUrl)) { + return; + } + userRepository.findByIntraId(intraId).ifPresent(user -> { + UserImage userImage = new UserImage(user, (s3ImageUrl != null) ? s3ImageUrl : defaultImageUrl, + LocalDateTime.now(), null, true); + userImageRepository.save(userImage); + userRepository.updateUserImage(user.getId(), userImage.getImageUri()); + }); + } + + @Transactional + public void update(String intraId, MultipartFile multipartFile) throws IOException { + User user = userRepository.findByIntraId(intraId).get(); + String s3ImageUrl = userImageHandler.updateAndGetS3ImageUri(multipartFile, user); + s3ImageUrl = s3ImageUrl == null ? defaultImageUrl : s3ImageUrl; + UserImage userImage = new UserImage(user, s3ImageUrl, LocalDateTime.now(), null, true); + userImageRepository.saveAndFlush(userImage); + user.updateImageUri(s3ImageUrl); + } +} diff --git a/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryCounter.java b/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryCounter.java index b7a5c9a69..78f73ab30 100644 --- a/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryCounter.java +++ b/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryCounter.java @@ -1,16 +1,17 @@ package com.gg.server.global.utils.querytracker; -import lombok.Getter; import org.springframework.stereotype.Component; import org.springframework.web.context.annotation.RequestScope; +import lombok.Getter; + @Component @RequestScope @Getter public class ApiQueryCounter { - private int count; + private int count; - public void increaseCount() { - this.count++; - } + public void increaseCount() { + this.count++; + } } diff --git a/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryCounterAop.java b/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryCounterAop.java index 120c9a167..bd484d4e2 100644 --- a/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryCounterAop.java +++ b/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryCounterAop.java @@ -10,19 +10,19 @@ @Aspect public class ApiQueryCounterAop { - private final ApiQueryCounter apiQueryCounter; + private final ApiQueryCounter apiQueryCounter; - public ApiQueryCounterAop(final ApiQueryCounter apiQueryCounter) { - this.apiQueryCounter = apiQueryCounter; - } + public ApiQueryCounterAop(final ApiQueryCounter apiQueryCounter) { + this.apiQueryCounter = apiQueryCounter; + } - @Around("execution(* javax.sql.DataSource.getConnection())") - public Object getConnection(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { - Object connection = proceedingJoinPoint.proceed(); - return Proxy.newProxyInstance( - connection.getClass().getClassLoader(), - connection.getClass().getInterfaces(), - new ConnectionProxyHandler(connection, apiQueryCounter) - ); - } -} \ No newline at end of file + @Around("execution(* javax.sql.DataSource.getConnection())") + public Object getConnection(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { + Object connection = proceedingJoinPoint.proceed(); + return Proxy.newProxyInstance( + connection.getClass().getClassLoader(), + connection.getClass().getInterfaces(), + new ConnectionProxyHandler(connection, apiQueryCounter) + ); + } +} diff --git a/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryInspector.java b/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryInspector.java index 2d7d236df..be39ce8e2 100644 --- a/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryInspector.java +++ b/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryInspector.java @@ -1,29 +1,29 @@ package com.gg.server.global.utils.querytracker; +import java.util.Objects; + import org.hibernate.resource.jdbc.spi.StatementInspector; import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestContextHolder; -import java.util.Objects; - @Component public class ApiQueryInspector implements StatementInspector { - private final ApiQueryCounter apiQueryCounter; + private final ApiQueryCounter apiQueryCounter; - public ApiQueryInspector(final ApiQueryCounter apiQueryCounter) { - this.apiQueryCounter = apiQueryCounter; - } + public ApiQueryInspector(final ApiQueryCounter apiQueryCounter) { + this.apiQueryCounter = apiQueryCounter; + } - @Override - public String inspect(final String sql) { - if (isInRequestScope()) { - apiQueryCounter.increaseCount(); - } - return sql; - } + @Override + public String inspect(final String sql) { + if (isInRequestScope()) { + apiQueryCounter.increaseCount(); + } + return sql; + } - private boolean isInRequestScope() { - return Objects.nonNull(RequestContextHolder.getRequestAttributes()); - } + private boolean isInRequestScope() { + return Objects.nonNull(RequestContextHolder.getRequestAttributes()); + } } diff --git a/src/main/java/com/gg/server/global/utils/querytracker/ConnectionProxyHandler.java b/src/main/java/com/gg/server/global/utils/querytracker/ConnectionProxyHandler.java index 3a5a6f5d6..6fc63dee1 100644 --- a/src/main/java/com/gg/server/global/utils/querytracker/ConnectionProxyHandler.java +++ b/src/main/java/com/gg/server/global/utils/querytracker/ConnectionProxyHandler.java @@ -1,30 +1,30 @@ package com.gg.server.global.utils.querytracker; +import java.lang.reflect.Method; + import org.springframework.cglib.proxy.InvocationHandler; import org.springframework.cglib.proxy.Proxy; -import java.lang.reflect.Method; - public class ConnectionProxyHandler implements InvocationHandler { - private final Object connection; - private final ApiQueryCounter apiQueryCounter; + private final Object connection; + private final ApiQueryCounter apiQueryCounter; - public ConnectionProxyHandler(final Object connection, final ApiQueryCounter apiQueryCounter) { - this.connection = connection; - this.apiQueryCounter = apiQueryCounter; - } + public ConnectionProxyHandler(final Object connection, final ApiQueryCounter apiQueryCounter) { + this.connection = connection; + this.apiQueryCounter = apiQueryCounter; + } - @Override - public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { - Object invokeResult = method.invoke(connection, args); // (1) - if (method.getName().equals("prepareStatement")) { - return Proxy.newProxyInstance( - invokeResult.getClass().getClassLoader(), - invokeResult.getClass().getInterfaces(), - new PreparedStatementProxyHandler(invokeResult, apiQueryCounter) - ); - } - return invokeResult; - } -} \ No newline at end of file + @Override + public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { + Object invokeResult = method.invoke(connection, args); // (1) + if (method.getName().equals("prepareStatement")) { + return Proxy.newProxyInstance( + invokeResult.getClass().getClassLoader(), + invokeResult.getClass().getInterfaces(), + new PreparedStatementProxyHandler(invokeResult, apiQueryCounter) + ); + } + return invokeResult; + } +} diff --git a/src/main/java/com/gg/server/global/utils/querytracker/LoggingInterceptor.java b/src/main/java/com/gg/server/global/utils/querytracker/LoggingInterceptor.java index 95d8387e3..73ac677c5 100644 --- a/src/main/java/com/gg/server/global/utils/querytracker/LoggingInterceptor.java +++ b/src/main/java/com/gg/server/global/utils/querytracker/LoggingInterceptor.java @@ -1,30 +1,31 @@ package com.gg.server.global.utils.querytracker; -import lombok.extern.slf4j.Slf4j; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.springframework.stereotype.Component; import org.springframework.web.servlet.HandlerInterceptor; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; @Slf4j @Component public class LoggingInterceptor implements HandlerInterceptor { - private static final String QUERY_COUNT_LOG_FORMAT = "STATUS_CODE: {}, METHOD: {}, URL: {}, QUERY_COUNT: {}"; + private static final String QUERY_COUNT_LOG_FORMAT = "STATUS_CODE: {}, METHOD: {}, URL: {}, QUERY_COUNT: {}"; - private final ApiQueryCounter apiQueryCounter; + private final ApiQueryCounter apiQueryCounter; - public LoggingInterceptor(final ApiQueryCounter apiQueryCounter) { - this.apiQueryCounter = apiQueryCounter; - } + public LoggingInterceptor(final ApiQueryCounter apiQueryCounter) { + this.apiQueryCounter = apiQueryCounter; + } - @Override - public void afterCompletion(final HttpServletRequest request, final HttpServletResponse response, - final Object handler, final Exception ex) { - final int queryCount = apiQueryCounter.getCount(); + @Override + public void afterCompletion(final HttpServletRequest request, final HttpServletResponse response, + final Object handler, final Exception ex) { + final int queryCount = apiQueryCounter.getCount(); - log.info(QUERY_COUNT_LOG_FORMAT, response.getStatus(), request.getMethod(), request.getRequestURI(), - queryCount); - } -} \ No newline at end of file + log.info(QUERY_COUNT_LOG_FORMAT, response.getStatus(), request.getMethod(), request.getRequestURI(), + queryCount); + } +} diff --git a/src/main/java/com/gg/server/global/utils/querytracker/PreparedStatementProxyHandler.java b/src/main/java/com/gg/server/global/utils/querytracker/PreparedStatementProxyHandler.java index 7dfff27a5..069771343 100644 --- a/src/main/java/com/gg/server/global/utils/querytracker/PreparedStatementProxyHandler.java +++ b/src/main/java/com/gg/server/global/utils/querytracker/PreparedStatementProxyHandler.java @@ -1,35 +1,35 @@ package com.gg.server.global.utils.querytracker; -import org.springframework.cglib.proxy.InvocationHandler; -import org.springframework.web.context.request.RequestContextHolder; - import java.lang.reflect.Method; import java.util.Objects; +import org.springframework.cglib.proxy.InvocationHandler; +import org.springframework.web.context.request.RequestContextHolder; + public class PreparedStatementProxyHandler implements InvocationHandler { - private final Object preparedStatement; - private final ApiQueryCounter apiQueryCounter; - - public PreparedStatementProxyHandler(final Object preparedStatement, final ApiQueryCounter apiQueryCounter) { - this.preparedStatement = preparedStatement; - this.apiQueryCounter = apiQueryCounter; - } - - @Override // (1) - public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { - if (isExecuteQuery(method) && isInRequestScope()) { // (2) - apiQueryCounter.increaseCount(); - } - return method.invoke(preparedStatement, args); // (3) - } - - private boolean isExecuteQuery(final Method method) { - String methodName = method.getName(); - return methodName.equals("executeQuery") || methodName.equals("execute") || methodName.equals("executeUpdate"); - } - - private boolean isInRequestScope() { - return Objects.nonNull(RequestContextHolder.getRequestAttributes()); - } -} \ No newline at end of file + private final Object preparedStatement; + private final ApiQueryCounter apiQueryCounter; + + public PreparedStatementProxyHandler(final Object preparedStatement, final ApiQueryCounter apiQueryCounter) { + this.preparedStatement = preparedStatement; + this.apiQueryCounter = apiQueryCounter; + } + + @Override // (1) + public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { + if (isExecuteQuery(method) && isInRequestScope()) { // (2) + apiQueryCounter.increaseCount(); + } + return method.invoke(preparedStatement, args); // (3) + } + + private boolean isExecuteQuery(final Method method) { + String methodName = method.getName(); + return methodName.equals("executeQuery") || methodName.equals("execute") || methodName.equals("executeUpdate"); + } + + private boolean isInRequestScope() { + return Objects.nonNull(RequestContextHolder.getRequestAttributes()); + } +} diff --git a/src/test/java/com/gg/server/ServerApplicationTests.java b/src/test/java/com/gg/server/ServerApplicationTests.java index 41edb5630..1e1a1b9e0 100644 --- a/src/test/java/com/gg/server/ServerApplicationTests.java +++ b/src/test/java/com/gg/server/ServerApplicationTests.java @@ -1,11 +1,12 @@ package com.gg.server; -import com.gg.server.utils.annotation.IntegrationTest; +import java.util.TimeZone; + import org.assertj.core.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import java.util.TimeZone; +import com.gg.server.utils.annotation.IntegrationTest; @IntegrationTest class ServerApplicationTests { @@ -16,7 +17,7 @@ void contextLoads() { @Test @DisplayName("TimeZone Test") - public void TimeZoneTest() throws Exception { + public void timeZoneTest() throws Exception { TimeZone tz = TimeZone.getDefault(); Assertions.assertThat(tz.getID()).isEqualTo("Asia/Seoul"); diff --git a/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerFailTest.java b/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerFailTest.java index 69d181cf4..925fb0ba0 100644 --- a/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerFailTest.java +++ b/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerFailTest.java @@ -1,11 +1,8 @@ package com.gg.server.admin.announcement.controller; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.announcement.data.AnnouncementAdminRepository; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import lombok.RequiredArgsConstructor; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + import org.apache.http.HttpHeaders; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -14,60 +11,65 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.admin.announcement.data.AnnouncementAdminRepository; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc @Transactional public class AnnouncementAdminControllerFailTest { - @Autowired - TestDataUtils testDataUtils; + @Autowired + TestDataUtils testDataUtils; - @Autowired - private MockMvc mockMvc; + @Autowired + private MockMvc mockMvc; - @Autowired - ObjectMapper objectMapper; + @Autowired + ObjectMapper objectMapper; - @Autowired - AuthTokenProvider tokenProvider; + @Autowired + AuthTokenProvider tokenProvider; - @Autowired - AnnouncementAdminRepository announcementAdminRepository; + @Autowired + AnnouncementAdminRepository announcementAdminRepository; - @Test - @DisplayName("fail currentPage[Get]/pingpong/admin/announcement") - void failAnnouncementList1() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + @Test + @DisplayName("fail currentPage[Get]/pingpong/admin/announcement") + void failAnnouncementList1() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - Integer currentPage = 0; - Integer pageSize = 5;//페이지 사이즈 크기가 실제 디비 정보보다 큰지 확인할 것 + Integer currentPage = 0; + Integer pageSize = 5; //페이지 사이즈 크기가 실제 디비 정보보다 큰지 확인할 것 - String url = "/pingpong/admin/announcement?page=" + currentPage + "&size=" + pageSize; + String url = "/pingpong/admin/announcement?page=" + currentPage + "&size=" + pageSize; - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - } + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + } - @Test - @DisplayName("fail pageSize[Get]/pingpong/admin/announcement") - void failAnnouncementList2() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + @Test + @DisplayName("fail pageSize[Get]/pingpong/admin/announcement") + void failAnnouncementList2() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - Integer currentPage = 2; - Integer pageSize = 0;//페이지 사이즈 크기가 실제 디비 정보보다 큰지 확인할 것 + Integer currentPage = 2; + Integer pageSize = 0; //페이지 사이즈 크기가 실제 디비 정보보다 큰지 확인할 것 - String url = "/pingpong/admin/announcement?page=" + currentPage + "&size=" + pageSize; + String url = "/pingpong/admin/announcement?page=" + currentPage + "&size=" + pageSize; - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - } + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + } } diff --git a/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerTest.java b/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerTest.java index d25c1b935..6ce5c4f5a 100644 --- a/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerTest.java @@ -1,148 +1,152 @@ package com.gg.server.admin.announcement.controller; -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.assertj.core.api.Assertions.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import org.apache.http.HttpHeaders; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; import com.gg.server.admin.announcement.data.AnnouncementAdminRepository; import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; import com.gg.server.admin.announcement.dto.AnnouncementAdminListResponseDto; -import com.gg.server.utils.annotation.IntegrationTest; import com.gg.server.domain.announcement.data.Announcement; import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + import lombok.RequiredArgsConstructor; -import org.apache.http.HttpHeaders; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.transaction.annotation.Transactional; @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc @Transactional class AnnouncementAdminControllerTest { - @Autowired - TestDataUtils testDataUtils; - - @Autowired - private MockMvc mockMvc; - - @Autowired - ObjectMapper objectMapper; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - AnnouncementAdminRepository announcementAdminRepository; - - @Test - @DisplayName("[Get]/pingpong/admin/announcement") - void getAnnouncementList() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - - Integer currentPage = 2; - Integer pageSize = 5;//페이지 사이즈 크기가 실제 디비 정보보다 큰지 확인할 것 - - String url = "/pingpong/admin/announcement?page=" + currentPage + "&size=" + pageSize; - - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - //ResponseEntity announceListDtoResponse = objectMapper - // .readValue(contentAsString, new TypeReference>() {}); - //AnnouncementAdminListResponseDto announceListDto = announceListDtoResponse.getBody(); - AnnouncementAdminListResponseDto announceListDto = objectMapper.readValue(contentAsString, AnnouncementAdminListResponseDto.class); - - } - - @Test - @DisplayName("[Post]/pingpong/admin/announcement") - void addAnnouncement() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - testDataUtils.createAnnouncements(testDataUtils.createAdminUser(), 20); - //공지사항 1개 정책 때문에 기존 공지사항 지울 것 - Announcement delDto = announcementAdminRepository.findFirstByOrderByIdDesc().orElseThrow(()-> new AnnounceNotFoundException()); - announcementAdminRepository.delete(delDto); - - AnnouncementAdminAddDto addDto = new AnnouncementAdminAddDto("하나하나둘둘", "testId"); - - String content = objectMapper.writeValueAsString(addDto); - String url = "/pingpong/admin/announcement"; - - String contentAsString = mockMvc.perform(post(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isCreated()) - .andReturn().getResponse().getContentAsString(); - - Announcement result = announcementAdminRepository.findFirstByOrderByIdDesc().orElseThrow(()-> new AnnounceNotFoundException()); - - assertThat(result.getContent()).isEqualTo(addDto.getContent()); - assertThat(result.getCreatorIntraId()).isEqualTo(addDto.getCreatorIntraId()); - assertThat(result.getDeletedAt()).isNull(); - } - - @Test - @DisplayName("fail[Post]/pingpong/admin/announcement") - void addAnnouncementFail() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - - AnnouncementAdminAddDto addDto = new AnnouncementAdminAddDto("하나하나둘둘", null); - - String content = objectMapper.writeValueAsString(addDto); - String url = "/pingpong/admin/announcement"; - - String contentAsString = mockMvc.perform(post(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - - } - - @Test - @DisplayName("[Put]/pingpong/admin/announcement") - void putAnnouncement() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - testDataUtils.createAnnouncement(testDataUtils.createAdminUser(), "testContent"); - - //공지사항 1개 정책 때문에 기존 공지사항 지울 것 -// Announcement delDto = announcementAdminRepository.findFirstByOrderByIdDesc(); -// announcementAdminRepository.delete(delDto); - //공지사항 없으면 만들어 주는 과정 넣어 줄것 - - String url = "/pingpong/admin/announcement/"; - - String contentAsString = mockMvc.perform(delete(url + "deleterTestId") - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNoContent()) - .andReturn().getResponse().getContentAsString(); - - Announcement result = announcementAdminRepository.findFirstByOrderByIdDesc().orElseThrow(()-> new AnnounceNotFoundException()); - - assertThat(result.getDeleterIntraId()).isEqualTo("deleterTestId"); - assertThat(result.getDeletedAt()).isNotNull(); - System.out.println(result.getId()); - System.out.println(result.getDeleterIntraId()); - System.out.println(result.getDeletedAt()); - } - -} \ No newline at end of file + @Autowired + TestDataUtils testDataUtils; + + @Autowired + private MockMvc mockMvc; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + AuthTokenProvider tokenProvider; + + @Autowired + AnnouncementAdminRepository announcementAdminRepository; + + @Test + @DisplayName("[Get]/pingpong/admin/announcement") + void getAnnouncementList() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + + Integer currentPage = 2; + Integer pageSize = 5; //페이지 사이즈 크기가 실제 디비 정보보다 큰지 확인할 것 + + String url = "/pingpong/admin/announcement?page=" + currentPage + "&size=" + pageSize; + + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + //ResponseEntity announceListDtoResponse = objectMapper + // .readValue(contentAsString, new TypeReference>() {}); + //AnnouncementAdminListResponseDto announceListDto = announceListDtoResponse.getBody(); + AnnouncementAdminListResponseDto announceListDto = objectMapper.readValue(contentAsString, + AnnouncementAdminListResponseDto.class); + + } + + @Test + @DisplayName("[Post]/pingpong/admin/announcement") + void addAnnouncement() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + testDataUtils.createAnnouncements(testDataUtils.createAdminUser(), 20); + //공지사항 1개 정책 때문에 기존 공지사항 지울 것 + Announcement delDto = announcementAdminRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new AnnounceNotFoundException()); + announcementAdminRepository.delete(delDto); + + AnnouncementAdminAddDto addDto = new AnnouncementAdminAddDto("하나하나둘둘", "testId"); + + String content = objectMapper.writeValueAsString(addDto); + String url = "/pingpong/admin/announcement"; + + String contentAsString = mockMvc.perform(post(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isCreated()) + .andReturn().getResponse().getContentAsString(); + + Announcement result = announcementAdminRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new AnnounceNotFoundException()); + + assertThat(result.getContent()).isEqualTo(addDto.getContent()); + assertThat(result.getCreatorIntraId()).isEqualTo(addDto.getCreatorIntraId()); + assertThat(result.getDeletedAt()).isNull(); + } + + @Test + @DisplayName("fail[Post]/pingpong/admin/announcement") + void addAnnouncementFail() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + + AnnouncementAdminAddDto addDto = new AnnouncementAdminAddDto("하나하나둘둘", null); + + String content = objectMapper.writeValueAsString(addDto); + String url = "/pingpong/admin/announcement"; + + String contentAsString = mockMvc.perform(post(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + + } + + @Test + @DisplayName("[Put]/pingpong/admin/announcement") + void putAnnouncement() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + testDataUtils.createAnnouncement(testDataUtils.createAdminUser(), "testContent"); + + //공지사항 1개 정책 때문에 기존 공지사항 지울 것 + // Announcement delDto = announcementAdminRepository.findFirstByOrderByIdDesc(); + // announcementAdminRepository.delete(delDto); + //공지사항 없으면 만들어 주는 과정 넣어 줄것 + + String url = "/pingpong/admin/announcement/"; + + String contentAsString = mockMvc.perform(delete(url + "deleterTestId") + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNoContent()) + .andReturn().getResponse().getContentAsString(); + + Announcement result = announcementAdminRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new AnnounceNotFoundException()); + + assertThat(result.getDeleterIntraId()).isEqualTo("deleterTestId"); + assertThat(result.getDeletedAt()).isNotNull(); + System.out.println(result.getId()); + System.out.println(result.getDeleterIntraId()); + System.out.println(result.getDeletedAt()); + } + +} diff --git a/src/test/java/com/gg/server/admin/coin/controller/CoinAdminControllerTest.java b/src/test/java/com/gg/server/admin/coin/controller/CoinAdminControllerTest.java index 12136f17f..f1c3d6113 100644 --- a/src/test/java/com/gg/server/admin/coin/controller/CoinAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/coin/controller/CoinAdminControllerTest.java @@ -1,12 +1,8 @@ package com.gg.server.admin.coin.controller; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.coin.dto.CoinUpdateRequestDto; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import lombok.RequiredArgsConstructor; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + import org.apache.http.HttpHeaders; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.DisplayName; @@ -17,42 +13,48 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.admin.coin.dto.CoinUpdateRequestDto; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc @Transactional class CoinAdminControllerTest { - @Autowired - TestDataUtils testDataUtils; - - @Autowired - private MockMvc mockMvc; - - @Autowired - ObjectMapper objectMapper; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - UserRepository userRepository; - - @Test - @DisplayName("PUT /pingpong/admin/coin") - public void updateCoinTest() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - String creatorId = userRepository.getById(userId).getIntraId(); - int beforeCoin = userRepository.getById(userId).getGgCoin(); - int changeCoin = 10; - CoinUpdateRequestDto coinUpdateRequestDto = new CoinUpdateRequestDto(creatorId, changeCoin, "관리자 코인 지급 테스트"); - mockMvc.perform(put("/pingpong/admin/coin").header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON) - .content(objectMapper.writeValueAsString(coinUpdateRequestDto))) - .andExpect(status().isNoContent()); - Assertions.assertThat(userRepository.getById(userId).getGgCoin()).isEqualTo(beforeCoin + changeCoin); - } -} \ No newline at end of file + @Autowired + TestDataUtils testDataUtils; + + @Autowired + private MockMvc mockMvc; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + AuthTokenProvider tokenProvider; + + @Autowired + UserRepository userRepository; + + @Test + @DisplayName("PUT /pingpong/admin/coin") + public void updateCoinTest() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + String creatorId = userRepository.getById(userId).getIntraId(); + int beforeCoin = userRepository.getById(userId).getGgCoin(); + int changeCoin = 10; + CoinUpdateRequestDto coinUpdateRequestDto = new CoinUpdateRequestDto(creatorId, changeCoin, "관리자 코인 지급 테스트"); + mockMvc.perform(put("/pingpong/admin/coin").header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(coinUpdateRequestDto))) + .andExpect(status().isNoContent()); + Assertions.assertThat(userRepository.getById(userId).getGgCoin()).isEqualTo(beforeCoin + changeCoin); + } +} diff --git a/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerFailTest.java b/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerFailTest.java index 9d1330471..e6e487c9b 100644 --- a/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerFailTest.java +++ b/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerFailTest.java @@ -1,12 +1,8 @@ package com.gg.server.admin.coin.controller; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.coin.data.CoinPolicyAdminRepository; -import com.gg.server.admin.coin.dto.CoinPolicyAdminAddDto; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import lombok.RequiredArgsConstructor; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + import org.apache.http.HttpHeaders; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -16,45 +12,51 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.admin.coin.data.CoinPolicyAdminRepository; +import com.gg.server.admin.coin.dto.CoinPolicyAdminAddDto; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc @Transactional public class CoinPolicyAdminControllerFailTest { - @Autowired - TestDataUtils testDataUtils; + @Autowired + TestDataUtils testDataUtils; - @Autowired - private MockMvc mockMvc; + @Autowired + private MockMvc mockMvc; - @Autowired - ObjectMapper objectMapper; + @Autowired + ObjectMapper objectMapper; - @Autowired - AuthTokenProvider tokenProvider; + @Autowired + AuthTokenProvider tokenProvider; - @Autowired - CoinPolicyAdminRepository coinPolicyAdminRepository; + @Autowired + CoinPolicyAdminRepository coinPolicyAdminRepository; - @Test - @DisplayName("[Post FAIL]/pingpong/admin/coinpolicy") - void addAnnouncement() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + @Test + @DisplayName("[Post FAIL]/pingpong/admin/coinpolicy") + void addAnnouncement() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - CoinPolicyAdminAddDto addDto = new CoinPolicyAdminAddDto(1,2,5,-1); + CoinPolicyAdminAddDto addDto = new CoinPolicyAdminAddDto(1, 2, 5, -1); - String content = objectMapper.writeValueAsString(addDto); - String url = "/pingpong/admin/coinpolicy"; + String content = objectMapper.writeValueAsString(addDto); + String url = "/pingpong/admin/coinpolicy"; - String contentAsString = mockMvc.perform(post(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - } + String contentAsString = mockMvc.perform(post(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + } } diff --git a/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerTest.java b/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerTest.java index fdc351425..2c5929f2b 100644 --- a/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerTest.java @@ -1,103 +1,107 @@ package com.gg.server.admin.coin.controller; -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.assertj.core.api.Assertions.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.util.stream.IntStream; + +import org.apache.http.HttpHeaders; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; import com.gg.server.admin.coin.data.CoinPolicyAdminRepository; import com.gg.server.admin.coin.dto.CoinPolicyAdminAddDto; import com.gg.server.admin.coin.dto.CoinPolicyAdminListResponseDto; -import com.gg.server.utils.annotation.IntegrationTest; import com.gg.server.domain.coin.data.CoinPolicy; import com.gg.server.domain.coin.exception.CoinPolicyNotFoundException; import com.gg.server.domain.user.data.User; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; -import java.util.stream.IntStream; +import com.gg.server.utils.annotation.IntegrationTest; + import lombok.RequiredArgsConstructor; -import org.apache.http.HttpHeaders; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.transaction.annotation.Transactional; @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc @Transactional class CoinPolicyAdminControllerTest { - @Autowired - TestDataUtils testDataUtils; - - @Autowired - private MockMvc mockMvc; - - @Autowired - ObjectMapper objectMapper; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - CoinPolicyAdminRepository coinPolicyAdminRepository; - - @Test - @DisplayName("[Get]/pingpong/admin/coinpolicy") - void getCoinPolicy() throws Exception { - User admin = testDataUtils.createAdminUser(); - IntStream.range(0, 3).forEach(i -> testDataUtils - .createCoinPolicy(admin, 1, 2, 3, 4)); - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - - Integer currentPage = 1; - Integer pageSize = 5;//페이지 사이즈 크기가 실제 디비 정보보다 큰지 확인할 것 - - String url = "/pingpong/admin/coinpolicy?page=" + currentPage + "&size=" + pageSize; - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - CoinPolicyAdminListResponseDto result = objectMapper.readValue(contentAsString, CoinPolicyAdminListResponseDto.class); - assertThat(result.getCoinPolicyList().size()).isEqualTo(3); - System.out.println(result.getCoinPolicyList().get(0).getCoinPolicyId()); - System.out.println(result.getCoinPolicyList().get(0).getCreateUserId()); - System.out.println(result.getCoinPolicyList().get(0).getAttendance()); - System.out.println(result.getCoinPolicyList().get(0).getNormal()); - System.out.println(result.getCoinPolicyList().get(0).getRankWin()); - System.out.println(result.getCoinPolicyList().get(0).getRankLose()); - - } - - @Test - @DisplayName("[Post]/pingpong/admin/coinpolicy") - void addCoinPolicy() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - - CoinPolicyAdminAddDto addDto = new CoinPolicyAdminAddDto(1,2,5,0); - - String content = objectMapper.writeValueAsString(addDto); - String url = "/pingpong/admin/coinpolicy"; - - String contentAsString = mockMvc.perform(post(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isCreated()) - .andReturn().getResponse().getContentAsString(); - - CoinPolicy result = coinPolicyAdminRepository.findFirstByOrderByIdDesc().orElseThrow(()-> new CoinPolicyNotFoundException()); - - assertThat(result.getAttendance()).isEqualTo(addDto.getAttendance()); - assertThat(result.getNormal()).isEqualTo(addDto.getNormal()); - assertThat(result.getRankWin()).isEqualTo(addDto.getRankWin()); - assertThat(result.getRankLose()).isEqualTo(addDto.getRankLose()); - } -} \ No newline at end of file + @Autowired + TestDataUtils testDataUtils; + + @Autowired + private MockMvc mockMvc; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + AuthTokenProvider tokenProvider; + + @Autowired + CoinPolicyAdminRepository coinPolicyAdminRepository; + + @Test + @DisplayName("[Get]/pingpong/admin/coinpolicy") + void getCoinPolicy() throws Exception { + User admin = testDataUtils.createAdminUser(); + IntStream.range(0, 3).forEach(i -> testDataUtils + .createCoinPolicy(admin, 1, 2, 3, 4)); + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + + Integer currentPage = 1; + Integer pageSize = 5; //페이지 사이즈 크기가 실제 디비 정보보다 큰지 확인할 것 + + String url = "/pingpong/admin/coinpolicy?page=" + currentPage + "&size=" + pageSize; + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + CoinPolicyAdminListResponseDto result = objectMapper.readValue(contentAsString, + CoinPolicyAdminListResponseDto.class); + assertThat(result.getCoinPolicyList().size()).isEqualTo(3); + System.out.println(result.getCoinPolicyList().get(0).getCoinPolicyId()); + System.out.println(result.getCoinPolicyList().get(0).getCreateUserId()); + System.out.println(result.getCoinPolicyList().get(0).getAttendance()); + System.out.println(result.getCoinPolicyList().get(0).getNormal()); + System.out.println(result.getCoinPolicyList().get(0).getRankWin()); + System.out.println(result.getCoinPolicyList().get(0).getRankLose()); + + } + + @Test + @DisplayName("[Post]/pingpong/admin/coinpolicy") + void addCoinPolicy() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + + CoinPolicyAdminAddDto addDto = new CoinPolicyAdminAddDto(1, 2, 5, 0); + + String content = objectMapper.writeValueAsString(addDto); + String url = "/pingpong/admin/coinpolicy"; + + String contentAsString = mockMvc.perform(post(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isCreated()) + .andReturn().getResponse().getContentAsString(); + + CoinPolicy result = coinPolicyAdminRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new CoinPolicyNotFoundException()); + + assertThat(result.getAttendance()).isEqualTo(addDto.getAttendance()); + assertThat(result.getNormal()).isEqualTo(addDto.getNormal()); + assertThat(result.getRankWin()).isEqualTo(addDto.getRankWin()); + assertThat(result.getRankLose()).isEqualTo(addDto.getRankLose()); + } +} diff --git a/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerTest.java b/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerTest.java index 05ac3012e..fa704b25f 100644 --- a/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerTest.java @@ -1,136 +1,139 @@ -package com.gg.server.admin.feedback.controller; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.feedback.data.FeedbackAdminRepository; -import com.gg.server.admin.feedback.dto.FeedbackListAdminResponseDto; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.feedback.data.Feedback; -import com.gg.server.domain.feedback.type.FeedbackType; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import lombok.RequiredArgsConstructor; -import org.apache.http.HttpHeaders; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.transaction.annotation.Transactional; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@RequiredArgsConstructor -@IntegrationTest -@AutoConfigureMockMvc -@Transactional -class FeedbackAdminControllerTest { - @Autowired - TestDataUtils testDataUtils; - - @Autowired - private MockMvc mockMvc; - - @Autowired - ObjectMapper objectMapper; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - FeedbackAdminRepository feedbackAdminRepository; - @Autowired - UserRepository userRepository; - - @Test - @DisplayName("[Get]/pingpong/admin/feedback") - void getFeedback() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - - for (int i = 0; i < 6; i++) { - Feedback feedback = Feedback.builder() - .category(FeedbackType.ETC) - .content("test" + i) - .user(testDataUtils.createNewUser()) - .build(); - feedbackAdminRepository.save(feedback); - } - - Integer currentPage = 1; - Integer pageSize = 5;//페이지 사이즈 크기가 실제 디비 정보보다 큰지 확인할 것 - - String url = "/pingpong/admin/feedback?page=" + currentPage + "&size=" + pageSize; - - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - - FeedbackListAdminResponseDto result = objectMapper.readValue(contentAsString, FeedbackListAdminResponseDto.class); - assertThat(result.getFeedbackList().size()).isEqualTo(5); - System.out.println(result.getFeedbackList().get(0).getId()); - System.out.println(result.getFeedbackList().get(0).getContent()); - - } - - @Test - @DisplayName("[Patch]pingpong/admin/feedback/{id}") - void patchFeedback() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - - Feedback feedback = Feedback.builder() - .category(FeedbackType.ETC) - .content("test1234") - .user(userRepository.findById(userId).get()) - .build(); - feedbackAdminRepository.save(feedback); - - String url = "/pingpong/admin/feedback/" + feedback.getId().toString(); - Boolean status = feedback.getIsSolved(); - - String contentAsString = mockMvc.perform(patch(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNoContent()) - .andReturn().getResponse().getContentAsString(); - - - } - - @Test - @DisplayName("[get]pingpong/admin/feedback?intraId=${intraId}&page=${pageNumber}&size={size}") - void findFeedbackByIntraId() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - - User user = userRepository.findById(userId).get(); - - Feedback feedback = Feedback.builder() - .category(FeedbackType.ETC) - .content("test1234") - .user(user) - .build(); - feedbackAdminRepository.save(feedback); - - Integer currentPage = 1; - Integer pageSize = 5;//페이지 사이즈 크기가 실제 디비 정보보다 큰지 확인할 것 - - String url = "/pingpong/admin/feedback?intraId=" + user.getIntraId() + "&page=" + currentPage + "&size=" + pageSize; - Boolean status = feedback.getIsSolved(); - - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - FeedbackListAdminResponseDto result = objectMapper.readValue(contentAsString, FeedbackListAdminResponseDto.class); - assertThat(result.getFeedbackList().size()).isBetween(0, 5); - assertThat(result.getFeedbackList().get(0).getIntraId()).isEqualTo(user.getIntraId()); - assertThat(result.getFeedbackList().get(0).getContent()).isEqualTo("test1234"); - assertThat(result.getFeedbackList().get(0).getIntraId()).isEqualTo(user.getIntraId()); - } -} \ No newline at end of file +package com.gg.server.admin.feedback.controller; + +import static org.assertj.core.api.Assertions.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import org.apache.http.HttpHeaders; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.admin.feedback.data.FeedbackAdminRepository; +import com.gg.server.admin.feedback.dto.FeedbackListAdminResponseDto; +import com.gg.server.domain.feedback.data.Feedback; +import com.gg.server.domain.feedback.type.FeedbackType; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@IntegrationTest +@AutoConfigureMockMvc +@Transactional +class FeedbackAdminControllerTest { + @Autowired + TestDataUtils testDataUtils; + + @Autowired + private MockMvc mockMvc; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + AuthTokenProvider tokenProvider; + + @Autowired + FeedbackAdminRepository feedbackAdminRepository; + @Autowired + UserRepository userRepository; + + @Test + @DisplayName("[Get]/pingpong/admin/feedback") + void getFeedback() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + + for (int i = 0; i < 6; i++) { + Feedback feedback = Feedback.builder() + .category(FeedbackType.ETC) + .content("test" + i) + .user(testDataUtils.createNewUser()) + .build(); + feedbackAdminRepository.save(feedback); + } + + Integer currentPage = 1; + Integer pageSize = 5; //페이지 사이즈 크기가 실제 디비 정보보다 큰지 확인할 것 + + String url = "/pingpong/admin/feedback?page=" + currentPage + "&size=" + pageSize; + + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + FeedbackListAdminResponseDto result = objectMapper.readValue(contentAsString, + FeedbackListAdminResponseDto.class); + assertThat(result.getFeedbackList().size()).isEqualTo(5); + System.out.println(result.getFeedbackList().get(0).getId()); + System.out.println(result.getFeedbackList().get(0).getContent()); + + } + + @Test + @DisplayName("[Patch]pingpong/admin/feedback/{id}") + void patchFeedback() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + + Feedback feedback = Feedback.builder() + .category(FeedbackType.ETC) + .content("test1234") + .user(userRepository.findById(userId).get()) + .build(); + feedbackAdminRepository.save(feedback); + + String url = "/pingpong/admin/feedback/" + feedback.getId().toString(); + Boolean status = feedback.getIsSolved(); + + String contentAsString = mockMvc.perform(patch(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNoContent()) + .andReturn().getResponse().getContentAsString(); + + } + + @Test + @DisplayName("[get]pingpong/admin/feedback?intraId=${intraId}&page=${pageNumber}&size={size}") + void findFeedbackByIntraId() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + + User user = userRepository.findById(userId).get(); + + Feedback feedback = Feedback.builder() + .category(FeedbackType.ETC) + .content("test1234") + .user(user) + .build(); + feedbackAdminRepository.save(feedback); + + Integer currentPage = 1; + Integer pageSize = 5; //페이지 사이즈 크기가 실제 디비 정보보다 큰지 확인할 것 + + String url = + "/pingpong/admin/feedback?intraId=" + user.getIntraId() + "&page=" + currentPage + "&size=" + pageSize; + Boolean status = feedback.getIsSolved(); + + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + FeedbackListAdminResponseDto result = objectMapper.readValue(contentAsString, + FeedbackListAdminResponseDto.class); + assertThat(result.getFeedbackList().size()).isBetween(0, 5); + assertThat(result.getFeedbackList().get(0).getIntraId()).isEqualTo(user.getIntraId()); + assertThat(result.getFeedbackList().get(0).getContent()).isEqualTo("test1234"); + assertThat(result.getFeedbackList().get(0).getIntraId()).isEqualTo(user.getIntraId()); + } +} diff --git a/src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java b/src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java index 489271352..95c67602f 100644 --- a/src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java @@ -1,275 +1,284 @@ -package com.gg.server.admin.game.controller; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.game.dto.GameLogListAdminResponseDto; -import com.gg.server.admin.game.dto.RankGamePPPModifyReqDto; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.game.dto.request.RankResultReqDto; -import com.gg.server.domain.game.service.GameService; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.match.service.GameUpdateService; -import com.gg.server.domain.rank.data.Rank; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.tier.data.Tier; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.controller.dto.GameInfoDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import java.util.ArrayList; -import lombok.RequiredArgsConstructor; -import org.apache.http.HttpHeaders; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.List; - -import static java.lang.Thread.sleep; -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import javax.persistence.EntityManager; - -@RequiredArgsConstructor -@IntegrationTest -@AutoConfigureMockMvc -@Transactional -@DisplayName("[Admin] Game Admin Controller Integration Test") -class GameAdminControllerTest { - @Autowired - TestDataUtils testDataUtils; - - @Autowired - private MockMvc mockMvc; - - @Autowired - ObjectMapper objectMapper; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - GameRepository gameRepository; - - @Autowired - UserRepository userRepository; - - @Autowired - GameUpdateService gameUpdateService; - - @Autowired - GameService gameService; - - @Autowired - RankRepository rankRepository; - - @Autowired - RankRedisRepository rankRedisRepository; - @Autowired - EntityManager entityManager; - - @AfterEach - void redisDown() { - rankRedisRepository.deleteAll(); - } - - @Nested - @DisplayName("[GET] /pingpong/admin/games/users?intraId=${intraId}&page=${pageNumber}&size={sizeNum}") - class GetUserGameList { - String accessToken; - Long userId; - User user; - Season season; - - static final int TOTAL_PAGE_SIZE = 18; - static final int TOURNAMENT_GAME_SIZE = 4; - static final String INTRA_ID = "nheo"; - - @BeforeEach - void setUp() { - accessToken = testDataUtils.getAdminLoginAccessToken(); - userId = tokenProvider.getUserIdFromAccessToken(accessToken); - user = testDataUtils.createNewUser(INTRA_ID); - season = testDataUtils.createSeason(); - testDataUtils.createUserRank(user, "status message", season); - for (int i = 0; i < TOTAL_PAGE_SIZE; i++) { - testDataUtils.createMockMatchWithMockRank(user, season, LocalDateTime.now().minusMinutes(20 + i * 15), LocalDateTime.now().minusMinutes(5 + i * 15)); - } - for (int i = TOTAL_PAGE_SIZE; i< TOTAL_PAGE_SIZE + TOURNAMENT_GAME_SIZE; i++) { - testDataUtils.createMockMatch(testDataUtils.createNewUser("testUser"+i), season, - LocalDateTime.now().minusMinutes(20 + i * 15), LocalDateTime.now().minusMinutes(5 + i * 15), Mode.TOURNAMENT); - } - } - private GameLogListAdminResponseDto getPageResult(int currentPage, int pageSize) - throws Exception { - String url = "/pingpong/admin/games/users?intraId=" - + INTRA_ID + "&page=" + currentPage + "&size=" + pageSize; - - String contentAsString = mockMvc - .perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - return objectMapper.readValue(contentAsString, GameLogListAdminResponseDto.class); - } - @Test - @Transactional - @DisplayName("First page") - void getUserGameListFirstPage() throws Exception { - //given - int pageSize = 5; - //when - GameLogListAdminResponseDto result = getPageResult(1, pageSize); - //then - assertThat(result.getGameLogList().size()).isEqualTo(pageSize); - } - - @Test - @Transactional - @DisplayName("Middle page") - void getUserGameListMidPage() throws Exception { - //given - int pageSize = 5; - //when - GameLogListAdminResponseDto result = getPageResult(2, pageSize); - //then - assertThat(result.getGameLogList().size()).isEqualTo(pageSize); - } - - @Test - @Transactional - @DisplayName("End page") - void getUserGameListEndPage() throws Exception { - //given - int pageSize = 5; - //when - GameLogListAdminResponseDto result = getPageResult(4, pageSize); - //then - assertThat(result.getGameLogList().size()).isEqualTo(TOTAL_PAGE_SIZE % pageSize); - } - } - - @Test - @DisplayName("[PUT] /pingpong/admin/games") - @Transactional - public void 관리자게임전적수정테스트() throws Exception { - String url = "/pingpong/admin/games"; - Mode currentMatchMode = Mode.RANK; - Season season = testDataUtils.createSeason(); - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long adminUserId = tokenProvider.getUserIdFromAccessToken(accessToken); - User adminUser = userRepository.findById(adminUserId).get(); - ArrayList tierList = testDataUtils.createTierSystem("pinpong"); - GameInfoDto game1Info = testDataUtils.createGameWithTierAndRank(adminUser, LocalDateTime.now().minusMinutes(5), LocalDateTime.now().plusMinutes(5), season, currentMatchMode, tierList.get(0)); - - User enemyUser1 = userRepository.findById(game1Info.getEnemyUserId()).get(); - - RankResultReqDto rankResultReqDto = new RankResultReqDto(game1Info.getGameId(), - game1Info.getMyTeamId(), - 2, - game1Info.getEnemyTeamId(), - 1); - gameService.createRankResult(rankResultReqDto, adminUserId); - - Rank adminUserRank = rankRepository.findByUserIdAndSeasonId(adminUserId, season.getId()).get(); - Rank enemyUser1Rank = rankRepository.findByUserIdAndSeasonId(enemyUser1.getId(), - season.getId()).get(); - // win 1, losses 0, ppp 1020 -// System.out.println("MANGO ADMIN1 before DB PPP : " + adminUserRank.getPpp()); - assertThat(adminUserRank.getLosses()).isEqualTo(0); - assertThat(adminUserRank.getWins()).isEqualTo(1); - // win 0, losses 1, ppp 982 -// System.out.println("MANGO ENEMY1 before DB PPP : " + enemyUser1Rank.getPpp()); - assertThat(enemyUser1Rank.getWins()).isEqualTo(0); - assertThat(enemyUser1Rank.getLosses()).isEqualTo(1); - - RankGamePPPModifyReqDto modifyReqDto = new RankGamePPPModifyReqDto(game1Info.getMyTeamId(), 1, game1Info.getEnemyTeamId(), 0); - mockMvc.perform(put("/pingpong/admin/games/" + game1Info.getGameId()) - .content(objectMapper.writeValueAsString(modifyReqDto)) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().is2xxSuccessful()) - .andReturn().getResponse().getContentAsString(); - GameTeamUser historyGame1 = gameRepository.findTeamsByGameIsIn(List.of(game1Info.getGameId())).get(0); - - entityManager.flush(); - entityManager.clear(); - adminUserRank = rankRepository.findByUserIdAndSeasonId(adminUserId, season.getId()).get(); - enemyUser1Rank = rankRepository.findByUserIdAndSeasonId(enemyUser1.getId(), season.getId()) - .get(); - // win 1, losses 0, ppp 1020 - // MANGO ADMIN1 after DB - assertThat(adminUserRank.getPpp()).isEqualTo(1020); - assertThat(adminUserRank.getWins()).isEqualTo(1); - assertThat(adminUserRank.getLosses()).isEqualTo(0); - // win 0, losses 1, ppp 982 - // MANGO ENEMY1 after DB - assertThat(enemyUser1Rank.getWins()).isEqualTo(0); - assertThat(enemyUser1Rank.getLosses()).isEqualTo(1); - assertThat(enemyUser1Rank.getPpp()).isEqualTo(982); - ////////////////////////////// - sleep(1000); - ////////////////////////////// - GameInfoDto game2Info = testDataUtils.createGameWithTierAndRank(adminUser, LocalDateTime.now().minusMinutes(4), LocalDateTime.now().plusMinutes(6), season, currentMatchMode, tierList.get(0)); - User enemyUser2 = userRepository.findById(game2Info.getEnemyUserId()).get(); - - rankResultReqDto = new RankResultReqDto(game2Info.getGameId(), - game2Info.getMyTeamId(), - 1, - game2Info.getEnemyTeamId(), - 2); - gameService.createRankResult(rankResultReqDto, adminUserId); - - adminUserRank = rankRepository.findByUserIdAndSeasonId(adminUserId, season.getId()).get(); - Rank enemyUser2Rank = rankRepository.findByUserIdAndSeasonId(enemyUser2.getId(), - season.getId()).get(); - // win 1, losses 1, ppp 1001 - // MANGO ADMIN2 before DB - assertThat(adminUserRank.getWins()).isEqualTo(1); - assertThat(adminUserRank.getLosses()).isEqualTo(1); - assertThat(adminUserRank.getPpp()).isEqualTo(1001); - // win1, losses 0, ppp 1021 - // MANGO ENEMY2 before DB - assertThat(enemyUser2Rank.getWins()).isEqualTo(1); - assertThat(enemyUser2Rank.getLosses()).isEqualTo(0); - assertThat(enemyUser2Rank.getPpp()).isEqualTo(1021); - - modifyReqDto = new RankGamePPPModifyReqDto(game2Info.getMyTeamId(), 2, game2Info.getEnemyTeamId(), 1); - mockMvc.perform(put("/pingpong/admin/games/" + game2Info.getGameId()) - .content(objectMapper.writeValueAsString(modifyReqDto)) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().is2xxSuccessful()) - .andReturn().getResponse().getContentAsString(); - - adminUserRank = rankRepository.findByUserIdAndSeasonId(adminUserId, season.getId()).get(); - enemyUser2Rank = rankRepository.findByUserIdAndSeasonId(enemyUser2.getId(), season.getId()).get(); - // win 2, losses 0, ppp 1038 -// System.out.println("MANGO ADMIN2 after DB PPP : " + adminUserRank.getPpp() + ", WIN: " -// + adminUserRank.getWins() + ", LOSSES" + adminUserRank.getLosses()); - assertThat(adminUserRank.getWins()).isEqualTo(2); - assertThat(adminUserRank.getLosses()).isEqualTo(0); - assertThat(adminUserRank.getPpp()).isEqualTo(1038); - // win 0, losses 1, ppp - System.out.println("MANGO ENEMY2 after DB PPP : " + enemyUser2Rank.getPpp() + ", WIN: " - + enemyUser2Rank.getWins() + ", LOSSES" + enemyUser2Rank.getLosses()); - assertThat(enemyUser2Rank.getWins()).isEqualTo(0); - assertThat(enemyUser2Rank.getLosses()).isEqualTo(1); -// assertThat(enemyUser2Rank.getPpp()).isEqualTo() - } -} \ No newline at end of file +package com.gg.server.admin.game.controller; + +import static java.lang.Thread.*; +import static org.assertj.core.api.Assertions.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.EntityManager; + +import org.apache.http.HttpHeaders; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.admin.game.dto.GameLogListAdminResponseDto; +import com.gg.server.admin.game.dto.RankGamePPPModifyReqDto; +import com.gg.server.domain.game.data.GameRepository; +import com.gg.server.domain.game.dto.GameTeamUser; +import com.gg.server.domain.game.dto.request.RankResultReqDto; +import com.gg.server.domain.game.service.GameService; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.match.service.GameUpdateService; +import com.gg.server.domain.rank.data.Rank; +import com.gg.server.domain.rank.data.RankRepository; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.tier.data.Tier; +import com.gg.server.domain.user.controller.dto.GameInfoDto; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@IntegrationTest +@AutoConfigureMockMvc +@Transactional +@DisplayName("[Admin] Game Admin Controller Integration Test") +class GameAdminControllerTest { + @Autowired + TestDataUtils testDataUtils; + + @Autowired + private MockMvc mockMvc; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + AuthTokenProvider tokenProvider; + + @Autowired + GameRepository gameRepository; + + @Autowired + UserRepository userRepository; + + @Autowired + GameUpdateService gameUpdateService; + + @Autowired + GameService gameService; + + @Autowired + RankRepository rankRepository; + + @Autowired + RankRedisRepository rankRedisRepository; + @Autowired + EntityManager entityManager; + + @AfterEach + void redisDown() { + rankRedisRepository.deleteAll(); + } + + @Nested + @DisplayName("[GET] /pingpong/admin/games/users?intraId=${intraId}&page=${pageNumber}&size={sizeNum}") + class GetUserGameList { + String accessToken; + Long userId; + User user; + Season season; + + static final int TOTAL_PAGE_SIZE = 18; + static final int TOURNAMENT_GAME_SIZE = 4; + static final String INTRA_ID = "nheo"; + + @BeforeEach + void setUp() { + accessToken = testDataUtils.getAdminLoginAccessToken(); + userId = tokenProvider.getUserIdFromAccessToken(accessToken); + user = testDataUtils.createNewUser(INTRA_ID); + season = testDataUtils.createSeason(); + testDataUtils.createUserRank(user, "status message", season); + for (int i = 0; i < TOTAL_PAGE_SIZE; i++) { + testDataUtils.createMockMatchWithMockRank(user, season, LocalDateTime.now().minusMinutes(20 + i * 15), + LocalDateTime.now().minusMinutes(5 + i * 15)); + } + for (int i = TOTAL_PAGE_SIZE; i < TOTAL_PAGE_SIZE + TOURNAMENT_GAME_SIZE; i++) { + testDataUtils.createMockMatch(testDataUtils.createNewUser("testUser" + i), season, + LocalDateTime.now().minusMinutes(20 + i * 15), LocalDateTime.now().minusMinutes(5 + i * 15), + Mode.TOURNAMENT); + } + } + + private GameLogListAdminResponseDto getPageResult(int currentPage, int pageSize) + throws Exception { + String url = "/pingpong/admin/games/users?intraId=" + + INTRA_ID + "&page=" + currentPage + "&size=" + pageSize; + + String contentAsString = mockMvc + .perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + return objectMapper.readValue(contentAsString, GameLogListAdminResponseDto.class); + } + + @Test + @Transactional + @DisplayName("First page") + void getUserGameListFirstPage() throws Exception { + //given + int pageSize = 5; + //when + GameLogListAdminResponseDto result = getPageResult(1, pageSize); + //then + assertThat(result.getGameLogList().size()).isEqualTo(pageSize); + } + + @Test + @Transactional + @DisplayName("Middle page") + void getUserGameListMidPage() throws Exception { + //given + int pageSize = 5; + //when + GameLogListAdminResponseDto result = getPageResult(2, pageSize); + //then + assertThat(result.getGameLogList().size()).isEqualTo(pageSize); + } + + @Test + @Transactional + @DisplayName("End page") + void getUserGameListEndPage() throws Exception { + //given + int pageSize = 5; + //when + GameLogListAdminResponseDto result = getPageResult(4, pageSize); + //then + assertThat(result.getGameLogList().size()).isEqualTo(TOTAL_PAGE_SIZE % pageSize); + } + } + + @Test + @DisplayName("[PUT] /pingpong/admin/games 관리자게임전적수정테스트") + @Transactional + public void admingamestatUpdate() throws Exception { + String url = "/pingpong/admin/games"; + Mode currentMatchMode = Mode.RANK; + Season season = testDataUtils.createSeason(); + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long adminUserId = tokenProvider.getUserIdFromAccessToken(accessToken); + User adminUser = userRepository.findById(adminUserId).get(); + ArrayList tierList = testDataUtils.createTierSystem("pinpong"); + GameInfoDto game1Info = testDataUtils.createGameWithTierAndRank(adminUser, LocalDateTime.now().minusMinutes(5), + LocalDateTime.now().plusMinutes(5), season, currentMatchMode, tierList.get(0)); + + User enemyUser1 = userRepository.findById(game1Info.getEnemyUserId()).get(); + + RankResultReqDto rankResultReqDto = new RankResultReqDto(game1Info.getGameId(), + game1Info.getMyTeamId(), + 2, + game1Info.getEnemyTeamId(), + 1); + gameService.createRankResult(rankResultReqDto, adminUserId); + + Rank adminUserRank = rankRepository.findByUserIdAndSeasonId(adminUserId, season.getId()).get(); + Rank enemyUser1Rank = rankRepository.findByUserIdAndSeasonId(enemyUser1.getId(), + season.getId()).get(); + // win 1, losses 0, ppp 1020 + // System.out.println("MANGO ADMIN1 before DB PPP : " + adminUserRank.getPpp()); + assertThat(adminUserRank.getLosses()).isEqualTo(0); + assertThat(adminUserRank.getWins()).isEqualTo(1); + // win 0, losses 1, ppp 982 + // System.out.println("MANGO ENEMY1 before DB PPP : " + enemyUser1Rank.getPpp()); + assertThat(enemyUser1Rank.getWins()).isEqualTo(0); + assertThat(enemyUser1Rank.getLosses()).isEqualTo(1); + + RankGamePPPModifyReqDto modifyReqDto = new RankGamePPPModifyReqDto(game1Info.getMyTeamId(), 1, + game1Info.getEnemyTeamId(), 0); + mockMvc.perform(put("/pingpong/admin/games/" + game1Info.getGameId()) + .content(objectMapper.writeValueAsString(modifyReqDto)) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().is2xxSuccessful()) + .andReturn().getResponse().getContentAsString(); + GameTeamUser historyGame1 = gameRepository.findTeamsByGameIsIn(List.of(game1Info.getGameId())).get(0); + + entityManager.flush(); + entityManager.clear(); + adminUserRank = rankRepository.findByUserIdAndSeasonId(adminUserId, season.getId()).get(); + enemyUser1Rank = rankRepository.findByUserIdAndSeasonId(enemyUser1.getId(), season.getId()) + .get(); + // win 1, losses 0, ppp 1020 + // MANGO ADMIN1 after DB + assertThat(adminUserRank.getPpp()).isEqualTo(1020); + assertThat(adminUserRank.getWins()).isEqualTo(1); + assertThat(adminUserRank.getLosses()).isEqualTo(0); + // win 0, losses 1, ppp 982 + // MANGO ENEMY1 after DB + assertThat(enemyUser1Rank.getWins()).isEqualTo(0); + assertThat(enemyUser1Rank.getLosses()).isEqualTo(1); + assertThat(enemyUser1Rank.getPpp()).isEqualTo(982); + ////////////////////////////// + sleep(1000); + ////////////////////////////// + GameInfoDto game2Info = testDataUtils.createGameWithTierAndRank(adminUser, LocalDateTime.now().minusMinutes(4), + LocalDateTime.now().plusMinutes(6), season, currentMatchMode, tierList.get(0)); + User enemyUser2 = userRepository.findById(game2Info.getEnemyUserId()).get(); + + rankResultReqDto = new RankResultReqDto(game2Info.getGameId(), + game2Info.getMyTeamId(), + 1, + game2Info.getEnemyTeamId(), + 2); + gameService.createRankResult(rankResultReqDto, adminUserId); + + adminUserRank = rankRepository.findByUserIdAndSeasonId(adminUserId, season.getId()).get(); + Rank enemyUser2Rank = rankRepository.findByUserIdAndSeasonId(enemyUser2.getId(), + season.getId()).get(); + // win 1, losses 1, ppp 1001 + // MANGO ADMIN2 before DB + assertThat(adminUserRank.getWins()).isEqualTo(1); + assertThat(adminUserRank.getLosses()).isEqualTo(1); + assertThat(adminUserRank.getPpp()).isEqualTo(1001); + // win1, losses 0, ppp 1021 + // MANGO ENEMY2 before DB + assertThat(enemyUser2Rank.getWins()).isEqualTo(1); + assertThat(enemyUser2Rank.getLosses()).isEqualTo(0); + assertThat(enemyUser2Rank.getPpp()).isEqualTo(1021); + + modifyReqDto = new RankGamePPPModifyReqDto(game2Info.getMyTeamId(), 2, game2Info.getEnemyTeamId(), 1); + mockMvc.perform(put("/pingpong/admin/games/" + game2Info.getGameId()) + .content(objectMapper.writeValueAsString(modifyReqDto)) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().is2xxSuccessful()) + .andReturn().getResponse().getContentAsString(); + + adminUserRank = rankRepository.findByUserIdAndSeasonId(adminUserId, season.getId()).get(); + enemyUser2Rank = rankRepository.findByUserIdAndSeasonId(enemyUser2.getId(), season.getId()).get(); + // win 2, losses 0, ppp 1038 + // System.out.println("MANGO ADMIN2 after DB PPP : " + adminUserRank.getPpp() + ", WIN: " + // + adminUserRank.getWins() + ", LOSSES" + adminUserRank.getLosses()); + assertThat(adminUserRank.getWins()).isEqualTo(2); + assertThat(adminUserRank.getLosses()).isEqualTo(0); + assertThat(adminUserRank.getPpp()).isEqualTo(1038); + // win 0, losses 1, ppp + System.out.println("MANGO ENEMY2 after DB PPP : " + enemyUser2Rank.getPpp() + ", WIN: " + + enemyUser2Rank.getWins() + ", LOSSES" + enemyUser2Rank.getLosses()); + assertThat(enemyUser2Rank.getWins()).isEqualTo(0); + assertThat(enemyUser2Rank.getLosses()).isEqualTo(1); + // assertThat(enemyUser2Rank.getPpp()).isEqualTo() + } +} diff --git a/src/test/java/com/gg/server/admin/item/controller/ItemAdminControllerTest.java b/src/test/java/com/gg/server/admin/item/controller/ItemAdminControllerTest.java index 9bb2a6c13..1f3b99635 100644 --- a/src/test/java/com/gg/server/admin/item/controller/ItemAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/item/controller/ItemAdminControllerTest.java @@ -1,26 +1,13 @@ package com.gg.server.admin.item.controller; -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.multipart; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.assertj.core.api.Assertions.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.item.data.ItemAdminRepository; -import com.gg.server.admin.item.dto.ItemListResponseDto; -import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.admin.item.service.ItemAdminService; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.item.data.Item; -import com.gg.server.domain.item.type.ItemType; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.global.utils.ItemImageHandler; -import com.gg.server.utils.ItemTestUtils; -import com.gg.server.utils.TestDataUtils; import java.util.List; + import javax.transaction.Transactional; + import org.apache.http.HttpHeaders; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -35,103 +22,118 @@ import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.web.servlet.MockMvc; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.admin.item.data.ItemAdminRepository; +import com.gg.server.admin.item.dto.ItemListResponseDto; +import com.gg.server.admin.item.dto.ItemUpdateRequestDto; +import com.gg.server.admin.item.service.ItemAdminService; +import com.gg.server.domain.item.data.Item; +import com.gg.server.domain.item.type.ItemType; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.global.utils.ItemImageHandler; +import com.gg.server.utils.ItemTestUtils; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + @IntegrationTest @AutoConfigureMockMvc @Transactional class ItemAdminControllerTest { - @Autowired - ItemAdminService itemAdminService; - @Autowired - UserRepository userRepository; - @Autowired - TestDataUtils testDataUtils; - @Autowired - ObjectMapper objectMapper; - @Autowired - AuthTokenProvider tokenProvider; - @Autowired - ItemAdminRepository itemAdminRepository; - @Autowired - MockMvc mockMvc; - @Autowired - ItemTestUtils itemTestUtils; - @MockBean - ItemImageHandler ItemImageHandler; + @Autowired + ItemAdminService itemAdminService; + @Autowired + UserRepository userRepository; + @Autowired + TestDataUtils testDataUtils; + @Autowired + ObjectMapper objectMapper; + @Autowired + AuthTokenProvider tokenProvider; + @Autowired + ItemAdminRepository itemAdminRepository; + @Autowired + MockMvc mockMvc; + @Autowired + ItemTestUtils itemTestUtils; + @MockBean + ItemImageHandler itemImageHandler; - Item item; - @BeforeEach - void setUp() { - ItemUpdateRequestDto dto = new ItemUpdateRequestDto("name", "content", - "subContent", 100, 50, ItemType.EDGE); - item = itemTestUtils.createItem(testDataUtils.createAdminUserForItem(), dto); - } + Item item; - @Test - @DisplayName("GET /pingpong/admin/items/history") - public void getAllItemHistoryTest() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Integer page = 1; - Integer size = 20; - String url = "/pingpong/admin/items/history?page=" + page + "&size=" + size; - Pageable pageable = PageRequest.of(page - 1, size, Sort.by("createdAt").descending()); + @BeforeEach + void setUp() { + ItemUpdateRequestDto dto = new ItemUpdateRequestDto("name", "content", + "subContent", 100, 50, ItemType.EDGE); + item = itemTestUtils.createItem(testDataUtils.createAdminUserForItem(), dto); + } - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); + @Test + @DisplayName("GET /pingpong/admin/items/history") + public void getAllItemHistoryTest() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Integer page = 1; + Integer size = 20; + String url = "/pingpong/admin/items/history?page=" + page + "&size=" + size; + Pageable pageable = PageRequest.of(page - 1, size, Sort.by("createdAt").descending()); - System.out.println(contentAsString); - ItemListResponseDto expect = itemAdminService.getAllItemHistory(pageable); - System.out.println(expect.getHistoryList()); - ItemListResponseDto result = objectMapper.readValue(contentAsString, ItemListResponseDto.class); - System.out.println(expect.getHistoryList().get(0)); - System.out.println(result.getHistoryList().get(0)); - assertThat(result.getHistoryList().get(0).getItemId()); - assertThat(result.getHistoryList().get(0).getName()); - assertThat(result.getHistoryList().get(0).getMainContent()); - assertThat(result.getHistoryList().get(0).getSubContent()); - assertThat(result.getHistoryList().get(0).getPrice()); - } + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); - @Test - @DisplayName("POST /pingpong/admin/items/history/{itemId}") - public void updateItemTest() throws Exception { - Mockito.when(ItemImageHandler.uploadToS3(Mockito.any(), Mockito.anyString())) - .thenAnswer(invocation -> invocation.getArgument(1, String.class)); + System.out.println(contentAsString); + ItemListResponseDto expect = itemAdminService.getAllItemHistory(pageable); + System.out.println(expect.getHistoryList()); + ItemListResponseDto result = objectMapper.readValue(contentAsString, ItemListResponseDto.class); + System.out.println(expect.getHistoryList().get(0)); + System.out.println(result.getHistoryList().get(0)); + assertThat(result.getHistoryList().get(0).getItemId()); + assertThat(result.getHistoryList().get(0).getName()); + assertThat(result.getHistoryList().get(0).getMainContent()); + assertThat(result.getHistoryList().get(0).getSubContent()); + assertThat(result.getHistoryList().get(0).getPrice()); + } + @Test + @DisplayName("POST /pingpong/admin/items/history/{itemId}") + public void updateItemTest() throws Exception { + Mockito.when(itemImageHandler.uploadToS3(Mockito.any(), Mockito.anyString())) + .thenAnswer(invocation -> invocation.getArgument(1, String.class)); - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - String creatorId = userRepository.getById(userId).getIntraId(); - MockMultipartFile image = new MockMultipartFile("imgData", "imagefile.jpeg", "image/jpeg", "<>".getBytes()); - MockMultipartFile jsonFile = new MockMultipartFile("updateItemInfo", "", - "application/json", - ("{\"name\": \"TEST\", " - + "\"mainContent\": \"TESTING\", " - + "\"subContent\": \"TESTING\", " - + "\"price\": 42, " - + "\"discount\": 50, " - + "\"itemType\": \"MEGAPHONE\"}").getBytes()); - String contentAsString = mockMvc.perform(multipart("/pingpong/admin/items/{itemId}", item.getId()) - .file(image) - .file(jsonFile) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNoContent()) - .andReturn().getResponse().getContentAsString(); - } + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + String creatorId = userRepository.getById(userId).getIntraId(); + MockMultipartFile image = new MockMultipartFile("imgData", "imagefile.jpeg", "image/jpeg", + "<>".getBytes()); + MockMultipartFile jsonFile = new MockMultipartFile("updateItemInfo", "", + "application/json", + ("{\"name\": \"TEST\", " + + "\"mainContent\": \"TESTING\", " + + "\"subContent\": \"TESTING\", " + + "\"price\": 42, " + + "\"discount\": 50, " + + "\"itemType\": \"MEGAPHONE\"}").getBytes()); + String contentAsString = mockMvc.perform(multipart("/pingpong/admin/items/{itemId}", item.getId()) + .file(image) + .file(jsonFile) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNoContent()) + .andReturn().getResponse().getContentAsString(); + } - @Test - @DisplayName("DELETE /pingpong/admin/items/{itemId}") - public void deleteItemTest() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - String deleterId = userRepository.getById(userId).getIntraId(); + @Test + @DisplayName("DELETE /pingpong/admin/items/{itemId}") + public void deleteItemTest() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + String deleterId = userRepository.getById(userId).getIntraId(); - String contentAsString = mockMvc.perform(delete("/pingpong/admin/items/{itemId}", item.getId()) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNoContent()) - .andReturn().getResponse().getContentAsString(); - List list = itemAdminRepository.findAll(); - assertThat(list.get(0).getDeleterIntraId()).isEqualTo(deleterId); - } -} \ No newline at end of file + String contentAsString = mockMvc.perform(delete("/pingpong/admin/items/{itemId}", item.getId()) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNoContent()) + .andReturn().getResponse().getContentAsString(); + List list = itemAdminRepository.findAll(); + assertThat(list.get(0).getDeleterIntraId()).isEqualTo(deleterId); + } +} diff --git a/src/test/java/com/gg/server/admin/megaphone/controller/MegaphoneAdminControllerTest.java b/src/test/java/com/gg/server/admin/megaphone/controller/MegaphoneAdminControllerTest.java index d227592b7..43605f159 100644 --- a/src/test/java/com/gg/server/admin/megaphone/controller/MegaphoneAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/megaphone/controller/MegaphoneAdminControllerTest.java @@ -1,10 +1,10 @@ package com.gg.server.admin.megaphone.controller; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + import javax.transaction.Transactional; -import lombok.RequiredArgsConstructor; + import org.apache.http.HttpHeaders; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -12,35 +12,38 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.test.web.servlet.MockMvc; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc @Transactional class MegaphoneAdminControllerTest { - @Autowired - TestDataUtils testDataUtils; - - @Autowired - private MockMvc mockMvc; - - @Autowired - AuthTokenProvider tokenProvider; - - @Test - @DisplayName("[GET] /pingpong/admin/megaphones/history?page={page}&size={pageSize}&intraId={intraId}") - void getMegaphoneListTest() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - String url = "/pingpong/admin/megaphones/history?page=1&size=30"; - - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } -} \ No newline at end of file + @Autowired + TestDataUtils testDataUtils; + + @Autowired + private MockMvc mockMvc; + + @Autowired + AuthTokenProvider tokenProvider; + + @Test + @DisplayName("[GET] /pingpong/admin/megaphones/history?page={page}&size={pageSize}&intraId={intraId}") + void getMegaphoneListTest() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + String url = "/pingpong/admin/megaphones/history?page=1&size=30"; + + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } +} diff --git a/src/test/java/com/gg/server/admin/noti/controller/NotiAdminControllerTest.java b/src/test/java/com/gg/server/admin/noti/controller/NotiAdminControllerTest.java index 1bc7d42ce..deced8bdf 100644 --- a/src/test/java/com/gg/server/admin/noti/controller/NotiAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/noti/controller/NotiAdminControllerTest.java @@ -1,142 +1,150 @@ -package com.gg.server.admin.noti.controller; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.noti.data.NotiAdminRepository; -import com.gg.server.admin.noti.dto.NotiAdminDto; -import com.gg.server.admin.noti.dto.NotiListAdminResponseDto; -import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; -import com.gg.server.admin.noti.service.NotiAdminService; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.noti.data.Noti; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import lombok.RequiredArgsConstructor; -import org.apache.http.HttpHeaders; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; - -import javax.transaction.Transactional; - -import java.util.List; -import java.util.UUID; - -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@RequiredArgsConstructor -@IntegrationTest -@AutoConfigureMockMvc -class NotiAdminControllerTest { - @Autowired - TestDataUtils testDataUtils; - @Autowired - AuthTokenProvider tokenProvider; - @Autowired - UserRepository userRepository; - @Autowired - NotiAdminService notiAdminService; - @Autowired - NotiAdminRepository notiAdminRepository; - @Autowired - NotiRepository notiRepository; - @Autowired - MockMvc mockMvc; - @Autowired - ObjectMapper objectMapper; - - @Test - @DisplayName("GET /pingpong/admin/notifications") - @Transactional - public void getAllNotiTest() throws Exception { - //given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.findById(userId).get(); - String testMessage = "Test notification"; - notiAdminService.sendAnnounceNotiToUser(new SendNotiAdminRequestDto(user.getIntraId(), testMessage)); - String url = "/pingpong/admin/notifications?page=1&size=20"; - String url2 = "/pingpong/admin/notifications?page=1&q=\"" + user.getIntraId() + "\""; - - //when - //200 성공(전체조회) - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - NotiListAdminResponseDto actureResponse1 = objectMapper.readValue(contentAsString, NotiListAdminResponseDto.class); - //200 성공(검색조회) - String contentAsString2 = mockMvc.perform(get(url2).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - NotiListAdminResponseDto actureResponse2 = objectMapper.readValue(contentAsString, NotiListAdminResponseDto.class); - Pageable pageable = PageRequest.of(0, 20); - Sort.by("createdAt").descending().and(Sort.by("user.intraId").ascending()); - - //then - List notiList1 = notiAdminRepository.findAll(pageable).getContent(); - List expectedNotiAdminDtoList = actureResponse1.getNotiList(); - for (int i = 0; i < notiList1.size(); i++) { - Assertions.assertThat(expectedNotiAdminDtoList.get(i).getIntraId()).isEqualTo(expectedNotiAdminDtoList.get(i).getIntraId()); - Assertions.assertThat(expectedNotiAdminDtoList.get(i).getMessage()).isEqualTo(expectedNotiAdminDtoList.get(i).getMessage()); - Assertions.assertThat(expectedNotiAdminDtoList.get(i).getIsChecked()).isEqualTo(expectedNotiAdminDtoList.get(i).getIsChecked()); - Assertions.assertThat(expectedNotiAdminDtoList.get(i).getType()).isEqualTo(expectedNotiAdminDtoList.get(i).getType()); - } - - List notiList2 = notiRepository.findByUser(user); - Assertions.assertThat(notiList2.size()).isEqualTo(1); - Noti expectedNoti2 = notiList2.get(0); - NotiAdminDto actureNotiResponseDto2 = actureResponse2.getNotiList().get(0); - Assertions.assertThat(expectedNoti2.getUser().getIntraId()).isEqualTo(actureNotiResponseDto2.getIntraId()); - Assertions.assertThat(expectedNoti2.getMessage()).isEqualTo(testMessage); - Assertions.assertThat(expectedNoti2.getIsChecked()).isFalse(); - Assertions.assertThat(expectedNoti2.getType()).isEqualTo(NotiType.ANNOUNCE); - } - - @Test - @DisplayName("POST /pingpong/admin/notifications") - @Transactional - public void sendNotiToUserTest() throws Exception { - //given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.findById(userId).get(); - String url = "/pingpong/admin/notifications"; - String wrongIntraId = UUID.randomUUID().toString().substring(0, 30); - String expectedMessage = "test 알림 message "; - - //when - //201 성공 - mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON) - .content(objectMapper.writeValueAsString(new SendNotiAdminRequestDto(user.getIntraId(), expectedMessage)))) - .andExpect(status().isCreated()); - - //404 존재하지 않는 intraId - mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON) - .content(objectMapper.writeValueAsString(new SendNotiAdminRequestDto(wrongIntraId, expectedMessage)))) - .andExpect(status().isNotFound()); - - //then - List notiList = notiRepository.findByUser(user); - Assertions.assertThat(notiList.size()).isEqualTo(1); - Noti actureNoti = notiList.get(0); - Assertions.assertThat(actureNoti.getUser()).isEqualTo(user); - Assertions.assertThat(actureNoti.getMessage()).isEqualTo(expectedMessage); - Assertions.assertThat(actureNoti.getIsChecked()).isFalse(); - Assertions.assertThat(actureNoti.getType()).isEqualTo(NotiType.ANNOUNCE); - } -} +package com.gg.server.admin.noti.controller; + +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.util.List; +import java.util.UUID; + +import javax.transaction.Transactional; + +import org.apache.http.HttpHeaders; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.admin.noti.data.NotiAdminRepository; +import com.gg.server.admin.noti.dto.NotiAdminDto; +import com.gg.server.admin.noti.dto.NotiListAdminResponseDto; +import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; +import com.gg.server.admin.noti.service.NotiAdminService; +import com.gg.server.domain.noti.data.Noti; +import com.gg.server.domain.noti.data.NotiRepository; +import com.gg.server.domain.noti.type.NotiType; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@IntegrationTest +@AutoConfigureMockMvc +class NotiAdminControllerTest { + @Autowired + TestDataUtils testDataUtils; + @Autowired + AuthTokenProvider tokenProvider; + @Autowired + UserRepository userRepository; + @Autowired + NotiAdminService notiAdminService; + @Autowired + NotiAdminRepository notiAdminRepository; + @Autowired + NotiRepository notiRepository; + @Autowired + MockMvc mockMvc; + @Autowired + ObjectMapper objectMapper; + + @Test + @DisplayName("GET /pingpong/admin/notifications") + @Transactional + public void getAllNotiTest() throws Exception { + //given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.findById(userId).get(); + String testMessage = "Test notification"; + notiAdminService.sendAnnounceNotiToUser(new SendNotiAdminRequestDto(user.getIntraId(), testMessage)); + String url = "/pingpong/admin/notifications?page=1&size=20"; + String url2 = "/pingpong/admin/notifications?page=1&q=\"" + user.getIntraId() + "\""; + + //when + //200 성공(전체조회) + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + NotiListAdminResponseDto actureResponse1 = objectMapper.readValue(contentAsString, + NotiListAdminResponseDto.class); + //200 성공(검색조회) + String contentAsString2 = mockMvc.perform(get(url2).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + NotiListAdminResponseDto actureResponse2 = objectMapper.readValue(contentAsString, + NotiListAdminResponseDto.class); + Pageable pageable = PageRequest.of(0, 20); + Sort.by("createdAt").descending().and(Sort.by("user.intraId").ascending()); + + //then + List notiList1 = notiAdminRepository.findAll(pageable).getContent(); + List expectedNotiAdminDtoList = actureResponse1.getNotiList(); + for (int i = 0; i < notiList1.size(); i++) { + Assertions.assertThat(expectedNotiAdminDtoList.get(i).getIntraId()) + .isEqualTo(expectedNotiAdminDtoList.get(i).getIntraId()); + Assertions.assertThat(expectedNotiAdminDtoList.get(i).getMessage()) + .isEqualTo(expectedNotiAdminDtoList.get(i).getMessage()); + Assertions.assertThat(expectedNotiAdminDtoList.get(i).getIsChecked()) + .isEqualTo(expectedNotiAdminDtoList.get(i).getIsChecked()); + Assertions.assertThat(expectedNotiAdminDtoList.get(i).getType()) + .isEqualTo(expectedNotiAdminDtoList.get(i).getType()); + } + + List notiList2 = notiRepository.findByUser(user); + Assertions.assertThat(notiList2.size()).isEqualTo(1); + Noti expectedNoti2 = notiList2.get(0); + NotiAdminDto actureNotiResponseDto2 = actureResponse2.getNotiList().get(0); + Assertions.assertThat(expectedNoti2.getUser().getIntraId()).isEqualTo(actureNotiResponseDto2.getIntraId()); + Assertions.assertThat(expectedNoti2.getMessage()).isEqualTo(testMessage); + Assertions.assertThat(expectedNoti2.getIsChecked()).isFalse(); + Assertions.assertThat(expectedNoti2.getType()).isEqualTo(NotiType.ANNOUNCE); + } + + @Test + @DisplayName("POST /pingpong/admin/notifications") + @Transactional + public void sendNotiToUserTest() throws Exception { + //given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.findById(userId).get(); + String url = "/pingpong/admin/notifications"; + String wrongIntraId = UUID.randomUUID().toString().substring(0, 30); + String expectedMessage = "test 알림 message "; + + //when + //201 성공 + mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(new SendNotiAdminRequestDto(user.getIntraId(), + expectedMessage)))) + .andExpect(status().isCreated()); + + //404 존재하지 않는 intraId + mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(new SendNotiAdminRequestDto(wrongIntraId, expectedMessage)))) + .andExpect(status().isNotFound()); + + //then + List notiList = notiRepository.findByUser(user); + Assertions.assertThat(notiList.size()).isEqualTo(1); + Noti actureNoti = notiList.get(0); + Assertions.assertThat(actureNoti.getUser()).isEqualTo(user); + Assertions.assertThat(actureNoti.getMessage()).isEqualTo(expectedMessage); + Assertions.assertThat(actureNoti.getIsChecked()).isFalse(); + Assertions.assertThat(actureNoti.getType()).isEqualTo(NotiType.ANNOUNCE); + } +} diff --git a/src/test/java/com/gg/server/admin/penalty/controller/PenaltyAdminControllerTest.java b/src/test/java/com/gg/server/admin/penalty/controller/PenaltyAdminControllerTest.java index 59d2efca6..e823e120e 100644 --- a/src/test/java/com/gg/server/admin/penalty/controller/PenaltyAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/penalty/controller/PenaltyAdminControllerTest.java @@ -1,352 +1,352 @@ -package com.gg.server.admin.penalty.controller; - -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.penalty.data.PenaltyAdminRepository; -import com.gg.server.admin.penalty.data.PenaltyUserAdminRedisRepository; -import com.gg.server.admin.penalty.dto.PenaltyListResponseDto; -import com.gg.server.admin.penalty.dto.PenaltyRequestDto; -import com.gg.server.admin.penalty.service.PenaltyAdminService; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.penalty.data.Penalty; -import com.gg.server.domain.penalty.redis.RedisPenaltyUser; -import com.gg.server.domain.penalty.type.PenaltyType; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import java.time.Duration; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import java.util.stream.Collectors; -import org.apache.http.HttpHeaders; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.data.redis.connection.RedisConnection; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.transaction.annotation.Transactional; - -@IntegrationTest -@AutoConfigureMockMvc -@Transactional -class PenaltyAdminControllerTest { - @Autowired - TestDataUtils testDataUtils; - @Autowired - MockMvc mockMvc; - @Autowired - ObjectMapper objectMapper; - @Autowired - UserRepository userRepository; - @Autowired - PenaltyUserAdminRedisRepository penaltyUserAdminRedisRepository; - @Autowired - PenaltyAdminRepository penaltyAdminRepository; - @Autowired - AuthTokenProvider tokenProvider; - @Autowired - RedisConnectionFactory redisConnectionFactory; - @Autowired - PenaltyAdminService penaltyAdminService; - - private final String headUrl = "/pingpong/admin/"; - - @AfterEach - void clear() { - RedisConnection connection = redisConnectionFactory.getConnection(); - connection.flushDb(); - connection.close(); - } - - @Test - @DisplayName("POST : penalty를 부여받지 않은 유효한 intraId에 penalty 부여") - public void giveUserPenaltyforFirstTimeWithValidIntraId() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - User newUser = testDataUtils.createNewUser(); - String intraId = newUser.getIntraId(); - String url = "/pingpong/admin/penalty"; - mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON) - .content(objectMapper.writeValueAsString(new PenaltyRequestDto(intraId, 3, "test1")))) - .andExpect(status().isCreated()); - Optional penaltyUser = penaltyUserAdminRedisRepository.findByIntraId(intraId); - //redis - Assertions.assertThat(penaltyUser).isPresent(); - Assertions.assertThat(penaltyUser.get().getPenaltyTime()).isEqualTo(3 * 60); - Assertions.assertThat( - Duration.between(penaltyUser.get().getStartTime(), - penaltyUser.get().getReleaseTime()).getSeconds()).isEqualTo(3 * 60 * 60); - Assertions.assertThat(penaltyUser.get().getReason()); - //mySQL - List penalties = penaltyAdminRepository.findAll(); - Assertions.assertThat(penalties.stream().anyMatch(ele -> ele.getUser().getIntraId().equals(intraId) - && ele.getPenaltyTime().equals(3 * 60))).isEqualTo(true); - } - - @Test - @DisplayName("POST : penalty를 부여받은 유효한 intraId에 penalty 부여") - public void giveUserPenaltyRepeatablyWithValidIntraId() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - User newUser = testDataUtils.createNewUser(); - String intraId = newUser.getIntraId(); - String url = "/pingpong/admin/penalty"; - //패널티 두번 부여 - mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON) - .content(objectMapper.writeValueAsString(new PenaltyRequestDto(intraId, 3, "test1")))) - .andExpect(status().isCreated()); - mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON) - .content(objectMapper.writeValueAsString(new PenaltyRequestDto(intraId, 2, "test2")))) - .andExpect(status().isCreated()); - Optional penaltyUser = penaltyUserAdminRedisRepository.findByIntraId(intraId); - //redis 확인 - Assertions.assertThat(penaltyUser).isPresent(); - Assertions.assertThat(penaltyUser.get().getPenaltyTime()).isEqualTo(5 * 60); - Assertions.assertThat( - Duration.between(penaltyUser.get().getStartTime(), - penaltyUser.get().getReleaseTime()).getSeconds()).isEqualTo(5 * 60 * 60); - Assertions.assertThat(penaltyUser.get().getReason()); - //mySQL 확인 - List penalties = penaltyAdminRepository.findAll(); - List userPenalties = penalties.stream().filter(ele -> ele.getUser().getIntraId().equals(intraId)) - .collect(Collectors.toList()); - Assertions.assertThat(userPenalties.size()).isEqualTo(2); - Duration duration = Duration.between(userPenalties.get(0).getStartTime(), userPenalties.get(1).getStartTime()); - Assertions.assertThat(duration.getSeconds()).isEqualTo(3 * 60 * 60); - } - - - @Test - @DisplayName("POST 유효하지 않은 intraId에 penalty 부여") - public void giveUserPenaltyWithInvalidIntraId() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - String intraId = "invalid!"; - String url = "/pingpong/admin/penalty"; - mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON) - .content(objectMapper.writeValueAsString(new PenaltyRequestDto(intraId, 3, "test1")))) - .andExpect(status().is4xxClientError()); - } - - @Test - @DisplayName("GET pagination 유효성 검사") - public void checkPagination() throws Exception { - List users = new ArrayList(); - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - //penalty user 20명 넣고 테스트 - for (int i = 0; i < 20; i++) { - User newUser = testDataUtils.createNewUser(); - users.add(newUser); - penaltyAdminService.givePenalty(newUser.getIntraId(), 3, "test" + String.valueOf(i)); - } - List sizeCounts = new ArrayList(); - Integer totalPages = -1; - for (int i = 1; i <= 3; i++) { - String url = "/pingpong/admin/penalty?page=" + String.valueOf(i)+"&size=10¤t=true"; - String contentAsString = mockMvc.perform( - get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); - PenaltyListResponseDto penaltyListResponseDto = objectMapper.readValue(contentAsString, - PenaltyListResponseDto.class); - sizeCounts.add(penaltyListResponseDto.getPenaltyList().size()); - totalPages = penaltyListResponseDto.getTotalPage(); - } - Assertions.assertThat(sizeCounts).isEqualTo(List.of(10, 10, 0)); - Assertions.assertThat(totalPages).isEqualTo(2); - } - - @Test - @DisplayName("GET parameter 유효성 검사") - public void checkInputException() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - String url = "/pingpong/admin/penalty?page=-1&size=10¤t=false"; - String contentAsString = mockMvc.perform( - get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isBadRequest()).andReturn().getResponse().getContentAsString(); - String url2 = "/pingpong/admin/penalty?page=2&size=0¤t=false"; - String contentAsString2 = mockMvc.perform( - get(url2).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isBadRequest()).andReturn().getResponse().getContentAsString(); - } - - @Test - @DisplayName("GET pagination keyword 유효성 검사") - public void checkPaginationWithKeyword() throws Exception { - List users = new ArrayList(); - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - //penalty user 40명 넣고 테스트 - //그중 20명만 intraId에 test포함 - for (int i = 0; i < 20; i++) { - String intraId = UUID.randomUUID().toString().substring(0, 4) + "test" + UUID.randomUUID().toString() - .substring(0, 4); - User newUser = testDataUtils.createNewUser(intraId, "test", RacketType.NONE, SnsType.EMAIL, - RoleType.USER); - users.add(newUser); - penaltyAdminService.givePenalty(newUser.getIntraId(), 3, "test" + String.valueOf(i)); - } - for (int i = 0; i < 20; i++) { - String intraId = "dummy" + String.valueOf(i); - User newUser = testDataUtils.createNewUser(intraId, "test", RacketType.NONE, SnsType.EMAIL, - RoleType.USER); - users.add(newUser); - penaltyAdminService.givePenalty(newUser.getIntraId(), 3, "test" + String.valueOf(i)); - } - List sizeCounts = new ArrayList(); - Integer totalPages = -1; - for (int i = 1; i <= 3; i++) { - String url = "/pingpong/admin/penalty?page=" + String.valueOf(i)+"&size=10¤t=true&intraId=test"; - String contentAsString = mockMvc.perform( - get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); - PenaltyListResponseDto penaltyListResponseDto = objectMapper.readValue(contentAsString, - PenaltyListResponseDto.class); - sizeCounts.add(penaltyListResponseDto.getPenaltyList().size()); - totalPages = penaltyListResponseDto.getTotalPage(); - } - Assertions.assertThat(sizeCounts).isEqualTo(List.of(10, 10, 0)); - Assertions.assertThat(totalPages).isEqualTo(2); - } - - @Test - @DisplayName("DELETE 패널티 삭제 - 유저 패널티가 1번만 부과된 경우") - public void deleteExistPenaltyUser() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - User newUser = testDataUtils.createNewUser(); - String intraId = newUser.getIntraId(); - penaltyAdminService.givePenalty(intraId, 3, "test!"); - List penalties = penaltyAdminRepository.findAll(); - List userPenalties = penalties.stream().filter(ele -> ele.getUser().getIntraId().equals(intraId)) - .collect(Collectors.toList()); - Long penaltyId = userPenalties.get(0).getId(); - String url = "/pingpong/admin/penalty/" + penaltyId.toString(); - mockMvc.perform( - delete(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNoContent()); - //Redis에 penaltyUser 없는지 확인 - Optional penaltyUser = penaltyUserAdminRedisRepository.findByIntraId(intraId); - Assertions.assertThat(penaltyUser).isEmpty(); - //MySQL에 penalty 없는지 확인 - List afterPenalties = penaltyAdminRepository.findAll(); - boolean isPresent = afterPenalties.stream().anyMatch(ele -> ele.getId().equals(penaltyId)); - Assertions.assertThat(isPresent).isEqualTo(false); - } - - @Test - @DisplayName("DELETE 패널티 삭제 - 유저 패널티가 2번 부과된 경우") - public void deleteExistPenaltyUserOfTwicePenalty() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - User newUser = testDataUtils.createNewUser(); - String intraId = newUser.getIntraId(); - penaltyAdminService.givePenalty(intraId, 3, "test!"); - penaltyAdminService.givePenalty(intraId, 2, "test2"); - List penalties = penaltyAdminRepository.findAll(); - List userPenalties = penalties.stream().filter(ele -> ele.getUser().getIntraId().equals(intraId)) - .collect(Collectors.toList()); - Long penaltyId = userPenalties.get(0).getId(); - String url = "/pingpong/admin/penalty/" + penaltyId.toString(); - mockMvc.perform( - delete(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNoContent()); - //Redis에 penaltyUser 있는지 확인 - Optional penaltyUser = penaltyUserAdminRedisRepository.findByIntraId(intraId); - Assertions.assertThat(penaltyUser.get().getPenaltyTime()).isEqualTo(2 * 60); - - //MySQL에 penalty 없는지 확인 - List afterPenalties = penaltyAdminRepository.findAll(); - boolean isPresent = afterPenalties.stream().anyMatch(ele -> ele.getId().equals(penaltyId)); - Assertions.assertThat(isPresent).isEqualTo(false); - } - - @Test - @DisplayName("DELETE 존재하지 않는 패널티 유저 삭제") - public void deleteInvalidPenaltyUser() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - //user에 패널티는 부여하지 않는다. - User newUser = testDataUtils.createNewUser(); - String intraId = newUser.getIntraId(); - String url = "/pingpong/admin/penalty/users/" + intraId; - mockMvc.perform( - delete(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNotFound()); - } - - @Test - @DisplayName("DELETE 존재하지 않는 패널티 유저 삭제") - public void deleteInvalidIntraId() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - //30자 이상 - String intraId = UUID.randomUUID().toString(); - String url = "/pingpong/admin/penalty/users/" + intraId; - mockMvc.perform( - delete(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNotFound()); - } - - @Test - @DisplayName("get pingpong/admin/penalty?page={page}&size={pageSize}¤t=true") - public void getCurrentPenalties() throws Exception { - List users = new ArrayList(); - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - //penalty user 20명 넣고 테스트 - for (int i = 0; i < 20; i++) { - User newUser = testDataUtils.createNewUser(); - users.add(newUser); - } - - //과거 penalty들 db에 저장 - for (int i = 0; i < 20; i++) { - Penalty penalty = new Penalty(users.get(i), PenaltyType.NOSHOW, "test", LocalDateTime.now().minusHours(3), 120); - penaltyAdminRepository.save(penalty); - } - - //현재 패널티 부여 - for (int i = 0; i < 20; i++) { - penaltyAdminService.givePenalty(users.get(i).getIntraId(), 3, "test" + String.valueOf(i)); - } - - - - List sizeCounts = new ArrayList(); - Integer totalPages = -1; - for (int i = 1; i <= 3; i++) { - String url = "/pingpong/admin/penalty?page=" + String.valueOf(i)+"&size=10¤t=true"; - String contentAsString = mockMvc.perform( - get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); - PenaltyListResponseDto penaltyListResponseDto = objectMapper.readValue(contentAsString, - PenaltyListResponseDto.class); - sizeCounts.add(penaltyListResponseDto.getPenaltyList().size()); - totalPages = penaltyListResponseDto.getTotalPage(); - } - Assertions.assertThat(sizeCounts).isEqualTo(List.of(10, 10, 0)); - Assertions.assertThat(totalPages).isEqualTo(2); - } -} +package com.gg.server.admin.penalty.controller; + +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import java.util.stream.Collectors; + +import org.apache.http.HttpHeaders; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.admin.penalty.data.PenaltyAdminRepository; +import com.gg.server.admin.penalty.data.PenaltyUserAdminRedisRepository; +import com.gg.server.admin.penalty.dto.PenaltyListResponseDto; +import com.gg.server.admin.penalty.dto.PenaltyRequestDto; +import com.gg.server.admin.penalty.service.PenaltyAdminService; +import com.gg.server.domain.penalty.data.Penalty; +import com.gg.server.domain.penalty.redis.RedisPenaltyUser; +import com.gg.server.domain.penalty.type.PenaltyType; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +@IntegrationTest +@AutoConfigureMockMvc +@Transactional +class PenaltyAdminControllerTest { + @Autowired + TestDataUtils testDataUtils; + @Autowired + MockMvc mockMvc; + @Autowired + ObjectMapper objectMapper; + @Autowired + UserRepository userRepository; + @Autowired + PenaltyUserAdminRedisRepository penaltyUserAdminRedisRepository; + @Autowired + PenaltyAdminRepository penaltyAdminRepository; + @Autowired + AuthTokenProvider tokenProvider; + @Autowired + RedisConnectionFactory redisConnectionFactory; + @Autowired + PenaltyAdminService penaltyAdminService; + + private final String headUrl = "/pingpong/admin/"; + + @AfterEach + void clear() { + RedisConnection connection = redisConnectionFactory.getConnection(); + connection.flushDb(); + connection.close(); + } + + @Test + @DisplayName("POST : penalty를 부여받지 않은 유효한 intraId에 penalty 부여") + public void giveUserPenaltyforFirstTimeWithValidIntraId() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + User newUser = testDataUtils.createNewUser(); + String intraId = newUser.getIntraId(); + String url = "/pingpong/admin/penalty"; + mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(new PenaltyRequestDto(intraId, 3, "test1")))) + .andExpect(status().isCreated()); + Optional penaltyUser = penaltyUserAdminRedisRepository.findByIntraId(intraId); + //redis + Assertions.assertThat(penaltyUser).isPresent(); + Assertions.assertThat(penaltyUser.get().getPenaltyTime()).isEqualTo(3 * 60); + Assertions.assertThat( + Duration.between(penaltyUser.get().getStartTime(), + penaltyUser.get().getReleaseTime()).getSeconds()).isEqualTo(3 * 60 * 60); + Assertions.assertThat(penaltyUser.get().getReason()); + //mySQL + List penalties = penaltyAdminRepository.findAll(); + Assertions.assertThat(penalties.stream().anyMatch(ele -> ele.getUser().getIntraId().equals(intraId) + && ele.getPenaltyTime().equals(3 * 60))).isEqualTo(true); + } + + @Test + @DisplayName("POST : penalty를 부여받은 유효한 intraId에 penalty 부여") + public void giveUserPenaltyRepeatablyWithValidIntraId() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + User newUser = testDataUtils.createNewUser(); + String intraId = newUser.getIntraId(); + String url = "/pingpong/admin/penalty"; + //패널티 두번 부여 + mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(new PenaltyRequestDto(intraId, 3, "test1")))) + .andExpect(status().isCreated()); + mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(new PenaltyRequestDto(intraId, 2, "test2")))) + .andExpect(status().isCreated()); + Optional penaltyUser = penaltyUserAdminRedisRepository.findByIntraId(intraId); + //redis 확인 + Assertions.assertThat(penaltyUser).isPresent(); + Assertions.assertThat(penaltyUser.get().getPenaltyTime()).isEqualTo(5 * 60); + Assertions.assertThat( + Duration.between(penaltyUser.get().getStartTime(), + penaltyUser.get().getReleaseTime()).getSeconds()).isEqualTo(5 * 60 * 60); + Assertions.assertThat(penaltyUser.get().getReason()); + //mySQL 확인 + List penalties = penaltyAdminRepository.findAll(); + List userPenalties = penalties.stream().filter(ele -> ele.getUser().getIntraId().equals(intraId)) + .collect(Collectors.toList()); + Assertions.assertThat(userPenalties.size()).isEqualTo(2); + Duration duration = Duration.between(userPenalties.get(0).getStartTime(), userPenalties.get(1).getStartTime()); + Assertions.assertThat(duration.getSeconds()).isEqualTo(3 * 60 * 60); + } + + @Test + @DisplayName("POST 유효하지 않은 intraId에 penalty 부여") + public void giveUserPenaltyWithInvalidIntraId() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + String intraId = "invalid!"; + String url = "/pingpong/admin/penalty"; + mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(new PenaltyRequestDto(intraId, 3, "test1")))) + .andExpect(status().is4xxClientError()); + } + + @Test + @DisplayName("GET pagination 유효성 검사") + public void checkPagination() throws Exception { + List users = new ArrayList(); + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + //penalty user 20명 넣고 테스트 + for (int i = 0; i < 20; i++) { + User newUser = testDataUtils.createNewUser(); + users.add(newUser); + penaltyAdminService.givePenalty(newUser.getIntraId(), 3, "test" + String.valueOf(i)); + } + List sizeCounts = new ArrayList(); + Integer totalPages = -1; + for (int i = 1; i <= 3; i++) { + String url = "/pingpong/admin/penalty?page=" + String.valueOf(i) + "&size=10¤t=true"; + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + PenaltyListResponseDto penaltyListResponseDto = objectMapper.readValue(contentAsString, + PenaltyListResponseDto.class); + sizeCounts.add(penaltyListResponseDto.getPenaltyList().size()); + totalPages = penaltyListResponseDto.getTotalPage(); + } + Assertions.assertThat(sizeCounts).isEqualTo(List.of(10, 10, 0)); + Assertions.assertThat(totalPages).isEqualTo(2); + } + + @Test + @DisplayName("GET parameter 유효성 검사") + public void checkInputException() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + String url = "/pingpong/admin/penalty?page=-1&size=10¤t=false"; + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isBadRequest()).andReturn().getResponse().getContentAsString(); + String url2 = "/pingpong/admin/penalty?page=2&size=0¤t=false"; + String contentAsString2 = mockMvc.perform( + get(url2).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isBadRequest()).andReturn().getResponse().getContentAsString(); + } + + @Test + @DisplayName("GET pagination keyword 유효성 검사") + public void checkPaginationWithKeyword() throws Exception { + List users = new ArrayList(); + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + //penalty user 40명 넣고 테스트 + //그중 20명만 intraId에 test포함 + for (int i = 0; i < 20; i++) { + String intraId = UUID.randomUUID().toString().substring(0, 4) + "test" + UUID.randomUUID().toString() + .substring(0, 4); + User newUser = testDataUtils.createNewUser(intraId, "test", RacketType.NONE, SnsType.EMAIL, + RoleType.USER); + users.add(newUser); + penaltyAdminService.givePenalty(newUser.getIntraId(), 3, "test" + String.valueOf(i)); + } + for (int i = 0; i < 20; i++) { + String intraId = "dummy" + String.valueOf(i); + User newUser = testDataUtils.createNewUser(intraId, "test", RacketType.NONE, SnsType.EMAIL, + RoleType.USER); + users.add(newUser); + penaltyAdminService.givePenalty(newUser.getIntraId(), 3, "test" + String.valueOf(i)); + } + List sizeCounts = new ArrayList(); + Integer totalPages = -1; + for (int i = 1; i <= 3; i++) { + String url = "/pingpong/admin/penalty?page=" + String.valueOf(i) + "&size=10¤t=true&intraId=test"; + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + PenaltyListResponseDto penaltyListResponseDto = objectMapper.readValue(contentAsString, + PenaltyListResponseDto.class); + sizeCounts.add(penaltyListResponseDto.getPenaltyList().size()); + totalPages = penaltyListResponseDto.getTotalPage(); + } + Assertions.assertThat(sizeCounts).isEqualTo(List.of(10, 10, 0)); + Assertions.assertThat(totalPages).isEqualTo(2); + } + + @Test + @DisplayName("DELETE 패널티 삭제 - 유저 패널티가 1번만 부과된 경우") + public void deleteExistPenaltyUser() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + User newUser = testDataUtils.createNewUser(); + String intraId = newUser.getIntraId(); + penaltyAdminService.givePenalty(intraId, 3, "test!"); + List penalties = penaltyAdminRepository.findAll(); + List userPenalties = penalties.stream().filter(ele -> ele.getUser().getIntraId().equals(intraId)) + .collect(Collectors.toList()); + Long penaltyId = userPenalties.get(0).getId(); + String url = "/pingpong/admin/penalty/" + penaltyId.toString(); + mockMvc.perform( + delete(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNoContent()); + //Redis에 penaltyUser 없는지 확인 + Optional penaltyUser = penaltyUserAdminRedisRepository.findByIntraId(intraId); + Assertions.assertThat(penaltyUser).isEmpty(); + //MySQL에 penalty 없는지 확인 + List afterPenalties = penaltyAdminRepository.findAll(); + boolean isPresent = afterPenalties.stream().anyMatch(ele -> ele.getId().equals(penaltyId)); + Assertions.assertThat(isPresent).isEqualTo(false); + } + + @Test + @DisplayName("DELETE 패널티 삭제 - 유저 패널티가 2번 부과된 경우") + public void deleteExistPenaltyUserOfTwicePenalty() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + User newUser = testDataUtils.createNewUser(); + String intraId = newUser.getIntraId(); + penaltyAdminService.givePenalty(intraId, 3, "test!"); + penaltyAdminService.givePenalty(intraId, 2, "test2"); + List penalties = penaltyAdminRepository.findAll(); + List userPenalties = penalties.stream().filter(ele -> ele.getUser().getIntraId().equals(intraId)) + .collect(Collectors.toList()); + Long penaltyId = userPenalties.get(0).getId(); + String url = "/pingpong/admin/penalty/" + penaltyId.toString(); + mockMvc.perform( + delete(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNoContent()); + //Redis에 penaltyUser 있는지 확인 + Optional penaltyUser = penaltyUserAdminRedisRepository.findByIntraId(intraId); + Assertions.assertThat(penaltyUser.get().getPenaltyTime()).isEqualTo(2 * 60); + + //MySQL에 penalty 없는지 확인 + List afterPenalties = penaltyAdminRepository.findAll(); + boolean isPresent = afterPenalties.stream().anyMatch(ele -> ele.getId().equals(penaltyId)); + Assertions.assertThat(isPresent).isEqualTo(false); + } + + @Test + @DisplayName("DELETE 존재하지 않는 패널티 유저 삭제") + public void deleteInvalidPenaltyUser() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + //user에 패널티는 부여하지 않는다. + User newUser = testDataUtils.createNewUser(); + String intraId = newUser.getIntraId(); + String url = "/pingpong/admin/penalty/users/" + intraId; + mockMvc.perform( + delete(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNotFound()); + } + + @Test + @DisplayName("DELETE 존재하지 않는 패널티 유저 삭제") + public void deleteInvalidIntraId() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + //30자 이상 + String intraId = UUID.randomUUID().toString(); + String url = "/pingpong/admin/penalty/users/" + intraId; + mockMvc.perform( + delete(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNotFound()); + } + + @Test + @DisplayName("get pingpong/admin/penalty?page={page}&size={pageSize}¤t=true") + public void getCurrentPenalties() throws Exception { + List users = new ArrayList(); + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + //penalty user 20명 넣고 테스트 + for (int i = 0; i < 20; i++) { + User newUser = testDataUtils.createNewUser(); + users.add(newUser); + } + + //과거 penalty들 db에 저장 + for (int i = 0; i < 20; i++) { + Penalty penalty = new Penalty(users.get(i), PenaltyType.NOSHOW, "test", LocalDateTime.now().minusHours(3), + 120); + penaltyAdminRepository.save(penalty); + } + + //현재 패널티 부여 + for (int i = 0; i < 20; i++) { + penaltyAdminService.givePenalty(users.get(i).getIntraId(), 3, "test" + String.valueOf(i)); + } + + List sizeCounts = new ArrayList(); + Integer totalPages = -1; + for (int i = 1; i <= 3; i++) { + String url = "/pingpong/admin/penalty?page=" + String.valueOf(i) + "&size=10¤t=true"; + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + PenaltyListResponseDto penaltyListResponseDto = objectMapper.readValue(contentAsString, + PenaltyListResponseDto.class); + sizeCounts.add(penaltyListResponseDto.getPenaltyList().size()); + totalPages = penaltyListResponseDto.getTotalPage(); + } + Assertions.assertThat(sizeCounts).isEqualTo(List.of(10, 10, 0)); + Assertions.assertThat(totalPages).isEqualTo(2); + } +} diff --git a/src/test/java/com/gg/server/admin/receipt/controller/ReceiptAdminControllerTest.java b/src/test/java/com/gg/server/admin/receipt/controller/ReceiptAdminControllerTest.java index 2faf794e4..6e4197952 100644 --- a/src/test/java/com/gg/server/admin/receipt/controller/ReceiptAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/receipt/controller/ReceiptAdminControllerTest.java @@ -1,21 +1,9 @@ package com.gg.server.admin.receipt.controller; -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.assertj.core.api.Assertions.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.admin.receipt.data.ReceiptAdminRepository; -import com.gg.server.admin.receipt.dto.ReceiptListResponseDto; -import com.gg.server.admin.receipt.service.ReceiptAdminService; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.item.data.Item; -import com.gg.server.domain.item.type.ItemType; -import com.gg.server.domain.user.data.User; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.ItemTestUtils; -import com.gg.server.utils.TestDataUtils; import org.apache.http.HttpHeaders; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -28,80 +16,102 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.admin.item.dto.ItemUpdateRequestDto; +import com.gg.server.admin.receipt.data.ReceiptAdminRepository; +import com.gg.server.admin.receipt.dto.ReceiptListResponseDto; +import com.gg.server.admin.receipt.service.ReceiptAdminService; +import com.gg.server.domain.item.data.Item; +import com.gg.server.domain.item.type.ItemType; +import com.gg.server.domain.user.data.User; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.ItemTestUtils; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + @IntegrationTest @AutoConfigureMockMvc @Transactional class ReceiptAdminControllerTest { - @Autowired - ReceiptAdminService receiptAdminService; - @Autowired - ReceiptAdminRepository receiptAdminRepository; - @Autowired - TestDataUtils testDataUtils; - @Autowired - ObjectMapper objectMapper; - @Autowired - AuthTokenProvider tokenProvider; - @Autowired - MockMvc mockMvc; - @Autowired - ItemTestUtils itemTestUtils; - Item item; - User user; - @BeforeEach - void setUp() { - user = testDataUtils.createNewUser(); - ItemUpdateRequestDto dto = new ItemUpdateRequestDto("name", "mainContent", "subContent", - 100, 50, ItemType.EDGE); - item = itemTestUtils.createItem(testDataUtils.createAdminUserForItem(), dto); - } + @Autowired + ReceiptAdminService receiptAdminService; + @Autowired + ReceiptAdminRepository receiptAdminRepository; + @Autowired + TestDataUtils testDataUtils; + @Autowired + ObjectMapper objectMapper; + @Autowired + AuthTokenProvider tokenProvider; + @Autowired + MockMvc mockMvc; + @Autowired + ItemTestUtils itemTestUtils; + Item item; + User user; + + @BeforeEach + void setUp() { + user = testDataUtils.createNewUser(); + ItemUpdateRequestDto dto = new ItemUpdateRequestDto("name", "mainContent", "subContent", + 100, 50, ItemType.EDGE); + item = itemTestUtils.createItem(testDataUtils.createAdminUserForItem(), dto); + } - @Test - @DisplayName("GET /pingpong/admin/receipt") - public void getAllReceipt() throws Exception { - itemTestUtils.purchaseItem(user, user, item); - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Integer page = 1; - Integer size = 20; - String url = "/pingpong/admin/receipt?page=" + page + "&size=" + size; - Pageable pageable = PageRequest.of(page - 1, size, Sort.by("createdAt").descending()); - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - ReceiptListResponseDto expect = receiptAdminService.getAllReceipt(pageable); - ReceiptListResponseDto result = objectMapper.readValue(contentAsString, ReceiptListResponseDto.class); - assertThat(result.getReceiptList().get(0).getReceiptId()).isEqualTo(expect.getReceiptList().get(0).getReceiptId()); - assertThat(result.getReceiptList().get(0).getCreatedAt()).isEqualTo(expect.getReceiptList().get(0).getCreatedAt()); - assertThat(result.getReceiptList().get(0).getItemName()).isEqualTo(expect.getReceiptList().get(0).getItemName()); - assertThat(result.getReceiptList().get(0).getItemPrice()).isEqualTo(expect.getReceiptList().get(0).getItemPrice()); - assertThat(result.getReceiptList().size()).isEqualTo(expect.getReceiptList().size()); - assertThat(result.getReceiptList().size()).isEqualTo(1); - } + @Test + @DisplayName("GET /pingpong/admin/receipt") + public void getAllReceipt() throws Exception { + itemTestUtils.purchaseItem(user, user, item); + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Integer page = 1; + Integer size = 20; + String url = "/pingpong/admin/receipt?page=" + page + "&size=" + size; + Pageable pageable = PageRequest.of(page - 1, size, Sort.by("createdAt").descending()); + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + ReceiptListResponseDto expect = receiptAdminService.getAllReceipt(pageable); + ReceiptListResponseDto result = objectMapper.readValue(contentAsString, ReceiptListResponseDto.class); + assertThat(result.getReceiptList().get(0).getReceiptId()).isEqualTo( + expect.getReceiptList().get(0).getReceiptId()); + assertThat(result.getReceiptList().get(0).getCreatedAt()).isEqualTo( + expect.getReceiptList().get(0).getCreatedAt()); + assertThat(result.getReceiptList().get(0).getItemName()).isEqualTo( + expect.getReceiptList().get(0).getItemName()); + assertThat(result.getReceiptList().get(0).getItemPrice()).isEqualTo( + expect.getReceiptList().get(0).getItemPrice()); + assertThat(result.getReceiptList().size()).isEqualTo(expect.getReceiptList().size()); + assertThat(result.getReceiptList().size()).isEqualTo(1); + } - @Test - @DisplayName("GET /pingpong/admin/receipt") - public void findByIntraId() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Integer page = 1; - Integer size = 20; - User targetUser = testDataUtils.createNewUser("david"); - itemTestUtils.purchaseItem(user, user, item); - itemTestUtils.purchaseItem(targetUser, targetUser, item); + @Test + @DisplayName("GET /pingpong/admin/receipt") + public void findByIntraId() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Integer page = 1; + Integer size = 20; + User targetUser = testDataUtils.createNewUser("david"); + itemTestUtils.purchaseItem(user, user, item); + itemTestUtils.purchaseItem(targetUser, targetUser, item); - String url = "/pingpong/admin/receipt?page=" + page + "&size=" + size + "&intraId=" + targetUser.getIntraId(); - Pageable pageable = PageRequest.of(page - 1, size, Sort.by("createdAt").descending()); - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - ReceiptListResponseDto expect = receiptAdminService.findByIntraId(targetUser.getIntraId(), pageable); - ReceiptListResponseDto result = objectMapper.readValue(contentAsString, ReceiptListResponseDto.class); - assertThat(result.getReceiptList().get(0).getReceiptId()).isEqualTo(expect.getReceiptList().get(0).getReceiptId()); - assertThat(result.getReceiptList().get(0).getCreatedAt()).isEqualTo(expect.getReceiptList().get(0).getCreatedAt()); - assertThat(result.getReceiptList().get(0).getItemName()).isEqualTo(expect.getReceiptList().get(0).getItemName()); - assertThat(result.getReceiptList().get(0).getItemPrice()).isEqualTo(expect.getReceiptList().get(0).getItemPrice()); - assertThat(result.getReceiptList().size()).isEqualTo(expect.getReceiptList().size()); - assertThat(result.getReceiptList().size()).isEqualTo(1); - } -} \ No newline at end of file + String url = "/pingpong/admin/receipt?page=" + page + "&size=" + size + "&intraId=" + targetUser.getIntraId(); + Pageable pageable = PageRequest.of(page - 1, size, Sort.by("createdAt").descending()); + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + ReceiptListResponseDto expect = receiptAdminService.findByIntraId(targetUser.getIntraId(), pageable); + ReceiptListResponseDto result = objectMapper.readValue(contentAsString, ReceiptListResponseDto.class); + assertThat(result.getReceiptList().get(0).getReceiptId()).isEqualTo( + expect.getReceiptList().get(0).getReceiptId()); + assertThat(result.getReceiptList().get(0).getCreatedAt()).isEqualTo( + expect.getReceiptList().get(0).getCreatedAt()); + assertThat(result.getReceiptList().get(0).getItemName()).isEqualTo( + expect.getReceiptList().get(0).getItemName()); + assertThat(result.getReceiptList().get(0).getItemPrice()).isEqualTo( + expect.getReceiptList().get(0).getItemPrice()); + assertThat(result.getReceiptList().size()).isEqualTo(expect.getReceiptList().size()); + assertThat(result.getReceiptList().size()).isEqualTo(1); + } +} diff --git a/src/test/java/com/gg/server/admin/season/SeasonAdminControllerTest.java b/src/test/java/com/gg/server/admin/season/SeasonAdminControllerTest.java index ee80537de..b0c7f7a44 100644 --- a/src/test/java/com/gg/server/admin/season/SeasonAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/season/SeasonAdminControllerTest.java @@ -1,7 +1,20 @@ package com.gg.server.admin.season; -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.assertj.core.api.Assertions.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.time.LocalDateTime; +import java.util.List; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; import com.gg.server.admin.rank.service.RankAdminService; @@ -12,7 +25,6 @@ import com.gg.server.admin.season.dto.SeasonListAdminResponseDto; import com.gg.server.admin.season.dto.SeasonUpdateRequestDto; import com.gg.server.admin.season.service.SeasonAdminService; -import com.gg.server.utils.annotation.IntegrationTest; import com.gg.server.domain.rank.data.RankRepository; import com.gg.server.domain.rank.exception.RedisDataNotFoundException; import com.gg.server.domain.rank.redis.RankRedisRepository; @@ -23,218 +35,208 @@ import com.gg.server.domain.tier.data.Tier; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; import com.google.common.net.HttpHeaders; -import java.time.LocalDateTime; -import java.util.List; + import lombok.RequiredArgsConstructor; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import org.springframework.transaction.annotation.Transactional; @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc @Transactional class SeasonAdminControllerTest { - @Autowired - MockMvc mockMvc; - - @Autowired - ObjectMapper objectMapper; - - @Autowired - private SeasonAdminRepository seasonAdminRepository; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - TestDataUtils testDataUtils; - - @Autowired - RankRepository rankRepository; - - @Autowired - RankRedisRepository rankRedisRepository; - - @Autowired - SeasonAdminService seasonAdminService; - - @Autowired - RankAdminService rankAdminService; - - @Autowired - RankRedisAdminService rankRedisAdminService; - - SeasonListAdminResponseDto responseDto; - Long dbSeasonId; - - - @AfterEach - void tearDown() { - rankRedisRepository.deleteAll(); - } - - @Test - @DisplayName("[GET]pingpong/admin/seasons") - void getAdminSeasons() throws Exception { - testDataUtils.createTierSystem("pingpong"); - testDataUtils.createSeason(); - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - - String contentAsString = mockMvc.perform(MockMvcRequestBuilders.get("/pingpong/admin/seasons") - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - SeasonListAdminResponseDto seasonListAdminResponseDto = objectMapper.readValue(contentAsString, SeasonListAdminResponseDto.class); - System.out.println(seasonListAdminResponseDto.getSeasonList().size()); - } - - @Test - @DisplayName("[POST]/pingpong/admin/seasons") - void createSeasons() throws Exception { - List pingpong = testDataUtils.createTierSystem("pingpong"); - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - - SeasonCreateRequestDto seasonCreateReqeustDto = new SeasonCreateRequestDto( - "redis1", - LocalDateTime.now().plusHours(25), - 1000, - 500); - String content = objectMapper.writeValueAsString(seasonCreateReqeustDto); - - String contentAsString = mockMvc.perform(MockMvcRequestBuilders.post("/pingpong/admin/seasons") - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isCreated()) - .andReturn().getResponse().getContentAsString(); - - dbSeasonId = rankRepository.findFirstByOrderByCreatedAtDesc().get().getSeason().getId(); - String redisHashKey = RedisKeyManager.getHashKey(dbSeasonId); - - - if (rankRedisRepository.findRankByUserId(redisHashKey, userId) == null) - throw new SeasonNotFoundException(); - System.out.println(rankRedisRepository.findRankByUserId(redisHashKey, userId).getIntraId()); - } - - - @Test - @DisplayName("[Delete]/pingpong/admin/season/{seasonId}") - void deleteSeasons() throws Exception { - testDataUtils.createTierSystem("pingpong"); - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - - Season newSeason = Season.builder() - .seasonName("redis1") - .startTime(LocalDateTime.now().plusDays(1)) - .endTime(LocalDateTime.now().plusDays(10)) - .startPpp(1000) - .pppGap(500) - .build(); - seasonAdminRepository.save(newSeason); - Long seasonId = newSeason.getId(); - - SeasonAdminDto seasonAdminDto = seasonAdminService.findSeasonById(seasonId); - if (LocalDateTime.now().isBefore(seasonAdminDto.getStartTime())) { - rankAdminService.addAllUserRankByNewSeason(seasonAdminDto); - rankRedisAdminService.addAllUserRankByNewSeason(seasonAdminDto); - } - dbSeasonId = seasonId; - - String contentAsString = mockMvc.perform(MockMvcRequestBuilders.delete("/pingpong/admin/seasons/" + dbSeasonId) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNoContent()) - .andReturn().getResponse().getContentAsString(); - - try { - String redisHashKey = RedisKeyManager.getHashKey(dbSeasonId); - if (rankRedisRepository.findRankByUserId(redisHashKey, userId) != null) - throw new SeasonForbiddenException(); - } - catch(RedisDataNotFoundException ex){ - System.out.println("success: 레디스가 지워져 있습니다"); - } - } - - @Test - @DisplayName("[Put]/pingpong/admin/seasons/{seasonId}") - void updateSeasons() throws Exception { - testDataUtils.createTierSystem("pingpong"); - testDataUtils.createSeason(); - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - - Season newSeason = Season.builder() - .seasonName("redis1") - .startTime(LocalDateTime.now().plusHours(25)) - .endTime(LocalDateTime.now().plusDays(10)) - .startPpp(1000) - .pppGap(500) - .build(); - seasonAdminRepository.save(newSeason); - Long seasonId = newSeason.getId(); - - SeasonAdminDto seasonAdminDto = seasonAdminService.findSeasonById(seasonId); - if (LocalDateTime.now().isBefore(seasonAdminDto.getStartTime())) { - rankAdminService.addAllUserRankByNewSeason(seasonAdminDto); - rankRedisAdminService.addAllUserRankByNewSeason(seasonAdminDto); - } - dbSeasonId = seasonId; - SeasonUpdateRequestDto seasonUpdateRequestDto = new SeasonUpdateRequestDto( - "putSeasonTestName", - LocalDateTime.now().plusHours(25), - 1000, - 500); - - String content = objectMapper.writeValueAsString(seasonUpdateRequestDto); - - String contentAsString = mockMvc.perform(MockMvcRequestBuilders.put("/pingpong/admin/seasons/" + dbSeasonId) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNoContent()) - .andReturn().getResponse().getContentAsString(); - - assertThat(seasonAdminRepository.findById(dbSeasonId).get().getSeasonName()) - .isEqualTo(seasonUpdateRequestDto.getSeasonName()); - } - - @Test - @DisplayName("Fail[Put]/pingpong/admin/seasons/{seasonId}") - void failUpdateSeasons() throws Exception {//현재 시즌을 변경할 때 400번대 상태코드 반환 - testDataUtils.createTierSystem("pingpong"); - testDataUtils.createSeason(); - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - - Long nowSeasonId = seasonAdminRepository.findCurrentSeason(LocalDateTime.now().plusMinutes(1)).get().getId(); - SeasonUpdateRequestDto seasonUpdateRequestDto = new SeasonUpdateRequestDto( - "putSeasonTestName", - LocalDateTime.now().plusHours(25), - 1000, - 500); - - String content = objectMapper.writeValueAsString(seasonUpdateRequestDto); - - String contentAsString = mockMvc.perform(MockMvcRequestBuilders.put("/pingpong/admin/seasons/" + nowSeasonId) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().is4xxClientError())//403반환 - .andReturn().getResponse().getContentAsString(); - - } -} \ No newline at end of file + @Autowired + MockMvc mockMvc; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + private SeasonAdminRepository seasonAdminRepository; + + @Autowired + AuthTokenProvider tokenProvider; + + @Autowired + TestDataUtils testDataUtils; + + @Autowired + RankRepository rankRepository; + + @Autowired + RankRedisRepository rankRedisRepository; + + @Autowired + SeasonAdminService seasonAdminService; + + @Autowired + RankAdminService rankAdminService; + + @Autowired + RankRedisAdminService rankRedisAdminService; + + SeasonListAdminResponseDto responseDto; + Long dbSeasonId; + + @AfterEach + void tearDown() { + rankRedisRepository.deleteAll(); + } + + @Test + @DisplayName("[GET]pingpong/admin/seasons") + void getAdminSeasons() throws Exception { + testDataUtils.createTierSystem("pingpong"); + testDataUtils.createSeason(); + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + + String contentAsString = mockMvc.perform(MockMvcRequestBuilders.get("/pingpong/admin/seasons") + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + SeasonListAdminResponseDto seasonListAdminResponseDto = objectMapper.readValue(contentAsString, + SeasonListAdminResponseDto.class); + System.out.println(seasonListAdminResponseDto.getSeasonList().size()); + } + + @Test + @DisplayName("[POST]/pingpong/admin/seasons") + void createSeasons() throws Exception { + List pingpong = testDataUtils.createTierSystem("pingpong"); + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + + SeasonCreateRequestDto seasonCreateReqeustDto = new SeasonCreateRequestDto( + "redis1", + LocalDateTime.now().plusHours(25), + 1000, + 500); + String content = objectMapper.writeValueAsString(seasonCreateReqeustDto); + + String contentAsString = mockMvc.perform(MockMvcRequestBuilders.post("/pingpong/admin/seasons") + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isCreated()) + .andReturn().getResponse().getContentAsString(); + + dbSeasonId = rankRepository.findFirstByOrderByCreatedAtDesc().get().getSeason().getId(); + String redisHashKey = RedisKeyManager.getHashKey(dbSeasonId); + + if (rankRedisRepository.findRankByUserId(redisHashKey, userId) == null) { + throw new SeasonNotFoundException(); + } + System.out.println(rankRedisRepository.findRankByUserId(redisHashKey, userId).getIntraId()); + } + + @Test + @DisplayName("[Delete]/pingpong/admin/season/{seasonId}") + void deleteSeasons() throws Exception { + testDataUtils.createTierSystem("pingpong"); + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + + Season newSeason = Season.builder() + .seasonName("redis1") + .startTime(LocalDateTime.now().plusDays(1)) + .endTime(LocalDateTime.now().plusDays(10)) + .startPpp(1000) + .pppGap(500) + .build(); + seasonAdminRepository.save(newSeason); + Long seasonId = newSeason.getId(); + + SeasonAdminDto seasonAdminDto = seasonAdminService.findSeasonById(seasonId); + if (LocalDateTime.now().isBefore(seasonAdminDto.getStartTime())) { + rankAdminService.addAllUserRankByNewSeason(seasonAdminDto); + rankRedisAdminService.addAllUserRankByNewSeason(seasonAdminDto); + } + dbSeasonId = seasonId; + + String contentAsString = mockMvc.perform(MockMvcRequestBuilders.delete("/pingpong/admin/seasons/" + dbSeasonId) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNoContent()) + .andReturn().getResponse().getContentAsString(); + + try { + String redisHashKey = RedisKeyManager.getHashKey(dbSeasonId); + if (rankRedisRepository.findRankByUserId(redisHashKey, userId) != null) { + throw new SeasonForbiddenException(); + } + } catch (RedisDataNotFoundException ex) { + System.out.println("success: 레디스가 지워져 있습니다"); + } + } + + @Test + @DisplayName("[Put]/pingpong/admin/seasons/{seasonId}") + void updateSeasons() throws Exception { + testDataUtils.createTierSystem("pingpong"); + testDataUtils.createSeason(); + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + + Season newSeason = Season.builder() + .seasonName("redis1") + .startTime(LocalDateTime.now().plusHours(25)) + .endTime(LocalDateTime.now().plusDays(10)) + .startPpp(1000) + .pppGap(500) + .build(); + seasonAdminRepository.save(newSeason); + Long seasonId = newSeason.getId(); + + SeasonAdminDto seasonAdminDto = seasonAdminService.findSeasonById(seasonId); + if (LocalDateTime.now().isBefore(seasonAdminDto.getStartTime())) { + rankAdminService.addAllUserRankByNewSeason(seasonAdminDto); + rankRedisAdminService.addAllUserRankByNewSeason(seasonAdminDto); + } + dbSeasonId = seasonId; + SeasonUpdateRequestDto seasonUpdateRequestDto = new SeasonUpdateRequestDto( + "putSeasonTestName", + LocalDateTime.now().plusHours(25), + 1000, + 500); + + String content = objectMapper.writeValueAsString(seasonUpdateRequestDto); + + String contentAsString = mockMvc.perform(MockMvcRequestBuilders.put("/pingpong/admin/seasons/" + dbSeasonId) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNoContent()) + .andReturn().getResponse().getContentAsString(); + + assertThat(seasonAdminRepository.findById(dbSeasonId).get().getSeasonName()) + .isEqualTo(seasonUpdateRequestDto.getSeasonName()); + } + + @Test + @DisplayName("Fail[Put]/pingpong/admin/seasons/{seasonId}") + void failUpdateSeasons() throws Exception { //현재 시즌을 변경할 때 400번대 상태코드 반환 + testDataUtils.createTierSystem("pingpong"); + testDataUtils.createSeason(); + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + + Long nowSeasonId = seasonAdminRepository.findCurrentSeason(LocalDateTime.now().plusMinutes(1)).get().getId(); + SeasonUpdateRequestDto seasonUpdateRequestDto = new SeasonUpdateRequestDto( + "putSeasonTestName", + LocalDateTime.now().plusHours(25), + 1000, + 500); + + String content = objectMapper.writeValueAsString(seasonUpdateRequestDto); + + String contentAsString = mockMvc.perform(MockMvcRequestBuilders.put("/pingpong/admin/seasons/" + nowSeasonId) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().is4xxClientError())//403반환 + .andReturn().getResponse().getContentAsString(); + + } +} diff --git a/src/test/java/com/gg/server/admin/slotmanagement/controller/SlotAdminControllerFailTest.java b/src/test/java/com/gg/server/admin/slotmanagement/controller/SlotAdminControllerFailTest.java index e70c2b819..1741e2f64 100644 --- a/src/test/java/com/gg/server/admin/slotmanagement/controller/SlotAdminControllerFailTest.java +++ b/src/test/java/com/gg/server/admin/slotmanagement/controller/SlotAdminControllerFailTest.java @@ -1,20 +1,11 @@ package com.gg.server.admin.slotmanagement.controller; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.slotmanagement.data.adminSlotManagementRepository; -import com.gg.server.admin.slotmanagement.dto.SlotCreateRequestDto; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; import java.time.LocalDateTime; import java.util.List; -import lombok.RequiredArgsConstructor; + import org.apache.http.HttpHeaders; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -24,152 +15,150 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.admin.slotmanagement.data.AdminSlotManagementsRepository; +import com.gg.server.admin.slotmanagement.dto.SlotCreateRequestDto; +import com.gg.server.domain.slotmanagement.SlotManagement; +import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; + @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc @Transactional public class SlotAdminControllerFailTest { - @Autowired - TestDataUtils testDataUtils; - - @Autowired - private MockMvc mockMvc; - - @Autowired - ObjectMapper objectMapper; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - adminSlotManagementRepository adminSlotManagementRepository; - - @Autowired - SlotManagementRepository slotManagementRepository; - -//이거 테스트 할려면 디비 내용 모두 지워야 함 -// @Test -// @DisplayName("fail[Get]/pingpong/admin/slot-management") -// void failGetSlotSetting() throws Exception { -// String accessToken = testDataUtils.getLoginAccessToken(); -// Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); -// -// String contentAsString = mockMvc.perform(get("/pingpong/admin/slot-management").header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) -// .andExpect(status().isBadRequest()) -// .andReturn().getResponse().getContentAsString(); -// -// System.out.println(contentAsString); -// } - - @Test - @DisplayName("fail[Post]/pingpong/admin/slot-management") - void failModifySlotSetting() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - SlotCreateRequestDto test = new SlotCreateRequestDto(4,1,20,null,LocalDateTime.now().plusDays(2)); - String content = objectMapper.writeValueAsString(test); - - String contentAsString = mockMvc.perform(post("/pingpong/admin/slot-management") - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - - @Test - @DisplayName("fail[Post]/pingpong/admin/slot-management") - void 엔드타임_미래시점_보다_가까울_경우() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - SlotCreateRequestDto test = new SlotCreateRequestDto(4,1,20,1,LocalDateTime.now().plusHours(1)); - String content = objectMapper.writeValueAsString(test); - - String contentAsString = mockMvc.perform(post("/pingpong/admin/slot-management") - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().is4xxClientError()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - - @Test - @DisplayName("fail[Post]/pingpong/admin/slot-management") - void 인터벌이7일때() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - SlotCreateRequestDto test = new SlotCreateRequestDto(4,1,7,1,LocalDateTime.now().plusHours(1)); - String content = objectMapper.writeValueAsString(test); - - String contentAsString = mockMvc.perform(post("/pingpong/admin/slot-management") - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().is4xxClientError()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - - @Test - @DisplayName("fail[Post]/pingpong/admin/slot-management") - void 상대방공개시간이게임시간보다클떄() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - SlotCreateRequestDto test = new SlotCreateRequestDto(4,1,10,15,LocalDateTime.now().plusHours(1)); - String content = objectMapper.writeValueAsString(test); - - String contentAsString = mockMvc.perform(post("/pingpong/admin/slot-management") - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().is4xxClientError()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - - @Test - @DisplayName("fail[Delete]/pingpong/admin/slot-management") - void 슬롯정보가현재적용중인경우() throws Exception { - SlotManagement preSlot = SlotManagement.builder() - .futureSlotTime(12) - .pastSlotTime(0) - .openMinute(5) - .gameInterval(15) - .startTime(LocalDateTime.now().minusDays(1)) - .build(); - slotManagementRepository.save(preSlot); - - String accessToken = testDataUtils.getAdminLoginAccessToken(); - - List slotManagements = adminSlotManagementRepository.findAllByOrderByCreatedAtDesc(); - for (SlotManagement slot : slotManagements) { - System.out.println("-----------------------"); - System.out.println(slot.getFutureSlotTime()); - System.out.println(slot.getPastSlotTime()); - System.out.println(slot.getOpenMinute()); - System.out.println(slot.getStartTime()); - System.out.println(slot.getEndTime()); - System.out.println(slot.getId()); - } - - String contentAsString = mockMvc.perform(delete("/pingpong/admin/slot-management") - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().is4xxClientError()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - - List slotManagements2 = adminSlotManagementRepository.findAllByOrderByCreatedAtDesc(); - for (SlotManagement slot : slotManagements2) { - System.out.println("-----------------------"); - System.out.println(slot.getFutureSlotTime()); - System.out.println(slot.getPastSlotTime()); - System.out.println(slot.getOpenMinute()); - System.out.println(slot.getStartTime()); - System.out.println(slot.getEndTime()); - System.out.println(slot.getId()); - } - } + @Autowired + TestDataUtils testDataUtils; + + @Autowired + private MockMvc mockMvc; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + AuthTokenProvider tokenProvider; + + @Autowired + AdminSlotManagementsRepository adminSlotManagementRepository; + + @Autowired + SlotManagementRepository slotManagementRepository; + + @Test + @DisplayName("fail[Post]/pingpong/admin/slot-management") + void failModifySlotSetting() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + SlotCreateRequestDto test = new SlotCreateRequestDto(4, 1, 20, null, LocalDateTime.now().plusDays(2)); + String content = objectMapper.writeValueAsString(test); + + String contentAsString = mockMvc.perform(post("/pingpong/admin/slot-management") + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @DisplayName("fail[Post]/pingpong/admin/slot-management") + void endTimeCloseThenFuture() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + SlotCreateRequestDto test = new SlotCreateRequestDto(4, 1, 20, 1, LocalDateTime.now().plusHours(1)); + String content = objectMapper.writeValueAsString(test); + + String contentAsString = mockMvc.perform(post("/pingpong/admin/slot-management") + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().is4xxClientError()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @DisplayName("fail[Post]/pingpong/admin/slot-management") + void intervalIsSeven() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + SlotCreateRequestDto test = new SlotCreateRequestDto(4, 1, 7, 1, LocalDateTime.now().plusHours(1)); + String content = objectMapper.writeValueAsString(test); + + String contentAsString = mockMvc.perform(post("/pingpong/admin/slot-management") + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().is4xxClientError()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @DisplayName("상대방공개시간이게임시간보다클떄") + void enemyOpenCloseThenGameTime() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + SlotCreateRequestDto test = new SlotCreateRequestDto(4, 1, 10, 15, + LocalDateTime.now().plusHours(1)); + String content = objectMapper.writeValueAsString(test); + + String contentAsString = mockMvc.perform(post("/pingpong/admin/slot-management") + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().is4xxClientError()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @DisplayName("슬롯정보가현재적용중인경우") + void slotAlreadyApply() throws Exception { + SlotManagement preSlot = SlotManagement.builder() + .futureSlotTime(12) + .pastSlotTime(0) + .openMinute(5) + .gameInterval(15) + .startTime(LocalDateTime.now().minusDays(1)) + .build(); + slotManagementRepository.save(preSlot); + + String accessToken = testDataUtils.getAdminLoginAccessToken(); + + List slotManagements = adminSlotManagementRepository.findAllByOrderByCreatedAtDesc(); + for (SlotManagement slot : slotManagements) { + System.out.println("-----------------------"); + System.out.println(slot.getFutureSlotTime()); + System.out.println(slot.getPastSlotTime()); + System.out.println(slot.getOpenMinute()); + System.out.println(slot.getStartTime()); + System.out.println(slot.getEndTime()); + System.out.println(slot.getId()); + } + + String contentAsString = mockMvc.perform(delete("/pingpong/admin/slot-management") + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().is4xxClientError()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + + List slotManagements2 = adminSlotManagementRepository.findAllByOrderByCreatedAtDesc(); + for (SlotManagement slot : slotManagements2) { + System.out.println("-----------------------"); + System.out.println(slot.getFutureSlotTime()); + System.out.println(slot.getPastSlotTime()); + System.out.println(slot.getOpenMinute()); + System.out.println(slot.getStartTime()); + System.out.println(slot.getEndTime()); + System.out.println(slot.getId()); + } + } } diff --git a/src/test/java/com/gg/server/admin/slotmanagement/controller/SlotAdminControllerTest.java b/src/test/java/com/gg/server/admin/slotmanagement/controller/SlotAdminControllerTest.java index ca76ed77e..ad722e176 100644 --- a/src/test/java/com/gg/server/admin/slotmanagement/controller/SlotAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/slotmanagement/controller/SlotAdminControllerTest.java @@ -1,23 +1,11 @@ package com.gg.server.admin.slotmanagement.controller; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.slotmanagement.data.adminSlotManagementRepository; -import com.gg.server.admin.slotmanagement.dto.SlotAdminDto; -import com.gg.server.admin.slotmanagement.dto.SlotCreateRequestDto; -import com.gg.server.admin.slotmanagement.dto.SlotListAdminResponseDto; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; import java.time.LocalDateTime; import java.util.List; -import lombok.RequiredArgsConstructor; + import org.apache.http.HttpHeaders; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -28,161 +16,176 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.admin.slotmanagement.data.AdminSlotManagementsRepository; +import com.gg.server.admin.slotmanagement.dto.SlotAdminDto; +import com.gg.server.admin.slotmanagement.dto.SlotCreateRequestDto; +import com.gg.server.admin.slotmanagement.dto.SlotListAdminResponseDto; +import com.gg.server.domain.slotmanagement.SlotManagement; +import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; + @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc @Transactional class SlotAdminControllerTest { - @Autowired - TestDataUtils testDataUtils; - - @Autowired - private MockMvc mockMvc; - - @Autowired - ObjectMapper objectMapper; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - adminSlotManagementRepository adminSlotManagementRepository; - - @Autowired - SlotManagementRepository slotManagementRepository; - - @BeforeEach - void setUp() { - SlotManagement preSlot = SlotManagement.builder() - .futureSlotTime(12) - .pastSlotTime(0) - .openMinute(5) - .gameInterval(15) - .startTime(LocalDateTime.now().minusDays(1)) - .build(); - slotManagementRepository.save(preSlot); - } - - @Test - @DisplayName("[Get]/pingpong/admin/slot-management") - void getSlotSetting1() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - - SlotCreateRequestDto test = new SlotCreateRequestDto(4,1,20,1,LocalDateTime.now().plusHours(13)); - System.out.println(test.getStartTime()); - String content = objectMapper.writeValueAsString(test); - mockMvc.perform(post("/pingpong/admin/slot-management") - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isCreated()) - .andReturn().getResponse().getContentAsString(); - SlotCreateRequestDto test2 = new SlotCreateRequestDto(4,1,20,1,LocalDateTime.now().plusHours(48)); - System.out.println(test.getStartTime()); - String content2 = objectMapper.writeValueAsString(test2); - mockMvc.perform(post("/pingpong/admin/slot-management") - .content(content2) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isCreated()) - .andReturn().getResponse().getContentAsString(); - - String contentAsString = mockMvc.perform(get("/pingpong/admin/slot-management").header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - SlotListAdminResponseDto slotAdminDto = objectMapper.readValue(contentAsString, SlotListAdminResponseDto.class); - - for(SlotAdminDto dto : slotAdminDto.getSlotList()){ - System.out.println(dto.getFutureSlotTime()); - System.out.println(dto.getPastSlotTime()); - System.out.println(dto.getInterval()); - System.out.println(dto.getOpenMinute()); - System.out.println(dto.getStartTime()); - System.out.println(dto.getEndTime()); - System.out.println("----------------------"); - } - } - - @Test - @DisplayName("[Get]/pingpong/admin/slot-management") - void getSlotSetting2() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - - String contentAsString = mockMvc.perform(get("/pingpong/admin/slot-management").header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - SlotListAdminResponseDto slotAdminDto = objectMapper.readValue(contentAsString, SlotListAdminResponseDto.class); - - for(SlotAdminDto dto : slotAdminDto.getSlotList()){ - System.out.println(dto.getFutureSlotTime()); - System.out.println(dto.getPastSlotTime()); - System.out.println(dto.getInterval()); - System.out.println(dto.getOpenMinute()); - System.out.println(dto.getStartTime()); - System.out.println(dto.getEndTime()); - System.out.println("----------------------"); - } - } - - @Test - @DisplayName("[Post]/pingpong/admin/slot-management") - void modifySlotSetting() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - SlotCreateRequestDto test = new SlotCreateRequestDto(4,1,20,1,LocalDateTime.now().plusHours(13)); - System.out.println(test.getStartTime()); - String content = objectMapper.writeValueAsString(test); - - String contentAsString = mockMvc.perform(post("/pingpong/admin/slot-management") - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isCreated()) - .andReturn().getResponse().getContentAsString(); - - List slotList = adminSlotManagementRepository.findAllByOrderByCreatedAtDesc(); - for(SlotManagement slot : slotList){ - System.out.println(slot.getFutureSlotTime()); - System.out.println(slot.getPastSlotTime()); - System.out.println(slot.getGameInterval()); - System.out.println(slot.getOpenMinute()); - System.out.println(slot.getStartTime()); - System.out.println(slot.getEndTime()); - System.out.println("----------------------"); - } - } - - @Test - @DisplayName("[Delete]/pingpong/admin/slot-management") - void delSlotSetting() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - SlotCreateRequestDto test = new SlotCreateRequestDto(4,1,20,1,LocalDateTime.now().plusHours(13)); - System.out.println(test.getStartTime()); - String content = objectMapper.writeValueAsString(test); - - mockMvc.perform(post("/pingpong/admin/slot-management") - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isCreated()) - .andReturn().getResponse().getContentAsString(); - - String contentAsString = mockMvc.perform(delete("/pingpong/admin/slot-management") - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNoContent()) - .andReturn().getResponse().getContentAsString(); - - List slotList = adminSlotManagementRepository.findAllByOrderByCreatedAtDesc(); - for(SlotManagement slot : slotList){ - System.out.println(slot.getFutureSlotTime()); - System.out.println(slot.getPastSlotTime()); - System.out.println(slot.getGameInterval()); - System.out.println(slot.getOpenMinute()); - System.out.println(slot.getStartTime()); - System.out.println(slot.getEndTime()); - System.out.println("----------------------"); - } - } - -} \ No newline at end of file + @Autowired + TestDataUtils testDataUtils; + + @Autowired + private MockMvc mockMvc; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + AuthTokenProvider tokenProvider; + + @Autowired + AdminSlotManagementsRepository adminSlotManagementRepository; + + @Autowired + SlotManagementRepository slotManagementRepository; + + @BeforeEach + void setUp() { + SlotManagement preSlot = SlotManagement.builder() + .futureSlotTime(12) + .pastSlotTime(0) + .openMinute(5) + .gameInterval(15) + .startTime(LocalDateTime.now().minusDays(1)) + .build(); + slotManagementRepository.save(preSlot); + } + + @Test + @DisplayName("[Get]/pingpong/admin/slot-management") + void getSlotSetting1() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + + SlotCreateRequestDto test = new SlotCreateRequestDto(4, 1, 20, 1, LocalDateTime.now().plusHours(13)); + System.out.println(test.getStartTime()); + String content = objectMapper.writeValueAsString(test); + mockMvc.perform(post("/pingpong/admin/slot-management") + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isCreated()) + .andReturn().getResponse().getContentAsString(); + SlotCreateRequestDto test2 = new SlotCreateRequestDto(4, 1, 20, 1, LocalDateTime.now().plusHours(48)); + System.out.println(test.getStartTime()); + String content2 = objectMapper.writeValueAsString(test2); + mockMvc.perform(post("/pingpong/admin/slot-management") + .content(content2) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isCreated()) + .andReturn().getResponse().getContentAsString(); + + String contentAsString = mockMvc.perform( + get("/pingpong/admin/slot-management").header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + SlotListAdminResponseDto slotAdminDto = objectMapper.readValue(contentAsString, SlotListAdminResponseDto.class); + + for (SlotAdminDto dto : slotAdminDto.getSlotList()) { + System.out.println(dto.getFutureSlotTime()); + System.out.println(dto.getPastSlotTime()); + System.out.println(dto.getInterval()); + System.out.println(dto.getOpenMinute()); + System.out.println(dto.getStartTime()); + System.out.println(dto.getEndTime()); + System.out.println("----------------------"); + } + } + + @Test + @DisplayName("[Get]/pingpong/admin/slot-management") + void getSlotSetting2() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + + String contentAsString = mockMvc.perform( + get("/pingpong/admin/slot-management").header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + SlotListAdminResponseDto slotAdminDto = objectMapper.readValue(contentAsString, SlotListAdminResponseDto.class); + + for (SlotAdminDto dto : slotAdminDto.getSlotList()) { + System.out.println(dto.getFutureSlotTime()); + System.out.println(dto.getPastSlotTime()); + System.out.println(dto.getInterval()); + System.out.println(dto.getOpenMinute()); + System.out.println(dto.getStartTime()); + System.out.println(dto.getEndTime()); + System.out.println("----------------------"); + } + } + + @Test + @DisplayName("[Post]/pingpong/admin/slot-management") + void modifySlotSetting() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + SlotCreateRequestDto test = new SlotCreateRequestDto(4, 1, 20, 1, LocalDateTime.now().plusHours(13)); + System.out.println(test.getStartTime()); + String content = objectMapper.writeValueAsString(test); + + String contentAsString = mockMvc.perform(post("/pingpong/admin/slot-management") + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isCreated()) + .andReturn().getResponse().getContentAsString(); + + List slotList = adminSlotManagementRepository.findAllByOrderByCreatedAtDesc(); + for (SlotManagement slot : slotList) { + System.out.println(slot.getFutureSlotTime()); + System.out.println(slot.getPastSlotTime()); + System.out.println(slot.getGameInterval()); + System.out.println(slot.getOpenMinute()); + System.out.println(slot.getStartTime()); + System.out.println(slot.getEndTime()); + System.out.println("----------------------"); + } + } + + @Test + @DisplayName("[Delete]/pingpong/admin/slot-management") + void delSlotSetting() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + SlotCreateRequestDto test = new SlotCreateRequestDto(4, 1, 20, 1, LocalDateTime.now().plusHours(13)); + System.out.println(test.getStartTime()); + String content = objectMapper.writeValueAsString(test); + + mockMvc.perform(post("/pingpong/admin/slot-management") + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isCreated()) + .andReturn().getResponse().getContentAsString(); + + String contentAsString = mockMvc.perform(delete("/pingpong/admin/slot-management") + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNoContent()) + .andReturn().getResponse().getContentAsString(); + + List slotList = adminSlotManagementRepository.findAllByOrderByCreatedAtDesc(); + for (SlotManagement slot : slotList) { + System.out.println(slot.getFutureSlotTime()); + System.out.println(slot.getPastSlotTime()); + System.out.println(slot.getGameInterval()); + System.out.println(slot.getOpenMinute()); + System.out.println(slot.getStartTime()); + System.out.println(slot.getEndTime()); + System.out.println("----------------------"); + } + } + +} diff --git a/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java b/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java index 213d54668..d4187b7dc 100644 --- a/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java @@ -1,28 +1,40 @@ package com.gg.server.admin.tournament.controller; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Random; + +import org.apache.http.HttpHeaders; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; import com.gg.server.admin.tournament.dto.TournamentAdminAddUserRequestDto; +import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; import com.gg.server.admin.tournament.dto.TournamentGameUpdateRequestDto; import com.gg.server.admin.tournament.service.TournamentAdminService; import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.pchange.data.PChangeRepository; import com.gg.server.domain.season.data.Season; -import com.gg.server.utils.MatchTestUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import com.gg.server.domain.team.dto.TeamReqDto; import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentUser; -import com.gg.server.domain.tournament.data.TournamentUserRepository; import com.gg.server.domain.tournament.data.TournamentGame; +import com.gg.server.domain.tournament.data.TournamentGameRepository; import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.team.dto.TeamReqDto; -import com.gg.server.domain.tournament.data.*; +import com.gg.server.domain.tournament.data.TournamentUser; +import com.gg.server.domain.tournament.data.TournamentUserRepository; import com.gg.server.domain.tournament.type.TournamentRound; import com.gg.server.domain.tournament.type.TournamentStatus; import com.gg.server.domain.tournament.type.TournamentType; @@ -31,22 +43,11 @@ import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.CustomRuntimeException; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.MatchTestUtils; import com.gg.server.utils.TestDataUtils; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Random; +import com.gg.server.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; -import org.apache.http.HttpHeaders; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.transaction.annotation.Transactional; @IntegrationTest @AutoConfigureMockMvc @@ -54,914 +55,945 @@ @Transactional class TournamentAdminControllerTest { - @Autowired - TestDataUtils testDataUtils; - - @Autowired - MockMvc mockMvc; - - @Autowired - ObjectMapper objectMapper; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - TournamentAdminService tournamentAdminService; - - @Autowired - TournamentRepository tournamentRepository; - - @Autowired - TournamentUserRepository tournamentUserRepository; - - @Autowired - TournamentGameRepository tournamentGameRepository; - - @Autowired - PChangeRepository pChangeRepository; - - @Autowired - private MatchTestUtils matchTestUtils; - - @Nested - @DisplayName("토너먼트_관리_수정_컨트롤러_테스트") - class TournamentAdminControllerUpdateTest { - @BeforeEach - void beforeEach() { - testDataUtils.createSlot(15); - } - @Test - @DisplayName("토너먼트_업데이트_성공") - void success() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - Tournament tournament = testDataUtils.createTournament( - LocalDateTime.now().plusDays(2).withHour(14).withMinute(0), - LocalDateTime.now().plusDays(2).withHour(16).withMinute(0), - TournamentStatus.BEFORE); - - TournamentAdminUpdateRequestDto updateDto = testDataUtils.createUpdateRequestDto ( - LocalDateTime.now().plusDays(3).withHour(14).withMinute(0), - LocalDateTime.now().plusDays(3).withHour(16).withMinute(0), - TournamentType.MASTER); - - String url = "/pingpong/admin/tournaments/" + tournament.getId(); - - String content = objectMapper.writeValueAsString(updateDto); - - // when - String contentAsString = mockMvc.perform(patch(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNoContent()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - - // then - Tournament result = tournamentRepository.findById(tournament.getId()).get(); - assertThat(result.getTitle()).isEqualTo(tournament.getTitle()); - assertThat(result.getContents()).isEqualTo(tournament.getContents()); - assertThat(result.getStartTime()).isEqualTo(updateDto.getStartTime()); - assertThat(result.getEndTime()).isEqualTo(updateDto.getEndTime()); - assertThat(result.getType()).isEqualTo(updateDto.getType()); - assertThat(result.getStatus()).isEqualTo(tournament.getStatus()); - } - - @Test - @DisplayName("토너먼트_없는_경우") - void tournamentNotFound() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - TournamentAdminUpdateRequestDto updateDto = testDataUtils.createUpdateRequestDto( - LocalDateTime.now().plusDays(2).withHour(14).withMinute(0), - LocalDateTime.now().plusDays(2).withHour(16).withMinute(0), - TournamentType.MASTER); - - String url = "/pingpong/admin/tournaments/" + 1111; - - String content = objectMapper.writeValueAsString(updateDto); - // when, then - String contentAsString = mockMvc.perform(patch(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNotFound()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - - @Test - @DisplayName("토너먼트_업데이트_기간_겹치는_경우") - void tournamentConflicted() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - Tournament tournamentAlreadyExist = testDataUtils.createTournament( - LocalDateTime.now().plusDays(3).withHour(14).withMinute(0), - LocalDateTime.now().plusDays(3).withHour(16).withMinute(0), - TournamentStatus.BEFORE); - - Tournament tournamentToChange = testDataUtils.createTournament( - LocalDateTime.now().plusDays(3).withHour(18).withMinute(0), - LocalDateTime.now().plusDays(3).withHour(20).withMinute(0), - TournamentStatus.BEFORE); - - // 겹치는 시간 조절 - TournamentAdminUpdateRequestDto updateDto = testDataUtils.createUpdateRequestDto( - LocalDateTime.now().plusDays(3).withHour(13).withMinute(0), - LocalDateTime.now().plusDays(3).withHour(15).withMinute(0), - TournamentType.MASTER); - - String url = "/pingpong/admin/tournaments/" + tournamentToChange.getId(); - - String content = objectMapper.writeValueAsString(updateDto); - - // when, then - String contentAsString = mockMvc.perform(patch(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isConflict()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - - @Test - @DisplayName("기간내_게임_존재") - void gameAlreadyExist() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - - GameInfoDto game = testDataUtils.createGame(testDataUtils.createNewUser("testUser"), - LocalDateTime.now().plusDays(3).withHour(14).withMinute(0), - LocalDateTime.now().plusDays(3).withHour(14).withMinute(15), - testDataUtils.createSeason(), Mode.NORMAL); - - Tournament tournament = testDataUtils.createTournament( - LocalDateTime.now().plusDays(2).withHour(14).withMinute(0), - LocalDateTime.now().plusDays(2).withHour(16).withMinute(0), - TournamentStatus.BEFORE); - - // 겹치는 시간 조절 - TournamentAdminUpdateRequestDto updateDto = testDataUtils.createUpdateRequestDto( - tournament.getStartTime().plusDays(1), - tournament.getEndTime().plusDays(1), - TournamentType.MASTER); - - String url = "/pingpong/admin/tournaments/" + tournament.getId(); - - String content = objectMapper.writeValueAsString(updateDto); - - // when, then - String contentAsString = mockMvc.perform(patch(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isConflict()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - - @Test - @DisplayName("이미_시작했거나_종료된_토너먼트_수정") - void canNotUpdate() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - Tournament liveTournament = testDataUtils.createTournament( - LocalDateTime.now().minusHours(1).withMinute(0), - LocalDateTime.now().plusHours(2).withMinute(0), - TournamentStatus.LIVE); - - Tournament endedTournament = testDataUtils.createTournament( - LocalDateTime.now().minusHours(3).withMinute(0), - LocalDateTime.now().minusHours(1).withMinute(0), - TournamentStatus.END); - - TournamentAdminUpdateRequestDto updateTournamentDto = testDataUtils.createUpdateRequestDto( - LocalDateTime.now().plusDays(2).plusHours(3).withMinute(0), - LocalDateTime.now().plusDays(2).plusHours(5).withMinute(0), - TournamentType.MASTER); - - String url = "/pingpong/admin/tournaments/" + liveTournament.getId(); - - String content = objectMapper.writeValueAsString(updateTournamentDto); - - // when live tournament test, then - String contentAsString = mockMvc.perform(patch(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isForbidden()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - - url = "/pingpong/admin/tournaments/" + endedTournament.getId(); - - // when ended tournament test, then - contentAsString = mockMvc.perform(patch(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isForbidden()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - - @Test - @DisplayName("토너먼트_잘못된_기간") - void wrongTournamentTime() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - Tournament tournamentToChange = testDataUtils.createTournament( - LocalDateTime.now().plusDays(2).withHour(14).withMinute(0), - LocalDateTime.now().plusDays(2).withHour(16).withMinute(0), - TournamentStatus.BEFORE); - - TournamentAdminUpdateRequestDto updateDto1 = testDataUtils.createUpdateRequestDto( - tournamentToChange.getStartTime(), - tournamentToChange.getStartTime(), - TournamentType.MASTER); - - TournamentAdminUpdateRequestDto updateDto2 = testDataUtils.createUpdateRequestDto( - tournamentToChange.getEndTime(), - tournamentToChange.getStartTime(), - TournamentType.MASTER); - - TournamentAdminUpdateRequestDto updateDto3 = testDataUtils.createUpdateRequestDto( - LocalDateTime.now().plusDays(2).withHour(14).withMinute(5), - LocalDateTime.now().plusDays(2).withHour(16).withMinute(5), - TournamentType.MASTER); - - String url = "/pingpong/admin/tournaments/" + tournamentToChange.getId(); - // when startTime == endTime, then - String content = objectMapper.writeValueAsString(updateDto1); - - String contentAsString = mockMvc.perform(patch(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isForbidden()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - - // when startTime > endTime test, then - content = objectMapper.writeValueAsString(updateDto2); - - contentAsString = mockMvc.perform(patch(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isForbidden()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - - // when startTime minute invalid test, then - content = objectMapper.writeValueAsString(updateDto3); - - contentAsString = mockMvc.perform(patch(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isForbidden()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - - @Test - @DisplayName("잘못된_dto") - void wrongDto() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - Tournament tournamentToChange = testDataUtils.createTournament( - LocalDateTime.now().plusDays(2).withHour(14).withMinute(0), - LocalDateTime.now().plusDays(2).withHour(16).withMinute(0), - TournamentStatus.BEFORE); - - TournamentAdminUpdateRequestDto updateDto1 = testDataUtils.createUpdateRequestDto( - tournamentToChange.getStartTime(), - tournamentToChange.getStartTime(), - null); - - String url = "/pingpong/admin/tournaments/" + tournamentToChange.getId(); - // when startTime == endTime, then - String content = objectMapper.writeValueAsString(updateDto1); - - String contentAsString = mockMvc.perform(patch(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - } - - @Nested - @DisplayName("토너먼트_관리_삭제_컨트롤러_테스트") - class TournamentAdminControllerDeleteTest { - @Test - @DisplayName("토너먼트_삭제_성공") - void success() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - Tournament tournament = testDataUtils.createTournament( - LocalDateTime.now().plusDays(2).plusHours(1), - LocalDateTime.now().plusDays(2).plusHours(3), - TournamentStatus.BEFORE); - - List tournamentGameList = testDataUtils.createTournamentGameList(tournament, 7); - - String url = "/pingpong/admin/tournaments/" + tournament.getId(); - - // when - String contentAsString = mockMvc.perform(delete(url) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNoContent()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - - // then - tournamentRepository.findById(tournament.getId()).ifPresent( - a-> {throw new CustomRuntimeException("삭제되지 않았습니다.", ErrorCode.BAD_REQUEST);}); - } - - @Test - @DisplayName("토너먼트_없는_경우") - void tournamentNotFound() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - String url = "/pingpong/admin/tournaments/" + 1111; - - // when, then - String contentAsString = mockMvc.perform(delete(url) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNotFound()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - - @Test - @DisplayName("이미_시작했거나_종료된_토너먼트_수정") - void canNotDelete() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - Tournament liveTournament = testDataUtils.createTournament( - LocalDateTime.now().minusHours(1), - LocalDateTime.now().plusHours(2), - TournamentStatus.LIVE); - - Tournament endedTournament = testDataUtils.createTournament( - LocalDateTime.now().minusHours(3), - LocalDateTime.now().minusHours(1), - TournamentStatus.END); - - String url = "/pingpong/admin/tournaments/" + liveTournament.getId(); - - // when live tournament test, then - String contentAsString = mockMvc.perform(delete(url) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isForbidden()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - - url = "/pingpong/admin/tournaments/" + endedTournament.getId(); - - // when ended tournament test, then - contentAsString = mockMvc.perform(delete(url) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isForbidden()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - } - - @Nested - @DisplayName("토너먼트_관리_생성_컨트롤러_테스트") - class TournamentAdminControllerCreateTest { - @BeforeEach - void beforeEach() { - testDataUtils.createSlot(15); - } - @Test - @DisplayName("토너먼트 생성 성공") - void success() throws Exception { - //given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - - TournamentAdminCreateRequestDto createDto = testDataUtils.createRequestDto( - LocalDateTime.now().plusDays(3).withHour(14).withMinute(0), - LocalDateTime.now().plusDays(3).withHour(16).withMinute(0), - TournamentType.ROOKIE); - - String url = "/pingpong/admin/tournaments"; - String content = objectMapper.writeValueAsString(createDto); - - //when, then - String contentAsString = mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON) - .content(content)) - .andExpect(status().isCreated()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - - @Test - @DisplayName("기간내_게임_존재") - void gameAlreadyExist() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - GameInfoDto game = testDataUtils.createGame(testDataUtils.createNewUser("testUser"), - LocalDateTime.now().plusDays(3).withHour(14).withMinute(0), - LocalDateTime.now().plusDays(3).withHour(14).withMinute(15), - testDataUtils.createSeason(), Mode.NORMAL); - - TournamentAdminCreateRequestDto createDto = testDataUtils.createRequestDto( - LocalDateTime.now().plusDays(3).withHour(14).withMinute(0), - LocalDateTime.now().plusDays(3).withHour(16).withMinute(0), - TournamentType.ROOKIE); - - String url = "/pingpong/admin/tournaments"; - String content = objectMapper.writeValueAsString(createDto); - - // when, then - String contentAsString = mockMvc.perform(post(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isConflict()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - - @Test - @DisplayName("잘못된 DTO - 길이 초과") - void invalidLength() throws Exception { - //given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - int leftLimit = 97; // letter 'a' - int rightLimit = 122; // letter 'z' - int targetStringLength = 3100; - Random random = new Random(); - String contents = random.ints(leftLimit, rightLimit + 1) - .limit(targetStringLength) - .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) - .toString(); - TournamentAdminCreateRequestDto createDto = new TournamentAdminCreateRequestDto( - "1st rookie tournament", - contents, - LocalDateTime.now().plusDays(3).withHour(14).withMinute(0), - LocalDateTime.now().plusDays(3).withHour(16).withMinute(0), - TournamentType.ROOKIE); - - String url = "/pingpong/admin/tournaments"; - String content = objectMapper.writeValueAsString(createDto); - - //when, then - String contentAsString = mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON) - .content(content)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - } - } - - @Nested - @DisplayName("관리자_토너먼트_유저_추가_컨트롤러_테스트") - class TournamentAdminControllerAddUserTest { - @Test - @DisplayName("유저_추가_성공") - void success() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - Tournament tournament1 = testDataUtils.createTournament( - LocalDateTime.now().plusDays(2).plusHours(1), - LocalDateTime.now().plusDays(2).plusHours(3), - TournamentStatus.BEFORE); - Tournament tournament2 = testDataUtils.createTournament( - LocalDateTime.now().plusDays(3).plusHours(1), - LocalDateTime.now().plusDays(3).plusHours(3), - TournamentStatus.BEFORE); - User user = testDataUtils.createNewUser("testUser"); - testDataUtils.createTournamentUser(user, tournament2, true); - - TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto(user.getIntraId()); - - String url = "/pingpong/admin/tournaments/" + tournament1.getId() + "/users"; - String content = objectMapper.writeValueAsString(requestDto); - - // when - String contentAsString = mockMvc.perform(post(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isCreated()) - .andReturn().getResponse().getContentAsString(); - - // then - System.out.println(contentAsString); - tournament1.getTournamentUsers().stream().filter(tu->tu.getUser().equals(user)).findAny() - .orElseThrow(()->new CustomRuntimeException("토너먼트 유저 리스트에 추가 안됨", ErrorCode.BAD_REQUEST)); - tournamentUserRepository.findAllByTournamentId(tournament1.getId()) - .stream().filter(tu-> tu.getUser().getIntraId().equals(requestDto.getIntraId())) - .findAny().orElseThrow(()->new CustomRuntimeException("토너먼트 유저 테이블에 추가 안됨", ErrorCode.BAD_REQUEST)); - } - - @Test - @DisplayName("토너먼트_없는_경우") - void tournamentNotFound() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - User user = testDataUtils.createNewUser("test"); - - TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto(user.getIntraId()); - - String url = "/pingpong/admin/tournaments/" + 9999 + "/users"; - - String content = objectMapper.writeValueAsString(requestDto); - - // when, then - String contentAsString = mockMvc.perform(post(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNotFound()) - .andReturn().getResponse().getContentAsString(); - - } - - @Test - @DisplayName("이미_시작했거나_종료된_토너먼트_수정") - void canNotUpdate() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - Tournament tournament = testDataUtils.createTournament( - LocalDateTime.now().plusDays(0).plusHours(-1), - LocalDateTime.now().plusDays(0).plusHours(1), - TournamentStatus.LIVE); - User user = testDataUtils.createNewUser("test"); - - TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto(user.getIntraId()); - - String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/users"; - - String content = objectMapper.writeValueAsString(requestDto); - - // when, then - String contentAsString = mockMvc.perform(post(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isForbidden()) - .andReturn().getResponse().getContentAsString(); - } - - @Test - @DisplayName("찾을_수_없는_유저") - void userNotFound() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - Tournament tournament = testDataUtils.createTournament( - LocalDateTime.now().plusDays(2).plusHours(1), - LocalDateTime.now().plusDays(2).plusHours(3), - TournamentStatus.BEFORE); - - TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto("nobody"); - - String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/users"; - - String content = objectMapper.writeValueAsString(requestDto); - - // when, then - String contentAsString = mockMvc.perform(post(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNotFound()) - .andReturn().getResponse().getContentAsString(); - } - - @Test - @DisplayName("해당_토너먼트_참가자인_경우") - void alreadyTournamentParticipant() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - Tournament tournament = testDataUtils.createTournament( - LocalDateTime.now().plusDays(2).plusHours(1), - LocalDateTime.now().plusDays(2).plusHours(3), - TournamentStatus.BEFORE); - - User user = testDataUtils.createNewUser("test"); - TournamentUser participant = testDataUtils.createTournamentUser(user, tournament, false); - TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto(user.getIntraId()); - - String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/users"; - String content = objectMapper.writeValueAsString(requestDto); - - // when, then - String contentAsString = mockMvc.perform(post(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isConflict()) - .andReturn().getResponse().getContentAsString(); - } - - @Test - @DisplayName("토너먼트_대기자_신청") - void waitUserTest() throws Exception { - // given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - tokenProvider.getUserIdFromAccessToken(accessToken); - - Tournament tournament = testDataUtils.createTournament( - LocalDateTime.now().plusDays(2).plusHours(1), - LocalDateTime.now().plusDays(2).plusHours(3), - TournamentStatus.BEFORE); - - User user = testDataUtils.createNewUser("testUser0"); - for (int i=1; i<=8; i++) { - testDataUtils.createTournamentUser(testDataUtils.createNewUser("testUser" + i), tournament, true); - } - TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto(user.getIntraId()); - - String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/users"; - String content = objectMapper.writeValueAsString(requestDto); - - // when - String contentAsString = mockMvc.perform(post(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isCreated()) - .andReturn().getResponse().getContentAsString(); - - // then - tournamentUserRepository.findAllByTournamentId(tournament.getId()).stream() - .filter(tu->tu.getUser().getIntraId().equals(user.getIntraId())).findAny() - .filter(tu->!tu.getIsJoined()).orElseThrow(()->new CustomRuntimeException("waitlist 제대로 등록 안됨", ErrorCode.BAD_REQUEST)); - } - } - - @Nested - @DisplayName("관리자_토너먼트_유저_삭제_컨트롤러_테스트") - class TournamentAdminControllerDeleteUserTest { - @Test - @DisplayName("유저_삭제_성공") - void success() throws Exception { - // given - int maxTournamentUser = 8; - String accessToken = testDataUtils.getAdminLoginAccessToken(); - - Tournament tournament = testDataUtils.createTournament( - LocalDateTime.now().plusDays(2).plusHours(1), - LocalDateTime.now().plusDays(2).plusHours(3), - TournamentStatus.BEFORE); - - for (int i=0; i tournamentUserList = tournament.getTournamentUsers(); - tournamentUserList.stream().filter(tu->tu.getUser().equals(user)).findAny() - .ifPresent(a->{throw new CustomRuntimeException("토너먼트 유저 리스트에 삭제 안됨", ErrorCode.BAD_REQUEST);}); - tournamentUserRepository.findByTournamentIdAndUserId(tournament.getId(), user.getId()) - .ifPresent(a->{throw new CustomRuntimeException("토너먼트 유저 레포에서 삭제 안됨", ErrorCode.BAD_REQUEST);}); - for (int i=0; i 참여자 전환 제대로 안됨", ErrorCode.BAD_REQUEST); - } - } - for (int i=maxTournamentUser; i allTournamentGames; - Season season; - @BeforeEach - void setUp() { - // 토너먼트 생성하고 8강 & 4강은 게임 점수 입력하고 종료된 상태이고 결승전 매칭된 상태로 초기화 - season = testDataUtils.createSeason(); - testDataUtils.createSlotManagement(15); - tournament = testDataUtils.createTournamentWithUser(Tournament.ALLOWED_JOINED_NUMBER, 4, "test"); - allTournamentGames = testDataUtils.createTournamentGameList(tournament, 7); - tournament.updateStatus(TournamentStatus.LIVE); - List quarterGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.QUARTER_FINAL_1); - matchTestUtils.updateTournamentGamesResult(quarterGames, List.of(2, 0)); - List semiGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.SEMI_FINAL_1); - matchTestUtils.updateTournamentGamesResult(semiGames, List.of(2, 0)); - - accessToken = testDataUtils.getAdminLoginAccessToken(); - } - - @Test - @DisplayName("토너먼트_게임_수정_성공") - void updateTournamentGameSuccess() throws Exception { - // given - String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/games"; - - int myTeamScore = 2; - int otherTeamScore = 1; - TournamentGame tournamentGame = allTournamentGames.stream().filter(tg -> tg.getTournamentRound() == TournamentRound.SEMI_FINAL_1).findAny().orElseThrow(); - TournamentGame nextTournamentGame = allTournamentGames.stream().filter(tg -> tg.getTournamentRound() == TournamentRound.THE_FINAL).findAny().orElseThrow(); - User user1 = tournamentGame.getGame().getTeams().get(0).getTeamUsers().get(0).getUser(); - User user2 = tournamentGame.getGame().getTeams().get(1).getTeamUsers().get(0).getUser(); - testDataUtils.createUserRank(user1, "" ,season); - testDataUtils.createUserRank(user2, "" ,season); - - TournamentGameUpdateRequestDto requestDto = new TournamentGameUpdateRequestDto(tournamentGame.getId(), nextTournamentGame.getId(), - new TeamReqDto(tournamentGame.getGame().getTeams().get(0).getId(), myTeamScore), - new TeamReqDto(tournamentGame.getGame().getTeams().get(1).getId(), otherTeamScore)); - - String content = objectMapper.writeValueAsString(requestDto); - // when - mockMvc.perform(patch(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .content(content) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - TournamentGame resTournamentGame = tournamentGameRepository.findById(tournamentGame.getId()).orElseThrow(); - assertThat(resTournamentGame.getGame().getTeams().get(0).getScore()).isEqualTo(myTeamScore); - assertThat(resTournamentGame.getGame().getTeams().get(1).getScore()).isEqualTo(otherTeamScore); - assertThat(pChangeRepository.findByUserIdAndGameId(user1.getId(), tournamentGame.getGame().getId())).isNotEmpty(); - assertThat(pChangeRepository.findByUserIdAndGameId(user2.getId(), tournamentGame.getGame().getId())).isNotEmpty(); - } - @Test - @DisplayName("토너먼트_게임_수정_불가능") - void updateTournamentGameEnable() throws Exception { - // given - String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/games"; - int myTeamScore = 2; - int otherTeamScore = 1; - TournamentGame tournamentGame = allTournamentGames.stream().filter(tg -> tg.getTournamentRound() == TournamentRound.QUARTER_FINAL_1).findAny().orElseThrow(); - TournamentGame nextTournamentGame = allTournamentGames.stream().filter(tg -> tg.getTournamentRound() == TournamentRound.SEMI_FINAL_1).findAny().orElseThrow(); - TournamentGameUpdateRequestDto requestDto = new TournamentGameUpdateRequestDto(tournamentGame.getId(), nextTournamentGame.getId(), - new TeamReqDto(tournamentGame.getGame().getTeams().get(0).getId(), myTeamScore), - new TeamReqDto(tournamentGame.getGame().getTeams().get(1).getId(), otherTeamScore)); - - String content = objectMapper.writeValueAsString(requestDto); - // when - mockMvc.perform(patch(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .content(content) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isForbidden()) - .andReturn().getResponse().getContentAsString(); - } - - } -} \ No newline at end of file + @Autowired + TestDataUtils testDataUtils; + + @Autowired + MockMvc mockMvc; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + AuthTokenProvider tokenProvider; + + @Autowired + TournamentAdminService tournamentAdminService; + + @Autowired + TournamentRepository tournamentRepository; + + @Autowired + TournamentUserRepository tournamentUserRepository; + + @Autowired + TournamentGameRepository tournamentGameRepository; + + @Autowired + PChangeRepository pChangeRepository; + + @Autowired + private MatchTestUtils matchTestUtils; + + @Nested + @DisplayName("토너먼트_관리_수정_컨트롤러_테스트") + class TournamentAdminControllerUpdateTest { + @BeforeEach + void beforeEach() { + testDataUtils.createSlot(15); + } + + @Test + @DisplayName("토너먼트_업데이트_성공") + void success() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + Tournament tournament = testDataUtils.createTournament( + LocalDateTime.now().plusDays(2).withHour(14).withMinute(0), + LocalDateTime.now().plusDays(2).withHour(16).withMinute(0), + TournamentStatus.BEFORE); + + TournamentAdminUpdateRequestDto updateDto = testDataUtils.createUpdateRequestDto( + LocalDateTime.now().plusDays(3).withHour(14).withMinute(0), + LocalDateTime.now().plusDays(3).withHour(16).withMinute(0), + TournamentType.MASTER); + + String url = "/pingpong/admin/tournaments/" + tournament.getId(); + + String content = objectMapper.writeValueAsString(updateDto); + + // when + String contentAsString = mockMvc.perform(patch(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNoContent()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + + // then + Tournament result = tournamentRepository.findById(tournament.getId()).get(); + assertThat(result.getTitle()).isEqualTo(tournament.getTitle()); + assertThat(result.getContents()).isEqualTo(tournament.getContents()); + assertThat(result.getStartTime()).isEqualTo(updateDto.getStartTime()); + assertThat(result.getEndTime()).isEqualTo(updateDto.getEndTime()); + assertThat(result.getType()).isEqualTo(updateDto.getType()); + assertThat(result.getStatus()).isEqualTo(tournament.getStatus()); + } + + @Test + @DisplayName("토너먼트_없는_경우") + void tournamentNotFound() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + TournamentAdminUpdateRequestDto updateDto = testDataUtils.createUpdateRequestDto( + LocalDateTime.now().plusDays(2).withHour(14).withMinute(0), + LocalDateTime.now().plusDays(2).withHour(16).withMinute(0), + TournamentType.MASTER); + + String url = "/pingpong/admin/tournaments/" + 1111; + + String content = objectMapper.writeValueAsString(updateDto); + // when, then + String contentAsString = mockMvc.perform(patch(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNotFound()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @DisplayName("토너먼트_업데이트_기간_겹치는_경우") + void tournamentConflicted() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + Tournament tournamentAlreadyExist = testDataUtils.createTournament( + LocalDateTime.now().plusDays(3).withHour(14).withMinute(0), + LocalDateTime.now().plusDays(3).withHour(16).withMinute(0), + TournamentStatus.BEFORE); + + Tournament tournamentToChange = testDataUtils.createTournament( + LocalDateTime.now().plusDays(3).withHour(18).withMinute(0), + LocalDateTime.now().plusDays(3).withHour(20).withMinute(0), + TournamentStatus.BEFORE); + + // 겹치는 시간 조절 + TournamentAdminUpdateRequestDto updateDto = testDataUtils.createUpdateRequestDto( + LocalDateTime.now().plusDays(3).withHour(13).withMinute(0), + LocalDateTime.now().plusDays(3).withHour(15).withMinute(0), + TournamentType.MASTER); + + String url = "/pingpong/admin/tournaments/" + tournamentToChange.getId(); + + String content = objectMapper.writeValueAsString(updateDto); + + // when, then + String contentAsString = mockMvc.perform(patch(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isConflict()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @DisplayName("기간내_게임_존재") + void gameAlreadyExist() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + + GameInfoDto game = testDataUtils.createGame(testDataUtils.createNewUser("testUser"), + LocalDateTime.now().plusDays(3).withHour(14).withMinute(0), + LocalDateTime.now().plusDays(3).withHour(14).withMinute(15), + testDataUtils.createSeason(), Mode.NORMAL); + + Tournament tournament = testDataUtils.createTournament( + LocalDateTime.now().plusDays(2).withHour(14).withMinute(0), + LocalDateTime.now().plusDays(2).withHour(16).withMinute(0), + TournamentStatus.BEFORE); + + // 겹치는 시간 조절 + TournamentAdminUpdateRequestDto updateDto = testDataUtils.createUpdateRequestDto( + tournament.getStartTime().plusDays(1), + tournament.getEndTime().plusDays(1), + TournamentType.MASTER); + + String url = "/pingpong/admin/tournaments/" + tournament.getId(); + + String content = objectMapper.writeValueAsString(updateDto); + + // when, then + String contentAsString = mockMvc.perform(patch(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isConflict()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @DisplayName("이미_시작했거나_종료된_토너먼트_수정") + void canNotUpdate() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + Tournament liveTournament = testDataUtils.createTournament( + LocalDateTime.now().minusHours(1).withMinute(0), + LocalDateTime.now().plusHours(2).withMinute(0), + TournamentStatus.LIVE); + + Tournament endedTournament = testDataUtils.createTournament( + LocalDateTime.now().minusHours(3).withMinute(0), + LocalDateTime.now().minusHours(1).withMinute(0), + TournamentStatus.END); + + TournamentAdminUpdateRequestDto updateTournamentDto = testDataUtils.createUpdateRequestDto( + LocalDateTime.now().plusDays(2).plusHours(3).withMinute(0), + LocalDateTime.now().plusDays(2).plusHours(5).withMinute(0), + TournamentType.MASTER); + + String url = "/pingpong/admin/tournaments/" + liveTournament.getId(); + + String content = objectMapper.writeValueAsString(updateTournamentDto); + + // when live tournament test, then + String contentAsString = mockMvc.perform(patch(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isForbidden()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + + url = "/pingpong/admin/tournaments/" + endedTournament.getId(); + + // when ended tournament test, then + contentAsString = mockMvc.perform(patch(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isForbidden()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @DisplayName("토너먼트_잘못된_기간") + void wrongTournamentTime() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + Tournament tournamentToChange = testDataUtils.createTournament( + LocalDateTime.now().plusDays(2).withHour(14).withMinute(0), + LocalDateTime.now().plusDays(2).withHour(16).withMinute(0), + TournamentStatus.BEFORE); + + TournamentAdminUpdateRequestDto updateDto1 = testDataUtils.createUpdateRequestDto( + tournamentToChange.getStartTime(), + tournamentToChange.getStartTime(), + TournamentType.MASTER); + + TournamentAdminUpdateRequestDto updateDto2 = testDataUtils.createUpdateRequestDto( + tournamentToChange.getEndTime(), + tournamentToChange.getStartTime(), + TournamentType.MASTER); + + TournamentAdminUpdateRequestDto updateDto3 = testDataUtils.createUpdateRequestDto( + LocalDateTime.now().plusDays(2).withHour(14).withMinute(5), + LocalDateTime.now().plusDays(2).withHour(16).withMinute(5), + TournamentType.MASTER); + + String url = "/pingpong/admin/tournaments/" + tournamentToChange.getId(); + // when startTime == endTime, then + String content = objectMapper.writeValueAsString(updateDto1); + + String contentAsString = mockMvc.perform(patch(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isForbidden()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + + // when startTime > endTime test, then + content = objectMapper.writeValueAsString(updateDto2); + + contentAsString = mockMvc.perform(patch(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isForbidden()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + + // when startTime minute invalid test, then + content = objectMapper.writeValueAsString(updateDto3); + + contentAsString = mockMvc.perform(patch(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isForbidden()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @DisplayName("잘못된_dto") + void wrongDto() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + Tournament tournamentToChange = testDataUtils.createTournament( + LocalDateTime.now().plusDays(2).withHour(14).withMinute(0), + LocalDateTime.now().plusDays(2).withHour(16).withMinute(0), + TournamentStatus.BEFORE); + + TournamentAdminUpdateRequestDto updateDto1 = testDataUtils.createUpdateRequestDto( + tournamentToChange.getStartTime(), + tournamentToChange.getStartTime(), + null); + + String url = "/pingpong/admin/tournaments/" + tournamentToChange.getId(); + // when startTime == endTime, then + String content = objectMapper.writeValueAsString(updateDto1); + + String contentAsString = mockMvc.perform(patch(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + } + + @Nested + @DisplayName("토너먼트_관리_삭제_컨트롤러_테스트") + class TournamentAdminControllerDeleteTest { + @Test + @DisplayName("토너먼트_삭제_성공") + void success() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + Tournament tournament = testDataUtils.createTournament( + LocalDateTime.now().plusDays(2).plusHours(1), + LocalDateTime.now().plusDays(2).plusHours(3), + TournamentStatus.BEFORE); + + List tournamentGameList = testDataUtils.createTournamentGameList(tournament, 7); + + String url = "/pingpong/admin/tournaments/" + tournament.getId(); + + // when + String contentAsString = mockMvc.perform(delete(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNoContent()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + + // then + tournamentRepository.findById(tournament.getId()).ifPresent( + a -> { + throw new CustomRuntimeException("삭제되지 않았습니다.", ErrorCode.BAD_REQUEST); + }); + } + + @Test + @DisplayName("토너먼트_없는_경우") + void tournamentNotFound() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + String url = "/pingpong/admin/tournaments/" + 1111; + + // when, then + String contentAsString = mockMvc.perform(delete(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNotFound()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @DisplayName("이미_시작했거나_종료된_토너먼트_수정") + void canNotDelete() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + Tournament liveTournament = testDataUtils.createTournament( + LocalDateTime.now().minusHours(1), + LocalDateTime.now().plusHours(2), + TournamentStatus.LIVE); + + Tournament endedTournament = testDataUtils.createTournament( + LocalDateTime.now().minusHours(3), + LocalDateTime.now().minusHours(1), + TournamentStatus.END); + + String url = "/pingpong/admin/tournaments/" + liveTournament.getId(); + + // when live tournament test, then + String contentAsString = mockMvc.perform(delete(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isForbidden()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + + url = "/pingpong/admin/tournaments/" + endedTournament.getId(); + + // when ended tournament test, then + contentAsString = mockMvc.perform(delete(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isForbidden()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + } + + @Nested + @DisplayName("토너먼트_관리_생성_컨트롤러_테스트") + class TournamentAdminControllerCreateTest { + @BeforeEach + void beforeEach() { + testDataUtils.createSlot(15); + } + + @Test + @DisplayName("토너먼트 생성 성공") + void success() throws Exception { + //given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + + TournamentAdminCreateRequestDto createDto = testDataUtils.createRequestDto( + LocalDateTime.now().plusDays(3).withHour(14).withMinute(0), + LocalDateTime.now().plusDays(3).withHour(16).withMinute(0), + TournamentType.ROOKIE); + + String url = "/pingpong/admin/tournaments"; + String content = objectMapper.writeValueAsString(createDto); + + //when, then + String contentAsString = mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON) + .content(content)) + .andExpect(status().isCreated()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @DisplayName("기간내_게임_존재") + void gameAlreadyExist() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + GameInfoDto game = testDataUtils.createGame(testDataUtils.createNewUser("testUser"), + LocalDateTime.now().plusDays(3).withHour(14).withMinute(0), + LocalDateTime.now().plusDays(3).withHour(14).withMinute(15), + testDataUtils.createSeason(), Mode.NORMAL); + + TournamentAdminCreateRequestDto createDto = testDataUtils.createRequestDto( + LocalDateTime.now().plusDays(3).withHour(14).withMinute(0), + LocalDateTime.now().plusDays(3).withHour(16).withMinute(0), + TournamentType.ROOKIE); + + String url = "/pingpong/admin/tournaments"; + String content = objectMapper.writeValueAsString(createDto); + + // when, then + String contentAsString = mockMvc.perform(post(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isConflict()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @DisplayName("잘못된 DTO - 길이 초과") + void invalidLength() throws Exception { + //given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + int leftLimit = 97; // letter 'a' + int rightLimit = 122; // letter 'z' + int targetStringLength = 3100; + Random random = new Random(); + String contents = random.ints(leftLimit, rightLimit + 1) + .limit(targetStringLength) + .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) + .toString(); + TournamentAdminCreateRequestDto createDto = new TournamentAdminCreateRequestDto( + "1st rookie tournament", + contents, + LocalDateTime.now().plusDays(3).withHour(14).withMinute(0), + LocalDateTime.now().plusDays(3).withHour(16).withMinute(0), + TournamentType.ROOKIE); + + String url = "/pingpong/admin/tournaments"; + String content = objectMapper.writeValueAsString(createDto); + + //when, then + String contentAsString = mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON) + .content(content)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + } + } + + @Nested + @DisplayName("관리자_토너먼트_유저_추가_컨트롤러_테스트") + class TournamentAdminControllerAddUserTest { + @Test + @DisplayName("유저_추가_성공") + void success() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + Tournament tournament1 = testDataUtils.createTournament( + LocalDateTime.now().plusDays(2).plusHours(1), + LocalDateTime.now().plusDays(2).plusHours(3), + TournamentStatus.BEFORE); + Tournament tournament2 = testDataUtils.createTournament( + LocalDateTime.now().plusDays(3).plusHours(1), + LocalDateTime.now().plusDays(3).plusHours(3), + TournamentStatus.BEFORE); + User user = testDataUtils.createNewUser("testUser"); + testDataUtils.createTournamentUser(user, tournament2, true); + + TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto(user.getIntraId()); + + String url = "/pingpong/admin/tournaments/" + tournament1.getId() + "/users"; + String content = objectMapper.writeValueAsString(requestDto); + + // when + String contentAsString = mockMvc.perform(post(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isCreated()) + .andReturn().getResponse().getContentAsString(); + + // then + System.out.println(contentAsString); + tournament1.getTournamentUsers().stream().filter(tu -> tu.getUser().equals(user)).findAny() + .orElseThrow(() -> new CustomRuntimeException("토너먼트 유저 리스트에 추가 안됨", ErrorCode.BAD_REQUEST)); + tournamentUserRepository.findAllByTournamentId(tournament1.getId()) + .stream().filter(tu -> tu.getUser().getIntraId().equals(requestDto.getIntraId())) + .findAny().orElseThrow(() -> new CustomRuntimeException("토너먼트 유저 테이블에 추가 안됨", ErrorCode.BAD_REQUEST)); + } + + @Test + @DisplayName("토너먼트_없는_경우") + void tournamentNotFound() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + User user = testDataUtils.createNewUser("test"); + + TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto(user.getIntraId()); + + String url = "/pingpong/admin/tournaments/" + 9999 + "/users"; + + String content = objectMapper.writeValueAsString(requestDto); + + // when, then + String contentAsString = mockMvc.perform(post(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNotFound()) + .andReturn().getResponse().getContentAsString(); + + } + + @Test + @DisplayName("이미_시작했거나_종료된_토너먼트_수정") + void canNotUpdate() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + Tournament tournament = testDataUtils.createTournament( + LocalDateTime.now().plusDays(0).plusHours(-1), + LocalDateTime.now().plusDays(0).plusHours(1), + TournamentStatus.LIVE); + User user = testDataUtils.createNewUser("test"); + + TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto(user.getIntraId()); + + String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/users"; + + String content = objectMapper.writeValueAsString(requestDto); + + // when, then + String contentAsString = mockMvc.perform(post(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isForbidden()) + .andReturn().getResponse().getContentAsString(); + } + + @Test + @DisplayName("찾을_수_없는_유저") + void userNotFound() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + Tournament tournament = testDataUtils.createTournament( + LocalDateTime.now().plusDays(2).plusHours(1), + LocalDateTime.now().plusDays(2).plusHours(3), + TournamentStatus.BEFORE); + + TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto("nobody"); + + String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/users"; + + String content = objectMapper.writeValueAsString(requestDto); + + // when, then + String contentAsString = mockMvc.perform(post(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNotFound()) + .andReturn().getResponse().getContentAsString(); + } + + @Test + @DisplayName("해당_토너먼트_참가자인_경우") + void alreadyTournamentParticipant() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + Tournament tournament = testDataUtils.createTournament( + LocalDateTime.now().plusDays(2).plusHours(1), + LocalDateTime.now().plusDays(2).plusHours(3), + TournamentStatus.BEFORE); + + User user = testDataUtils.createNewUser("test"); + TournamentUser participant = testDataUtils.createTournamentUser(user, tournament, false); + TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto(user.getIntraId()); + + String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/users"; + String content = objectMapper.writeValueAsString(requestDto); + + // when, then + String contentAsString = mockMvc.perform(post(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isConflict()) + .andReturn().getResponse().getContentAsString(); + } + + @Test + @DisplayName("토너먼트_대기자_신청") + void waitUserTest() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + tokenProvider.getUserIdFromAccessToken(accessToken); + + Tournament tournament = testDataUtils.createTournament( + LocalDateTime.now().plusDays(2).plusHours(1), + LocalDateTime.now().plusDays(2).plusHours(3), + TournamentStatus.BEFORE); + + User user = testDataUtils.createNewUser("testUser0"); + for (int i = 1; i <= 8; i++) { + testDataUtils.createTournamentUser(testDataUtils.createNewUser("testUser" + i), tournament, true); + } + TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto(user.getIntraId()); + + String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/users"; + String content = objectMapper.writeValueAsString(requestDto); + + // when + String contentAsString = mockMvc.perform(post(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isCreated()) + .andReturn().getResponse().getContentAsString(); + + // then + tournamentUserRepository.findAllByTournamentId(tournament.getId()) + .stream() + .filter(tu -> tu.getUser().getIntraId().equals(user.getIntraId())) + .findAny() + .filter(tu -> !tu.getIsJoined()) + .orElseThrow(() -> new CustomRuntimeException("waitlist 제대로 등록 안됨", ErrorCode.BAD_REQUEST)); + } + } + + @Nested + @DisplayName("관리자_토너먼트_유저_삭제_컨트롤러_테스트") + class TournamentAdminControllerDeleteUserTest { + @Test + @DisplayName("유저_삭제_성공") + void success() throws Exception { + // given + int maxTournamentUser = 8; + String accessToken = testDataUtils.getAdminLoginAccessToken(); + + Tournament tournament = testDataUtils.createTournament( + LocalDateTime.now().plusDays(2).plusHours(1), + LocalDateTime.now().plusDays(2).plusHours(3), + TournamentStatus.BEFORE); + + for (int i = 0; i < maxTournamentUser; i++) { + TournamentUser tournamentUser = testDataUtils.createTournamentUser( + testDataUtils.createNewUser("testUser" + i), tournament, true); + } + for (int i = maxTournamentUser; i < maxTournamentUser + 4; i++) { + TournamentUser tournamentUser = testDataUtils.createTournamentUser( + testDataUtils.createNewUser("testUser" + i), tournament, false); + } + + User user = tournament.getTournamentUsers().get(6).getUser(); + + String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/users/" + user.getId(); + // when + String contentAsString = mockMvc.perform(delete(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNoContent()) + .andReturn().getResponse().getContentAsString(); + + // then + System.out.println(contentAsString); + List tournamentUserList = tournament.getTournamentUsers(); + tournamentUserList.stream().filter(tu -> tu.getUser().equals(user)).findAny() + .ifPresent(a -> { + throw new CustomRuntimeException("토너먼트 유저 리스트에 삭제 안됨", ErrorCode.BAD_REQUEST); + }); + tournamentUserRepository.findByTournamentIdAndUserId(tournament.getId(), user.getId()) + .ifPresent(a -> { + throw new CustomRuntimeException("토너먼트 유저 레포에서 삭제 안됨", ErrorCode.BAD_REQUEST); + }); + for (int i = 0; i < maxTournamentUser; i++) { + if (!tournamentUserList.get(i).getIsJoined()) { + throw new CustomRuntimeException("대기자 => 참여자 전환 제대로 안됨", ErrorCode.BAD_REQUEST); + } + } + for (int i = maxTournamentUser; i < tournamentUserList.size(); i++) { + if (tournamentUserList.get(i).getIsJoined()) { + throw new CustomRuntimeException("정해진 참가자 수보다 참가자가 많음", ErrorCode.BAD_REQUEST); + } + } + } + + @Test + @DisplayName("토너먼트_없는_경우") + void tournamentNotFound() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + + User user = testDataUtils.createNewUser("testUser"); + + TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto(user.getIntraId()); + + String url = "/pingpong/admin/tournaments/" + 1234 + "/users/" + user.getId(); + + String content = objectMapper.writeValueAsString(requestDto); + + // when, then + String contentAsString = mockMvc.perform(delete(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNotFound()) + .andReturn().getResponse().getContentAsString(); + + } + + @Test + @DisplayName("이미_시작했거나_종료된_토너먼트_수정") + void canNotUpdate() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + + Tournament tournament = testDataUtils.createTournament( + LocalDateTime.now().plusDays(0).plusHours(-1), + LocalDateTime.now().plusDays(0).plusHours(1), + TournamentStatus.LIVE); + User user = testDataUtils.createNewUser("testUser"); + + TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto(user.getIntraId()); + + String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/users/" + user.getId(); + + String content = objectMapper.writeValueAsString(requestDto); + + // when, then + String contentAsString = mockMvc.perform(delete(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isForbidden()) + .andReturn().getResponse().getContentAsString(); + } + + @Test + @DisplayName("찾을_수_없는_유저") + void userNotFound() throws Exception { + // given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + + Tournament tournament = testDataUtils.createTournament( + LocalDateTime.now().plusDays(2).plusHours(1), + LocalDateTime.now().plusDays(2).plusHours(3), + TournamentStatus.BEFORE); + + TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto("nobody"); + + String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/users/" + "4321"; + + String content = objectMapper.writeValueAsString(requestDto); + + // when, then + String contentAsString = mockMvc.perform(delete(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNotFound()) + .andReturn().getResponse().getContentAsString(); + } + } + + @Nested + @DisplayName("[Patch] /pingpong/admin/tournaments/{tournamentId}/games") + class AdminUpdateTournamentGameTest { + private String accessToken; + private Tournament tournament; + private List allTournamentGames; + Season season; + + @BeforeEach + void setUp() { + // 토너먼트 생성하고 8강 & 4강은 게임 점수 입력하고 종료된 상태이고 결승전 매칭된 상태로 초기화 + season = testDataUtils.createSeason(); + testDataUtils.createSlotManagement(15); + tournament = testDataUtils.createTournamentWithUser(Tournament.ALLOWED_JOINED_NUMBER, 4, "test"); + allTournamentGames = testDataUtils.createTournamentGameList(tournament, 7); + tournament.updateStatus(TournamentStatus.LIVE); + List quarterGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.QUARTER_FINAL_1); + matchTestUtils.updateTournamentGamesResult(quarterGames, List.of(2, 0)); + List semiGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.SEMI_FINAL_1); + matchTestUtils.updateTournamentGamesResult(semiGames, List.of(2, 0)); + + accessToken = testDataUtils.getAdminLoginAccessToken(); + } + + @Test + @DisplayName("토너먼트_게임_수정_성공") + void updateTournamentGameSuccess() throws Exception { + // given + String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/games"; + + int myTeamScore = 2; + int otherTeamScore = 1; + TournamentGame tournamentGame = allTournamentGames.stream() + .filter(tg -> tg.getTournamentRound() == TournamentRound.SEMI_FINAL_1) + .findAny() + .orElseThrow(); + TournamentGame nextTournamentGame = allTournamentGames.stream() + .filter(tg -> tg.getTournamentRound() == TournamentRound.THE_FINAL) + .findAny() + .orElseThrow(); + User user1 = tournamentGame.getGame().getTeams().get(0).getTeamUsers().get(0).getUser(); + User user2 = tournamentGame.getGame().getTeams().get(1).getTeamUsers().get(0).getUser(); + testDataUtils.createUserRank(user1, "", season); + testDataUtils.createUserRank(user2, "", season); + + TournamentGameUpdateRequestDto requestDto = new TournamentGameUpdateRequestDto(tournamentGame.getId(), + nextTournamentGame.getId(), + new TeamReqDto(tournamentGame.getGame().getTeams().get(0).getId(), myTeamScore), + new TeamReqDto(tournamentGame.getGame().getTeams().get(1).getId(), otherTeamScore)); + + String content = objectMapper.writeValueAsString(requestDto); + // when + mockMvc.perform(patch(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .content(content) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + TournamentGame resTournamentGame = tournamentGameRepository.findById(tournamentGame.getId()).orElseThrow(); + assertThat(resTournamentGame.getGame().getTeams().get(0).getScore()).isEqualTo(myTeamScore); + assertThat(resTournamentGame.getGame().getTeams().get(1).getScore()).isEqualTo(otherTeamScore); + assertThat( + pChangeRepository.findByUserIdAndGameId(user1.getId(), tournamentGame.getGame().getId())).isNotEmpty(); + assertThat( + pChangeRepository.findByUserIdAndGameId(user2.getId(), tournamentGame.getGame().getId())).isNotEmpty(); + } + + @Test + @DisplayName("토너먼트_게임_수정_불가능") + void updateTournamentGameEnable() throws Exception { + // given + String url = "/pingpong/admin/tournaments/" + tournament.getId() + "/games"; + int myTeamScore = 2; + int otherTeamScore = 1; + TournamentGame tournamentGame = allTournamentGames.stream() + .filter(tg -> tg.getTournamentRound() == TournamentRound.QUARTER_FINAL_1) + .findAny() + .orElseThrow(); + TournamentGame nextTournamentGame = allTournamentGames.stream() + .filter(tg -> tg.getTournamentRound() == TournamentRound.SEMI_FINAL_1) + .findAny() + .orElseThrow(); + TournamentGameUpdateRequestDto requestDto = new TournamentGameUpdateRequestDto(tournamentGame.getId(), + nextTournamentGame.getId(), + new TeamReqDto(tournamentGame.getGame().getTeams().get(0).getId(), myTeamScore), + new TeamReqDto(tournamentGame.getGame().getTeams().get(1).getId(), otherTeamScore)); + + String content = objectMapper.writeValueAsString(requestDto); + // when + mockMvc.perform(patch(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .content(content) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isForbidden()) + .andReturn().getResponse().getContentAsString(); + } + + } +} diff --git a/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminUserControllerTest.java b/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminUserControllerTest.java index 498e0e2da..c3739223f 100644 --- a/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminUserControllerTest.java +++ b/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminUserControllerTest.java @@ -1,16 +1,9 @@ package com.gg.server.admin.tournament.controller; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.dto.TournamentUserListResponseDto; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import lombok.extern.slf4j.Slf4j; +import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + import org.apache.http.HttpHeaders; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -21,9 +14,18 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.domain.tournament.data.Tournament; +import com.gg.server.domain.tournament.dto.TournamentUserListResponseDto; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.extern.slf4j.Slf4j; @IntegrationTest @AutoConfigureMockMvc @@ -31,71 +33,77 @@ @Slf4j public class TournamentAdminUserControllerTest { - @Autowired - MockMvc mockMvc; - @Autowired - TestDataUtils testDataUtils; - @Autowired - ObjectMapper objectMapper; - @Autowired - AuthTokenProvider tokenProvider; - - String accessToken; - final int joinUserCnt = 8; - final int notJoinUserCnt = 4; - String testName = "42_gg_tester_"; - Tournament tournament; - String adminUrl = "/pingpong/admin/tournaments/"; - @BeforeEach - void beforeEach() { - User tester = testDataUtils.createNewUser("findControllerTester", "findControllerTester", RacketType.DUAL, SnsType.SLACK, RoleType.ADMIN); - accessToken = tokenProvider.createToken(tester.getId()); - tournament = testDataUtils.createTournamentWithUser(joinUserCnt, notJoinUserCnt, testName); - } - - @Nested - @DisplayName("/pingpong/admin/tournaments") - class FindTournamentUser { - - @Test - @DisplayName("[Get] /{tournamentId}/users") - void getAllTournamentUser() throws Exception { - // given - - String url = adminUrl + tournament.getId() + "/users"; - - // when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - TournamentUserListResponseDto resp = objectMapper.readValue(contentAsString, TournamentUserListResponseDto.class); - - // then - assertThat(resp.getUsers().size()).isEqualTo(joinUserCnt+ notJoinUserCnt); - for (int i = 0; i < joinUserCnt + notJoinUserCnt; i++) { - assertThat(resp.getUsers().get(i).getIntraId()).isEqualTo(testName + i); - } - } - - @Test - @DisplayName("[Get] /{tournamentId}/users?isJoined=true") - void getAllTournamentUserByIsJoined() throws Exception { - - // given - String url = adminUrl + tournament.getId() + "/users" + "?isJoined=true"; - - // when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - TournamentUserListResponseDto resp = objectMapper.readValue(contentAsString, TournamentUserListResponseDto.class); - - // then - assertThat(resp.getUsers().size()).isEqualTo(joinUserCnt); - for (int i = 0; i < joinUserCnt; i++) { - assertThat(resp.getUsers().get(i).getIntraId()).isEqualTo(testName + i); - assertThat(resp.getUsers().get(i).getIsJoined()).isEqualTo(true); - } - } - } + @Autowired + MockMvc mockMvc; + @Autowired + TestDataUtils testDataUtils; + @Autowired + ObjectMapper objectMapper; + @Autowired + AuthTokenProvider tokenProvider; + + String accessToken; + final int joinUserCnt = 8; + final int notJoinUserCnt = 4; + String testName = "42_gg_tester_"; + Tournament tournament; + String adminUrl = "/pingpong/admin/tournaments/"; + + @BeforeEach + void beforeEach() { + User tester = testDataUtils.createNewUser("findControllerTester", "findControllerTester", RacketType.DUAL, + SnsType.SLACK, RoleType.ADMIN); + accessToken = tokenProvider.createToken(tester.getId()); + tournament = testDataUtils.createTournamentWithUser(joinUserCnt, notJoinUserCnt, testName); + } + + @Nested + @DisplayName("/pingpong/admin/tournaments") + class FindTournamentUser { + + @Test + @DisplayName("[Get] /{tournamentId}/users") + void getAllTournamentUser() throws Exception { + // given + + String url = adminUrl + tournament.getId() + "/users"; + + // when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + TournamentUserListResponseDto resp = objectMapper.readValue(contentAsString, + TournamentUserListResponseDto.class); + + // then + assertThat(resp.getUsers().size()).isEqualTo(joinUserCnt + notJoinUserCnt); + for (int i = 0; i < joinUserCnt + notJoinUserCnt; i++) { + assertThat(resp.getUsers().get(i).getIntraId()).isEqualTo(testName + i); + } + } + + @Test + @DisplayName("[Get] /{tournamentId}/users?isJoined=true") + void getAllTournamentUserByIsJoined() throws Exception { + + // given + String url = adminUrl + tournament.getId() + "/users" + "?isJoined=true"; + + // when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + TournamentUserListResponseDto resp = objectMapper.readValue(contentAsString, + TournamentUserListResponseDto.class); + + // then + assertThat(resp.getUsers().size()).isEqualTo(joinUserCnt); + for (int i = 0; i < joinUserCnt; i++) { + assertThat(resp.getUsers().get(i).getIntraId()).isEqualTo(testName + i); + assertThat(resp.getUsers().get(i).getIsJoined()).isEqualTo(true); + } + } + } } diff --git a/src/test/java/com/gg/server/admin/tournament/service/TournamentAdminServiceTest.java b/src/test/java/com/gg/server/admin/tournament/service/TournamentAdminServiceTest.java index 6eccffb1b..ebf569e7e 100644 --- a/src/test/java/com/gg/server/admin/tournament/service/TournamentAdminServiceTest.java +++ b/src/test/java/com/gg/server/admin/tournament/service/TournamentAdminServiceTest.java @@ -1,12 +1,24 @@ package com.gg.server.admin.tournament.service; import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.when; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; import com.gg.server.admin.tournament.dto.TournamentAdminAddUserRequestDto; +import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; @@ -33,550 +45,559 @@ import com.gg.server.global.config.ConstantConfig; import com.gg.server.utils.ReflectionUtilsForUnitTest; import com.gg.server.utils.annotation.UnitTest; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; @UnitTest @ExtendWith(MockitoExtension.class) class TournamentAdminServiceTest { - @Mock - TournamentRepository tournamentRepository; - @Mock - TournamentGameRepository tournamentGameRepository; - @Mock - TournamentUserRepository tournamentUserRepository; - @Mock - SlotManagementRepository slotManagementRepository; - @Mock - UserRepository userRepository; - @Mock - GameRepository gameRepository; - @Mock - ConstantConfig constantConfig; - @InjectMocks - TournamentAdminService tournamentAdminService; - - // 토너먼트 생성 서비스 테스트 - @Nested - @DisplayName("토너먼트 관리자 생성 서비스 테스트") - class TournamentAdminServiceCreateTest { - @Test - @DisplayName("토너먼트 생성 성공") - void success() { - // given - TournamentAdminCreateRequestDto requestDto = createTournamentCreateRequestDto( - "1st tournament", - getTargetTime(3, 14, 0), getTargetTime(3, 16, 0)); - List tournamentList = createTournaments(1L, 2, getTargetTime(2, 10, 0)); - Tournament tournament = tournamentList.get(0); - TournamentGame tournamentGame = createTournamentGame(tournament, TournamentRound.THE_FINAL); - - given(slotManagementRepository.findCurrent(requestDto.getStartTime())).willReturn(Optional.of(createSlot(15))); - given(tournamentRepository.findAllBetween(requestDto.getStartTime(), requestDto.getEndTime())) - .willReturn(new ArrayList<>()); - given(gameRepository.findAllBetweenTournament(requestDto.getStartTime(), requestDto.getEndTime())) - .willReturn(new ArrayList<>()); - given(tournamentRepository.save(any(Tournament.class))).willReturn(tournament); - - // when - tournamentAdminService.createTournament(requestDto); - } - - @Test - @DisplayName("유효하지 않은 시간 입력") - public void invalidTime() { - when(constantConfig.getAllowedMinimalStartDays()).thenReturn(2); - //given - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - getTargetTime(0, 0, 0), getTargetTime(0, 1, 0)); - - TournamentAdminCreateRequestDto requestDto1 = createTournamentCreateRequestDto( - "1st tournament", - getTargetTime(1, 1, 0), getTargetTime(1, 3, 0)); - TournamentAdminCreateRequestDto requestDto2 = createTournamentCreateRequestDto( - "1st tournament", - getTargetTime(3, 3, 0), getTargetTime(3, 1, 0)); - TournamentAdminCreateRequestDto requestDto3 = createTournamentCreateRequestDto( - "1st tournament", - getTargetTime(3, 3, 0), getTargetTime(3, 3, 0)); - TournamentAdminCreateRequestDto requestDto4 = createTournamentCreateRequestDto( - "1st tournament", - getTargetTime(3, 1, 10), getTargetTime(3, 2, 10)); - given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn(Optional.of(createSlot(15))); - // when, then - assertThatThrownBy(() -> tournamentAdminService.createTournament(requestDto1)) - .isInstanceOf(TournamentUpdateException.class); - assertThatThrownBy(() -> tournamentAdminService.createTournament(requestDto2)) - .isInstanceOf(TournamentUpdateException.class); - assertThatThrownBy(() -> tournamentAdminService.createTournament(requestDto3)) - .isInstanceOf(TournamentUpdateException.class); - assertThatThrownBy(() -> tournamentAdminService.createTournament(requestDto4)) - .isInstanceOf(TournamentUpdateException.class); - } - - @Test - @DisplayName("기존에 있는 토너먼트와 겹치는 토너먼트 시간") - public void tournamentTimeConflict() { - // given - List tournamentList = createTournaments(1L, 2, getTargetTime(3, 10, 0)); - Tournament tournament = tournamentList.get(0); - TournamentAdminCreateRequestDto createRequestDto = createTournamentCreateRequestDto( - "1st tournament", - getTargetTime(3, 11, 0), getTargetTime(3, 13, 0)); - given(slotManagementRepository.findCurrent(createRequestDto.getStartTime())).willReturn(Optional.of(createSlot(15))); - given(tournamentRepository.findAllBetween(createRequestDto.getStartTime(), createRequestDto.getEndTime())) - .willReturn(tournamentList); - - // when, then - assertThatThrownBy(() -> tournamentAdminService.createTournament(createRequestDto)) - .isInstanceOf(TournamentConflictException.class); - } - - @Test - @DisplayName("기존에 있는 게임과 겹치는 토너먼트 시간") - void gameAlreadyExist() { - // given - TournamentAdminCreateRequestDto tournamentAdminCreateRequestDto = createTournamentCreateRequestDto( - "1st tournament", - getTargetTime(3, 10, 0), getTargetTime(3, 12, 0)); - List tournamentList = createTournaments(1L, 2, getTargetTime(2, 10, 0)); - Tournament tournament = tournamentList.get(0); - TournamentGame tournamentGame = createTournamentGame(tournament, TournamentRound.THE_FINAL); - List gameList = new ArrayList<>(); - gameList.add(new Game()); - given(slotManagementRepository.findCurrent(tournamentAdminCreateRequestDto.getStartTime())).willReturn(Optional.of(createSlot(15))); - given(tournamentRepository.findAllBetween(tournamentAdminCreateRequestDto.getStartTime(), tournamentAdminCreateRequestDto.getEndTime())) - .willReturn(new ArrayList<>()); - given(gameRepository.findAllBetweenTournament(tournamentAdminCreateRequestDto.getStartTime(), tournamentAdminCreateRequestDto.getEndTime())) - .willReturn(gameList); - - // when - assertThatThrownBy(() -> tournamentAdminService.createTournament(tournamentAdminCreateRequestDto)) - .isInstanceOf(TournamentConflictException.class); - ; - } - } - - // 토너먼트 수정 서비스 테스트 - @Nested - @DisplayName("토너먼트 관리자 서비스 수정 테스트") - class TournamentAdminServiceUpdateTest { - @Test - @DisplayName("토너먼트_업데이트_성공") - public void success() { - // given - List tournamentList = createTournaments(1L, 2, getTargetTime(2, 10, 0)); - Tournament tournament = tournamentList.get(0); - TournamentAdminUpdateRequestDto updateRequestDto = createTournamentAdminUpdateRequestDto( - getTargetTime(3, 14, 0), getTargetTime(3, 16, 0)); - given(slotManagementRepository.findCurrent(updateRequestDto.getStartTime())).willReturn(Optional.of(createSlot(15))); - given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); - given(tournamentRepository.findAllBetween(updateRequestDto.getStartTime(), updateRequestDto.getEndTime())) - .willReturn(new ArrayList<>()); - given(gameRepository.findAllBetweenTournament(updateRequestDto.getStartTime(), updateRequestDto.getEndTime())) - .willReturn(new ArrayList<>()); - given(tournamentRepository.save(any(Tournament.class))).willReturn(tournament); - // when - Tournament changedTournament = tournamentAdminService.updateTournamentInfo(1L, updateRequestDto); - // then - assertThat(changedTournament.getId()).isEqualTo(tournament.getId()); - assertThat(changedTournament.getTitle()).isEqualTo(updateRequestDto.getTitle()); - assertThat(changedTournament.getContents()).isEqualTo(updateRequestDto.getContents()); - assertThat(changedTournament.getStartTime()).isEqualTo(updateRequestDto.getStartTime()); - assertThat(changedTournament.getEndTime()).isEqualTo(updateRequestDto.getEndTime()); - assertThat(changedTournament.getType()).isEqualTo(updateRequestDto.getType()); - assertThat(changedTournament.getStatus()).isEqualTo(tournament.getStatus()); - } - - @Test - @DisplayName("타겟_토너먼트_없음") - public void tournamentNotFound() { - // given - Tournament tournament = createTournament(1234L, TournamentStatus.BEFORE, - getTargetTime(2, 1, 0), getTargetTime(2, 3, 0)); - TournamentAdminUpdateRequestDto updateRequestDto = createTournamentAdminUpdateRequestDto( - getTargetTime(2, 1, 0), getTargetTime(2, 3, 0)); - - given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.empty()); - // when, then - assertThatThrownBy(() -> tournamentAdminService.updateTournamentInfo(tournament.getId(), updateRequestDto)) - .isInstanceOf(TournamentNotFoundException.class); - } - - @Test - @DisplayName("토너먼트_업데이트_불가_상태") - public void canNotUpdate() { - // given - Tournament tournamentLive = createTournament(1L, TournamentStatus.LIVE, - LocalDateTime.now().plusHours(-1).withMinute(0), LocalDateTime.now().plusHours(1).withMinute(0)); - Tournament tournamentEnd = createTournament(2L, TournamentStatus.END, - LocalDateTime.now().plusHours(-4).withMinute(0), LocalDateTime.now().plusHours(-2).withMinute(0)); - TournamentAdminUpdateRequestDto updateRequestDto = createTournamentAdminUpdateRequestDto( - getTargetTime(3, 10, 0), getTargetTime(3, 12, 0)); - given(tournamentRepository.findById(tournamentLive.getId())).willReturn(Optional.of(tournamentLive)); - given(tournamentRepository.findById(tournamentEnd.getId())).willReturn(Optional.of(tournamentEnd)); - // when, then - assertThatThrownBy(() -> tournamentAdminService.updateTournamentInfo(tournamentLive.getId(), updateRequestDto)) - .isInstanceOf(TournamentUpdateException.class); - assertThatThrownBy(() -> tournamentAdminService.updateTournamentInfo(tournamentEnd.getId(), updateRequestDto)) - .isInstanceOf(TournamentUpdateException.class); - } - - @Test - @DisplayName("업데이트_토너먼트_Dto_Invalid_Time") - public void Dto_Invalid_Time() { - when(constantConfig.getAllowedMinimalStartDays()).thenReturn(2); - // given - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - getTargetTime(2, 1, 0), getTargetTime(2, 3, 0)); - TournamentAdminUpdateRequestDto invalidRequestDto1 = createTournamentAdminUpdateRequestDto( - getTargetTime(2, 3, 0), getTargetTime(2, 1, 0)); - TournamentAdminUpdateRequestDto invalidRequestDto2 = createTournamentAdminUpdateRequestDto( - invalidRequestDto1.getStartTime(), invalidRequestDto1.getStartTime()); - TournamentAdminUpdateRequestDto invalidRequestDto3 = createTournamentAdminUpdateRequestDto( - getTargetTime(1, 23, 0), getTargetTime(2, 1, 0)); - TournamentAdminUpdateRequestDto invalidRequestDto4 = createTournamentAdminUpdateRequestDto( - getTargetTime(2, 20, 1), getTargetTime(2, 23, 0)); - - given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn(Optional.of(createSlot(15))); - given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); - // when then - assertThatThrownBy(() -> tournamentAdminService.updateTournamentInfo(tournament.getId(), invalidRequestDto1)) - .isInstanceOf(TournamentUpdateException.class); - assertThatThrownBy(() -> tournamentAdminService.updateTournamentInfo(tournament.getId(), invalidRequestDto2)) - .isInstanceOf(TournamentUpdateException.class); - assertThatThrownBy(() -> tournamentAdminService.updateTournamentInfo(tournament.getId(), invalidRequestDto3)) - .isInstanceOf(TournamentUpdateException.class); - assertThatThrownBy(() -> tournamentAdminService.updateTournamentInfo(tournament.getId(), invalidRequestDto4)) - .isInstanceOf(TournamentUpdateException.class); - } - - @Test - @DisplayName("Dto_기간_토너먼트_기간_겹침") - public void tournamentTimeConflict() { - // given - List tournamentList = createTournaments(1L, 2, getTargetTime(3, 10, 0)); - Tournament tournament = tournamentList.get(0); - TournamentAdminUpdateRequestDto updateRequestDto = createTournamentAdminUpdateRequestDto( - getTargetTime(3, 12, 0), getTargetTime(3, 14, 0)); - given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn(Optional.of(createSlot(15))); - given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); - given(tournamentRepository.findAllBetween(updateRequestDto.getStartTime(), updateRequestDto.getEndTime())) - .willReturn(tournamentList); - // when, then - assertThatThrownBy(() -> tournamentAdminService.updateTournamentInfo(tournament.getId(), updateRequestDto)) - .isInstanceOf(TournamentConflictException.class); - } - - @Test - @DisplayName("Dto_기간_게임_겹침") - public void gameTimeConflict() { - // given - List tournamentList = createTournaments(1L, 2, getTargetTime(2, 10, 0)); - Tournament tournament = tournamentList.get(0); - TournamentAdminUpdateRequestDto updateRequestDto = createTournamentAdminUpdateRequestDto( - getTargetTime(3, 1, 0), getTargetTime(3, 3, 0)); - List gameList = new ArrayList<>(); - gameList.add(new Game()); - given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn(Optional.of(createSlot(15))); - given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); - given(tournamentRepository.findAllBetween(updateRequestDto.getStartTime(), updateRequestDto.getEndTime())) - .willReturn(new ArrayList<>()); - given(gameRepository.findAllBetweenTournament(updateRequestDto.getStartTime(), updateRequestDto.getEndTime())).willReturn(gameList); - // when, then - assertThatThrownBy(() -> tournamentAdminService.updateTournamentInfo(tournament.getId(), updateRequestDto)) - .isInstanceOf(TournamentConflictException.class); - } - } - - // 토너먼트 삭제 서비스 테스트 - @Nested - @DisplayName("토너먼트 관리자 서비스 삭제 테스트") - class TournamentAdminServiceDeleteTest { - @Test - @DisplayName("토너먼트_삭제_성공") - void success() { - // given - int tournamentGameCnt = 7; - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - getTargetTime(2, 1, 0), getTargetTime(2, 3, 0)); - List tournamentGameList = createTournamentGames(1L, tournament, tournamentGameCnt); - given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); - // when, then - tournamentAdminService.deleteTournament(tournament.getId()); - } - @Test - @DisplayName("타겟_토너먼트_없음") - public void tournamentNotFound() { - // given - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - getTargetTime(2, 1, 0), getTargetTime(2, 3, 0)); - given(tournamentRepository.findById(1L)).willReturn(Optional.empty()); - // when, then - assertThatThrownBy(() -> tournamentAdminService.deleteTournament(tournament.getId())) - .isInstanceOf(TournamentNotFoundException.class); - } - - @Test - @DisplayName("토너먼트_삭제_불가_상태") - public void canNotDelete() { - // given - Tournament liveTournament = createTournament(1L, TournamentStatus.LIVE, - LocalDateTime.now().plusHours(-1).withMinute(0), LocalDateTime.now().plusHours(1).withMinute(0)); - Tournament endTournament = createTournament(1L, TournamentStatus.END, - LocalDateTime.now().plusHours(-4).withMinute(0), LocalDateTime.now().plusHours(-2).withMinute(0)); - given(tournamentRepository.findById(liveTournament.getId())).willReturn(Optional.of(liveTournament)); - given(tournamentRepository.findById(endTournament.getId())).willReturn(Optional.of(endTournament)); - // when, then - assertThatThrownBy(() -> tournamentAdminService.deleteTournament(liveTournament.getId())) - .isInstanceOf(TournamentUpdateException.class); - assertThatThrownBy(() -> tournamentAdminService.deleteTournament(endTournament.getId())) - .isInstanceOf(TournamentUpdateException.class); - } - - } - - @Nested - @DisplayName("관리자_토너먼트_유저_추가_테스트") - class TournamentAdminServiceAddUserTest { - @Test - @DisplayName("유저_추가_성공") - public void success() { - // given - List tournamentList = createTournaments(1L, 2, getTargetTime(2, 1, 0)); - Tournament tournament = tournamentList.get(0); - TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto("testUser"); - User user = createUser("testUser"); - given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); - given(userRepository.findByIntraId("testUser")).willReturn(Optional.of(user)); - given(tournamentUserRepository.save(any(TournamentUser.class))).willReturn(null); - // when, then - tournamentAdminService.addTournamentUser(1L, requestDto); - } - - @Test - @DisplayName("타겟_토너먼트_없음") - public void tournamentNotFound() { - // given - TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto("test"); - - given(tournamentRepository.findById(any(Long.class))).willReturn(Optional.empty()); - // when, then - assertThatThrownBy(() -> tournamentAdminService.addTournamentUser(1L, requestDto)) - .isInstanceOf(TournamentNotFoundException.class); - } - - @Test - @DisplayName("토너먼트_업데이트_불가_상태") - public void canNotAdd() { - // given - Tournament tournamentLive = createTournament(1L, TournamentStatus.LIVE, - LocalDateTime.now().plusHours(-1).withMinute(0), LocalDateTime.now().plusHours(1).withMinute(0)); - Tournament tournamentEnd = createTournament(2L, TournamentStatus.END, - LocalDateTime.now().plusHours(-4).withMinute(0), LocalDateTime.now().plusHours(-2).withMinute(0)); - TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto("test"); - given(tournamentRepository.findById(tournamentLive.getId())).willReturn(Optional.of(tournamentLive)); - given(tournamentRepository.findById(tournamentEnd.getId())).willReturn(Optional.of(tournamentEnd)); - // when, then - assertThatThrownBy(() -> tournamentAdminService.addTournamentUser(tournamentLive.getId(), requestDto)) - .isInstanceOf(TournamentUpdateException.class); - assertThatThrownBy(() -> tournamentAdminService.addTournamentUser(tournamentEnd.getId(), requestDto)) - .isInstanceOf(TournamentUpdateException.class); - } - - @Test - @DisplayName("찾을_수_없는_유저") - public void userNotFound() { - // given - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - getTargetTime(0, 14, 0), getTargetTime(0, 16, 0)); - TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto("test"); - given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); - given(userRepository.findByIntraId("test")).willReturn(Optional.empty()); - - // when then - assertThatThrownBy(() -> tournamentAdminService.addTournamentUser(tournament.getId(), requestDto)) - .isInstanceOf(UserNotFoundException.class); - } - - @Test - @DisplayName("이미_해당_토너먼트_참가중인_유저") - public void alreadyTournamentParticipant() { - // given - List tournamentList = createTournaments(1L, 2, getTargetTime(2, 1, 0)); - Tournament tournament = tournamentList.get(0); - TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto("testUser"); - User user = createUser("testUser"); - TournamentUser tournamentUser = new TournamentUser(user, tournament, true, LocalDateTime.now()); - given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); - given(userRepository.findByIntraId("testUser")).willReturn(Optional.of(user)); - - // when, then - assertThatThrownBy(() -> tournamentAdminService.addTournamentUser(tournament.getId(), requestDto)) - .isInstanceOf(TournamentConflictException.class); - } - } - - @Nested - @DisplayName("관리자_토너먼트_유저_삭제_테스트") - class TournamentAdminServiceDeleteUserTest { - @Test - @DisplayName("찾을_수_없는_유저") - public void userNotFound() { - //given - List tournamentList = createTournaments(1L, 2, getTargetTime(2, 1, 0)); - Tournament tournament = tournamentList.get(0); - User user = createUser("user"); - given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); - given(userRepository.findById(null)).willReturn(Optional.empty()); - - // when, then - assertThatThrownBy(() -> tournamentAdminService.deleteTournamentUser(tournament.getId(), user.getId())) - .isInstanceOf(UserNotFoundException.class); - } - } - - /** - * 토너먼트 생성 requestDto - * @param startTime 토너먼트 시작 시간 - * @param endTime 토너먼트 종료 시간 - * @return - */ - private TournamentAdminCreateRequestDto createTournamentCreateRequestDto(String title, LocalDateTime startTime, LocalDateTime endTime) { - return new TournamentAdminCreateRequestDto( - title, - "제 1회 루키전 많관부!!", - startTime, - endTime, - TournamentType.ROOKIE - ); - } - - /** - * 토너먼트 게임 테이블 생성 - * @param tournament 토너먼트 - * @param round 몇 번째 게임인지에 대한 정보 - * @return 새로 생성된 토너먼트 게임 - */ - private TournamentGame createTournamentGame(Tournament tournament, TournamentRound round) { - TournamentGame tournamentGame = new TournamentGame(null, tournament, round); - return tournamentGameRepository.save(tournamentGame); - } - - /** - * 현재 시간에서 days hours, 만큼 차이나는 시간을 구한다. - * @param days - * @param hours - * @return - */ - private LocalDateTime getTargetTime(int days, int hours, int minutes) { - return LocalDateTime.now().plusDays(days).withHour(hours).withMinute(minutes); - } - - /** - * 각 매개변수로 초기화 된 토너먼트를 반환 - * @param id - * @param status - * @param startTime - * @param endTime - * @return - */ - private Tournament createTournament(Long id, TournamentStatus status, LocalDateTime startTime, LocalDateTime endTime) { - Tournament tournament = Tournament.builder() - .title(id + "st tournament") - .contents("") - .startTime(startTime) - .endTime(endTime) - .type(TournamentType.ROOKIE) - .status(status) - .build(); - ReflectionUtilsForUnitTest.setFieldWithReflection(tournament, "id", id); - return tournament; - } - - /** - *

id 부터 cnt개 만큼의 토너먼트 리스트를 반환해준다.
- * 각 토너먼트는 1시간 길이이며, 토너먼트간 1시간의 간격이 있다. - * @param id - * @param cnt - * @param startTime - * @return - */ - private List createTournaments(Long id, long cnt, LocalDateTime startTime) { - List tournamentList = new ArrayList<>(); - for (long i=0; i createTournamentGames(Long id, Tournament tournament, int cnt) { - List tournamentGameList = new ArrayList<>(); - TournamentRound [] values = TournamentRound.values(); - while (--cnt >= 0) { - tournamentGameList.add(new TournamentGame(null, tournament, values[cnt])); - } - return tournamentGameList; - } - - private SlotManagement createSlot(int gameInterval) { - return SlotManagement.builder() - .pastSlotTime(0) - .futureSlotTime(0) - .openMinute(0) - .gameInterval(gameInterval) - .startTime(LocalDateTime.now().minusHours(1)) - .build(); - } -} \ No newline at end of file + @Mock + TournamentRepository tournamentRepository; + @Mock + TournamentGameRepository tournamentGameRepository; + @Mock + TournamentUserRepository tournamentUserRepository; + @Mock + SlotManagementRepository slotManagementRepository; + @Mock + UserRepository userRepository; + @Mock + GameRepository gameRepository; + @Mock + ConstantConfig constantConfig; + @InjectMocks + TournamentAdminService tournamentAdminService; + + // 토너먼트 생성 서비스 테스트 + @Nested + @DisplayName("토너먼트 관리자 생성 서비스 테스트") + class TournamentAdminServiceCreateTest { + @Test + @DisplayName("토너먼트 생성 성공") + void success() { + // given + TournamentAdminCreateRequestDto requestDto = createTournamentCreateRequestDto( + "1st tournament", + getTargetTime(3, 14, 0), getTargetTime(3, 16, 0)); + List tournamentList = createTournaments(1L, 2, getTargetTime(2, 10, 0)); + Tournament tournament = tournamentList.get(0); + TournamentGame tournamentGame = createTournamentGame(tournament, TournamentRound.THE_FINAL); + + given(slotManagementRepository.findCurrent(requestDto.getStartTime())).willReturn( + Optional.of(createSlot(15))); + given(tournamentRepository.findAllBetween(requestDto.getStartTime(), requestDto.getEndTime())) + .willReturn(new ArrayList<>()); + given(gameRepository.findAllBetweenTournament(requestDto.getStartTime(), requestDto.getEndTime())) + .willReturn(new ArrayList<>()); + given(tournamentRepository.save(any(Tournament.class))).willReturn(tournament); + + // when + tournamentAdminService.createTournament(requestDto); + } + + @Test + @DisplayName("유효하지 않은 시간 입력") + public void invalidTime() { + when(constantConfig.getAllowedMinimalStartDays()).thenReturn(2); + //given + Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, + getTargetTime(0, 0, 0), getTargetTime(0, 1, 0)); + + TournamentAdminCreateRequestDto requestDto1 = createTournamentCreateRequestDto( + "1st tournament", + getTargetTime(1, 1, 0), getTargetTime(1, 3, 0)); + TournamentAdminCreateRequestDto requestDto2 = createTournamentCreateRequestDto( + "1st tournament", + getTargetTime(3, 3, 0), getTargetTime(3, 1, 0)); + TournamentAdminCreateRequestDto requestDto3 = createTournamentCreateRequestDto( + "1st tournament", + getTargetTime(3, 3, 0), getTargetTime(3, 3, 0)); + TournamentAdminCreateRequestDto requestDto4 = createTournamentCreateRequestDto( + "1st tournament", + getTargetTime(3, 1, 10), getTargetTime(3, 2, 10)); + given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn( + Optional.of(createSlot(15))); + // when, then + assertThatThrownBy(() -> tournamentAdminService.createTournament(requestDto1)) + .isInstanceOf(TournamentUpdateException.class); + assertThatThrownBy(() -> tournamentAdminService.createTournament(requestDto2)) + .isInstanceOf(TournamentUpdateException.class); + assertThatThrownBy(() -> tournamentAdminService.createTournament(requestDto3)) + .isInstanceOf(TournamentUpdateException.class); + assertThatThrownBy(() -> tournamentAdminService.createTournament(requestDto4)) + .isInstanceOf(TournamentUpdateException.class); + } + + @Test + @DisplayName("기존에 있는 토너먼트와 겹치는 토너먼트 시간") + public void tournamentTimeConflict() { + // given + List tournamentList = createTournaments(1L, 2, getTargetTime(3, 10, 0)); + Tournament tournament = tournamentList.get(0); + TournamentAdminCreateRequestDto createRequestDto = createTournamentCreateRequestDto( + "1st tournament", + getTargetTime(3, 11, 0), getTargetTime(3, 13, 0)); + given(slotManagementRepository.findCurrent(createRequestDto.getStartTime())).willReturn( + Optional.of(createSlot(15))); + given(tournamentRepository.findAllBetween(createRequestDto.getStartTime(), createRequestDto.getEndTime())) + .willReturn(tournamentList); + + // when, then + assertThatThrownBy(() -> tournamentAdminService.createTournament(createRequestDto)) + .isInstanceOf(TournamentConflictException.class); + } + + @Test + @DisplayName("기존에 있는 게임과 겹치는 토너먼트 시간") + void gameAlreadyExist() { + // given + TournamentAdminCreateRequestDto tournamentAdminCreateRequestDto = createTournamentCreateRequestDto( + "1st tournament", + getTargetTime(3, 10, 0), getTargetTime(3, 12, 0)); + List tournamentList = createTournaments(1L, 2, getTargetTime(2, 10, 0)); + Tournament tournament = tournamentList.get(0); + TournamentGame tournamentGame = createTournamentGame(tournament, TournamentRound.THE_FINAL); + List gameList = new ArrayList<>(); + gameList.add(new Game()); + given(slotManagementRepository.findCurrent(tournamentAdminCreateRequestDto.getStartTime())).willReturn( + Optional.of(createSlot(15))); + given(tournamentRepository.findAllBetween(tournamentAdminCreateRequestDto.getStartTime(), + tournamentAdminCreateRequestDto.getEndTime())) + .willReturn(new ArrayList<>()); + given(gameRepository.findAllBetweenTournament(tournamentAdminCreateRequestDto.getStartTime(), + tournamentAdminCreateRequestDto.getEndTime())) + .willReturn(gameList); + + // when + assertThatThrownBy(() -> tournamentAdminService.createTournament(tournamentAdminCreateRequestDto)) + .isInstanceOf(TournamentConflictException.class); + ; + } + } + + // 토너먼트 수정 서비스 테스트 + @Nested + @DisplayName("토너먼트 관리자 서비스 수정 테스트") + class TournamentAdminServiceUpdateTest { + @Test + @DisplayName("토너먼트_업데이트_성공") + public void success() { + // given + List tournamentList = createTournaments(1L, 2, getTargetTime(2, 10, 0)); + Tournament tournament = tournamentList.get(0); + TournamentAdminUpdateRequestDto updateRequestDto = createTournamentAdminUpdateRequestDto( + getTargetTime(3, 14, 0), getTargetTime(3, 16, 0)); + given(slotManagementRepository.findCurrent(updateRequestDto.getStartTime())).willReturn( + Optional.of(createSlot(15))); + given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); + given(tournamentRepository.findAllBetween(updateRequestDto.getStartTime(), updateRequestDto.getEndTime())) + .willReturn(new ArrayList<>()); + given( + gameRepository.findAllBetweenTournament(updateRequestDto.getStartTime(), updateRequestDto.getEndTime())) + .willReturn(new ArrayList<>()); + given(tournamentRepository.save(any(Tournament.class))).willReturn(tournament); + // when + Tournament changedTournament = tournamentAdminService.updateTournamentInfo(1L, updateRequestDto); + // then + assertThat(changedTournament.getId()).isEqualTo(tournament.getId()); + assertThat(changedTournament.getTitle()).isEqualTo(updateRequestDto.getTitle()); + assertThat(changedTournament.getContents()).isEqualTo(updateRequestDto.getContents()); + assertThat(changedTournament.getStartTime()).isEqualTo(updateRequestDto.getStartTime()); + assertThat(changedTournament.getEndTime()).isEqualTo(updateRequestDto.getEndTime()); + assertThat(changedTournament.getType()).isEqualTo(updateRequestDto.getType()); + assertThat(changedTournament.getStatus()).isEqualTo(tournament.getStatus()); + } + + @Test + @DisplayName("타겟_토너먼트_없음") + public void tournamentNotFound() { + // given + Tournament tournament = createTournament(1234L, TournamentStatus.BEFORE, + getTargetTime(2, 1, 0), getTargetTime(2, 3, 0)); + TournamentAdminUpdateRequestDto updateRequestDto = createTournamentAdminUpdateRequestDto( + getTargetTime(2, 1, 0), getTargetTime(2, 3, 0)); + + given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> tournamentAdminService.updateTournamentInfo(tournament.getId(), updateRequestDto)) + .isInstanceOf(TournamentNotFoundException.class); + } + + @Test + @DisplayName("토너먼트_업데이트_불가_상태") + public void canNotUpdate() { + // given + Tournament tournamentLive = createTournament(1L, TournamentStatus.LIVE, + LocalDateTime.now().plusHours(-1).withMinute(0), LocalDateTime.now().plusHours(1).withMinute(0)); + Tournament tournamentEnd = createTournament(2L, TournamentStatus.END, + LocalDateTime.now().plusHours(-4).withMinute(0), LocalDateTime.now().plusHours(-2).withMinute(0)); + TournamentAdminUpdateRequestDto updateRequestDto = createTournamentAdminUpdateRequestDto( + getTargetTime(3, 10, 0), getTargetTime(3, 12, 0)); + given(tournamentRepository.findById(tournamentLive.getId())).willReturn(Optional.of(tournamentLive)); + given(tournamentRepository.findById(tournamentEnd.getId())).willReturn(Optional.of(tournamentEnd)); + // when, then + assertThatThrownBy( + () -> tournamentAdminService.updateTournamentInfo(tournamentLive.getId(), updateRequestDto)) + .isInstanceOf(TournamentUpdateException.class); + assertThatThrownBy( + () -> tournamentAdminService.updateTournamentInfo(tournamentEnd.getId(), updateRequestDto)) + .isInstanceOf(TournamentUpdateException.class); + } + + @Test + @DisplayName("업데이트_토너먼트_Dto_Invalid_Time") + public void dto_Invalid_Time() { + when(constantConfig.getAllowedMinimalStartDays()).thenReturn(2); + // given + Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, + getTargetTime(2, 1, 0), getTargetTime(2, 3, 0)); + TournamentAdminUpdateRequestDto invalidRequestDto1 = createTournamentAdminUpdateRequestDto( + getTargetTime(2, 3, 0), getTargetTime(2, 1, 0)); + TournamentAdminUpdateRequestDto invalidRequestDto2 = createTournamentAdminUpdateRequestDto( + invalidRequestDto1.getStartTime(), invalidRequestDto1.getStartTime()); + TournamentAdminUpdateRequestDto invalidRequestDto3 = createTournamentAdminUpdateRequestDto( + getTargetTime(1, 23, 0), getTargetTime(2, 1, 0)); + TournamentAdminUpdateRequestDto invalidRequestDto4 = createTournamentAdminUpdateRequestDto( + getTargetTime(2, 20, 1), getTargetTime(2, 23, 0)); + + given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn( + Optional.of(createSlot(15))); + given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); + // when then + assertThatThrownBy( + () -> tournamentAdminService.updateTournamentInfo(tournament.getId(), invalidRequestDto1)) + .isInstanceOf(TournamentUpdateException.class); + assertThatThrownBy( + () -> tournamentAdminService.updateTournamentInfo(tournament.getId(), invalidRequestDto2)) + .isInstanceOf(TournamentUpdateException.class); + assertThatThrownBy( + () -> tournamentAdminService.updateTournamentInfo(tournament.getId(), invalidRequestDto3)) + .isInstanceOf(TournamentUpdateException.class); + assertThatThrownBy( + () -> tournamentAdminService.updateTournamentInfo(tournament.getId(), invalidRequestDto4)) + .isInstanceOf(TournamentUpdateException.class); + } + + @Test + @DisplayName("Dto_기간_토너먼트_기간_겹침") + public void tournamentTimeConflict() { + // given + List tournamentList = createTournaments(1L, 2, getTargetTime(3, 10, 0)); + Tournament tournament = tournamentList.get(0); + TournamentAdminUpdateRequestDto updateRequestDto = createTournamentAdminUpdateRequestDto( + getTargetTime(3, 12, 0), getTargetTime(3, 14, 0)); + given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn( + Optional.of(createSlot(15))); + given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); + given(tournamentRepository.findAllBetween(updateRequestDto.getStartTime(), updateRequestDto.getEndTime())) + .willReturn(tournamentList); + // when, then + assertThatThrownBy(() -> tournamentAdminService.updateTournamentInfo(tournament.getId(), updateRequestDto)) + .isInstanceOf(TournamentConflictException.class); + } + + @Test + @DisplayName("Dto_기간_게임_겹침") + public void gameTimeConflict() { + // given + List tournamentList = createTournaments(1L, 2, getTargetTime(2, 10, 0)); + Tournament tournament = tournamentList.get(0); + TournamentAdminUpdateRequestDto updateRequestDto = createTournamentAdminUpdateRequestDto( + getTargetTime(3, 1, 0), getTargetTime(3, 3, 0)); + List gameList = new ArrayList<>(); + gameList.add(new Game()); + given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn( + Optional.of(createSlot(15))); + given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); + given(tournamentRepository.findAllBetween(updateRequestDto.getStartTime(), updateRequestDto.getEndTime())) + .willReturn(new ArrayList<>()); + given(gameRepository.findAllBetweenTournament(updateRequestDto.getStartTime(), + updateRequestDto.getEndTime())).willReturn(gameList); + // when, then + assertThatThrownBy(() -> tournamentAdminService.updateTournamentInfo(tournament.getId(), updateRequestDto)) + .isInstanceOf(TournamentConflictException.class); + } + } + + // 토너먼트 삭제 서비스 테스트 + @Nested + @DisplayName("토너먼트 관리자 서비스 삭제 테스트") + class TournamentAdminServiceDeleteTest { + @Test + @DisplayName("토너먼트_삭제_성공") + void success() { + // given + int tournamentGameCnt = 7; + Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, + getTargetTime(2, 1, 0), getTargetTime(2, 3, 0)); + List tournamentGameList = createTournamentGames(1L, tournament, tournamentGameCnt); + given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); + // when, then + tournamentAdminService.deleteTournament(tournament.getId()); + } + + @Test + @DisplayName("타겟_토너먼트_없음") + public void tournamentNotFound() { + // given + Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, + getTargetTime(2, 1, 0), getTargetTime(2, 3, 0)); + given(tournamentRepository.findById(1L)).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> tournamentAdminService.deleteTournament(tournament.getId())) + .isInstanceOf(TournamentNotFoundException.class); + } + + @Test + @DisplayName("토너먼트_삭제_불가_상태") + public void canNotDelete() { + // given + Tournament liveTournament = createTournament(1L, TournamentStatus.LIVE, + LocalDateTime.now().plusHours(-1).withMinute(0), LocalDateTime.now().plusHours(1).withMinute(0)); + Tournament endTournament = createTournament(1L, TournamentStatus.END, + LocalDateTime.now().plusHours(-4).withMinute(0), LocalDateTime.now().plusHours(-2).withMinute(0)); + given(tournamentRepository.findById(liveTournament.getId())).willReturn(Optional.of(liveTournament)); + given(tournamentRepository.findById(endTournament.getId())).willReturn(Optional.of(endTournament)); + // when, then + assertThatThrownBy(() -> tournamentAdminService.deleteTournament(liveTournament.getId())) + .isInstanceOf(TournamentUpdateException.class); + assertThatThrownBy(() -> tournamentAdminService.deleteTournament(endTournament.getId())) + .isInstanceOf(TournamentUpdateException.class); + } + + } + + @Nested + @DisplayName("관리자_토너먼트_유저_추가_테스트") + class TournamentAdminServiceAddUserTest { + @Test + @DisplayName("유저_추가_성공") + public void success() { + // given + List tournamentList = createTournaments(1L, 2, getTargetTime(2, 1, 0)); + Tournament tournament = tournamentList.get(0); + TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto("testUser"); + User user = createUser("testUser"); + given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); + given(userRepository.findByIntraId("testUser")).willReturn(Optional.of(user)); + given(tournamentUserRepository.save(any(TournamentUser.class))).willReturn(null); + // when, then + tournamentAdminService.addTournamentUser(1L, requestDto); + } + + @Test + @DisplayName("타겟_토너먼트_없음") + public void tournamentNotFound() { + // given + TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto("test"); + + given(tournamentRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> tournamentAdminService.addTournamentUser(1L, requestDto)) + .isInstanceOf(TournamentNotFoundException.class); + } + + @Test + @DisplayName("토너먼트_업데이트_불가_상태") + public void canNotAdd() { + // given + Tournament tournamentLive = createTournament(1L, TournamentStatus.LIVE, + LocalDateTime.now().plusHours(-1).withMinute(0), LocalDateTime.now().plusHours(1).withMinute(0)); + Tournament tournamentEnd = createTournament(2L, TournamentStatus.END, + LocalDateTime.now().plusHours(-4).withMinute(0), LocalDateTime.now().plusHours(-2).withMinute(0)); + TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto("test"); + given(tournamentRepository.findById(tournamentLive.getId())).willReturn(Optional.of(tournamentLive)); + given(tournamentRepository.findById(tournamentEnd.getId())).willReturn(Optional.of(tournamentEnd)); + // when, then + assertThatThrownBy(() -> tournamentAdminService.addTournamentUser(tournamentLive.getId(), requestDto)) + .isInstanceOf(TournamentUpdateException.class); + assertThatThrownBy(() -> tournamentAdminService.addTournamentUser(tournamentEnd.getId(), requestDto)) + .isInstanceOf(TournamentUpdateException.class); + } + + @Test + @DisplayName("찾을_수_없는_유저") + public void userNotFound() { + // given + Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, + getTargetTime(0, 14, 0), getTargetTime(0, 16, 0)); + TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto("test"); + given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); + given(userRepository.findByIntraId("test")).willReturn(Optional.empty()); + + // when then + assertThatThrownBy(() -> tournamentAdminService.addTournamentUser(tournament.getId(), requestDto)) + .isInstanceOf(UserNotFoundException.class); + } + + @Test + @DisplayName("이미_해당_토너먼트_참가중인_유저") + public void alreadyTournamentParticipant() { + // given + List tournamentList = createTournaments(1L, 2, getTargetTime(2, 1, 0)); + Tournament tournament = tournamentList.get(0); + TournamentAdminAddUserRequestDto requestDto = new TournamentAdminAddUserRequestDto("testUser"); + User user = createUser("testUser"); + TournamentUser tournamentUser = new TournamentUser(user, tournament, true, LocalDateTime.now()); + given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); + given(userRepository.findByIntraId("testUser")).willReturn(Optional.of(user)); + + // when, then + assertThatThrownBy(() -> tournamentAdminService.addTournamentUser(tournament.getId(), requestDto)) + .isInstanceOf(TournamentConflictException.class); + } + } + + @Nested + @DisplayName("관리자_토너먼트_유저_삭제_테스트") + class TournamentAdminServiceDeleteUserTest { + @Test + @DisplayName("찾을_수_없는_유저") + public void userNotFound() { + //given + List tournamentList = createTournaments(1L, 2, getTargetTime(2, 1, 0)); + Tournament tournament = tournamentList.get(0); + User user = createUser("user"); + given(tournamentRepository.findById(1L)).willReturn(Optional.of(tournament)); + given(userRepository.findById(null)).willReturn(Optional.empty()); + + // when, then + assertThatThrownBy(() -> tournamentAdminService.deleteTournamentUser(tournament.getId(), user.getId())) + .isInstanceOf(UserNotFoundException.class); + } + } + + /** + * 토너먼트 생성 requestDto + * @param startTime 토너먼트 시작 시간 + * @param endTime 토너먼트 종료 시간 + * @return + */ + private TournamentAdminCreateRequestDto createTournamentCreateRequestDto(String title, LocalDateTime startTime, + LocalDateTime endTime) { + return new TournamentAdminCreateRequestDto( + title, + "제 1회 루키전 많관부!!", + startTime, + endTime, + TournamentType.ROOKIE + ); + } + + /** + * 토너먼트 게임 테이블 생성 + * @param tournament 토너먼트 + * @param round 몇 번째 게임인지에 대한 정보 + * @return 새로 생성된 토너먼트 게임 + */ + private TournamentGame createTournamentGame(Tournament tournament, TournamentRound round) { + TournamentGame tournamentGame = new TournamentGame(null, tournament, round); + return tournamentGameRepository.save(tournamentGame); + } + + /** + * 현재 시간에서 days hours, 만큼 차이나는 시간을 구한다. + * @param days + * @param hours + * @return + */ + private LocalDateTime getTargetTime(int days, int hours, int minutes) { + return LocalDateTime.now().plusDays(days).withHour(hours).withMinute(minutes); + } + + /** + * 각 매개변수로 초기화 된 토너먼트를 반환 + * @param id + * @param status + * @param startTime + * @param endTime + * @return + */ + private Tournament createTournament(Long id, TournamentStatus status, LocalDateTime startTime, + LocalDateTime endTime) { + Tournament tournament = Tournament.builder() + .title(id + "st tournament") + .contents("") + .startTime(startTime) + .endTime(endTime) + .type(TournamentType.ROOKIE) + .status(status) + .build(); + ReflectionUtilsForUnitTest.setFieldWithReflection(tournament, "id", id); + return tournament; + } + + /** + *
id 부터 cnt개 만큼의 토너먼트 리스트를 반환해준다.
+ * 각 토너먼트는 1시간 길이이며, 토너먼트간 1시간의 간격이 있다. + * @param id + * @param cnt + * @param startTime + * @return + */ + private List createTournaments(Long id, long cnt, LocalDateTime startTime) { + List tournamentList = new ArrayList<>(); + for (long i = 0; i < cnt; i++) { + tournamentList.add(createTournament(id++, TournamentStatus.BEFORE, + startTime.plusHours(i * 2), startTime.plusHours((i * 2 + 2)))); + } + return tournamentList; + } + + /** + * 각 매개변수로 초기화된 TournamentAdminUpdateRequestDto를 반환 + * @param startTime + * @param endTime + * @return + */ + private TournamentAdminUpdateRequestDto createTournamentAdminUpdateRequestDto(LocalDateTime startTime, + LocalDateTime endTime) { + return new TournamentAdminUpdateRequestDto( + "tournament changed", + "changed", + startTime, + endTime, + TournamentType.ROOKIE + ); + } + + /** + * 유저 생성 매서드 - intraId로만 초기화 + * @param intraId + * @return + */ + private User createUser(String intraId) { + return User.builder() + .eMail("email") + .intraId(intraId) + .racketType(RacketType.PENHOLDER) + .snsNotiOpt(SnsType.NONE) + .roleType(RoleType.USER) + .totalExp(1000) + .build(); + } + + /** + * cnt 사이즈의 토너먼트 게임 리스트 생성 + * @param id 토너먼트 게임 id + * @param tournament 해당 토너먼트 + * @param cnt 토너먼트 게임 수 + * @return + */ + private List createTournamentGames(Long id, Tournament tournament, int cnt) { + List tournamentGameList = new ArrayList<>(); + TournamentRound[] values = TournamentRound.values(); + while (--cnt >= 0) { + tournamentGameList.add(new TournamentGame(null, tournament, values[cnt])); + } + return tournamentGameList; + } + + private SlotManagement createSlot(int gameInterval) { + return SlotManagement.builder() + .pastSlotTime(0) + .futureSlotTime(0) + .openMinute(0) + .gameInterval(gameInterval) + .startTime(LocalDateTime.now().minusHours(1)) + .build(); + } +} diff --git a/src/test/java/com/gg/server/admin/user/controller/UserAdminControllerTest.java b/src/test/java/com/gg/server/admin/user/controller/UserAdminControllerTest.java index 1aca93555..d5877e8a9 100644 --- a/src/test/java/com/gg/server/admin/user/controller/UserAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/user/controller/UserAdminControllerTest.java @@ -1,256 +1,266 @@ -package com.gg.server.admin.user.controller; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.admin.user.data.UserImageAdminRepository; -import com.gg.server.admin.user.dto.UserDetailAdminResponseDto; -import com.gg.server.admin.user.dto.UserImageAdminDto; -import com.gg.server.admin.user.dto.UserImageListAdminResponseDto; -import com.gg.server.admin.user.dto.UserSearchAdminDto; -import com.gg.server.admin.user.dto.UserSearchAdminResponseDto; -import com.gg.server.admin.user.service.UserAdminService; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserImage; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import java.util.List; -import javax.transaction.Transactional; -import lombok.RequiredArgsConstructor; -import org.apache.http.HttpHeaders; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.test.web.servlet.MockMvc; - -@RequiredArgsConstructor -@IntegrationTest -@AutoConfigureMockMvc -class UserAdminControllerTest { - - @Autowired - UserAdminService userAdminService; - @Autowired - TestDataUtils testDataUtils; - @Autowired - AuthTokenProvider tokenProvider; - @Autowired - UserRepository userRepository; - @Autowired - UserAdminRepository userAdminRepository; - @Autowired - MockMvc mockMvc; - @Autowired - ObjectMapper objectMapper; - @Autowired - UserImageAdminRepository userImageAdminRepository; - - @BeforeEach - public void setUp() { - testDataUtils.createTierSystem("pingpong"); - testDataUtils.createSeason(); - } - - @Test - @DisplayName("GET /pingpong/admin/users") - @Transactional - public void userSearchAllTest() throws Exception{ - //given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.findById(userId).get(); - int page = 1; - int size = 20; - Pageable pageable = PageRequest.of(page - 1, size, Sort.by("intraId").ascending()); - String url = "/pingpong/admin/users?page=1"; - String url2 = "/pingpong/admin/users?page=1&intraId=" + user.getIntraId(); - //when - //200 성공 - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - UserSearchAdminResponseDto actureResponse1 = objectMapper.readValue(contentAsString, UserSearchAdminResponseDto.class); - //200 성공 - contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - UserSearchAdminResponseDto actureResponse2 = objectMapper.readValue(contentAsString, UserSearchAdminResponseDto.class); - - //then - List userList1 = userAdminRepository.findAll(pageable).getContent(); - List actureUserList1 = actureResponse1.getUserSearchAdminDtos(); - for (int i = 0; i < userList1.size(); i++) { - Assertions.assertThat(userList1.get(i).getIntraId()).isEqualTo(actureUserList1.get(i).getIntraId()); - } - - List userList2 = userAdminRepository.findAll(pageable).getContent(); - List actureUserList2 = actureResponse2.getUserSearchAdminDtos(); - for (int i = 0; i < userList1.size(); i++) { - Assertions.assertThat(userList2.get(i).getIntraId()).isEqualTo(actureUserList2.get(i).getIntraId()); - } - } - - @Test - @DisplayName("유저 필터링 조회 테스트") - @Transactional - public void 유저필터링조회테스트() throws Exception { - //given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.findById(userId).get(); - int page = 1; - int size = 20; - Pageable pageable = PageRequest.of(page - 1, size, Sort.by("intraId").ascending()); - String url = "/pingpong/admin/users?page=1&userFilter=\"" + user.getIntraId() + "\""; - - //when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - UserSearchAdminResponseDto actureResponse = objectMapper.readValue(contentAsString, UserSearchAdminResponseDto.class); - - List actureUserList = actureResponse.getUserSearchAdminDtos(); - for (UserSearchAdminDto userDto : actureUserList) - Assertions.assertThat(userDto.getIntraId()).isEqualTo(user.getIntraId()); - } - - @Test - @DisplayName("GET /pingpong/admin/users/{intraId}") - @Transactional - public void userGetDetailTest() throws Exception{ - //given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = testDataUtils.createNewUser("nheo"); - User target = userRepository.findByIntraId(user.getIntraId()).get(); - String url = "/pingpong/admin/users/" + user.getIntraId(); - UserDetailAdminResponseDto expectedResponse = userAdminService.getUserDetailByIntraId(user.getIntraId()); - - //when - //200 성공 - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - UserDetailAdminResponseDto actureResponse = objectMapper.readValue(contentAsString, UserDetailAdminResponseDto.class); - - //then - Assertions.assertThat(actureResponse.getUserId()).isEqualTo(expectedResponse.getUserId()); - Assertions.assertThat(actureResponse.getIntraId()).isEqualTo(expectedResponse.getIntraId()); - Assertions.assertThat(actureResponse.getUserImageUri()).isEqualTo(expectedResponse.getUserImageUri()); - Assertions.assertThat(actureResponse.getRacketType()).isEqualTo(expectedResponse.getRacketType()); -// Assertions.assertThat(actureResponse.getStatusMessage()).isEqualTo(expecxtedResponse.getStatusMessage()); - Assertions.assertThat(actureResponse.getWins()).isEqualTo(expectedResponse.getWins()); - Assertions.assertThat(actureResponse.getLosses()).isEqualTo(expectedResponse.getLosses()); - Assertions.assertThat(actureResponse.getPpp()).isEqualTo(expectedResponse.getPpp()); - Assertions.assertThat(actureResponse.getEmail()).isEqualTo(expectedResponse.getEmail()); - Assertions.assertThat(actureResponse.getRoleType()).isEqualTo(expectedResponse.getRoleType()); - Assertions.assertThat(actureResponse.getExp()).isEqualTo(expectedResponse.getExp()); - Assertions.assertThat(actureResponse.getCoin()).isEqualTo(expectedResponse.getCoin()); - } - - /** - * 추가적으로 의도 확인이 필요한 테스트 - * @throws Exception - */ - @Test - @DisplayName("DELETE /pingpong/admin/users/{intraId}") - @Transactional - public void deleteUserProfileImageTest() throws Exception{ - //given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User klew = testDataUtils.createNewUser("klew"); - User user = userRepository.findByIntraId(klew.getIntraId()).get(); - testDataUtils.createUserImages(user, 2); - String url = "/pingpong/admin/users/images/" + user.getIntraId(); - UserImage PrevUserImage = userImageAdminRepository.findTopByUserAndIsCurrentIsTrueOrderByCreatedAtDesc(user).orElseThrow(UserNotFoundException::new); - //when - //200 성공 - mockMvc.perform(delete(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNoContent()); - -// UserImage CurrentUserImage = userImageAdminRepository.findTopByUserAndIsCurrentIsTrueOrderByCreatedAtDesc(user).orElseThrow(UserNotFoundException::new); -// Assertions.assertThat(PrevUserImage.getId()).isNotEqualTo(CurrentUserImage.getId()); - } - - @Test - @DisplayName("GET /pingpong/admin/users/delete-list") - @Transactional - public void getUserImageDeleteListTest() throws Exception{ - //given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - int page = 1; - int size = 30; - String url = "/pingpong/admin/users/delete-list?page=1"; - - //when - //200 성공 - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - UserImageListAdminResponseDto actureResponse = objectMapper.readValue(contentAsString, UserImageListAdminResponseDto.class); - - //then - //각 유저의 이미지가 삭제된 이미지인지 확인 - List actureUserImageList = actureResponse.getUserImageList(); - for (UserImageAdminDto userImageDto : actureUserImageList) - Assertions.assertThat(userImageDto.getDeletedAt()).isNotEqualTo(null); - } - - @Test - @DisplayName("GET /pingpong/admin/users/images") - @Transactional - public void getUserImageListTest() throws Exception{ - //given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - String url = "/pingpong/admin/users/images?page=1"; - testDataUtils.createUserImages(testDataUtils.createNewUser(), 4); - - //when - //200 성공 - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - //then - //각 유저의 이미지가 삭제된 이미지인지 확인 - UserImageListAdminResponseDto actureResponse = objectMapper.readValue(contentAsString, UserImageListAdminResponseDto.class); - assertThat(actureResponse.getUserImageList().size()).isEqualTo(3); - } - - @Test - @DisplayName("GET /pingpong/admin/users/images/{intraId}") - @Transactional - public void getUserImageListByIntraIdTest() throws Exception{ - //given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - User user = testDataUtils.createNewUser("klew"); - String url = "/pingpong/admin/users/images/" + user.getIntraId() + "?page=1"; - testDataUtils.createUserImages(user, 3); - - //when - //200 성공 - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - //then - //각 유저의 이미지가 삭제된 이미지인지 확인 - UserImageListAdminResponseDto actureResponse = objectMapper.readValue(contentAsString, UserImageListAdminResponseDto.class); - assertThat(actureResponse.getUserImageList().size()).isEqualTo(2); - } -} \ No newline at end of file +package com.gg.server.admin.user.controller; + +import static org.assertj.core.api.Assertions.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.util.List; + +import javax.transaction.Transactional; + +import org.apache.http.HttpHeaders; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.test.web.servlet.MockMvc; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.admin.user.data.UserAdminRepository; +import com.gg.server.admin.user.data.UserImageAdminRepository; +import com.gg.server.admin.user.dto.UserDetailAdminResponseDto; +import com.gg.server.admin.user.dto.UserImageAdminDto; +import com.gg.server.admin.user.dto.UserImageListAdminResponseDto; +import com.gg.server.admin.user.dto.UserSearchAdminDto; +import com.gg.server.admin.user.dto.UserSearchAdminResponseDto; +import com.gg.server.admin.user.service.UserAdminService; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserImage; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.exception.UserNotFoundException; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@IntegrationTest +@AutoConfigureMockMvc +class UserAdminControllerTest { + + @Autowired + UserAdminService userAdminService; + @Autowired + TestDataUtils testDataUtils; + @Autowired + AuthTokenProvider tokenProvider; + @Autowired + UserRepository userRepository; + @Autowired + UserAdminRepository userAdminRepository; + @Autowired + MockMvc mockMvc; + @Autowired + ObjectMapper objectMapper; + @Autowired + UserImageAdminRepository userImageAdminRepository; + + @BeforeEach + public void setUp() { + testDataUtils.createTierSystem("pingpong"); + testDataUtils.createSeason(); + } + + @Test + @DisplayName("GET /pingpong/admin/users") + @Transactional + public void userSearchAllTest() throws Exception { + //given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.findById(userId).get(); + int page = 1; + int size = 20; + Pageable pageable = PageRequest.of(page - 1, size, Sort.by("intraId").ascending()); + String url = "/pingpong/admin/users?page=1"; + String url2 = "/pingpong/admin/users?page=1&intraId=" + user.getIntraId(); + //when + //200 성공 + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + UserSearchAdminResponseDto actureResponse1 = objectMapper.readValue(contentAsString, + UserSearchAdminResponseDto.class); + //200 성공 + contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + UserSearchAdminResponseDto actureResponse2 = objectMapper.readValue(contentAsString, + UserSearchAdminResponseDto.class); + + //then + List userList1 = userAdminRepository.findAll(pageable).getContent(); + List actureUserList1 = actureResponse1.getUserSearchAdminDtos(); + for (int i = 0; i < userList1.size(); i++) { + Assertions.assertThat(userList1.get(i).getIntraId()).isEqualTo(actureUserList1.get(i).getIntraId()); + } + + List userList2 = userAdminRepository.findAll(pageable).getContent(); + List actureUserList2 = actureResponse2.getUserSearchAdminDtos(); + for (int i = 0; i < userList1.size(); i++) { + Assertions.assertThat(userList2.get(i).getIntraId()).isEqualTo(actureUserList2.get(i).getIntraId()); + } + } + + @Test + @DisplayName("유저 필터링 조회 테스트") + @Transactional + public void userFiltering() throws Exception { + //given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.findById(userId).get(); + int page = 1; + int size = 20; + Pageable pageable = PageRequest.of(page - 1, size, Sort.by("intraId").ascending()); + String url = "/pingpong/admin/users?page=1&userFilter=\"" + user.getIntraId() + "\""; + + //when + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, + "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + UserSearchAdminResponseDto actureResponse = objectMapper.readValue(contentAsString, + UserSearchAdminResponseDto.class); + + List actureUserList = actureResponse.getUserSearchAdminDtos(); + for (UserSearchAdminDto userDto : actureUserList) { + Assertions.assertThat(userDto.getIntraId()).isEqualTo(user.getIntraId()); + } + } + + @Test + @DisplayName("GET /pingpong/admin/users/{intraId}") + @Transactional + public void userGetDetailTest() throws Exception { + //given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = testDataUtils.createNewUser("nheo"); + User target = userRepository.findByIntraId(user.getIntraId()).get(); + String url = "/pingpong/admin/users/" + user.getIntraId(); + UserDetailAdminResponseDto expectedResponse = userAdminService.getUserDetailByIntraId(user.getIntraId()); + + //when + //200 성공 + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + UserDetailAdminResponseDto actureResponse = objectMapper.readValue(contentAsString, + UserDetailAdminResponseDto.class); + + //then + Assertions.assertThat(actureResponse.getUserId()).isEqualTo(expectedResponse.getUserId()); + Assertions.assertThat(actureResponse.getIntraId()).isEqualTo(expectedResponse.getIntraId()); + Assertions.assertThat(actureResponse.getUserImageUri()).isEqualTo(expectedResponse.getUserImageUri()); + Assertions.assertThat(actureResponse.getRacketType()).isEqualTo(expectedResponse.getRacketType()); + Assertions.assertThat(actureResponse.getWins()).isEqualTo(expectedResponse.getWins()); + Assertions.assertThat(actureResponse.getLosses()).isEqualTo(expectedResponse.getLosses()); + Assertions.assertThat(actureResponse.getPpp()).isEqualTo(expectedResponse.getPpp()); + Assertions.assertThat(actureResponse.getEmail()).isEqualTo(expectedResponse.getEmail()); + Assertions.assertThat(actureResponse.getRoleType()).isEqualTo(expectedResponse.getRoleType()); + Assertions.assertThat(actureResponse.getExp()).isEqualTo(expectedResponse.getExp()); + Assertions.assertThat(actureResponse.getCoin()).isEqualTo(expectedResponse.getCoin()); + } + + /** + * 추가적으로 의도 확인이 필요한 테스트 + * @throws Exception + */ + @Test + @DisplayName("DELETE /pingpong/admin/users/{intraId}") + @Transactional + public void deleteUserProfileImageTest() throws Exception { + //given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User klew = testDataUtils.createNewUser("klew"); + User user = userRepository.findByIntraId(klew.getIntraId()).get(); + testDataUtils.createUserImages(user, 2); + String url = "/pingpong/admin/users/images/" + user.getIntraId(); + UserImage prevUserImage = userImageAdminRepository.findTopByUserAndIsCurrentIsTrueOrderByCreatedAtDesc(user) + .orElseThrow(UserNotFoundException::new); + //when + //200 성공 + mockMvc.perform(delete(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNoContent()); + } + + @Test + @DisplayName("GET /pingpong/admin/users/delete-list") + @Transactional + public void getUserImageDeleteListTest() throws Exception { + //given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + int page = 1; + int size = 30; + String url = "/pingpong/admin/users/delete-list?page=1"; + + //when + //200 성공 + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + UserImageListAdminResponseDto actureResponse = objectMapper.readValue(contentAsString, + UserImageListAdminResponseDto.class); + + //then + //각 유저의 이미지가 삭제된 이미지인지 확인 + List actureUserImageList = actureResponse.getUserImageList(); + for (UserImageAdminDto userImageDto : actureUserImageList) { + Assertions.assertThat(userImageDto.getDeletedAt()).isNotEqualTo(null); + } + } + + @Test + @DisplayName("GET /pingpong/admin/users/images") + @Transactional + public void getUserImageListTest() throws Exception { + //given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + String url = "/pingpong/admin/users/images?page=1"; + testDataUtils.createUserImages(testDataUtils.createNewUser(), 4); + + //when + //200 성공 + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + //then + //각 유저의 이미지가 삭제된 이미지인지 확인 + UserImageListAdminResponseDto actureResponse = objectMapper.readValue(contentAsString, + UserImageListAdminResponseDto.class); + assertThat(actureResponse.getUserImageList().size()).isEqualTo(3); + } + + @Test + @DisplayName("GET /pingpong/admin/users/images/{intraId}") + @Transactional + public void getUserImageListByIntraIdTest() throws Exception { + //given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + User user = testDataUtils.createNewUser("klew"); + String url = "/pingpong/admin/users/images/" + user.getIntraId() + "?page=1"; + testDataUtils.createUserImages(user, 3); + + //when + //200 성공 + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + //then + //각 유저의 이미지가 삭제된 이미지인지 확인 + UserImageListAdminResponseDto actureResponse = objectMapper.readValue(contentAsString, + UserImageListAdminResponseDto.class); + assertThat(actureResponse.getUserImageList().size()).isEqualTo(2); + } +} diff --git a/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerTest.java b/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerTest.java index edc75ffd6..8f1e3ce24 100644 --- a/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerTest.java +++ b/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerTest.java @@ -1,18 +1,10 @@ package com.gg.server.domain.announcement.controller; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.announcement.data.Announcement; -import com.gg.server.domain.announcement.data.AnnouncementRepository; -import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; -import com.gg.server.domain.user.data.User; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; import java.time.LocalDateTime; -import lombok.RequiredArgsConstructor; + import org.apache.http.HttpHeaders; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -22,62 +14,72 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.domain.announcement.data.Announcement; +import com.gg.server.domain.announcement.data.AnnouncementRepository; +import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; +import com.gg.server.domain.user.data.User; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; + @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc class AnnouncementControllerTest { - @Autowired - TestDataUtils testDataUtils; - - @Autowired - private MockMvc mockMvc; + @Autowired + TestDataUtils testDataUtils; - @Autowired - ObjectMapper objectMapper; + @Autowired + private MockMvc mockMvc; - @Autowired - AuthTokenProvider tokenProvider; + @Autowired + ObjectMapper objectMapper; - @Autowired - AnnouncementRepository announcementRepository; + @Autowired + AuthTokenProvider tokenProvider; - @BeforeEach - void setUp() { - User admin = testDataUtils.createAdminUser(); - testDataUtils.createAnnouncements(admin, 5); - } + @Autowired + AnnouncementRepository announcementRepository; - @Test - @Transactional - @DisplayName("[GET]/pingpong/announcement") - void getAnnouncement() throws Exception { - String accessToken = testDataUtils.getLoginAccessToken(); + @BeforeEach + void setUp() { + User admin = testDataUtils.createAdminUser(); + testDataUtils.createAnnouncements(admin, 5); + } - String contentAsString = mockMvc.perform(get("/pingpong/announcement") - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); + @Test + @Transactional + @DisplayName("[GET]/pingpong/announcement") + void getAnnouncement() throws Exception { + String accessToken = testDataUtils.getLoginAccessToken(); - System.out.println(contentAsString); - } + String contentAsString = mockMvc.perform(get("/pingpong/announcement") + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + System.out.println(contentAsString); + } - @Test - @Transactional - @DisplayName("[GET]/pingpong/announcement") - void getAnnouncementEmpty() throws Exception { - String accessToken = testDataUtils.getLoginAccessToken(); - Announcement announcement = announcementRepository.findFirstByOrderByIdDesc() - .orElseThrow(AnnounceNotFoundException::new); + @Test + @Transactional + @DisplayName("[GET]/pingpong/announcement") + void getAnnouncementEmpty() throws Exception { + String accessToken = testDataUtils.getLoginAccessToken(); + Announcement announcement = announcementRepository.findFirstByOrderByIdDesc() + .orElseThrow(AnnounceNotFoundException::new); - announcement.update("testId", LocalDateTime.now()); + announcement.update("testId", LocalDateTime.now()); - String contentAsString = mockMvc.perform(get("/pingpong/announcement") - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); + String contentAsString = mockMvc.perform(get("/pingpong/announcement") + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); - System.out.println(contentAsString); - } + System.out.println(contentAsString); + } -} \ No newline at end of file +} diff --git a/src/test/java/com/gg/server/domain/coin/service/CoinHistoryServiceTest.java b/src/test/java/com/gg/server/domain/coin/service/CoinHistoryServiceTest.java index ab849ca07..8cc1d8cff 100644 --- a/src/test/java/com/gg/server/domain/coin/service/CoinHistoryServiceTest.java +++ b/src/test/java/com/gg/server/domain/coin/service/CoinHistoryServiceTest.java @@ -1,8 +1,15 @@ package com.gg.server.domain.coin.service; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.*; + +import java.util.List; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; -import com.gg.server.utils.annotation.IntegrationTest; import com.gg.server.domain.coin.data.CoinHistory; import com.gg.server.domain.coin.data.CoinHistoryRepository; import com.gg.server.domain.coin.data.CoinPolicy; @@ -11,144 +18,139 @@ import com.gg.server.domain.user.data.UserRepository; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; -import java.util.List; +import com.gg.server.utils.annotation.IntegrationTest; + import lombok.RequiredArgsConstructor; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; @IntegrationTest @RequiredArgsConstructor @Transactional class CoinHistoryServiceTest { - @Autowired - TestDataUtils testDataUtils; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - CoinHistoryService coinHistoryService; - - @Autowired - CoinHistoryRepository coinHistoryRepository; - - @Autowired - UserRepository userRepository; - - @Autowired - CoinPolicyRepository coinPolicyRepository; - - @BeforeEach - void beforeEach() { - CoinPolicy coinPolicy = CoinPolicy.builder() - .user(testDataUtils.createAdminUser()) - .attendance(1) - .normal(3) - .rankWin(10) - .rankLose(5) - .build(); - coinPolicyRepository.save(coinPolicy); - } - - @Test - @DisplayName("출석 재화이력 등록") - void addAttendanceCoinHistory() { - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.getById(userId); - - int beforeCoinHistoryCount = coinHistoryRepository.findAllByUserOrderByIdDesc(user).size(); - - coinHistoryService.addAttendanceCoinHistory(user); - - List afterCoinHistory = coinHistoryRepository.findAllByUserOrderByIdDesc(user); - - assertThat(beforeCoinHistoryCount).isEqualTo(afterCoinHistory.size() - 1); - - System.out.println(beforeCoinHistoryCount + " < " + afterCoinHistory.size()); - for(CoinHistory ch : afterCoinHistory){ - System.out.println("이력 : " + ch.getHistory()); - System.out.println("사용값 : " + ch.getAmount()); - System.out.println("사용자 : " + ch.getUser().getIntraId()); - System.out.println("생성날짜 : " + ch.getCreatedAt()); - } - } - - @Test - @DisplayName("일반게임 재화이력 등록") - void addNormalCoin() { - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.getById(userId); - - int beforeCoinHistoryCount = coinHistoryRepository.findAllByUserOrderByIdDesc(user).size(); - - coinHistoryService.addNormalCoin(user); - - List afterCoinHistory = coinHistoryRepository.findAllByUserOrderByIdDesc(user); - - assertThat(beforeCoinHistoryCount).isEqualTo(afterCoinHistory.size() - 1); - - System.out.println(beforeCoinHistoryCount + " < " + afterCoinHistory.size()); - for(CoinHistory ch : afterCoinHistory){ - System.out.println("이력 : " + ch.getHistory()); - System.out.println("사용값 : " + ch.getAmount()); - System.out.println("사용자 : " + ch.getUser().getIntraId()); - System.out.println("생성날짜 : " + ch.getCreatedAt()); - } - - - } - - @Test - @DisplayName("랭크게임 win 재화이력 등록") - void addRankWinCoin() { - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.getById(userId); - - int beforeCoinHistoryCount = coinHistoryRepository.findAllByUserOrderByIdDesc(user).size(); + @Autowired + TestDataUtils testDataUtils; - coinHistoryService.addRankWinCoin(user); + @Autowired + AuthTokenProvider tokenProvider; - List afterCoinHistory = coinHistoryRepository.findAllByUserOrderByIdDesc(user); + @Autowired + CoinHistoryService coinHistoryService; + + @Autowired + CoinHistoryRepository coinHistoryRepository; - assertThat(beforeCoinHistoryCount).isEqualTo(afterCoinHistory.size() - 1); + @Autowired + UserRepository userRepository; - System.out.println(beforeCoinHistoryCount + " < " + afterCoinHistory.size()); - for(CoinHistory ch : afterCoinHistory){ - System.out.println("이력 : " + ch.getHistory()); - System.out.println("사용값 : " + ch.getAmount()); - System.out.println("사용자 : " + ch.getUser().getIntraId()); - System.out.println("생성날짜 : " + ch.getCreatedAt()); - } - } + @Autowired + CoinPolicyRepository coinPolicyRepository; - @Test - @DisplayName("랭크게임 lose 재화이력 등록") - void addRankLoseCoin() { - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.getById(userId); + @BeforeEach + void beforeEach() { + CoinPolicy coinPolicy = CoinPolicy.builder() + .user(testDataUtils.createAdminUser()) + .attendance(1) + .normal(3) + .rankWin(10) + .rankLose(5) + .build(); + coinPolicyRepository.save(coinPolicy); + } + + @Test + @DisplayName("출석 재화이력 등록") + void addAttendanceCoinHistory() { + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.getById(userId); + + int beforeCoinHistoryCount = coinHistoryRepository.findAllByUserOrderByIdDesc(user).size(); + + coinHistoryService.addAttendanceCoinHistory(user); + + List afterCoinHistory = coinHistoryRepository.findAllByUserOrderByIdDesc(user); + + assertThat(beforeCoinHistoryCount).isEqualTo(afterCoinHistory.size() - 1); + + System.out.println(beforeCoinHistoryCount + " < " + afterCoinHistory.size()); + for (CoinHistory ch : afterCoinHistory) { + System.out.println("이력 : " + ch.getHistory()); + System.out.println("사용값 : " + ch.getAmount()); + System.out.println("사용자 : " + ch.getUser().getIntraId()); + System.out.println("생성날짜 : " + ch.getCreatedAt()); + } + } + + @Test + @DisplayName("일반게임 재화이력 등록") + void addNormalCoin() { + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.getById(userId); + + int beforeCoinHistoryCount = coinHistoryRepository.findAllByUserOrderByIdDesc(user).size(); + + coinHistoryService.addNormalCoin(user); + + List afterCoinHistory = coinHistoryRepository.findAllByUserOrderByIdDesc(user); + + assertThat(beforeCoinHistoryCount).isEqualTo(afterCoinHistory.size() - 1); + + System.out.println(beforeCoinHistoryCount + " < " + afterCoinHistory.size()); + for (CoinHistory ch : afterCoinHistory) { + System.out.println("이력 : " + ch.getHistory()); + System.out.println("사용값 : " + ch.getAmount()); + System.out.println("사용자 : " + ch.getUser().getIntraId()); + System.out.println("생성날짜 : " + ch.getCreatedAt()); + } + + } + + @Test + @DisplayName("랭크게임 win 재화이력 등록") + void addRankWinCoin() { + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.getById(userId); + + int beforeCoinHistoryCount = coinHistoryRepository.findAllByUserOrderByIdDesc(user).size(); + + coinHistoryService.addRankWinCoin(user); + + List afterCoinHistory = coinHistoryRepository.findAllByUserOrderByIdDesc(user); + + assertThat(beforeCoinHistoryCount).isEqualTo(afterCoinHistory.size() - 1); + + System.out.println(beforeCoinHistoryCount + " < " + afterCoinHistory.size()); + for (CoinHistory ch : afterCoinHistory) { + System.out.println("이력 : " + ch.getHistory()); + System.out.println("사용값 : " + ch.getAmount()); + System.out.println("사용자 : " + ch.getUser().getIntraId()); + System.out.println("생성날짜 : " + ch.getCreatedAt()); + } + } - int beforeCoinHistoryCount = coinHistoryRepository.findAllByUserOrderByIdDesc(user).size(); - - coinHistoryService.addRankLoseCoin(user); - coinHistoryService.addRankLoseCoin(user); - - List afterCoinHistory = coinHistoryRepository.findAllByUserOrderByIdDesc(user); - - assertThat(beforeCoinHistoryCount).isEqualTo(afterCoinHistory.size() - 2); - - System.out.println(beforeCoinHistoryCount + " < " + afterCoinHistory.size()); - for(CoinHistory ch : afterCoinHistory){ - System.out.println("이력 : " + ch.getHistory()); - System.out.println("사용값 : " + ch.getAmount()); - System.out.println("사용자 : " + ch.getUser().getIntraId()); - System.out.println("생성날짜 : " + ch.getCreatedAt()); - } - } -} \ No newline at end of file + @Test + @DisplayName("랭크게임 lose 재화이력 등록") + void addRankLoseCoin() { + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.getById(userId); + + int beforeCoinHistoryCount = coinHistoryRepository.findAllByUserOrderByIdDesc(user).size(); + + coinHistoryService.addRankLoseCoin(user); + coinHistoryService.addRankLoseCoin(user); + + List afterCoinHistory = coinHistoryRepository.findAllByUserOrderByIdDesc(user); + + assertThat(beforeCoinHistoryCount).isEqualTo(afterCoinHistory.size() - 2); + + System.out.println(beforeCoinHistoryCount + " < " + afterCoinHistory.size()); + for (CoinHistory ch : afterCoinHistory) { + System.out.println("이력 : " + ch.getHistory()); + System.out.println("사용값 : " + ch.getAmount()); + System.out.println("사용자 : " + ch.getUser().getIntraId()); + System.out.println("생성날짜 : " + ch.getCreatedAt()); + } + } +} diff --git a/src/test/java/com/gg/server/domain/coin/service/UserCoinChangeServiceTest.java b/src/test/java/com/gg/server/domain/coin/service/UserCoinChangeServiceTest.java index 6590eb462..632ea5567 100644 --- a/src/test/java/com/gg/server/domain/coin/service/UserCoinChangeServiceTest.java +++ b/src/test/java/com/gg/server/domain/coin/service/UserCoinChangeServiceTest.java @@ -1,8 +1,15 @@ package com.gg.server.domain.coin.service; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.*; + +import java.time.LocalDateTime; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; -import com.gg.server.utils.annotation.IntegrationTest; import com.gg.server.domain.coin.data.CoinHistoryRepository; import com.gg.server.domain.coin.data.CoinPolicy; import com.gg.server.domain.coin.data.CoinPolicyRepository; @@ -19,204 +26,202 @@ import com.gg.server.domain.user.data.UserRepository; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; -import java.time.LocalDateTime; +import com.gg.server.utils.annotation.IntegrationTest; + import lombok.RequiredArgsConstructor; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; @IntegrationTest @RequiredArgsConstructor @Transactional class UserCoinChangeServiceTest { - @Autowired - TestDataUtils testDataUtils; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - CoinHistoryService coinHistoryService; - - @Autowired - CoinHistoryRepository coinHistoryRepository; - - @Autowired - CoinPolicyRepository coinPolicyRepository; - - @Autowired - UserRepository userRepository; - - @Autowired - UserCoinChangeService userCoinChangeService; - - @Autowired - ItemRepository itemRepository; - - User admin; - - @BeforeEach - void init() { - admin = testDataUtils.createAdminUser(); - } - - @Test - @DisplayName("출석시 재화 증가 서비스 테스트") - void addAttendanceCoin() { - CoinPolicy coinPolicy = CoinPolicy.builder().user(admin).attendance(100).build(); - coinPolicyRepository.save(coinPolicy); - - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.getById(userId); - - int beforeCoin = user.getGgCoin(); - - int coinIncrement = userCoinChangeService.addAttendanceCoin(user); - - assertThat(beforeCoin + coinIncrement).isEqualTo(user.getGgCoin()); - assertThat(coinPolicyRepository.findTopByOrderByCreatedAtDesc() - .orElseThrow(() -> new CoinPolicyNotFoundException()).getAttendance()).isEqualTo(coinIncrement); - System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); - - try{ - coinIncrement = userCoinChangeService.addAttendanceCoin(user); - }catch (Exception e){ - System.out.println(e.getMessage() + " " + e); - System.out.println("===출석 중복 제거 기능 수행 완료==="); - } - } - - @Test - @DisplayName("아이템 구매시 코인사용 테스트") - void purchaseItemCoin() { - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.getById(userId); - user.addGgCoin(100); - int beforeCoin = user.getGgCoin(); - - Item item = new Item("과자", "111", "1", "1", 100, true, 0, - ItemType.EDGE,LocalDateTime.now(), user.getIntraId()); - itemRepository.save(item); - - userCoinChangeService.purchaseItemCoin(item, item.getPrice(), userId); - - assertThat(beforeCoin).isEqualTo(user.getGgCoin() + item.getPrice()); - System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()+coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getAmount()); - System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); - try{ - userCoinChangeService.purchaseItemCoin(item, item.getPrice(), userId); - }catch (Exception e){ - System.out.println(e.getMessage() + " " + e); - System.out.println("===coin이 없을 때 방어로직 기능 수행 완료==="); - } - } - - @Test - @DisplayName("아이템 선물시 코인사용 테스트") - void giftItemCoin() { - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.getById(userId); - user.addGgCoin(100); - int beforeCoin = user.getGgCoin(); - - Item item = new Item("과자", "111", "1", "1", 100, true, 0, - ItemType.EDGE,LocalDateTime.now(), user.getIntraId()); - itemRepository.save(item); - - userCoinChangeService.giftItemCoin(item, item.getPrice(), user, user); - - assertThat(beforeCoin).isEqualTo(user.getGgCoin() + item.getPrice()); - System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory() - +coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getAmount()); - System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); - - try{ - userCoinChangeService.giftItemCoin(item, item.getPrice(), user, user); - }catch (Exception e){ - System.out.println(e.getMessage() + " " + e); - System.out.println("===coin이 없을 때 방어로직 기능 수행 완료==="); - } - } - - @Test - @DisplayName("노말 게임 재화 증가 서비스 테스트") - void addNormalGameService() { - CoinPolicy coinPolicy = CoinPolicy.builder().user(admin).normal(100).build(); - coinPolicyRepository.save(coinPolicy); - - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.getById(userId); - - UserGameCoinResultDto userGameCoinResultDto = userCoinChangeService.addNormalGameCoin(userId); - - assertThat(user.getGgCoin()).isEqualTo(userGameCoinResultDto.getAfterCoin()); - assertThat(coinPolicyRepository.findTopByOrderByCreatedAtDesc() - .orElseThrow(() -> new CoinPolicyNotFoundException()).getNormal()).isEqualTo(userGameCoinResultDto.getCoinIncrement()); - System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); - } - - @Test - @DisplayName("랭크 게임 승리 재화 증가 서비스 테스트") - void addRankWinGameService() { - CoinPolicy coinPolicy = CoinPolicy.builder().user(admin).rankWin(100).build(); - coinPolicyRepository.save(coinPolicy); - - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.getById(userId); - - Season season = testDataUtils.createSeason(); - Game mockMatch = testDataUtils.createMockMatch(user, season, - LocalDateTime.now().minusMinutes(20), - LocalDateTime.now().minusMinutes(5), Mode.RANK, 2, 1); - UserGameCoinResultDto userGameCoinResultDto = userCoinChangeService - .addRankGameCoin(mockMatch.getId(), user.getId());//본인의 게임Id와 id 값 - - assertThat(user.getGgCoin()).isEqualTo(userGameCoinResultDto.getAfterCoin()); - assertThat(coinPolicyRepository.findTopByOrderByCreatedAtDesc() - .orElseThrow(() -> new CoinPolicyNotFoundException()).getRankWin()) - .isEqualTo(userGameCoinResultDto.getCoinIncrement()); - System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); - } - - @Test - @DisplayName("랭크 게임 패배 재화 증가 서비스 테스트") - void addRankLoseGameService() { - CoinPolicy coinPolicy = CoinPolicy.builder().user(admin).rankLose(100).build(); - coinPolicyRepository.save(coinPolicy); - - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.getById(userId); - - Season season = testDataUtils.createSeason(); - Game mockMatch = testDataUtils.createMockMatch(user, season, - LocalDateTime.now().minusMinutes(20), - LocalDateTime.now().minusMinutes(5), Mode.RANK, 1, 2); - - UserGameCoinResultDto userGameCoinResultDto = userCoinChangeService - .addRankGameCoin(mockMatch.getId(), user.getId()); - - assertThat(user.getGgCoin()).isEqualTo(userGameCoinResultDto.getAfterCoin()); - assertThat(coinPolicyRepository.findTopByOrderByCreatedAtDesc() - .orElseThrow(() -> new CoinPolicyNotFoundException()).getRankLose()) - .isEqualTo(userGameCoinResultDto.getCoinIncrement()); - System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); - } -} \ No newline at end of file + @Autowired + TestDataUtils testDataUtils; + + @Autowired + AuthTokenProvider tokenProvider; + + @Autowired + CoinHistoryService coinHistoryService; + + @Autowired + CoinHistoryRepository coinHistoryRepository; + + @Autowired + CoinPolicyRepository coinPolicyRepository; + + @Autowired + UserRepository userRepository; + + @Autowired + UserCoinChangeService userCoinChangeService; + + @Autowired + ItemRepository itemRepository; + + User admin; + + @BeforeEach + void init() { + admin = testDataUtils.createAdminUser(); + } + + @Test + @DisplayName("출석시 재화 증가 서비스 테스트") + void addAttendanceCoin() { + CoinPolicy coinPolicy = CoinPolicy.builder().user(admin).attendance(100).build(); + coinPolicyRepository.save(coinPolicy); + + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.getById(userId); + + int beforeCoin = user.getGgCoin(); + + int coinIncrement = userCoinChangeService.addAttendanceCoin(user); + + assertThat(beforeCoin + coinIncrement).isEqualTo(user.getGgCoin()); + assertThat(coinPolicyRepository.findTopByOrderByCreatedAtDesc() + .orElseThrow(() -> new CoinPolicyNotFoundException()).getAttendance()).isEqualTo(coinIncrement); + System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); + + try { + coinIncrement = userCoinChangeService.addAttendanceCoin(user); + } catch (Exception e) { + System.out.println(e.getMessage() + " " + e); + System.out.println("===출석 중복 제거 기능 수행 완료==="); + } + } + + @Test + @DisplayName("아이템 구매시 코인사용 테스트") + void purchaseItemCoin() { + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.getById(userId); + user.addGgCoin(100); + int beforeCoin = user.getGgCoin(); + + Item item = new Item("과자", "111", "1", "1", 100, true, 0, + ItemType.EDGE, LocalDateTime.now(), user.getIntraId()); + itemRepository.save(item); + + userCoinChangeService.purchaseItemCoin(item, item.getPrice(), userId); + + assertThat(beforeCoin).isEqualTo(user.getGgCoin() + item.getPrice()); + System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory() + + coinHistoryRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new CoinHistoryNotFoundException()).getAmount()); + System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); + try { + userCoinChangeService.purchaseItemCoin(item, item.getPrice(), userId); + } catch (Exception e) { + System.out.println(e.getMessage() + " " + e); + System.out.println("===coin이 없을 때 방어로직 기능 수행 완료==="); + } + } + + @Test + @DisplayName("아이템 선물시 코인사용 테스트") + void giftItemCoin() { + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.getById(userId); + user.addGgCoin(100); + int beforeCoin = user.getGgCoin(); + + Item item = new Item("과자", "111", "1", "1", 100, true, 0, + ItemType.EDGE, LocalDateTime.now(), user.getIntraId()); + itemRepository.save(item); + + userCoinChangeService.giftItemCoin(item, item.getPrice(), user, user); + + assertThat(beforeCoin).isEqualTo(user.getGgCoin() + item.getPrice()); + System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory() + + coinHistoryRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new CoinHistoryNotFoundException()).getAmount()); + System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); + + try { + userCoinChangeService.giftItemCoin(item, item.getPrice(), user, user); + } catch (Exception e) { + System.out.println(e.getMessage() + " " + e); + System.out.println("===coin이 없을 때 방어로직 기능 수행 완료==="); + } + } + + @Test + @DisplayName("노말 게임 재화 증가 서비스 테스트") + void addNormalGameService() { + CoinPolicy coinPolicy = CoinPolicy.builder().user(admin).normal(100).build(); + coinPolicyRepository.save(coinPolicy); + + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.getById(userId); + + UserGameCoinResultDto userGameCoinResultDto = userCoinChangeService.addNormalGameCoin(userId); + + assertThat(user.getGgCoin()).isEqualTo(userGameCoinResultDto.getAfterCoin()); + assertThat(coinPolicyRepository.findTopByOrderByCreatedAtDesc() + .orElseThrow(() -> new CoinPolicyNotFoundException()).getNormal()).isEqualTo( + userGameCoinResultDto.getCoinIncrement()); + System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); + } + + @Test + @DisplayName("랭크 게임 승리 재화 증가 서비스 테스트") + void addRankWinGameService() { + CoinPolicy coinPolicy = CoinPolicy.builder().user(admin).rankWin(100).build(); + coinPolicyRepository.save(coinPolicy); + + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.getById(userId); + + Season season = testDataUtils.createSeason(); + Game mockMatch = testDataUtils.createMockMatch(user, season, + LocalDateTime.now().minusMinutes(20), + LocalDateTime.now().minusMinutes(5), Mode.RANK, 2, 1); + UserGameCoinResultDto userGameCoinResultDto = userCoinChangeService + .addRankGameCoin(mockMatch.getId(), user.getId()); //본인의 게임Id와 id 값 + + assertThat(user.getGgCoin()).isEqualTo(userGameCoinResultDto.getAfterCoin()); + assertThat(coinPolicyRepository.findTopByOrderByCreatedAtDesc() + .orElseThrow(() -> new CoinPolicyNotFoundException()).getRankWin()) + .isEqualTo(userGameCoinResultDto.getCoinIncrement()); + System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); + } + + @Test + @DisplayName("랭크 게임 패배 재화 증가 서비스 테스트") + void addRankLoseGameService() { + CoinPolicy coinPolicy = CoinPolicy.builder().user(admin).rankLose(100).build(); + coinPolicyRepository.save(coinPolicy); + + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.getById(userId); + + Season season = testDataUtils.createSeason(); + Game mockMatch = testDataUtils.createMockMatch(user, season, + LocalDateTime.now().minusMinutes(20), + LocalDateTime.now().minusMinutes(5), Mode.RANK, 1, 2); + + UserGameCoinResultDto userGameCoinResultDto = userCoinChangeService + .addRankGameCoin(mockMatch.getId(), user.getId()); + + assertThat(user.getGgCoin()).isEqualTo(userGameCoinResultDto.getAfterCoin()); + assertThat(coinPolicyRepository.findTopByOrderByCreatedAtDesc() + .orElseThrow(() -> new CoinPolicyNotFoundException()).getRankLose()) + .isEqualTo(userGameCoinResultDto.getCoinIncrement()); + System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() + .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); + } +} diff --git a/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerTest.java b/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerTest.java index 7f96f2ef3..106e5da02 100644 --- a/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerTest.java +++ b/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerTest.java @@ -1,14 +1,9 @@ package com.gg.server.domain.feedback.controller; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.feedback.data.Feedback; -import com.gg.server.domain.feedback.data.FeedbackRepository; -import com.gg.server.domain.feedback.dto.FeedbackRequestDto; -import com.gg.server.domain.feedback.type.FeedbackType; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import lombok.RequiredArgsConstructor; +import static org.assertj.core.api.Assertions.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + import org.apache.http.HttpHeaders; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -18,57 +13,64 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.domain.feedback.data.Feedback; +import com.gg.server.domain.feedback.data.FeedbackRepository; +import com.gg.server.domain.feedback.dto.FeedbackRequestDto; +import com.gg.server.domain.feedback.type.FeedbackType; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc class FeedbackControllerTest { - @Autowired - TestDataUtils testDataUtils; + @Autowired + TestDataUtils testDataUtils; - @Autowired - private MockMvc mockMvc; + @Autowired + private MockMvc mockMvc; - @Autowired - ObjectMapper objectMapper; + @Autowired + ObjectMapper objectMapper; - @Autowired - AuthTokenProvider tokenProvider; + @Autowired + AuthTokenProvider tokenProvider; - @Autowired - FeedbackRepository feedbackRepository; + @Autowired + FeedbackRepository feedbackRepository; - @Test - @Transactional - @DisplayName("[Post]/pingpong/feedback") - void getAnnouncementList() throws Exception { - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - System.out.println(userId); + @Test + @Transactional + @DisplayName("[Post]/pingpong/feedback") + void getAnnouncementList() throws Exception { + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + System.out.println(userId); - FeedbackRequestDto addDto = FeedbackRequestDto.builder() - .content("하나하나둘둘테스트") - .category(FeedbackType.ETC) - .build(); + FeedbackRequestDto addDto = FeedbackRequestDto.builder() + .content("하나하나둘둘테스트") + .category(FeedbackType.ETC) + .build(); - String content = objectMapper.writeValueAsString(addDto); - String url = "/pingpong/feedback"; + String content = objectMapper.writeValueAsString(addDto); + String url = "/pingpong/feedback"; - String contentAsString = mockMvc.perform(post(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isCreated()) - .andReturn().getResponse().getContentAsString(); + String contentAsString = mockMvc.perform(post(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isCreated()) + .andReturn().getResponse().getContentAsString(); - Feedback result = feedbackRepository.findFirstByOrderByIdDesc(); - assertThat(result.getCategory()).isEqualTo(addDto.getCategory()); - assertThat(result.getContent()).isEqualTo(addDto.getContent()); + Feedback result = feedbackRepository.findFirstByOrderByIdDesc(); + assertThat(result.getCategory()).isEqualTo(addDto.getCategory()); + assertThat(result.getContent()).isEqualTo(addDto.getContent()); - System.out.println(result.getId() + ", " + result.getUser().getIntraId()); - } + System.out.println(result.getId() + ", " + result.getUser().getIntraId()); + } -} \ No newline at end of file +} diff --git a/src/test/java/com/gg/server/domain/game/GameControllerTest.java b/src/test/java/com/gg/server/domain/game/GameControllerTest.java index 813b5d7dd..8c0bf64c0 100644 --- a/src/test/java/com/gg/server/domain/game/GameControllerTest.java +++ b/src/test/java/com/gg/server/domain/game/GameControllerTest.java @@ -1,776 +1,837 @@ -package com.gg.server.domain.game; - -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.GameListResDto; -import com.gg.server.domain.game.dto.GameTeamInfo; -import com.gg.server.domain.game.dto.request.RankResultReqDto; -import com.gg.server.domain.game.dto.request.TournamentResultReqDto; -import com.gg.server.domain.game.service.GameFindService; -import com.gg.server.domain.game.service.GameService; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.pchange.data.PChange; -import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.rank.data.Rank; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RankRedisService; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.team.data.Team; -import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.tier.data.Tier; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; -import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import lombok.RequiredArgsConstructor; -import org.apache.http.HttpHeaders; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.transaction.annotation.Transactional; - -@IntegrationTest -@AutoConfigureMockMvc -@RequiredArgsConstructor -@Transactional -public class GameControllerTest { - @Autowired - GameRepository gameRepository; - @Autowired - SeasonRepository seasonRepository; - @Autowired - TeamRepository teamRepository; - @Autowired - TeamUserRepository teamUserRepository; - @Autowired - RankRedisRepository rankRedisRepository; - - @Autowired - TierRepository tierRepository; - - @Autowired - PChangeRepository pChangeRepository; - @Autowired - TournamentRepository tournamentRepository; - @Autowired - RankRedisService rankRedisService; - @Autowired - RankRepository rankRepository; - @Autowired - TestDataUtils testDataUtils; - @Autowired - GameService gameService; - @Autowired - GameFindService gameFindService; - @Autowired - private MockMvc mockMvc; - @Autowired - ObjectMapper objectMapper; - @Autowired - AuthTokenProvider tokenProvider; - private String accessToken; - private Season season; - private User user1; - private User user2; - private User user3; - private Game game1; - private Game game2; - ArrayList tiers; - - @BeforeEach - void init() { - tiers = testDataUtils.createTierSystem("pingpong"); - season = seasonRepository.save(new Season("test season", LocalDateTime.of(2023, 7, 14, 0, 0), LocalDateTime.of(2999, 12, 31, 23, 59), - 1000, 100)); - user1 = testDataUtils.createNewUser("test1", "test1@email", RacketType.NONE, SnsType.EMAIL, RoleType.USER); - accessToken = tokenProvider.createToken(user1.getId()); - user2 = testDataUtils.createNewUser("test2", "test2@email", RacketType.NONE, SnsType.EMAIL, RoleType.USER); - Tier tier = tiers.get(0); - rankRepository.save(Rank.from(user1, season, season.getStartPpp(), tier)); - rankRepository.save(Rank.from(user2, season, season.getStartPpp(), tier)); - RankRedis userRank = RankRedis.from(UserDto.from(user1), season.getStartPpp(), tier.getImageUri()); - String redisHashKey = RedisKeyManager.getHashKey(season.getId()); - rankRedisRepository.addRankData(redisHashKey, user1.getId(), userRank); - userRank = RankRedis.from(UserDto.from(user2), season.getStartPpp(), tier.getImageUri()); - rankRedisRepository.addRankData(redisHashKey, user2.getId(), userRank); - - game1 = gameRepository.save(new Game(season, StatusType.END, Mode.RANK, LocalDateTime.now().minusMinutes(15), LocalDateTime.now())); - Team team1 = teamRepository.save(new Team(game1, 1, false)); - Team team2 = teamRepository.save(new Team(game1, 2, true)); - teamUserRepository.save(new TeamUser(team1, user1)); - teamUserRepository.save(new TeamUser(team2, user2)); - game2 = gameRepository.save(new Game(season, StatusType.WAIT, Mode.RANK, LocalDateTime.now().minusMinutes(15), LocalDateTime.now())); - team1 = teamRepository.save(new Team(game2, 1, false)); - team2 = teamRepository.save(new Team(game2, 2, true)); - List teams = new ArrayList<>(); - teams.add(teamUserRepository.save(new TeamUser(team1, user1))); - teams.add(teamUserRepository.save(new TeamUser(team2, user2))); - gameService.expUpdates(game2, teams); - rankRedisService.updateRankRedis(teams.get(0), teams.get(1), game2); - } - - @AfterEach - public void flushRedis() { - rankRedisRepository.deleteAll(); - } - - // GET /pingpong/games/{gameId} - @Nested - @DisplayName("게임 조회 테스트") - class GetGameInfoTest { - /** - * getGameInfo() -> GameFindService.getGameInfo() - */ - @Test - @DisplayName("유저 쿼리 포함 성공") - public void getGameInfoTest() throws Exception { - //given - String url = "/pingpong/games/" + game1.getId().toString(); - GameTeamInfo expect = gameService.getUserGameInfo(game1.getId(), user1.getId()); - // when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - GameTeamInfo result = objectMapper.readValue(contentAsString, GameTeamInfo.class); - System.out.println("expect: " + expect); - System.out.println("result: " + result); - assertThat(result.getGameId()).isEqualTo(expect.getGameId()); - assertThat(result.getStartTime()).isEqualTo(expect.getStartTime()); - assertThat(result.getMatchTeamsInfo().getMyTeam().getTeamId()).isEqualTo(expect.getMatchTeamsInfo().getMyTeam().getTeamId()); - assertThat(result.getMatchTeamsInfo().getEnemyTeam().getTeamId()).isEqualTo(expect.getMatchTeamsInfo().getEnemyTeam().getTeamId()); - } - } - - // GET /pingpong/games/normal - @Nested - @DisplayName("normal 게임 조회") - class NormalGameListTest { - /** - * GET /pingpong/games/normal?page=1&size=10 - * normalGameList() -> GameFindService.normalGameList() - */ - @Test - @DisplayName("조회 성공") - public void success() throws Exception { - //given - testDataUtils.createGame(user1, LocalDateTime.now().minusMinutes(16), - LocalDateTime.now().minusMinutes(1), season, Mode.NORMAL); - String url = "/pingpong/games/normal?page=1&size=10"; - Pageable pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "startTime")); - GameListResDto expect = gameFindService.getNormalGameList(pageable); - //when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - System.out.println(contentAsString); - GameListResDto result = objectMapper.readValue(contentAsString, GameListResDto.class); - //then - System.out.println(result.getGames().size() +", " + result.getIsLast()); - System.out.println(expect.getGames()); - assertThat(result.getGames().size()).isEqualTo(expect.getGames().size()); - assertThat(result.getGames().get(0).getGameId().equals(expect.getGames().get(0).getGameId())); - assertThat(result.getIsLast()).isEqualTo(expect.getIsLast()); - } - - /** - * GET /pingpong/games/normal?page=1&size=10&intraId=test1 - * normalGameList() -> GameFindService.normalGameListByIntra() - */ - @Test - @DisplayName("유저 쿼리 포함 성공") - public void successUserQuery() throws Exception { - //given - String url = "/pingpong/games/normal?page=1&size=10&intraId=test1"; - for (int i = 0; i < 10; i++) { - Game game = gameRepository.save(new Game(season, StatusType.WAIT, Mode.RANK, LocalDateTime.now().minusMinutes(15), LocalDateTime.now())); - Team team1 = teamRepository.save(new Team(game, 1, false)); - Team team2 = teamRepository.save(new Team(game, 2, true)); - List teams = new ArrayList<>(); - teams.add(teamUserRepository.save(new TeamUser(team1, user1))); - teams.add(teamUserRepository.save(new TeamUser(team2, user2))); - gameService.expUpdates(game, teams); - rankRedisService.updateRankRedis(teams.get(0), teams.get(1), game); - game = gameRepository.save(new Game(season, StatusType.WAIT, Mode.NORMAL, LocalDateTime.now().minusMinutes(15), LocalDateTime.now())); - team1 = teamRepository.save(new Team(game, 0, false)); - team2 = teamRepository.save(new Team(game, 0, false)); - teamUserRepository.save(new TeamUser(team1, user1)); - teamUserRepository.save(new TeamUser(team2, user2)); - teams.clear(); - teams.add(teamUserRepository.save(new TeamUser(team1, user1))); - teams.add(teamUserRepository.save(new TeamUser(team2, user2))); - game.updateStatus(); - gameService.expUpdates(game, teams); - pChangeRepository.save(new PChange(game, user1, 0, true)); - pChangeRepository.save(new PChange(game, user2, 0, true)); - } - - Pageable pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "startTime")); - GameListResDto expect = gameFindService.normalGameListByIntra(pageable, "test1"); - //when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - System.out.println(contentAsString); - GameListResDto result = objectMapper.readValue(contentAsString, GameListResDto.class); - //then - System.out.println(result.getGames().size() +", " + result.getIsLast()); - System.out.println(expect.getGames()); - assertThat(result.getGames().size()).isEqualTo(expect.getGames().size()); - assertThat(result.getGames().get(0).getGameId().equals(expect.getGames().get(0).getGameId())); - assertThat(result.getIsLast()).isEqualTo(expect.getIsLast()); - } - } - - // GET /pingpong/games/rank - @Nested - @DisplayName("rank 게임 조회") - class RankGameListTest { - /** - * GET /pingpong/games/rank?page=1&size=10&seasonId=1 - * rankGameList() -> GameFindService.rankGameList() - */ - @Test - @DisplayName("조회 성공") - public void success() throws Exception { - //given - String url = "/pingpong/games/rank?page=1&size=10&seasonId=" + season.getId(); - Pageable pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "startTime")); - GameListResDto expect = gameFindService.rankGameList(pageable, season.getId()); - //when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - System.out.println(contentAsString); - GameListResDto result = objectMapper.readValue(contentAsString, GameListResDto.class); - //then - System.out.println(result.getGames().size() +", " + result.getIsLast()); - System.out.println(expect.getGames().size() + ", " + expect.getIsLast()); - assertThat(result.getGames().size()).isEqualTo(expect.getGames().size()); - assertThat(result.getGames().get(0).getGameId().equals(expect.getGames().get(0).getGameId())); - assertThat(result.getIsLast()).isEqualTo(expect.getIsLast()); - } - - /** - * GET /pingpong/games/rank?page=1&size=10&seasonId={seasonId}&nickname=test1 - * rankGameList() -> GameFindService.rankGameListByIntra() - */ - @Test - @DisplayName("nickname 쿼리 포함 조회 성공") - public void successNicknameQuery() throws Exception { - //given - String url = "/pingpong/games/rank?page=1&size=10&seasonId=" + season.getId() + "&nickname=" + "test1"; - Pageable pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "startTime")); - GameListResDto expect = gameFindService.rankGameListByIntra(pageable, season.getId(), "test1"); - //when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - System.out.println(contentAsString); - GameListResDto result = objectMapper.readValue(contentAsString, GameListResDto.class); - //then - System.out.println(result.getGames().size() +", " + result.getIsLast()); - System.out.println(expect.getGames().size() + ", " + expect.getIsLast()); - assertThat(result.getGames().size()).isEqualTo(expect.getGames().size()); - assertThat(result.getGames().get(0).getGameId().equals(expect.getGames().get(0).getGameId())); - assertThat(result.getIsLast()).isEqualTo(expect.getIsLast()); - } - - /** - * GET /pingpong/games/rank?page=1&size=0 - * allGameList() -> GameFindService.allGameList() - */ - @Test - @DisplayName("Bad Request exception 발생") - public void failBadRequest() throws Exception { - //given - String url = "/pingpong/games/rank?page=1&size=0"; - //then - mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - } - } - - // GET /pingpong/games - @Nested - @DisplayName("전체 게임 목록 조회") - class AllGameListTest { - /** - * GET /pingpong/games?page=1&size=10 - */ - @Test - @DisplayName("조회 성공") - public void success() throws Exception { - //given - String url = "/pingpong/games?page=1&size=10"; - Pageable pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "startTime")); - GameListResDto expect = gameFindService.allGameList(pageable, null); - //when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - System.out.println(contentAsString); - GameListResDto result = objectMapper.readValue(contentAsString, GameListResDto.class); - //then - System.out.println(result.getGames().size() +", " + result.getIsLast()); - System.out.println(expect.getGames().size() + ", " + expect.getIsLast()); - assertThat(result.getGames().size()).isEqualTo(expect.getGames().size()); - assertThat(result.getGames().get(result.getGames().size() - 1).getGameId().equals(expect.getGames().get(expect.getGames().size() - 1).getGameId())); - assertThat(result.getIsLast()).isEqualTo(expect.getIsLast()); - } - - /** - * GET /pingpong/games?page=1&size=10&nickname=test1 - */ - @Test - @DisplayName("nickname 쿼리 포함 조회 성공") - public void suceessNicknameQuery() throws Exception { - //given - String url = "/pingpong/games?page=1&size=10&nickname=test1"; - Pageable pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "startTime")); - GameListResDto expect = gameFindService.allGameListUser(pageable, "test1", null); - //when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - System.out.println(contentAsString); - GameListResDto result = objectMapper.readValue(contentAsString, GameListResDto.class); - //then - System.out.println(result.getGames().size() +", " + result.getIsLast()); - System.out.println(expect.getGames().size() + ", " + expect.getIsLast()); - assertThat(result.getGames().size()).isEqualTo(expect.getGames().size()); - assertThat(result.getGames().get(result.getGames().size() - 1).getGameId()).isEqualTo(expect.getGames().get(expect.getGames().size() - 1).getGameId()); - assertThat(result.getIsLast()).isEqualTo(expect.getIsLast()); - } - - /** - * GET /pingpong/games?pageNum=1&pageSize=10&status=live - */ - @Test - @DisplayName("잘못된 query parameter인 경우, Bad Request exception 발생") - public void failBadRequest() throws Exception { - String url = "/pingpong/games?pageNum=1&pageSize=10&status=live"; // LIVE 대문자여야 함 - mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - } - - /** - * GET /pingpong/games?page=1&size=10&status=2 - */ - @Test - @DisplayName("잘못된 query parameter인 경우, Bad Request exception 발생") - public void failBadRequest2() throws Exception { - String url = "/pingpong/games?page=1&size=10&status=2"; - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - System.out.println(contentAsString); - } - } - - // POST /pingpong/games/rank - @Nested - @DisplayName("랭크 게임 점수 결과 입력") - class CreateRankResultTest { - /** - * POST /pingpong/games/rank - */ - @Test - @DisplayName("둘 중 한명 입력 후 나머지 한 명이 입력할 경우 conflict exception 발생") - public void success() throws Exception { - String url = "/pingpong/games/rank"; - Game game = gameRepository.save(new Game(season, StatusType.WAIT, Mode.RANK, LocalDateTime.now().minusMinutes(15), LocalDateTime.now())); - Team team1 = teamRepository.save(new Team(game, -1, false)); - Team team2 = teamRepository.save(new Team(game, -1, false)); - String ac1 = tokenProvider.createToken(user1.getId()); - String ac2 = tokenProvider.createToken(user2.getId()); - teamUserRepository.save(new TeamUser(team1, user1)); - teamUserRepository.save(new TeamUser(team2, user2)); - teamUserRepository.flush(); - gameRepository.flush(); - teamRepository.flush(); - String content = objectMapper.writeValueAsString(new RankResultReqDto(game.getId(), team1.getId(), 1, team2.getId(), 2)); - System.out.println(user1.getTotalExp()); - System.out.println(user2.getTotalExp()); - // then - System.out.println("======================="); - mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) - .contentType(MediaType.APPLICATION_JSON) - .content(content)) - .andExpect(status().isCreated()) - .andReturn().getResponse(); - System.out.println("======================="); - content = objectMapper.writeValueAsString(new RankResultReqDto(game.getId(), team2.getId(), 2, team1.getId(), 1)); - mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + ac2) - .contentType(MediaType.APPLICATION_JSON) - .content(content)) - .andExpect(status().isConflict()) - .andReturn().getResponse(); - System.out.println(user1.getTotalExp()); - System.out.println(user2.getTotalExp()); - } - - // TODO : 랭크 게임 결과 입력 실패 테스트 (잘못된 점수 입력할 경우 InvalidParameterException 발생) - } - @Nested - @DisplayName("토너먼트 게임 점수 결과 입력") - class CreateTournamentResultTest { - @Test - @DisplayName("입력 성공") - public void success() throws Exception { - //given - String url = "/pingpong/games/tournament"; - Tournament tournament = testDataUtils.createTournamentWithUser(Tournament.ALLOWED_JOINED_NUMBER, 4, "ttt"); - List tournamentGameList = testDataUtils.createTournamentGameList(tournament, Tournament.ALLOWED_JOINED_NUMBER - 1); - // 8강 경기 생성 - Game game = null; - Team team1 = null; - Team team2 = null; - for (int i = 0; i < Tournament.ALLOWED_JOINED_NUMBER / 2; ++i) { - game = new Game(season, StatusType.WAIT, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(15), LocalDateTime.now()); - team1 = new Team(game, -1, false); - team2 = new Team(game, -1, false); - TeamUser teamUser1 = new TeamUser(team1, tournament.getTournamentUsers().get(i * 2).getUser()); - TeamUser teamUser2 = new TeamUser(team2, tournament.getTournamentUsers().get(i * 2 + 1).getUser()); - gameRepository.save(game); - tournamentGameList.get(i).updateGame(game); - } - - testDataUtils.createUserRank(team1.getTeamUsers().get(0).getUser(), "", season); - testDataUtils.createUserRank(team2.getTeamUsers().get(0).getUser(), "", season); - - String ac1 = tokenProvider.createToken(team1.getTeamUsers().get(0).getUser().getId()); - String content = objectMapper.writeValueAsString(new TournamentResultReqDto(game.getId(), team1.getId(), 1, team2.getId(), 2)); - - //when - String contentAsString = mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) - .contentType(MediaType.APPLICATION_JSON) - .content(content)) - .andExpect(status().isCreated()) - .andReturn().getResponse().getContentAsString(); - - //then - assertThat(game.getStatus()).isEqualTo(StatusType.END); - assertThat(pChangeRepository.findByUserIdAndGameId(team1.getTeamUsers().get(0).getUser().getId(), game.getId())).isNotEmpty(); - assertThat(pChangeRepository.findByUserIdAndGameId(team2.getTeamUsers().get(0).getUser().getId(), game.getId())).isNotEmpty(); - System.out.println(contentAsString); - } - - @Test - @DisplayName("잘못된 Game Id") - public void invalidGameId() throws Exception { - //given - String url = "/pingpong/games/tournament"; - Game game = gameRepository.save(new Game(season, StatusType.WAIT, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(15), LocalDateTime.now())); - Team team1 = teamRepository.save(new Team(game, -1, false)); - Team team2 = teamRepository.save(new Team(game, -1, false)); - String ac1 = tokenProvider.createToken(user1.getId()); - teamUserRepository.save(new TeamUser(team1, user1)); - teamUserRepository.save(new TeamUser(team2, user2)); - String content = objectMapper.writeValueAsString(new TournamentResultReqDto(99999999L, team1.getId(), 1, team2.getId(), 2)); - //when - String contentAsString = mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) - .contentType(MediaType.APPLICATION_JSON) - .content(content)) - .andExpect(status().isNotFound()) - .andReturn().getResponse().getContentAsString(); - //then - System.out.println(contentAsString); - } - - @Test - @DisplayName("잘못된 Team Id") - public void invalidTeamId() throws Exception { - //given - String url = "/pingpong/games/tournament"; - Game game = gameRepository.save(new Game(season, StatusType.WAIT, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(15), LocalDateTime.now())); - Game game2 = gameRepository.save(new Game(season, StatusType.WAIT, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(30), LocalDateTime.now().minusMinutes(15))); - Team team1 = teamRepository.save(new Team(game, -1, false)); - Team team2 = teamRepository.save(new Team(game, -1, false)); - Team team3 = teamRepository.save(new Team(game2, -1, false)); - String ac1 = tokenProvider.createToken(user1.getId()); - teamUserRepository.save(new TeamUser(team1, user1)); - teamUserRepository.save(new TeamUser(team2, user2)); - String content1 = objectMapper.writeValueAsString(new TournamentResultReqDto(game.getId(), -1L, 1, team2.getId(), 2)); - String content2 = objectMapper.writeValueAsString(new TournamentResultReqDto(game.getId(), team1.getId(), 1, -1L, 2)); - String content3 = objectMapper.writeValueAsString(new TournamentResultReqDto(game.getId(), team1.getId(), 1, team3.getId(), 2)); - //when1 - 존재하지 않는 myTeamId - String contentAsString1 = mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) - .contentType(MediaType.APPLICATION_JSON) - .content(content1)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - //then - System.out.println(contentAsString1); - - //when2 - 존재하지 않는 enemyTeamId - String contentAsString2 = mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) - .contentType(MediaType.APPLICATION_JSON) - .content(content2)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - //then2 - System.out.println(contentAsString2); - - //when3 - game에 존재하지 않은 TeamId - String contentAsString3 = mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) - .contentType(MediaType.APPLICATION_JSON) - .content(content3)) - .andExpect(status().isNotFound()) - .andReturn().getResponse().getContentAsString(); - //then3 - System.out.println(contentAsString2); - } - - @Test - @DisplayName("잘못된 점수") - public void invalidScore() throws Exception { - //given - String url = "/pingpong/games/tournament"; - Game game = gameRepository.save(new Game(season, StatusType.WAIT, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(15), LocalDateTime.now())); - Team team1 = teamRepository.save(new Team(game, -1, false)); - Team team2 = teamRepository.save(new Team(game, -1, false)); - String ac1 = tokenProvider.createToken(user1.getId()); - teamUserRepository.save(new TeamUser(team1, user1)); - teamUserRepository.save(new TeamUser(team2, user2)); - String content1 = objectMapper.writeValueAsString(new TournamentResultReqDto(game.getId(), team1.getId(), -1, team2.getId(), 2)); - String content2 = objectMapper.writeValueAsString(new TournamentResultReqDto(game.getId(), team1.getId(), 1, team2.getId(), 1)); - String content3 = objectMapper.writeValueAsString(new TournamentResultReqDto(game.getId(), team1.getId(), 3, team2.getId(), 0)); - //when1 - String contentAsString1 = mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) - .contentType(MediaType.APPLICATION_JSON) - .content(content1)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - //then1 - System.out.println(contentAsString1); - - //when2 - String contentAsString2 = mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) - .contentType(MediaType.APPLICATION_JSON) - .content(content2)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - //then2 - System.out.println(contentAsString2); - - //when3 - String contentAsString3 = mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) - .contentType(MediaType.APPLICATION_JSON) - .content(content3)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - //then3 - System.out.println(contentAsString3); - } - - @Test - @DisplayName("잘못된 Game Status") - public void invalidStatus() throws Exception { - //given - String url = "/pingpong/games/tournament"; - Game game = gameRepository.save(new Game(season, StatusType.END, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(15), LocalDateTime.now())); - Team team1 = teamRepository.save(new Team(game, -1, false)); - Team team2 = teamRepository.save(new Team(game, -1, false)); - String ac1 = tokenProvider.createToken(user1.getId()); - teamUserRepository.save(new TeamUser(team1, user1)); - teamUserRepository.save(new TeamUser(team2, user2)); - String content = objectMapper.writeValueAsString(new TournamentResultReqDto(game.getId(), team1.getId(), 1, team2.getId(), 2)); - //when - String contentAsString = mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) - .contentType(MediaType.APPLICATION_JSON) - .content(content)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - //then - System.out.println(contentAsString); - } - - @Test - @DisplayName("이미 점수 입력이 완료된 게임") - public void scoreAlreadyEntered() throws Exception { - //given - String url = "/pingpong/games/tournament"; - Game game = gameRepository.save(new Game(season, StatusType.BEFORE, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(15), LocalDateTime.now())); - Team team1 = teamRepository.save(new Team(game, 2, true)); - Team team2 = teamRepository.save(new Team(game, 1, false)); - String ac1 = tokenProvider.createToken(user1.getId()); - teamUserRepository.save(new TeamUser(team1, user1)); - teamUserRepository.save(new TeamUser(team2, user2)); - String content = objectMapper.writeValueAsString(new TournamentResultReqDto(game.getId(), team1.getId(), 2, team2.getId(), 1)); - //when - String contentAsString = mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) - .contentType(MediaType.APPLICATION_JSON) - .content(content)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - //then - System.out.println(contentAsString); - } - - @Test - @DisplayName("잘못된 Team User") - public void invalidTeamUser() throws Exception { - //given - String url = "/pingpong/games/tournament"; - user3 = testDataUtils.createNewUser("test3", "test3@email", RacketType.NONE, SnsType.EMAIL, RoleType.USER); - Game game = gameRepository.save(new Game(season, StatusType.WAIT, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(15), LocalDateTime.now())); - Team team1 = teamRepository.save(new Team(game, -1, false)); - Team team2 = teamRepository.save(new Team(game, -1, false)); - String ac1 = tokenProvider.createToken(user1.getId()); - teamUserRepository.save(new TeamUser(team1, user3)); - teamUserRepository.save(new TeamUser(team2, user2)); - String content = objectMapper.writeValueAsString(new TournamentResultReqDto(game.getId(), team1.getId(), 1, team2.getId(), 2)); - //when - String contentAsString1 = mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) - .contentType(MediaType.APPLICATION_JSON) - .content(content)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - //then - System.out.println(contentAsString1); - } - } - - // POST /pingpong/games/normal - @Nested - @DisplayName("일반 게임 종료 버튼 클릭") - class CreateNormalResultTest { - /** - * POST /pingpong/games/normal - */ - @Test - @DisplayName("게임 종료") - public void success() throws Exception { - String url = "/pingpong/games/normal"; - Game game = gameRepository.save(new Game(season, StatusType.WAIT, Mode.NORMAL, LocalDateTime.now().minusMinutes(15), LocalDateTime.now())); - Team team1 = teamRepository.save(new Team(game, -1, false)); - Team team2 = teamRepository.save(new Team(game, -1, false)); - String ac1 = tokenProvider.createToken(user1.getId()); - String ac2 = tokenProvider.createToken(user2.getId()); - teamUserRepository.save(new TeamUser(team1, user1)); - teamUserRepository.save(new TeamUser(team2, user2)); - teamUserRepository.flush(); - gameRepository.flush(); - teamRepository.flush(); - String content = objectMapper.writeValueAsString(new RankResultReqDto(game.getId(), team1.getId(), 1, team2.getId(), 2)); - System.out.println(user1.getTotalExp()); - System.out.println(user2.getTotalExp()); - // then - System.out.println("======================="); - mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) - .contentType(MediaType.APPLICATION_JSON) - .content(content)) - .andExpect(status().isCreated()) - .andReturn().getResponse(); - System.out.println("======================="); - content = objectMapper.writeValueAsString(new RankResultReqDto(game.getId(), team2.getId(), 2, team1.getId(), 1)); - mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + ac2) - .contentType(MediaType.APPLICATION_JSON) - .content(content)) - .andExpect(status().isCreated()) - .andReturn().getResponse(); - System.out.println(user1.getTotalExp()); - System.out.println(user2.getTotalExp()); - } - // TODO HttpStatus.ACCEPTED 테스트 - service 함수에서 BEFORE 상태일 때 false 리턴할 경우 - } - - @Nested - @DisplayName("/{gameId}/result?mode=?") - class GameChangeRestTest { - @Test - @DisplayName("랭크 게임 결과 조회") - public void successGetRankPPPChange() throws Exception { - Game mockMatch = testDataUtils.createMockMatch(user1, season, - LocalDateTime.now().minusMinutes(16), - LocalDateTime.now().minusMinutes(1), Mode.RANK); - testDataUtils.createUserRank(user1, "hello", season, tiers.get(0)); - testDataUtils.createCoinPolicy(user1, 0, 0, 1, 0); - - String url = "/pingpong/games/" + mockMatch.getId() + "/pchange/result?mode=" + Mode.RANK; - String content = mockMvc.perform( - get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - System.out.println("result: " + content); - } - - @Test - @DisplayName("일반 게임 결과 조회") - public void normalGameResult() throws Exception { - Game mockMatch = testDataUtils.createMockMatch(user1, season, - LocalDateTime.now().minusMinutes(16), - LocalDateTime.now().minusMinutes(1), Mode.NORMAL); - testDataUtils.createCoinPolicy(user1, 0, 1, 0, 0); - String url = "/pingpong/games/" + mockMatch.getId() + "/pchange/result?mode=" + Mode.NORMAL; - String content = mockMvc.perform( - get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - System.out.println("result: " + content); - } - - @Test - @DisplayName("토너먼트 게임 결과 조회") - public void tournamentGameResult() throws Exception { - Game mockMatch = testDataUtils.createMockMatch(user1, season, - LocalDateTime.now().minusMinutes(16), - LocalDateTime.now().minusMinutes(1), Mode.TOURNAMENT); - testDataUtils.createCoinPolicy(user1, 0, 1, 0, 0); - String url = "/pingpong/games/" + mockMatch.getId() + "/pchange/result?mode=" + Mode.TOURNAMENT; - String content = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - System.out.println("result: " + content); - } - } -} +package com.gg.server.domain.game; + +import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +import org.apache.http.HttpHeaders; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.data.GameRepository; +import com.gg.server.domain.game.dto.GameListResDto; +import com.gg.server.domain.game.dto.GameTeamInfo; +import com.gg.server.domain.game.dto.request.RankResultReqDto; +import com.gg.server.domain.game.dto.request.TournamentResultReqDto; +import com.gg.server.domain.game.service.GameFindService; +import com.gg.server.domain.game.service.GameService; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.pchange.data.PChange; +import com.gg.server.domain.pchange.data.PChangeRepository; +import com.gg.server.domain.rank.data.Rank; +import com.gg.server.domain.rank.data.RankRepository; +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.rank.redis.RankRedisService; +import com.gg.server.domain.rank.redis.RedisKeyManager; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.data.SeasonRepository; +import com.gg.server.domain.team.data.Team; +import com.gg.server.domain.team.data.TeamRepository; +import com.gg.server.domain.team.data.TeamUser; +import com.gg.server.domain.team.data.TeamUserRepository; +import com.gg.server.domain.tier.data.Tier; +import com.gg.server.domain.tier.data.TierRepository; +import com.gg.server.domain.tournament.data.Tournament; +import com.gg.server.domain.tournament.data.TournamentGame; +import com.gg.server.domain.tournament.data.TournamentRepository; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; + +@IntegrationTest +@AutoConfigureMockMvc +@RequiredArgsConstructor +@Transactional +public class GameControllerTest { + @Autowired + GameRepository gameRepository; + @Autowired + SeasonRepository seasonRepository; + @Autowired + TeamRepository teamRepository; + @Autowired + TeamUserRepository teamUserRepository; + @Autowired + RankRedisRepository rankRedisRepository; + + @Autowired + TierRepository tierRepository; + + @Autowired + PChangeRepository pChangeRepository; + @Autowired + TournamentRepository tournamentRepository; + @Autowired + RankRedisService rankRedisService; + @Autowired + RankRepository rankRepository; + @Autowired + TestDataUtils testDataUtils; + @Autowired + GameService gameService; + @Autowired + GameFindService gameFindService; + @Autowired + private MockMvc mockMvc; + @Autowired + ObjectMapper objectMapper; + @Autowired + AuthTokenProvider tokenProvider; + private String accessToken; + private Season season; + private User user1; + private User user2; + private User user3; + private Game game1; + private Game game2; + ArrayList tiers; + + @BeforeEach + void init() { + tiers = testDataUtils.createTierSystem("pingpong"); + season = seasonRepository.save( + new Season("test season", LocalDateTime.of(2023, 7, 14, 0, 0), LocalDateTime.of(2999, 12, 31, 23, 59), + 1000, 100)); + user1 = testDataUtils.createNewUser("test1", "test1@email", RacketType.NONE, SnsType.EMAIL, RoleType.USER); + accessToken = tokenProvider.createToken(user1.getId()); + user2 = testDataUtils.createNewUser("test2", "test2@email", RacketType.NONE, SnsType.EMAIL, RoleType.USER); + Tier tier = tiers.get(0); + rankRepository.save(Rank.from(user1, season, season.getStartPpp(), tier)); + rankRepository.save(Rank.from(user2, season, season.getStartPpp(), tier)); + RankRedis userRank = RankRedis.from(UserDto.from(user1), season.getStartPpp(), tier.getImageUri()); + String redisHashKey = RedisKeyManager.getHashKey(season.getId()); + rankRedisRepository.addRankData(redisHashKey, user1.getId(), userRank); + userRank = RankRedis.from(UserDto.from(user2), season.getStartPpp(), tier.getImageUri()); + rankRedisRepository.addRankData(redisHashKey, user2.getId(), userRank); + + game1 = gameRepository.save( + new Game(season, StatusType.END, Mode.RANK, LocalDateTime.now().minusMinutes(15), LocalDateTime.now())); + Team team1 = teamRepository.save(new Team(game1, 1, false)); + Team team2 = teamRepository.save(new Team(game1, 2, true)); + teamUserRepository.save(new TeamUser(team1, user1)); + teamUserRepository.save(new TeamUser(team2, user2)); + game2 = gameRepository.save( + new Game(season, StatusType.WAIT, Mode.RANK, LocalDateTime.now().minusMinutes(15), LocalDateTime.now())); + team1 = teamRepository.save(new Team(game2, 1, false)); + team2 = teamRepository.save(new Team(game2, 2, true)); + List teams = new ArrayList<>(); + teams.add(teamUserRepository.save(new TeamUser(team1, user1))); + teams.add(teamUserRepository.save(new TeamUser(team2, user2))); + gameService.expUpdates(game2, teams); + rankRedisService.updateRankRedis(teams.get(0), teams.get(1), game2); + } + + @AfterEach + public void flushRedis() { + rankRedisRepository.deleteAll(); + } + + // GET /pingpong/games/{gameId} + @Nested + @DisplayName("게임 조회 테스트") + class GetGameInfoTest { + /** + * getGameInfo() -> GameFindService.getGameInfo() + */ + @Test + @DisplayName("유저 쿼리 포함 성공") + public void getGameInfoTest() throws Exception { + //given + String url = "/pingpong/games/" + game1.getId().toString(); + GameTeamInfo expect = gameService.getUserGameInfo(game1.getId(), user1.getId()); + // when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + GameTeamInfo result = objectMapper.readValue(contentAsString, GameTeamInfo.class); + System.out.println("expect: " + expect); + System.out.println("result: " + result); + assertThat(result.getGameId()).isEqualTo(expect.getGameId()); + assertThat(result.getStartTime()).isEqualTo(expect.getStartTime()); + assertThat(result.getMatchTeamsInfo().getMyTeam().getTeamId()).isEqualTo( + expect.getMatchTeamsInfo().getMyTeam().getTeamId()); + assertThat(result.getMatchTeamsInfo().getEnemyTeam().getTeamId()).isEqualTo( + expect.getMatchTeamsInfo().getEnemyTeam().getTeamId()); + } + } + + // GET /pingpong/games/normal + @Nested + @DisplayName("normal 게임 조회") + class NormalGameListTest { + /** + * GET /pingpong/games/normal?page=1&size=10 + * normalGameList() -> GameFindService.normalGameList() + */ + @Test + @DisplayName("조회 성공") + public void success() throws Exception { + //given + testDataUtils.createGame(user1, LocalDateTime.now().minusMinutes(16), + LocalDateTime.now().minusMinutes(1), season, Mode.NORMAL); + String url = "/pingpong/games/normal?page=1&size=10"; + Pageable pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "startTime")); + GameListResDto expect = gameFindService.getNormalGameList(pageable); + //when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + System.out.println(contentAsString); + GameListResDto result = objectMapper.readValue(contentAsString, GameListResDto.class); + //then + System.out.println(result.getGames().size() + ", " + result.getIsLast()); + System.out.println(expect.getGames()); + assertThat(result.getGames().size()).isEqualTo(expect.getGames().size()); + assertThat(result.getGames().get(0).getGameId().equals(expect.getGames().get(0).getGameId())); + assertThat(result.getIsLast()).isEqualTo(expect.getIsLast()); + } + + /** + * GET /pingpong/games/normal?page=1&size=10&intraId=test1 + * normalGameList() -> GameFindService.normalGameListByIntra() + */ + @Test + @DisplayName("유저 쿼리 포함 성공") + public void successUserQuery() throws Exception { + //given + String url = "/pingpong/games/normal?page=1&size=10&intraId=test1"; + for (int i = 0; i < 10; i++) { + Game game = gameRepository.save( + new Game(season, StatusType.WAIT, Mode.RANK, LocalDateTime.now().minusMinutes(15), + LocalDateTime.now())); + Team team1 = teamRepository.save(new Team(game, 1, false)); + Team team2 = teamRepository.save(new Team(game, 2, true)); + List teams = new ArrayList<>(); + teams.add(teamUserRepository.save(new TeamUser(team1, user1))); + teams.add(teamUserRepository.save(new TeamUser(team2, user2))); + gameService.expUpdates(game, teams); + rankRedisService.updateRankRedis(teams.get(0), teams.get(1), game); + game = gameRepository.save( + new Game(season, StatusType.WAIT, Mode.NORMAL, LocalDateTime.now().minusMinutes(15), + LocalDateTime.now())); + team1 = teamRepository.save(new Team(game, 0, false)); + team2 = teamRepository.save(new Team(game, 0, false)); + teamUserRepository.save(new TeamUser(team1, user1)); + teamUserRepository.save(new TeamUser(team2, user2)); + teams.clear(); + teams.add(teamUserRepository.save(new TeamUser(team1, user1))); + teams.add(teamUserRepository.save(new TeamUser(team2, user2))); + game.updateStatus(); + gameService.expUpdates(game, teams); + pChangeRepository.save(new PChange(game, user1, 0, true)); + pChangeRepository.save(new PChange(game, user2, 0, true)); + } + + Pageable pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "startTime")); + GameListResDto expect = gameFindService.normalGameListByIntra(pageable, "test1"); + //when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + System.out.println(contentAsString); + GameListResDto result = objectMapper.readValue(contentAsString, GameListResDto.class); + //then + System.out.println(result.getGames().size() + ", " + result.getIsLast()); + System.out.println(expect.getGames()); + assertThat(result.getGames().size()).isEqualTo(expect.getGames().size()); + assertThat(result.getGames().get(0).getGameId().equals(expect.getGames().get(0).getGameId())); + assertThat(result.getIsLast()).isEqualTo(expect.getIsLast()); + } + } + + // GET /pingpong/games/rank + @Nested + @DisplayName("rank 게임 조회") + class RankGameListTest { + /** + * GET /pingpong/games/rank?page=1&size=10&seasonId=1 + * rankGameList() -> GameFindService.rankGameList() + */ + @Test + @DisplayName("조회 성공") + public void success() throws Exception { + //given + String url = "/pingpong/games/rank?page=1&size=10&seasonId=" + season.getId(); + Pageable pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "startTime")); + GameListResDto expect = gameFindService.rankGameList(pageable, season.getId()); + //when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + System.out.println(contentAsString); + GameListResDto result = objectMapper.readValue(contentAsString, GameListResDto.class); + //then + System.out.println(result.getGames().size() + ", " + result.getIsLast()); + System.out.println(expect.getGames().size() + ", " + expect.getIsLast()); + assertThat(result.getGames().size()).isEqualTo(expect.getGames().size()); + assertThat(result.getGames().get(0).getGameId().equals(expect.getGames().get(0).getGameId())); + assertThat(result.getIsLast()).isEqualTo(expect.getIsLast()); + } + + /** + * GET /pingpong/games/rank?page=1&size=10&seasonId={seasonId}&nickname=test1 + * rankGameList() -> GameFindService.rankGameListByIntra() + */ + @Test + @DisplayName("nickname 쿼리 포함 조회 성공") + public void successNicknameQuery() throws Exception { + //given + String url = "/pingpong/games/rank?page=1&size=10&seasonId=" + season.getId() + "&nickname=" + "test1"; + Pageable pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "startTime")); + GameListResDto expect = gameFindService.rankGameListByIntra(pageable, season.getId(), "test1"); + //when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + System.out.println(contentAsString); + GameListResDto result = objectMapper.readValue(contentAsString, GameListResDto.class); + //then + System.out.println(result.getGames().size() + ", " + result.getIsLast()); + System.out.println(expect.getGames().size() + ", " + expect.getIsLast()); + assertThat(result.getGames().size()).isEqualTo(expect.getGames().size()); + assertThat(result.getGames().get(0).getGameId().equals(expect.getGames().get(0).getGameId())); + assertThat(result.getIsLast()).isEqualTo(expect.getIsLast()); + } + + /** + * GET /pingpong/games/rank?page=1&size=0 + * allGameList() -> GameFindService.allGameList() + */ + @Test + @DisplayName("Bad Request exception 발생") + public void failBadRequest() throws Exception { + //given + String url = "/pingpong/games/rank?page=1&size=0"; + //then + mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + } + } + + // GET /pingpong/games + @Nested + @DisplayName("전체 게임 목록 조회") + class AllGameListTest { + /** + * GET /pingpong/games?page=1&size=10 + */ + @Test + @DisplayName("조회 성공") + public void success() throws Exception { + //given + String url = "/pingpong/games?page=1&size=10"; + Pageable pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "startTime")); + GameListResDto expect = gameFindService.allGameList(pageable, null); + //when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + System.out.println(contentAsString); + GameListResDto result = objectMapper.readValue(contentAsString, GameListResDto.class); + //then + System.out.println(result.getGames().size() + ", " + result.getIsLast()); + System.out.println(expect.getGames().size() + ", " + expect.getIsLast()); + assertThat(result.getGames().size()).isEqualTo(expect.getGames().size()); + assertThat(result.getGames() + .get(result.getGames().size() - 1) + .getGameId() + .equals(expect.getGames().get(expect.getGames().size() - 1).getGameId())); + assertThat(result.getIsLast()).isEqualTo(expect.getIsLast()); + } + + /** + * GET /pingpong/games?page=1&size=10&nickname=test1 + */ + @Test + @DisplayName("nickname 쿼리 포함 조회 성공") + public void suceessNicknameQuery() throws Exception { + //given + String url = "/pingpong/games?page=1&size=10&nickname=test1"; + Pageable pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "startTime")); + GameListResDto expect = gameFindService.allGameListUser(pageable, "test1", null); + //when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + System.out.println(contentAsString); + GameListResDto result = objectMapper.readValue(contentAsString, GameListResDto.class); + //then + System.out.println(result.getGames().size() + ", " + result.getIsLast()); + System.out.println(expect.getGames().size() + ", " + expect.getIsLast()); + assertThat(result.getGames().size()).isEqualTo(expect.getGames().size()); + assertThat(result.getGames().get(result.getGames().size() - 1).getGameId()).isEqualTo( + expect.getGames().get(expect.getGames().size() - 1).getGameId()); + assertThat(result.getIsLast()).isEqualTo(expect.getIsLast()); + } + + /** + * GET /pingpong/games?pageNum=1&pageSize=10&status=live + */ + @Test + @DisplayName("잘못된 query parameter인 경우, Bad Request exception 발생") + public void failBadRequest() throws Exception { + String url = "/pingpong/games?pageNum=1&pageSize=10&status=live"; // LIVE 대문자여야 함 + mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + } + + /** + * GET /pingpong/games?page=1&size=10&status=2 + */ + @Test + @DisplayName("잘못된 query parameter인 경우, Bad Request exception 발생") + public void failBadRequest2() throws Exception { + String url = "/pingpong/games?page=1&size=10&status=2"; + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + System.out.println(contentAsString); + } + } + + // POST /pingpong/games/rank + @Nested + @DisplayName("랭크 게임 점수 결과 입력") + class CreateRankResultTest { + /** + * POST /pingpong/games/rank + */ + @Test + @DisplayName("둘 중 한명 입력 후 나머지 한 명이 입력할 경우 conflict exception 발생") + public void success() throws Exception { + String url = "/pingpong/games/rank"; + Game game = gameRepository.save( + new Game(season, StatusType.WAIT, Mode.RANK, LocalDateTime.now().minusMinutes(15), + LocalDateTime.now())); + Team team1 = teamRepository.save(new Team(game, -1, false)); + Team team2 = teamRepository.save(new Team(game, -1, false)); + String ac1 = tokenProvider.createToken(user1.getId()); + String ac2 = tokenProvider.createToken(user2.getId()); + teamUserRepository.save(new TeamUser(team1, user1)); + teamUserRepository.save(new TeamUser(team2, user2)); + teamUserRepository.flush(); + gameRepository.flush(); + teamRepository.flush(); + String content = objectMapper.writeValueAsString( + new RankResultReqDto(game.getId(), team1.getId(), 1, team2.getId(), 2)); + System.out.println(user1.getTotalExp()); + System.out.println(user2.getTotalExp()); + // then + System.out.println("======================="); + mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) + .contentType(MediaType.APPLICATION_JSON) + .content(content)) + .andExpect(status().isCreated()) + .andReturn().getResponse(); + System.out.println("======================="); + content = objectMapper.writeValueAsString( + new RankResultReqDto(game.getId(), team2.getId(), 2, team1.getId(), 1)); + mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + ac2) + .contentType(MediaType.APPLICATION_JSON) + .content(content)) + .andExpect(status().isConflict()) + .andReturn().getResponse(); + System.out.println(user1.getTotalExp()); + System.out.println(user2.getTotalExp()); + } + + // TODO : 랭크 게임 결과 입력 실패 테스트 (잘못된 점수 입력할 경우 InvalidParameterException 발생) + } + + @Nested + @DisplayName("토너먼트 게임 점수 결과 입력") + class CreateTournamentResultTest { + @Test + @DisplayName("입력 성공") + public void success() throws Exception { + //given + String url = "/pingpong/games/tournament"; + Tournament tournament = testDataUtils.createTournamentWithUser(Tournament.ALLOWED_JOINED_NUMBER, 4, "ttt"); + List tournamentGameList = testDataUtils.createTournamentGameList(tournament, + Tournament.ALLOWED_JOINED_NUMBER - 1); + // 8강 경기 생성 + Game game = null; + Team team1 = null; + Team team2 = null; + for (int i = 0; i < Tournament.ALLOWED_JOINED_NUMBER / 2; ++i) { + game = new Game(season, StatusType.WAIT, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(15), + LocalDateTime.now()); + team1 = new Team(game, -1, false); + team2 = new Team(game, -1, false); + TeamUser teamUser1 = new TeamUser(team1, tournament.getTournamentUsers().get(i * 2).getUser()); + TeamUser teamUser2 = new TeamUser(team2, tournament.getTournamentUsers().get(i * 2 + 1).getUser()); + gameRepository.save(game); + tournamentGameList.get(i).updateGame(game); + } + + testDataUtils.createUserRank(team1.getTeamUsers().get(0).getUser(), "", season); + testDataUtils.createUserRank(team2.getTeamUsers().get(0).getUser(), "", season); + + String ac1 = tokenProvider.createToken(team1.getTeamUsers().get(0).getUser().getId()); + String content = objectMapper.writeValueAsString( + new TournamentResultReqDto(game.getId(), team1.getId(), 1, team2.getId(), 2)); + + //when + String contentAsString = mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) + .contentType(MediaType.APPLICATION_JSON) + .content(content)) + .andExpect(status().isCreated()) + .andReturn().getResponse().getContentAsString(); + + //then + assertThat(game.getStatus()).isEqualTo(StatusType.END); + assertThat(pChangeRepository.findByUserIdAndGameId(team1.getTeamUsers().get(0).getUser().getId(), + game.getId())).isNotEmpty(); + assertThat(pChangeRepository.findByUserIdAndGameId(team2.getTeamUsers().get(0).getUser().getId(), + game.getId())).isNotEmpty(); + System.out.println(contentAsString); + } + + @Test + @DisplayName("잘못된 Game Id") + public void invalidGameId() throws Exception { + //given + String url = "/pingpong/games/tournament"; + Game game = gameRepository.save( + new Game(season, StatusType.WAIT, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(15), + LocalDateTime.now())); + Team team1 = teamRepository.save(new Team(game, -1, false)); + Team team2 = teamRepository.save(new Team(game, -1, false)); + String ac1 = tokenProvider.createToken(user1.getId()); + teamUserRepository.save(new TeamUser(team1, user1)); + teamUserRepository.save(new TeamUser(team2, user2)); + String content = objectMapper.writeValueAsString( + new TournamentResultReqDto(99999999L, team1.getId(), 1, team2.getId(), 2)); + //when + String contentAsString = mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) + .contentType(MediaType.APPLICATION_JSON) + .content(content)) + .andExpect(status().isNotFound()) + .andReturn().getResponse().getContentAsString(); + //then + System.out.println(contentAsString); + } + + @Test + @DisplayName("잘못된 Team Id") + public void invalidTeamId() throws Exception { + //given + String url = "/pingpong/games/tournament"; + Game game = gameRepository.save( + new Game(season, StatusType.WAIT, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(15), + LocalDateTime.now())); + Game game2 = gameRepository.save( + new Game(season, StatusType.WAIT, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(30), + LocalDateTime.now().minusMinutes(15))); + Team team1 = teamRepository.save(new Team(game, -1, false)); + Team team2 = teamRepository.save(new Team(game, -1, false)); + Team team3 = teamRepository.save(new Team(game2, -1, false)); + String ac1 = tokenProvider.createToken(user1.getId()); + teamUserRepository.save(new TeamUser(team1, user1)); + teamUserRepository.save(new TeamUser(team2, user2)); + String content1 = objectMapper.writeValueAsString( + new TournamentResultReqDto(game.getId(), -1L, 1, team2.getId(), 2)); + String content2 = objectMapper.writeValueAsString( + new TournamentResultReqDto(game.getId(), team1.getId(), 1, -1L, 2)); + String content3 = objectMapper.writeValueAsString( + new TournamentResultReqDto(game.getId(), team1.getId(), 1, team3.getId(), 2)); + //when1 - 존재하지 않는 myTeamId + String contentAsString1 = mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) + .contentType(MediaType.APPLICATION_JSON) + .content(content1)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + //then + System.out.println(contentAsString1); + + //when2 - 존재하지 않는 enemyTeamId + String contentAsString2 = mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) + .contentType(MediaType.APPLICATION_JSON) + .content(content2)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + //then2 + System.out.println(contentAsString2); + + //when3 - game에 존재하지 않은 TeamId + String contentAsString3 = mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) + .contentType(MediaType.APPLICATION_JSON) + .content(content3)) + .andExpect(status().isNotFound()) + .andReturn().getResponse().getContentAsString(); + //then3 + System.out.println(contentAsString2); + } + + @Test + @DisplayName("잘못된 점수") + public void invalidScore() throws Exception { + //given + String url = "/pingpong/games/tournament"; + Game game = gameRepository.save( + new Game(season, StatusType.WAIT, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(15), + LocalDateTime.now())); + Team team1 = teamRepository.save(new Team(game, -1, false)); + Team team2 = teamRepository.save(new Team(game, -1, false)); + String ac1 = tokenProvider.createToken(user1.getId()); + teamUserRepository.save(new TeamUser(team1, user1)); + teamUserRepository.save(new TeamUser(team2, user2)); + String content1 = objectMapper.writeValueAsString( + new TournamentResultReqDto(game.getId(), team1.getId(), -1, team2.getId(), 2)); + String content2 = objectMapper.writeValueAsString( + new TournamentResultReqDto(game.getId(), team1.getId(), 1, team2.getId(), 1)); + String content3 = objectMapper.writeValueAsString( + new TournamentResultReqDto(game.getId(), team1.getId(), 3, team2.getId(), 0)); + //when1 + String contentAsString1 = mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) + .contentType(MediaType.APPLICATION_JSON) + .content(content1)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + //then1 + System.out.println(contentAsString1); + + //when2 + String contentAsString2 = mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) + .contentType(MediaType.APPLICATION_JSON) + .content(content2)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + //then2 + System.out.println(contentAsString2); + + //when3 + String contentAsString3 = mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) + .contentType(MediaType.APPLICATION_JSON) + .content(content3)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + //then3 + System.out.println(contentAsString3); + } + + @Test + @DisplayName("잘못된 Game Status") + public void invalidStatus() throws Exception { + //given + String url = "/pingpong/games/tournament"; + Game game = gameRepository.save( + new Game(season, StatusType.END, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(15), + LocalDateTime.now())); + Team team1 = teamRepository.save(new Team(game, -1, false)); + Team team2 = teamRepository.save(new Team(game, -1, false)); + String ac1 = tokenProvider.createToken(user1.getId()); + teamUserRepository.save(new TeamUser(team1, user1)); + teamUserRepository.save(new TeamUser(team2, user2)); + String content = objectMapper.writeValueAsString( + new TournamentResultReqDto(game.getId(), team1.getId(), 1, team2.getId(), 2)); + //when + String contentAsString = mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) + .contentType(MediaType.APPLICATION_JSON) + .content(content)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + //then + System.out.println(contentAsString); + } + + @Test + @DisplayName("이미 점수 입력이 완료된 게임") + public void scoreAlreadyEntered() throws Exception { + //given + String url = "/pingpong/games/tournament"; + Game game = gameRepository.save( + new Game(season, StatusType.BEFORE, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(15), + LocalDateTime.now())); + Team team1 = teamRepository.save(new Team(game, 2, true)); + Team team2 = teamRepository.save(new Team(game, 1, false)); + String ac1 = tokenProvider.createToken(user1.getId()); + teamUserRepository.save(new TeamUser(team1, user1)); + teamUserRepository.save(new TeamUser(team2, user2)); + String content = objectMapper.writeValueAsString( + new TournamentResultReqDto(game.getId(), team1.getId(), 2, team2.getId(), 1)); + //when + String contentAsString = mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) + .contentType(MediaType.APPLICATION_JSON) + .content(content)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + //then + System.out.println(contentAsString); + } + + @Test + @DisplayName("잘못된 Team User") + public void invalidTeamUser() throws Exception { + //given + String url = "/pingpong/games/tournament"; + user3 = testDataUtils.createNewUser("test3", "test3@email", RacketType.NONE, SnsType.EMAIL, RoleType.USER); + Game game = gameRepository.save( + new Game(season, StatusType.WAIT, Mode.TOURNAMENT, LocalDateTime.now().minusMinutes(15), + LocalDateTime.now())); + Team team1 = teamRepository.save(new Team(game, -1, false)); + Team team2 = teamRepository.save(new Team(game, -1, false)); + String ac1 = tokenProvider.createToken(user1.getId()); + teamUserRepository.save(new TeamUser(team1, user3)); + teamUserRepository.save(new TeamUser(team2, user2)); + String content = objectMapper.writeValueAsString( + new TournamentResultReqDto(game.getId(), team1.getId(), 1, team2.getId(), 2)); + //when + String contentAsString1 = mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) + .contentType(MediaType.APPLICATION_JSON) + .content(content)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + //then + System.out.println(contentAsString1); + } + } + + // POST /pingpong/games/normal + @Nested + @DisplayName("일반 게임 종료 버튼 클릭") + class CreateNormalResultTest { + /** + * POST /pingpong/games/normal + */ + @Test + @DisplayName("게임 종료") + public void success() throws Exception { + String url = "/pingpong/games/normal"; + Game game = gameRepository.save( + new Game(season, StatusType.WAIT, Mode.NORMAL, LocalDateTime.now().minusMinutes(15), + LocalDateTime.now())); + Team team1 = teamRepository.save(new Team(game, -1, false)); + Team team2 = teamRepository.save(new Team(game, -1, false)); + String ac1 = tokenProvider.createToken(user1.getId()); + String ac2 = tokenProvider.createToken(user2.getId()); + teamUserRepository.save(new TeamUser(team1, user1)); + teamUserRepository.save(new TeamUser(team2, user2)); + teamUserRepository.flush(); + gameRepository.flush(); + teamRepository.flush(); + String content = objectMapper.writeValueAsString( + new RankResultReqDto(game.getId(), team1.getId(), 1, team2.getId(), 2)); + System.out.println(user1.getTotalExp()); + System.out.println(user2.getTotalExp()); + // then + System.out.println("======================="); + mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + ac1) + .contentType(MediaType.APPLICATION_JSON) + .content(content)) + .andExpect(status().isCreated()) + .andReturn().getResponse(); + System.out.println("======================="); + content = objectMapper.writeValueAsString( + new RankResultReqDto(game.getId(), team2.getId(), 2, team1.getId(), 1)); + mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + ac2) + .contentType(MediaType.APPLICATION_JSON) + .content(content)) + .andExpect(status().isCreated()) + .andReturn().getResponse(); + System.out.println(user1.getTotalExp()); + System.out.println(user2.getTotalExp()); + } + // TODO HttpStatus.ACCEPTED 테스트 - service 함수에서 BEFORE 상태일 때 false 리턴할 경우 + } + + @Nested + @DisplayName("/{gameId}/result?mode=?") + class GameChangeRestTest { + @Test + @DisplayName("랭크 게임 결과 조회") + public void successGetRankPppChange() throws Exception { + Game mockMatch = testDataUtils.createMockMatch(user1, season, + LocalDateTime.now().minusMinutes(16), + LocalDateTime.now().minusMinutes(1), Mode.RANK); + testDataUtils.createUserRank(user1, "hello", season, tiers.get(0)); + testDataUtils.createCoinPolicy(user1, 0, 0, 1, 0); + + String url = "/pingpong/games/" + mockMatch.getId() + "/pchange/result?mode=" + Mode.RANK; + String content = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + System.out.println("result: " + content); + } + + @Test + @DisplayName("일반 게임 결과 조회") + public void normalGameResult() throws Exception { + Game mockMatch = testDataUtils.createMockMatch(user1, season, + LocalDateTime.now().minusMinutes(16), + LocalDateTime.now().minusMinutes(1), Mode.NORMAL); + testDataUtils.createCoinPolicy(user1, 0, 1, 0, 0); + String url = "/pingpong/games/" + mockMatch.getId() + "/pchange/result?mode=" + Mode.NORMAL; + String content = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + System.out.println("result: " + content); + } + + @Test + @DisplayName("토너먼트 게임 결과 조회") + public void tournamentGameResult() throws Exception { + Game mockMatch = testDataUtils.createMockMatch(user1, season, + LocalDateTime.now().minusMinutes(16), + LocalDateTime.now().minusMinutes(1), Mode.TOURNAMENT); + testDataUtils.createCoinPolicy(user1, 0, 1, 0, 0); + String url = "/pingpong/games/" + mockMatch.getId() + "/pchange/result?mode=" + Mode.TOURNAMENT; + String content = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + System.out.println("result: " + content); + } + } +} diff --git a/src/test/java/com/gg/server/domain/game/data/GameUnitTest.java b/src/test/java/com/gg/server/domain/game/data/GameUnitTest.java index 632deb614..a0d2c7740 100644 --- a/src/test/java/com/gg/server/domain/game/data/GameUnitTest.java +++ b/src/test/java/com/gg/server/domain/game/data/GameUnitTest.java @@ -1,119 +1,120 @@ package com.gg.server.domain.game.data; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.mock; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; -import com.gg.server.domain.team.data.Team; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; -import com.gg.server.utils.annotation.UnitTest; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import com.gg.server.domain.team.data.Team; +import com.gg.server.global.exception.ErrorCode; +import com.gg.server.global.exception.custom.BusinessException; +import com.gg.server.utils.annotation.UnitTest; + @UnitTest @DisplayName("GameUnitTest") class GameUnitTest { - List mockTeams; - List games; - - @BeforeEach - void setUp() { - mockTeams = IntStream.range(0, 10) - .mapToObj(i -> mock(Team.class)) - .collect(Collectors.toCollection(ArrayList::new)); - games = IntStream.range(0, 10) - .mapToObj(i -> new Game()) - .collect(Collectors.toCollection(ArrayList::new)); - } - - @Nested - @DisplayName("AddTeam") - class AddTeam { - @Test - @DisplayName("단일 Team 추가 성공") - public void addSingleTeamSuccess() { - //given - Game game = games.get(0); - Team mockTeam = mockTeams.get(0); - - //when - game.addTeam(mockTeam); - - //then - assertEquals(1, game.getTeams().size()); - assertEquals(mockTeam, game.getTeams().get(0)); - } - - @Test - @DisplayName("두개 Team 추가 성공") - void addMultiTeamSuccess() { - //given - Game game = games.get(0); - - //when - game.addTeam(mockTeams.get(0)); - game.addTeam(mockTeams.get(1)); - - //then - assertEquals(2, game.getTeams().size()); - assertEquals(mockTeams.get(0), game.getTeams().get(0)); - assertEquals(mockTeams.get(1), game.getTeams().get(1)); - } - - @Test - @DisplayName("두개 이상의 Team 추가 실패") - void addExceedTeamFailed() { - //given - Game game = games.get(0); - - //when - game.addTeam(mockTeams.get(0)); - game.addTeam(mockTeams.get(1)); - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> game.addTeam(mockTeams.get(2))); - assertEquals(ErrorCode.TEAM_SIZE_EXCEED, businessException.getErrorCode()); - assertEquals(ErrorCode.TEAM_SIZE_EXCEED.getMessage(), businessException.getMessage()); - } - - @Test - @DisplayName("동일한 Team 추가 실패") - void duplicatedTeamAddFailed() { - //given - Game game = games.get(0); - - //when - game.addTeam(mockTeams.get(0)); - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> game.addTeam(mockTeams.get(0))); - assertEquals(ErrorCode.TEAM_DUPLICATION, businessException.getErrorCode()); - assertEquals(ErrorCode.TEAM_DUPLICATION.getMessage(), businessException.getMessage()); - } - - @Test - @DisplayName("null 포인터 전달 시 실패") - void nullAddFailed() { - //given - Game game = games.get(0); - - //when - Team team = null; - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> game.addTeam(team)); - assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); - assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); - } - } -} \ No newline at end of file + List mockTeams; + List games; + + @BeforeEach + void setUp() { + mockTeams = IntStream.range(0, 10) + .mapToObj(i -> mock(Team.class)) + .collect(Collectors.toCollection(ArrayList::new)); + games = IntStream.range(0, 10) + .mapToObj(i -> new Game()) + .collect(Collectors.toCollection(ArrayList::new)); + } + + @Nested + @DisplayName("AddTeam") + class AddTeam { + @Test + @DisplayName("단일 Team 추가 성공") + public void addSingleTeamSuccess() { + //given + Game game = games.get(0); + Team mockTeam = mockTeams.get(0); + + //when + game.addTeam(mockTeam); + + //then + assertEquals(1, game.getTeams().size()); + assertEquals(mockTeam, game.getTeams().get(0)); + } + + @Test + @DisplayName("두개 Team 추가 성공") + void addMultiTeamSuccess() { + //given + Game game = games.get(0); + + //when + game.addTeam(mockTeams.get(0)); + game.addTeam(mockTeams.get(1)); + + //then + assertEquals(2, game.getTeams().size()); + assertEquals(mockTeams.get(0), game.getTeams().get(0)); + assertEquals(mockTeams.get(1), game.getTeams().get(1)); + } + + @Test + @DisplayName("두개 이상의 Team 추가 실패") + void addExceedTeamFailed() { + //given + Game game = games.get(0); + + //when + game.addTeam(mockTeams.get(0)); + game.addTeam(mockTeams.get(1)); + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> game.addTeam(mockTeams.get(2))); + assertEquals(ErrorCode.TEAM_SIZE_EXCEED, businessException.getErrorCode()); + assertEquals(ErrorCode.TEAM_SIZE_EXCEED.getMessage(), businessException.getMessage()); + } + + @Test + @DisplayName("동일한 Team 추가 실패") + void duplicatedTeamAddFailed() { + //given + Game game = games.get(0); + + //when + game.addTeam(mockTeams.get(0)); + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> game.addTeam(mockTeams.get(0))); + assertEquals(ErrorCode.TEAM_DUPLICATION, businessException.getErrorCode()); + assertEquals(ErrorCode.TEAM_DUPLICATION.getMessage(), businessException.getMessage()); + } + + @Test + @DisplayName("null 포인터 전달 시 실패") + void nullAddFailed() { + //given + Game game = games.get(0); + + //when + Team team = null; + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> game.addTeam(team)); + assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); + assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); + } + } +} diff --git a/src/test/java/com/gg/server/domain/game/service/GameDBTest.java b/src/test/java/com/gg/server/domain/game/service/GameDBTest.java index 275962291..b4e6d62e1 100644 --- a/src/test/java/com/gg/server/domain/game/service/GameDBTest.java +++ b/src/test/java/com/gg/server/domain/game/service/GameDBTest.java @@ -1,11 +1,23 @@ package com.gg.server.domain.game.service; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import java.time.LocalDateTime; +import java.util.List; + +import javax.persistence.EntityManager; + +import org.apache.http.HttpHeaders; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; import com.gg.server.admin.game.service.GameAdminService; -import com.gg.server.utils.annotation.IntegrationTest; import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.type.Mode; @@ -19,19 +31,10 @@ import com.gg.server.domain.user.data.User; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; -import java.time.LocalDateTime; -import java.util.List; -import javax.persistence.EntityManager; +import com.gg.server.utils.annotation.IntegrationTest; + import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpHeaders; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.transaction.annotation.Transactional; @IntegrationTest @RequiredArgsConstructor @@ -40,65 +43,65 @@ @Slf4j public class GameDBTest { - @Autowired - GameFindService gameFindService; - @Autowired - TestDataUtils testDataUtils; - @Autowired - AuthTokenProvider tokenProvider; - @Autowired - RankRedisRepository rankRedisRepository; - @Autowired - GameRepository gameRepository; - @Autowired - GameAdminService gameAdminService; - @Autowired - TeamRepository teamRepository; - @Autowired - TeamUserRepository teamUserRepository; - @Autowired - PChangeRepository pChangeRepository; - @Autowired - EntityManager em; - @Autowired - MockMvc mockMvc; + @Autowired + GameFindService gameFindService; + @Autowired + TestDataUtils testDataUtils; + @Autowired + AuthTokenProvider tokenProvider; + @Autowired + RankRedisRepository rankRedisRepository; + @Autowired + GameRepository gameRepository; + @Autowired + GameAdminService gameAdminService; + @Autowired + TeamRepository teamRepository; + @Autowired + TeamUserRepository teamUserRepository; + @Autowired + PChangeRepository pChangeRepository; + @Autowired + EntityManager em; + @Autowired + MockMvc mockMvc; - @Test - @DisplayName(value = "Cascade 종속삭제테스트") - @Transactional - public void Cascade종속삭제테스트() throws Exception { - pChangeRepository.deleteAll(); - gameRepository.deleteAll(); - em.flush(); - List gameList = gameRepository.findAll(); - List teamList = teamRepository.findAll(); - List teamUserList = teamUserRepository.findAll(); - log.info("GAME LIST SIZE : " + Integer.toString(gameList.size())); - log.info("TEAM LIST SIZE: " + Integer.toString(teamList.size())); - log.info("TEAM_USER LIST SIZE: " + Integer.toString(teamUserList.size())); - Assertions.assertThat(teamList.size()).isEqualTo(0); - Assertions.assertThat(teamUserList.size()).isEqualTo(0); - } + @Test + @DisplayName(value = "Cascade 종속삭제테스트") + @Transactional + public void cascadeTest() throws Exception { + pChangeRepository.deleteAll(); + gameRepository.deleteAll(); + em.flush(); + List gameList = gameRepository.findAll(); + List teamList = teamRepository.findAll(); + List teamUserList = teamUserRepository.findAll(); + log.info("GAME LIST SIZE : " + Integer.toString(gameList.size())); + log.info("TEAM LIST SIZE: " + Integer.toString(teamList.size())); + log.info("TEAM_USER LIST SIZE: " + Integer.toString(teamUserList.size())); + Assertions.assertThat(teamList.size()).isEqualTo(0); + Assertions.assertThat(teamUserList.size()).isEqualTo(0); + } - @Test - @DisplayName(value = "game 전적조회 쿼리 수 테스트") - @Transactional - public void 게임전적조회쿼리테스트() throws Exception { - Season season = testDataUtils.createSeason(); - User user = testDataUtils.createNewUser(); - for (int i = 0; i < 20; i++) { - testDataUtils.createMockMatch(user, season, LocalDateTime.now().minusMinutes(15 * i + 20), - LocalDateTime.now().minusMinutes(15 * i + 5), Mode.RANK, 2, 1); - } - //given - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - String url = "/pingpong/admin/games?page=1&seasonId=" + season.getId(); + @Test + @DisplayName(value = "game 전적조회 쿼리 수 테스트") + @Transactional + public void gameStatusQuery() throws Exception { + Season season = testDataUtils.createSeason(); + User user = testDataUtils.createNewUser(); + for (int i = 0; i < 20; i++) { + testDataUtils.createMockMatch(user, season, LocalDateTime.now().minusMinutes(15 * i + 20), + LocalDateTime.now().minusMinutes(15 * i + 5), Mode.RANK, 2, 1); + } + //given + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + String url = "/pingpong/admin/games?page=1&seasonId=" + season.getId(); - //when - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - } + //when + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + } } diff --git a/src/test/java/com/gg/server/domain/game/service/GameFindServiceTest.java b/src/test/java/com/gg/server/domain/game/service/GameFindServiceTest.java index a4bf97449..7e276ad32 100644 --- a/src/test/java/com/gg/server/domain/game/service/GameFindServiceTest.java +++ b/src/test/java/com/gg/server/domain/game/service/GameFindServiceTest.java @@ -1,103 +1,109 @@ -package com.gg.server.domain.game.service; - -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; - -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.GameListResDto; -import com.gg.server.domain.game.dto.GameResultResDto; -import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.tier.data.Tier; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; -import lombok.RequiredArgsConstructor; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Slice; -import org.springframework.data.domain.Sort; -import org.springframework.transaction.annotation.Transactional; - -@IntegrationTest -@RequiredArgsConstructor -@Transactional -public class GameFindServiceTest { - - @Autowired - GameFindService gameFindService; - @Autowired - TestDataUtils testDataUtils; - @Autowired - AuthTokenProvider tokenProvider; - @Autowired - RankRedisRepository rankRedisRepository; - - @Autowired - TierRepository tierRepository; - - @Autowired - GameRepository gameRepository; - - @BeforeEach - void init() { - testDataUtils.createTierSystem("pingpong"); - Season season = testDataUtils.createSeason(); - User newUser = testDataUtils.createNewUser(); - Tier tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); - String accessToken = tokenProvider.createToken(newUser.getId()); - String statusMsg = "status message test1"; - - LocalDateTime startTime = LocalDateTime.now().minusDays(1); - LocalDateTime endTime = startTime.plusMinutes(15); - testDataUtils.createMockMatch(newUser, season, startTime, endTime); - - LocalDateTime startTime1 = LocalDateTime.now().minusDays(2); - LocalDateTime endTime1 = startTime1.plusMinutes(15); - testDataUtils.createMockMatch(newUser, season, startTime1, endTime1); - - LocalDateTime startTime2 = LocalDateTime.now().minusDays(3); - LocalDateTime endTime2 = startTime2.plusMinutes(15); - testDataUtils.createMockMatch(newUser, season, startTime2, endTime2); - - testDataUtils.createUserRank(newUser, statusMsg, season); - RankRedis userRank = RankRedis.from(UserDto.from(newUser), season.getStartPpp(), tier.getImageUri()); - String redisHashKey = RedisKeyManager.getHashKey(season.getId()); - rankRedisRepository.addRankData(redisHashKey, newUser.getId(), userRank); - } - - @AfterEach - public void flushRedis() { - rankRedisRepository.deleteAll(); - } - @Test - void 일반game목록조회() { - Pageable pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "startTime")); - GameListResDto response = gameFindService.getNormalGameList(pageable); - Slice games = gameRepository.findAllByModeAndStatus(Mode.NORMAL, StatusType.END, pageable); - GameListResDto expect = new GameListResDto(getGameResultList(games.getContent().stream().map(Game::getId).collect(Collectors.toList())), games.isLast()); - assertThat(response).isEqualTo(expect); - } - private List getGameResultList(List games) { - List teamViews = gameRepository.findTeamsByGameIsIn(games); - return teamViews.stream().map(GameResultResDto::new).collect(Collectors.toList()); - } - - -} +package com.gg.server.domain.game.service; + +import static org.assertj.core.api.AssertionsForClassTypes.*; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; +import org.springframework.data.domain.Sort; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.data.GameRepository; +import com.gg.server.domain.game.dto.GameListResDto; +import com.gg.server.domain.game.dto.GameResultResDto; +import com.gg.server.domain.game.dto.GameTeamUser; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.rank.redis.RedisKeyManager; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.tier.data.Tier; +import com.gg.server.domain.tier.data.TierRepository; +import com.gg.server.domain.tier.exception.TierNotFoundException; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; + +@IntegrationTest +@RequiredArgsConstructor +@Transactional +public class GameFindServiceTest { + + @Autowired + GameFindService gameFindService; + @Autowired + TestDataUtils testDataUtils; + @Autowired + AuthTokenProvider tokenProvider; + @Autowired + RankRedisRepository rankRedisRepository; + + @Autowired + TierRepository tierRepository; + + @Autowired + GameRepository gameRepository; + + @BeforeEach + void init() { + testDataUtils.createTierSystem("pingpong"); + Season season = testDataUtils.createSeason(); + User newUser = testDataUtils.createNewUser(); + Tier tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); + String accessToken = tokenProvider.createToken(newUser.getId()); + String statusMsg = "status message test1"; + + LocalDateTime startTime = LocalDateTime.now().minusDays(1); + LocalDateTime endTime = startTime.plusMinutes(15); + testDataUtils.createMockMatch(newUser, season, startTime, endTime); + + LocalDateTime startTime1 = LocalDateTime.now().minusDays(2); + LocalDateTime endTime1 = startTime1.plusMinutes(15); + testDataUtils.createMockMatch(newUser, season, startTime1, endTime1); + + LocalDateTime startTime2 = LocalDateTime.now().minusDays(3); + LocalDateTime endTime2 = startTime2.plusMinutes(15); + testDataUtils.createMockMatch(newUser, season, startTime2, endTime2); + + testDataUtils.createUserRank(newUser, statusMsg, season); + RankRedis userRank = RankRedis.from(UserDto.from(newUser), season.getStartPpp(), tier.getImageUri()); + String redisHashKey = RedisKeyManager.getHashKey(season.getId()); + rankRedisRepository.addRankData(redisHashKey, newUser.getId(), userRank); + } + + @AfterEach + public void flushRedis() { + rankRedisRepository.deleteAll(); + } + + @Test + void normalGameListGet() { + Pageable pageable = PageRequest.of(0, 10, Sort.by(Sort.Direction.DESC, "startTime")); + GameListResDto response = gameFindService.getNormalGameList(pageable); + Slice games = gameRepository.findAllByModeAndStatus(Mode.NORMAL, StatusType.END, pageable); + GameListResDto expect = new GameListResDto( + getGameResultList(games.getContent().stream().map(Game::getId).collect(Collectors.toList())), + games.isLast()); + assertThat(response).isEqualTo(expect); + } + + private List getGameResultList(List games) { + List teamViews = gameRepository.findTeamsByGameIsIn(games); + return teamViews.stream().map(GameResultResDto::new).collect(Collectors.toList()); + } + +} diff --git a/src/test/java/com/gg/server/domain/game/service/GameServiceTest.java b/src/test/java/com/gg/server/domain/game/service/GameServiceTest.java index 3afe616a5..c618e7d6f 100644 --- a/src/test/java/com/gg/server/domain/game/service/GameServiceTest.java +++ b/src/test/java/com/gg/server/domain/game/service/GameServiceTest.java @@ -1,117 +1,123 @@ -package com.gg.server.domain.game.service; - -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; - -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.request.RankResultReqDto; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.rank.data.Rank; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.exception.RankNotFoundException; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.team.data.Team; -import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.tier.data.Tier; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import java.time.LocalDateTime; -import lombok.RequiredArgsConstructor; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; - -@IntegrationTest -@RequiredArgsConstructor -@Transactional -public class GameServiceTest { - - @Autowired - RankRedisRepository rankRedisRepository; - - @Autowired - GameRepository gameRepository; - @Autowired - TeamRepository teamRepository; - - @Autowired - TeamUserRepository teamUserRepository; - - @Autowired - RankRepository rankRepository; - - @Autowired - TierRepository tierRepository; - - @Autowired - GameService gameService; - - User user1; - User user2; - Game game1; - Team team1, team2; - @Autowired - TestDataUtils testDataUtils; - @Autowired - AuthTokenProvider tokenProvider; - - @BeforeEach - void init() { - testDataUtils.createTierSystem("pingpong"); - Season season = testDataUtils.createSeason(); - Tier tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); - user1 = testDataUtils.createNewUser(); - user2 = testDataUtils.createNewUser(); - LocalDateTime now = LocalDateTime.now(); - LocalDateTime startTime = LocalDateTime.of(now.getYear(), now.getMonthValue(), now.getDayOfMonth(), now.getHour(), now.getMinute()); - game1 = gameRepository.save(new Game(season, StatusType.LIVE, Mode.RANK, startTime, startTime.plusMinutes(15))); - team1 = teamRepository.save(new Team(game1, -1, false)); - team2 = teamRepository.save(new Team(game1, -1, true)); - teamUserRepository.save(new TeamUser(team1, user1)); - teamUserRepository.save(new TeamUser(team2, user2)); - String statusMsg = "status message test1"; - - testDataUtils.createUserRank(user1, statusMsg, season); - RankRedis userRank = RankRedis.from(UserDto.from(user1), season.getStartPpp(), tier.getImageUri()); - String redisHashKey = RedisKeyManager.getHashKey(season.getId()); - rankRedisRepository.addRankData(redisHashKey, user1.getId(), userRank); - statusMsg = "status message test2"; - testDataUtils.createUserRank(user2, statusMsg, season); - RankRedis userRank2 = RankRedis.from(UserDto.from(user2), season.getStartPpp(), tier.getImageUri()); - rankRedisRepository.addRankData(redisHashKey, user2.getId(), userRank2); - } - @AfterEach - public void flushRedis() { - rankRedisRepository.deleteAll(); - } - - @Test - void ppp변화량_조회_test() throws Exception { - String key = RedisKeyManager.getHashKey(game1.getSeason().getId()); - Integer user1BeforePpp = rankRedisRepository.findRankByUserId(key, user1.getId()) - .getPpp(); - System.out.println("Before ppp: " + user1BeforePpp); - assertThat(gameService.createRankResult(new RankResultReqDto(game1.getId(), team1.getId(), - 1, team2.getId(), 2), user1.getId())).isEqualTo(true); - Integer user1AfterPpp = rankRedisRepository.findRankByUserId(key, user1.getId()).getPpp(); - System.out.println("After ppp: " + rankRedisRepository.findRankByUserId(key, user1.getId()) - .getPpp()); - Rank rank = rankRepository.findByUserIdAndSeasonId(user1.getId(), game1.getSeason().getId()) - .orElseThrow(RankNotFoundException::new); - assertThat(rank.getPpp()).isEqualTo(user1AfterPpp); - assertThat(user1BeforePpp).isGreaterThan(user1AfterPpp); - } -} +package com.gg.server.domain.game.service; + +import static org.assertj.core.api.AssertionsForClassTypes.*; + +import java.time.LocalDateTime; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.data.GameRepository; +import com.gg.server.domain.game.dto.request.RankResultReqDto; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.rank.data.Rank; +import com.gg.server.domain.rank.data.RankRepository; +import com.gg.server.domain.rank.exception.RankNotFoundException; +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.rank.redis.RedisKeyManager; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.team.data.Team; +import com.gg.server.domain.team.data.TeamRepository; +import com.gg.server.domain.team.data.TeamUser; +import com.gg.server.domain.team.data.TeamUserRepository; +import com.gg.server.domain.tier.data.Tier; +import com.gg.server.domain.tier.data.TierRepository; +import com.gg.server.domain.tier.exception.TierNotFoundException; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; + +@IntegrationTest +@RequiredArgsConstructor +@Transactional +public class GameServiceTest { + + @Autowired + RankRedisRepository rankRedisRepository; + + @Autowired + GameRepository gameRepository; + @Autowired + TeamRepository teamRepository; + + @Autowired + TeamUserRepository teamUserRepository; + + @Autowired + RankRepository rankRepository; + + @Autowired + TierRepository tierRepository; + + @Autowired + GameService gameService; + + User user1; + User user2; + Game game1; + Team team1; + Team team2; + @Autowired + TestDataUtils testDataUtils; + @Autowired + AuthTokenProvider tokenProvider; + + @BeforeEach + void init() { + testDataUtils.createTierSystem("pingpong"); + Season season = testDataUtils.createSeason(); + Tier tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); + user1 = testDataUtils.createNewUser(); + user2 = testDataUtils.createNewUser(); + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startTime = LocalDateTime.of(now.getYear(), now.getMonthValue(), now.getDayOfMonth(), + now.getHour(), now.getMinute()); + game1 = gameRepository.save(new Game(season, StatusType.LIVE, Mode.RANK, startTime, startTime.plusMinutes(15))); + team1 = teamRepository.save(new Team(game1, -1, false)); + team2 = teamRepository.save(new Team(game1, -1, true)); + teamUserRepository.save(new TeamUser(team1, user1)); + teamUserRepository.save(new TeamUser(team2, user2)); + String statusMsg = "status message test1"; + + testDataUtils.createUserRank(user1, statusMsg, season); + RankRedis userRank = RankRedis.from(UserDto.from(user1), season.getStartPpp(), tier.getImageUri()); + String redisHashKey = RedisKeyManager.getHashKey(season.getId()); + rankRedisRepository.addRankData(redisHashKey, user1.getId(), userRank); + statusMsg = "status message test2"; + testDataUtils.createUserRank(user2, statusMsg, season); + RankRedis userRank2 = RankRedis.from(UserDto.from(user2), season.getStartPpp(), tier.getImageUri()); + rankRedisRepository.addRankData(redisHashKey, user2.getId(), userRank2); + } + + @AfterEach + public void flushRedis() { + rankRedisRepository.deleteAll(); + } + + @Test + void ppp_change_test() throws Exception { + String key = RedisKeyManager.getHashKey(game1.getSeason().getId()); + Integer user1BeforePpp = rankRedisRepository.findRankByUserId(key, user1.getId()) + .getPpp(); + System.out.println("Before ppp: " + user1BeforePpp); + assertThat(gameService.createRankResult(new RankResultReqDto(game1.getId(), team1.getId(), + 1, team2.getId(), 2), user1.getId())).isEqualTo(true); + Integer user1AfterPpp = rankRedisRepository.findRankByUserId(key, user1.getId()).getPpp(); + System.out.println("After ppp: " + rankRedisRepository.findRankByUserId(key, user1.getId()) + .getPpp()); + Rank rank = rankRepository.findByUserIdAndSeasonId(user1.getId(), game1.getSeason().getId()) + .orElseThrow(RankNotFoundException::new); + assertThat(rank.getPpp()).isEqualTo(user1AfterPpp); + assertThat(user1BeforePpp).isGreaterThan(user1AfterPpp); + } +} diff --git a/src/test/java/com/gg/server/domain/game/service/GameStatusServiceTest.java b/src/test/java/com/gg/server/domain/game/service/GameStatusServiceTest.java index 9a874f478..0578b6dac 100644 --- a/src/test/java/com/gg/server/domain/game/service/GameStatusServiceTest.java +++ b/src/test/java/com/gg/server/domain/game/service/GameStatusServiceTest.java @@ -1,103 +1,113 @@ -package com.gg.server.domain.game.service; - -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; - -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.data.Team; -import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; -import com.gg.server.utils.TestDataUtils; -import java.time.LocalDateTime; -import lombok.RequiredArgsConstructor; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; - -@IntegrationTest -@RequiredArgsConstructor -@Transactional -public class GameStatusServiceTest { - @Autowired - private GameRepository gameRepository; - @Autowired private SeasonRepository seasonRepository; - @Autowired - private GameStatusService gameStatusService; - @Autowired - private RankRedisRepository rankRedisRepository; - @Autowired - TestDataUtils testDataUtils; - @Autowired - private TeamRepository teamRepository; - @Autowired - private TeamUserRepository teamUserRepository; - @Autowired - private SlotManagementRepository slotManagementRepository; - private Season season; - User user1; - User user2; - Game game1; - Game liveGame; - - @BeforeEach - void init() { - season = seasonRepository.save(new Season("test season", LocalDateTime.of(2023, 5, 14, 0, 0), LocalDateTime.of(2999, 12, 31, 23, 59), - 1000, 100)); - user1 = testDataUtils.createNewUser("test2", "test2@naver.com", RacketType.NONE, SnsType.EMAIL, RoleType.USER); - user2 = testDataUtils.createNewUser("test3", "test3@naver.com", RacketType.NONE, SnsType.EMAIL, RoleType.USER); - LocalDateTime now = LocalDateTime.now(); - LocalDateTime startTime = LocalDateTime.of(now.getYear(), now.getMonthValue(), now.getDayOfMonth(), now.getHour(), now.getMinute()); - game1 = gameRepository.save(new Game(season, StatusType.BEFORE, Mode.RANK, startTime, startTime.plusMinutes(15))); - Team team1 = teamRepository.save(new Team(game1, 1, false)); - Team team2 = teamRepository.save(new Team(game1, 2, true)); - teamUserRepository.save(new TeamUser(team1, user1)); - teamUserRepository.save(new TeamUser(team2, user2)); - liveGame = gameRepository.save(new Game(season, StatusType.LIVE, Mode.RANK, startTime.minusMinutes(15), startTime)); - } - @AfterEach - public void flushRedis() { - rankRedisRepository.deleteAll(); - } - @Test - void gameBefore상태변경테스트() throws Exception{ - System.out.println("g1.startTime: " + game1.getStartTime()); - System.out.println(game1.getStatus()); - gameStatusService.updateBeforeToLiveStatus(); - assertThat(game1.getStatus()).isEqualTo(StatusType.LIVE); - } - - @Test - void gameLIVE상태변경테스트() throws Exception{ - gameStatusService.updateLiveToWaitStatus(); - assertThat(liveGame.getStatus()).isEqualTo(StatusType.WAIT); - } - - @Test - void game5분전알림테스트() throws Exception{ - SlotManagement slotManagement = SlotManagement.builder() - .futureSlotTime(12) - .pastSlotTime(0) - .openMinute(5) - .gameInterval(15) - .startTime(LocalDateTime.now().minusMinutes(1)) - .build(); - slotManagementRepository.save(slotManagement); - System.out.println("=============="); - gameStatusService.imminentGame(); - } -} +package com.gg.server.domain.game.service; + +import static org.assertj.core.api.AssertionsForClassTypes.*; + +import java.time.LocalDateTime; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.data.GameRepository; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.data.SeasonRepository; +import com.gg.server.domain.slotmanagement.SlotManagement; +import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; +import com.gg.server.domain.team.data.Team; +import com.gg.server.domain.team.data.TeamRepository; +import com.gg.server.domain.team.data.TeamUser; +import com.gg.server.domain.team.data.TeamUserRepository; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; + +@IntegrationTest +@RequiredArgsConstructor +@Transactional +public class GameStatusServiceTest { + @Autowired + private GameRepository gameRepository; + @Autowired + private SeasonRepository seasonRepository; + @Autowired + private GameStatusService gameStatusService; + @Autowired + private RankRedisRepository rankRedisRepository; + @Autowired + TestDataUtils testDataUtils; + @Autowired + private TeamRepository teamRepository; + @Autowired + private TeamUserRepository teamUserRepository; + @Autowired + private SlotManagementRepository slotManagementRepository; + private Season season; + User user1; + User user2; + Game game1; + Game liveGame; + + @BeforeEach + void init() { + season = seasonRepository.save( + new Season("test season", LocalDateTime.of(2023, 5, 14, 0, 0), LocalDateTime.of(2999, 12, 31, 23, 59), + 1000, 100)); + user1 = testDataUtils.createNewUser("test2", "test2@naver.com", RacketType.NONE, SnsType.EMAIL, RoleType.USER); + user2 = testDataUtils.createNewUser("test3", "test3@naver.com", RacketType.NONE, SnsType.EMAIL, RoleType.USER); + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startTime = LocalDateTime.of(now.getYear(), now.getMonthValue(), now.getDayOfMonth(), + now.getHour(), now.getMinute()); + game1 = gameRepository.save( + new Game(season, StatusType.BEFORE, Mode.RANK, startTime, startTime.plusMinutes(15))); + Team team1 = teamRepository.save(new Team(game1, 1, false)); + Team team2 = teamRepository.save(new Team(game1, 2, true)); + teamUserRepository.save(new TeamUser(team1, user1)); + teamUserRepository.save(new TeamUser(team2, user2)); + liveGame = gameRepository.save( + new Game(season, StatusType.LIVE, Mode.RANK, startTime.minusMinutes(15), startTime)); + } + + @AfterEach + public void flushRedis() { + rankRedisRepository.deleteAll(); + } + + @Test + void gameBeforeStatusChange() throws Exception { + System.out.println("g1.startTime: " + game1.getStartTime()); + System.out.println(game1.getStatus()); + gameStatusService.updateBeforeToLiveStatus(); + assertThat(game1.getStatus()).isEqualTo(StatusType.LIVE); + } + + @Test + void gameLiveStatusChange() throws Exception { + gameStatusService.updateLiveToWaitStatus(); + assertThat(liveGame.getStatus()).isEqualTo(StatusType.WAIT); + } + + @Test + void game5BeforeNoti() throws Exception { + SlotManagement slotManagement = SlotManagement.builder() + .futureSlotTime(12) + .pastSlotTime(0) + .openMinute(5) + .gameInterval(15) + .startTime(LocalDateTime.now().minusMinutes(1)) + .build(); + slotManagementRepository.save(slotManagement); + System.out.println("=============="); + gameStatusService.imminentGame(); + } +} diff --git a/src/test/java/com/gg/server/domain/item/controller/ItemGiftControllerTest.java b/src/test/java/com/gg/server/domain/item/controller/ItemGiftControllerTest.java index da7d65cb2..99a507d8d 100644 --- a/src/test/java/com/gg/server/domain/item/controller/ItemGiftControllerTest.java +++ b/src/test/java/com/gg/server/domain/item/controller/ItemGiftControllerTest.java @@ -1,13 +1,11 @@ package com.gg.server.domain.item.controller; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.item.dto.ItemGiftRequestDto; -import com.gg.server.domain.item.service.ItemService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import lombok.RequiredArgsConstructor; +import static org.mockito.Mockito.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import javax.transaction.Transactional; + import org.apache.http.HttpHeaders; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -16,12 +14,16 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; -import javax.transaction.Transactional; -import static org.mockito.Mockito.*; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.domain.item.dto.ItemGiftRequestDto; +import com.gg.server.domain.item.service.ItemService; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @IntegrationTest @@ -29,47 +31,47 @@ @Transactional class ItemGiftControllerTest { - @Autowired - TestDataUtils testDataUtils; + @Autowired + TestDataUtils testDataUtils; - @Autowired - AuthTokenProvider tokenProvider; + @Autowired + AuthTokenProvider tokenProvider; - @Autowired - ObjectMapper objectMapper; + @Autowired + ObjectMapper objectMapper; - @Autowired - private MockMvc mockMvc; + @Autowired + private MockMvc mockMvc; - @MockBean - private ItemService itemService; + @MockBean + private ItemService itemService; - @Test - @DisplayName("[Post]/pingpong/items/gift/{itemId} - success") - public void giftItemSuccessTest() throws Exception { + @Test + @DisplayName("[Post]/pingpong/items/gift/{itemId} - success") + public void giftItemSuccessTest() throws Exception { - // given - Long testItemId = 1L; - UserDto testUser = UserDto.builder() - .id(1L) - .intraId("testIntraId") - .build(); + // given + Long testItemId = 1L; + UserDto testUser = UserDto.builder() + .id(1L) + .intraId("testIntraId") + .build(); - ItemGiftRequestDto requestDto = new ItemGiftRequestDto("recipientId"); + ItemGiftRequestDto requestDto = new ItemGiftRequestDto("recipientId"); - doNothing().when(itemService).giftItem(testItemId, requestDto.getOwnerId(), testUser); + doNothing().when(itemService).giftItem(testItemId, requestDto.getOwnerId(), testUser); - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - System.out.println(userId); - String url = "/pingpong/items/gift/" + testItemId; + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + System.out.println(userId); + String url = "/pingpong/items/gift/" + testItemId; - // when - mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON) - .content(objectMapper.writeValueAsString(requestDto))) - .andExpect(status().isCreated()); + // when + mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(requestDto))) + .andExpect(status().isCreated()); - } + } } diff --git a/src/test/java/com/gg/server/domain/item/controller/ItemPurchaseControllerTest.java b/src/test/java/com/gg/server/domain/item/controller/ItemPurchaseControllerTest.java index dbe2dfee5..b666079bb 100644 --- a/src/test/java/com/gg/server/domain/item/controller/ItemPurchaseControllerTest.java +++ b/src/test/java/com/gg/server/domain/item/controller/ItemPurchaseControllerTest.java @@ -1,12 +1,11 @@ package com.gg.server.domain.item.controller; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.item.service.ItemService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import lombok.RequiredArgsConstructor; +import static org.mockito.Mockito.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import javax.transaction.Transactional; + import org.apache.http.HttpHeaders; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -14,11 +13,15 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.web.servlet.MockMvc; -import javax.transaction.Transactional; -import static org.mockito.Mockito.*; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.domain.item.service.ItemService; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @IntegrationTest @@ -26,43 +29,43 @@ @Transactional class ItemPurchaseControllerTest { - @Autowired - TestDataUtils testDataUtils; + @Autowired + TestDataUtils testDataUtils; - @Autowired - AuthTokenProvider tokenProvider; + @Autowired + AuthTokenProvider tokenProvider; - @Autowired - ObjectMapper objectMapper; + @Autowired + ObjectMapper objectMapper; - @Autowired - private MockMvc mockMvc; + @Autowired + private MockMvc mockMvc; - @MockBean - private ItemService itemService; + @MockBean + private ItemService itemService; - @Test - @DisplayName("[Post]/pingpong/items/purchases/{itemId} - success") - public void purchaseItemSuccessTest() throws Exception { + @Test + @DisplayName("[Post]/pingpong/items/purchases/{itemId} - success") + public void purchaseItemSuccessTest() throws Exception { - // given - Long testItemId = 1L; - UserDto testUser = UserDto.builder() - .id(1L) - .intraId("testIntraId") - .build(); + // given + Long testItemId = 1L; + UserDto testUser = UserDto.builder() + .id(1L) + .intraId("testIntraId") + .build(); - doNothing().when(itemService).purchaseItem(testItemId, testUser); + doNothing().when(itemService).purchaseItem(testItemId, testUser); - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - System.out.println(userId); - String url = "/pingpong/items/purchases/" + testItemId; + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + System.out.println(userId); + String url = "/pingpong/items/purchases/" + testItemId; - // when - mockMvc.perform(post(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isCreated()); + // when + mockMvc.perform(post(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isCreated()); - } + } } diff --git a/src/test/java/com/gg/server/domain/item/controller/ItemStoreListControllerTest.java b/src/test/java/com/gg/server/domain/item/controller/ItemStoreListControllerTest.java index d974ead62..8b8821b3a 100644 --- a/src/test/java/com/gg/server/domain/item/controller/ItemStoreListControllerTest.java +++ b/src/test/java/com/gg/server/domain/item/controller/ItemStoreListControllerTest.java @@ -1,30 +1,34 @@ package com.gg.server.domain.item.controller; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.item.data.ItemRepository; -import com.gg.server.domain.item.dto.ItemStoreListResponseDto; -import com.gg.server.domain.item.dto.ItemStoreResponseDto; -import com.gg.server.domain.item.service.ItemService; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import lombok.RequiredArgsConstructor; +import static com.gg.server.domain.item.type.ItemType.*; +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Mockito.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.util.Arrays; +import java.util.List; + +import javax.transaction.Transactional; + import org.apache.http.HttpHeaders; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.test.web.servlet.MockMvc; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.web.servlet.MockMvc; -import static com.gg.server.domain.item.type.ItemType.*; -import static org.assertj.core.api.Assertions.assertThat; -import javax.transaction.Transactional; -import java.util.Arrays; -import java.util.List; -import static org.mockito.Mockito.when; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.domain.item.data.ItemRepository; +import com.gg.server.domain.item.dto.ItemStoreListResponseDto; +import com.gg.server.domain.item.dto.ItemStoreResponseDto; +import com.gg.server.domain.item.service.ItemService; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @IntegrationTest @@ -32,69 +36,72 @@ @Transactional class ItemStoreListControllerTest { - @Autowired - TestDataUtils testDataUtils; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - ObjectMapper objectMapper; - - @Autowired - private MockMvc mockMvc; - - @Autowired - ItemRepository itemRepository; - - @MockBean - private ItemService itemService; - - @Test - @DisplayName("[Get]/pingpong/items/store") - public void getAllItemsTest() throws Exception { - - //given - List testItems = Arrays.asList( - new ItemStoreResponseDto(1L, "itemName 1", "mainContent 1","subContent 1", MEGAPHONE, "ImageUrl 1", 1000, 10, 900), - new ItemStoreResponseDto(2L, "itemName 2", "mainContent 2","subContent 2", PROFILE_IMAGE, "ImageUrl 2", 2000, 20, 1800), - new ItemStoreResponseDto(3L, "itemName 3", "mainContent 2","subContent 2", TEXT_COLOR, "ImageUrl 3", 3000, 30, 2700) - ); - ItemStoreListResponseDto testResponse = new ItemStoreListResponseDto(testItems); - when(itemService.getAllItems()).thenReturn(testResponse); - - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - System.out.println(userId); - String url = "/pingpong/items/store"; - - //when - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - //then - ItemStoreListResponseDto result = objectMapper.readValue(contentAsString, ItemStoreListResponseDto.class); - assertThat(result.getItemList()).isNotNull(); - assertThat(result.getItemList()).isNotEmpty(); - assertThat(result.getItemList()).hasSize(testItems.size()); - - for (int i = 0; i < result.getItemList().size(); i++) { - ItemStoreResponseDto actual = result.getItemList().get(i); - ItemStoreResponseDto expected = testItems.get(i); - - assertThat(actual.getItemId()).isEqualTo(expected.getItemId()); - assertThat(actual.getItemName()).isEqualTo(expected.getItemName()); - assertThat(actual.getMainContent()).isEqualTo(expected.getMainContent()); - assertThat(actual.getSubContent()).isEqualTo(expected.getSubContent()); - assertThat(actual.getItemType()).isEqualTo(expected.getItemType()); - assertThat(actual.getImageUri()).isEqualTo(expected.getImageUri()); - assertThat(actual.getOriginalPrice()).isEqualTo(expected.getOriginalPrice()); - assertThat(actual.getDiscount()).isEqualTo(expected.getDiscount()); - assertThat(actual.getSalePrice()).isEqualTo(expected.getSalePrice()); - } - - System.out.println(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(result)); - } + @Autowired + TestDataUtils testDataUtils; + + @Autowired + AuthTokenProvider tokenProvider; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + private MockMvc mockMvc; + + @Autowired + ItemRepository itemRepository; + + @MockBean + private ItemService itemService; + + @Test + @DisplayName("[Get]/pingpong/items/store") + public void getAllItemsTest() throws Exception { + + //given + List testItems = Arrays.asList( + new ItemStoreResponseDto(1L, "itemName 1", "mainContent 1", "subContent 1", MEGAPHONE, "ImageUrl 1", 1000, + 10, 900), + new ItemStoreResponseDto(2L, "itemName 2", "mainContent 2", "subContent 2", PROFILE_IMAGE, "ImageUrl 2", + 2000, 20, 1800), + new ItemStoreResponseDto(3L, "itemName 3", "mainContent 2", "subContent 2", TEXT_COLOR, "ImageUrl 3", 3000, + 30, 2700) + ); + ItemStoreListResponseDto testResponse = new ItemStoreListResponseDto(testItems); + when(itemService.getAllItems()).thenReturn(testResponse); + + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + System.out.println(userId); + String url = "/pingpong/items/store"; + + //when + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + //then + ItemStoreListResponseDto result = objectMapper.readValue(contentAsString, ItemStoreListResponseDto.class); + assertThat(result.getItemList()).isNotNull(); + assertThat(result.getItemList()).isNotEmpty(); + assertThat(result.getItemList()).hasSize(testItems.size()); + + for (int i = 0; i < result.getItemList().size(); i++) { + ItemStoreResponseDto actual = result.getItemList().get(i); + ItemStoreResponseDto expected = testItems.get(i); + + assertThat(actual.getItemId()).isEqualTo(expected.getItemId()); + assertThat(actual.getItemName()).isEqualTo(expected.getItemName()); + assertThat(actual.getMainContent()).isEqualTo(expected.getMainContent()); + assertThat(actual.getSubContent()).isEqualTo(expected.getSubContent()); + assertThat(actual.getItemType()).isEqualTo(expected.getItemType()); + assertThat(actual.getImageUri()).isEqualTo(expected.getImageUri()); + assertThat(actual.getOriginalPrice()).isEqualTo(expected.getOriginalPrice()); + assertThat(actual.getDiscount()).isEqualTo(expected.getDiscount()); + assertThat(actual.getSalePrice()).isEqualTo(expected.getSalePrice()); + } + + System.out.println(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(result)); + } } diff --git a/src/test/java/com/gg/server/domain/item/controller/UserItemResponseControllerTest.java b/src/test/java/com/gg/server/domain/item/controller/UserItemResponseControllerTest.java index 2ee964640..711d02608 100644 --- a/src/test/java/com/gg/server/domain/item/controller/UserItemResponseControllerTest.java +++ b/src/test/java/com/gg/server/domain/item/controller/UserItemResponseControllerTest.java @@ -1,9 +1,8 @@ package com.gg.server.domain.item.controller; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.item.service.ItemService; -import com.gg.server.utils.TestDataUtils; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -11,39 +10,42 @@ import org.springframework.http.HttpHeaders; import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.domain.item.service.ItemService; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; @IntegrationTest @AutoConfigureMockMvc @Transactional public class UserItemResponseControllerTest { - @Autowired - ItemService itemService; + @Autowired + ItemService itemService; - @Autowired - TestDataUtils testDataUtils; + @Autowired + TestDataUtils testDataUtils; - @Autowired - ObjectMapper objectMapper; + @Autowired + ObjectMapper objectMapper; - @Autowired - MockMvc mockMvc; + @Autowired + MockMvc mockMvc; - @Test - @DisplayName("GET /pingpong/items?page=1&size=20") - public void getItemByUser() throws Exception { - String accessToken = testDataUtils.getLoginAccessToken(); + @Test + @DisplayName("GET /pingpong/items?page=1&size=20") + public void getItemByUser() throws Exception { + String accessToken = testDataUtils.getLoginAccessToken(); - Integer page = 1; - Integer size = 20; + Integer page = 1; + Integer size = 20; - String url = "/pingpong/items?page=" + page + "&size=" + size; + String url = "/pingpong/items?page=" + page + "&size=" + size; - mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - } -} \ No newline at end of file + mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + } +} diff --git a/src/test/java/com/gg/server/domain/match/dto/MatchStatusDtoUnitTest.java b/src/test/java/com/gg/server/domain/match/dto/MatchStatusDtoUnitTest.java index 545eea571..60b289d45 100644 --- a/src/test/java/com/gg/server/domain/match/dto/MatchStatusDtoUnitTest.java +++ b/src/test/java/com/gg/server/domain/match/dto/MatchStatusDtoUnitTest.java @@ -1,13 +1,9 @@ package com.gg.server.domain.match.dto; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.utils.annotation.UnitTest; import java.time.LocalDateTime; + import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -15,84 +11,88 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.slotmanagement.SlotManagement; +import com.gg.server.utils.annotation.UnitTest; + @UnitTest class MatchStatusDtoUnitTest { - @Nested - @DisplayName("MatchStatusDto(Game game, String userIntraId, String enemyIntraId, SlotManagement slotManagement)") - class MatchStatusDtoConstructor { - Game tournamentGame; - Game rankGame; - Game normalGame; - SlotManagement slotManagement; - String userIntraId = "myId"; - String enemyIntraId = "enemyId"; - LocalDateTime time = LocalDateTime.now(); - - @BeforeEach - void setup() { - tournamentGame = mock(Game.class); - rankGame = mock(Game.class); - normalGame = mock(Game.class); - slotManagement = mock(SlotManagement.class); - when(slotManagement.getOpenMinute()).thenReturn(5); - } - - @ParameterizedTest - @DisplayName("Game Mode 가 토너먼트인 경우 항상 Imminent") - @ValueSource(ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) - void IfGameTypeTournamentAlwaysImminent(int arg) { - //Arrange - when(tournamentGame.getMode()).thenReturn(Mode.TOURNAMENT); - when(tournamentGame.getStartTime()).thenReturn(time.plusMinutes(arg)); - - //Act - MatchStatusDto dto = new MatchStatusDto(tournamentGame, userIntraId, enemyIntraId, slotManagement); - - //Assert - Assertions.assertThat(dto.getIsImminent()).isEqualTo(true); - } - - @ParameterizedTest - @DisplayName("Game Mode 가 토너먼트가 아닌 경우 시간에 따라 NotImminent") - @ValueSource(ints = {6, 7, 8, 9, 10}) - void RankAndNormalGameNotImminent(int arg) { - //Arrange - when(rankGame.getMode()).thenReturn(Mode.RANK); - when(normalGame.getMode()).thenReturn(Mode.RANK); - when(rankGame.getStartTime()).thenReturn(time.plusMinutes(arg)); - when(normalGame.getStartTime()).thenReturn(time.plusMinutes(arg)); - - //Act - MatchStatusDto rankDto = new MatchStatusDto(rankGame, userIntraId, enemyIntraId, slotManagement); - MatchStatusDto normalDto = new MatchStatusDto(normalGame, userIntraId, enemyIntraId, slotManagement); - - //Assert - Assertions.assertThat(rankDto.getIsImminent()) - .isEqualTo(normalDto.getIsImminent()) - .isEqualTo(false); - } - - @ParameterizedTest - @DisplayName("Game Mode 가 토너먼트가 아닌 경우 시간에 따라 Imminent") - @ValueSource(ints = {0, 1, 2, 3, 4, 5}) - void RankAndNormalGameImminent(int arg) { - //Arrange - when(rankGame.getMode()).thenReturn(Mode.RANK); - when(normalGame.getMode()).thenReturn(Mode.RANK); - when(rankGame.getStartTime()).thenReturn(time.plusMinutes(arg)); - when(normalGame.getStartTime()).thenReturn(time.plusMinutes(arg)); - - //Act - MatchStatusDto rankDto = new MatchStatusDto(rankGame, userIntraId, enemyIntraId, slotManagement); - MatchStatusDto normalDto = new MatchStatusDto(normalGame, userIntraId, enemyIntraId, slotManagement); - - //Assert - Assertions.assertThat(rankDto.getIsImminent()) - .isEqualTo(normalDto.getIsImminent()) - .isEqualTo(true); - } - } - - -} \ No newline at end of file + @Nested + @DisplayName("MatchStatusDto(Game game, String userIntraId, String enemyIntraId, SlotManagement slotManagement)") + class MatchStatusDtoConstructor { + Game tournamentGame; + Game rankGame; + Game normalGame; + SlotManagement slotManagement; + String userIntraId = "myId"; + String enemyIntraId = "enemyId"; + LocalDateTime time = LocalDateTime.now(); + + @BeforeEach + void setup() { + tournamentGame = mock(Game.class); + rankGame = mock(Game.class); + normalGame = mock(Game.class); + slotManagement = mock(SlotManagement.class); + when(slotManagement.getOpenMinute()).thenReturn(5); + } + + @ParameterizedTest + @DisplayName("Game Mode 가 토너먼트인 경우 항상 Imminent") + @ValueSource(ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) + void ifGameTypeTournamentAlwaysImminent(int arg) { + //Arrange + when(tournamentGame.getMode()).thenReturn(Mode.TOURNAMENT); + when(tournamentGame.getStartTime()).thenReturn(time.plusMinutes(arg)); + + //Act + MatchStatusDto dto = new MatchStatusDto(tournamentGame, userIntraId, enemyIntraId, slotManagement); + + //Assert + Assertions.assertThat(dto.getIsImminent()).isEqualTo(true); + } + + @ParameterizedTest + @DisplayName("Game Mode 가 토너먼트가 아닌 경우 시간에 따라 NotImminent") + @ValueSource(ints = {6, 7, 8, 9, 10}) + void rankAndNormalGameNotImminent(int arg) { + //Arrange + when(rankGame.getMode()).thenReturn(Mode.RANK); + when(normalGame.getMode()).thenReturn(Mode.RANK); + when(rankGame.getStartTime()).thenReturn(time.plusMinutes(arg)); + when(normalGame.getStartTime()).thenReturn(time.plusMinutes(arg)); + + //Act + MatchStatusDto rankDto = new MatchStatusDto(rankGame, userIntraId, enemyIntraId, slotManagement); + MatchStatusDto normalDto = new MatchStatusDto(normalGame, userIntraId, enemyIntraId, slotManagement); + + //Assert + Assertions.assertThat(rankDto.getIsImminent()) + .isEqualTo(normalDto.getIsImminent()) + .isEqualTo(false); + } + + @ParameterizedTest + @DisplayName("Game Mode 가 토너먼트가 아닌 경우 시간에 따라 Imminent") + @ValueSource(ints = {0, 1, 2, 3, 4, 5}) + void rankAndNormalGameImminent(int arg) { + //Arrange + when(rankGame.getMode()).thenReturn(Mode.RANK); + when(normalGame.getMode()).thenReturn(Mode.RANK); + when(rankGame.getStartTime()).thenReturn(time.plusMinutes(arg)); + when(normalGame.getStartTime()).thenReturn(time.plusMinutes(arg)); + + //Act + MatchStatusDto rankDto = new MatchStatusDto(rankGame, userIntraId, enemyIntraId, slotManagement); + MatchStatusDto normalDto = new MatchStatusDto(normalGame, userIntraId, enemyIntraId, slotManagement); + + //Assert + Assertions.assertThat(rankDto.getIsImminent()) + .isEqualTo(normalDto.getIsImminent()) + .isEqualTo(true); + } + } + +} diff --git a/src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java b/src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java index 9c8eac3f5..a7fa29104 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java +++ b/src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java @@ -1,141 +1,150 @@ -package com.gg.server.domain.match.service; - -import com.gg.server.admin.penalty.data.PenaltyAdminRepository; -import com.gg.server.admin.penalty.type.PenaltyKey; -import com.gg.server.utils.MatchTestUtils; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.match.data.RedisMatchTimeRepository; -import com.gg.server.domain.match.data.RedisMatchUserRepository; -import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.match.type.Option; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.penalty.redis.PenaltyUserRedisRepository; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.utils.TestDataUtils; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.Random; -import lombok.RequiredArgsConstructor; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.data.redis.connection.RedisConnection; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.transaction.annotation.Transactional; - -@IntegrationTest -@Transactional -@AutoConfigureMockMvc -@RequiredArgsConstructor -class MatchBothServiceTest { - @Autowired - MatchFindService matchFindService; - @Autowired - MatchService matchService; - @Autowired - RedisMatchTimeRepository redisMatchTimeRepository; - @Autowired - RedisMatchUserRepository redisMatchUserRepository; - @Autowired - RedisConnectionFactory redisConnectionFactory; - @Autowired - RedisTemplate redisTemplate; - @Autowired - MatchTestUtils matchTestSetting; - @Autowired - GameRepository gameRepository; - @Autowired - RankRedisRepository rankRedisRepository; - @Autowired - NotiRepository notiRepository; - @Autowired - PenaltyAdminRepository penaltyAdminRepository; - @Autowired - PenaltyUserRedisRepository penaltyUserRedisRepository; - @Autowired - SlotManagementRepository slotManagementRepository; - @Autowired - TestDataUtils testDataUtils; - List users; - List slotTimes; - - Season testSeason; - - @BeforeEach - void init() { - testDataUtils.createTierSystem("pingpong"); - testDataUtils.createSeason(); - Random random = new Random(); - Integer userCount = random.nextInt(10) + 5; - Integer pppGap = random.nextInt(100) + 50; - Season season = matchTestSetting.makeTestSeason(pppGap); - this.testSeason = season; - List users = new ArrayList(); - for(int i = 0; i < userCount; i++) { - User user = matchTestSetting.createUser(); - users.add(user); - } - this.users = users; - users.stream().forEach(user -> - matchTestSetting.addUsertoRankRedis(user.getId(), 1000, season.getId())); - SlotManagement slotManagement = matchTestSetting.makeTestSlotManagement(15); - List slotTimes = matchTestSetting.getTestSlotTimes(slotManagement.getGameInterval()); - this.slotTimes = slotTimes; - } - @AfterEach - void clear() { - RedisConnection connection = redisConnectionFactory.getConnection(); - connection.flushDb(); - connection.close(); - } - - @DisplayName("both 매칭 시뮬레이션") - @Test - void makeGameWithNormalAndBoth() { - System.out.println("this.users = " + this.users); - // 유저 0 slot 2, 3, 0 등록 유저 1 slot 2 - matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, this.slotTimes.get(2)); - matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, this.slotTimes.get(3)); - matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, this.slotTimes.get(0)); - matchService.makeMatch(UserDto.from(users.get(1)), Option.BOTH, this.slotTimes.get(2)); - - System.out.println("matchFindService.getAllMatchStatus(users.get(0).getId(), Option.BOTH) = " - + matchFindService.getAllMatchStatus(UserDto.from(users.get(0)), Option.BOTH).getMatchBoards().get(0)); - System.out.println("matchFindService = " + matchFindService.getCurrentMatch(UserDto.from(users.get(0)))); - System.out.println("matchFindService.getCurrentMatch(UserDto.from(users.get(1))) = " + matchFindService.getCurrentMatch(UserDto.from(users.get(1)))); - System.out.println("matchFindService.getAllMatchStatus(users.get(1).getId(), Option.BOTH) = " + matchFindService.getAllMatchStatus(UserDto.from(users.get(1)), Option.BOTH)); - Optional game1 = gameRepository.findByStartTime(slotTimes.get(2)); - Assertions.assertThat(game1).isPresent(); - matchService.cancelMatch(UserDto.from(users.get(0)), slotTimes.get(2)); - System.out.println("matchFindService.getCurrentMatch(UserDto.from(users.get(1))) = " + matchFindService.getCurrentMatch(UserDto.from(users.get(1)))); - redisTemplate.delete(PenaltyKey.USER_ADMIN + users.get(0).getIntraId()); - matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, slotTimes.get(2)); - System.out.println("matchFindService = " + matchFindService.getCurrentMatch(UserDto.from(users.get(0)))); - } - - @DisplayName("매칭 경기 상대가 아닌 다른 유저의 매칭 경기 취소") - @Test - void cancelByNotMatchedUser() { - System.out.println("this.users = " + this.users); - // 유저 0 slot 2, 3, 0 등록 유저 1 slot 2 - matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, this.slotTimes.get(2)); - matchService.makeMatch(UserDto.from(users.get(1)), Option.BOTH, this.slotTimes.get(2)); - org.junit.jupiter.api.Assertions.assertThrows(SlotNotFoundException.class, () -> { - matchService.cancelMatch(UserDto.from(users.get(2)), this.slotTimes.get(2)); - }); - } -} +package com.gg.server.domain.match.service; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.Random; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.transaction.annotation.Transactional; + +import com.gg.server.admin.penalty.data.PenaltyAdminRepository; +import com.gg.server.admin.penalty.type.PenaltyKey; +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.data.GameRepository; +import com.gg.server.domain.match.data.RedisMatchTimeRepository; +import com.gg.server.domain.match.data.RedisMatchUserRepository; +import com.gg.server.domain.match.exception.SlotNotFoundException; +import com.gg.server.domain.match.type.Option; +import com.gg.server.domain.noti.data.NotiRepository; +import com.gg.server.domain.penalty.redis.PenaltyUserRedisRepository; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.slotmanagement.SlotManagement; +import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.utils.MatchTestUtils; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; + +@IntegrationTest +@Transactional +@AutoConfigureMockMvc +@RequiredArgsConstructor +class MatchBothServiceTest { + @Autowired + MatchFindService matchFindService; + @Autowired + MatchService matchService; + @Autowired + RedisMatchTimeRepository redisMatchTimeRepository; + @Autowired + RedisMatchUserRepository redisMatchUserRepository; + @Autowired + RedisConnectionFactory redisConnectionFactory; + @Autowired + RedisTemplate redisTemplate; + @Autowired + MatchTestUtils matchTestSetting; + @Autowired + GameRepository gameRepository; + @Autowired + RankRedisRepository rankRedisRepository; + @Autowired + NotiRepository notiRepository; + @Autowired + PenaltyAdminRepository penaltyAdminRepository; + @Autowired + PenaltyUserRedisRepository penaltyUserRedisRepository; + @Autowired + SlotManagementRepository slotManagementRepository; + @Autowired + TestDataUtils testDataUtils; + List users; + List slotTimes; + + Season testSeason; + + @BeforeEach + void init() { + testDataUtils.createTierSystem("pingpong"); + testDataUtils.createSeason(); + Random random = new Random(); + Integer userCount = random.nextInt(10) + 5; + Integer pppGap = random.nextInt(100) + 50; + Season season = matchTestSetting.makeTestSeason(pppGap); + this.testSeason = season; + List users = new ArrayList(); + for (int i = 0; i < userCount; i++) { + User user = matchTestSetting.createUser(); + users.add(user); + } + this.users = users; + users.stream().forEach(user -> + matchTestSetting.addUsertoRankRedis(user.getId(), 1000, season.getId())); + SlotManagement slotManagement = matchTestSetting.makeTestSlotManagement(15); + List slotTimes = matchTestSetting.getTestSlotTimes(slotManagement.getGameInterval()); + this.slotTimes = slotTimes; + } + + @AfterEach + void clear() { + RedisConnection connection = redisConnectionFactory.getConnection(); + connection.flushDb(); + connection.close(); + } + + @DisplayName("both 매칭 시뮬레이션") + @Test + void makeGameWithNormalAndBoth() { + System.out.println("this.users = " + this.users); + // 유저 0 slot 2, 3, 0 등록 유저 1 slot 2 + matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, this.slotTimes.get(2)); + matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, this.slotTimes.get(3)); + matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, this.slotTimes.get(0)); + matchService.makeMatch(UserDto.from(users.get(1)), Option.BOTH, this.slotTimes.get(2)); + + System.out.println("matchFindService.getAllMatchStatus(users.get(0).getId(), Option.BOTH) = " + + matchFindService.getAllMatchStatus(UserDto.from(users.get(0)), Option.BOTH).getMatchBoards().get(0)); + System.out.println("matchFindService = " + matchFindService.getCurrentMatch(UserDto.from(users.get(0)))); + System.out.println( + "matchFindService.getCurrentMatch(UserDto.from(users.get(1))) = " + matchFindService.getCurrentMatch( + UserDto.from(users.get(1)))); + System.out.println("matchFindService.getAllMatchStatus(users.get(1).getId(), Option.BOTH) = " + + matchFindService.getAllMatchStatus(UserDto.from(users.get(1)), Option.BOTH)); + Optional game1 = gameRepository.findByStartTime(slotTimes.get(2)); + Assertions.assertThat(game1).isPresent(); + matchService.cancelMatch(UserDto.from(users.get(0)), slotTimes.get(2)); + System.out.println( + "matchFindService.getCurrentMatch(UserDto.from(users.get(1))) = " + matchFindService.getCurrentMatch( + UserDto.from(users.get(1)))); + redisTemplate.delete(PenaltyKey.USER_ADMIN + users.get(0).getIntraId()); + matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, slotTimes.get(2)); + System.out.println("matchFindService = " + matchFindService.getCurrentMatch(UserDto.from(users.get(0)))); + } + + @DisplayName("매칭 경기 상대가 아닌 다른 유저의 매칭 경기 취소") + @Test + void cancelByNotMatchedUser() { + System.out.println("this.users = " + this.users); + // 유저 0 slot 2, 3, 0 등록 유저 1 slot 2 + matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, this.slotTimes.get(2)); + matchService.makeMatch(UserDto.from(users.get(1)), Option.BOTH, this.slotTimes.get(2)); + org.junit.jupiter.api.Assertions.assertThrows(SlotNotFoundException.class, () -> { + matchService.cancelMatch(UserDto.from(users.get(2)), this.slotTimes.get(2)); + }); + } +} diff --git a/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java b/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java index 937b08056..d81d099ff 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java +++ b/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java @@ -1,5 +1,25 @@ package com.gg.server.domain.match.service; +import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; +import java.util.Set; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.type.Mode; @@ -25,223 +45,221 @@ import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.type.RoleType; import com.gg.server.utils.annotation.UnitTest; -import org.junit.jupiter.api.*; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.Optional; -import java.util.Set; - -import static com.gg.server.utils.ReflectionUtilsForUnitTest.setFieldWithReflection; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; @UnitTest @ExtendWith(MockitoExtension.class) public class MatchFindServiceUnitTest { - @InjectMocks - MatchFindService matchFindService; - @Mock - private SlotManagementRepository slotManagementRepository; - @Mock - private GameRepository gameRepository; - @Mock - private UserRepository userRepository; - @Mock - private RedisMatchUserRepository redisMatchUserRepository; - @Mock - private SeasonFindService seasonFindService; - @Mock - private RankRedisRepository rankRedisRepository; - @Mock - private RedisMatchTimeRepository redisMatchTimeRepository; - @Mock - private TierRepository tierRepository; - - private static final SlotManagement slotManagement = SlotManagement.builder() - .pastSlotTime(0) - .futureSlotTime(12) - .openMinute(5) - .gameInterval(15) - .startTime(LocalDateTime.now()) - .build(); - private static final Season season = Season.builder().startTime(LocalDateTime.now()).startPpp(123).build(); - private static final Tier tier = new Tier(); - - @BeforeEach - public void init() { - setFieldWithReflection(slotManagement, "id", 1L); - setFieldWithReflection(season, "id", 1L); - setFieldWithReflection(tier, "id", 1L); - } - - private Game createGame(User user, User enemy) { - LocalDateTime startTime = LocalDateTime.of(2024, 1, 1, 0, 0); - Game game = new Game(season, StatusType.BEFORE, Mode.NORMAL, startTime, startTime.plusMinutes(15)); - Team teamA = new Team(game, -1, false); - Team teamB = new Team(game, -1, false); - new TeamUser(teamA, user); - new TeamUser(teamB, enemy); - setFieldWithReflection(game, "id", 1L); - return game; - } - - @Nested - @DisplayName("현재 내가 등록한 슬롯 정보 가져오기") - class getCurrentMatch { - private final User user = User.builder().roleType(RoleType.USER).intraId("hannkim").build(); - - @BeforeEach - public void init() { - setFieldWithReflection(user, "id", 1L); - } - - @Test - @DisplayName("등록한 슬롯(최대 3개) 정보를 가져온다.") - void successUnmatchedSlots() { - // given - UserDto userDto = UserDto.from(user); - LocalDateTime startTime = LocalDateTime.of(2024, 1, 1, 0, 0); - RedisMatchTime redisMatchTime = new RedisMatchTime(startTime, Option.BOTH); - given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn(Optional.of(slotManagement)); - given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, user.getId())).willReturn(Optional.empty()); - given(redisMatchUserRepository.getAllMatchTime(user.getId())).willReturn(Set.of(redisMatchTime)); - - // when - matchFindService.getCurrentMatch(userDto); - - // then - verify(slotManagementRepository, times(1)).findCurrent(any(LocalDateTime.class)); - verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, user.getId()); - verify(redisMatchUserRepository, times(1)).getAllMatchTime(user.getId()); - } - - @Test - @DisplayName("매칭된 슬롯(1개) 정보를 가져온다.") - void successMatchedSlot() { - // given - UserDto userDto = UserDto.from(user); - User enemy = User.builder().roleType(RoleType.USER).intraId("enemy").build(); - setFieldWithReflection(enemy, "id", 2L); - Game myGame = createGame(user, enemy); - given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn(Optional.of(slotManagement)); - given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, user.getId())).willReturn(Optional.of(myGame)); - given(userRepository.findEnemyByGameAndUser(myGame.getId(), user.getId())).willReturn(List.of(enemy)); - - // when - matchFindService.getCurrentMatch(userDto); - - // then - verify(slotManagementRepository, times(1)).findCurrent(any(LocalDateTime.class)); - verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, user.getId()); - verify(userRepository, times(1)).findEnemyByGameAndUser(myGame.getId(), user.getId()); - } - - } - - @Nested - @DisplayName("경기 매칭 가능 상태 조회") - class getAllMatchStatus { - private final User user = User.builder().roleType(RoleType.USER).intraId("hannkim").build(); - private SlotGenerator slotGenerator; - - @BeforeEach - void init() { - setFieldWithReflection(user, "id", 1L); - given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn(Optional.of(slotManagement)); - given(seasonFindService.findCurrentSeason(any(LocalDateTime.class))).willReturn(season); - given(tierRepository.findStartTier()).willReturn(Optional.of(tier)); - List games = List.of(); // TODO 수정? 또는 slogGenerator에서 검증? - given(gameRepository.findAllBetween(any(LocalDateTime.class), any(LocalDateTime.class))).willReturn(games); - } - - @AfterEach - void verifyEach() { - verify(slotManagementRepository, times(1)).findCurrent(any(LocalDateTime.class)); - verify(seasonFindService, times(1)).findCurrentSeason(any(LocalDateTime.class)); - verify(tierRepository, times(1)).findStartTier(); - verify(gameRepository, times(1)).findAllBetween(any(LocalDateTime.class), any(LocalDateTime.class)); - } - - @Test - @DisplayName("슬롯 정보를 가져온다. - 내가 등록한 슬롯이 없는 경우") - void success() { - // given - UserDto userDto = UserDto.from(user); - RankRedis redisUser = RankRedis.from(userDto, season.getStartPpp(), tier.getImageUri()); - String hashKey = RedisKeyManager.getHashKey(season.getId()); - slotGenerator = new SlotGenerator(redisUser, slotManagement, season, Option.BOTH); - given(rankRedisRepository.findRankByUserId(hashKey, user.getId())).willReturn(redisUser); // guest가 아닌 유저일 경우 - given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(user).getId())).willReturn(Optional.empty()); - given(redisMatchTimeRepository.getAllEnrolledStartTimes()).willReturn(Set.of(LocalDateTime.now())); - given(redisMatchUserRepository.getAllMatchTime(slotGenerator.getMatchUser().getUserId())).willReturn(Set.of()); - given(redisMatchTimeRepository.getAllMatchUsers(any(LocalDateTime.class))).willReturn(List.of()); // TODO 수정 - - // when - matchFindService.getAllMatchStatus(userDto, Option.BOTH); - - // then - verify(rankRedisRepository, times(1)).findRankByUserId(hashKey, user.getId()); - verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(user).getId()); - verify(redisMatchTimeRepository, times(1)).getAllEnrolledStartTimes(); - verify(redisMatchUserRepository, times(1)).getAllMatchTime(slotGenerator.getMatchUser().getUserId()); - verify(redisMatchTimeRepository, times(1)).getAllMatchUsers(any(LocalDateTime.class)); - - // TODO slotGenerator 검증 (response dto) - } - - @Test - @DisplayName("GUEST 유저가 슬롯 정보를 가져온다. - 내가 등록한 슬롯 없는 경우") - void successGuest() { - // given - User guest = User.builder().intraId("guest").roleType(RoleType.GUEST).build(); - RankRedis redisUser = RankRedis.from(UserDto.from(guest), season.getStartPpp(), tier.getImageUri()); - slotGenerator = new SlotGenerator(redisUser, slotManagement, season, Option.BOTH); - given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(guest).getId())).willReturn(Optional.empty()); - given(redisMatchTimeRepository.getAllEnrolledStartTimes()).willReturn(Set.of(LocalDateTime.now())); - given(redisMatchUserRepository.getAllMatchTime(slotGenerator.getMatchUser().getUserId())).willReturn(Set.of()); - given(redisMatchTimeRepository.getAllMatchUsers(any(LocalDateTime.class))).willReturn(List.of()); // TODO 수정 - - // when - matchFindService.getAllMatchStatus(UserDto.from(guest), Option.BOTH); - - // then - verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(guest).getId()); - verify(redisMatchTimeRepository, times(1)).getAllEnrolledStartTimes(); - verify(redisMatchUserRepository, times(1)).getAllMatchTime(slotGenerator.getMatchUser().getUserId()); - verify(redisMatchTimeRepository, times(1)).getAllMatchUsers(any(LocalDateTime.class)); - } - - @Test - @DisplayName("슬롯 정보를 가져온다. - 내가 등록한 슬롯이 있는 경우") - void successWithMySlot() { - // given - UserDto userDto = UserDto.from(user); - RankRedis redisUser = RankRedis.from(userDto, season.getStartPpp(), tier.getImageUri()); - String hashKey = RedisKeyManager.getHashKey(season.getId()); - User enemy = User.builder().roleType(RoleType.USER).intraId("enemy").build(); - Game game = createGame(user, enemy); - setFieldWithReflection(enemy, "id", 2L); - setFieldWithReflection(game, "id", 1L); - given(rankRedisRepository.findRankByUserId(hashKey, user.getId())).willReturn(redisUser); - given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(user).getId())).willReturn(Optional.of(game)); - given(redisMatchTimeRepository.getAllEnrolledStartTimes()).willReturn(Set.of(LocalDateTime.now())); - given(redisMatchTimeRepository.getAllMatchUsers(any(LocalDateTime.class))).willReturn(List.of()); // TODO 수정 - - // when - matchFindService.getAllMatchStatus(userDto, Option.BOTH); - - // then - verify(rankRedisRepository, times(1)).findRankByUserId(hashKey, user.getId()); - verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(user).getId()); - verify(redisMatchTimeRepository, times(1)).getAllEnrolledStartTimes(); - verify(redisMatchTimeRepository, times(1)).getAllMatchUsers(any(LocalDateTime.class)); - } - } + @InjectMocks + MatchFindService matchFindService; + @Mock + private SlotManagementRepository slotManagementRepository; + @Mock + private GameRepository gameRepository; + @Mock + private UserRepository userRepository; + @Mock + private RedisMatchUserRepository redisMatchUserRepository; + @Mock + private SeasonFindService seasonFindService; + @Mock + private RankRedisRepository rankRedisRepository; + @Mock + private RedisMatchTimeRepository redisMatchTimeRepository; + @Mock + private TierRepository tierRepository; + + private static final SlotManagement slotManagement = SlotManagement.builder() + .pastSlotTime(0) + .futureSlotTime(12) + .openMinute(5) + .gameInterval(15) + .startTime(LocalDateTime.now()) + .build(); + private static final Season season = Season.builder().startTime(LocalDateTime.now()).startPpp(123).build(); + private static final Tier tier = new Tier(); + + @BeforeEach + public void init() { + setFieldWithReflection(slotManagement, "id", 1L); + setFieldWithReflection(season, "id", 1L); + setFieldWithReflection(tier, "id", 1L); + } + + private Game createGame(User user, User enemy) { + LocalDateTime startTime = LocalDateTime.of(2024, 1, 1, 0, 0); + Game game = new Game(season, StatusType.BEFORE, Mode.NORMAL, startTime, startTime.plusMinutes(15)); + Team teamA = new Team(game, -1, false); + Team teamB = new Team(game, -1, false); + new TeamUser(teamA, user); + new TeamUser(teamB, enemy); + setFieldWithReflection(game, "id", 1L); + return game; + } + + @Nested + @DisplayName("현재 내가 등록한 슬롯 정보 가져오기") + class GetCurrentMatch { + private final User user = User.builder().roleType(RoleType.USER).intraId("hannkim").build(); + + @BeforeEach + public void init() { + setFieldWithReflection(user, "id", 1L); + } + + @Test + @DisplayName("등록한 슬롯(최대 3개) 정보를 가져온다.") + void successUnmatchedSlots() { + // given + UserDto userDto = UserDto.from(user); + LocalDateTime startTime = LocalDateTime.of(2024, 1, 1, 0, 0); + RedisMatchTime redisMatchTime = new RedisMatchTime(startTime, Option.BOTH); + given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn( + Optional.of(slotManagement)); + given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, user.getId())).willReturn( + Optional.empty()); + given(redisMatchUserRepository.getAllMatchTime(user.getId())).willReturn(Set.of(redisMatchTime)); + + // when + matchFindService.getCurrentMatch(userDto); + + // then + verify(slotManagementRepository, times(1)).findCurrent(any(LocalDateTime.class)); + verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, user.getId()); + verify(redisMatchUserRepository, times(1)).getAllMatchTime(user.getId()); + } + + @Test + @DisplayName("매칭된 슬롯(1개) 정보를 가져온다.") + void successMatchedSlot() { + // given + UserDto userDto = UserDto.from(user); + User enemy = User.builder().roleType(RoleType.USER).intraId("enemy").build(); + setFieldWithReflection(enemy, "id", 2L); + Game myGame = createGame(user, enemy); + given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn( + Optional.of(slotManagement)); + given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, user.getId())).willReturn( + Optional.of(myGame)); + given(userRepository.findEnemyByGameAndUser(myGame.getId(), user.getId())).willReturn(List.of(enemy)); + + // when + matchFindService.getCurrentMatch(userDto); + + // then + verify(slotManagementRepository, times(1)).findCurrent(any(LocalDateTime.class)); + verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, user.getId()); + verify(userRepository, times(1)).findEnemyByGameAndUser(myGame.getId(), user.getId()); + } + + } + + @Nested + @DisplayName("경기 매칭 가능 상태 조회") + class GetAllMatchStatus { + private final User user = User.builder().roleType(RoleType.USER).intraId("hannkim").build(); + private SlotGenerator slotGenerator; + + @BeforeEach + void init() { + setFieldWithReflection(user, "id", 1L); + given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn( + Optional.of(slotManagement)); + given(seasonFindService.findCurrentSeason(any(LocalDateTime.class))).willReturn(season); + given(tierRepository.findStartTier()).willReturn(Optional.of(tier)); + List games = List.of(); // TODO 수정? 또는 slogGenerator에서 검증? + given(gameRepository.findAllBetween(any(LocalDateTime.class), any(LocalDateTime.class))).willReturn(games); + } + + @AfterEach + void verifyEach() { + verify(slotManagementRepository, times(1)).findCurrent(any(LocalDateTime.class)); + verify(seasonFindService, times(1)).findCurrentSeason(any(LocalDateTime.class)); + verify(tierRepository, times(1)).findStartTier(); + verify(gameRepository, times(1)).findAllBetween(any(LocalDateTime.class), any(LocalDateTime.class)); + } + + @Test + @DisplayName("슬롯 정보를 가져온다. - 내가 등록한 슬롯이 없는 경우") + void success() { + // given + UserDto userDto = UserDto.from(user); + RankRedis redisUser = RankRedis.from(userDto, season.getStartPpp(), tier.getImageUri()); + String hashKey = RedisKeyManager.getHashKey(season.getId()); + slotGenerator = new SlotGenerator(redisUser, slotManagement, season, Option.BOTH); + given(rankRedisRepository.findRankByUserId(hashKey, user.getId())).willReturn( + redisUser); // guest가 아닌 유저일 경우 + given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(user).getId())).willReturn( + Optional.empty()); + given(redisMatchTimeRepository.getAllEnrolledStartTimes()).willReturn(Set.of(LocalDateTime.now())); + given(redisMatchUserRepository.getAllMatchTime(slotGenerator.getMatchUser().getUserId())).willReturn( + Set.of()); + given(redisMatchTimeRepository.getAllMatchUsers(any(LocalDateTime.class))).willReturn( + List.of()); // TODO 수정 + + // when + matchFindService.getAllMatchStatus(userDto, Option.BOTH); + + // then + verify(rankRedisRepository, times(1)).findRankByUserId(hashKey, user.getId()); + verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(user).getId()); + verify(redisMatchTimeRepository, times(1)).getAllEnrolledStartTimes(); + verify(redisMatchUserRepository, times(1)).getAllMatchTime(slotGenerator.getMatchUser().getUserId()); + verify(redisMatchTimeRepository, times(1)).getAllMatchUsers(any(LocalDateTime.class)); + + // TODO slotGenerator 검증 (response dto) + } + + @Test + @DisplayName("GUEST 유저가 슬롯 정보를 가져온다. - 내가 등록한 슬롯 없는 경우") + void successGuest() { + // given + User guest = User.builder().intraId("guest").roleType(RoleType.GUEST).build(); + RankRedis redisUser = RankRedis.from(UserDto.from(guest), season.getStartPpp(), tier.getImageUri()); + slotGenerator = new SlotGenerator(redisUser, slotManagement, season, Option.BOTH); + given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(guest).getId())).willReturn( + Optional.empty()); + given(redisMatchTimeRepository.getAllEnrolledStartTimes()).willReturn(Set.of(LocalDateTime.now())); + given(redisMatchUserRepository.getAllMatchTime(slotGenerator.getMatchUser().getUserId())).willReturn( + Set.of()); + given(redisMatchTimeRepository.getAllMatchUsers(any(LocalDateTime.class))).willReturn( + List.of()); // TODO 수정 + + // when + matchFindService.getAllMatchStatus(UserDto.from(guest), Option.BOTH); + + // then + verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(guest).getId()); + verify(redisMatchTimeRepository, times(1)).getAllEnrolledStartTimes(); + verify(redisMatchUserRepository, times(1)).getAllMatchTime(slotGenerator.getMatchUser().getUserId()); + verify(redisMatchTimeRepository, times(1)).getAllMatchUsers(any(LocalDateTime.class)); + } + + @Test + @DisplayName("슬롯 정보를 가져온다. - 내가 등록한 슬롯이 있는 경우") + void successWithMySlot() { + // given + UserDto userDto = UserDto.from(user); + RankRedis redisUser = RankRedis.from(userDto, season.getStartPpp(), tier.getImageUri()); + String hashKey = RedisKeyManager.getHashKey(season.getId()); + User enemy = User.builder().roleType(RoleType.USER).intraId("enemy").build(); + Game game = createGame(user, enemy); + setFieldWithReflection(enemy, "id", 2L); + setFieldWithReflection(game, "id", 1L); + given(rankRedisRepository.findRankByUserId(hashKey, user.getId())).willReturn(redisUser); + given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(user).getId())).willReturn( + Optional.of(game)); + given(redisMatchTimeRepository.getAllEnrolledStartTimes()).willReturn(Set.of(LocalDateTime.now())); + given(redisMatchTimeRepository.getAllMatchUsers(any(LocalDateTime.class))).willReturn( + List.of()); // TODO 수정 + + // when + matchFindService.getAllMatchStatus(userDto, Option.BOTH); + + // then + verify(rankRedisRepository, times(1)).findRankByUserId(hashKey, user.getId()); + verify(gameRepository, times(1)).findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(user).getId()); + verify(redisMatchTimeRepository, times(1)).getAllEnrolledStartTimes(); + verify(redisMatchTimeRepository, times(1)).getAllMatchUsers(any(LocalDateTime.class)); + } + } } diff --git a/src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java b/src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java index b164c000b..492459201 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java +++ b/src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java @@ -1,9 +1,25 @@ package com.gg.server.domain.match.service; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.Random; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.admin.penalty.data.PenaltyAdminRepository; -import com.gg.server.global.exception.custom.BusinessException; -import com.gg.server.utils.MatchTestUtils; -import com.gg.server.utils.annotation.IntegrationTest; import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.type.Mode; @@ -40,501 +56,499 @@ import com.gg.server.domain.tournament.type.TournamentType; import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.exception.custom.BusinessException; +import com.gg.server.utils.MatchTestUtils; import com.gg.server.utils.TestDataUtils; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.Random; +import com.gg.server.utils.annotation.IntegrationTest; + import lombok.RequiredArgsConstructor; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.connection.RedisConnection; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.transaction.annotation.Transactional; @IntegrationTest @Transactional @RequiredArgsConstructor class MatchServiceTest { - @Autowired - MatchFindService matchFindService; - @Autowired - MatchService matchService; - @Autowired - RedisMatchTimeRepository redisMatchTimeRepository; - @Autowired - RedisMatchUserRepository redisMatchUserRepository; - @Autowired - RedisConnectionFactory redisConnectionFactory; - @Autowired - RedisTemplate redisTemplate; - @Autowired - MatchTestUtils matchTestSetting; - @Autowired - GameRepository gameRepository; - @Autowired - RankRedisRepository rankRedisRepository; - @Autowired - NotiRepository notiRepository; - @Autowired - PenaltyAdminRepository penaltyRepository; - @Autowired - PenaltyUserRedisRepository penaltyUserRedisRepository; - @Autowired - TournamentRepository tournamentRepository; - @Autowired - SlotManagementRepository slotManagementRepository; - @Autowired - TierRepository tierRepository; - @Autowired - RedisUploadService redisUploadService; - @Autowired - TestDataUtils testDataUtils; - List users; - List slotTimes; - - Season testSeason; - - - @BeforeEach - void init() { - testDataUtils.createTierSystem("pingpong"); - Random random = new Random(); - Integer userCount = random.nextInt(10) + 5; - Integer pppGap = random.nextInt(100) + 50; - Season season = matchTestSetting.makeTestSeason(pppGap); - testSeason = season; - users = new ArrayList(); - for(int i = 0; i < userCount; i++) { - User user = matchTestSetting.createUser(); - users.add(user); - } - users.stream().forEach(user -> - matchTestSetting.addUsertoRankRedis(user.getId(), random.nextInt(season.getPppGap()), season.getId())); - SlotManagement slotManagement = matchTestSetting.makeTestSlotManagement(15); - slotTimes = matchTestSetting.getTestSlotTimes(slotManagement.getGameInterval()); - } - @AfterEach - void clear() { - RedisConnection connection = redisConnectionFactory.getConnection(); - connection.flushDb(); - connection.close(); - } - - @Nested - @DisplayName("매칭 요청 API 테스트") - class MatchTest { - @DisplayName("매칭 가능 상대가 없는 경우 큐에 들어감") - @Test - void addMatchDifferentOption() { - System.out.println("users = " + users); - matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)); - matchService.makeMatch(UserDto.from(users.get(1)), Option.RANK, slotTimes.get(0)); - Long size = redisTemplate.opsForList().size(MatchKey.getTime(slotTimes.get(0))); - Assertions.assertThat(size).isEqualTo(2L); - } - - @DisplayName("normal both 매칭 시 게임 생성") - @Test - void makeGameWithNormalAndBoth() { - System.out.println("users = " + users); - matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)); - matchService.makeMatch(UserDto.from(users.get(1)), Option.BOTH, slotTimes.get(0)); - matchService.makeMatch(UserDto.from(users.get(2)), Option.BOTH, slotTimes.get(1)); - matchService.makeMatch(UserDto.from(users.get(3)), Option.NORMAL, slotTimes.get(1)); - Optional game1 = gameRepository.findByStartTime(slotTimes.get(0)); - Optional game2 = gameRepository.findByStartTime(slotTimes.get(1)); - Assertions.assertThat(game1).isPresent(); - Assertions.assertThat(game2).isPresent(); - System.out.println("normal user + matchService = " + matchFindService.getAllMatchStatus(UserDto.from(users.get(0)), Option.NORMAL)); - System.out.println(); - System.out.println("normal user both + matchService = " + matchFindService.getAllMatchStatus(UserDto.from(users.get(0)), Option.BOTH)); - System.out.println("both user + matchService = " + matchFindService.getAllMatchStatus(UserDto.from(users.get(1)), - Option.BOTH)); - System.out.println("both user normal matchService = " + matchFindService.getAllMatchStatus(UserDto.from(users.get(1)), - Option.NORMAL)); - } - - @DisplayName("Queue에 매칭 가능한 normal 상대가 있을 경우 게임 생성") - @Test - void addMatchSameNormalOption() { - matchService.makeMatch(UserDto.from(users.get(2)), Option.RANK, slotTimes.get(0)); - matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)); - matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(0)); - matchService.cancelMatch(UserDto.from(users.get(0)), slotTimes.get(0)); - Optional game = gameRepository.findByStartTime(slotTimes.get(0)); - Assertions.assertThat(game).isEmpty(); - Long size = redisTemplate.opsForList().size(MatchKey.getTime(slotTimes.get(0))); - List allMatchUsers = redisMatchTimeRepository.getAllMatchUsers(slotTimes.get(0)); - Assertions.assertThat(size).isEqualTo(2L); - RedisMatchUser remainedUser = (RedisMatchUser) redisTemplate.opsForList().index(MatchKey.getTime(slotTimes.get(0)), 0); - Assertions.assertThat(remainedUser.getUserId()).isEqualTo(users.get(2).getId()); - Assertions.assertThat(notiRepository.findAllByUser(users.get(1)).size()).isEqualTo(2); - Assertions.assertThat(notiRepository.findAllByUser(users.get(0)).size()).isEqualTo(1); - Assertions.assertThat(notiRepository.findAllByUser(users.get(2)).size()).isEqualTo(0); - } - - @DisplayName("게임 재생성 테스트") - @Test - void remakeGameAfterCancelling() { - matchService.makeMatch(UserDto.from(users.get(2)), Option.RANK, slotTimes.get(0)); - matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)); - matchService.makeMatch(UserDto.from(users.get(1)), Option.BOTH, slotTimes.get(0)); - matchService.cancelMatch(UserDto.from(users.get(2)), slotTimes.get(0)); - Optional game = gameRepository.findByStartTime(slotTimes.get(0)); - Assertions.assertThat(game).isPresent(); - Long size = redisTemplate.opsForList().size(MatchKey.getTime(slotTimes.get(0))); - Assertions.assertThat(size).isEqualTo(2L); - RedisMatchUser remainedUser = (RedisMatchUser) redisTemplate.opsForList().index(MatchKey.getTime(slotTimes.get(0)), 0); - Assertions.assertThat(remainedUser.getUserId()).isEqualTo(users.get(0).getId()); - Assertions.assertThat(notiRepository.findAllByUser(users.get(1)).size()).isEqualTo(1); - Assertions.assertThat(notiRepository.findAllByUser(users.get(0)).size()).isEqualTo(1); - Assertions.assertThat(notiRepository.findAllByUser(users.get(2)).size()).isEqualTo(1); - } - - @DisplayName("Queue에 user가 선택한 random option으로 매칭 가능한 상대가 없을 경우") - @Test - void addMatchRankOptionAndPppGapBiggerThanSeasonPppGap() { - User user1 = matchTestSetting.createUser(); - matchTestSetting.addUsertoRankRedis(user1.getId(), - testSeason.getStartPpp() + testSeason.getPppGap() + 1, testSeason.getId());//pppGap차이가 충분히 큰 경우 - matchService.makeMatch(UserDto.from(user1), Option.RANK, slotTimes.get(0)); - matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)); - matchService.makeMatch(UserDto.from(users.get(1)), Option.RANK, slotTimes.get(0)); - Long size = redisTemplate.opsForList().size(MatchKey.getTime(slotTimes.get(0))); - Assertions.assertThat(size).isEqualTo(3L); - Optional game = gameRepository.findByStartTime(slotTimes.get(0)); - Assertions.assertThat(game.isEmpty()).isEqualTo(true); - - } - - @DisplayName("Queue에 user가 선택한 random option으로 매칭 가능한 상대가 있는 경우") - @Test - void addMatchRankOptionAndPppGapSamllerThanOrEqualToSeasonPppGap() { - RankRedis userRank = rankRedisRepository.findRankByUserId(RedisKeyManager - .getHashKey(testSeason.getId()), users.get(0).getId()); - User user1 = matchTestSetting.createUser(); - matchTestSetting.addUsertoRankRedis(user1.getId(),userRank.getPpp() + testSeason.getPppGap() - , testSeason.getId());//pppGap차이가 pppGap만큼 - matchService.makeMatch(UserDto.from(user1), Option.RANK, slotTimes.get(0)); - matchService.makeMatch(UserDto.from(users.get(0)), Option.RANK, slotTimes.get(0)); - Long size = redisTemplate.opsForList().size(MatchKey.getTime(slotTimes.get(0))); - // 현재 시스템 코드에서는 매칭된 슬롯은 안지우고 있음, 매칭되지 않은 슬롯만 삭제중이므로 2가 나옴 - Assertions.assertThat(size).isEqualTo(2L); - Optional game = gameRepository.findByStartTime(slotTimes.get(0)); - Assertions.assertThat(game.isEmpty()).isEqualTo(false); - } - - @DisplayName("Queue에 user가 선택한 both option으로 매칭 가능한 상대가 있는 경우") - @Test - void addMatchBothOptionAndPppGapSmallerThanOrEqualToSeasonPppGap() { - RankRedis userRank = rankRedisRepository.findRankByUserId(RedisKeyManager - .getHashKey(testSeason.getId()), users.get(0).getId()); - User user1 = matchTestSetting.createUser(); - matchTestSetting.addUsertoRankRedis(user1.getId(),userRank.getPpp() + testSeason.getPppGap() - , testSeason.getId());//pppGap차이가 pppGap만큼 - matchService.makeMatch(UserDto.from(user1), Option.BOTH, slotTimes.get(0)); - matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, slotTimes.get(0)); - Long size = redisTemplate.opsForList().size(MatchKey.getTime(slotTimes.get(0))); - // 현재 시스템 코드에서는 매칭된 슬롯은 안지우고 있음, 매칭되지 않은 슬롯만 삭제중이므로 2가 나옴 - Assertions.assertThat(size).isEqualTo(2L); - Optional game = gameRepository.findByStartTime(slotTimes.get(0)); - Assertions.assertThat(game.isEmpty()).isEqualTo(false); - Assertions.assertThat(game.get().getMode()).isEqualTo(Mode.RANK); - } - - @DisplayName("토너먼트 시간과 겹칠 경우 게임 생성 안됨") - @Test - void addMatchTournamentTime() { - // given - Tournament tournament = Tournament.builder() - .title("test tournament") - .contents("test contents") - .startTime(LocalDateTime.now().plusHours(1)) - .endTime(LocalDateTime.now().plusHours(2)) - .type(TournamentType.MASTER) - .status(TournamentStatus.BEFORE) - .build(); - tournamentRepository.save(tournament); - - // when, then - Assertions.assertThatThrownBy(() -> matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, tournament.getStartTime())) - .isInstanceOf(TournamentConflictException.class); - - } - } - - @Nested - @DisplayName("매칭 취소 API 테스트") - class CancelMatch { - @DisplayName("게임 생성되었을 때 경기 취소") - @Test - void cancelMatchAfterMakingGameEntity() { - //normal 게임 생성 - matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(3)); - matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(3)); - //user2 다른 슬롯 등록 - //첫번째 유저 경기 취소 - org.junit.jupiter.api.Assertions.assertThrows( - EnrolledSlotException.class, - () -> matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)) - ); - matchService.cancelMatch(UserDto.from(users.get(0)), slotTimes.get(3)); - Optional game = gameRepository.findByStartTime(slotTimes.get(3)); - Assertions.assertThat(game.isEmpty()).isEqualTo(true); - // 취소한 유저는 큐에 없음 - Assertions.assertThat(redisMatchUserRepository.countMatchTime(users.get(0).getId())).isEqualTo(0L); - // 취소하지 않은 유저는 큐에 유지 - Assertions.assertThat(redisMatchUserRepository.countMatchTime(users.get(1).getId())).isEqualTo(1L); - - //알람 확인 - List notifications = notiRepository.findAllByUser(users.get(1)); - System.out.println("users.get(0).getIntraId() = " + users.get(0).getIntraId()); - for (Noti noti : notifications) { - System.out.println("noti.getMessage() = " + noti.getMessage()); - } - Assertions.assertThat(notifications.size()).isEqualTo(2); - Assertions.assertThat(notifications.get(0).getType()).isEqualTo(NotiType.MATCHED); - Assertions.assertThat(notifications.get(1).getType()).isEqualTo(NotiType.CANCELEDBYMAN); - - //패널티 확인 - Optional penaltyUser = penaltyUserRedisRepository.findByIntraId(users.get(0).getIntraId()); - Assertions.assertThat(penaltyUser).isPresent(); - // 패널티 시간은 하드 코딩 시 관리가 어려우니 Static이나 enum으로 관리하는게 좋을 듯 하다. - Assertions.assertThat(penaltyUser.get().getPenaltyTime()).isEqualTo(30); - org.junit.jupiter.api.Assertions.assertThrows(PenaltyUserSlotException.class, () -> { - matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, slotTimes.get(10)); - } - ); - } - - @DisplayName("게임 생성 전 경기 취소") - @Test - void cancelBeforeMakingGameEntity() { - RankRedis userRank = rankRedisRepository.findRankByUserId(RedisKeyManager - .getHashKey(testSeason.getId()), users.get(0).getId()); - User user1 = matchTestSetting.createUser(); - matchTestSetting.addUsertoRankRedis(user1.getId(),userRank.getPpp() + testSeason.getPppGap() + 100 - , testSeason.getId()); - //매칭이 이루어질 수 없는 유저 3명을 큐에 등록 - matchService.makeMatch(UserDto.from(users.get(0)), Option.RANK, slotTimes.get(0)); - matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(0)); - matchService.makeMatch(UserDto.from(user1), Option.RANK, slotTimes.get(0)); - //user1의 취소 - matchService.cancelMatch(UserDto.from(users.get(1)), slotTimes.get(0)); - List allMatchUsers = redisMatchTimeRepository.getAllMatchUsers(slotTimes.get(0)); - Assertions.assertThat(allMatchUsers.size()).isEqualTo(2L); - - } - - @Test - @DisplayName("토너먼트 게임 취소 테스트") - void cancelMatchedTournamentGame() { - // given - LocalDateTime time = LocalDateTime.now().plusHours(1).withMinute(0).withSecond(0).withNano(0); - Game game = testDataUtils.createMockMatch(users.get(0), testSeason, time, time.withMinute(15), Mode.TOURNAMENT); - // when, then - Assertions.assertThatThrownBy(()->matchService.cancelMatch(UserDto.from(users.get(0)), game.getStartTime())) - .isInstanceOf(BusinessException.class); - } - } - - @Nested - @DisplayName("특정 시간대의 경기 매칭 가능 상태 조회 API 테스트") - class GetMatchTimeScope { - @DisplayName("슬롯 조회 : 게임 생성한 후 내 테이블로 인식") - @Test - void readMyTableAfterMakingGame() { - //normal 게임 생성 - matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)); - matchService.makeMatch(UserDto.from(users.get(0)), Option.RANK, slotTimes.get(4)); - matchService.makeMatch(UserDto.from(users.get(1)), Option.RANK, slotTimes.get(1)); - matchService.makeMatch(UserDto.from(users.get(2)), Option.NORMAL, slotTimes.get(2)); - SlotStatusResponseListDto slotStatusList = matchFindService.getAllMatchStatus(UserDto.from(users.get(0)), - Option.NORMAL); - for (int i = 0; i < 3; i++) { - System.out.println("slotTimes = " + String.valueOf(i) + slotTimes.get(i)); - } - for (List dtos : slotStatusList.getMatchBoards()) { - for (SlotStatusDto dto: dtos) { - System.out.println("dto = " + dto); - if (dto.getStartTime().equals(slotTimes.get(0))) { - Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.MYTABLE.getCode()); - } - if (dto.getStartTime().equals(slotTimes.get(1))) { - Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.OPEN.getCode()); - } - if (dto.getStartTime().equals(slotTimes.get(2))) { - Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.MATCH.getCode()); - } - if (dto.getStartTime().equals(slotTimes.get(4))) { - Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.CLOSE.getCode()); - } - } - } - - } - - @DisplayName("슬롯 조회 : 게임 생성 전 내 테이블로 인식") - @Test - void readMyTableBeforeMakingGame() { - for (int i = 0; i < 3; i++) { - matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(i)); - } - matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(3)); - matchService.makeMatch(UserDto.from(users.get(2)), Option.NORMAL, slotTimes.get(3)); - SlotStatusResponseListDto slotStatusList = matchFindService.getAllMatchStatus(UserDto.from(users.get(0)), - Option.NORMAL); - for (List dtos : slotStatusList.getMatchBoards()) { - for (SlotStatusDto dto: dtos) { - if (dto.getStartTime().equals(slotTimes.get(0))) { - Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.MYTABLE.getCode()); - } - if (dto.getStartTime().equals(slotTimes.get(1))) { - Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.MYTABLE.getCode()); - } - if (dto.getStartTime().equals(slotTimes.get(2))) { - Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.MYTABLE.getCode()); - } - if (dto.getStartTime().equals(slotTimes.get(3))) { - Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.CLOSE.getCode()); - } - } - } - - } - - @DisplayName("슬롯 조회 : 게임 등록 되면 제 3자한테 closed 처리") - @Test - void getClosedStatusOfExistGame() { - matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(3)); - matchService.makeMatch(UserDto.from(users.get(2)), Option.NORMAL, slotTimes.get(3)); - SlotStatusResponseListDto allMatchStatus = matchFindService.getAllMatchStatus(UserDto.from(users.get(3)), - Option.NORMAL); - for (List dtos : allMatchStatus.getMatchBoards()) { - for (SlotStatusDto dto: dtos) { - if (dto.getStartTime().equals(slotTimes.get(3))) { - Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.CLOSE.getCode()); - } - } - } - } - - @DisplayName("슬롯 조회 : 게임 등록 되면 제3자가 다른 게임 등록해도 제 3자한테 closed 처리") - @Test - void getClosedStatusOfExistGame2() { - matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(3)); - matchService.makeMatch(UserDto.from(users.get(2)), Option.NORMAL, slotTimes.get(3)); - matchService.makeMatch(UserDto.from(users.get(3)), Option.NORMAL, slotTimes.get(4)); - matchService.makeMatch(UserDto.from(users.get(4)), Option.NORMAL, slotTimes.get(4)); - SlotStatusResponseListDto allMatchStatus = matchFindService.getAllMatchStatus(UserDto.from(users.get(3)), - Option.NORMAL); - for (List dtos : allMatchStatus.getMatchBoards()) { - for (SlotStatusDto dto: dtos) { - if (dto.getStartTime().equals(slotTimes.get(3))) { - Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.CLOSE.getCode()); - } - } - } - } - - @DisplayName("토너먼트 시간에 대한 슬롯 블락") - @Test - @Disabled - void getClosedStatusOfTournament() { - // given - Tournament tournament = Tournament.builder() - .title("test tournament") - .contents("test contents") - .startTime(LocalDateTime.now().plusHours(1)) - .endTime(LocalDateTime.now().plusHours(2)) - .type(TournamentType.MASTER) - .status(TournamentStatus.BEFORE) - .build(); - tournamentRepository.save(tournament); - tierRepository.save(new Tier("image url")); - - // TODO 현재 upload redis해도 redis 데이터 없다는 에러 발생함 - redisUploadService.uploadRedis(); - // when - LocalDateTime now = LocalDateTime.now(); - SlotStatusResponseListDto allMatchStatus = matchFindService.getAllMatchStatus(UserDto.from(users.get(0)), - Option.NORMAL); - - // then - for (List dtos : allMatchStatus.getMatchBoards()) { - for (SlotStatusDto dto: dtos) { - if (dto.getStartTime().isBefore(tournament.getStartTime()) || - dto.getEndTime().isAfter(tournament.getEndTime())) { - Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.OPEN.getCode()); - } else { - Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.CLOSE.getCode()); - } - } - } - } - } - - @Nested - @DisplayName("현재 매치 정보 조회 API 테스트") - class GetCurrentMatch { - @DisplayName("current Match 조회 : user가 등록한 슬롯이 매칭되었을 때") - @Test - void readCurrentMatchAfterMakingGameEntity() { - //게임생성 - matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(3)); - matchService.makeMatch(UserDto.from(users.get(2)), Option.NORMAL, slotTimes.get(3)); - UserDto userDto = UserDto.from(users.get(1)); - MatchStatusResponseListDto currentMatch = matchFindService.getCurrentMatch(userDto); - //user의 current match 확인 - List match = currentMatch.getMatch(); - Assertions.assertThat(match.size()).isEqualTo(1); - Assertions.assertThat(match.get(0).getMyTeam().get(0)).isEqualTo(users.get(1).getIntraId()); - Assertions.assertThat(match.get(0).getEnemyTeam().get(0)).isEqualTo(users.get(2).getIntraId()); - Assertions.assertThat(match.get(0).getStartTime()).isEqualTo(slotTimes.get(3)); - Assertions.assertThat(match.get(0).getIsMatched()).isEqualTo(true); - } - - @DisplayName("current Match 조회 : user가 등록한 슬롯이 매칭되지 않았을 때") - @Test - void readCurrentMatchBeforeMakingGameEntity() { - //유저 슬롯 3개 등록 시도 - for (int i = 0; i < 3; i++) { - System.out.println("slotTimes = " + slotTimes.get(i)); - matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(i)); - } - UserDto userDto = UserDto.from(users.get(1)); - MatchStatusResponseListDto currentMatch = matchFindService.getCurrentMatch(userDto); - List match = currentMatch.getMatch(); - //user current match 확인 - Assertions.assertThat(match.size()).isEqualTo(3); - for (int i = 0; i < 3; i++) { - System.out.println("match = " + match.get(i).getStartTime()); - Assertions.assertThat(match.get(i).getMyTeam().size()).isEqualTo(0); - Assertions.assertThat(match.get(i).getEnemyTeam().size()).isEqualTo(0); - Assertions.assertThat(match.get(i).getStartTime()).isEqualTo(slotTimes.get(i)); - Assertions.assertThat(match.get(i).getIsMatched()).isEqualTo(false); - } - } - - @DisplayName("Guest User slot 조회") - @Test - void readAllSlotsAndCurrentMatchForGuset() { - User guestUser = matchTestSetting.createGuestUser(); - MatchStatusResponseListDto currentMatch = matchFindService.getCurrentMatch(UserDto.from(guestUser)); - SlotStatusResponseListDto allMatchStatus = matchFindService.getAllMatchStatus(UserDto.from(guestUser), - Option.NORMAL); - Assertions.assertThat(currentMatch.getMatch().size()).isEqualTo(0); - System.out.println("allMatchStatus = " + allMatchStatus); - } - - } + @Autowired + MatchFindService matchFindService; + @Autowired + MatchService matchService; + @Autowired + RedisMatchTimeRepository redisMatchTimeRepository; + @Autowired + RedisMatchUserRepository redisMatchUserRepository; + @Autowired + RedisConnectionFactory redisConnectionFactory; + @Autowired + RedisTemplate redisTemplate; + @Autowired + MatchTestUtils matchTestSetting; + @Autowired + GameRepository gameRepository; + @Autowired + RankRedisRepository rankRedisRepository; + @Autowired + NotiRepository notiRepository; + @Autowired + PenaltyAdminRepository penaltyRepository; + @Autowired + PenaltyUserRedisRepository penaltyUserRedisRepository; + @Autowired + TournamentRepository tournamentRepository; + @Autowired + SlotManagementRepository slotManagementRepository; + @Autowired + TierRepository tierRepository; + @Autowired + RedisUploadService redisUploadService; + @Autowired + TestDataUtils testDataUtils; + List users; + List slotTimes; + + Season testSeason; + + @BeforeEach + void init() { + testDataUtils.createTierSystem("pingpong"); + Random random = new Random(); + Integer userCount = random.nextInt(10) + 5; + Integer pppGap = random.nextInt(100) + 50; + Season season = matchTestSetting.makeTestSeason(pppGap); + testSeason = season; + users = new ArrayList(); + for (int i = 0; i < userCount; i++) { + User user = matchTestSetting.createUser(); + users.add(user); + } + users.stream().forEach(user -> + matchTestSetting.addUsertoRankRedis(user.getId(), random.nextInt(season.getPppGap()), season.getId())); + SlotManagement slotManagement = matchTestSetting.makeTestSlotManagement(15); + slotTimes = matchTestSetting.getTestSlotTimes(slotManagement.getGameInterval()); + } + + @AfterEach + void clear() { + RedisConnection connection = redisConnectionFactory.getConnection(); + connection.flushDb(); + connection.close(); + } + + @Nested + @DisplayName("매칭 요청 API 테스트") + class MatchTest { + @DisplayName("매칭 가능 상대가 없는 경우 큐에 들어감") + @Test + void addMatchDifferentOption() { + System.out.println("users = " + users); + matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)); + matchService.makeMatch(UserDto.from(users.get(1)), Option.RANK, slotTimes.get(0)); + Long size = redisTemplate.opsForList().size(MatchKey.getTime(slotTimes.get(0))); + Assertions.assertThat(size).isEqualTo(2L); + } + + @DisplayName("normal both 매칭 시 게임 생성") + @Test + void makeGameWithNormalAndBoth() { + System.out.println("users = " + users); + matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)); + matchService.makeMatch(UserDto.from(users.get(1)), Option.BOTH, slotTimes.get(0)); + matchService.makeMatch(UserDto.from(users.get(2)), Option.BOTH, slotTimes.get(1)); + matchService.makeMatch(UserDto.from(users.get(3)), Option.NORMAL, slotTimes.get(1)); + Optional game1 = gameRepository.findByStartTime(slotTimes.get(0)); + Optional game2 = gameRepository.findByStartTime(slotTimes.get(1)); + Assertions.assertThat(game1).isPresent(); + Assertions.assertThat(game2).isPresent(); + System.out.println( + "normal user + matchService = " + matchFindService.getAllMatchStatus(UserDto.from(users.get(0)), + Option.NORMAL)); + System.out.println(); + System.out.println( + "normal user both + matchService = " + matchFindService.getAllMatchStatus(UserDto.from(users.get(0)), + Option.BOTH)); + System.out.println( + "both user + matchService = " + matchFindService.getAllMatchStatus(UserDto.from(users.get(1)), + Option.BOTH)); + System.out.println( + "both user normal matchService = " + matchFindService.getAllMatchStatus(UserDto.from(users.get(1)), + Option.NORMAL)); + } + + @DisplayName("Queue에 매칭 가능한 normal 상대가 있을 경우 게임 생성") + @Test + void addMatchSameNormalOption() { + matchService.makeMatch(UserDto.from(users.get(2)), Option.RANK, slotTimes.get(0)); + matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)); + matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(0)); + matchService.cancelMatch(UserDto.from(users.get(0)), slotTimes.get(0)); + Optional game = gameRepository.findByStartTime(slotTimes.get(0)); + Assertions.assertThat(game).isEmpty(); + Long size = redisTemplate.opsForList().size(MatchKey.getTime(slotTimes.get(0))); + List allMatchUsers = redisMatchTimeRepository.getAllMatchUsers(slotTimes.get(0)); + Assertions.assertThat(size).isEqualTo(2L); + RedisMatchUser remainedUser = (RedisMatchUser)redisTemplate.opsForList() + .index(MatchKey.getTime(slotTimes.get(0)), 0); + Assertions.assertThat(remainedUser.getUserId()).isEqualTo(users.get(2).getId()); + Assertions.assertThat(notiRepository.findAllByUser(users.get(1)).size()).isEqualTo(2); + Assertions.assertThat(notiRepository.findAllByUser(users.get(0)).size()).isEqualTo(1); + Assertions.assertThat(notiRepository.findAllByUser(users.get(2)).size()).isEqualTo(0); + } + + @DisplayName("게임 재생성 테스트") + @Test + void remakeGameAfterCancelling() { + matchService.makeMatch(UserDto.from(users.get(2)), Option.RANK, slotTimes.get(0)); + matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)); + matchService.makeMatch(UserDto.from(users.get(1)), Option.BOTH, slotTimes.get(0)); + matchService.cancelMatch(UserDto.from(users.get(2)), slotTimes.get(0)); + Optional game = gameRepository.findByStartTime(slotTimes.get(0)); + Assertions.assertThat(game).isPresent(); + Long size = redisTemplate.opsForList().size(MatchKey.getTime(slotTimes.get(0))); + Assertions.assertThat(size).isEqualTo(2L); + RedisMatchUser remainedUser = (RedisMatchUser)redisTemplate.opsForList() + .index(MatchKey.getTime(slotTimes.get(0)), 0); + Assertions.assertThat(remainedUser.getUserId()).isEqualTo(users.get(0).getId()); + Assertions.assertThat(notiRepository.findAllByUser(users.get(1)).size()).isEqualTo(1); + Assertions.assertThat(notiRepository.findAllByUser(users.get(0)).size()).isEqualTo(1); + Assertions.assertThat(notiRepository.findAllByUser(users.get(2)).size()).isEqualTo(1); + } + + @DisplayName("Queue에 user가 선택한 random option으로 매칭 가능한 상대가 없을 경우") + @Test + void addMatchRankOptionAndPppGapBiggerThanSeasonPppGap() { + User user1 = matchTestSetting.createUser(); + matchTestSetting.addUsertoRankRedis(user1.getId(), + testSeason.getStartPpp() + testSeason.getPppGap() + 1, testSeason.getId()); //pppGap차이가 충분히 큰 경우 + matchService.makeMatch(UserDto.from(user1), Option.RANK, slotTimes.get(0)); + matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)); + matchService.makeMatch(UserDto.from(users.get(1)), Option.RANK, slotTimes.get(0)); + Long size = redisTemplate.opsForList().size(MatchKey.getTime(slotTimes.get(0))); + Assertions.assertThat(size).isEqualTo(3L); + Optional game = gameRepository.findByStartTime(slotTimes.get(0)); + Assertions.assertThat(game.isEmpty()).isEqualTo(true); + + } + + @DisplayName("Queue에 user가 선택한 random option으로 매칭 가능한 상대가 있는 경우") + @Test + void addMatchRankOptionAndPppGapSamllerThanOrEqualToSeasonPppGap() { + RankRedis userRank = rankRedisRepository.findRankByUserId(RedisKeyManager + .getHashKey(testSeason.getId()), users.get(0).getId()); + User user1 = matchTestSetting.createUser(); + matchTestSetting.addUsertoRankRedis(user1.getId(), userRank.getPpp() + testSeason.getPppGap(), + testSeason.getId()); //pppGap차이가 pppGap만큼 + matchService.makeMatch(UserDto.from(user1), Option.RANK, slotTimes.get(0)); + matchService.makeMatch(UserDto.from(users.get(0)), Option.RANK, slotTimes.get(0)); + Long size = redisTemplate.opsForList().size(MatchKey.getTime(slotTimes.get(0))); + // 현재 시스템 코드에서는 매칭된 슬롯은 안지우고 있음, 매칭되지 않은 슬롯만 삭제중이므로 2가 나옴 + Assertions.assertThat(size).isEqualTo(2L); + Optional game = gameRepository.findByStartTime(slotTimes.get(0)); + Assertions.assertThat(game.isEmpty()).isEqualTo(false); + } + + @DisplayName("Queue에 user가 선택한 both option으로 매칭 가능한 상대가 있는 경우") + @Test + void addMatchBothOptionAndPppGapSmallerThanOrEqualToSeasonPppGap() { + RankRedis userRank = rankRedisRepository.findRankByUserId(RedisKeyManager + .getHashKey(testSeason.getId()), users.get(0).getId()); + User user1 = matchTestSetting.createUser(); + matchTestSetting.addUsertoRankRedis(user1.getId(), userRank.getPpp() + testSeason.getPppGap(), + testSeason.getId()); //pppGap차이가 pppGap만큼 + matchService.makeMatch(UserDto.from(user1), Option.BOTH, slotTimes.get(0)); + matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, slotTimes.get(0)); + Long size = redisTemplate.opsForList().size(MatchKey.getTime(slotTimes.get(0))); + // 현재 시스템 코드에서는 매칭된 슬롯은 안지우고 있음, 매칭되지 않은 슬롯만 삭제중이므로 2가 나옴 + Assertions.assertThat(size).isEqualTo(2L); + Optional game = gameRepository.findByStartTime(slotTimes.get(0)); + Assertions.assertThat(game.isEmpty()).isEqualTo(false); + Assertions.assertThat(game.get().getMode()).isEqualTo(Mode.RANK); + } + + @DisplayName("토너먼트 시간과 겹칠 경우 게임 생성 안됨") + @Test + void addMatchTournamentTime() { + // given + Tournament tournament = Tournament.builder() + .title("test tournament") + .contents("test contents") + .startTime(LocalDateTime.now().plusHours(1)) + .endTime(LocalDateTime.now().plusHours(2)) + .type(TournamentType.MASTER) + .status(TournamentStatus.BEFORE) + .build(); + tournamentRepository.save(tournament); + + // when, then + Assertions.assertThatThrownBy( + () -> matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, tournament.getStartTime())) + .isInstanceOf(TournamentConflictException.class); + + } + } + + @Nested + @DisplayName("매칭 취소 API 테스트") + class CancelMatch { + @DisplayName("게임 생성되었을 때 경기 취소") + @Test + void cancelMatchAfterMakingGameEntity() { + //normal 게임 생성 + matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(3)); + matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(3)); + //user2 다른 슬롯 등록 + //첫번째 유저 경기 취소 + org.junit.jupiter.api.Assertions.assertThrows( + EnrolledSlotException.class, + () -> matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)) + ); + matchService.cancelMatch(UserDto.from(users.get(0)), slotTimes.get(3)); + Optional game = gameRepository.findByStartTime(slotTimes.get(3)); + Assertions.assertThat(game.isEmpty()).isEqualTo(true); + // 취소한 유저는 큐에 없음 + Assertions.assertThat(redisMatchUserRepository.countMatchTime(users.get(0).getId())).isEqualTo(0L); + // 취소하지 않은 유저는 큐에 유지 + Assertions.assertThat(redisMatchUserRepository.countMatchTime(users.get(1).getId())).isEqualTo(1L); + + //알람 확인 + List notifications = notiRepository.findAllByUser(users.get(1)); + System.out.println("users.get(0).getIntraId() = " + users.get(0).getIntraId()); + for (Noti noti : notifications) { + System.out.println("noti.getMessage() = " + noti.getMessage()); + } + Assertions.assertThat(notifications.size()).isEqualTo(2); + Assertions.assertThat(notifications.get(0).getType()).isEqualTo(NotiType.MATCHED); + Assertions.assertThat(notifications.get(1).getType()).isEqualTo(NotiType.CANCELEDBYMAN); + + //패널티 확인 + Optional penaltyUser = penaltyUserRedisRepository.findByIntraId( + users.get(0).getIntraId()); + Assertions.assertThat(penaltyUser).isPresent(); + // 패널티 시간은 하드 코딩 시 관리가 어려우니 Static이나 enum으로 관리하는게 좋을 듯 하다. + Assertions.assertThat(penaltyUser.get().getPenaltyTime()).isEqualTo(30); + org.junit.jupiter.api.Assertions.assertThrows(PenaltyUserSlotException.class, () -> { + matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, slotTimes.get(10)); + }); + } + + @DisplayName("게임 생성 전 경기 취소") + @Test + void cancelBeforeMakingGameEntity() { + RankRedis userRank = rankRedisRepository.findRankByUserId(RedisKeyManager + .getHashKey(testSeason.getId()), users.get(0).getId()); + User user1 = matchTestSetting.createUser(); + matchTestSetting.addUsertoRankRedis(user1.getId(), userRank.getPpp() + testSeason.getPppGap() + 100, + testSeason.getId()); + //매칭이 이루어질 수 없는 유저 3명을 큐에 등록 + matchService.makeMatch(UserDto.from(users.get(0)), Option.RANK, slotTimes.get(0)); + matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(0)); + matchService.makeMatch(UserDto.from(user1), Option.RANK, slotTimes.get(0)); + //user1의 취소 + matchService.cancelMatch(UserDto.from(users.get(1)), slotTimes.get(0)); + List allMatchUsers = redisMatchTimeRepository.getAllMatchUsers(slotTimes.get(0)); + Assertions.assertThat(allMatchUsers.size()).isEqualTo(2L); + + } + + @Test + @DisplayName("토너먼트 게임 취소 테스트") + void cancelMatchedTournamentGame() { + // given + LocalDateTime time = LocalDateTime.now().plusHours(1).withMinute(0).withSecond(0).withNano(0); + Game game = testDataUtils.createMockMatch(users.get(0), testSeason, time, time.withMinute(15), + Mode.TOURNAMENT); + // when, then + Assertions.assertThatThrownBy( + () -> matchService.cancelMatch(UserDto.from(users.get(0)), game.getStartTime())) + .isInstanceOf(BusinessException.class); + } + } + + @Nested + @DisplayName("특정 시간대의 경기 매칭 가능 상태 조회 API 테스트") + class GetMatchTimeScope { + @DisplayName("슬롯 조회 : 게임 생성한 후 내 테이블로 인식") + @Test + void readMyTableAfterMakingGame() { + //normal 게임 생성 + matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)); + matchService.makeMatch(UserDto.from(users.get(0)), Option.RANK, slotTimes.get(4)); + matchService.makeMatch(UserDto.from(users.get(1)), Option.RANK, slotTimes.get(1)); + matchService.makeMatch(UserDto.from(users.get(2)), Option.NORMAL, slotTimes.get(2)); + SlotStatusResponseListDto slotStatusList = matchFindService.getAllMatchStatus(UserDto.from(users.get(0)), + Option.NORMAL); + for (int i = 0; i < 3; i++) { + System.out.println("slotTimes = " + String.valueOf(i) + slotTimes.get(i)); + } + for (List dtos : slotStatusList.getMatchBoards()) { + for (SlotStatusDto dto : dtos) { + System.out.println("dto = " + dto); + if (dto.getStartTime().equals(slotTimes.get(0))) { + Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.MYTABLE.getCode()); + } + if (dto.getStartTime().equals(slotTimes.get(1))) { + Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.OPEN.getCode()); + } + if (dto.getStartTime().equals(slotTimes.get(2))) { + Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.MATCH.getCode()); + } + if (dto.getStartTime().equals(slotTimes.get(4))) { + Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.CLOSE.getCode()); + } + } + } + + } + + @DisplayName("슬롯 조회 : 게임 생성 전 내 테이블로 인식") + @Test + void readMyTableBeforeMakingGame() { + for (int i = 0; i < 3; i++) { + matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(i)); + } + matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(3)); + matchService.makeMatch(UserDto.from(users.get(2)), Option.NORMAL, slotTimes.get(3)); + SlotStatusResponseListDto slotStatusList = matchFindService.getAllMatchStatus(UserDto.from(users.get(0)), + Option.NORMAL); + for (List dtos : slotStatusList.getMatchBoards()) { + for (SlotStatusDto dto : dtos) { + if (dto.getStartTime().equals(slotTimes.get(0))) { + Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.MYTABLE.getCode()); + } + if (dto.getStartTime().equals(slotTimes.get(1))) { + Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.MYTABLE.getCode()); + } + if (dto.getStartTime().equals(slotTimes.get(2))) { + Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.MYTABLE.getCode()); + } + if (dto.getStartTime().equals(slotTimes.get(3))) { + Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.CLOSE.getCode()); + } + } + } + + } + + @DisplayName("슬롯 조회 : 게임 등록 되면 제 3자한테 closed 처리") + @Test + void getClosedStatusOfExistGame() { + matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(3)); + matchService.makeMatch(UserDto.from(users.get(2)), Option.NORMAL, slotTimes.get(3)); + SlotStatusResponseListDto allMatchStatus = matchFindService.getAllMatchStatus(UserDto.from(users.get(3)), + Option.NORMAL); + for (List dtos : allMatchStatus.getMatchBoards()) { + for (SlotStatusDto dto : dtos) { + if (dto.getStartTime().equals(slotTimes.get(3))) { + Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.CLOSE.getCode()); + } + } + } + } + + @DisplayName("슬롯 조회 : 게임 등록 되면 제3자가 다른 게임 등록해도 제 3자한테 closed 처리") + @Test + void getClosedStatusOfExistGame2() { + matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(3)); + matchService.makeMatch(UserDto.from(users.get(2)), Option.NORMAL, slotTimes.get(3)); + matchService.makeMatch(UserDto.from(users.get(3)), Option.NORMAL, slotTimes.get(4)); + matchService.makeMatch(UserDto.from(users.get(4)), Option.NORMAL, slotTimes.get(4)); + SlotStatusResponseListDto allMatchStatus = matchFindService.getAllMatchStatus(UserDto.from(users.get(3)), + Option.NORMAL); + for (List dtos : allMatchStatus.getMatchBoards()) { + for (SlotStatusDto dto : dtos) { + if (dto.getStartTime().equals(slotTimes.get(3))) { + Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.CLOSE.getCode()); + } + } + } + } + + @DisplayName("토너먼트 시간에 대한 슬롯 블락") + @Test + @Disabled + void getClosedStatusOfTournament() { + // given + Tournament tournament = Tournament.builder() + .title("test tournament") + .contents("test contents") + .startTime(LocalDateTime.now().plusHours(1)) + .endTime(LocalDateTime.now().plusHours(2)) + .type(TournamentType.MASTER) + .status(TournamentStatus.BEFORE) + .build(); + tournamentRepository.save(tournament); + tierRepository.save(new Tier("image url")); + + // TODO 현재 upload redis해도 redis 데이터 없다는 에러 발생함 + redisUploadService.uploadRedis(); + // when + LocalDateTime now = LocalDateTime.now(); + SlotStatusResponseListDto allMatchStatus = matchFindService.getAllMatchStatus(UserDto.from(users.get(0)), + Option.NORMAL); + + // then + for (List dtos : allMatchStatus.getMatchBoards()) { + for (SlotStatusDto dto : dtos) { + if (dto.getStartTime().isBefore(tournament.getStartTime()) + || dto.getEndTime().isAfter(tournament.getEndTime())) { + Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.OPEN.getCode()); + } else { + Assertions.assertThat(dto.getStatus()).isEqualTo(SlotStatus.CLOSE.getCode()); + } + } + } + } + } + + @Nested + @DisplayName("현재 매치 정보 조회 API 테스트") + class GetCurrentMatch { + @DisplayName("current Match 조회 : user가 등록한 슬롯이 매칭되었을 때") + @Test + void readCurrentMatchAfterMakingGameEntity() { + //게임생성 + matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(3)); + matchService.makeMatch(UserDto.from(users.get(2)), Option.NORMAL, slotTimes.get(3)); + UserDto userDto = UserDto.from(users.get(1)); + MatchStatusResponseListDto currentMatch = matchFindService.getCurrentMatch(userDto); + //user의 current match 확인 + List match = currentMatch.getMatch(); + Assertions.assertThat(match.size()).isEqualTo(1); + Assertions.assertThat(match.get(0).getMyTeam().get(0)).isEqualTo(users.get(1).getIntraId()); + Assertions.assertThat(match.get(0).getEnemyTeam().get(0)).isEqualTo(users.get(2).getIntraId()); + Assertions.assertThat(match.get(0).getStartTime()).isEqualTo(slotTimes.get(3)); + Assertions.assertThat(match.get(0).getIsMatched()).isEqualTo(true); + } + + @DisplayName("current Match 조회 : user가 등록한 슬롯이 매칭되지 않았을 때") + @Test + void readCurrentMatchBeforeMakingGameEntity() { + //유저 슬롯 3개 등록 시도 + for (int i = 0; i < 3; i++) { + System.out.println("slotTimes = " + slotTimes.get(i)); + matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(i)); + } + UserDto userDto = UserDto.from(users.get(1)); + MatchStatusResponseListDto currentMatch = matchFindService.getCurrentMatch(userDto); + List match = currentMatch.getMatch(); + //user current match 확인 + Assertions.assertThat(match.size()).isEqualTo(3); + for (int i = 0; i < 3; i++) { + System.out.println("match = " + match.get(i).getStartTime()); + Assertions.assertThat(match.get(i).getMyTeam().size()).isEqualTo(0); + Assertions.assertThat(match.get(i).getEnemyTeam().size()).isEqualTo(0); + Assertions.assertThat(match.get(i).getStartTime()).isEqualTo(slotTimes.get(i)); + Assertions.assertThat(match.get(i).getIsMatched()).isEqualTo(false); + } + } + + @DisplayName("Guest User slot 조회") + @Test + void readAllSlotsAndCurrentMatchForGuset() { + User guestUser = matchTestSetting.createGuestUser(); + MatchStatusResponseListDto currentMatch = matchFindService.getCurrentMatch(UserDto.from(guestUser)); + SlotStatusResponseListDto allMatchStatus = matchFindService.getAllMatchStatus(UserDto.from(guestUser), + Option.NORMAL); + Assertions.assertThat(currentMatch.getMatch().size()).isEqualTo(0); + System.out.println("allMatchStatus = " + allMatchStatus); + } + + } } diff --git a/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java b/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java index 5f503071a..fdfae8721 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java +++ b/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java @@ -1,5 +1,24 @@ package com.gg.server.domain.match.service; +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Mockito.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; import com.gg.server.admin.noti.service.NotiAdminService; import com.gg.server.domain.game.data.Game; @@ -19,298 +38,307 @@ import com.gg.server.utils.MatchTestUtils; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; @IntegrationTest @SpringBootTest @Transactional public class MatchTournamentServiceTest { - @Autowired - TestDataUtils testDataUtils; - @Autowired - SlotManagementRepository slotManagementRepository; - @Autowired - GameRepository gameRepository; - @Autowired - MatchTournamentService matchTournamentService; - @Autowired - MatchTestUtils matchTestUtils; - @MockBean - NotiAdminService notiAdminService; - - Tournament tournament; - List allTournamentGames; - - @BeforeEach - public void beforeEach() { - testDataUtils.createSeason(); - testDataUtils.createSlotManagement(15); - tournament = testDataUtils.createTournamentWithUser(Tournament.ALLOWED_JOINED_NUMBER, 4, "test"); - allTournamentGames = testDataUtils.createTournamentGameList(tournament, 7); - } - - @Nested - @DisplayName("토너먼트 라운드별 경기 생성 테스트") - class MatchTournament { - @Test - @DisplayName("8강 경기 매칭 성공") - public void quarterTest() { - // when - matchTournamentService.matchGames(tournament, TournamentRound.QUARTER_FINAL_1); - - // then - List quarterRounds = TournamentRound.getSameRounds(TournamentRound.QUARTER_FINAL_1); - List quarterRoundGames = allTournamentGames.stream() - .filter(o -> quarterRounds.contains(o.getTournamentRound())) - .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) - .collect(Collectors.toList()); - LocalDateTime startTime = tournament.getStartTime(); - int gameInterval = slotManagementRepository.findCurrent(startTime) - .orElseThrow(SlotNotFoundException::new) - .getGameInterval(); - - // 4개의 8강 경기가 생성되었는지 확인 - assertThat(quarterRoundGames.size()).isEqualTo(Tournament.ALLOWED_JOINED_NUMBER / 2); - for (TournamentGame tournamentGame : quarterRoundGames) { - assertThat(tournamentGame.getGame()).isNotNull(); - assertThat(tournamentGame.getGame().getStatus()).isEqualTo(StatusType.BEFORE); - assertThat(tournamentGame.getGame().getStartTime()).isEqualTo(startTime); - assertThat(tournamentGame.getGame().getEndTime()).isEqualTo(startTime.plusMinutes(gameInterval)); - startTime = startTime.plusMinutes((long) gameInterval); - } - verify(notiAdminService, times(8)).sendAnnounceNotiToUser(Mockito.any(SendNotiAdminRequestDto.class)); - } - - @Test - @DisplayName("4강 경기 매칭 성공") - public void semiTest() { - // given - // 8강 경기 결과 - List tournamentGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.QUARTER_FINAL_1); - matchTestUtils.updateTournamentGamesResult(tournamentGames, List.of(2, 0)); - - // when - matchTournamentService.matchGames(tournament, TournamentRound.SEMI_FINAL_1); - - // then - List semiRounds = TournamentRound.getSameRounds(TournamentRound.SEMI_FINAL_1); - List semiRoundGames = allTournamentGames.stream() - .filter(o -> semiRounds.contains(o.getTournamentRound())) - .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) - .collect(Collectors.toList()); - // 2개의 4강 경기가 생성되었는지 확인 - assertThat(semiRoundGames.size()).isEqualTo(Tournament.ALLOWED_JOINED_NUMBER / 4); - for (TournamentGame tournamentGame : semiRoundGames) { - assertThat(tournamentGame.getGame()).isNotNull(); - assertThat(tournamentGame.getGame().getStatus()).isEqualTo(StatusType.BEFORE); - } - // 8강에서 이긴 유저끼리 4강에 매칭되었는지 확인 - List quarterRounds = TournamentRound.getSameRounds(TournamentRound.QUARTER_FINAL_1); - List quarterRoundGames = allTournamentGames.stream() - .filter(o -> quarterRounds.contains(o.getTournamentRound())) - .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) - .collect(Collectors.toList()); - List semiTeams = new ArrayList<>(); - List quarterWinningTeams = new ArrayList<>(); - for(TournamentGame semiRoundGame : semiRoundGames) { - semiTeams.add(semiRoundGame.getGame().getTeams().get(0).getTeamUsers().get(0).getUser()); - semiTeams.add(semiRoundGame.getGame().getTeams().get(1).getTeamUsers().get(0).getUser()); - } - for (TournamentGame quarterRoundGame : quarterRoundGames) { - Team winningTeam = matchTestUtils.getWinningTeam(quarterRoundGame.getGame()); - quarterWinningTeams.add(winningTeam.getTeamUsers().get(0).getUser()); - } - assertThat(semiTeams).contains(quarterWinningTeams.get(0)); - assertThat(semiTeams).contains(quarterWinningTeams.get(1)); - verify(notiAdminService, times(4)).sendAnnounceNotiToUser(Mockito.any(SendNotiAdminRequestDto.class)); - } - - @Test - @DisplayName("결승 경기 매칭 테스트 성공") - public void finalTest() { - // given - // 8강 & 4강 경기 결과 입력 - List quarterGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.QUARTER_FINAL_1); - matchTestUtils.updateTournamentGamesResult(quarterGames, List.of(2, 0)); - List semiGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.SEMI_FINAL_1); - matchTestUtils.updateTournamentGamesResult(semiGames, List.of(2, 0)); - - // when - matchTournamentService.matchGames(tournament, TournamentRound.THE_FINAL); - - // then - // 1개의 결승 경기가 생성되었는지 확인 - TournamentGame finalRoundGame = allTournamentGames.stream() - .filter(o -> TournamentRound.THE_FINAL.equals(o.getTournamentRound())).findAny().orElse(null); - assertThat(finalRoundGame.getGame()).isNotNull(); - verify(notiAdminService, times(2)).sendAnnounceNotiToUser(Mockito.any(SendNotiAdminRequestDto.class)); - } - - @Test - @DisplayName("이미 매칭된 게임이 존재할 경우 실패") - public void failAlreadyMatched() { - // given - // 8강 경기 매칭 + 4강 경기 매칭 - List quarterGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.QUARTER_FINAL_1); - matchTestUtils.updateTournamentGamesResult(quarterGames, List.of(2, 0)); - List semiGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.SEMI_FINAL_1); - matchTestUtils.updateTournamentGamesResult(semiGames, List.of(2, 0)); - - // when, then - assertThatThrownBy(() -> matchTournamentService.matchGames(tournament, TournamentRound.SEMI_FINAL_1)) - .isInstanceOf(EnrolledSlotException.class); - } - } - - @Nested - @DisplayName("토너먼트 매칭 가능 상태 확인 테스트") - class CheckTournament { - @Test - @DisplayName("IMPOSSIBLE : 결승 경기 점수 입력 후 토너먼트 END 상태로 업데이트 성공 & 종료 시간 갱신") - public void finalEndTest() { - // given - // 8강 & 4강 & 결승 경기 결과 입력 - List quarterGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.QUARTER_FINAL_1); - matchTestUtils.updateTournamentGamesResult(quarterGames, List.of(2, 0)); - List semiGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.SEMI_FINAL_1); - matchTestUtils.updateTournamentGamesResult(semiGames, List.of(2, 0)); - Game finalGame = matchTestUtils.matchTournamentGames(tournament, TournamentRound.THE_FINAL).get(0).getGame(); - matchTestUtils.updateTournamentGameResult(finalGame, List.of(2, 0)); - - // when - TournamentMatchStatus tournamentMatchStatus = matchTournamentService.checkTournamentGame(finalGame); - - // then - // 토너먼트 상태가 END로 변경되었는지 - // winner가 존재하는지 확인 - assertThat(TournamentMatchStatus.IMPOSSIBLE).isEqualTo(tournamentMatchStatus); - assertThat(tournament.getStatus()).isEqualTo(TournamentStatus.END); - assertThat(tournament.getWinner()).isNotNull(); - assertThat(tournament.getEndTime()).isEqualTo(finalGame.getEndTime()); - } - - @Test - @DisplayName("IMPOSSBLE : 진행중인 라운드의 모든 경기가 점수입력 완료되지 않을 경우") - public void impossibleTest() { - // given - // 8강 경기 매칭 - List quarterGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.QUARTER_FINAL_1); - - // when - matchTestUtils.updateTournamentGameResult(quarterGames.get(0).getGame(), List.of(2, 0)); - TournamentMatchStatus tournamentMatchStatus = matchTournamentService.checkTournamentGame(quarterGames.get(0).getGame()); - - // then - assertThat(tournamentMatchStatus).isEqualTo(TournamentMatchStatus.IMPOSSIBLE); - } - - @Test - @DisplayName("ALREADY_MATCHED : 이미 매칭된 게임이 존재할 경우") - public void alreadyMatchedTest() { - // given - // 8강 경기 매칭 + 4강 경기 매칭 - List quarterGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.QUARTER_FINAL_1); - matchTestUtils.updateTournamentGamesResult(quarterGames, List.of(2, 0)); - List semiGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.SEMI_FINAL_1); - matchTestUtils.updateTournamentGamesResult(semiGames, List.of(2, 0)); - - // when - TournamentMatchStatus tournamentMatchStatus = matchTournamentService.checkTournamentGame(quarterGames.get(0).getGame()); - - // then - assertThat(tournamentMatchStatus).isEqualTo(TournamentMatchStatus.ALREADY_MATCHED); - } - - @Test - @DisplayName("POSSIBLE : 토너먼트 매칭 가능 상태") - public void possibleTest() { - // given - // 8강 경기 매칭 - List quarterGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.QUARTER_FINAL_1); - matchTestUtils.updateTournamentGamesResult(quarterGames, List.of(2, 0)); - - // when - TournamentMatchStatus tournamentMatchStatus = matchTournamentService.checkTournamentGame(quarterGames.get(0).getGame()); - - // then - assertThat(tournamentMatchStatus).isEqualTo(TournamentMatchStatus.POSSIBLE); - } - - } - - @Nested - @DisplayName("위너 변경에 따른 다음 경기 팀 변경 테스트") - class ChangeTeam { - @Test - @DisplayName("8강 경기에서 4강 경기로 팀 변경 성공") - public void quarterToSemiTest() { - // given - // 8강 경기 결과 + 4강 매칭 - List quarterGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.QUARTER_FINAL_1); - matchTestUtils.updateTournamentGamesResult(quarterGames, List.of(2, 0)); - List semiGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.SEMI_FINAL_1); - - Game game = quarterGames.get(0).getGame(); // QAUARTER_FINAL_1l Game - TournamentRound nextRound = quarterGames.get(0).getTournamentRound().getNextRound(); // SEMI_FINAL_1 - Game nextMatchedGame = semiGames.stream() // SEMI_FINAL_1 Game - .filter(o -> nextRound.equals(o.getTournamentRound())) - .findAny() - .orElseThrow(() -> new IllegalArgumentException("다음 경기가 존재하지 않습니다.")).getGame(); - - // when - // 기존 8강 경기에서 진 팀이 점수 수정으로 이긴 팀으로 변경 - Team losingTeam = game.getTeams().stream().filter(Team::getWin).findAny().orElseThrow(() -> new IllegalArgumentException("승리팀이 존재하지 않습니다.")); - Team winningTeam = game.getTeams().stream().filter(o -> !o.getWin()).findAny().orElseThrow(() -> new IllegalArgumentException("패배팀이 존재하지 않습니다.")); - losingTeam.updateScore(0, false); - winningTeam.updateScore(2, true); - matchTournamentService.updateMatchedGameUser(game, nextMatchedGame); - - // then - // 점수 수정으로 8강 경기에서 이긴 팀이 다음 경기로 변경되었는지 확인 - List nextGameUsers = new ArrayList<>(); - nextGameUsers.add(nextMatchedGame.getTeams().get(0).getTeamUsers().get(0).getUser()); - nextGameUsers.add(nextMatchedGame.getTeams().get(1).getTeamUsers().get(0).getUser()); - - assertThat(nextGameUsers.contains(winningTeam.getTeamUsers().get(0).getUser())).isTrue(); - assertThat(nextGameUsers.contains(losingTeam.getTeamUsers().get(0).getUser())).isFalse(); - verify(notiAdminService, times(2)).sendAnnounceNotiToUser(Mockito.any(SendNotiAdminRequestDto.class)); - } - - @Test - @DisplayName("우승팀이 존재하지 않을 경우 실패") - public void failUpdateWinner() { - // given - // 8강 매칭 - List quarterGames = matchTestUtils.matchTournamentGames(tournament, TournamentRound.QUARTER_FINAL_1); - TournamentGame targetTournamentGame = quarterGames.get(0); - TournamentRound nextRound = targetTournamentGame.getTournamentRound().getNextRound(); - Game nextMatchedGame = allTournamentGames.stream() - .filter(o -> nextRound.equals(o.getTournamentRound())) - .findAny() - .orElseThrow(() -> new IllegalArgumentException("다음 경기가 존재하지 않습니다.")).getGame(); - - // when, then - assertThatThrownBy(() -> matchTournamentService.updateMatchedGameUser(targetTournamentGame.getGame(), nextMatchedGame)) - .isInstanceOf(WinningTeamNotFoundException.class); - } - } + @Autowired + TestDataUtils testDataUtils; + @Autowired + SlotManagementRepository slotManagementRepository; + @Autowired + GameRepository gameRepository; + @Autowired + MatchTournamentService matchTournamentService; + @Autowired + MatchTestUtils matchTestUtils; + @MockBean + NotiAdminService notiAdminService; + + Tournament tournament; + List allTournamentGames; + + @BeforeEach + public void beforeEach() { + testDataUtils.createSeason(); + testDataUtils.createSlotManagement(15); + tournament = testDataUtils.createTournamentWithUser(Tournament.ALLOWED_JOINED_NUMBER, 4, "test"); + allTournamentGames = testDataUtils.createTournamentGameList(tournament, 7); + } + + @Nested + @DisplayName("토너먼트 라운드별 경기 생성 테스트") + class MatchTournament { + @Test + @DisplayName("8강 경기 매칭 성공") + public void quarterTest() { + // when + matchTournamentService.matchGames(tournament, TournamentRound.QUARTER_FINAL_1); + + // then + List quarterRounds = TournamentRound.getSameRounds(TournamentRound.QUARTER_FINAL_1); + List quarterRoundGames = allTournamentGames.stream() + .filter(o -> quarterRounds.contains(o.getTournamentRound())) + .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) + .collect(Collectors.toList()); + LocalDateTime startTime = tournament.getStartTime(); + int gameInterval = slotManagementRepository.findCurrent(startTime) + .orElseThrow(SlotNotFoundException::new) + .getGameInterval(); + + // 4개의 8강 경기가 생성되었는지 확인 + assertThat(quarterRoundGames.size()).isEqualTo(Tournament.ALLOWED_JOINED_NUMBER / 2); + for (TournamentGame tournamentGame : quarterRoundGames) { + assertThat(tournamentGame.getGame()).isNotNull(); + assertThat(tournamentGame.getGame().getStatus()).isEqualTo(StatusType.BEFORE); + assertThat(tournamentGame.getGame().getStartTime()).isEqualTo(startTime); + assertThat(tournamentGame.getGame().getEndTime()).isEqualTo(startTime.plusMinutes(gameInterval)); + startTime = startTime.plusMinutes((long)gameInterval); + } + verify(notiAdminService, times(8)).sendAnnounceNotiToUser(Mockito.any(SendNotiAdminRequestDto.class)); + } + + @Test + @DisplayName("4강 경기 매칭 성공") + public void semiTest() { + // given + // 8강 경기 결과 + List tournamentGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.QUARTER_FINAL_1); + matchTestUtils.updateTournamentGamesResult(tournamentGames, List.of(2, 0)); + + // when + matchTournamentService.matchGames(tournament, TournamentRound.SEMI_FINAL_1); + + // then + List semiRounds = TournamentRound.getSameRounds(TournamentRound.SEMI_FINAL_1); + List semiRoundGames = allTournamentGames.stream() + .filter(o -> semiRounds.contains(o.getTournamentRound())) + .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) + .collect(Collectors.toList()); + // 2개의 4강 경기가 생성되었는지 확인 + assertThat(semiRoundGames.size()).isEqualTo(Tournament.ALLOWED_JOINED_NUMBER / 4); + for (TournamentGame tournamentGame : semiRoundGames) { + assertThat(tournamentGame.getGame()).isNotNull(); + assertThat(tournamentGame.getGame().getStatus()).isEqualTo(StatusType.BEFORE); + } + // 8강에서 이긴 유저끼리 4강에 매칭되었는지 확인 + List quarterRounds = TournamentRound.getSameRounds(TournamentRound.QUARTER_FINAL_1); + List quarterRoundGames = allTournamentGames.stream() + .filter(o -> quarterRounds.contains(o.getTournamentRound())) + .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) + .collect(Collectors.toList()); + List semiTeams = new ArrayList<>(); + List quarterWinningTeams = new ArrayList<>(); + for (TournamentGame semiRoundGame : semiRoundGames) { + semiTeams.add(semiRoundGame.getGame().getTeams().get(0).getTeamUsers().get(0).getUser()); + semiTeams.add(semiRoundGame.getGame().getTeams().get(1).getTeamUsers().get(0).getUser()); + } + for (TournamentGame quarterRoundGame : quarterRoundGames) { + Team winningTeam = matchTestUtils.getWinningTeam(quarterRoundGame.getGame()); + quarterWinningTeams.add(winningTeam.getTeamUsers().get(0).getUser()); + } + assertThat(semiTeams).contains(quarterWinningTeams.get(0)); + assertThat(semiTeams).contains(quarterWinningTeams.get(1)); + verify(notiAdminService, times(4)).sendAnnounceNotiToUser(Mockito.any(SendNotiAdminRequestDto.class)); + } + + @Test + @DisplayName("결승 경기 매칭 테스트 성공") + public void finalTest() { + // given + // 8강 & 4강 경기 결과 입력 + List quarterGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.QUARTER_FINAL_1); + matchTestUtils.updateTournamentGamesResult(quarterGames, List.of(2, 0)); + List semiGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.SEMI_FINAL_1); + matchTestUtils.updateTournamentGamesResult(semiGames, List.of(2, 0)); + + // when + matchTournamentService.matchGames(tournament, TournamentRound.THE_FINAL); + + // then + // 1개의 결승 경기가 생성되었는지 확인 + TournamentGame finalRoundGame = allTournamentGames.stream() + .filter(o -> TournamentRound.THE_FINAL.equals(o.getTournamentRound())).findAny().orElse(null); + assertThat(finalRoundGame.getGame()).isNotNull(); + verify(notiAdminService, times(2)).sendAnnounceNotiToUser(Mockito.any(SendNotiAdminRequestDto.class)); + } + + @Test + @DisplayName("이미 매칭된 게임이 존재할 경우 실패") + public void failAlreadyMatched() { + // given + // 8강 경기 매칭 + 4강 경기 매칭 + List quarterGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.QUARTER_FINAL_1); + matchTestUtils.updateTournamentGamesResult(quarterGames, List.of(2, 0)); + List semiGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.SEMI_FINAL_1); + matchTestUtils.updateTournamentGamesResult(semiGames, List.of(2, 0)); + + // when, then + assertThatThrownBy(() -> matchTournamentService.matchGames(tournament, TournamentRound.SEMI_FINAL_1)) + .isInstanceOf(EnrolledSlotException.class); + } + } + + @Nested + @DisplayName("토너먼트 매칭 가능 상태 확인 테스트") + class CheckTournament { + @Test + @DisplayName("IMPOSSIBLE : 결승 경기 점수 입력 후 토너먼트 END 상태로 업데이트 성공 & 종료 시간 갱신") + public void finalEndTest() { + // given + // 8강 & 4강 & 결승 경기 결과 입력 + List quarterGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.QUARTER_FINAL_1); + matchTestUtils.updateTournamentGamesResult(quarterGames, List.of(2, 0)); + List semiGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.SEMI_FINAL_1); + matchTestUtils.updateTournamentGamesResult(semiGames, List.of(2, 0)); + Game finalGame = matchTestUtils.matchTournamentGames(tournament, TournamentRound.THE_FINAL) + .get(0) + .getGame(); + matchTestUtils.updateTournamentGameResult(finalGame, List.of(2, 0)); + + // when + TournamentMatchStatus tournamentMatchStatus = matchTournamentService.checkTournamentGame(finalGame); + + // then + // 토너먼트 상태가 END로 변경되었는지 + // winner가 존재하는지 확인 + assertThat(TournamentMatchStatus.IMPOSSIBLE).isEqualTo(tournamentMatchStatus); + assertThat(tournament.getStatus()).isEqualTo(TournamentStatus.END); + assertThat(tournament.getWinner()).isNotNull(); + assertThat(tournament.getEndTime()).isEqualTo(finalGame.getEndTime()); + } + + @Test + @DisplayName("IMPOSSBLE : 진행중인 라운드의 모든 경기가 점수입력 완료되지 않을 경우") + public void impossibleTest() { + // given + // 8강 경기 매칭 + List quarterGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.QUARTER_FINAL_1); + + // when + matchTestUtils.updateTournamentGameResult(quarterGames.get(0).getGame(), List.of(2, 0)); + TournamentMatchStatus tournamentMatchStatus = matchTournamentService.checkTournamentGame( + quarterGames.get(0).getGame()); + + // then + assertThat(tournamentMatchStatus).isEqualTo(TournamentMatchStatus.IMPOSSIBLE); + } + + @Test + @DisplayName("ALREADY_MATCHED : 이미 매칭된 게임이 존재할 경우") + public void alreadyMatchedTest() { + // given + // 8강 경기 매칭 + 4강 경기 매칭 + List quarterGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.QUARTER_FINAL_1); + matchTestUtils.updateTournamentGamesResult(quarterGames, List.of(2, 0)); + List semiGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.SEMI_FINAL_1); + matchTestUtils.updateTournamentGamesResult(semiGames, List.of(2, 0)); + + // when + TournamentMatchStatus tournamentMatchStatus = matchTournamentService.checkTournamentGame( + quarterGames.get(0).getGame()); + + // then + assertThat(tournamentMatchStatus).isEqualTo(TournamentMatchStatus.ALREADY_MATCHED); + } + + @Test + @DisplayName("POSSIBLE : 토너먼트 매칭 가능 상태") + public void possibleTest() { + // given + // 8강 경기 매칭 + List quarterGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.QUARTER_FINAL_1); + matchTestUtils.updateTournamentGamesResult(quarterGames, List.of(2, 0)); + + // when + TournamentMatchStatus tournamentMatchStatus = matchTournamentService.checkTournamentGame( + quarterGames.get(0).getGame()); + + // then + assertThat(tournamentMatchStatus).isEqualTo(TournamentMatchStatus.POSSIBLE); + } + + } + + @Nested + @DisplayName("위너 변경에 따른 다음 경기 팀 변경 테스트") + class ChangeTeam { + @Test + @DisplayName("8강 경기에서 4강 경기로 팀 변경 성공") + public void quarterToSemiTest() { + // given + // 8강 경기 결과 + 4강 매칭 + List quarterGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.QUARTER_FINAL_1); + matchTestUtils.updateTournamentGamesResult(quarterGames, List.of(2, 0)); + List semiGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.SEMI_FINAL_1); + + Game game = quarterGames.get(0) + .getGame(); // QAUARTER_FINAL_1l Game + TournamentRound nextRound = quarterGames.get(0).getTournamentRound().getNextRound(); // SEMI_FINAL_1 + Game nextMatchedGame = semiGames.stream() // SEMI_FINAL_1 Game + .filter(o -> nextRound.equals(o.getTournamentRound())) + .findAny() + .orElseThrow(() -> new IllegalArgumentException("다음 경기가 존재하지 않습니다.")).getGame(); + + // when + // 기존 8강 경기에서 진 팀이 점수 수정으로 이긴 팀으로 변경 + Team losingTeam = game.getTeams() + .stream() + .filter(Team::getWin) + .findAny() + .orElseThrow(() -> new IllegalArgumentException("승리팀이 존재하지 않습니다.")); + Team winningTeam = game.getTeams() + .stream() + .filter(o -> !o.getWin()) + .findAny() + .orElseThrow(() -> new IllegalArgumentException("패배팀이 존재하지 않습니다.")); + losingTeam.updateScore(0, false); + winningTeam.updateScore(2, true); + matchTournamentService.updateMatchedGameUser(game, nextMatchedGame); + + // then + // 점수 수정으로 8강 경기에서 이긴 팀이 다음 경기로 변경되었는지 확인 + List nextGameUsers = new ArrayList<>(); + nextGameUsers.add(nextMatchedGame.getTeams().get(0).getTeamUsers().get(0).getUser()); + nextGameUsers.add(nextMatchedGame.getTeams().get(1).getTeamUsers().get(0).getUser()); + + assertThat(nextGameUsers.contains(winningTeam.getTeamUsers().get(0).getUser())).isTrue(); + assertThat(nextGameUsers.contains(losingTeam.getTeamUsers().get(0).getUser())).isFalse(); + verify(notiAdminService, times(2)).sendAnnounceNotiToUser(Mockito.any(SendNotiAdminRequestDto.class)); + } + + @Test + @DisplayName("우승팀이 존재하지 않을 경우 실패") + public void failUpdateWinner() { + // given + // 8강 매칭 + List quarterGames = matchTestUtils.matchTournamentGames(tournament, + TournamentRound.QUARTER_FINAL_1); + TournamentGame targetTournamentGame = quarterGames.get(0); + TournamentRound nextRound = targetTournamentGame.getTournamentRound().getNextRound(); + Game nextMatchedGame = allTournamentGames.stream() + .filter(o -> nextRound.equals(o.getTournamentRound())) + .findAny() + .orElseThrow(() -> new IllegalArgumentException("다음 경기가 존재하지 않습니다.")).getGame(); + + // when, then + assertThatThrownBy( + () -> matchTournamentService.updateMatchedGameUser(targetTournamentGame.getGame(), nextMatchedGame)) + .isInstanceOf(WinningTeamNotFoundException.class); + } + } } diff --git a/src/test/java/com/gg/server/domain/megaphone/controller/MegaphoneControllerTest.java b/src/test/java/com/gg/server/domain/megaphone/controller/MegaphoneControllerTest.java index 47aecc9db..29ff626a6 100644 --- a/src/test/java/com/gg/server/domain/megaphone/controller/MegaphoneControllerTest.java +++ b/src/test/java/com/gg/server/domain/megaphone/controller/MegaphoneControllerTest.java @@ -1,14 +1,23 @@ package com.gg.server.domain.megaphone.controller; -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.assertj.core.api.Assertions.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.time.LocalTime; + +import org.apache.http.HttpHeaders; +import org.assertj.core.api.AssertionsForClassTypes; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.utils.annotation.IntegrationTest; import com.gg.server.domain.item.data.Item; import com.gg.server.domain.item.type.ItemType; import com.gg.server.domain.megaphone.data.Megaphone; @@ -24,138 +33,130 @@ import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.ItemTestUtils; import com.gg.server.utils.TestDataUtils; -import java.time.LocalTime; +import com.gg.server.utils.annotation.IntegrationTest; + import lombok.RequiredArgsConstructor; -import org.apache.http.HttpHeaders; -import org.assertj.core.api.AssertionsForClassTypes; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.transaction.annotation.Transactional; @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc class MegaphoneControllerTest { - @Autowired - TestDataUtils testDataUtils; - - @Autowired - private MockMvc mockMvc; - - @Autowired - ObjectMapper objectMapper; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - MegaphoneRepository megaphoneRepository; - - @Autowired - ReceiptRepository receiptRepository; - - @Autowired - ItemTestUtils itemTestUtils; - - @Test - @Transactional - @DisplayName("[Post] /pingpong/megaphones") - void useMegaphoneTest() throws Exception { - // 해당 테스트는 시스템상 23:55 ~ 00:05 사이에 테스트 불가능 - if (LocalTime.now().isAfter(LocalTime.of(23, 54)) - || LocalTime.now().isBefore(LocalTime.of(0, 6))) { - return; - } - String intraId = "intra"; - String email = "email"; - User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, - SnsType.BOTH, RoleType.ADMIN); - String accessToken = tokenProvider.createToken(newUser.getId()); - // db에 저장해두고 테스트 - ItemUpdateRequestDto dto = new ItemUpdateRequestDto("확성기", "default", - "default", 40, 50, ItemType.MEGAPHONE); - Item item = itemTestUtils.createItem(newUser, dto); - Receipt receipt = itemTestUtils.purchaseItem(newUser, newUser, item); - MegaphoneUseRequestDto megaphoneUseRequestDto = new MegaphoneUseRequestDto(receipt.getId(), "test"); - String content = objectMapper.writeValueAsString(megaphoneUseRequestDto); - String url = "/pingpong/megaphones"; - - mockMvc.perform(post(url) - .content(content) - .contentType(MediaType.APPLICATION_JSON) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().is2xxSuccessful()) - .andReturn().getResponse().getContentAsString(); - - Megaphone result = megaphoneRepository.findFirstByOrderByIdDesc(); - assertThat(result.getContent()).isEqualTo(megaphoneUseRequestDto.getContent()); - } - - @Test - @Transactional - @DisplayName("DELETE /pingpong/megaphones/{megaphoneId}") - public void deleteMegaphoneTest() throws Exception { - //given - String intraId = "intra2"; - String email = "email"; - User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, - SnsType.BOTH, RoleType.ADMIN); - String accessToken = tokenProvider.createToken(newUser.getId()); - ItemUpdateRequestDto dto = new ItemUpdateRequestDto("확성기", "default", - "default", 40, 50, ItemType.MEGAPHONE); - Item item = itemTestUtils.createItem(newUser, dto); - Receipt receipt = itemTestUtils.purchaseItem(newUser, newUser, item); - Receipt receipt2 = itemTestUtils.purchaseItem(newUser, newUser, item); - Megaphone megaphone = itemTestUtils.createMegaPhone(newUser, receipt, "test"); - Megaphone megaphone2 = itemTestUtils.createMegaPhone(newUser, receipt2, "test"); - String url = "/pingpong/megaphones/" + megaphone2.getId(); - - //when - mockMvc.perform(delete(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().is2xxSuccessful()) - .andReturn().getResponse(); - - //then - AssertionsForClassTypes.assertThat(receipt2.getStatus()).isEqualTo(ItemStatus.DELETED); - } - - @Test - @Transactional - @DisplayName("[GET] /pingpong/megaphones/receipt/{receiptId}") - void getMegaphoneDetailTest() throws Exception { - String intraId = "intra"; - String email = "email"; - User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, - SnsType.BOTH, RoleType.ADMIN); - String accessToken = tokenProvider.createToken(newUser.getId()); - ItemUpdateRequestDto dto = new ItemUpdateRequestDto("확성기", "default", - "default", 40, 50, ItemType.MEGAPHONE); - Item item = itemTestUtils.createItem(newUser, dto); - Receipt receipt = itemTestUtils.purchaseItem(newUser, newUser, item); - Megaphone megaphone = itemTestUtils.createMegaPhone(newUser, receipt, "test"); - String url = "/pingpong/megaphones/receipt/" + receipt.getId(); - - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - System.out.println(contentAsString); - } - - @Test - @Transactional - @DisplayName("[GET] /pingpong/megaphones") - void getMegaphoneTodayListTest() throws Exception { - String accessToken = testDataUtils.getLoginAccessToken(); - String url = "/pingpong/megaphones"; - mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().is2xxSuccessful()) - .andReturn().getResponse().getContentAsString(); - } -} \ No newline at end of file + @Autowired + TestDataUtils testDataUtils; + + @Autowired + private MockMvc mockMvc; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + AuthTokenProvider tokenProvider; + + @Autowired + MegaphoneRepository megaphoneRepository; + + @Autowired + ReceiptRepository receiptRepository; + + @Autowired + ItemTestUtils itemTestUtils; + + @Test + @Transactional + @DisplayName("[Post] /pingpong/megaphones") + void useMegaphoneTest() throws Exception { + // 해당 테스트는 시스템상 23:55 ~ 00:05 사이에 테스트 불가능 + if (LocalTime.now().isAfter(LocalTime.of(23, 54)) + || LocalTime.now().isBefore(LocalTime.of(0, 6))) { + return; + } + String intraId = "intra"; + String email = "email"; + User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, + SnsType.BOTH, RoleType.ADMIN); + String accessToken = tokenProvider.createToken(newUser.getId()); + // db에 저장해두고 테스트 + ItemUpdateRequestDto dto = new ItemUpdateRequestDto("확성기", "default", + "default", 40, 50, ItemType.MEGAPHONE); + Item item = itemTestUtils.createItem(newUser, dto); + Receipt receipt = itemTestUtils.purchaseItem(newUser, newUser, item); + MegaphoneUseRequestDto megaphoneUseRequestDto = new MegaphoneUseRequestDto(receipt.getId(), "test"); + String content = objectMapper.writeValueAsString(megaphoneUseRequestDto); + String url = "/pingpong/megaphones"; + + mockMvc.perform(post(url) + .content(content) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().is2xxSuccessful()) + .andReturn().getResponse().getContentAsString(); + + Megaphone result = megaphoneRepository.findFirstByOrderByIdDesc(); + assertThat(result.getContent()).isEqualTo(megaphoneUseRequestDto.getContent()); + } + + @Test + @Transactional + @DisplayName("DELETE /pingpong/megaphones/{megaphoneId}") + public void deleteMegaphoneTest() throws Exception { + //given + String intraId = "intra2"; + String email = "email"; + User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, + SnsType.BOTH, RoleType.ADMIN); + String accessToken = tokenProvider.createToken(newUser.getId()); + ItemUpdateRequestDto dto = new ItemUpdateRequestDto("확성기", "default", + "default", 40, 50, ItemType.MEGAPHONE); + Item item = itemTestUtils.createItem(newUser, dto); + Receipt receipt = itemTestUtils.purchaseItem(newUser, newUser, item); + Receipt receipt2 = itemTestUtils.purchaseItem(newUser, newUser, item); + Megaphone megaphone = itemTestUtils.createMegaPhone(newUser, receipt, "test"); + Megaphone megaphone2 = itemTestUtils.createMegaPhone(newUser, receipt2, "test"); + String url = "/pingpong/megaphones/" + megaphone2.getId(); + + //when + mockMvc.perform(delete(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().is2xxSuccessful()) + .andReturn().getResponse(); + + //then + AssertionsForClassTypes.assertThat(receipt2.getStatus()).isEqualTo(ItemStatus.DELETED); + } + + @Test + @Transactional + @DisplayName("[GET] /pingpong/megaphones/receipt/{receiptId}") + void getMegaphoneDetailTest() throws Exception { + String intraId = "intra"; + String email = "email"; + User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, + SnsType.BOTH, RoleType.ADMIN); + String accessToken = tokenProvider.createToken(newUser.getId()); + ItemUpdateRequestDto dto = new ItemUpdateRequestDto("확성기", "default", + "default", 40, 50, ItemType.MEGAPHONE); + Item item = itemTestUtils.createItem(newUser, dto); + Receipt receipt = itemTestUtils.purchaseItem(newUser, newUser, item); + Megaphone megaphone = itemTestUtils.createMegaPhone(newUser, receipt, "test"); + String url = "/pingpong/megaphones/receipt/" + receipt.getId(); + + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @Transactional + @DisplayName("[GET] /pingpong/megaphones") + void getMegaphoneTodayListTest() throws Exception { + String accessToken = testDataUtils.getLoginAccessToken(); + String url = "/pingpong/megaphones"; + mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().is2xxSuccessful()) + .andReturn().getResponse().getContentAsString(); + } +} diff --git a/src/test/java/com/gg/server/domain/noti/controller/NotiControllerTest.java b/src/test/java/com/gg/server/domain/noti/controller/NotiControllerTest.java index e7c77ba95..80d539795 100644 --- a/src/test/java/com/gg/server/domain/noti/controller/NotiControllerTest.java +++ b/src/test/java/com/gg/server/domain/noti/controller/NotiControllerTest.java @@ -1,125 +1,127 @@ -package com.gg.server.domain.noti.controller; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.noti.data.Noti; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.noti.dto.NotiListResponseDto; -import com.gg.server.domain.noti.service.NotiService; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import lombok.RequiredArgsConstructor; -import org.apache.http.HttpHeaders; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.test.web.servlet.MockMvc; - -import javax.transaction.Transactional; - -import java.util.List; - -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@RequiredArgsConstructor -@IntegrationTest -@AutoConfigureMockMvc -@Transactional -class NotiControllerTest { - - @Autowired - TestDataUtils testDataUtils; - @Autowired - AuthTokenProvider tokenProvider; - @Autowired - UserRepository userRepository; - @Autowired - NotiRepository notiRepository; - @Autowired - private NotiService notiService; - @Autowired - private MockMvc mockMvc; - @Autowired - private ObjectMapper objectMapper; - - @Test - @DisplayName("GET /pingpong/notifications") - @Transactional - public void NotiFindByUserTest() throws Exception { - //given - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - String url = "/pingpong/notifications"; - - UserDto userDto = UserDto.from(userRepository.getById(userId)); - NotiListResponseDto expectedResponse = new NotiListResponseDto(notiService.findNotiByUser(userDto)); - //when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - NotiListResponseDto actureResponse= objectMapper.readValue(contentAsString, NotiListResponseDto.class); - - //then - assertThat(actureResponse).isEqualTo(expectedResponse); - } - - @Test - @DisplayName("PUT /pingpong/notifications/check") - @Transactional - public void checkNotiByUserTest() throws Exception{ - //given - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - String url = "/pingpong/notifications/check"; - User user = userRepository.findById(userId).get(); - - notiRepository.save(new Noti(user, NotiType.ANNOUNCE, "announce", false)); - notiRepository.save(new Noti(user, NotiType.MATCHED, "matched", false)); - notiRepository.save(new Noti(user, NotiType.IMMINENT, "imminent", true)); - notiRepository.save(new Noti(user, NotiType.CANCELEDBYMAN, "canceledbyman", false)); - notiRepository.save(new Noti(user, NotiType.CANCELEDBYTIME, "canceledbytime", false)); - //when - String contentAsString = mockMvc.perform(put(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().is2xxSuccessful()) - .andReturn().getResponse().getContentAsString(); - - //then - List notiList = notiRepository.findByUser(user); - for (Noti noti : notiList) { - assertThat(noti.getIsChecked()).isTrue(); - } - } - - @Test - @DisplayName("DELETE /notifications") - @Transactional - public void notiRemoveAll() throws Exception { - //given - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - String url = "/pingpong/notifications"; - User user = userRepository.findById(userId).get(); - - notiRepository.save(new Noti(user, NotiType.ANNOUNCE, "announce", false)); - notiRepository.save(new Noti(user, NotiType.MATCHED, "matched", false)); - notiRepository.save(new Noti(user, NotiType.IMMINENT, "imminent", true)); - notiRepository.save(new Noti(user, NotiType.CANCELEDBYMAN, "canceledbyman", false)); - notiRepository.save(new Noti(user, NotiType.CANCELEDBYTIME, "canceledbytime", false)); - - //when - String contentAsString = mockMvc.perform(delete(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().is2xxSuccessful()) - .andReturn().getResponse().getContentAsString(); - - //then - List notiList = notiRepository.findByUser(user); - assertThat(notiList.size()).isEqualTo(0); - } -} \ No newline at end of file +package com.gg.server.domain.noti.controller; + +import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.util.List; + +import javax.transaction.Transactional; + +import org.apache.http.HttpHeaders; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.test.web.servlet.MockMvc; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.domain.noti.data.Noti; +import com.gg.server.domain.noti.data.NotiRepository; +import com.gg.server.domain.noti.dto.NotiListResponseDto; +import com.gg.server.domain.noti.service.NotiService; +import com.gg.server.domain.noti.type.NotiType; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@IntegrationTest +@AutoConfigureMockMvc +@Transactional +class NotiControllerTest { + + @Autowired + TestDataUtils testDataUtils; + @Autowired + AuthTokenProvider tokenProvider; + @Autowired + UserRepository userRepository; + @Autowired + NotiRepository notiRepository; + @Autowired + private NotiService notiService; + @Autowired + private MockMvc mockMvc; + @Autowired + private ObjectMapper objectMapper; + + @Test + @DisplayName("GET /pingpong/notifications") + @Transactional + public void notiFindByUserTest() throws Exception { + //given + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + String url = "/pingpong/notifications"; + + UserDto userDto = UserDto.from(userRepository.getById(userId)); + NotiListResponseDto expectedResponse = new NotiListResponseDto(notiService.findNotiByUser(userDto)); + //when + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + NotiListResponseDto actureResponse = objectMapper.readValue(contentAsString, NotiListResponseDto.class); + + //then + assertThat(actureResponse).isEqualTo(expectedResponse); + } + + @Test + @DisplayName("PUT /pingpong/notifications/check") + @Transactional + public void checkNotiByUserTest() throws Exception { + //given + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + String url = "/pingpong/notifications/check"; + User user = userRepository.findById(userId).get(); + + notiRepository.save(new Noti(user, NotiType.ANNOUNCE, "announce", false)); + notiRepository.save(new Noti(user, NotiType.MATCHED, "matched", false)); + notiRepository.save(new Noti(user, NotiType.IMMINENT, "imminent", true)); + notiRepository.save(new Noti(user, NotiType.CANCELEDBYMAN, "canceledbyman", false)); + notiRepository.save(new Noti(user, NotiType.CANCELEDBYTIME, "canceledbytime", false)); + //when + String contentAsString = mockMvc.perform(put(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().is2xxSuccessful()) + .andReturn().getResponse().getContentAsString(); + + //then + List notiList = notiRepository.findByUser(user); + for (Noti noti : notiList) { + assertThat(noti.getIsChecked()).isTrue(); + } + } + + @Test + @DisplayName("DELETE /notifications") + @Transactional + public void notiRemoveAll() throws Exception { + //given + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + String url = "/pingpong/notifications"; + User user = userRepository.findById(userId).get(); + + notiRepository.save(new Noti(user, NotiType.ANNOUNCE, "announce", false)); + notiRepository.save(new Noti(user, NotiType.MATCHED, "matched", false)); + notiRepository.save(new Noti(user, NotiType.IMMINENT, "imminent", true)); + notiRepository.save(new Noti(user, NotiType.CANCELEDBYMAN, "canceledbyman", false)); + notiRepository.save(new Noti(user, NotiType.CANCELEDBYTIME, "canceledbytime", false)); + + //when + String contentAsString = mockMvc.perform(delete(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().is2xxSuccessful()) + .andReturn().getResponse().getContentAsString(); + + //then + List notiList = notiRepository.findByUser(user); + assertThat(notiList.size()).isEqualTo(0); + } +} diff --git a/src/test/java/com/gg/server/domain/noti/service/NotiServiceTest.java b/src/test/java/com/gg/server/domain/noti/service/NotiServiceTest.java index a4fe14141..3bca32208 100644 --- a/src/test/java/com/gg/server/domain/noti/service/NotiServiceTest.java +++ b/src/test/java/com/gg/server/domain/noti/service/NotiServiceTest.java @@ -1,73 +1,75 @@ -package com.gg.server.domain.noti.service; - -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.noti.data.Noti; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import javax.transaction.Transactional; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.List; - -@RequiredArgsConstructor -@IntegrationTest -@Slf4j -class NotiServiceTest { - - @Autowired - TestDataUtils testDataUtils; - @Autowired - AuthTokenProvider tokenProvider; - @Autowired - NotiService notiService; - @Autowired - NotiRepository notiRepository; - @Autowired - UserRepository userRepository; - - @Test - @DisplayName("NotiService 유저매칭알림 전송 테스트") - @Transactional - public void 유저매칭알림전송테스트() throws Exception { - //given - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.getById(userId); - UserDto userDto = UserDto.from(user); - LocalDateTime now = LocalDateTime.now(); - String expectedMatchedNotiMessage = now.format(DateTimeFormatter.ofPattern("HH:mm")) + "에 신청한 매칭이 성사되었습니다."; - String expectedMatchCancelNotiMessage = now.format(DateTimeFormatter.ofPattern("HH:mm")) + "에 신청한 매칭이 상대에 의해 취소되었습니다."; - - //when - notiService.createMatched(user, now); - notiService.createMatchCancel(user, now); - List actureNotiList = notiRepository.findAllByUser(user); - - //then - Assertions.assertThat(actureNotiList.size()).isEqualTo(2); - for (Noti noti: actureNotiList) { - if (noti.getType() == NotiType.MATCHED) { - Assertions.assertThat(noti.getMessage()).isEqualTo(expectedMatchedNotiMessage); - log.info("Matched Message : " + noti.getMessage()); - } - else if (noti.getType() == NotiType.CANCELEDBYMAN) { - Assertions.assertThat(noti.getMessage()).isEqualTo(expectedMatchCancelNotiMessage); - log.info("MatchCancel Message : " + noti.getMessage()); - } - Assertions.assertThat(noti.getIsChecked()).isFalse(); - } - } -} +package com.gg.server.domain.noti.service; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; + +import javax.transaction.Transactional; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import com.gg.server.domain.noti.data.Noti; +import com.gg.server.domain.noti.data.NotiRepository; +import com.gg.server.domain.noti.type.NotiType; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +@RequiredArgsConstructor +@IntegrationTest +@Slf4j +class NotiServiceTest { + + @Autowired + TestDataUtils testDataUtils; + @Autowired + AuthTokenProvider tokenProvider; + @Autowired + NotiService notiService; + @Autowired + NotiRepository notiRepository; + @Autowired + UserRepository userRepository; + + @Test + @DisplayName("NotiService 유저매칭알림 전송 테스트") + @Transactional + public void userMatingNotSend() throws Exception { + //given + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.getById(userId); + UserDto userDto = UserDto.from(user); + LocalDateTime now = LocalDateTime.now(); + String expectedMatchedNotiMessage = now.format(DateTimeFormatter.ofPattern("HH:mm")) + "에 신청한 매칭이 성사되었습니다."; + String expectedMatchCancelNotiMessage = + now.format(DateTimeFormatter.ofPattern("HH:mm")) + "에 신청한 매칭이 상대에 의해 취소되었습니다."; + + //when + notiService.createMatched(user, now); + notiService.createMatchCancel(user, now); + List actureNotiList = notiRepository.findAllByUser(user); + + //then + Assertions.assertThat(actureNotiList.size()).isEqualTo(2); + for (Noti noti : actureNotiList) { + if (noti.getType() == NotiType.MATCHED) { + Assertions.assertThat(noti.getMessage()).isEqualTo(expectedMatchedNotiMessage); + log.info("Matched Message : " + noti.getMessage()); + } else if (noti.getType() == NotiType.CANCELEDBYMAN) { + Assertions.assertThat(noti.getMessage()).isEqualTo(expectedMatchCancelNotiMessage); + log.info("MatchCancel Message : " + noti.getMessage()); + } + Assertions.assertThat(noti.getIsChecked()).isFalse(); + } + } +} diff --git a/src/test/java/com/gg/server/domain/rank/controller/RankControllerTest.java b/src/test/java/com/gg/server/domain/rank/controller/RankControllerTest.java index 82bb54931..b8500f4ac 100644 --- a/src/test/java/com/gg/server/domain/rank/controller/RankControllerTest.java +++ b/src/test/java/com/gg/server/domain/rank/controller/RankControllerTest.java @@ -1,167 +1,164 @@ -package com.gg.server.domain.rank.controller; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; -import com.gg.server.domain.rank.dto.RankDto; -import com.gg.server.domain.rank.dto.RankPageResponseDto; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.service.RedisUploadService; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.user.data.User; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import org.apache.http.HttpHeaders; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Comparator; -import java.util.List; - - -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - - -@IntegrationTest -@Transactional -@AutoConfigureMockMvc -class RankControllerTest { - - @Autowired - TestDataUtils testDataUtils; - - @Autowired - MockMvc mockMvc; - @Autowired - ObjectMapper objectMapper; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - SeasonRepository seasonRepository; - - @Autowired - RankRedisRepository redisRepository; - - @Autowired - RedisUploadService redisUploadService; - - @BeforeEach - public void flushRedis(){ - redisRepository.deleteAll(); - testDataUtils.createTierSystem("pingpong"); - } - - @AfterEach - public void flushRedisAfter(){ - redisRepository.deleteAll(); - } - - @Test - @DisplayName("/exp") - void getExpRankPage() throws Exception { - - // given - Season season = testDataUtils.createSeason(); - int myTotalExp = 1000; - User myUser = testDataUtils.createNewUser(myTotalExp); - testDataUtils.createUserRank(myUser, "1", season); - - int otherTotalExp = 2000; - User user1 = testDataUtils.createNewUser(otherTotalExp); - testDataUtils.createUserRank(user1, "2", season); - int otherTotalExp2 = 3000; - User user2 = testDataUtils.createNewUser(otherTotalExp2); - testDataUtils.createUserRank(user2, "3", season); - int otherTotalExp3 = 4000; - User user3 = testDataUtils.createNewUser(otherTotalExp3); - testDataUtils.createUserRank(user3, "4", season); - - int page = 1; - int size = 3; - String url = "/pingpong/exp?page=" + page + "&size=" + size; - String accessToken = tokenProvider.createToken(myUser.getId()); - - //when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - ExpRankPageResponseDto response = objectMapper.readValue(contentAsString, ExpRankPageResponseDto.class); - - //then - Assertions.assertThat(response.getMyRank()).isEqualTo(4); - Assertions.assertThat(response.getCurrentPage()).isEqualTo(page); - Assertions.assertThat(response.getTotalPage()).isEqualTo(2); - Assertions.assertThat(response.getRankList().size()).isEqualTo(3); - } - - @Test - @DisplayName("/pingpong/ranks/{gameType}") - public void getRankPage () throws Exception - { - //given - Season season = testDataUtils.createSeason(); - User myUser = testDataUtils.createNewUser(); - testDataUtils.createUserRank(myUser, "1", season, 1000); - - User user2 = testDataUtils.createNewUser(); - testDataUtils.createUserRank(user2, "2", season, 1500); - - User user3 = testDataUtils.createNewUser(); - testDataUtils.createUserRank(user3, "3", season, 2000); - - User user4 = testDataUtils.createNewUser(); - testDataUtils.createUserRank(user4, "4", season, 2500); - - User user5 = testDataUtils.createNewUser(); - testDataUtils.createUserRank(user5, "5", season, 3000); - - User user6 = testDataUtils.createNewUser(); - testDataUtils.createUserRank(user6, "6", season, 3500); - - User user7 = testDataUtils.createNewUser(); - testDataUtils.createUserRank(user7, "7", season, 4000); - - User user8 = testDataUtils.createNewUser(); - testDataUtils.createUserRank(user8, "8", season, 4500); - - User user9 = testDataUtils.createNewUser(); - testDataUtils.createUserRank(user9, "9", season, 5000); - - User user10 = testDataUtils.createNewUser(); - testDataUtils.createUserRank(user10, "10", season, 5500); - - String accessToken = tokenProvider.createToken(myUser.getId()); - - int page = 4; - int size = 3; - String url = "/pingpong/ranks/single?page=" + page + "&size=" + size; - - //when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - RankPageResponseDto resp = objectMapper.readValue(contentAsString, RankPageResponseDto.class); - - //then - List rankList = resp.getRankList(); - Assertions.assertThat(resp.getCurrentPage()).isEqualTo(4); - Assertions.assertThat(resp.getTotalPage()).isEqualTo(4); - Assertions.assertThat(resp.getMyRank()).isEqualTo(10); - Assertions.assertThat(rankList.size()).isEqualTo(1); - Assertions.assertThat(rankList).isSortedAccordingTo(Comparator.comparing(RankDto::getPpp).reversed()); - } - - -} \ No newline at end of file +package com.gg.server.domain.rank.controller; + +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.util.Comparator; +import java.util.List; + +import org.apache.http.HttpHeaders; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; +import com.gg.server.domain.rank.dto.RankDto; +import com.gg.server.domain.rank.dto.RankPageResponseDto; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.rank.service.RedisUploadService; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.data.SeasonRepository; +import com.gg.server.domain.user.data.User; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +@IntegrationTest +@Transactional +@AutoConfigureMockMvc +class RankControllerTest { + + @Autowired + TestDataUtils testDataUtils; + + @Autowired + MockMvc mockMvc; + @Autowired + ObjectMapper objectMapper; + + @Autowired + AuthTokenProvider tokenProvider; + + @Autowired + SeasonRepository seasonRepository; + + @Autowired + RankRedisRepository redisRepository; + + @Autowired + RedisUploadService redisUploadService; + + @BeforeEach + public void flushRedis() { + redisRepository.deleteAll(); + testDataUtils.createTierSystem("pingpong"); + } + + @AfterEach + public void flushRedisAfter() { + redisRepository.deleteAll(); + } + + @Test + @DisplayName("/exp") + void getExpRankPage() throws Exception { + + // given + Season season = testDataUtils.createSeason(); + int myTotalExp = 1000; + User myUser = testDataUtils.createNewUser(myTotalExp); + testDataUtils.createUserRank(myUser, "1", season); + + int otherTotalExp = 2000; + User user1 = testDataUtils.createNewUser(otherTotalExp); + testDataUtils.createUserRank(user1, "2", season); + int otherTotalExp2 = 3000; + User user2 = testDataUtils.createNewUser(otherTotalExp2); + testDataUtils.createUserRank(user2, "3", season); + int otherTotalExp3 = 4000; + User user3 = testDataUtils.createNewUser(otherTotalExp3); + testDataUtils.createUserRank(user3, "4", season); + + int page = 1; + int size = 3; + String url = "/pingpong/exp?page=" + page + "&size=" + size; + String accessToken = tokenProvider.createToken(myUser.getId()); + + //when + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + ExpRankPageResponseDto response = objectMapper.readValue(contentAsString, ExpRankPageResponseDto.class); + + //then + Assertions.assertThat(response.getMyRank()).isEqualTo(4); + Assertions.assertThat(response.getCurrentPage()).isEqualTo(page); + Assertions.assertThat(response.getTotalPage()).isEqualTo(2); + Assertions.assertThat(response.getRankList().size()).isEqualTo(3); + } + + @Test + @DisplayName("/pingpong/ranks/{gameType}") + public void getRankPage() throws Exception { + //given + Season season = testDataUtils.createSeason(); + User myUser = testDataUtils.createNewUser(); + testDataUtils.createUserRank(myUser, "1", season, 1000); + + User user2 = testDataUtils.createNewUser(); + testDataUtils.createUserRank(user2, "2", season, 1500); + + User user3 = testDataUtils.createNewUser(); + testDataUtils.createUserRank(user3, "3", season, 2000); + + User user4 = testDataUtils.createNewUser(); + testDataUtils.createUserRank(user4, "4", season, 2500); + + User user5 = testDataUtils.createNewUser(); + testDataUtils.createUserRank(user5, "5", season, 3000); + + User user6 = testDataUtils.createNewUser(); + testDataUtils.createUserRank(user6, "6", season, 3500); + + User user7 = testDataUtils.createNewUser(); + testDataUtils.createUserRank(user7, "7", season, 4000); + + User user8 = testDataUtils.createNewUser(); + testDataUtils.createUserRank(user8, "8", season, 4500); + + User user9 = testDataUtils.createNewUser(); + testDataUtils.createUserRank(user9, "9", season, 5000); + + User user10 = testDataUtils.createNewUser(); + testDataUtils.createUserRank(user10, "10", season, 5500); + + String accessToken = tokenProvider.createToken(myUser.getId()); + + int page = 4; + int size = 3; + String url = "/pingpong/ranks/single?page=" + page + "&size=" + size; + + //when + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + RankPageResponseDto resp = objectMapper.readValue(contentAsString, RankPageResponseDto.class); + + //then + List rankList = resp.getRankList(); + Assertions.assertThat(resp.getCurrentPage()).isEqualTo(4); + Assertions.assertThat(resp.getTotalPage()).isEqualTo(4); + Assertions.assertThat(resp.getMyRank()).isEqualTo(10); + Assertions.assertThat(rankList.size()).isEqualTo(1); + Assertions.assertThat(rankList).isSortedAccordingTo(Comparator.comparing(RankDto::getPpp).reversed()); + } + +} diff --git a/src/test/java/com/gg/server/domain/rank/controller/RankV2ControllerTest.java b/src/test/java/com/gg/server/domain/rank/controller/RankV2ControllerTest.java index d961dfa1e..2bd4ab106 100644 --- a/src/test/java/com/gg/server/domain/rank/controller/RankV2ControllerTest.java +++ b/src/test/java/com/gg/server/domain/rank/controller/RankV2ControllerTest.java @@ -1,18 +1,12 @@ package com.gg.server.domain.rank.controller; -import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; -import com.gg.server.domain.rank.dto.RankPageResponseDto; -import com.gg.server.domain.rank.service.RankService; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.config.WebConfig; -import com.gg.server.global.security.config.SecurityConfig; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.global.security.jwt.utils.TokenAuthenticationFilter; -import com.gg.server.global.utils.querytracker.LoggingInterceptor; +import static org.mockito.BDDMockito.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + import java.util.ArrayList; import java.util.Optional; + import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; @@ -24,70 +18,79 @@ import org.springframework.data.domain.PageRequest; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.servlet.MockMvc; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import static org.mockito.BDDMockito.*; + +import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; +import com.gg.server.domain.rank.dto.RankPageResponseDto; +import com.gg.server.domain.rank.service.RankService; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.config.WebConfig; +import com.gg.server.global.security.config.SecurityConfig; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.global.security.jwt.utils.TokenAuthenticationFilter; +import com.gg.server.global.utils.querytracker.LoggingInterceptor; @WebMvcTest(value = RankV2Controller.class, - excludeFilters = { - @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = SecurityConfig.class), - @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = WebConfig.class), - @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = TokenAuthenticationFilter.class), - @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = LoggingInterceptor.class) - } + excludeFilters = { + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = SecurityConfig.class), + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = WebConfig.class), + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = TokenAuthenticationFilter.class), + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = LoggingInterceptor.class) + } ) @ExtendWith(MockitoExtension.class) class RankV2ControllerTest { - @Autowired - private MockMvc mockMvc; - @MockBean - private RankService rankService; - @MockBean - private UserRepository userRepository; - @MockBean - private AuthTokenProvider authTokenProvider; + @Autowired + private MockMvc mockMvc; + @MockBean + private RankService rankService; + @MockBean + private UserRepository userRepository; + @MockBean + private AuthTokenProvider authTokenProvider; - @Test - @WithMockUser(username = "TestUser") - void getExpRankPage() throws Exception { - given(userRepository.findById(0L)) - .willReturn(Optional.of(User.builder().intraId("TestUser").build())); - given(rankService.getExpRankPage(PageRequest.of(1, 10), - UserDto - .builder() - .intraId("TestUser") - .id(1L) - .build()) - ).willReturn(new ExpRankPageResponseDto( - -1, - 1, - 1, - new ArrayList<>() - )); - mockMvc.perform(get("/pingpong/v2/exp") - .queryParam("size", "10") - .queryParam("page", "1")) - .andExpect(status().isOk()); - } + @Test + @WithMockUser(username = "TestUser") + void getExpRankPage() throws Exception { + given(userRepository.findById(0L)) + .willReturn(Optional.of(User.builder().intraId("TestUser").build())); + given(rankService.getExpRankPage(PageRequest.of(1, 10), + UserDto + .builder() + .intraId("TestUser") + .id(1L) + .build()) + ).willReturn(new ExpRankPageResponseDto( + -1, + 1, + 1, + new ArrayList<>() + )); + mockMvc.perform(get("/pingpong/v2/exp") + .queryParam("size", "10") + .queryParam("page", "1")) + .andExpect(status().isOk()); + } - @Test - @WithMockUser(username = "TestUser") - void getRankPage() throws Exception{ - given(userRepository.findById(0L)) - .willReturn(Optional.of(User.builder().intraId("TestUser").build())); - given(rankService.getRankPageV2(PageRequest.of(1, 10), - UserDto - .builder() - .intraId("TestUser") - .id(1L) - .build(), 1L) - ).willReturn(new RankPageResponseDto(-1, 1, 1, new ArrayList<>())); - mockMvc.perform(get("/pingpong/v2/ranks/single") - .queryParam("size", "10") - .queryParam("page", "1") - .queryParam("season", "1")) - .andExpect(status().isOk()); + @Test + @WithMockUser(username = "TestUser") + void getRankPage() throws Exception { + given(userRepository.findById(0L)) + .willReturn(Optional.of(User.builder().intraId("TestUser").build())); + given(rankService.getRankPageV2(PageRequest.of(1, 10), + UserDto + .builder() + .intraId("TestUser") + .id(1L) + .build(), 1L) + ).willReturn(new RankPageResponseDto(-1, 1, 1, new ArrayList<>())); + mockMvc.perform(get("/pingpong/v2/ranks/single") + .queryParam("size", "10") + .queryParam("page", "1") + .queryParam("season", "1")) + .andExpect(status().isOk()); - } -} \ No newline at end of file + } +} diff --git a/src/test/java/com/gg/server/domain/rank/redis/RankRedisRepositoryTest.java b/src/test/java/com/gg/server/domain/rank/redis/RankRedisRepositoryTest.java index e360f693c..04df8e200 100644 --- a/src/test/java/com/gg/server/domain/rank/redis/RankRedisRepositoryTest.java +++ b/src/test/java/com/gg/server/domain/rank/redis/RankRedisRepositoryTest.java @@ -1,275 +1,277 @@ package com.gg.server.domain.rank.redis; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.rank.exception.RedisDataNotFoundException; +import java.util.List; + import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import java.util.List; +import com.gg.server.domain.rank.exception.RedisDataNotFoundException; +import com.gg.server.utils.annotation.IntegrationTest; @IntegrationTest class RankRedisRepositoryTest { - - @Autowired - RankRedisRepository redisRepository; - - static String zSetKey = "test:ZSet"; - static String hashKey = "test:hash"; - - @AfterEach - void deleteAll(){ - redisRepository.deleteZSetKey(zSetKey); - redisRepository.deleteHashKey(hashKey); - } - - @Test - void addToZSet() { - //given - Long userId = 1L; - int ppp = 100; - - //when - redisRepository.addToZSet(zSetKey, userId, ppp); - - //then - Long scoreInZSet = redisRepository.getScoreInZSet(zSetKey, userId); - Assertions.assertThat(scoreInZSet).isEqualTo(ppp); - } - - @Test - void incrementScoreInZSet() { - //given - Long userId = 1L; - int ppp = 100; - int incrementPpp = 50; - redisRepository.addToZSet(zSetKey, userId, ppp); - - //when - redisRepository.incrementScoreInZSet(zSetKey, userId, incrementPpp); - - //then - Long scoreInZSet = redisRepository.getScoreInZSet(zSetKey, userId); - Assertions.assertThat(scoreInZSet).isEqualTo(ppp + incrementPpp); - } - - @Test - void decrementScoreInZSet() { - //given - Long userId = 1L; - int ppp = 100; - int decrementPpp = 50; - redisRepository.addToZSet(zSetKey, userId, ppp); - - //when - redisRepository.decrementScoreInZSet(zSetKey, userId, decrementPpp); - - //then - Long scoreInZSet = redisRepository.getScoreInZSet(zSetKey, userId); - Assertions.assertThat(scoreInZSet).isEqualTo(ppp - decrementPpp); - } - - - @Test - void add(){ - Long userId = 1L; - Long userId2 = 2L; - Long userId3 = 3L; - int ppp = 100; - int ppp2 = 200; - int ppp3 = 300; - redisRepository.addToZSet(zSetKey, userId, ppp); - redisRepository.addToZSet(zSetKey, userId2, ppp2); - redisRepository.addToZSet(zSetKey, userId3, ppp3); - } - - @Test - void getRankInZSet() { -// given - Long userId = 1L; - Long userId2 = 2L; - Long userId3 = 3L; - int ppp = 100; - int ppp2 = 200; - int ppp3 = 300; - redisRepository.addToZSet(zSetKey, userId, ppp); - redisRepository.addToZSet(zSetKey, userId2, ppp2); - redisRepository.addToZSet(zSetKey, userId3, ppp3); - - //when - Long rankInZSet = redisRepository.getRankInZSet(zSetKey, userId); - - //then - Assertions.assertThat(rankInZSet).isEqualTo(2); - } - - @Test - void getScoreInZSet() { - //given - Long userId = 1L; - int ppp = 100; - redisRepository.addToZSet(zSetKey, userId, ppp); - - //when - Long scoreInZSet = redisRepository.getScoreInZSet(zSetKey, userId); - - //then - Assertions.assertThat(scoreInZSet).isEqualTo(ppp); - } - - @Test - public void getUserIdsByRange () throws Exception { - //given - Long userId = 1L; - Long userId2 = 2L; - Long userId3 = 3L; - int ppp = 100; - int ppp2 = 200; - int ppp3 = 300; - redisRepository.addToZSet(zSetKey, userId, ppp); - redisRepository.addToZSet(zSetKey, userId2, ppp2); - redisRepository.addToZSet(zSetKey, userId3, ppp3); - - //when - List userIdsSorted = redisRepository.getUserIdsByRangeFromZSet(zSetKey, 0, 1); - - //then - Assertions.assertThat(userIdsSorted).containsExactly(userId3, userId2); - Assertions.assertThat(userIdsSorted.get(0)).isEqualTo(userId3); - Assertions.assertThat(userIdsSorted.get(1)).isEqualTo(userId2); - } - - @Test - @DisplayName("ZSet에서 유저 삭제") - public void deleteZSetTest () throws Exception - { - //given - Long userId = 1L; - int ppp = 100; - redisRepository.addToZSet(zSetKey, userId, ppp); - - //when - redisRepository.deleteFromZSet(zSetKey, userId); - - //then - Assertions.assertThatThrownBy(()->{ - redisRepository.getRankInZSet(zSetKey, userId); - }).isInstanceOf(RedisDataNotFoundException.class); - } - - - @Test - @DisplayName("Redis에 랭킹 데이터를 추가, 검색한다.") - public void rankCreateSearch () throws Exception - { - //given - Long userId = 1L; - int ppp = 100; - int win = 3; - int lose = 4; - String statusMessage = "statusMessage"; - RankRedis ranking = new RankRedis(userId, "aa", ppp, win, lose, statusMessage, "https://42gg-public-test-image.s3.ap-northeast-2.amazonaws.com/tier/hand.svg", "#000000"); - - //when - redisRepository.addRankData(hashKey, userId, ranking); - RankRedis findRanking = redisRepository.findRankByUserId(hashKey, userId); - - //then - Assertions.assertThat(findRanking.getUserId()).isEqualTo(userId); - Assertions.assertThat(findRanking.getPpp()).isEqualTo(ppp); - Assertions.assertThat(findRanking.getWins()).isEqualTo(win); - Assertions.assertThat(findRanking.getLosses()).isEqualTo(lose); - Assertions.assertThat(findRanking.getStatusMessage()).isEqualTo(statusMessage); - } - - @Test - @DisplayName("user rank정보 업데이트") - public void updateRank () throws Exception - { - //given - Long userId = 1L; - int ppp = 100; - int win = 3; - int lose = 4; - String statusMessage = "statusMessage"; - RankRedis ranking = new RankRedis(userId, "aa", ppp, win, lose, statusMessage, "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); - redisRepository.addRankData(hashKey, userId, ranking); - - //when - int newPpp = 200; - int newWin = 4; - int newLose = 5; - String newStatusMessage = "newStatusMessage"; - RankRedis newRanking = new RankRedis(userId, "aa", newPpp, newWin, newLose, newStatusMessage, "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); - - redisRepository.updateRankData(hashKey, userId, newRanking); - //then - RankRedis findRanking = redisRepository.findRankByUserId(hashKey, userId); - Assertions.assertThat(findRanking.getUserId()).isEqualTo(userId); - Assertions.assertThat(findRanking.getPpp()).isEqualTo(newPpp); - Assertions.assertThat(findRanking.getWins()).isEqualTo(newWin); - Assertions.assertThat(findRanking.getLosses()).isEqualTo(newLose); - Assertions.assertThat(findRanking.getStatusMessage()).isEqualTo(newStatusMessage); - } - - @Test - @DisplayName("유저 랭크를 삭제한다") - public void deleteUserRank () throws Exception - { - //given - Long userId = 3L; - int ppp = 100; - int win = 3; - int lose = 4; - String statusMessage = "statusMessage"; - RankRedis ranking = new RankRedis(userId, "aa", ppp, win, lose, statusMessage, "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); - redisRepository.addRankData(hashKey, userId, ranking); - - //when - redisRepository.deleteRankData(hashKey, userId); - - //then - Assertions.assertThatThrownBy(() -> { - redisRepository.findRankByUserId(hashKey, userId); - }).isInstanceOf(RedisDataNotFoundException.class); - } - - @Test - void findRanksByUserIds() { - //given - Long userId = 1L; - Long userId2 = 2L; - Long userId3 = 3L; - Long userId4 = 4L; - int ppp = 100; - int ppp2 = 200; - int ppp3 = 300; - int ppp4 = 400; - - RankRedis rank1 = new RankRedis(userId, "aa", ppp, 0, 0, "statusMessage", "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); - RankRedis rank2 = new RankRedis(userId2,"aa", ppp2, 0, 0, "statusMessage", "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); - RankRedis rank3 = new RankRedis(userId3, "aa", ppp3, 0, 0, "statusMessage", "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); - RankRedis rank4 = new RankRedis(userId4, "aa", ppp4, 0, 0, "statusMessage", "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); - redisRepository.addRankData(hashKey, userId, rank1); - redisRepository.addRankData(hashKey, userId2, rank2); - redisRepository.addRankData(hashKey, userId3, rank3); - redisRepository.addRankData(hashKey, userId4, rank4); - redisRepository.addToZSet(zSetKey, userId, ppp); - redisRepository.addToZSet(zSetKey, userId2, ppp2); - redisRepository.addToZSet(zSetKey, userId3, ppp3); - redisRepository.addToZSet(zSetKey, userId4, ppp4); - - //when - List sortedUserIds = redisRepository.getUserIdsByRangeFromZSet(zSetKey, 0, 3); - List ranks = redisRepository.findRanksByUserIds(hashKey, sortedUserIds); - - //then -> 랭크 순서도 알맞게 반환되는지 확인 - Assertions.assertThat(ranks) - .usingElementComparatorIgnoringFields("userId") - .containsExactly(rank4, rank3, rank2, rank1); - } - -} \ No newline at end of file + @Autowired + RankRedisRepository redisRepository; + + static String zSetKey = "test:ZSet"; + static String hashKey = "test:hash"; + + @AfterEach + void deleteAll() { + redisRepository.deleteZSetKey(zSetKey); + redisRepository.deleteHashKey(hashKey); + } + + @Test + void addToZSet() { + //given + Long userId = 1L; + int ppp = 100; + + //when + redisRepository.addToZSet(zSetKey, userId, ppp); + + //then + Long scoreInZSet = redisRepository.getScoreInZSet(zSetKey, userId); + Assertions.assertThat(scoreInZSet).isEqualTo(ppp); + } + + @Test + void incrementScoreInZSet() { + //given + Long userId = 1L; + int ppp = 100; + int incrementPpp = 50; + redisRepository.addToZSet(zSetKey, userId, ppp); + + //when + redisRepository.incrementScoreInZSet(zSetKey, userId, incrementPpp); + + //then + Long scoreInZSet = redisRepository.getScoreInZSet(zSetKey, userId); + Assertions.assertThat(scoreInZSet).isEqualTo(ppp + incrementPpp); + } + + @Test + void decrementScoreInZSet() { + //given + Long userId = 1L; + int ppp = 100; + int decrementPpp = 50; + redisRepository.addToZSet(zSetKey, userId, ppp); + + //when + redisRepository.decrementScoreInZSet(zSetKey, userId, decrementPpp); + + //then + Long scoreInZSet = redisRepository.getScoreInZSet(zSetKey, userId); + Assertions.assertThat(scoreInZSet).isEqualTo(ppp - decrementPpp); + } + + @Test + void add() { + Long userId = 1L; + Long userId2 = 2L; + Long userId3 = 3L; + int ppp = 100; + int ppp2 = 200; + int ppp3 = 300; + redisRepository.addToZSet(zSetKey, userId, ppp); + redisRepository.addToZSet(zSetKey, userId2, ppp2); + redisRepository.addToZSet(zSetKey, userId3, ppp3); + } + + @Test + void getRankInZSet() { + // given + Long userId = 1L; + Long userId2 = 2L; + Long userId3 = 3L; + int ppp = 100; + int ppp2 = 200; + int ppp3 = 300; + redisRepository.addToZSet(zSetKey, userId, ppp); + redisRepository.addToZSet(zSetKey, userId2, ppp2); + redisRepository.addToZSet(zSetKey, userId3, ppp3); + + //when + Long rankInZSet = redisRepository.getRankInZSet(zSetKey, userId); + + //then + Assertions.assertThat(rankInZSet).isEqualTo(2); + } + + @Test + void getScoreInZSet() { + //given + Long userId = 1L; + int ppp = 100; + redisRepository.addToZSet(zSetKey, userId, ppp); + + //when + Long scoreInZSet = redisRepository.getScoreInZSet(zSetKey, userId); + + //then + Assertions.assertThat(scoreInZSet).isEqualTo(ppp); + } + + @Test + public void getUserIdsByRange() throws Exception { + //given + Long userId = 1L; + Long userId2 = 2L; + Long userId3 = 3L; + int ppp = 100; + int ppp2 = 200; + int ppp3 = 300; + redisRepository.addToZSet(zSetKey, userId, ppp); + redisRepository.addToZSet(zSetKey, userId2, ppp2); + redisRepository.addToZSet(zSetKey, userId3, ppp3); + + //when + List userIdsSorted = redisRepository.getUserIdsByRangeFromZSet(zSetKey, 0, 1); + + //then + Assertions.assertThat(userIdsSorted).containsExactly(userId3, userId2); + Assertions.assertThat(userIdsSorted.get(0)).isEqualTo(userId3); + Assertions.assertThat(userIdsSorted.get(1)).isEqualTo(userId2); + } + + @Test + @DisplayName("ZSet에서 유저 삭제") + public void deleteZSetTest() throws Exception { + //given + Long userId = 1L; + int ppp = 100; + redisRepository.addToZSet(zSetKey, userId, ppp); + + //when + redisRepository.deleteFromZSet(zSetKey, userId); + + //then + Assertions.assertThatThrownBy(() -> { + redisRepository.getRankInZSet(zSetKey, userId); + }).isInstanceOf(RedisDataNotFoundException.class); + } + + @Test + @DisplayName("Redis에 랭킹 데이터를 추가, 검색한다.") + public void rankCreateSearch() throws Exception { + //given + Long userId = 1L; + int ppp = 100; + int win = 3; + int lose = 4; + String statusMessage = "statusMessage"; + RankRedis ranking = new RankRedis(userId, "aa", ppp, win, lose, statusMessage, + "https://42gg-public-test-image.s3.ap-northeast-2.amazonaws.com/tier/hand.svg", "#000000"); + + //when + redisRepository.addRankData(hashKey, userId, ranking); + RankRedis findRanking = redisRepository.findRankByUserId(hashKey, userId); + + //then + Assertions.assertThat(findRanking.getUserId()).isEqualTo(userId); + Assertions.assertThat(findRanking.getPpp()).isEqualTo(ppp); + Assertions.assertThat(findRanking.getWins()).isEqualTo(win); + Assertions.assertThat(findRanking.getLosses()).isEqualTo(lose); + Assertions.assertThat(findRanking.getStatusMessage()).isEqualTo(statusMessage); + } + + @Test + @DisplayName("user rank정보 업데이트") + public void updateRank() throws Exception { + //given + Long userId = 1L; + int ppp = 100; + int win = 3; + int lose = 4; + String statusMessage = "statusMessage"; + RankRedis ranking = new RankRedis(userId, "aa", ppp, win, lose, statusMessage, + "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); + redisRepository.addRankData(hashKey, userId, ranking); + + //when + int newPpp = 200; + int newWin = 4; + int newLose = 5; + String newStatusMessage = "newStatusMessage"; + RankRedis newRanking = new RankRedis(userId, "aa", newPpp, newWin, newLose, newStatusMessage, + "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); + + redisRepository.updateRankData(hashKey, userId, newRanking); + //then + RankRedis findRanking = redisRepository.findRankByUserId(hashKey, userId); + Assertions.assertThat(findRanking.getUserId()).isEqualTo(userId); + Assertions.assertThat(findRanking.getPpp()).isEqualTo(newPpp); + Assertions.assertThat(findRanking.getWins()).isEqualTo(newWin); + Assertions.assertThat(findRanking.getLosses()).isEqualTo(newLose); + Assertions.assertThat(findRanking.getStatusMessage()).isEqualTo(newStatusMessage); + } + + @Test + @DisplayName("유저 랭크를 삭제한다") + public void deleteUserRank() throws Exception { + //given + Long userId = 3L; + int ppp = 100; + int win = 3; + int lose = 4; + String statusMessage = "statusMessage"; + RankRedis ranking = new RankRedis(userId, "aa", ppp, win, lose, statusMessage, + "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); + redisRepository.addRankData(hashKey, userId, ranking); + + //when + redisRepository.deleteRankData(hashKey, userId); + + //then + Assertions.assertThatThrownBy(() -> { + redisRepository.findRankByUserId(hashKey, userId); + }).isInstanceOf(RedisDataNotFoundException.class); + } + + @Test + void findRanksByUserIds() { + //given + Long userId = 1L; + Long userId2 = 2L; + Long userId3 = 3L; + Long userId4 = 4L; + int ppp = 100; + int ppp2 = 200; + int ppp3 = 300; + int ppp4 = 400; + + RankRedis rank1 = new RankRedis(userId, "aa", ppp, 0, 0, "statusMessage", + "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); + RankRedis rank2 = new RankRedis(userId2, "aa", ppp2, 0, 0, "statusMessage", + "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); + RankRedis rank3 = new RankRedis(userId3, "aa", ppp3, 0, 0, "statusMessage", + "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); + RankRedis rank4 = new RankRedis(userId4, "aa", ppp4, 0, 0, "statusMessage", + "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); + redisRepository.addRankData(hashKey, userId, rank1); + redisRepository.addRankData(hashKey, userId2, rank2); + redisRepository.addRankData(hashKey, userId3, rank3); + redisRepository.addRankData(hashKey, userId4, rank4); + redisRepository.addToZSet(zSetKey, userId, ppp); + redisRepository.addToZSet(zSetKey, userId2, ppp2); + redisRepository.addToZSet(zSetKey, userId3, ppp3); + redisRepository.addToZSet(zSetKey, userId4, ppp4); + + //when + List sortedUserIds = redisRepository.getUserIdsByRangeFromZSet(zSetKey, 0, 3); + List ranks = redisRepository.findRanksByUserIds(hashKey, sortedUserIds); + + //then -> 랭크 순서도 알맞게 반환되는지 확인 + Assertions.assertThat(ranks) + .usingElementComparatorIgnoringFields("userId") + .containsExactly(rank4, rank3, rank2, rank1); + } + +} diff --git a/src/test/java/com/gg/server/domain/rank/redis/RedisTestService.java b/src/test/java/com/gg/server/domain/rank/redis/RedisTestService.java index c767b9e43..ce12c0614 100644 --- a/src/test/java/com/gg/server/domain/rank/redis/RedisTestService.java +++ b/src/test/java/com/gg/server/domain/rank/redis/RedisTestService.java @@ -1,27 +1,27 @@ package com.gg.server.domain.rank.redis; -import lombok.RequiredArgsConstructor; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import lombok.RequiredArgsConstructor; + @Service @Transactional @RequiredArgsConstructor public class RedisTestService { - private final RedisTemplate redisTemplate; - + private final RedisTemplate redisTemplate; - public void addStringWithError(String key, Object value) { - redisTemplate.opsForValue().set(key, value); - throw new RuntimeException(); - } + public void addStringWithError(String key, Object value) { + redisTemplate.opsForValue().set(key, value); + throw new RuntimeException(); + } - public void addString(String key, Object value) { - redisTemplate.opsForValue().set(key, value); - } + public void addString(String key, Object value) { + redisTemplate.opsForValue().set(key, value); + } - public Object getFromString(String key) { - return redisTemplate.opsForValue().get(key); - } + public Object getFromString(String key) { + return redisTemplate.opsForValue().get(key); + } } diff --git a/src/test/java/com/gg/server/domain/rank/redis/RedisTransactionTest.java b/src/test/java/com/gg/server/domain/rank/redis/RedisTransactionTest.java index 0dee1cbfc..e00e51059 100644 --- a/src/test/java/com/gg/server/domain/rank/redis/RedisTransactionTest.java +++ b/src/test/java/com/gg/server/domain/rank/redis/RedisTransactionTest.java @@ -1,7 +1,5 @@ package com.gg.server.domain.rank.redis; - -import com.gg.server.utils.annotation.IntegrationTestWithRedisTransaction; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -9,70 +7,68 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.transaction.annotation.Transactional; +import com.gg.server.utils.annotation.IntegrationTestWithRedisTransaction; + @IntegrationTestWithRedisTransaction public class RedisTransactionTest { - @Autowired - RedisTestService redisTestService; - - @Autowired - RedisTemplate redisTemplate; - - @Test - @DisplayName("transaction안에서 exception이 발생한다면 해당 transaction이 discord되는지 확인") - public void rollbackTest () throws Exception - { - String key = "hello"; - - Assertions.assertThatThrownBy(() ->{ - redisTestService.addStringWithError(key, "aaa"); - }).isInstanceOf(RuntimeException.class); - - Object result = redisTemplate.opsForValue().get(key); - Assertions.assertThat(result).isNull(); - } - - @Test - @DisplayName("transaction이 올바르게 exec를 실행시키는지 테스트") - public void commitTest () throws Exception - { - String key = "hello1"; - String value = "aaa"; - - redisTestService.addString(key, value); - - Object result = redisTemplate.opsForValue().get(key); - Assertions.assertThat(result).isNotNull(); - Assertions.assertThat(result.toString()).isEqualTo(value); - } - - @Test - @DisplayName("transaction안에서 새로 집어넣은 key에 대해서 조회시 null조회 test") - @Transactional - public void nullTest () throws Exception - { - String key = "test"; - String value = "value"; - - redisTestService.addString(key, value); - - Object result = redisTestService.getFromString(key); - Assertions.assertThat(result).isNull(); - } - - @Test - @DisplayName("transaction안에서 기존에 존재하던 key에 대해서 조회시 not null test") - public void nonNullTest () throws Exception - { - String key = "test"; - String value = "value"; - - redisTestService.addString(key, value); - - Object result = redisTestService.getFromString(key); - Assertions.assertThat(result).isNotNull(); - Assertions.assertThat(result.toString()).isEqualTo(value); - } + @Autowired + RedisTestService redisTestService; + + @Autowired + RedisTemplate redisTemplate; + + @Test + @DisplayName("transaction안에서 exception이 발생한다면 해당 transaction이 discord되는지 확인") + public void rollbackTest() throws Exception { + String key = "hello"; + + Assertions.assertThatThrownBy(() -> { + redisTestService.addStringWithError(key, "aaa"); + }).isInstanceOf(RuntimeException.class); + + Object result = redisTemplate.opsForValue().get(key); + Assertions.assertThat(result).isNull(); + } + + @Test + @DisplayName("transaction이 올바르게 exec를 실행시키는지 테스트") + public void commitTest() throws Exception { + String key = "hello1"; + String value = "aaa"; + + redisTestService.addString(key, value); + + Object result = redisTemplate.opsForValue().get(key); + Assertions.assertThat(result).isNotNull(); + Assertions.assertThat(result.toString()).isEqualTo(value); + } + + @Test + @DisplayName("transaction안에서 새로 집어넣은 key에 대해서 조회시 null조회 test") + @Transactional + public void nullTest() throws Exception { + String key = "test"; + String value = "value"; + + redisTestService.addString(key, value); + + Object result = redisTestService.getFromString(key); + Assertions.assertThat(result).isNull(); + } + + @Test + @DisplayName("transaction안에서 기존에 존재하던 key에 대해서 조회시 not null test") + public void nonNullTest() throws Exception { + String key = "test"; + String value = "value"; + + redisTestService.addString(key, value); + + Object result = redisTestService.getFromString(key); + Assertions.assertThat(result).isNotNull(); + Assertions.assertThat(result.toString()).isEqualTo(value); + } } diff --git a/src/test/java/com/gg/server/domain/rank/service/RankServiceTest.java b/src/test/java/com/gg/server/domain/rank/service/RankServiceTest.java index 400bc8e2a..76b0a7b45 100644 --- a/src/test/java/com/gg/server/domain/rank/service/RankServiceTest.java +++ b/src/test/java/com/gg/server/domain/rank/service/RankServiceTest.java @@ -1,23 +1,12 @@ package com.gg.server.domain.rank.service; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.*; +import static org.assertj.core.api.Assertions.*; +import static org.mockito.BDDMockito.*; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; -import com.gg.server.domain.rank.dto.ExpRankV2Dto; -import com.gg.server.domain.rank.dto.RankPageResponseDto; -import com.gg.server.domain.rank.dto.RankV2Dto; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; import java.util.ArrayList; import java.util.List; import java.util.Optional; -import org.jetbrains.annotations.NotNull; + import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -27,149 +16,161 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; -import static org.mockito.BDDMockito.*; + +import com.gg.server.domain.rank.data.RankRepository; +import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; +import com.gg.server.domain.rank.dto.ExpRankV2Dto; +import com.gg.server.domain.rank.dto.RankPageResponseDto; +import com.gg.server.domain.rank.dto.RankV2Dto; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.service.SeasonFindService; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; @ExtendWith(MockitoExtension.class) class RankServiceTest { - @Mock - private UserRepository userRepository; - @Mock - private RankRedisRepository redisRepository; - @Mock - private SeasonFindService seasonFindService; - @Mock - private RankRepository rankRepository; - @InjectMocks - private RankService rankService; - @BeforeEach - void setUp() { - // 현재 시즌 가져오기 - given(seasonFindService.findCurrentSeason(any())) - .willReturn(Season.builder() - .seasonName("Test Season") - .build()); - } - - @AfterEach - void tearDown() { - } - - @Test - void getExpRankPage() { - PageRequest pageRequest = PageRequest.of(0, 10); - // exp ranking user list, total page size 조회 - given(userRepository.findAllByTotalExpGreaterThan(pageRequest, 0)) - .willReturn(new PageImpl<>(new ArrayList(), pageRequest, 1)); - - // exp ranking list 조회 - List expRankV2DtoList = expRankingSampleData(); - given(userRepository.findExpRank(pageRequest.getPageNumber(), pageRequest.getPageSize(), - null)) - .willReturn(expRankV2DtoList); - ExpRankPageResponseDto testRes = rankService.getExpRankPage(pageRequest, UserDto - .builder() - .intraId("TestUser") - .id(1L) - .totalExp(0) - .build()); - assertThat(testRes.getMyRank()).isEqualTo(-1); - assertThat(testRes.getRankList().get(0).getIntraId()).isEqualTo("Test User"); - } - - private static List expRankingSampleData() { - List expRankV2Dtos = new ArrayList<>(); - expRankV2Dtos.add(new ExpRankV2Dto() { - @Override - public String getIntraId() { - return "Test User"; - } - - @Override - public String getStatusMessage() { - return "status message"; - } - - @Override - public Integer getTotalExp() { - return 0; - } - - @Override - public String getImageUri() { - return "null"; - } - - @Override - public String getTextColor() { - return null; - } - - @Override - public Integer getRanking() { - return 1; - } - }); - return expRankV2Dtos; - } - - @Test - void getRankPageV2() { - PageRequest pageRequest = PageRequest.of(0, 10); - // 현재 시즌 id 에 해당하는 랭크 유저 리스트의 페이지 수 - given(rankRepository.countRankUserBySeasonId(any())) - .willReturn(1); - // 현재 유저 ranking - given(rankRepository.findRankByUserIdAndSeasonId(any(), any())) - .willReturn(Optional.of(1)); - // sample data - List rankV2DtoList = pppRankingSampleData(); - given(rankRepository.findPppRankBySeasonId(anyInt(), anyInt(), any())) - .willReturn(rankV2DtoList); - RankPageResponseDto result = rankService.getRankPageV2(pageRequest, - UserDto - .builder() - .intraId("TestUser") - .id(1L) - .totalExp(0) - .build(), - any()); - assertThat(result.getCurrentPage()).isEqualTo(pageRequest.getPageNumber() + 1); - assertThat(result.getRankList().size()).isEqualTo(rankV2DtoList.size()); - } - - private static List pppRankingSampleData() { - List rankV2DtoList = new ArrayList<>(); - rankV2DtoList.add(new RankV2Dto() { - @Override - public String getIntraId() { - return "TestUser"; - } - - @Override - public String getStatusMessage() { - return "status message"; - } - - @Override - public Integer getPpp() { - return 1150; - } - - @Override - public String getTierImageUri() { - return "null"; - } - - @Override - public String getTextColor() { - return null; - } - - @Override - public Integer getRanking() { - return 1; - } - }); - return rankV2DtoList; - } -} \ No newline at end of file + @Mock + private UserRepository userRepository; + @Mock + private RankRedisRepository redisRepository; + @Mock + private SeasonFindService seasonFindService; + @Mock + private RankRepository rankRepository; + @InjectMocks + private RankService rankService; + + @BeforeEach + void setUp() { + // 현재 시즌 가져오기 + given(seasonFindService.findCurrentSeason(any())) + .willReturn(Season.builder() + .seasonName("Test Season") + .build()); + } + + @AfterEach + void tearDown() { + } + + @Test + void getExpRankPage() { + PageRequest pageRequest = PageRequest.of(0, 10); + // exp ranking user list, total page size 조회 + given(userRepository.findAllByTotalExpGreaterThan(pageRequest, 0)) + .willReturn(new PageImpl<>(new ArrayList(), pageRequest, 1)); + + // exp ranking list 조회 + List expRankV2DtoList = expRankingSampleData(); + given(userRepository.findExpRank(pageRequest.getPageNumber(), pageRequest.getPageSize(), + null)) + .willReturn(expRankV2DtoList); + ExpRankPageResponseDto testRes = rankService.getExpRankPage(pageRequest, UserDto + .builder() + .intraId("TestUser") + .id(1L) + .totalExp(0) + .build()); + assertThat(testRes.getMyRank()).isEqualTo(-1); + assertThat(testRes.getRankList().get(0).getIntraId()).isEqualTo("Test User"); + } + + private static List expRankingSampleData() { + List expRankV2Dtos = new ArrayList<>(); + expRankV2Dtos.add(new ExpRankV2Dto() { + @Override + public String getIntraId() { + return "Test User"; + } + + @Override + public String getStatusMessage() { + return "status message"; + } + + @Override + public Integer getTotalExp() { + return 0; + } + + @Override + public String getImageUri() { + return "null"; + } + + @Override + public String getTextColor() { + return null; + } + + @Override + public Integer getRanking() { + return 1; + } + }); + return expRankV2Dtos; + } + + @Test + void getRankPageV2() { + PageRequest pageRequest = PageRequest.of(0, 10); + // 현재 시즌 id 에 해당하는 랭크 유저 리스트의 페이지 수 + given(rankRepository.countRankUserBySeasonId(any())) + .willReturn(1); + // 현재 유저 ranking + given(rankRepository.findRankByUserIdAndSeasonId(any(), any())) + .willReturn(Optional.of(1)); + // sample data + List rankV2DtoList = pppRankingSampleData(); + given(rankRepository.findPppRankBySeasonId(anyInt(), anyInt(), any())) + .willReturn(rankV2DtoList); + RankPageResponseDto result = rankService.getRankPageV2(pageRequest, + UserDto + .builder() + .intraId("TestUser") + .id(1L) + .totalExp(0) + .build(), + any()); + assertThat(result.getCurrentPage()).isEqualTo(pageRequest.getPageNumber() + 1); + assertThat(result.getRankList().size()).isEqualTo(rankV2DtoList.size()); + } + + private static List pppRankingSampleData() { + List rankV2DtoList = new ArrayList<>(); + rankV2DtoList.add(new RankV2Dto() { + @Override + public String getIntraId() { + return "TestUser"; + } + + @Override + public String getStatusMessage() { + return "status message"; + } + + @Override + public Integer getPpp() { + return 1150; + } + + @Override + public String getTierImageUri() { + return "null"; + } + + @Override + public String getTextColor() { + return null; + } + + @Override + public Integer getRanking() { + return 1; + } + }); + return rankV2DtoList; + } +} diff --git a/src/test/java/com/gg/server/domain/season/SeasonTestController.java b/src/test/java/com/gg/server/domain/season/SeasonTestController.java index 23bfe8635..f5abe5578 100644 --- a/src/test/java/com/gg/server/domain/season/SeasonTestController.java +++ b/src/test/java/com/gg/server/domain/season/SeasonTestController.java @@ -1,20 +1,11 @@ package com.gg.server.domain.season; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.season.dto.SeasonListResDto; -import com.gg.server.domain.season.dto.SeasonResDto; -import com.gg.server.domain.season.service.SeasonService; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; import java.time.LocalDateTime; import java.util.List; -import lombok.RequiredArgsConstructor; + import org.apache.http.HttpHeaders; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -25,53 +16,65 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.data.SeasonRepository; +import com.gg.server.domain.season.dto.SeasonListResDto; +import com.gg.server.domain.season.dto.SeasonResDto; +import com.gg.server.domain.season.service.SeasonService; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc public class SeasonTestController { - @Autowired - MockMvc mvc; - @Autowired - private SeasonService seasonService; - @Autowired - TestDataUtils testDataUtils; - @Autowired - AuthTokenProvider tokenProvider; - @Autowired - ObjectMapper objectMapper; - - @Autowired - private SeasonRepository seasonRepository; + @Autowired + MockMvc mvc; + @Autowired + private SeasonService seasonService; + @Autowired + TestDataUtils testDataUtils; + @Autowired + AuthTokenProvider tokenProvider; + @Autowired + ObjectMapper objectMapper; + @Autowired + private SeasonRepository seasonRepository; - @BeforeEach - @Transactional - public void init() { - System.out.println("before each"); - Season s1 = new Season("test1 시즌", LocalDateTime.now(), LocalDateTime.now().plusMinutes(15), 1000, 100); - seasonRepository.save(s1); - seasonRepository.save(new Season("test2 season", LocalDateTime.now(), LocalDateTime.now().plusMinutes(15), 1000, 100)); - seasonRepository.flush(); - System.out.println(seasonRepository.findAll()); - } + @BeforeEach + @Transactional + public void init() { + System.out.println("before each"); + Season s1 = new Season("test1 시즌", LocalDateTime.now(), LocalDateTime.now().plusMinutes(15), 1000, 100); + seasonRepository.save(s1); + seasonRepository.save( + new Season("test2 season", LocalDateTime.now(), LocalDateTime.now().plusMinutes(15), 1000, 100)); + seasonRepository.flush(); + System.out.println(seasonRepository.findAll()); + } - @Test - @DisplayName("시즌 조회 Test") - @Transactional - void season_list_test() throws Exception { - //given - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - String url = "/pingpong/seasons"; - List list = seasonService.seasonList(); - //when - String contentAsString = mvc.perform(RestDocumentationRequestBuilders.get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - //then - SeasonListResDto result = objectMapper.readValue(contentAsString, SeasonListResDto.class); - assertThat(list.size()).isEqualTo(result.getSeasonList().size()); - } + @Test + @DisplayName("시즌 조회 Test") + @Transactional + void season_list_test() throws Exception { + //given + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + String url = "/pingpong/seasons"; + List list = seasonService.seasonList(); + //when + String contentAsString = mvc.perform( + RestDocumentationRequestBuilders.get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + //then + SeasonListResDto result = objectMapper.readValue(contentAsString, SeasonListResDto.class); + assertThat(list.size()).isEqualTo(result.getSeasonList().size()); + } } diff --git a/src/test/java/com/gg/server/domain/season/SeasonTriggerTest.java b/src/test/java/com/gg/server/domain/season/SeasonTriggerTest.java index d4c65cb49..8625189b8 100644 --- a/src/test/java/com/gg/server/domain/season/SeasonTriggerTest.java +++ b/src/test/java/com/gg/server/domain/season/SeasonTriggerTest.java @@ -1,16 +1,9 @@ package com.gg.server.domain.season; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; import java.time.LocalDateTime; + import javax.persistence.EntityManager; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -21,53 +14,64 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.data.SeasonRepository; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + @RequiredArgsConstructor @IntegrationTest @AutoConfigureMockMvc @Slf4j public class SeasonTriggerTest { - @Autowired - MockMvc mvc; - @Autowired - TestDataUtils testDataUtils; - @Autowired - AuthTokenProvider tokenProvider; - @Autowired - ObjectMapper objectMapper; - @Autowired - EntityManager em; - - @Autowired - private SeasonRepository seasonRepository; + @Autowired + MockMvc mvc; + @Autowired + TestDataUtils testDataUtils; + @Autowired + AuthTokenProvider tokenProvider; + @Autowired + ObjectMapper objectMapper; + @Autowired + EntityManager em; + @Autowired + private SeasonRepository seasonRepository; - @BeforeEach - @Transactional - public void init() { - System.out.println("before each"); - Season s1 = new Season("test1 시즌", LocalDateTime.now(), LocalDateTime.now().plusMinutes(15), 1000, 100); - seasonRepository.save(s1); - seasonRepository.save(new Season("test2 season", LocalDateTime.now(), LocalDateTime.now().plusMinutes(15), 1000, 100)); - seasonRepository.flush(); - System.out.println(seasonRepository.findAll()); - } + @BeforeEach + @Transactional + public void init() { + System.out.println("before each"); + Season s1 = new Season("test1 시즌", LocalDateTime.now(), LocalDateTime.now().plusMinutes(15), 1000, 100); + seasonRepository.save(s1); + seasonRepository.save( + new Season("test2 season", LocalDateTime.now(), LocalDateTime.now().plusMinutes(15), 1000, 100)); + seasonRepository.flush(); + System.out.println(seasonRepository.findAll()); + } - @Test - @DisplayName("시즌 삭제 방지 Test") - @Transactional - public void 시즌삭제방지Test() { - Season season = new Season("test1 시즌", LocalDateTime.now(), LocalDateTime.now().plusMinutes(15), 1000, 100); - seasonRepository.save(season); - Long id = season.getId(); - testDataUtils.createMockMatch(testDataUtils.createNewUser(), season, - LocalDateTime.now().minusMinutes(20), LocalDateTime.now().minusMinutes(5), Mode.RANK); - log.info("ID : " + id); - Throwable thrownException = Assertions.assertThrows(UndeclaredThrowableException.class, () -> { - seasonRepository.deleteById(id); - em.flush(); - }); + @Test + @DisplayName("시즌 삭제 방지 Test") + @Transactional + public void seasonDeleteImpossibleTest() { + Season season = new Season("test1 시즌", LocalDateTime.now(), LocalDateTime.now().plusMinutes(15), 1000, 100); + seasonRepository.save(season); + Long id = season.getId(); + testDataUtils.createMockMatch(testDataUtils.createNewUser(), season, + LocalDateTime.now().minusMinutes(20), LocalDateTime.now().minusMinutes(5), Mode.RANK); + log.info("ID : " + id); + Throwable thrownException = Assertions.assertThrows(UndeclaredThrowableException.class, () -> { + seasonRepository.deleteById(id); + em.flush(); + }); - log.info("에러 메시지: " + thrownException.getMessage()); - } + log.info("에러 메시지: " + thrownException.getMessage()); + } } diff --git a/src/test/java/com/gg/server/domain/team/data/TeamUnitTest.java b/src/test/java/com/gg/server/domain/team/data/TeamUnitTest.java index a5da26df2..c8aaf50e5 100644 --- a/src/test/java/com/gg/server/domain/team/data/TeamUnitTest.java +++ b/src/test/java/com/gg/server/domain/team/data/TeamUnitTest.java @@ -1,120 +1,121 @@ package com.gg.server.domain.team.data; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.mock; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; -import com.gg.server.utils.annotation.UnitTest; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import com.gg.server.global.exception.ErrorCode; +import com.gg.server.global.exception.custom.BusinessException; +import com.gg.server.utils.annotation.UnitTest; + @UnitTest @DisplayName("TeamUnitTest") class TeamUnitTest { - List mockTeamUsers; - List teams; - - @BeforeEach - void setUp() { - mockTeamUsers = IntStream.range(0, 10) - .mapToObj(i -> mock(TeamUser.class)) - .collect(Collectors.toCollection(ArrayList::new)); - teams = IntStream.range(0, 10) - .mapToObj(i -> new Team()) - .collect(Collectors.toCollection(ArrayList::new)); - } - - @Nested - @DisplayName("AddTeamUser") - class AddTeam { - - @Test - @DisplayName("단일 TeamUser 추가 성공") - public void addSingleTeamSuccess() { - //given - Team team = teams.get(0); - TeamUser mockTeamUser = mockTeamUsers.get(0); - - //when - team.addTeamUser(mockTeamUser); - - //then - assertEquals(1, team.getTeamUsers().size()); - assertEquals(mockTeamUser, team.getTeamUsers().get(0)); - } - - @Test - @DisplayName("두개 TeamUser 추가 성공") - void addMultiTeamSuccess() { - //given - Team team = teams.get(0); - - //when - team.addTeamUser(mockTeamUsers.get(0)); - team.addTeamUser(mockTeamUsers.get(1)); - - //then - assertEquals(2, team.getTeamUsers().size()); - assertEquals(mockTeamUsers.get(0), team.getTeamUsers().get(0)); - assertEquals(mockTeamUsers.get(1), team.getTeamUsers().get(1)); - } - - @Test - @DisplayName("두개 이상의 TeamUser 추가 실패") - void addExceedTeamFailed() { - //given - Team team = teams.get(0); - - //when - team.addTeamUser(mockTeamUsers.get(0)); - team.addTeamUser(mockTeamUsers.get(1)); - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> team.addTeamUser(mockTeamUsers.get(2))); - assertEquals(ErrorCode.TEAM_USER_EXCEED, businessException.getErrorCode()); - assertEquals(ErrorCode.TEAM_USER_EXCEED.getMessage(), businessException.getMessage()); - } - - @Test - @DisplayName("동일한 TeamUser 추가 실패") - void duplicatedTeamAddFailed() { - //given - Team team = teams.get(0); - - //when - team.addTeamUser(mockTeamUsers.get(0)); - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> team.addTeamUser(mockTeamUsers.get(0))); - assertEquals(ErrorCode.TEAM_USER_ALREADY_EXIST, businessException.getErrorCode()); - assertEquals(ErrorCode.TEAM_USER_ALREADY_EXIST.getMessage(), businessException.getMessage()); - } - - @Test - @DisplayName("null 포인터 전달 시 실패") - void nullAddFailed() { - //given - Team team = teams.get(0); - - //when - TeamUser teamUser = null; - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> team.addTeamUser(teamUser)); - assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); - assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); - } - } + List mockTeamUsers; + List teams; + + @BeforeEach + void setUp() { + mockTeamUsers = IntStream.range(0, 10) + .mapToObj(i -> mock(TeamUser.class)) + .collect(Collectors.toCollection(ArrayList::new)); + teams = IntStream.range(0, 10) + .mapToObj(i -> new Team()) + .collect(Collectors.toCollection(ArrayList::new)); + } + + @Nested + @DisplayName("AddTeamUser") + class AddTeam { + + @Test + @DisplayName("단일 TeamUser 추가 성공") + public void addSingleTeamSuccess() { + //given + Team team = teams.get(0); + TeamUser mockTeamUser = mockTeamUsers.get(0); + + //when + team.addTeamUser(mockTeamUser); + + //then + assertEquals(1, team.getTeamUsers().size()); + assertEquals(mockTeamUser, team.getTeamUsers().get(0)); + } + + @Test + @DisplayName("두개 TeamUser 추가 성공") + void addMultiTeamSuccess() { + //given + Team team = teams.get(0); + + //when + team.addTeamUser(mockTeamUsers.get(0)); + team.addTeamUser(mockTeamUsers.get(1)); + + //then + assertEquals(2, team.getTeamUsers().size()); + assertEquals(mockTeamUsers.get(0), team.getTeamUsers().get(0)); + assertEquals(mockTeamUsers.get(1), team.getTeamUsers().get(1)); + } + + @Test + @DisplayName("두개 이상의 TeamUser 추가 실패") + void addExceedTeamFailed() { + //given + Team team = teams.get(0); + + //when + team.addTeamUser(mockTeamUsers.get(0)); + team.addTeamUser(mockTeamUsers.get(1)); + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> team.addTeamUser(mockTeamUsers.get(2))); + assertEquals(ErrorCode.TEAM_USER_EXCEED, businessException.getErrorCode()); + assertEquals(ErrorCode.TEAM_USER_EXCEED.getMessage(), businessException.getMessage()); + } + + @Test + @DisplayName("동일한 TeamUser 추가 실패") + void duplicatedTeamAddFailed() { + //given + Team team = teams.get(0); + + //when + team.addTeamUser(mockTeamUsers.get(0)); + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> team.addTeamUser(mockTeamUsers.get(0))); + assertEquals(ErrorCode.TEAM_USER_ALREADY_EXIST, businessException.getErrorCode()); + assertEquals(ErrorCode.TEAM_USER_ALREADY_EXIST.getMessage(), businessException.getMessage()); + } + + @Test + @DisplayName("null 포인터 전달 시 실패") + void nullAddFailed() { + //given + Team team = teams.get(0); + + //when + TeamUser teamUser = null; + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> team.addTeamUser(teamUser)); + assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); + assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); + } + } } diff --git a/src/test/java/com/gg/server/domain/tournament/controller/TournamentFindControllerTest.java b/src/test/java/com/gg/server/domain/tournament/controller/TournamentFindControllerTest.java index a8fabcfd7..8b2d599f1 100644 --- a/src/test/java/com/gg/server/domain/tournament/controller/TournamentFindControllerTest.java +++ b/src/test/java/com/gg/server/domain/tournament/controller/TournamentFindControllerTest.java @@ -1,7 +1,24 @@ package com.gg.server.domain.tournament.controller; +import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.time.LocalDateTime; +import java.util.List; + +import org.apache.http.HttpHeaders; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.utils.annotation.IntegrationTest; import com.gg.server.domain.tournament.data.Tournament; import com.gg.server.domain.tournament.data.TournamentUser; import com.gg.server.domain.tournament.data.TournamentUserRepository; @@ -17,27 +34,10 @@ import com.gg.server.global.exception.custom.CustomRuntimeException; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; -import java.time.LocalDateTime; +import com.gg.server.utils.annotation.IntegrationTest; + import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpHeaders; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @IntegrationTest @AutoConfigureMockMvc @@ -46,484 +46,520 @@ @Slf4j public class TournamentFindControllerTest { - @Autowired - MockMvc mockMvc; - @Autowired - TestDataUtils testDataUtils; - @Autowired - ObjectMapper objectMapper; - @Autowired - AuthTokenProvider tokenProvider; - @Autowired - TournamentUserRepository tournamentUserRepository; - - List tournamentList; - String accessToken; - - User tester; - - - - @Nested - @DisplayName("토너먼트_리스트_조회") - class findTournamentListTest { - @BeforeEach - void beforeEach() { - tester = testDataUtils.createNewUser("findControllerTester", "findControllerTester", RacketType.DUAL, SnsType.SLACK, RoleType.ADMIN); - accessToken = tokenProvider.createToken(tester.getId()); - tournamentList = testDataUtils.makeTournamentList(); - } - @Test - @DisplayName("전체_조회") - public void getTournamentList() throws Exception { - // given - int page = 1; - int size = 20; - String url = "/pingpong/tournaments/?page=" + page + "&size=" + size; - - // when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - TournamentListResponseDto resp = objectMapper.readValue(contentAsString, TournamentListResponseDto.class); - - // then - List tournamentInfoList = resp.getTournaments(); - for (int i = 0; i < tournamentInfoList.size(); i++) { - Long tournamentId = tournamentInfoList.get(i).getTournamentId(); - TournamentResponseDto tournamentResponseDto = tournamentList.stream().filter(t -> t.getTournamentId().equals(tournamentId)).findFirst().orElse(null); - if (tournamentResponseDto != null) { - assertThat(tournamentInfoList.get(i).getTitle()).isEqualTo(tournamentResponseDto.getTitle()); - assertThat(tournamentInfoList.get(i).getContents()).isEqualTo(tournamentResponseDto.getContents()); - assertThat(tournamentInfoList.get(i).getType()).isEqualTo(tournamentResponseDto.getType()); - assertThat(tournamentInfoList.get(i).getStatus()).isEqualTo(tournamentResponseDto.getStatus()); - assertThat(tournamentInfoList.get(i).getWinnerIntraId()).isEqualTo(tournamentResponseDto.getWinnerIntraId()); - assertThat(tournamentInfoList.get(i).getWinnerImageUrl()).isEqualTo(tournamentResponseDto.getWinnerImageUrl()); - assertThat(tournamentInfoList.get(i).getPlayerCnt()).isEqualTo(tournamentResponseDto.getPlayerCnt()); - } - if (i > 0) - assertThat(tournamentInfoList.get(i).getStartTime()).isAfter(tournamentInfoList.get(i - 1).getEndTime()); - } - } - - @Test - @DisplayName("status별_조회") - public void getTournamentListByStatus() throws Exception { - - // given - int page = 1; - int size = 10; - String url = "/pingpong/tournaments/?page=" + page + "&size=" + size + "&status=" + TournamentStatus.BEFORE; - - // when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - TournamentListResponseDto resp = objectMapper.readValue(contentAsString, TournamentListResponseDto.class); - - // then - List tournamentInfoList = resp.getTournaments(); - for (TournamentResponseDto responseDto : tournamentInfoList) { - assertThat(responseDto.getStatus()).isEqualTo(TournamentStatus.BEFORE); - } - } - - @Test - @DisplayName("type별_조회") - public void getTournamentListByType() throws Exception { - - // given - int page = 1; - int size = 10; - String url = "/pingpong/tournaments/?page=" + page + "&size=" + size + "&type=" + TournamentType.ROOKIE; - - // when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - TournamentListResponseDto resp = objectMapper.readValue(contentAsString, TournamentListResponseDto.class); - - // then - List tournamentInfoList = resp.getTournaments(); - for (TournamentResponseDto responseDto : tournamentInfoList) { - assertThat(responseDto.getType()).isEqualTo(TournamentType.ROOKIE); - } - } - - @Test - @DisplayName("type과 status 별 조회") - public void getTournamentListByTypeAndStatus() throws Exception { - // given - int page = 1; - int size = 10; - String url = "/pingpong/tournaments/?page=" + page + "&size=" + size + "&type=" + TournamentType.ROOKIE + "&status=" + TournamentStatus.BEFORE; - - // when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - TournamentListResponseDto resp = objectMapper.readValue(contentAsString, TournamentListResponseDto.class); - - // then - List tournamentInfoList = resp.getTournaments(); - for (TournamentResponseDto responseDto : tournamentInfoList) { - assertThat(responseDto.getType()).isEqualTo(TournamentType.ROOKIE); - assertThat(responseDto.getStatus()).isEqualTo(TournamentStatus.BEFORE); - } - } - - @Test - @DisplayName("잘못된 type") - public void wrongType() throws Exception { - // given - int page = 1; - int size = 10; - String url = "/pingpong/tournaments/?page=" + page + "&size=" + size + "&type=" + "rookie123" + "&status=" + TournamentStatus.BEFORE.getCode(); - - // when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - - // then - log.info(contentAsString); - } - - @Test - @DisplayName("잘못된 status") - public void wrongStatus() throws Exception { - // given - int page = 1; - int size = 10; - String url = "/pingpong/tournaments/?page=" + page + "&size=" + size + "&type=" + TournamentType.ROOKIE.getCode() + "&status=" + "wrongStatus"; - - // when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - - // then - log.info(contentAsString); - } - } - - @Nested - @DisplayName("토너먼트_유저_신청_취소_테스트") - class cancelTournamentUserRegistrationTest { - @BeforeEach - void beforeEach() { - tester = testDataUtils.createNewUser("findControllerTester", "findControllerTester", RacketType.DUAL, SnsType.SLACK, RoleType.ADMIN); - accessToken = tokenProvider.createToken(tester.getId()); - } - @Test - @DisplayName("유저_신청_취소_성공") - void success() throws Exception { - // given - int maxTournamentUser = 8; - Tournament tournament = testDataUtils.createTournament(LocalDateTime.now(), LocalDateTime.now(), TournamentStatus.BEFORE); - for (int i=0; i{throw new CustomRuntimeException("", ErrorCode.BAD_REQUEST);}); - List tournamentUserList = tournament.getTournamentUsers(); - for (int i=0; i tournamentList; + String accessToken; + + User tester; + + @Nested + @DisplayName("토너먼트_리스트_조회") + class FindTournamentListTest { + @BeforeEach + void beforeEach() { + tester = testDataUtils.createNewUser("findControllerTester", "findControllerTester", RacketType.DUAL, + SnsType.SLACK, RoleType.ADMIN); + accessToken = tokenProvider.createToken(tester.getId()); + tournamentList = testDataUtils.makeTournamentList(); + } + + @Test + @DisplayName("전체_조회") + public void getTournamentList() throws Exception { + // given + int page = 1; + int size = 20; + String url = "/pingpong/tournaments/?page=" + page + "&size=" + size; + + // when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + TournamentListResponseDto resp = objectMapper.readValue(contentAsString, TournamentListResponseDto.class); + + // then + List tournamentInfoList = resp.getTournaments(); + for (int i = 0; i < tournamentInfoList.size(); i++) { + Long tournamentId = tournamentInfoList.get(i).getTournamentId(); + TournamentResponseDto tournamentResponseDto = tournamentList.stream() + .filter(t -> t.getTournamentId().equals(tournamentId)) + .findFirst() + .orElse(null); + if (tournamentResponseDto != null) { + assertThat(tournamentInfoList.get(i).getTitle()).isEqualTo(tournamentResponseDto.getTitle()); + assertThat(tournamentInfoList.get(i).getContents()).isEqualTo(tournamentResponseDto.getContents()); + assertThat(tournamentInfoList.get(i).getType()).isEqualTo(tournamentResponseDto.getType()); + assertThat(tournamentInfoList.get(i).getStatus()).isEqualTo(tournamentResponseDto.getStatus()); + assertThat(tournamentInfoList.get(i).getWinnerIntraId()).isEqualTo( + tournamentResponseDto.getWinnerIntraId()); + assertThat(tournamentInfoList.get(i).getWinnerImageUrl()).isEqualTo( + tournamentResponseDto.getWinnerImageUrl()); + assertThat(tournamentInfoList.get(i).getPlayerCnt()).isEqualTo( + tournamentResponseDto.getPlayerCnt()); + } + if (i > 0) { + assertThat(tournamentInfoList.get(i).getStartTime()).isAfter( + tournamentInfoList.get(i - 1).getEndTime()); + } + } + } + + @Test + @DisplayName("status별_조회") + public void getTournamentListByStatus() throws Exception { + + // given + int page = 1; + int size = 10; + String url = "/pingpong/tournaments/?page=" + page + "&size=" + size + "&status=" + TournamentStatus.BEFORE; + + // when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + TournamentListResponseDto resp = objectMapper.readValue(contentAsString, TournamentListResponseDto.class); + + // then + List tournamentInfoList = resp.getTournaments(); + for (TournamentResponseDto responseDto : tournamentInfoList) { + assertThat(responseDto.getStatus()).isEqualTo(TournamentStatus.BEFORE); + } + } + + @Test + @DisplayName("type별_조회") + public void getTournamentListByType() throws Exception { + + // given + int page = 1; + int size = 10; + String url = "/pingpong/tournaments/?page=" + page + "&size=" + size + "&type=" + TournamentType.ROOKIE; + + // when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + TournamentListResponseDto resp = objectMapper.readValue(contentAsString, TournamentListResponseDto.class); + + // then + List tournamentInfoList = resp.getTournaments(); + for (TournamentResponseDto responseDto : tournamentInfoList) { + assertThat(responseDto.getType()).isEqualTo(TournamentType.ROOKIE); + } + } + + @Test + @DisplayName("type과 status 별 조회") + public void getTournamentListByTypeAndStatus() throws Exception { + // given + int page = 1; + int size = 10; + String url = + "/pingpong/tournaments/?page=" + page + "&size=" + size + "&type=" + TournamentType.ROOKIE + "&status=" + + TournamentStatus.BEFORE; + + // when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + TournamentListResponseDto resp = objectMapper.readValue(contentAsString, TournamentListResponseDto.class); + + // then + List tournamentInfoList = resp.getTournaments(); + for (TournamentResponseDto responseDto : tournamentInfoList) { + assertThat(responseDto.getType()).isEqualTo(TournamentType.ROOKIE); + assertThat(responseDto.getStatus()).isEqualTo(TournamentStatus.BEFORE); + } + } + + @Test + @DisplayName("잘못된 type") + public void wrongType() throws Exception { + // given + int page = 1; + int size = 10; + String url = "/pingpong/tournaments/?page=" + page + "&size=" + size + "&type=" + "rookie123" + "&status=" + + TournamentStatus.BEFORE.getCode(); + + // when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + + // then + log.info(contentAsString); + } + + @Test + @DisplayName("잘못된 status") + public void wrongStatus() throws Exception { + // given + int page = 1; + int size = 10; + String url = + "/pingpong/tournaments/?page=" + page + "&size=" + size + "&type=" + TournamentType.ROOKIE.getCode() + + "&status=" + "wrongStatus"; + + // when + String contentAsString = mockMvc.perform( + get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse().getContentAsString(); + + // then + log.info(contentAsString); + } + } + + @Nested + @DisplayName("토너먼트_유저_신청_취소_테스트") + class CancelTournamentUserRegistrationTest { + @BeforeEach + void beforeEach() { + tester = testDataUtils.createNewUser("findControllerTester", "findControllerTester", RacketType.DUAL, + SnsType.SLACK, RoleType.ADMIN); + accessToken = tokenProvider.createToken(tester.getId()); + } + + @Test + @DisplayName("유저_신청_취소_성공") + void success() throws Exception { + // given + int maxTournamentUser = 8; + Tournament tournament = testDataUtils.createTournament(LocalDateTime.now(), LocalDateTime.now(), + TournamentStatus.BEFORE); + for (int i = 0; i < maxTournamentUser - 1; i++) { + testDataUtils.createTournamentUser(testDataUtils.createNewUser("testUser" + i), tournament, true); + } + testDataUtils.createTournamentUser(tester, tournament, true); + for (int i = maxTournamentUser; i < maxTournamentUser + 4; i++) { + testDataUtils.createTournamentUser(testDataUtils.createNewUser("testUser" + i), tournament, false); + } + String url = "/pingpong/tournaments/" + tournament.getId() + "/users"; + String expected = "{\"status\":\"BEFORE\"}"; + + // when + String contentAsString = mockMvc.perform(delete(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + // then + System.out.println(contentAsString); + if (expected.compareTo(contentAsString) != 0) { + throw new CustomRuntimeException("상태 오류", ErrorCode.BAD_REQUEST); + } + tournamentUserRepository.findByTournamentIdAndUserId(tournament.getId(), tester.getId()).ifPresent( + a -> { + throw new CustomRuntimeException("", ErrorCode.BAD_REQUEST); + }); + List tournamentUserList = tournament.getTournamentUsers(); + for (int i = 0; i < maxTournamentUser; i++) { + if (!tournamentUserList.get(i).getIsJoined()) { + throw new CustomRuntimeException("참가자 오류", ErrorCode.BAD_REQUEST); + } + } + for (int i = maxTournamentUser; i < tournamentUserList.size(); i++) { + if (tournamentUserList.get(i).getIsJoined()) { + throw new CustomRuntimeException("대기자 오류", ErrorCode.BAD_REQUEST); + } + } + } + + @Test + @DisplayName("유저_없음") + void userNotFound() throws Exception { + // given + Tournament tournament = testDataUtils.createTournament(LocalDateTime.now(), LocalDateTime.now(), + TournamentStatus.BEFORE); + String url = "/pingpong/tournaments/" + tournament.getId() + "/users"; + + // when, then + String contentAsString = mockMvc.perform(delete(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNotFound()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @DisplayName("토너먼트_없음") + void tournamentNotFound() throws Exception { + // given + String url = "/pingpong/tournaments/" + 9999 + "/users"; + + // when, then + String contentAsString = mockMvc.perform(delete(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNotFound()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + } + + @Nested + @DisplayName("토너먼트_단일_조회") + class FindTournamentTest { + @BeforeEach + void beforeEach() { + tester = testDataUtils.createNewUser("findControllerTester", "findControllerTester", RacketType.DUAL, + SnsType.SLACK, RoleType.ADMIN); + accessToken = tokenProvider.createToken(tester.getId()); + } + + @Test + @DisplayName("조회_성공") + public void success() throws Exception { + //given + Tournament tournament = testDataUtils.createTournament("string1", "string", + LocalDateTime.now().plusDays(2).plusHours(1), LocalDateTime.now().plusDays(2).plusHours(3), + TournamentType.ROOKIE, TournamentStatus.BEFORE); + User user = testDataUtils.createNewUser("test"); + testDataUtils.createTournamentUser(user, tournament, true); + tournament.updateWinner(user); + + Long tournamentId = tournament.getId(); + String url = "/pingpong/tournaments/" + tournamentId; + + //when + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + TournamentResponseDto responseDto = objectMapper.readValue(contentAsString, TournamentResponseDto.class); + + //then + assertThat(tournament.getTitle()).isEqualTo(responseDto.getTitle()); + assertThat(tournament.getContents()).isEqualTo(responseDto.getContents()); + assertThat(tournament.getType()).isEqualTo(responseDto.getType()); + assertThat(tournament.getStatus()).isEqualTo(responseDto.getStatus()); + if (tournament.getWinner() == null) { + assertThat(responseDto.getWinnerIntraId()).isEqualTo(null); + assertThat(responseDto.getWinnerImageUrl()).isEqualTo(null); + } else { + assertThat(tournament.getWinner().getIntraId()).isEqualTo(responseDto.getWinnerIntraId()); + assertThat(tournament.getWinner().getImageUri()).isEqualTo(responseDto.getWinnerImageUrl()); + } + assertThat(tournament.getTournamentUsers().size()).isEqualTo(responseDto.getPlayerCnt()); + } + + @Test + @DisplayName("잘못된_토너먼트_ID") + public void tournamentNotExist() throws Exception { + //given + Long tournamentId = 1L; + String url = "/pingpong/tournaments/" + tournamentId; + + //when + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNotFound()) + .andReturn().getResponse().getContentAsString(); + + //then + System.out.println(contentAsString); + } + } + + @Nested + @DisplayName("토너먼트_유저_참가_상태_조회") + class UserStatusInTournamentTest { + @BeforeEach + void beforeEach() { + tester = testDataUtils.createNewUser("findControllerTester", "findControllerTester", RacketType.DUAL, + SnsType.SLACK, RoleType.ADMIN); + accessToken = tokenProvider.createToken(tester.getId()); + } + + @Test + @DisplayName("유저_상태_조회_성공") + void success() throws Exception { + // given 1 + Tournament tournament = testDataUtils.createTournament(LocalDateTime.now(), LocalDateTime.now(), + TournamentStatus.BEFORE); + String url = "/pingpong/tournaments/" + tournament.getId() + "/users"; + String expected1 = "{\"status\":\"BEFORE\"}"; + + // when 1 + String contentAsString = mockMvc.perform(get(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + // then 1 + if (expected1.compareTo(contentAsString) != 0) { + throw new CustomRuntimeException("상태 오류", ErrorCode.BAD_REQUEST); + } + + // given 2 + testDataUtils.createTournamentUser(tester, tournament, false); + String expected2 = "{\"status\":\"WAIT\"}"; + + // when 2 + contentAsString = mockMvc.perform(get(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + // then 2 + if (expected2.compareTo(contentAsString) != 0) { + throw new CustomRuntimeException("상태 오류", ErrorCode.BAD_REQUEST); + } + + // given 3 + tournamentUserRepository.findByTournamentIdAndUserId(tournament.getId(), tester.getId()) + .get().updateIsJoined(true); + String expected3 = "{\"status\":\"PLAYER\"}"; + + // when 3 + contentAsString = mockMvc.perform(get(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + // then 3 + if (expected3.compareTo(contentAsString) != 0) { + throw new CustomRuntimeException("상태 오류", ErrorCode.BAD_REQUEST); + } + } + + @Test + @DisplayName("토너먼트_없음") + void tournamentNotFound() throws Exception { + // given + String url = "/pingpong/tournaments/" + 9999 + "/users"; + + // when, then + String contentAsString = mockMvc.perform(get(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNotFound()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + } + + @Nested + @DisplayName("토너먼트_유저_참가_신청") + class RegisterTournamentUserTest { + @BeforeEach + void beforeEach() { + tester = testDataUtils.createNewUser("findControllerTester", "findControllerTester", RacketType.DUAL, + SnsType.SLACK, RoleType.ADMIN); + accessToken = tokenProvider.createToken(tester.getId()); + } + + @Test + @DisplayName("유저_참가_신청(참가자)_성공") + void successPlayer() throws Exception { + // given + Tournament tournament = testDataUtils.createTournament(LocalDateTime.now(), LocalDateTime.now(), + TournamentStatus.BEFORE); + String url = "/pingpong/tournaments/" + tournament.getId() + "/users"; + String expected = "{\"status\":\"PLAYER\"}"; + + // when + String contentAsString = mockMvc.perform(post(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isCreated()) + .andReturn().getResponse().getContentAsString(); + + // then + if (expected.compareTo(contentAsString) != 0) { + throw new CustomRuntimeException("상태 오류", ErrorCode.BAD_REQUEST); + } + } + + @Test + @DisplayName("유저_참가_신청(대기자)_성공") + void successWait() throws Exception { + // given + int maxTournamentUser = 8; + Tournament tournament = testDataUtils.createTournament(LocalDateTime.now(), LocalDateTime.now(), + TournamentStatus.BEFORE); + for (int i = 0; i < maxTournamentUser; i++) { + testDataUtils.createTournamentUser(testDataUtils.createNewUser("testUser" + i), tournament, true); + } + String url = "/pingpong/tournaments/" + tournament.getId() + "/users"; + String expected = "{\"status\":\"WAIT\"}"; + + // when + String contentAsString = mockMvc.perform(post(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isCreated()) + .andReturn().getResponse().getContentAsString(); + + // then + if (expected.compareTo(contentAsString) != 0) { + throw new CustomRuntimeException("상태 오류", ErrorCode.BAD_REQUEST); + } + } + + @Test + @DisplayName("토너먼트_없음") + void tournamentNotFound() throws Exception { + // given + String url = "/pingpong/tournaments/" + 9999 + "/users"; + + // when, then + String contentAsString = mockMvc.perform(post(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNotFound()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + @Test + @DisplayName("이미_신청한_토너먼트_존재") + void conflictRegisteration() throws Exception { + // given + Tournament tournament1 = testDataUtils.createTournament(LocalDateTime.now(), LocalDateTime.now(), + TournamentStatus.BEFORE); + Tournament tournament2 = testDataUtils.createTournament(LocalDateTime.now(), LocalDateTime.now(), + TournamentStatus.BEFORE); + testDataUtils.createTournamentUser(tester, tournament1, false); + String url = "/pingpong/tournaments/" + tournament2.getId() + "/users"; + + // when, then + String contentAsString = mockMvc.perform(post(url) + .contentType(MediaType.APPLICATION_JSON) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isConflict()) + .andReturn().getResponse().getContentAsString(); + + System.out.println(contentAsString); + } + + } } diff --git a/src/test/java/com/gg/server/domain/tournament/controller/TournamentGameControllerTest.java b/src/test/java/com/gg/server/domain/tournament/controller/TournamentGameControllerTest.java index 256527dd8..80fa5794a 100644 --- a/src/test/java/com/gg/server/domain/tournament/controller/TournamentGameControllerTest.java +++ b/src/test/java/com/gg/server/domain/tournament/controller/TournamentGameControllerTest.java @@ -1,7 +1,22 @@ package com.gg.server.domain.tournament.controller; +import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.time.LocalDateTime; +import java.util.Objects; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.utils.annotation.IntegrationTest; import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.season.data.Season; import com.gg.server.domain.tournament.data.Tournament; @@ -17,24 +32,10 @@ import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.transaction.annotation.Transactional; - -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; - -import java.time.LocalDateTime; -import java.util.Objects; @IntegrationTest @AutoConfigureMockMvc @@ -43,61 +44,65 @@ @Slf4j public class TournamentGameControllerTest { - @Autowired - MockMvc mockMvc; - @Autowired - TestDataUtils testDataUtils; - @Autowired - ObjectMapper objectMapper; - @Autowired - AuthTokenProvider tokenProvider; + @Autowired + MockMvc mockMvc; + @Autowired + TestDataUtils testDataUtils; + @Autowired + ObjectMapper objectMapper; + @Autowired + AuthTokenProvider tokenProvider; - String accessToken; - Tournament testTournament; - String tournamentUrl = "/pingpong/tournaments/"; + String accessToken; + Tournament testTournament; + String tournamentUrl = "/pingpong/tournaments/"; - @BeforeEach - void beforeEach() { - User tester = testDataUtils.createNewUser("findControllerTester", "findControllerTester", RacketType.DUAL, SnsType.SLACK, RoleType.ADMIN); - accessToken = tokenProvider.createToken(tester.getId()); + @BeforeEach + void beforeEach() { + User tester = testDataUtils.createNewUser("findControllerTester", "findControllerTester", RacketType.DUAL, + SnsType.SLACK, RoleType.ADMIN); + accessToken = tokenProvider.createToken(tester.getId()); - Season season = testDataUtils.createSeason(); - testTournament = testDataUtils.createTournament("Test Tournament", LocalDateTime.now(), LocalDateTime.now().plusHours(2), TournamentStatus.LIVE); - int i=0; - for (TournamentRound round : TournamentRound.values()) { - User gamer = testDataUtils.createNewUser("gamer" + i++); - GameInfoDto gameInfoDto = testDataUtils.createGame(gamer, LocalDateTime.now().minusDays(10), LocalDateTime.now().minusDays(10).plusMinutes(20),season, Mode.TOURNAMENT); - TournamentGame tournamentGame = testDataUtils.createTournamentGame(testTournament, round, gameInfoDto); - } - } + Season season = testDataUtils.createSeason(); + testTournament = testDataUtils.createTournament("Test Tournament", LocalDateTime.now(), + LocalDateTime.now().plusHours(2), TournamentStatus.LIVE); + int idx = 0; + for (TournamentRound round : TournamentRound.values()) { + User gamer = testDataUtils.createNewUser("gamer" + idx++); + GameInfoDto gameInfoDto = testDataUtils.createGame(gamer, LocalDateTime.now().minusDays(10), + LocalDateTime.now().minusDays(10).plusMinutes(20), season, Mode.TOURNAMENT); + TournamentGame tournamentGame = testDataUtils.createTournamentGame(testTournament, round, gameInfoDto); + } + } - @Nested - @DisplayName("토너먼트_게임_리스트_조회") - class findTournamentGameTest { + @Nested + @DisplayName("토너먼트_게임_리스트_조회") + class FindTournamentGameTest { - @Test - @DisplayName("[Get] pingpong/tournaments/{tournamentId}/games") - public void getTournamentGames() throws Exception { + @Test + @DisplayName("[Get] pingpong/tournaments/{tournamentId}/games") + public void getTournamentGames() throws Exception { - // given - String url = tournamentUrl + testTournament.getId() + "/games"; + // given + String url = tournamentUrl + testTournament.getId() + "/games"; - // when - String contentAsString = mockMvc.perform(get(url).header("Authorization", "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - TournamentGameListResponseDto resp = objectMapper.readValue(contentAsString, TournamentGameListResponseDto.class); + // when + String contentAsString = mockMvc.perform(get(url).header("Authorization", "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + TournamentGameListResponseDto resp = objectMapper.readValue(contentAsString, + TournamentGameListResponseDto.class); - // then - assertThat(resp.getTournamentId()).isEqualTo(testTournament.getId()); - assertThat(resp.getGames().size()).isEqualTo(TournamentRound.values().length); - for (TournamentGameResDto tournamentGameResDto : resp.getGames()) { - assertThat(tournamentGameResDto.getTournamentGameId()).isNotNull(); - assertThat(tournamentGameResDto.getTournamentRound()).isNotNull(); - if (!Objects.equals(tournamentGameResDto.getTournamentRound(), TournamentRound.THE_FINAL)) { - assertThat(tournamentGameResDto.getNextTournamentGameId()).isNotNull(); - } - } - } - } + // then + assertThat(resp.getTournamentId()).isEqualTo(testTournament.getId()); + assertThat(resp.getGames().size()).isEqualTo(TournamentRound.values().length); + for (TournamentGameResDto tournamentGameResDto : resp.getGames()) { + assertThat(tournamentGameResDto.getTournamentGameId()).isNotNull(); + assertThat(tournamentGameResDto.getTournamentRound()).isNotNull(); + if (!Objects.equals(tournamentGameResDto.getTournamentRound(), TournamentRound.THE_FINAL)) { + assertThat(tournamentGameResDto.getNextTournamentGameId()).isNotNull(); + } + } + } + } } diff --git a/src/test/java/com/gg/server/domain/tournament/controller/TournamentSchedulerTest.java b/src/test/java/com/gg/server/domain/tournament/controller/TournamentSchedulerTest.java index 2003e9029..413cb8993 100644 --- a/src/test/java/com/gg/server/domain/tournament/controller/TournamentSchedulerTest.java +++ b/src/test/java/com/gg/server/domain/tournament/controller/TournamentSchedulerTest.java @@ -1,113 +1,111 @@ package com.gg.server.domain.tournament.controller; +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Mockito.*; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.transaction.annotation.Transactional; + import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; import com.gg.server.admin.noti.service.NotiAdminService; -import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; import com.gg.server.domain.tournament.data.Tournament; import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.data.TournamentGameRepository; -import com.gg.server.domain.tournament.data.TournamentRepository; import com.gg.server.domain.tournament.service.TournamentService; import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.global.scheduler.TournamentScheduler; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; - -import static org.assertj.core.api.Assertions.*; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; @IntegrationTest @Transactional public class TournamentSchedulerTest { - @Autowired - TournamentService tournamentService; - @Autowired - TestDataUtils testDataUtils; - @Autowired - SlotManagementRepository slotManagementRepository; - @Autowired - TournamentGameRepository tournamentGameRepository; - @MockBean - NotiAdminService notiAdminService; + @Autowired + TournamentService tournamentService; + @Autowired + TestDataUtils testDataUtils; + @Autowired + SlotManagementRepository slotManagementRepository; + @Autowired + TournamentGameRepository tournamentGameRepository; + @MockBean + NotiAdminService notiAdminService; - @Nested - @DisplayName("토너먼트 스케줄러 테스트") - class tournamentSchedulerTest { - @Test - @DisplayName("토너먼트 시작 성공") - public void startTournamentTest() { - // given - testDataUtils.createSeason(); - // BEFORE로 토너먼트 생성 - Tournament tournament = testDataUtils.createTournamentWithUser(Tournament.ALLOWED_JOINED_NUMBER, 4, "test"); - List tournamentGameList = testDataUtils.createTournamentGameList(tournament, 7); - SlotManagement slotManagement = SlotManagement.builder() - .pastSlotTime(0) - .futureSlotTime(0) - .openMinute(0) - .gameInterval(15) - .startTime(LocalDateTime.now().minusHours(1)) - .build(); - slotManagementRepository.save(slotManagement); + @Nested + @DisplayName("토너먼트 스케줄러 테스트") + class TournamentSchedulerTests { + @Test + @DisplayName("토너먼트 시작 성공") + public void startTournamentTest() { + // given + testDataUtils.createSeason(); + // BEFORE로 토너먼트 생성 + Tournament tournament = testDataUtils.createTournamentWithUser(Tournament.ALLOWED_JOINED_NUMBER, 4, "test"); + List tournamentGameList = testDataUtils.createTournamentGameList(tournament, 7); + SlotManagement slotManagement = SlotManagement.builder() + .pastSlotTime(0) + .futureSlotTime(0) + .openMinute(0) + .gameInterval(15) + .startTime(LocalDateTime.now().minusHours(1)) + .build(); + slotManagementRepository.save(slotManagement); - // when - tournamentService.startTournament(); + // when + tournamentService.startTournament(); - // then - // 토너먼트의 상태가 LIVE로 변경되었는지 확인 - assertThat(tournament.getStatus()) - .isEqualTo(TournamentStatus.LIVE); + // then + // 토너먼트의 상태가 LIVE로 변경되었는지 확인 + assertThat(tournament.getStatus()) + .isEqualTo(TournamentStatus.LIVE); - // game이 생성되었는지 확인 - List tournamentGames = tournamentGameRepository.findAllByTournamentId(tournament.getId()).stream() - .filter(o -> o.getGame() != null) - .collect(Collectors.toList()); - assertThat(tournamentGames.size()).isEqualTo(Tournament.ALLOWED_JOINED_NUMBER / 2); - for (TournamentGame tournamentGame : tournamentGames) { - assertThat(tournamentGame.getGame()).isNotNull(); - } - //참가자에게 토너먼트 시작 및 매칭 알림이 전송되었는지 확인 - verify(notiAdminService, times(Tournament.ALLOWED_JOINED_NUMBER)).sendAnnounceNotiToUser(Mockito.any(SendNotiAdminRequestDto.class)); - } + // game이 생성되었는지 확인 + List tournamentGames = tournamentGameRepository.findAllByTournamentId(tournament.getId()) + .stream() + .filter(o -> o.getGame() != null) + .collect(Collectors.toList()); + assertThat(tournamentGames.size()).isEqualTo(Tournament.ALLOWED_JOINED_NUMBER / 2); + for (TournamentGame tournamentGame : tournamentGames) { + assertThat(tournamentGame.getGame()).isNotNull(); + } + //참가자에게 토너먼트 시작 및 매칭 알림이 전송되었는지 확인 + verify(notiAdminService, times(Tournament.ALLOWED_JOINED_NUMBER)).sendAnnounceNotiToUser( + Mockito.any(SendNotiAdminRequestDto.class)); + } - @Test - @DisplayName("토너먼트 취소 성공") - public void cancelTournamentTest() { - // given - testDataUtils.createSeason(); - // BEFORE로 토너먼트 생성 - Tournament tournament = testDataUtils.createTournamentWithUser(7, 0, "test"); - SlotManagement slotManagement = SlotManagement.builder() - .pastSlotTime(0) - .futureSlotTime(0) - .openMinute(0) - .gameInterval(15) - .startTime(LocalDateTime.now().minusHours(1)) - .build(); - slotManagementRepository.save(slotManagement); + @Test + @DisplayName("토너먼트 취소 성공") + public void cancelTournamentTest() { + // given + testDataUtils.createSeason(); + // BEFORE로 토너먼트 생성 + Tournament tournament = testDataUtils.createTournamentWithUser(7, 0, "test"); + SlotManagement slotManagement = SlotManagement.builder() + .pastSlotTime(0) + .futureSlotTime(0) + .openMinute(0) + .gameInterval(15) + .startTime(LocalDateTime.now().minusHours(1)) + .build(); + slotManagementRepository.save(slotManagement); - // when - tournamentService.startTournament(); + // when + tournamentService.startTournament(); - // then - //참가자에게 취소 알림이 전송되었는지 확인 - verify(notiAdminService, times(7)).sendAnnounceNotiToUser(Mockito.any(SendNotiAdminRequestDto.class)); - } - } + // then + //참가자에게 취소 알림이 전송되었는지 확인 + verify(notiAdminService, times(7)).sendAnnounceNotiToUser(Mockito.any(SendNotiAdminRequestDto.class)); + } + } } diff --git a/src/test/java/com/gg/server/domain/tournament/data/TournamentGameUnitTest.java b/src/test/java/com/gg/server/domain/tournament/data/TournamentGameUnitTest.java index bd2cdd397..6986213b8 100644 --- a/src/test/java/com/gg/server/domain/tournament/data/TournamentGameUnitTest.java +++ b/src/test/java/com/gg/server/domain/tournament/data/TournamentGameUnitTest.java @@ -1,31 +1,35 @@ package com.gg.server.domain.tournament.data; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + import com.gg.server.domain.game.data.Game; import com.gg.server.utils.annotation.UnitTest; -import org.junit.jupiter.api.*; -import org.mockito.Mockito; @UnitTest @DisplayName("TournamentGameUnitTest") public class TournamentGameUnitTest { - TournamentGame tournamentGame; + TournamentGame tournamentGame; - @Nested - @DisplayName("UpdateGame") - class UpdateGame { - @Test - @DisplayName("TournamentGame의 게임 업데이트 성공") - void updateSuccess() { - //given - tournamentGame = new TournamentGame(); - Game game = Mockito.mock(Game.class); + @Nested + @DisplayName("UpdateGame") + class UpdateGame { + @Test + @DisplayName("TournamentGame의 게임 업데이트 성공") + void updateSuccess() { + //given + tournamentGame = new TournamentGame(); + Game game = Mockito.mock(Game.class); - //when - tournamentGame.updateGame(game); + //when + tournamentGame.updateGame(game); - //then - Assertions.assertEquals(game, tournamentGame.getGame()); - } - } + //then + Assertions.assertEquals(game, tournamentGame.getGame()); + } + } } diff --git a/src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java b/src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java index c7de7468c..5491c02f4 100644 --- a/src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java +++ b/src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java @@ -1,353 +1,353 @@ package com.gg.server.domain.tournament.data; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.mock; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.user.data.User; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; -import com.gg.server.utils.annotation.UnitTest; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import com.gg.server.domain.tournament.type.TournamentStatus; +import com.gg.server.domain.user.data.User; +import com.gg.server.global.exception.ErrorCode; +import com.gg.server.global.exception.custom.BusinessException; +import com.gg.server.utils.annotation.UnitTest; @UnitTest @DisplayName("TournamentUnitTest") class TournamentUnitTest { - List mockTournamentGames; - List mockTournamentUsers; - List tournaments; - - @BeforeEach - void setUp() { - mockTournamentGames = IntStream.range(0, 10) - .mapToObj(i -> mock(TournamentGame.class)) - .collect(Collectors.toCollection(ArrayList::new)); - - mockTournamentUsers = IntStream.range(0, 10) - .mapToObj(i -> mock(TournamentUser.class)) - .collect(Collectors.toCollection(ArrayList::new)); - - tournaments = IntStream.range(0, 10) - .mapToObj(i -> new Tournament()) - .collect(Collectors.toCollection(ArrayList::new)); - } - - @Nested - @DisplayName("AddTournamentGame") - class AddTournamentGame { - - @Test - @DisplayName("단일 TournamentGame 추가 성공") - public void addSingleTournamentGameSuccess() { - //given - Tournament tournament = tournaments.get(0); - TournamentGame mockTournamentGame = mockTournamentGames.get(0); - - //when - tournament.addTournamentGame(mockTournamentGame); - - //then - assertEquals(1, tournament.getTournamentGames().size()); - assertEquals(mockTournamentGame, tournament.getTournamentGames().get(0)); - } - - @Test - @DisplayName("최대 TournamentGame 추가 성공") - void addMultiTournamentGameSuccess() { - //given - Tournament tournament = tournaments.get(0); - - //when - IntStream.range(0, 7).forEach(i -> tournament.addTournamentGame(mockTournamentGames.get(i))); - - //then - assertEquals(7, tournament.getTournamentGames().size()); - IntStream.range(0, 7).forEach(i -> - assertEquals(mockTournamentGames.get(i), tournament.getTournamentGames().get(i))); - } - - @Test - @DisplayName("최대 이상의 TournamentGame 추가 실패") - void addExceedTournamentGameFailed() { - //given - Tournament tournament = tournaments.get(0); - - //when - IntStream.range(0, 7).forEach(i -> tournament.addTournamentGame(mockTournamentGames.get(i))); - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> tournament.addTournamentGame(mockTournamentGames.get(7))); - assertEquals(ErrorCode.TOURNAMENT_GAME_EXCEED, businessException.getErrorCode()); - assertEquals(ErrorCode.TOURNAMENT_GAME_EXCEED.getMessage(), businessException.getMessage()); - } - - @Test - @DisplayName("동일한 TournamentGame 추가 실패") - void duplicatedTournamentGameAddFailed() { - //given - Tournament tournament = tournaments.get(0); - - //when - tournament.addTournamentGame(mockTournamentGames.get(0)); - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> tournament.addTournamentGame(mockTournamentGames.get(0))); - assertEquals(ErrorCode.TOURNAMENT_GAME_DUPLICATION, businessException.getErrorCode()); - assertEquals(ErrorCode.TOURNAMENT_GAME_DUPLICATION.getMessage(), - businessException.getMessage()); - } - - @Test - @DisplayName("null 포인터 전달 시 실패") - void nullAddFailed() { - //given - Tournament tournament = tournaments.get(0); - - //when - TournamentGame tournamentGame = null; - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> tournament.addTournamentGame(tournamentGame)); - assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); - assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); - } - } - - @Nested - @DisplayName("AddTournamentUser") - class AddTournamentUser { - - @Test - @DisplayName("단일 TournamentUser 추가 성공") - public void addSingleTournamentGameSuccess() { - //given - Tournament tournament = tournaments.get(0); - TournamentUser mockTournamentUser = mockTournamentUsers.get(0); - - //when - tournament.addTournamentUser(mockTournamentUser); - - //then - assertEquals(1, tournament.getTournamentUsers().size()); - assertEquals(mockTournamentUser, tournament.getTournamentUsers().get(0)); - } - - @Test - @DisplayName("여러 TournamentUser 추가 성공") - void addMultiTournamentGameSuccess() { - //given - Tournament tournament = tournaments.get(0); - - //when - IntStream.range(0, mockTournamentUsers.size()).forEach(i -> - tournament.addTournamentUser(mockTournamentUsers.get(i))); - - //then - assertEquals(mockTournamentUsers.size(), tournament.getTournamentUsers().size()); - IntStream.range(0, mockTournamentUsers.size()).forEach(i -> - assertEquals(mockTournamentUsers.get(i), tournament.getTournamentUsers().get(i))); - } - - @Test - @DisplayName("동일한 TournamentUser 추가 실패") - void duplicatedTournamentGameAddFailed() { - //given - Tournament tournament = tournaments.get(0); - - //when - tournament.addTournamentUser(mockTournamentUsers.get(0)); - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> tournament.addTournamentUser(mockTournamentUsers.get(0))); - assertEquals(ErrorCode.TOURNAMENT_USER_DUPLICATION, businessException.getErrorCode()); - assertEquals(ErrorCode.TOURNAMENT_USER_DUPLICATION.getMessage(), - businessException.getMessage()); - } - - @Test - @DisplayName("null 포인터 전달 시 실패") - void nullAddFailed() { - //given - Tournament tournament = tournaments.get(0); - - //when - TournamentUser tournamentUser = null; - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> tournament.addTournamentUser(tournamentUser)); - assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); - assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); - } - } - - @Nested - @DisplayName("DeleteTournamentUser") - class DeleteTournamentUser { - - @Test - @DisplayName("TournamentUser 삭제 성공") - public void addSingleTournamentGameSuccess() { - //given - Tournament tournament = tournaments.get(0); - TournamentUser mockTournamentUser = mockTournamentUsers.get(0); - tournament.addTournamentUser(mockTournamentUser); - - //when - tournament.deleteTournamentUser(mockTournamentUser); - - //then - assertEquals(0, tournament.getTournamentUsers().size()); - } - - @Test - @DisplayName("존재하지 않는 TournamentUser 삭제 실패") - void duplicatedTournamentGameAddFailed() { - //given - Tournament tournament = tournaments.get(0); - - //when - tournament.addTournamentUser(mockTournamentUsers.get(0)); - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> tournament.deleteTournamentUser(mockTournamentUsers.get(1))); - assertEquals(ErrorCode.TOURNAMENT_USER_NOT_FOUND, businessException.getErrorCode()); - assertEquals(ErrorCode.TOURNAMENT_USER_NOT_FOUND.getMessage(), - businessException.getMessage()); - } - - @Test - @DisplayName("null 포인터 전달 시 실패") - void nullAddFailed() { - //given - Tournament tournament = tournaments.get(0); - - //when - TournamentUser tournamentUser = null; - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> tournament.deleteTournamentUser(tournamentUser)); - assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); - assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); - } - } - - @Nested - @DisplayName("UpdateWinner") - class UpdateWinner { - @Test - @DisplayName("null 포인터 전달 시 실패") - void nullAddFailed() { - //given - Tournament tournament = tournaments.get(0); - - //when - User user = null; - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> tournament.updateWinner(user)); - assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); - assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); - } - - @Test - @DisplayName("승자 업데이트 성공") - void updateSuccess() { - //given - Tournament tournament = tournaments.get(0); - User user = mock(User.class); - - //when - tournament.updateWinner(user); - - //then - assertEquals(user, tournament.getWinner()); - } - } - - @Nested - @DisplayName("UpdateStatus") - class UpdateStatus { - @Test - @DisplayName("null 포인터 전달 시 실패") - void nullAddFailed() { - //given - Tournament tournament = tournaments.get(0); - - //when - TournamentStatus status = null; - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> tournament.updateStatus(status)); - assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); - assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); - } - - @Test - @DisplayName("상태 업데이트 성공") - void updateSuccess() { - //given - Tournament tournament = tournaments.get(0); - TournamentStatus status = TournamentStatus.LIVE; - - //when - tournament.updateStatus(status); - - //then - assertEquals(status, tournament.getStatus()); - } - } - - @Nested - @DisplayName("UpdateStatus") - class UpdateEndTime { - @Test - @DisplayName("null 포인터 전달 시 실패") - void nullAddFailed() { - //given - Tournament tournament = tournaments.get(0); - - //when - LocalDateTime endTime = null; - - //then - BusinessException businessException = assertThrows(BusinessException.class, - () -> tournament.updateEndTime(endTime)); - assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); - assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); - } - - @Test - @DisplayName("endTime 업데이트 성공") - void updateEndTimeSuccess() { - //given - Tournament tournament = tournaments.get(0); - LocalDateTime endTime = LocalDateTime.now().withMinute(0).withNano(0); - - //when - tournament.updateEndTime(endTime); - - //then - assertEquals(endTime, tournament.getEndTime()); - } - } -} \ No newline at end of file + List mockTournamentGames; + List mockTournamentUsers; + List tournaments; + + @BeforeEach + void setUp() { + mockTournamentGames = IntStream.range(0, 10) + .mapToObj(i -> mock(TournamentGame.class)) + .collect(Collectors.toCollection(ArrayList::new)); + + mockTournamentUsers = IntStream.range(0, 10) + .mapToObj(i -> mock(TournamentUser.class)) + .collect(Collectors.toCollection(ArrayList::new)); + + tournaments = IntStream.range(0, 10) + .mapToObj(i -> new Tournament()) + .collect(Collectors.toCollection(ArrayList::new)); + } + + @Nested + @DisplayName("AddTournamentGame") + class AddTournamentGame { + + @Test + @DisplayName("단일 TournamentGame 추가 성공") + public void addSingleTournamentGameSuccess() { + //given + Tournament tournament = tournaments.get(0); + TournamentGame mockTournamentGame = mockTournamentGames.get(0); + + //when + tournament.addTournamentGame(mockTournamentGame); + + //then + assertEquals(1, tournament.getTournamentGames().size()); + assertEquals(mockTournamentGame, tournament.getTournamentGames().get(0)); + } + + @Test + @DisplayName("최대 TournamentGame 추가 성공") + void addMultiTournamentGameSuccess() { + //given + Tournament tournament = tournaments.get(0); + + //when + IntStream.range(0, 7).forEach(i -> tournament.addTournamentGame(mockTournamentGames.get(i))); + + //then + assertEquals(7, tournament.getTournamentGames().size()); + IntStream.range(0, 7).forEach(i -> + assertEquals(mockTournamentGames.get(i), tournament.getTournamentGames().get(i))); + } + + @Test + @DisplayName("최대 이상의 TournamentGame 추가 실패") + void addExceedTournamentGameFailed() { + //given + Tournament tournament = tournaments.get(0); + + //when + IntStream.range(0, 7).forEach(i -> tournament.addTournamentGame(mockTournamentGames.get(i))); + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> tournament.addTournamentGame(mockTournamentGames.get(7))); + assertEquals(ErrorCode.TOURNAMENT_GAME_EXCEED, businessException.getErrorCode()); + assertEquals(ErrorCode.TOURNAMENT_GAME_EXCEED.getMessage(), businessException.getMessage()); + } + + @Test + @DisplayName("동일한 TournamentGame 추가 실패") + void duplicatedTournamentGameAddFailed() { + //given + Tournament tournament = tournaments.get(0); + + //when + tournament.addTournamentGame(mockTournamentGames.get(0)); + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> tournament.addTournamentGame(mockTournamentGames.get(0))); + assertEquals(ErrorCode.TOURNAMENT_GAME_DUPLICATION, businessException.getErrorCode()); + assertEquals(ErrorCode.TOURNAMENT_GAME_DUPLICATION.getMessage(), + businessException.getMessage()); + } + + @Test + @DisplayName("null 포인터 전달 시 실패") + void nullAddFailed() { + //given + Tournament tournament = tournaments.get(0); + + //when + TournamentGame tournamentGame = null; + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> tournament.addTournamentGame(tournamentGame)); + assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); + assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); + } + } + + @Nested + @DisplayName("AddTournamentUser") + class AddTournamentUser { + + @Test + @DisplayName("단일 TournamentUser 추가 성공") + public void addSingleTournamentGameSuccess() { + //given + Tournament tournament = tournaments.get(0); + TournamentUser mockTournamentUser = mockTournamentUsers.get(0); + + //when + tournament.addTournamentUser(mockTournamentUser); + + //then + assertEquals(1, tournament.getTournamentUsers().size()); + assertEquals(mockTournamentUser, tournament.getTournamentUsers().get(0)); + } + + @Test + @DisplayName("여러 TournamentUser 추가 성공") + void addMultiTournamentGameSuccess() { + //given + Tournament tournament = tournaments.get(0); + + //when + IntStream.range(0, mockTournamentUsers.size()).forEach(i -> + tournament.addTournamentUser(mockTournamentUsers.get(i))); + + //then + assertEquals(mockTournamentUsers.size(), tournament.getTournamentUsers().size()); + IntStream.range(0, mockTournamentUsers.size()).forEach(i -> + assertEquals(mockTournamentUsers.get(i), tournament.getTournamentUsers().get(i))); + } + + @Test + @DisplayName("동일한 TournamentUser 추가 실패") + void duplicatedTournamentGameAddFailed() { + //given + Tournament tournament = tournaments.get(0); + + //when + tournament.addTournamentUser(mockTournamentUsers.get(0)); + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> tournament.addTournamentUser(mockTournamentUsers.get(0))); + assertEquals(ErrorCode.TOURNAMENT_USER_DUPLICATION, businessException.getErrorCode()); + assertEquals(ErrorCode.TOURNAMENT_USER_DUPLICATION.getMessage(), + businessException.getMessage()); + } + + @Test + @DisplayName("null 포인터 전달 시 실패") + void nullAddFailed() { + //given + Tournament tournament = tournaments.get(0); + + //when + TournamentUser tournamentUser = null; + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> tournament.addTournamentUser(tournamentUser)); + assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); + assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); + } + } + + @Nested + @DisplayName("DeleteTournamentUser") + class DeleteTournamentUser { + + @Test + @DisplayName("TournamentUser 삭제 성공") + public void addSingleTournamentGameSuccess() { + //given + Tournament tournament = tournaments.get(0); + TournamentUser mockTournamentUser = mockTournamentUsers.get(0); + tournament.addTournamentUser(mockTournamentUser); + + //when + tournament.deleteTournamentUser(mockTournamentUser); + + //then + assertEquals(0, tournament.getTournamentUsers().size()); + } + + @Test + @DisplayName("존재하지 않는 TournamentUser 삭제 실패") + void duplicatedTournamentGameAddFailed() { + //given + Tournament tournament = tournaments.get(0); + + //when + tournament.addTournamentUser(mockTournamentUsers.get(0)); + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> tournament.deleteTournamentUser(mockTournamentUsers.get(1))); + assertEquals(ErrorCode.TOURNAMENT_USER_NOT_FOUND, businessException.getErrorCode()); + assertEquals(ErrorCode.TOURNAMENT_USER_NOT_FOUND.getMessage(), + businessException.getMessage()); + } + + @Test + @DisplayName("null 포인터 전달 시 실패") + void nullAddFailed() { + //given + Tournament tournament = tournaments.get(0); + + //when + TournamentUser tournamentUser = null; + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> tournament.deleteTournamentUser(tournamentUser)); + assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); + assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); + } + } + + @Nested + @DisplayName("UpdateWinner") + class UpdateWinner { + @Test + @DisplayName("null 포인터 전달 시 실패") + void nullAddFailed() { + //given + Tournament tournament = tournaments.get(0); + + //when + User user = null; + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> tournament.updateWinner(user)); + assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); + assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); + } + + @Test + @DisplayName("승자 업데이트 성공") + void updateSuccess() { + //given + Tournament tournament = tournaments.get(0); + User user = mock(User.class); + + //when + tournament.updateWinner(user); + + //then + assertEquals(user, tournament.getWinner()); + } + } + + @Nested + @DisplayName("UpdateStatus") + class UpdateStatus { + @Test + @DisplayName("null 포인터 전달 시 실패") + void nullAddFailed() { + //given + Tournament tournament = tournaments.get(0); + + //when + TournamentStatus status = null; + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> tournament.updateStatus(status)); + assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); + assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); + } + + @Test + @DisplayName("상태 업데이트 성공") + void updateSuccess() { + //given + Tournament tournament = tournaments.get(0); + TournamentStatus status = TournamentStatus.LIVE; + + //when + tournament.updateStatus(status); + + //then + assertEquals(status, tournament.getStatus()); + } + } + + @Nested + @DisplayName("UpdateStatus") + class UpdateEndTime { + @Test + @DisplayName("null 포인터 전달 시 실패") + void nullAddFailed() { + //given + Tournament tournament = tournaments.get(0); + + //when + LocalDateTime endTime = null; + + //then + BusinessException businessException = assertThrows(BusinessException.class, + () -> tournament.updateEndTime(endTime)); + assertEquals(ErrorCode.NULL_POINT, businessException.getErrorCode()); + assertEquals(ErrorCode.NULL_POINT.getMessage(), businessException.getMessage()); + } + + @Test + @DisplayName("endTime 업데이트 성공") + void updateEndTimeSuccess() { + //given + Tournament tournament = tournaments.get(0); + LocalDateTime endTime = LocalDateTime.now().withMinute(0).withNano(0); + + //when + tournament.updateEndTime(endTime); + + //then + assertEquals(endTime, tournament.getEndTime()); + } + } +} diff --git a/src/test/java/com/gg/server/domain/tournament/data/TournamentUserUnitTest.java b/src/test/java/com/gg/server/domain/tournament/data/TournamentUserUnitTest.java index 6026f73d9..1ca91031a 100644 --- a/src/test/java/com/gg/server/domain/tournament/data/TournamentUserUnitTest.java +++ b/src/test/java/com/gg/server/domain/tournament/data/TournamentUserUnitTest.java @@ -1,56 +1,57 @@ package com.gg.server.domain.tournament.data; -import com.gg.server.domain.user.data.User; -import com.gg.server.utils.annotation.UnitTest; +import java.time.LocalDateTime; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import java.time.LocalDateTime; +import com.gg.server.domain.user.data.User; +import com.gg.server.utils.annotation.UnitTest; @UnitTest @DisplayName("TournamentUserUnitTest") public class TournamentUserUnitTest { - Tournament tournament; - TournamentUser tournamentUser; - User user; - - @Nested - @DisplayName("DeleteTournament") - class DeleteTournament { - @Test - @DisplayName("토너먼트 삭제 성공") - void deleteSuccess() { - //given - user = Mockito.mock(User.class); - tournament = new Tournament(); - tournamentUser = new TournamentUser(user, tournament, false, LocalDateTime.now()); - - //when - tournamentUser.deleteTournament(); - - //then - Assertions.assertNull(tournamentUser.getTournament()); - } - } - - @Nested - @DisplayName("UpdateIsJoined") - class UpdateIsJoined { - @Test - @DisplayName("참가 정보 업데이트 성공") - void updateSuccess() { - //given - tournamentUser = new TournamentUser(); - boolean isjoined = true; - - //when - tournamentUser.updateIsJoined(isjoined); - - //then - Assertions.assertEquals(isjoined, tournamentUser.getIsJoined()); - } - } + Tournament tournament; + TournamentUser tournamentUser; + User user; + + @Nested + @DisplayName("DeleteTournament") + class DeleteTournament { + @Test + @DisplayName("토너먼트 삭제 성공") + void deleteSuccess() { + //given + user = Mockito.mock(User.class); + tournament = new Tournament(); + tournamentUser = new TournamentUser(user, tournament, false, LocalDateTime.now()); + + //when + tournamentUser.deleteTournament(); + + //then + Assertions.assertNull(tournamentUser.getTournament()); + } + } + + @Nested + @DisplayName("UpdateIsJoined") + class UpdateIsJoined { + @Test + @DisplayName("참가 정보 업데이트 성공") + void updateSuccess() { + //given + tournamentUser = new TournamentUser(); + boolean isjoined = true; + + //when + tournamentUser.updateIsJoined(isjoined); + + //then + Assertions.assertEquals(isjoined, tournamentUser.getIsJoined()); + } + } } diff --git a/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceTest.java b/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceTest.java index f0e384d9d..3c33a25be 100644 --- a/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceTest.java +++ b/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceTest.java @@ -1,8 +1,21 @@ package com.gg.server.domain.tournament.service; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; +import static org.assertj.core.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; @@ -27,261 +40,253 @@ import com.gg.server.domain.user.type.SnsType; import com.gg.server.utils.ReflectionUtilsForUnitTest; import com.gg.server.utils.annotation.UnitTest; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; @UnitTest @ExtendWith(MockitoExtension.class) class TournamentServiceTest { - @Mock - TournamentRepository tournamentRepository; - @Mock - TournamentGameRepository tournamentGameRepository; - @Mock - TournamentUserRepository tournamentUserRepository; - @Mock - UserRepository userRepository; - @InjectMocks - TournamentService tournamentService; + @Mock + TournamentRepository tournamentRepository; + @Mock + TournamentGameRepository tournamentGameRepository; + @Mock + TournamentUserRepository tournamentUserRepository; + @Mock + UserRepository userRepository; + @InjectMocks + TournamentService tournamentService; - @Nested - @DisplayName("토너먼트_유저_상태_테스트") - class UserStatusInTournamentTest { - @Test - @DisplayName("유저_상태_반환_성공") - void success() { - // given - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - LocalDateTime.now(), LocalDateTime.now().plusHours(2)); - User user = createUser("testUser"); - TournamentUser tournamentUser = new TournamentUser(user, tournament, true, LocalDateTime.now()); - given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); - given(tournamentUserRepository.findByTournamentIdAndUserId(tournament.getId(), user.getId())) - .willReturn(Optional.of(tournamentUser)); + @Nested + @DisplayName("토너먼트_유저_상태_테스트") + class UserStatusInTournamentTest { + @Test + @DisplayName("유저_상태_반환_성공") + void success() { + // given + Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, + LocalDateTime.now(), LocalDateTime.now().plusHours(2)); + User user = createUser("testUser"); + TournamentUser tournamentUser = new TournamentUser(user, tournament, true, LocalDateTime.now()); + given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); + given(tournamentUserRepository.findByTournamentIdAndUserId(tournament.getId(), user.getId())) + .willReturn(Optional.of(tournamentUser)); - // when, then - TournamentUserRegistrationResponseDto responseDto = - tournamentService.getUserStatusInTournament(tournament.getId(), UserDto.from(user)); - } + // when, then + TournamentUserRegistrationResponseDto responseDto = + tournamentService.getUserStatusInTournament(tournament.getId(), UserDto.from(user)); + } - @Test - @DisplayName("찾을_수_없는_토너먼트") - void tournamentNotFound() { - // given - Long tournamentId = 1L; - User user = createUser("testUser"); - given(tournamentRepository.findById(tournamentId)).willReturn(Optional.empty()); + @Test + @DisplayName("찾을_수_없는_토너먼트") + void tournamentNotFound() { + // given + Long tournamentId = 1L; + User user = createUser("testUser"); + given(tournamentRepository.findById(tournamentId)).willReturn(Optional.empty()); - // when, then - assertThatThrownBy(() -> tournamentService.getUserStatusInTournament(tournamentId, UserDto.from(user))) - .isInstanceOf(TournamentNotFoundException.class); - } - } + // when, then + assertThatThrownBy(() -> tournamentService.getUserStatusInTournament(tournamentId, UserDto.from(user))) + .isInstanceOf(TournamentNotFoundException.class); + } + } - @Nested - @DisplayName("토너먼트_유저_신청_테스트") - class RegisterTournamentUserTest { - @Test - @DisplayName("유저_상태_추가_성공") - void success() { - // given - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - LocalDateTime.now(), LocalDateTime.now().plusHours(2)); - User user = createUser("testUser"); - List tournamentUserList = new ArrayList<>(); - given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); - given(userRepository.findById(user.getId())).willReturn(Optional.of(user)); - given(tournamentUserRepository.findAllByUser(any(User.class))).willReturn(tournamentUserList); + @Nested + @DisplayName("토너먼트_유저_신청_테스트") + class RegisterTournamentUserTest { + @Test + @DisplayName("유저_상태_추가_성공") + void success() { + // given + Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, + LocalDateTime.now(), LocalDateTime.now().plusHours(2)); + User user = createUser("testUser"); + List tournamentUserList = new ArrayList<>(); + given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); + given(userRepository.findById(user.getId())).willReturn(Optional.of(user)); + given(tournamentUserRepository.findAllByUser(any(User.class))).willReturn(tournamentUserList); - // when, then - TournamentUserRegistrationResponseDto responseDto = - tournamentService.registerTournamentUser(tournament.getId(), UserDto.from(user)); - } + // when, then + TournamentUserRegistrationResponseDto responseDto = + tournamentService.registerTournamentUser(tournament.getId(), UserDto.from(user)); + } - @Test - @DisplayName("찾을_수_없는_토너먼트") - void tournamentNotFound() { - // given - User user = createUser("testUser"); - given(tournamentRepository.findById(any(Long.class))).willReturn(Optional.empty()); + @Test + @DisplayName("찾을_수_없는_토너먼트") + void tournamentNotFound() { + // given + User user = createUser("testUser"); + given(tournamentRepository.findById(any(Long.class))).willReturn(Optional.empty()); - // when, then - assertThatThrownBy(()->tournamentService.registerTournamentUser(1L, UserDto.from(user))) - .isInstanceOf(TournamentNotFoundException.class); - } + // when, then + assertThatThrownBy(() -> tournamentService.registerTournamentUser(1L, UserDto.from(user))) + .isInstanceOf(TournamentNotFoundException.class); + } - @Test - @DisplayName("db에_없는_유저") - void userNotFound() { - // given - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - LocalDateTime.now(), LocalDateTime.now().plusHours(2)); - User user = createUser("testUser"); - given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); - given(userRepository.findById(null)).willReturn(Optional.empty()); + @Test + @DisplayName("db에_없는_유저") + void userNotFound() { + // given + Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, + LocalDateTime.now(), LocalDateTime.now().plusHours(2)); + User user = createUser("testUser"); + given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); + given(userRepository.findById(null)).willReturn(Optional.empty()); - // when, then - assertThatThrownBy(()->tournamentService.registerTournamentUser(tournament.getId(), UserDto.from(user))) - .isInstanceOf(UserNotFoundException.class); - } + // when, then + assertThatThrownBy(() -> tournamentService.registerTournamentUser(tournament.getId(), UserDto.from(user))) + .isInstanceOf(UserNotFoundException.class); + } - @Test - @DisplayName("이미_신청한_토너먼트_존재") - void conflictedRegistration() { - // given - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - LocalDateTime.now(), LocalDateTime.now().plusHours(2)); - User user = createUser("testUser"); - List tournamentUserList = new ArrayList<>(); - tournamentUserList.add(new TournamentUser(user, tournament, true, LocalDateTime.now())); - given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); - given(userRepository.findById(user.getId())).willReturn(Optional.of(user)); - given(tournamentUserRepository.findAllByUser(any(User.class))).willReturn(tournamentUserList); + @Test + @DisplayName("이미_신청한_토너먼트_존재") + void conflictedRegistration() { + // given + Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, + LocalDateTime.now(), LocalDateTime.now().plusHours(2)); + User user = createUser("testUser"); + List tournamentUserList = new ArrayList<>(); + tournamentUserList.add(new TournamentUser(user, tournament, true, LocalDateTime.now())); + given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); + given(userRepository.findById(user.getId())).willReturn(Optional.of(user)); + given(tournamentUserRepository.findAllByUser(any(User.class))).willReturn(tournamentUserList); - // when, then - assertThatThrownBy(()->tournamentService.registerTournamentUser(tournament.getId(), UserDto.from(user))) - .isInstanceOf(TournamentConflictException.class); - } - } + // when, then + assertThatThrownBy(() -> tournamentService.registerTournamentUser(tournament.getId(), UserDto.from(user))) + .isInstanceOf(TournamentConflictException.class); + } + } - @Nested - @DisplayName("토너먼트_유저_참가_취소_테스트") - class cancelTournamentUserRegistration { - @Test - @DisplayName("유저_참가_취소_성공") - void success() { - // given - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - LocalDateTime.now(), LocalDateTime.now().plusHours(2)); - User user = createUser("testUser"); - ReflectionUtilsForUnitTest.setFieldWithReflection(user, "id", 1L); - TournamentUser tournamentUser = new TournamentUser(user, tournament, true, LocalDateTime.now()); - given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); + @Nested + @DisplayName("토너먼트_유저_참가_취소_테스트") + class CancelTournamentUserRegistration { + @Test + @DisplayName("유저_참가_취소_성공") + void success() { + // given + Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, + LocalDateTime.now(), LocalDateTime.now().plusHours(2)); + User user = createUser("testUser"); + ReflectionUtilsForUnitTest.setFieldWithReflection(user, "id", 1L); + TournamentUser tournamentUser = new TournamentUser(user, tournament, true, LocalDateTime.now()); + given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); - // when, then - tournamentService.cancelTournamentUserRegistration(tournament.getId(), UserDto.from(user)); - } + // when, then + tournamentService.cancelTournamentUserRegistration(tournament.getId(), UserDto.from(user)); + } - @Test - @DisplayName("찾을_수_없는_토너먼트") - void tournamentNotFound() { - // given - Long tournamentId = 1L; - User user = createUser("testUser"); - given(tournamentRepository.findById(tournamentId)).willReturn(Optional.empty()); + @Test + @DisplayName("찾을_수_없는_토너먼트") + void tournamentNotFound() { + // given + Long tournamentId = 1L; + User user = createUser("testUser"); + given(tournamentRepository.findById(tournamentId)).willReturn(Optional.empty()); - // when, then - assertThatThrownBy(()->tournamentService.cancelTournamentUserRegistration(tournamentId, UserDto.from(user))) - .isInstanceOf(TournamentNotFoundException.class); - } - } + // when, then + assertThatThrownBy( + () -> tournamentService.cancelTournamentUserRegistration(tournamentId, UserDto.from(user))) + .isInstanceOf(TournamentNotFoundException.class); + } + } - /** - * 토너먼트 생성 requestDto - * @param startTime 토너먼트 시작 시간 - * @param endTime 토너먼트 종료 시간 - * @return - */ - private TournamentAdminCreateRequestDto createTournamentCreateRequestDto(String title, LocalDateTime startTime, LocalDateTime endTime) { - return new TournamentAdminCreateRequestDto( - title, - "제 1회 루키전 많관부!!", - startTime, - endTime, - TournamentType.ROOKIE - ); - } + /** + * 토너먼트 생성 requestDto + * @param startTime 토너먼트 시작 시간 + * @param endTime 토너먼트 종료 시간 + * @return + */ + private TournamentAdminCreateRequestDto createTournamentCreateRequestDto(String title, LocalDateTime startTime, + LocalDateTime endTime) { + return new TournamentAdminCreateRequestDto( + title, + "제 1회 루키전 많관부!!", + startTime, + endTime, + TournamentType.ROOKIE + ); + } - /** - * 토너먼트 게임 테이블 생성 - * @param tournament 토너먼트 - * @param round 몇 번째 게임인지에 대한 정보 - * @return 새로 생성된 토너먼트 게임 - */ - private TournamentGame createTournamentGame(Tournament tournament, TournamentRound round) { - TournamentGame tournamentGame = new TournamentGame(null, tournament, round); - return tournamentGameRepository.save(tournamentGame); - } + /** + * 토너먼트 게임 테이블 생성 + * @param tournament 토너먼트 + * @param round 몇 번째 게임인지에 대한 정보 + * @return 새로 생성된 토너먼트 게임 + */ + private TournamentGame createTournamentGame(Tournament tournament, TournamentRound round) { + TournamentGame tournamentGame = new TournamentGame(null, tournament, round); + return tournamentGameRepository.save(tournamentGame); + } - /** - * 현재 시간에서 days hours, 만큼 차이나는 시간을 구한다. - * @param days - * @param hours - * @return - */ - private LocalDateTime getTargetTime(long days, long hours) { - return LocalDateTime.now().plusDays(days).plusHours(hours); - } + /** + * 현재 시간에서 days hours, 만큼 차이나는 시간을 구한다. + * @param days + * @param hours + * @return + */ + private LocalDateTime getTargetTime(long days, long hours) { + return LocalDateTime.now().plusDays(days).plusHours(hours); + } - private Tournament createTournament(Long id, TournamentStatus status, LocalDateTime startTime, LocalDateTime endTime) { - Tournament tournament = Tournament.builder() - .title(id + "st tournament") - .contents("") - .startTime(startTime) - .endTime(endTime) - .type(TournamentType.ROOKIE) - .status(status) - .build(); - ReflectionUtilsForUnitTest.setFieldWithReflection(tournament, "id", id); - return tournament; - } + private Tournament createTournament(Long id, TournamentStatus status, LocalDateTime startTime, + LocalDateTime endTime) { + Tournament tournament = Tournament.builder() + .title(id + "st tournament") + .contents("") + .startTime(startTime) + .endTime(endTime) + .type(TournamentType.ROOKIE) + .status(status) + .build(); + ReflectionUtilsForUnitTest.setFieldWithReflection(tournament, "id", id); + return tournament; + } - /** - *
id 부터 cnt개 만큼의 토너먼트 리스트를 반환해준다.
- * 각 토너먼트는 1시간 길이이며, 토너먼트간 1시간의 간격이 있다. - * @param id - * @param cnt - * @param startTime - * @return - */ - private List createTournaments(Long id, long cnt, LocalDateTime startTime) { - List tournamentList = new ArrayList<>(); - for (long i=0; iid 부터 cnt개 만큼의 토너먼트 리스트를 반환해준다.
+ * 각 토너먼트는 1시간 길이이며, 토너먼트간 1시간의 간격이 있다. + * @param id + * @param cnt + * @param startTime + * @return + */ + private List createTournaments(Long id, long cnt, LocalDateTime startTime) { + List tournamentList = new ArrayList<>(); + for (long i = 0; i < cnt; i++) { + tournamentList.add(createTournament(id++, TournamentStatus.BEFORE, + startTime.plusHours(i * 2), startTime.plusHours((i * 2 + 2)))); + } + return tournamentList; + } - /** - * 각 매개변수로 초기화된 TournamentAdminUpdateRequestDto를 반환 - * @param startTime - * @param endTime - * @return - */ - private TournamentAdminUpdateRequestDto createTournamentAdminUpdateRequestDto(LocalDateTime startTime, LocalDateTime endTime) { - return new TournamentAdminUpdateRequestDto( - "tournament changed", - "changed", - startTime, - endTime, - TournamentType.ROOKIE - ); - } + /** + * 각 매개변수로 초기화된 TournamentAdminUpdateRequestDto를 반환 + * @param startTime + * @param endTime + * @return + */ + private TournamentAdminUpdateRequestDto createTournamentAdminUpdateRequestDto(LocalDateTime startTime, + LocalDateTime endTime) { + return new TournamentAdminUpdateRequestDto( + "tournament changed", + "changed", + startTime, + endTime, + TournamentType.ROOKIE + ); + } - /** - * 유저 생성 매서드 - intraId로만 초기화 - * @param intraId - * @return - */ - private User createUser(String intraId) { - return User.builder() - .eMail("email") - .intraId(intraId) - .racketType(RacketType.PENHOLDER) - .snsNotiOpt(SnsType.NONE) - .roleType(RoleType.USER) - .totalExp(1000) - .build(); - } -} \ No newline at end of file + /** + * 유저 생성 매서드 - intraId로만 초기화 + * @param intraId + * @return + */ + private User createUser(String intraId) { + return User.builder() + .eMail("email") + .intraId(intraId) + .racketType(RacketType.PENHOLDER) + .snsNotiOpt(SnsType.NONE) + .roleType(RoleType.USER) + .totalExp(1000) + .build(); + } +} diff --git a/src/test/java/com/gg/server/domain/user/controller/UserControllerTest.java b/src/test/java/com/gg/server/domain/user/controller/UserControllerTest.java index 08ee0be0a..26f2967f0 100644 --- a/src/test/java/com/gg/server/domain/user/controller/UserControllerTest.java +++ b/src/test/java/com/gg/server/domain/user/controller/UserControllerTest.java @@ -1,585 +1,613 @@ -package com.gg.server.domain.user.controller; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.multipart; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.patch; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.put; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.utils.annotation.IntegrationTest; -import com.gg.server.domain.coin.data.CoinHistoryRepository; -import com.gg.server.domain.coin.data.CoinPolicyRepository; -import com.gg.server.domain.coin.service.CoinHistoryService; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.request.RankResultReqDto; -import com.gg.server.domain.game.service.GameService; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.item.data.Item; -import com.gg.server.domain.item.type.ItemType; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.receipt.data.Receipt; -import com.gg.server.domain.receipt.data.ReceiptRepository; -import com.gg.server.domain.receipt.type.ItemStatus; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.tier.data.Tier; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.user.controller.dto.GameInfoDto; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.CoinHistoryResponseDto; -import com.gg.server.domain.user.dto.UserAttendanceResponseDto; -import com.gg.server.domain.user.dto.UserCoinHistoryListResponseDto; -import com.gg.server.domain.user.dto.UserCoinResponseDto; -import com.gg.server.domain.user.dto.UserDetailResponseDto; -import com.gg.server.domain.user.dto.UserHistoryResponseDto; -import com.gg.server.domain.user.dto.UserLiveResponseDto; -import com.gg.server.domain.user.dto.UserModifyRequestDto; -import com.gg.server.domain.user.dto.UserNormalDetailResponseDto; -import com.gg.server.domain.user.dto.UserRankResponseDto; -import com.gg.server.domain.user.dto.UserSearchResponseDto; -import com.gg.server.domain.user.dto.UserTextColorDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.type.BackgroundType; -import com.gg.server.domain.user.type.EdgeType; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.global.utils.UserImageHandler; -import com.gg.server.utils.ItemTestUtils; -import com.gg.server.utils.TestDataUtils; -import java.time.LocalDateTime; -import java.util.Arrays; -import lombok.extern.slf4j.Slf4j; -import org.apache.http.HttpHeaders; -import org.assertj.core.api.Assertions; -import org.assertj.core.api.AssertionsForClassTypes; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.http.MediaType; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import org.springframework.web.multipart.MultipartFile; - -@IntegrationTest -@AutoConfigureMockMvc -@Transactional -@Slf4j -class UserControllerTest { - - @Autowired - TestDataUtils testDataUtils; - - @Autowired - private MockMvc mockMvc; - - @Autowired - ObjectMapper objectMapper; - - @Autowired - AuthTokenProvider tokenProvider; - - @Autowired - UserRepository userRepository; - - @Autowired - RankRedisRepository redisRepository; - - @Autowired - TierRepository tierRepository; - - @Autowired - RankRepository rankRepository; - - @Autowired - SeasonRepository seasonRepository; - - @Autowired - GameRepository gameRepository; - - @Autowired - GameService gameService; - - @Autowired - CoinPolicyRepository coinPolicyRepository; - - @Autowired - CoinHistoryRepository coinHistoryRepository; - - @Autowired - ReceiptRepository receiptRepository; - - @Autowired - CoinHistoryService coinHistoryService; - @Autowired - ItemTestUtils itemTestUtils; - @MockBean - UserImageHandler userImageHandler; - User admin; - - @BeforeEach - public void setUp() { - testDataUtils.createTierSystem("pingpong"); - testDataUtils.createSeason(); - admin = testDataUtils.createAdminUserForItem(); - } - - @AfterEach - public void flushRedis() { - redisRepository.deleteAll(); - } - - @Test - @DisplayName("live") - public void userLiveTest() throws Exception { - String accessToken = testDataUtils.getLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - String liveUrl = "/pingpong/users/live"; - String event = "game"; - int notiCnt = 2; - Mode currentMatchMode = Mode.RANK; - GameInfoDto gameInfo = testDataUtils.addMockDataUserLiveApi(event, notiCnt, currentMatchMode.getCode(), userId); - Game testGame = gameRepository.getById(gameInfo.getGameId()); - - // Rank Live 게임 테스트 - String contentAsString1 = mockMvc.perform(get(liveUrl).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - UserLiveResponseDto userLiveResponseDto1 = objectMapper.readValue(contentAsString1, UserLiveResponseDto.class); - assertThat(userLiveResponseDto1.getEvent()).isEqualTo(event); - assertThat(userLiveResponseDto1.getNotiCount()).isEqualTo(notiCnt); - assertThat(userLiveResponseDto1.getCurrentMatchMode()).isEqualTo(currentMatchMode); - assertThat(userLiveResponseDto1.getGameId()).isEqualTo(gameInfo.getGameId()); - - // Rank 점수 입력 테스트 - RankResultReqDto rankResultReqDto = new RankResultReqDto(gameInfo.getGameId(), - gameInfo.getEnemyTeamId(), 1, - gameInfo.getMyTeamId(), 2); - assertThat(testGame.getStatus()).isEqualTo(StatusType.LIVE); - gameService.createRankResult(rankResultReqDto, gameInfo.getEnemyUserId()); - assertThat(testGame.getStatus()).isEqualTo(StatusType.END); - - String contentAsString2 = mockMvc.perform(get(liveUrl).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - UserLiveResponseDto userLiveResponseDto2 = objectMapper.readValue(contentAsString2, UserLiveResponseDto.class); - assertThat(userLiveResponseDto2.getEvent()).isEqualTo(event); - assertThat(userLiveResponseDto2.getNotiCount()).isEqualTo(notiCnt); - assertThat(userLiveResponseDto2.getCurrentMatchMode()).isEqualTo(currentMatchMode); - assertThat(userLiveResponseDto2.getGameId()).isEqualTo(gameInfo.getGameId()); - - // Rank PChange is_checked 테스트 - String contentAsString3 = mockMvc.perform(get(liveUrl).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - UserLiveResponseDto userLiveResponseDto3 = objectMapper.readValue(contentAsString3, UserLiveResponseDto.class); - assertThat(userLiveResponseDto3.getEvent()).isEqualTo(null); - assertThat(userLiveResponseDto3.getNotiCount()).isEqualTo(notiCnt); - assertThat(userLiveResponseDto3.getCurrentMatchMode()).isEqualTo(null); - assertThat(userLiveResponseDto3.getGameId()).isEqualTo(null); - } - - @Test - @DisplayName("GET /pingpong/users") - public void userNormalDetail() throws Exception { - //given - String url = "/pingpong/users"; - String intraId = "intra"; - String email = "email"; -// String imageUrl = "imageUrl"; - - User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, SnsType.BOTH, RoleType.ADMIN); - Season season = testDataUtils.createSeason(); - - String accessToken = tokenProvider.createToken(newUser.getId()); - Tier tier = tierRepository.findStartTier().get(); - testDataUtils.createUserRank(newUser, "statusMessage", season, tier); - - - //when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - UserNormalDetailResponseDto responseDto = objectMapper.readValue(contentAsString, UserNormalDetailResponseDto.class); - - //then - assertThat(responseDto.getIntraId()).isEqualTo(intraId); -// assertThat(responseDto.getUserImageUri()).isEqualTo(imageUrl); - assertThat(responseDto.getIsAdmin()).isTrue(); - assertThat(responseDto.getIsAttended()); - } - - @Test - @DisplayName("searches?intraId=${IntraId}") - public void searchUser() throws Exception { - //given - String intraId[] = {"intraId", "2intra2", "2intra", "aaaa", "bbbb"}; - String email = "email"; - User user = null; - for (String intra : intraId) { - user = testDataUtils.createNewUser(intra, email, RacketType.PENHOLDER, - SnsType.BOTH, RoleType.ADMIN); - } - String accessToken = tokenProvider.createToken(user.getId()); - String keyWord = "intra"; - String url = "/pingpong/users/searches?intraId=" + keyWord; - - //when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - UserSearchResponseDto userSearchResponseDto = objectMapper.readValue(contentAsString, UserSearchResponseDto.class); - - //then - assertThat(userSearchResponseDto.getUsers().size()).isEqualTo(3); - } - - @Test - @DisplayName("[GET] {targetId}") - public void getUserDetail() throws Exception { - //given - Season season = testDataUtils.createSeason(); - String intraId = "intraId"; - String email = "email"; - String statusMessage = "statusMessage"; - User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, SnsType.BOTH, RoleType.USER); - String accessToken = tokenProvider.createToken(newUser.getId()); - Tier tier = tierRepository.findStartTier().get(); - testDataUtils.createUserRank(newUser, statusMessage, season, tier); - String url = "/pingpong/users/" + newUser.getIntraId(); - - //when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); - UserDetailResponseDto responseDto = objectMapper.readValue(contentAsString, UserDetailResponseDto.class); - - //then - Assertions.assertThat(responseDto.getIntraId()).isEqualTo(intraId); - Assertions.assertThat(responseDto.getStatusMessage()).isEqualTo(statusMessage); - Assertions.assertThat(responseDto.getLevel()).isEqualTo(1); - Assertions.assertThat(responseDto.getCurrentExp()).isEqualTo(0); - System.out.println(responseDto); - } - - @Test - @DisplayName("/{intraId}/rank?season={seasonId}") - public void userRankDetail() throws Exception { - //given - Season season = testDataUtils.createSeason(); - User newUser = testDataUtils.createNewUser(); - String accessToken = tokenProvider.createToken(newUser.getId()); - testDataUtils.createUserRank(newUser, "statusMessage", season); - - //when - String url = "/pingpong/users/" + newUser.getIntraId() + "/rank?season=" + season.getId(); - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); - UserRankResponseDto responseDto = objectMapper.readValue(contentAsString, UserRankResponseDto.class); - - //then - Assertions.assertThat(responseDto.getRank()).isEqualTo(-1); - Assertions.assertThat(responseDto.getWins()).isEqualTo(0); - Assertions.assertThat(responseDto.getLosses()).isEqualTo(0); - Assertions.assertThat(responseDto.getPpp()).isEqualTo(season.getStartPpp()); - System.out.println(responseDto); - } - - @Test - @DisplayName("/{intraId}/historics?season={seasonId}") - public void getUserHistory() throws Exception { - //given - Season season = testDataUtils.createSeason(); - User newUser = testDataUtils.createNewUser(); - String accessToken = tokenProvider.createToken(newUser.getId()); - - LocalDateTime startTime = LocalDateTime.now().minusDays(1); - LocalDateTime endTime = startTime.plusMinutes(15); - testDataUtils.createMockMatch(newUser, season, startTime, endTime); - - LocalDateTime startTime1 = LocalDateTime.now().minusDays(2); - LocalDateTime endTime1 = startTime1.plusMinutes(15); - testDataUtils.createMockMatch(newUser, season, startTime1, endTime1); - - LocalDateTime startTime2 = LocalDateTime.now().minusDays(3); - LocalDateTime endTime2 = startTime2.plusMinutes(15); - testDataUtils.createMockMatch(newUser, season, startTime2, endTime2); - - String url = "/pingpong/users/" + newUser.getIntraId() + "/historics?season=" + season.getId(); - - //when - String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); - UserHistoryResponseDto responseDto = objectMapper.readValue(contentAsString, UserHistoryResponseDto.class); - - //then - Assertions.assertThat(responseDto.getHistorics().size()).isEqualTo(3); -// List historics = responseDto.getHistorics(); -// findPChangesHistory 에는 정렬한다는 내용이 없는 것 같아 보류 -// Assertions.assertThat(historics) -// .isSortedAccordingTo(Comparator.comparing(UserHistoryData::getDate)); - } - - @Test - @DisplayName("[put] {intraId}") - public void updateUser() throws Exception { - //given - Season season = testDataUtils.createSeason(); - String intraId = "intraId"; - String email = "email"; - String imageUrl = "imageUrl"; - User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, SnsType.BOTH, RoleType.USER); - String statusMessage = "statusMessage"; - testDataUtils.createUserRank(newUser, statusMessage, season); - String accessToken = tokenProvider.createToken(newUser.getId()); - String url = "/pingpong/users/" + newUser.getIntraId(); - - String newStatusMessage = "newStatusMessage"; - RacketType newRacketType = RacketType.SHAKEHAND; - SnsType newSnsType = SnsType.SLACK; - - //when - mockMvc.perform(put(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON) - .content(objectMapper.writeValueAsString(new UserModifyRequestDto(newRacketType, newStatusMessage, newSnsType)))) - .andExpect(status().isNoContent()); - //then - String hashKey = RedisKeyManager.getHashKey(season.getId()); - RankRedis rank = redisRepository.findRankByUserId(hashKey, newUser.getId()); - rankRepository.findByUserIdAndSeasonId(newUser.getId(), season.getId()).ifPresentOrElse(rank1 -> { - Assertions.assertThat(rank1.getStatusMessage()).isEqualTo(newStatusMessage); - }, () -> { - Assertions.fail("랭크 업데이트 실패"); - }); - userRepository.findById(newUser.getId()).ifPresentOrElse(user -> { - Assertions.assertThat(user.getRacketType()).isEqualTo((newRacketType)); - Assertions.assertThat(user.getSnsNotiOpt()).isEqualTo(newSnsType); - Assertions.assertThat(rank.getStatusMessage()).isEqualTo(newStatusMessage); - }, () -> { - Assertions.fail("유저 업데이트 실패"); - }); - } - - @Test - @DisplayName("[post] /attendance") - public void attendUserTest() throws Exception { - //given - testDataUtils.createCoinPolicy(admin, 1, 0, 0, 0); - String accessToken = testDataUtils.getLoginAccessToken(); - String url = "/pingpong/users/attendance"; - - //when - String contentAsString = mockMvc.perform(post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - UserAttendanceResponseDto result = objectMapper.readValue(contentAsString, UserAttendanceResponseDto.class); - - //then - System.out.println(result.getAfterCoin()); - Assertions.assertThat(result.getAfterCoin() - result.getBeforeCoin()).isEqualTo(result.getCoinIncrement()); - } - - @Test - @DisplayName("[patch] text-color") - public void updateTextColorTest() throws Exception { - //given - Season season = testDataUtils.createSeason(); - String intraId = "intraId"; - String email = "email"; - User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, SnsType.BOTH, RoleType.USER); - String statusMessage = "statusMessage"; - testDataUtils.createUserRank(newUser, statusMessage, season); - String accessToken = tokenProvider.createToken(newUser.getId()); - String url = "/pingpong/users/text-color"; - ItemUpdateRequestDto dto = new ItemUpdateRequestDto("name", "mainContent", - "subContent", 100, 50, ItemType.TEXT_COLOR); - Item item = itemTestUtils.createItem(admin, dto); - Receipt receipt = itemTestUtils.purchaseItem(newUser, newUser, item); -// Receipt receipt = receiptRepository.findById(4L).get(); - String newTextColor = "#FFFFFF"; - - //when - mockMvc.perform(patch(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON) - .content(objectMapper.writeValueAsString(new UserTextColorDto(receipt.getId(), newTextColor)))) - .andExpect(status().is2xxSuccessful()); - //then - userRepository.findById(newUser.getId()).ifPresentOrElse(user -> { - Assertions.assertThat(user.getTextColor()).isEqualTo(newTextColor); - }, () -> { - Assertions.fail("유저 업데이트 실패"); - }); - AssertionsForClassTypes.assertThat(receipt.getStatus()).isEqualTo(ItemStatus.USED); - } - - @Test - @DisplayName("[patch] edge") - public void updateEdgeTest() throws Exception { - //given - Season season = testDataUtils.createSeason(); - String intraId = "intraId"; - String email = "email"; - User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, SnsType.BOTH, RoleType.USER); - String statusMessage = "statusMessage"; - testDataUtils.createUserRank(newUser, statusMessage, season); - String accessToken = tokenProvider.createToken(newUser.getId()); - ItemUpdateRequestDto dto = new ItemUpdateRequestDto("name", "mainContent", - "subContent", 100, 50, ItemType.EDGE); - Item item = itemTestUtils.createItem(admin, dto); - Receipt receipt = itemTestUtils.purchaseItem(newUser, newUser, item); -// Receipt receipt = receiptRepository.findById(3L).get(); - String url = "/pingpong/users/edge"; - - //when - mockMvc.perform(patch(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .content(objectMapper.writeValueAsString(receipt.getId())) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().is2xxSuccessful()) - .andReturn().getResponse().getContentAsString(); - - //then - log.info("user.getEdge() : {}", newUser.getEdge()); - userRepository.findById(newUser.getId()).ifPresentOrElse(user -> { - Assertions.assertThat(Arrays.stream(EdgeType.values()).anyMatch(v -> v.equals(user.getEdge()))).isEqualTo(true); - }, () -> { - Assertions.fail("유저 업데이트 실패"); - }); - AssertionsForClassTypes.assertThat(receipt.getStatus()).isEqualTo(ItemStatus.USED); - } - - @Test - @DisplayName("[get]/pingpong/users/coin") - public void getUserCoin() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - - String url = "/pingpong/users/coin"; - - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - UserCoinResponseDto result = objectMapper.readValue(contentAsString, UserCoinResponseDto.class); - int userCoin = userRepository.findById(userId).orElseThrow(() -> new UserNotFoundException()).getGgCoin(); - assertThat(result.getCoin()).isEqualTo(userCoin); - System.out.println(userCoin); - } - - @Test - @DisplayName("[patch] background") - public void updateBackgroundTest() throws Exception { - //given - Season season = testDataUtils.createSeason(); - String intraId = "intraId"; - String email = "email"; - User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, SnsType.BOTH, RoleType.USER); - ItemUpdateRequestDto dto = new ItemUpdateRequestDto("name", "mainContent", - "subContent", 100, 50, ItemType.BACKGROUND); - Item item = itemTestUtils.createItem(admin, dto); - Receipt receipt = itemTestUtils.purchaseItem(newUser, newUser, item); - String statusMessage = "statusMessage"; - testDataUtils.createUserRank(newUser, statusMessage, season); - String accessToken = tokenProvider.createToken(newUser.getId()); - -// Receipt receipt = receiptRepository.findById(2L).get(); - String uri = "/pingpong/users/background"; - - //when - mockMvc.perform(patch(uri) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) - .content(objectMapper.writeValueAsString(receipt.getId())) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().is2xxSuccessful()) - .andReturn().getResponse().getContentAsString(); - - //then - log.info("user.getBackground() : {}", newUser.getBackground()); - userRepository.findById(newUser.getId()).ifPresentOrElse(user -> { - Assertions.assertThat(Arrays.stream(BackgroundType.values()).anyMatch(v -> v.equals(user.getBackground()))).isEqualTo(true); - }, () -> { - Assertions.fail("유저 업데이트 실패"); - }); - AssertionsForClassTypes.assertThat(receipt.getStatus()).isEqualTo(ItemStatus.USED); - } - - @Test - @DisplayName("[get]/pingpong/users/coinhistory") - public void getUserCoinHistory() throws Exception { - String accessToken = testDataUtils.getAdminLoginAccessToken(); - Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); - User user = userRepository.getById(userId); - testDataUtils.createCoinPolicy(admin, 0, 1, 3, 2); - - coinHistoryService.addNormalCoin(user); - coinHistoryService.addRankWinCoin(user); - coinHistoryService.addNormalCoin(user); - String url = "/pingpong/users/coinhistory?page=1&size=5"; - - String contentAsString = mockMvc.perform(get(url) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - UserCoinHistoryListResponseDto result = objectMapper.readValue(contentAsString, UserCoinHistoryListResponseDto.class); - - System.out.println(result.getTotalPage()); - for(CoinHistoryResponseDto temp : result.getUseCoinList()){ - System.out.println(temp.getHistory() + " " + temp.getAmount() + " " + temp.getCreatedAt()); - } - } - - @Test - @DisplayName("[post]/pingpong/users/profile-image") - public void getUserImage() throws Exception { - String mockS3Path = "mockS3Path"; - Mockito.when(userImageHandler - .uploadToS3(Mockito.any(MultipartFile.class), Mockito.any(String.class))) - .thenReturn(mockS3Path); -// String accessToken = testDataUtils.getLoginAccessToken(); - ItemUpdateRequestDto dto = new ItemUpdateRequestDto("name", "mainContent", - "subContent", 100, 50, ItemType.PROFILE_IMAGE); - Item item = itemTestUtils.createItem(admin, dto); - User user = testDataUtils.createNewUser(); - testDataUtils.createUserImage(user); - String accessToken = testDataUtils.getLoginAccessTokenFromUser(user); - Receipt receipt = itemTestUtils.purchaseItem(user, user, item); -// Receipt receipt = receiptRepository.findById(7L).orElseThrow(ReceiptNotFoundException::new); - MockMultipartFile image = new MockMultipartFile("profileImage", "imagefile.jpeg", "image/jpeg", "<>".getBytes()); - MockMultipartFile jsonFile = new MockMultipartFile("userProfileImageRequestDto", "", "application/json", ("{\"receiptId\": " + receipt.getId() + "}").getBytes()); - - String contentAsString = mockMvc.perform(multipart("/pingpong/users/profile-image") - .file(image) - .file(jsonFile) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) - .andExpect(status().isNoContent()) - .andReturn().getResponse().getContentAsString(); - AssertionsForClassTypes.assertThat(receipt.getStatus()).isEqualTo(ItemStatus.USED); - } -} +package com.gg.server.domain.user.controller; + +import static org.assertj.core.api.Assertions.*; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.Optional; + +import org.apache.http.HttpHeaders; +import org.assertj.core.api.Assertions; +import org.assertj.core.api.AssertionsForClassTypes; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.admin.item.dto.ItemUpdateRequestDto; +import com.gg.server.domain.coin.data.CoinHistoryRepository; +import com.gg.server.domain.coin.data.CoinPolicyRepository; +import com.gg.server.domain.coin.service.CoinHistoryService; +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.data.GameRepository; +import com.gg.server.domain.game.dto.request.RankResultReqDto; +import com.gg.server.domain.game.service.GameService; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.item.data.Item; +import com.gg.server.domain.item.type.ItemType; +import com.gg.server.domain.rank.data.Rank; +import com.gg.server.domain.rank.data.RankRepository; +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.rank.redis.RedisKeyManager; +import com.gg.server.domain.receipt.data.Receipt; +import com.gg.server.domain.receipt.data.ReceiptRepository; +import com.gg.server.domain.receipt.type.ItemStatus; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.data.SeasonRepository; +import com.gg.server.domain.tier.data.Tier; +import com.gg.server.domain.tier.data.TierRepository; +import com.gg.server.domain.user.controller.dto.GameInfoDto; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.CoinHistoryResponseDto; +import com.gg.server.domain.user.dto.UserAttendanceResponseDto; +import com.gg.server.domain.user.dto.UserCoinHistoryListResponseDto; +import com.gg.server.domain.user.dto.UserCoinResponseDto; +import com.gg.server.domain.user.dto.UserDetailResponseDto; +import com.gg.server.domain.user.dto.UserHistoryResponseDto; +import com.gg.server.domain.user.dto.UserLiveResponseDto; +import com.gg.server.domain.user.dto.UserModifyRequestDto; +import com.gg.server.domain.user.dto.UserNormalDetailResponseDto; +import com.gg.server.domain.user.dto.UserRankResponseDto; +import com.gg.server.domain.user.dto.UserSearchResponseDto; +import com.gg.server.domain.user.dto.UserTextColorDto; +import com.gg.server.domain.user.exception.UserNotFoundException; +import com.gg.server.domain.user.type.BackgroundType; +import com.gg.server.domain.user.type.EdgeType; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.global.utils.UserImageHandler; +import com.gg.server.utils.ItemTestUtils; +import com.gg.server.utils.TestDataUtils; +import com.gg.server.utils.annotation.IntegrationTest; + +import lombok.extern.slf4j.Slf4j; + +@IntegrationTest +@AutoConfigureMockMvc +@Transactional +@Slf4j +class UserControllerTest { + + @Autowired + TestDataUtils testDataUtils; + + @Autowired + private MockMvc mockMvc; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + AuthTokenProvider tokenProvider; + + @Autowired + UserRepository userRepository; + + @Autowired + RankRedisRepository redisRepository; + + @Autowired + TierRepository tierRepository; + + @Autowired + RankRepository rankRepository; + + @Autowired + SeasonRepository seasonRepository; + + @Autowired + GameRepository gameRepository; + + @Autowired + GameService gameService; + + @Autowired + CoinPolicyRepository coinPolicyRepository; + + @Autowired + CoinHistoryRepository coinHistoryRepository; + + @Autowired + ReceiptRepository receiptRepository; + + @Autowired + CoinHistoryService coinHistoryService; + @Autowired + ItemTestUtils itemTestUtils; + @MockBean + UserImageHandler userImageHandler; + User admin; + + @BeforeEach + public void setUp() { + testDataUtils.createTierSystem("pingpong"); + testDataUtils.createSeason(); + admin = testDataUtils.createAdminUserForItem(); + } + + @AfterEach + public void flushRedis() { + redisRepository.deleteAll(); + } + + @Test + @DisplayName("live") + public void userLiveTest() throws Exception { + String accessToken = testDataUtils.getLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + String liveUrl = "/pingpong/users/live"; + String event = "game"; + int notiCnt = 2; + Mode currentMatchMode = Mode.RANK; + GameInfoDto gameInfo = testDataUtils.addMockDataUserLiveApi(event, notiCnt, currentMatchMode.getCode(), userId); + Game testGame = gameRepository.getById(gameInfo.getGameId()); + + // Rank Live 게임 테스트 + String contentAsString1 = mockMvc.perform( + get(liveUrl).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + UserLiveResponseDto userLiveResponseDto1 = objectMapper.readValue(contentAsString1, UserLiveResponseDto.class); + assertThat(userLiveResponseDto1.getEvent()).isEqualTo(event); + assertThat(userLiveResponseDto1.getNotiCount()).isEqualTo(notiCnt); + assertThat(userLiveResponseDto1.getCurrentMatchMode()).isEqualTo(currentMatchMode); + assertThat(userLiveResponseDto1.getGameId()).isEqualTo(gameInfo.getGameId()); + + // Rank 점수 입력 테스트 + RankResultReqDto rankResultReqDto = new RankResultReqDto(gameInfo.getGameId(), + gameInfo.getEnemyTeamId(), 1, + gameInfo.getMyTeamId(), 2); + assertThat(testGame.getStatus()).isEqualTo(StatusType.LIVE); + gameService.createRankResult(rankResultReqDto, gameInfo.getEnemyUserId()); + assertThat(testGame.getStatus()).isEqualTo(StatusType.END); + + String contentAsString2 = mockMvc.perform( + get(liveUrl).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + UserLiveResponseDto userLiveResponseDto2 = objectMapper.readValue(contentAsString2, UserLiveResponseDto.class); + assertThat(userLiveResponseDto2.getEvent()).isEqualTo(event); + assertThat(userLiveResponseDto2.getNotiCount()).isEqualTo(notiCnt); + assertThat(userLiveResponseDto2.getCurrentMatchMode()).isEqualTo(currentMatchMode); + assertThat(userLiveResponseDto2.getGameId()).isEqualTo(gameInfo.getGameId()); + + // Rank PChange is_checked 테스트 + String contentAsString3 = mockMvc.perform( + get(liveUrl).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + UserLiveResponseDto userLiveResponseDto3 = objectMapper.readValue(contentAsString3, UserLiveResponseDto.class); + assertThat(userLiveResponseDto3.getEvent()).isEqualTo(null); + assertThat(userLiveResponseDto3.getNotiCount()).isEqualTo(notiCnt); + assertThat(userLiveResponseDto3.getCurrentMatchMode()).isEqualTo(null); + assertThat(userLiveResponseDto3.getGameId()).isEqualTo(null); + } + + @Test + @DisplayName("GET /pingpong/users") + public void userNormalDetail() throws Exception { + //given + String url = "/pingpong/users"; + String intraId = "intra"; + String email = "email"; + // String imageUrl = "imageUrl"; + + User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, SnsType.BOTH, RoleType.ADMIN); + Season season = testDataUtils.createSeason(); + + String accessToken = tokenProvider.createToken(newUser.getId()); + Tier tier = tierRepository.findStartTier().get(); + testDataUtils.createUserRank(newUser, "statusMessage", season, tier); + + //when + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + UserNormalDetailResponseDto responseDto = objectMapper.readValue(contentAsString, + UserNormalDetailResponseDto.class); + + //then + assertThat(responseDto.getIntraId()).isEqualTo(intraId); + // assertThat(responseDto.getUserImageUri()).isEqualTo(imageUrl); + assertThat(responseDto.getIsAdmin()).isTrue(); + assertThat(responseDto.getIsAttended()); + } + + @Test + @DisplayName("searches?intraId=${IntraId}") + public void searchUser() throws Exception { + //given + String[] intraId = {"intraId", "2intra2", "2intra", "aaaa", "bbbb"}; + String email = "email"; + User user = null; + for (String intra : intraId) { + user = testDataUtils.createNewUser(intra, email, RacketType.PENHOLDER, + SnsType.BOTH, RoleType.ADMIN); + } + String accessToken = tokenProvider.createToken(user.getId()); + String keyWord = "intra"; + String url = "/pingpong/users/searches?intraId=" + keyWord; + + //when + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + UserSearchResponseDto userSearchResponseDto = objectMapper.readValue(contentAsString, + UserSearchResponseDto.class); + + //then + assertThat(userSearchResponseDto.getUsers().size()).isEqualTo(3); + } + + @Test + @DisplayName("[GET] {targetId}") + public void getUserDetail() throws Exception { + //given + Season season = testDataUtils.createSeason(); + String intraId = "intraId"; + String email = "email"; + String statusMessage = "statusMessage"; + User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, SnsType.BOTH, RoleType.USER); + String accessToken = tokenProvider.createToken(newUser.getId()); + Tier tier = tierRepository.findStartTier().get(); + testDataUtils.createUserRank(newUser, statusMessage, season, tier); + String url = "/pingpong/users/" + newUser.getIntraId(); + + //when + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + UserDetailResponseDto responseDto = objectMapper.readValue(contentAsString, UserDetailResponseDto.class); + + //then + Assertions.assertThat(responseDto.getIntraId()).isEqualTo(intraId); + Assertions.assertThat(responseDto.getStatusMessage()).isEqualTo(statusMessage); + Assertions.assertThat(responseDto.getLevel()).isEqualTo(1); + Assertions.assertThat(responseDto.getCurrentExp()).isEqualTo(0); + System.out.println(responseDto); + } + + @Test + @DisplayName("/{intraId}/rank?season={seasonId}") + public void userRankDetail() throws Exception { + //given + Season season = testDataUtils.createSeason(); + User newUser = testDataUtils.createNewUser(); + String accessToken = tokenProvider.createToken(newUser.getId()); + testDataUtils.createUserRank(newUser, "statusMessage", season); + + //when + String url = "/pingpong/users/" + newUser.getIntraId() + "/rank?season=" + season.getId(); + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + UserRankResponseDto responseDto = objectMapper.readValue(contentAsString, UserRankResponseDto.class); + + //then + Assertions.assertThat(responseDto.getRank()).isEqualTo(-1); + Assertions.assertThat(responseDto.getWins()).isEqualTo(0); + Assertions.assertThat(responseDto.getLosses()).isEqualTo(0); + Assertions.assertThat(responseDto.getPpp()).isEqualTo(season.getStartPpp()); + System.out.println(responseDto); + } + + @Test + @DisplayName("/{intraId}/historics?season={seasonId}") + public void getUserHistory() throws Exception { + //given + Season season = testDataUtils.createSeason(); + User newUser = testDataUtils.createNewUser(); + String accessToken = tokenProvider.createToken(newUser.getId()); + + LocalDateTime startTime = LocalDateTime.now().minusDays(1); + LocalDateTime endTime = startTime.plusMinutes(15); + testDataUtils.createMockMatch(newUser, season, startTime, endTime); + + LocalDateTime startTime1 = LocalDateTime.now().minusDays(2); + LocalDateTime endTime1 = startTime1.plusMinutes(15); + testDataUtils.createMockMatch(newUser, season, startTime1, endTime1); + + LocalDateTime startTime2 = LocalDateTime.now().minusDays(3); + LocalDateTime endTime2 = startTime2.plusMinutes(15); + testDataUtils.createMockMatch(newUser, season, startTime2, endTime2); + + String url = "/pingpong/users/" + newUser.getIntraId() + "/historics?season=" + season.getId(); + + //when + String contentAsString = mockMvc.perform(get(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + UserHistoryResponseDto responseDto = objectMapper.readValue(contentAsString, UserHistoryResponseDto.class); + + //then + Assertions.assertThat(responseDto.getHistorics().size()).isEqualTo(3); + // List historics = responseDto.getHistorics(); + // findPChangesHistory 에는 정렬한다는 내용이 없는 것 같아 보류 + // Assertions.assertThat(historics) + // .isSortedAccordingTo(Comparator.comparing(UserHistoryData::getDate)); + } + + @Test + @DisplayName("[put] {intraId}") + public void updateUser() throws Exception { + //given + Season season = testDataUtils.createSeason(); + String intraId = "intraId"; + String email = "email"; + String imageUrl = "imageUrl"; + User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, SnsType.BOTH, RoleType.USER); + String statusMessage = "statusMessage"; + testDataUtils.createUserRank(newUser, statusMessage, season); + String accessToken = tokenProvider.createToken(newUser.getId()); + String url = "/pingpong/users/" + newUser.getIntraId(); + + String newStatusMessage = "newStatusMessage"; + RacketType newRacketType = RacketType.SHAKEHAND; + SnsType newSnsType = SnsType.SLACK; + + //when + mockMvc.perform(put(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON) + .content( + objectMapper.writeValueAsString(new UserModifyRequestDto(newRacketType, newStatusMessage, + newSnsType)))) + .andExpect(status().isNoContent()); + //then + String hashKey = RedisKeyManager.getHashKey(season.getId()); + RankRedis rank = redisRepository.findRankByUserId(hashKey, newUser.getId()); + Optional rankOptional = rankRepository.findByUserIdAndSeasonId(newUser.getId(), season.getId()); + + if (rankOptional.isPresent()) { + Rank rank1 = rankOptional.get(); + Assertions.assertThat(rank1.getStatusMessage()).isEqualTo(newStatusMessage); + } else { + Assertions.fail("랭크 업데이트 실패"); + } + + Optional userOptional = userRepository.findById(newUser.getId()); + + if (userOptional.isPresent()) { + User user = userOptional.get(); + Assertions.assertThat(user.getRacketType()).isEqualTo(newRacketType); + Assertions.assertThat(user.getSnsNotiOpt()).isEqualTo(newSnsType); + Assertions.assertThat(rank.getStatusMessage()).isEqualTo(newStatusMessage); + } else { + Assertions.fail("유저 업데이트 실패"); + } + + } + + @Test + @DisplayName("[post] /attendance") + public void attendUserTest() throws Exception { + //given + testDataUtils.createCoinPolicy(admin, 1, 0, 0, 0); + String accessToken = testDataUtils.getLoginAccessToken(); + String url = "/pingpong/users/attendance"; + + //when + String contentAsString = mockMvc.perform( + post(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + UserAttendanceResponseDto result = objectMapper.readValue(contentAsString, UserAttendanceResponseDto.class); + + //then + System.out.println(result.getAfterCoin()); + Assertions.assertThat(result.getAfterCoin() - result.getBeforeCoin()).isEqualTo(result.getCoinIncrement()); + } + + @Test + @DisplayName("[patch] text-color") + public void updateTextColorTest() throws Exception { + //given + Season season = testDataUtils.createSeason(); + String intraId = "intraId"; + String email = "email"; + User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, SnsType.BOTH, + RoleType.USER); + String statusMessage = "statusMessage"; + testDataUtils.createUserRank(newUser, statusMessage, season); + String accessToken = tokenProvider.createToken(newUser.getId()); + String url = "/pingpong/users/text-color"; + ItemUpdateRequestDto dto = new ItemUpdateRequestDto("name", "mainContent", + "subContent", 100, 50, ItemType.TEXT_COLOR); + Item item = itemTestUtils.createItem(admin, dto); + Receipt receipt = itemTestUtils.purchaseItem(newUser, newUser, item); + // Receipt receipt = receiptRepository.findById(4L).get(); + String newTextColor = "#FFFFFF"; + + //when + mockMvc.perform(patch(url).header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(new UserTextColorDto(receipt.getId(), newTextColor)))) + .andExpect(status().is2xxSuccessful()); + //then + Optional userOptional = userRepository.findById(newUser.getId()); + + if (userOptional.isPresent()) { + User user = userOptional.get(); + Assertions.assertThat(user.getTextColor()).isEqualTo(newTextColor); + } else { + Assertions.fail("유저 업데이트 실패"); + } + + AssertionsForClassTypes.assertThat(receipt.getStatus()).isEqualTo(ItemStatus.USED); + } + + @Test + @DisplayName("[patch] edge") + public void updateEdgeTest() throws Exception { + //given + Season season = testDataUtils.createSeason(); + String intraId = "intraId"; + String email = "email"; + User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, SnsType.BOTH, + RoleType.USER); + String statusMessage = "statusMessage"; + testDataUtils.createUserRank(newUser, statusMessage, season); + String accessToken = tokenProvider.createToken(newUser.getId()); + ItemUpdateRequestDto dto = new ItemUpdateRequestDto("name", "mainContent", + "subContent", 100, 50, ItemType.EDGE); + Item item = itemTestUtils.createItem(admin, dto); + Receipt receipt = itemTestUtils.purchaseItem(newUser, newUser, item); + // Receipt receipt = receiptRepository.findById(3L).get(); + String url = "/pingpong/users/edge"; + + //when + mockMvc.perform(patch(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .content(objectMapper.writeValueAsString(receipt.getId())) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().is2xxSuccessful()) + .andReturn().getResponse().getContentAsString(); + + //then + log.info("user.getEdge() : {}", newUser.getEdge()); + Optional userOptional = userRepository.findById(newUser.getId()); + + if (userOptional.isPresent()) { + User user = userOptional.get(); + boolean isEdgeTypeValid = Arrays.stream(EdgeType.values()).anyMatch(v -> v.equals(user.getEdge())); + Assertions.assertThat(isEdgeTypeValid).isEqualTo(true); + } else { + Assertions.fail("유저 업데이트 실패"); + } + + AssertionsForClassTypes.assertThat(receipt.getStatus()).isEqualTo(ItemStatus.USED); + } + + @Test + @DisplayName("[get]/pingpong/users/coin") + public void getUserCoin() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + + String url = "/pingpong/users/coin"; + + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + UserCoinResponseDto result = objectMapper.readValue(contentAsString, UserCoinResponseDto.class); + int userCoin = userRepository.findById(userId).orElseThrow(() -> new UserNotFoundException()).getGgCoin(); + assertThat(result.getCoin()).isEqualTo(userCoin); + System.out.println(userCoin); + } + + @Test + @DisplayName("[patch] background") + public void updateBackgroundTest() throws Exception { + //given + Season season = testDataUtils.createSeason(); + String intraId = "intraId"; + String email = "email"; + User newUser = testDataUtils.createNewUser(intraId, email, RacketType.PENHOLDER, SnsType.BOTH, + RoleType.USER); + ItemUpdateRequestDto dto = new ItemUpdateRequestDto("name", "mainContent", + "subContent", 100, 50, ItemType.BACKGROUND); + Item item = itemTestUtils.createItem(admin, dto); + Receipt receipt = itemTestUtils.purchaseItem(newUser, newUser, item); + String statusMessage = "statusMessage"; + testDataUtils.createUserRank(newUser, statusMessage, season); + String accessToken = tokenProvider.createToken(newUser.getId()); + + // Receipt receipt = receiptRepository.findById(2L).get(); + String uri = "/pingpong/users/background"; + + //when + mockMvc.perform(patch(uri) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .content(objectMapper.writeValueAsString(receipt.getId())) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().is2xxSuccessful()) + .andReturn().getResponse().getContentAsString(); + + //then + log.info("user.getBackground() : {}", newUser.getBackground()); + Optional userOptional = userRepository.findById(newUser.getId()); + + if (userOptional.isPresent()) { + User user = userOptional.get(); + boolean isBackgroundTypeValid = Arrays + .stream(BackgroundType.values()).anyMatch(v -> v.equals(user.getBackground())); + Assertions.assertThat(isBackgroundTypeValid).isEqualTo(true); + } else { + Assertions.fail("유저 업데이트 실패"); + } + + AssertionsForClassTypes.assertThat(receipt.getStatus()).isEqualTo(ItemStatus.USED); + } + + @Test + @DisplayName("[get]/pingpong/users/coinhistory") + public void getUserCoinHistory() throws Exception { + String accessToken = testDataUtils.getAdminLoginAccessToken(); + Long userId = tokenProvider.getUserIdFromAccessToken(accessToken); + User user = userRepository.getById(userId); + testDataUtils.createCoinPolicy(admin, 0, 1, 3, 2); + + coinHistoryService.addNormalCoin(user); + coinHistoryService.addRankWinCoin(user); + coinHistoryService.addNormalCoin(user); + String url = "/pingpong/users/coinhistory?page=1&size=5"; + + String contentAsString = mockMvc.perform(get(url) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + UserCoinHistoryListResponseDto result = objectMapper.readValue(contentAsString, + UserCoinHistoryListResponseDto.class); + + System.out.println(result.getTotalPage()); + for (CoinHistoryResponseDto temp : result.getUseCoinList()) { + System.out.println(temp.getHistory() + " " + temp.getAmount() + " " + temp.getCreatedAt()); + } + } + + @Test + @DisplayName("[post]/pingpong/users/profile-image") + public void getUserImage() throws Exception { + String mockS3Path = "mockS3Path"; + Mockito.when(userImageHandler + .uploadToS3(Mockito.any(MultipartFile.class), Mockito.any(String.class))) + .thenReturn(mockS3Path); + // String accessToken = testDataUtils.getLoginAccessToken(); + ItemUpdateRequestDto dto = new ItemUpdateRequestDto("name", "mainContent", + "subContent", 100, 50, ItemType.PROFILE_IMAGE); + Item item = itemTestUtils.createItem(admin, dto); + User user = testDataUtils.createNewUser(); + testDataUtils.createUserImage(user); + String accessToken = testDataUtils.getLoginAccessTokenFromUser(user); + Receipt receipt = itemTestUtils.purchaseItem(user, user, item); + // Receipt receipt = receiptRepository.findById(7L).orElseThrow(ReceiptNotFoundException::new); + MockMultipartFile image = new MockMultipartFile("profileImage", "imagefile.jpeg", "image/jpeg", + "<>".getBytes()); + MockMultipartFile jsonFile = new MockMultipartFile("userProfileImageRequestDto", "", "application/json", + ("{\"receiptId\": " + receipt.getId() + "}").getBytes()); + + String contentAsString = mockMvc.perform(multipart("/pingpong/users/profile-image") + .file(image) + .file(jsonFile) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken)) + .andExpect(status().isNoContent()) + .andReturn().getResponse().getContentAsString(); + AssertionsForClassTypes.assertThat(receipt.getStatus()).isEqualTo(ItemStatus.USED); + } +} diff --git a/src/test/java/com/gg/server/domain/user/controller/dto/GameInfoDto.java b/src/test/java/com/gg/server/domain/user/controller/dto/GameInfoDto.java index 1fef1036e..e466976e3 100644 --- a/src/test/java/com/gg/server/domain/user/controller/dto/GameInfoDto.java +++ b/src/test/java/com/gg/server/domain/user/controller/dto/GameInfoDto.java @@ -6,9 +6,9 @@ @AllArgsConstructor @Getter public class GameInfoDto { - private Long gameId; - private Long myTeamId; - private Long myUserId; - private Long enemyTeamId; - private Long enemyUserId; + private Long gameId; + private Long myTeamId; + private Long myUserId; + private Long enemyTeamId; + private Long enemyUserId; } diff --git a/src/test/java/com/gg/server/utils/ItemTestUtils.java b/src/test/java/com/gg/server/utils/ItemTestUtils.java index 02b013c3d..5a4db6967 100644 --- a/src/test/java/com/gg/server/utils/ItemTestUtils.java +++ b/src/test/java/com/gg/server/utils/ItemTestUtils.java @@ -1,5 +1,10 @@ package com.gg.server.utils; +import java.time.LocalDate; +import java.time.LocalDateTime; + +import org.springframework.stereotype.Component; + import com.gg.server.admin.item.dto.ItemUpdateRequestDto; import com.gg.server.domain.item.data.Item; import com.gg.server.domain.item.data.ItemRepository; @@ -9,10 +14,8 @@ import com.gg.server.domain.receipt.data.ReceiptRepository; import com.gg.server.domain.receipt.type.ItemStatus; import com.gg.server.domain.user.data.User; -import java.time.LocalDate; -import java.time.LocalDateTime; + import lombok.AllArgsConstructor; -import org.springframework.stereotype.Component; /** * ItemTestUtils. @@ -28,43 +31,43 @@ @AllArgsConstructor public class ItemTestUtils { - ItemRepository itemRepository; + ItemRepository itemRepository; - ReceiptRepository receiptRepository; + ReceiptRepository receiptRepository; - MegaphoneRepository megaphoneRepository; + MegaphoneRepository megaphoneRepository; - /** - * 아이템을 구매한다.(영수증 생성) - */ - public Receipt purchaseItem(User purchaser, User owner, Item item) { - Receipt receipt = new Receipt(item, purchaser.getIntraId(), owner.getIntraId(), - ItemStatus.BEFORE, LocalDateTime.now()); - return receiptRepository.save(receipt); - } + /** + * 아이템을 구매한다.(영수증 생성) + */ + public Receipt purchaseItem(User purchaser, User owner, Item item) { + Receipt receipt = new Receipt(item, purchaser.getIntraId(), owner.getIntraId(), + ItemStatus.BEFORE, LocalDateTime.now()); + return receiptRepository.save(receipt); + } - /** - * 아이템을 생성한다. - */ - public Item createItem(User creator, ItemUpdateRequestDto updateRequestDto) { - Item item = Item.builder() - .creatorIntraId(creator.getIntraId()) - .itemImageUri("42gg-s3") - .updateRequestDto(updateRequestDto) - .build(); - itemRepository.save(item); - return item; - } + /** + * 아이템을 생성한다. + */ + public Item createItem(User creator, ItemUpdateRequestDto updateRequestDto) { + Item item = Item.builder() + .creatorIntraId(creator.getIntraId()) + .itemImageUri("42gg-s3") + .updateRequestDto(updateRequestDto) + .build(); + itemRepository.save(item); + return item; + } - /** - * 메가폰을 생성한다. - * 현재 서비스에 맞게 WAITING 상태로 변경한다. - */ - public Megaphone createMegaPhone(User user, Receipt receipt, String content) { - Megaphone mega = new Megaphone(user, receipt, content, LocalDate.now().plusDays(1)); - receipt.updateStatus(ItemStatus.WAITING); - receiptRepository.save(receipt); - megaphoneRepository.save(mega); - return mega; - } + /** + * 메가폰을 생성한다. + * 현재 서비스에 맞게 WAITING 상태로 변경한다. + */ + public Megaphone createMegaPhone(User user, Receipt receipt, String content) { + Megaphone mega = new Megaphone(user, receipt, content, LocalDate.now().plusDays(1)); + receipt.updateStatus(ItemStatus.WAITING); + receiptRepository.save(receipt); + megaphoneRepository.save(mega); + return mega; + } } diff --git a/src/test/java/com/gg/server/utils/MatchTestUtils.java b/src/test/java/com/gg/server/utils/MatchTestUtils.java index 480c50706..248b46cd4 100644 --- a/src/test/java/com/gg/server/utils/MatchTestUtils.java +++ b/src/test/java/com/gg/server/utils/MatchTestUtils.java @@ -1,5 +1,15 @@ package com.gg.server.utils; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import java.util.stream.Collectors; + +import org.springframework.stereotype.Component; + import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.type.Mode; @@ -14,7 +24,6 @@ import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; import com.gg.server.domain.team.data.Team; import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.team.exception.TeamNotFoundException; import com.gg.server.domain.tournament.data.Tournament; import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.type.TournamentRound; @@ -23,185 +32,184 @@ import com.gg.server.domain.user.type.RacketType; import com.gg.server.domain.user.type.RoleType; import com.gg.server.domain.user.type.SnsType; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; @Component @RequiredArgsConstructor public class MatchTestUtils { - private final UserRepository userRepository; - private final SeasonRepository seasonRepository; - private final RankRedisRepository rankRedisRepository; - private final SlotManagementRepository slotManagementRepository; - private final GameRepository gameRepository; - - public User createUser() { - String randomId = UUID.randomUUID().toString().substring(0, 30); - User user = User.builder() - .eMail("email") - .intraId(randomId) - .racketType(RacketType.PENHOLDER) - .snsNotiOpt(SnsType.NONE) - .roleType(RoleType.USER) - .totalExp(1000) - .build(); - userRepository.save(user); - return user; - } - - public User createGuestUser() { - String randomId = UUID.randomUUID().toString().substring(0, 30); - User user = User.builder() - .eMail("email") - .intraId(randomId) - .racketType(RacketType.PENHOLDER) - .snsNotiOpt(SnsType.NONE) - .roleType(RoleType.GUEST) - .totalExp(1000) - .build(); - userRepository.save(user); - return user; - } - - public RankRedis addUsertoRankRedis(Long userId, Integer ppp, Long seasonId) { - String randomId = UUID.randomUUID().toString(); - RankRedis rankRedis = new RankRedis(userId, randomId, ppp, 0, 0,"test", "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); - rankRedisRepository.addRankData(RedisKeyManager.getHashKey(seasonId), userId, rankRedis); - rankRedisRepository.addToZSet(RedisKeyManager.getZSetKey(seasonId), userId, ppp); - return rankRedis; - } - - public List getTestSlotTimes(Integer interval) { - LocalDateTime now = LocalDateTime.now(); - LocalDateTime standard = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth() - , now.getHour(), 0); - List sampleSlots = new ArrayList(); - for (int i = 0; i < 15; i++) { - if (standard.plusMinutes(interval * i).isAfter(now)) { - sampleSlots.add(standard.plusMinutes(interval * i)); - } - } - return sampleSlots; - } - public Season makeTestSeason(Integer pppGap) { - Optional currentSeason = seasonRepository.findCurrentSeason(LocalDateTime.now()); - if (currentSeason.isPresent()) { - return currentSeason.get(); - } - Season season = new Season( - "test", - LocalDateTime.now().minusDays(1), - LocalDateTime.of(9999, 12, 31, 23, 59, 59), - 1000, - pppGap - ); - seasonRepository.save(season); - return season; - } - - public SlotManagement makeTestSlotManagement(Integer interval) { - SlotManagement slotManagement = SlotManagement.builder() - .futureSlotTime(10) - .pastSlotTime(0) - .gameInterval(interval) - .openMinute(5) - .startTime(LocalDateTime.now().minusHours(2)) - .build(); - slotManagementRepository.save(slotManagement); - return slotManagement; - } - - /** - * 토너먼트에서 동일한 라운드의 경기들을 매칭 (생성) - * @param tournament 토너먼트 - * @param round 해당 라운드와 동일한 라운드의 모든 경기를 매칭 - * ex ) 8강의 경우 8강의 4경기를 매칭 - * @return 매칭된 토너먼트 게임 - */ - public List matchTournamentGames(Tournament tournament, TournamentRound round) { - Season season = seasonRepository.findCurrentSeason(LocalDateTime.now()) - .orElseThrow(() -> new IllegalArgumentException("현재 시즌이 존재하지 않습니다.")); - List sameRounds = TournamentRound.getSameRounds(round); - List sameRoundGames = tournament.getTournamentGames().stream() - .filter(o -> sameRounds.contains(o.getTournamentRound())) - .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) - .collect(Collectors.toList()); - List previousRoundTournamentGames = findSameRoundGames(tournament.getTournamentGames(), TournamentRound.getPreviousRoundNumber(round)); - - for (int i = 0; i < round.getRoundNumber() / 2; ++i) { - Game game = new Game(season, StatusType.BEFORE, Mode.TOURNAMENT, LocalDateTime.now(), LocalDateTime.now()); - Team team1 = new Team(game, -1, false); - Team team2 = new Team(game, -1, false); - User user1 = findMatchUser(previousRoundTournamentGames, i * 2, tournament); - User user2 = findMatchUser(previousRoundTournamentGames, i * 2 + 1, tournament); - new TeamUser(team1, user1); - new TeamUser(team2, user2); - gameRepository.save(game); - sameRoundGames.get(i).updateGame(game); - } - return sameRoundGames; - } - - /** - * 여러 경기에 대한 결과 수정 - * @param tournamentGames - * @param scores - */ - public void updateTournamentGamesResult(List tournamentGames, List scores) { - int sum = scores.stream().mapToInt(Integer::intValue).sum(); - if (sum > 3 || sum < 0) { - throw new IllegalArgumentException("게임 점수는 0 ~ 3 사이여야 합니다."); - } - List games = tournamentGames.stream().map(TournamentGame::getGame).collect(Collectors.toList()); - for (Game game : games) { - updateTournamentGameResult(game, scores); - } - } - - /** - * 하나의 경기에 대한 결과 업데이트 - * @param game - * @param scores - */ - public void updateTournamentGameResult(Game game, List scores) { - int sum = scores.stream().mapToInt(Integer::intValue).sum(); - if (sum > 3 || sum < 0) { - throw new IllegalArgumentException("게임 점수는 0 ~ 3 사이여야 합니다."); - } - List teams = game.getTeams(); - teams.get(0).updateScore(scores.get(0), scores.get(0) > scores.get(1)); - teams.get(1).updateScore(scores.get(1), scores.get(0) < scores.get(1)); - // BEFORE -> LIVE -> WAIT -> END - game.updateStatus(); - game.updateStatus(); - game.updateStatus(); - - } - - public Team getWinningTeam(Game game) { - return game.getTeams().stream() - .filter(team -> Boolean.TRUE.equals(team.getWin())) - .findAny() - .orElseThrow(WinningTeamNotFoundException::new); - } - - private User findMatchUser(List previousTournamentGames, int index, Tournament tournament) { - if (previousTournamentGames.isEmpty()) { - return tournament.getTournamentUsers().get(index).getUser(); - } - Game game = previousTournamentGames.get(index).getGame(); - return getWinningTeam(game) - .getTeamUsers().get(0).getUser(); - } - - private List findSameRoundGames(List tournamentGames, int roundNum) { - return tournamentGames.stream() - .filter(tournamentGame -> roundNum == tournamentGame.getTournamentRound().getRoundNumber()) - .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) - .collect(Collectors.toList()); - } + private final UserRepository userRepository; + private final SeasonRepository seasonRepository; + private final RankRedisRepository rankRedisRepository; + private final SlotManagementRepository slotManagementRepository; + private final GameRepository gameRepository; + + public User createUser() { + String randomId = UUID.randomUUID().toString().substring(0, 30); + User user = User.builder() + .eMail("email") + .intraId(randomId) + .racketType(RacketType.PENHOLDER) + .snsNotiOpt(SnsType.NONE) + .roleType(RoleType.USER) + .totalExp(1000) + .build(); + userRepository.save(user); + return user; + } + + public User createGuestUser() { + String randomId = UUID.randomUUID().toString().substring(0, 30); + User user = User.builder() + .eMail("email") + .intraId(randomId) + .racketType(RacketType.PENHOLDER) + .snsNotiOpt(SnsType.NONE) + .roleType(RoleType.GUEST) + .totalExp(1000) + .build(); + userRepository.save(user); + return user; + } + + public RankRedis addUsertoRankRedis(Long userId, Integer ppp, Long seasonId) { + String randomId = UUID.randomUUID().toString(); + RankRedis rankRedis = new RankRedis(userId, randomId, ppp, 0, 0, "test", + "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000"); + rankRedisRepository.addRankData(RedisKeyManager.getHashKey(seasonId), userId, rankRedis); + rankRedisRepository.addToZSet(RedisKeyManager.getZSetKey(seasonId), userId, ppp); + return rankRedis; + } + + public List getTestSlotTimes(Integer interval) { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime standard = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(), + now.getHour(), 0); + List sampleSlots = new ArrayList(); + for (int i = 0; i < 15; i++) { + if (standard.plusMinutes(interval * i).isAfter(now)) { + sampleSlots.add(standard.plusMinutes(interval * i)); + } + } + return sampleSlots; + } + + public Season makeTestSeason(Integer pppGap) { + Optional currentSeason = seasonRepository.findCurrentSeason(LocalDateTime.now()); + if (currentSeason.isPresent()) { + return currentSeason.get(); + } + Season season = new Season( + "test", + LocalDateTime.now().minusDays(1), + LocalDateTime.of(9999, 12, 31, 23, 59, 59), + 1000, + pppGap + ); + seasonRepository.save(season); + return season; + } + + public SlotManagement makeTestSlotManagement(Integer interval) { + SlotManagement slotManagement = SlotManagement.builder() + .futureSlotTime(10) + .pastSlotTime(0) + .gameInterval(interval) + .openMinute(5) + .startTime(LocalDateTime.now().minusHours(2)) + .build(); + slotManagementRepository.save(slotManagement); + return slotManagement; + } + + /** + * 토너먼트에서 동일한 라운드의 경기들을 매칭 (생성) + * @param tournament 토너먼트 + * @param round 해당 라운드와 동일한 라운드의 모든 경기를 매칭 + * ex ) 8강의 경우 8강의 4경기를 매칭 + * @return 매칭된 토너먼트 게임 + */ + public List matchTournamentGames(Tournament tournament, TournamentRound round) { + Season season = seasonRepository.findCurrentSeason(LocalDateTime.now()) + .orElseThrow(() -> new IllegalArgumentException("현재 시즌이 존재하지 않습니다.")); + List sameRounds = TournamentRound.getSameRounds(round); + List sameRoundGames = tournament.getTournamentGames().stream() + .filter(o -> sameRounds.contains(o.getTournamentRound())) + .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) + .collect(Collectors.toList()); + List previousRoundTournamentGames = findSameRoundGames(tournament.getTournamentGames(), + TournamentRound.getPreviousRoundNumber(round)); + + for (int i = 0; i < round.getRoundNumber() / 2; ++i) { + Game game = new Game(season, StatusType.BEFORE, Mode.TOURNAMENT, LocalDateTime.now(), LocalDateTime.now()); + Team team1 = new Team(game, -1, false); + Team team2 = new Team(game, -1, false); + User user1 = findMatchUser(previousRoundTournamentGames, i * 2, tournament); + User user2 = findMatchUser(previousRoundTournamentGames, i * 2 + 1, tournament); + new TeamUser(team1, user1); + new TeamUser(team2, user2); + gameRepository.save(game); + sameRoundGames.get(i).updateGame(game); + } + return sameRoundGames; + } + + /** + * 여러 경기에 대한 결과 수정 + * @param tournamentGames + * @param scores + */ + public void updateTournamentGamesResult(List tournamentGames, List scores) { + int sum = scores.stream().mapToInt(Integer::intValue).sum(); + if (sum > 3 || sum < 0) { + throw new IllegalArgumentException("게임 점수는 0 ~ 3 사이여야 합니다."); + } + List games = tournamentGames.stream().map(TournamentGame::getGame).collect(Collectors.toList()); + for (Game game : games) { + updateTournamentGameResult(game, scores); + } + } + + /** + * 하나의 경기에 대한 결과 업데이트 + * @param game + * @param scores + */ + public void updateTournamentGameResult(Game game, List scores) { + int sum = scores.stream().mapToInt(Integer::intValue).sum(); + if (sum > 3 || sum < 0) { + throw new IllegalArgumentException("게임 점수는 0 ~ 3 사이여야 합니다."); + } + List teams = game.getTeams(); + teams.get(0).updateScore(scores.get(0), scores.get(0) > scores.get(1)); + teams.get(1).updateScore(scores.get(1), scores.get(0) < scores.get(1)); + // BEFORE -> LIVE -> WAIT -> END + game.updateStatus(); + game.updateStatus(); + game.updateStatus(); + + } + + public Team getWinningTeam(Game game) { + return game.getTeams().stream() + .filter(team -> Boolean.TRUE.equals(team.getWin())) + .findAny() + .orElseThrow(WinningTeamNotFoundException::new); + } + + private User findMatchUser(List previousTournamentGames, int index, Tournament tournament) { + if (previousTournamentGames.isEmpty()) { + return tournament.getTournamentUsers().get(index).getUser(); + } + Game game = previousTournamentGames.get(index).getGame(); + return getWinningTeam(game) + .getTeamUsers().get(0).getUser(); + } + + private List findSameRoundGames(List tournamentGames, int roundNum) { + return tournamentGames.stream() + .filter(tournamentGame -> roundNum == tournamentGame.getTournamentRound().getRoundNumber()) + .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) + .collect(Collectors.toList()); + } } diff --git a/src/test/java/com/gg/server/utils/ReflectionUtilsForUnitTest.java b/src/test/java/com/gg/server/utils/ReflectionUtilsForUnitTest.java index 80ecbcc5f..fc7f4cf0b 100644 --- a/src/test/java/com/gg/server/utils/ReflectionUtilsForUnitTest.java +++ b/src/test/java/com/gg/server/utils/ReflectionUtilsForUnitTest.java @@ -1,8 +1,9 @@ package com.gg.server.utils; +import java.lang.reflect.Field; + import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.BusinessException; -import java.lang.reflect.Field; /** * ReflectionUtilsForUnitTest. @@ -14,16 +15,16 @@ */ public class ReflectionUtilsForUnitTest { - /** - * 리플렉션을 사용해서 필드값을 설정한다. - */ - static public void setFieldWithReflection(Object object, String fieldName, Object value) { - try { - Field field = object.getClass().getDeclaredField(fieldName); - field.setAccessible(true); - field.set(object, value); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new BusinessException(ErrorCode.BAD_REQUEST); - } - } + /** + * 리플렉션을 사용해서 필드값을 설정한다. + */ + public static void setFieldWithReflection(Object object, String fieldName, Object value) { + try { + Field field = object.getClass().getDeclaredField(fieldName); + field.setAccessible(true); + field.set(object, value); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new BusinessException(ErrorCode.BAD_REQUEST); + } + } } diff --git a/src/test/java/com/gg/server/utils/TestDataUtils.java b/src/test/java/com/gg/server/utils/TestDataUtils.java index 564d111b7..cbc2730bb 100644 --- a/src/test/java/com/gg/server/utils/TestDataUtils.java +++ b/src/test/java/com/gg/server/utils/TestDataUtils.java @@ -1,727 +1,768 @@ -package com.gg.server.utils; - -import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; -import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; -import com.gg.server.domain.announcement.data.Announcement; -import com.gg.server.domain.announcement.data.AnnouncementRepository; -import com.gg.server.domain.coin.data.CoinPolicy; -import com.gg.server.domain.coin.data.CoinPolicyRepository; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.exception.GameNotExistException; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.noti.data.Noti; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.pchange.data.PChange; -import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.rank.data.Rank; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.data.Team; -import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.tier.data.Tier; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tournament.data.*; -import com.gg.server.domain.tournament.dto.TournamentResponseDto; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; -import com.gg.server.domain.user.controller.dto.GameInfoDto; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserImage; -import com.gg.server.domain.user.data.UserImageRepository; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserImageDto; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -@Component -@RequiredArgsConstructor -public class TestDataUtils { - private final UserRepository userRepository; - private final AuthTokenProvider tokenProvider; - private final NotiRepository notiRepository; - private final SeasonRepository seasonRepository; - private final GameRepository gameRepository; - private final TeamUserRepository teamUserRepository; - private final TeamRepository teamRepository; - private final RankRedisRepository redisRepository; - private final PChangeRepository pChangeRepository; - private final RankRepository rankRepository; - private final TierRepository tierRepository; - private final TournamentRepository tournamentRepository; - private final TournamentGameRepository tournamentGameRepository; - private final TournamentUserRepository tournamentUserRepository; - private final AnnouncementRepository announcementRepository; - private final CoinPolicyRepository coinPolicyRepository; - private final UserImageRepository userImageRepository; - private final SlotManagementRepository slotManagementRepository; - - public String getLoginAccessToken() { - User user = User.builder() - .eMail("email") - .intraId("intraId") - .racketType(RacketType.PENHOLDER) - .snsNotiOpt(SnsType.NONE) - .roleType(RoleType.USER) - .totalExp(1000) - .build(); - userRepository.save(user); - return tokenProvider.createToken(user.getId()); - } - - public String getLoginAccessTokenFromUser(User user) { - return tokenProvider.createToken(user.getId()); - } - - - public String getAdminLoginAccessToken() { - User user = User.builder() - .eMail("email") - .intraId("intraId") - .racketType(RacketType.PENHOLDER) - .snsNotiOpt(SnsType.NONE) - .roleType(RoleType.ADMIN) - .totalExp(1000) - .build(); - userRepository.save(user); - return tokenProvider.createToken(user.getId()); - } - - public User createAdminUser(){ - String randomId = UUID.randomUUID().toString().substring(0, 30); - User user = User.builder() - .eMail("email") - .intraId(randomId) - .racketType(RacketType.PENHOLDER) - .snsNotiOpt(SnsType.NONE) - .roleType(RoleType.ADMIN) - .totalExp(1000) - .build(); - userRepository.save(user); - return user; - } - - /** - * Item 에는 인트라 ID가 현재 10자로 제한되어 있음 - */ - public User createAdminUserForItem(){ - String randomId = UUID.randomUUID().toString().substring(0, 10); - User user = User.builder() - .eMail("email") - .intraId(randomId) - .racketType(RacketType.PENHOLDER) - .snsNotiOpt(SnsType.NONE) - .roleType(RoleType.ADMIN) - .totalExp(1000) - .build(); - userRepository.save(user); - return user; - } - - public User createNewUser(){ - String randomId = UUID.randomUUID().toString().substring(0, 30); - User user = User.builder() - .eMail("email") - .intraId(randomId) - .racketType(RacketType.PENHOLDER) - .snsNotiOpt(SnsType.NONE) - .roleType(RoleType.USER) - .totalExp(1000) - .build(); - userRepository.save(user); - return user; - } - - public User createNewUser(String intraId){ - User user = User.builder() - .eMail("email") - .intraId(intraId) - .racketType(RacketType.PENHOLDER) - .snsNotiOpt(SnsType.NONE) - .roleType(RoleType.USER) - .totalExp(1000) - .build(); - userRepository.save(user); - return user; - } - - public User createNewUser(String intraId, String email, RacketType racketType, - SnsType snsType, RoleType roleType){ - User user = User.builder() - .eMail(email) - .intraId(intraId) - .racketType(racketType) - .snsNotiOpt(snsType) - .roleType(roleType) - .totalExp(0) - .build(); - userRepository.save(user); - return user; - } - - public User createNewUser(int totalExp){ - String randomId = UUID.randomUUID().toString().substring(0, 30); - User user = User.builder() - .eMail("email") - .intraId(randomId) - .racketType(RacketType.PENHOLDER) - .snsNotiOpt(SnsType.NONE) - .roleType(RoleType.USER) - .totalExp(totalExp) - .build(); - userRepository.save(user); - return user; - } - - public GameInfoDto addMockDataUserLiveApi(String event, int notiCnt, String currentMatchMode, Long userId) { - User curUser = userRepository.findById(userId).get(); - for (int i = 0; i < notiCnt; i++) { - Noti noti = new Noti(curUser, NotiType.ANNOUNCE, String.valueOf(i), false); - notiRepository.save(noti); - } - LocalDateTime startTime, endTime; - Season season = createSeason(); - createUserRank(curUser, "testUserMessage", season); - Mode mode = (currentMatchMode.equals(Mode.RANK.getCode()))? Mode.RANK : Mode.NORMAL; - createGame(curUser, LocalDateTime.now().minusMinutes(100), LocalDateTime.now().minusMinutes(85), season, mode); - createGame(curUser, LocalDateTime.now().minusMinutes(50), LocalDateTime.now().minusMinutes(35), season, mode); - LocalDateTime now = LocalDateTime.now(); - if (event.equals("match")){ - startTime = now.plusMinutes(10); - endTime = startTime.plusMinutes(15); - return createGame(curUser, startTime, endTime, season, mode); - }else if (event.equals("game")){ - startTime = now.minusMinutes(5); - endTime = startTime.plusMinutes(15); - return createGame(curUser, startTime, endTime, season, mode); - } - return null; - } - - public GameInfoDto createGame(User curUser, LocalDateTime startTime, LocalDateTime endTime, Season season, Mode mode) { - LocalDateTime now = LocalDateTime.now(); - Game game; - if (now.isBefore(startTime)) - game = new Game(season, StatusType.BEFORE, mode, startTime, endTime); - else if (now.isAfter(startTime) && now.isBefore(endTime)) - game = new Game(season, StatusType.LIVE, mode, startTime, endTime); - else - game = new Game(season, StatusType.END, mode, startTime, endTime); - Team myTeam = new Team(game, -1, false); - TeamUser teamUser = new TeamUser(myTeam, curUser); - User enemyUser = createNewUser(); - Team enemyTeam = new Team(game, -1, false); - TeamUser enemyTeamUser = new TeamUser(enemyTeam, enemyUser); - createUserRank(curUser, "statusMessage", season); - createUserRank(enemyUser, "enemyUserMeassage", season); - gameRepository.save(game); - return new GameInfoDto(game.getId(), myTeam.getId(), curUser.getId(), enemyTeam.getId(), enemyUser.getId()); - } - - - public Season createSeason(){ - LocalDateTime startTime = LocalDateTime.now().minusMinutes(5); - LocalDateTime endTime = startTime.plusMonths(1); - Season season = seasonRepository.findCurrentSeason(LocalDateTime.now()).orElse(null); - if (season == null) - season = new Season("name", startTime.minusMinutes(1), endTime, 1000, 300); - seasonRepository.save(season); - return season; - } - - public void createUserRank(User newUser, String statusMessage, Season season) { - if (rankRepository.findByUserIdAndSeasonId(newUser.getId(), season.getId()).isPresent()) - return ; - String zSetKey = RedisKeyManager.getZSetKey(season.getId()); - String hashKey = RedisKeyManager.getHashKey(season.getId()); - redisRepository.addRankData(hashKey, newUser.getId(), - new RankRedis(newUser.getId(), "aa", season.getStartPpp(), 0, 0, statusMessage, "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000")); - Rank userRank = Rank.builder() - .user(newUser) - .season(season) - .ppp(season.getStartPpp()) - .wins(0) - .losses(0) - .statusMessage(statusMessage) - .build(); - rankRepository.save(userRank); - } - - public void createUserRank(User newUser, String statusMessage, Season season, Tier tier) { - if (rankRepository.findByUserIdAndSeasonId(newUser.getId(), season.getId()).isPresent()) - return ; - String zSetKey = RedisKeyManager.getZSetKey(season.getId()); - String hashKey = RedisKeyManager.getHashKey(season.getId()); - redisRepository.addRankData(hashKey, newUser.getId(), - new RankRedis(newUser.getId(), "aa", season.getStartPpp(), 0, 0, statusMessage, "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000")); - Rank userRank = Rank.builder() - .user(newUser) - .season(season) - .ppp(season.getStartPpp()) - .wins(0) - .losses(0) - .statusMessage(statusMessage) - .tier(tier) - .build(); - rankRepository.save(userRank); - } - - public void createUserRank(User newUser, String statusMessage, Season season, int ppp) { - String zSetKey = RedisKeyManager.getZSetKey(season.getId()); - String hashKey = RedisKeyManager.getHashKey(season.getId()); - Tier tier = tierRepository.findStartTier().get(); - redisRepository.addToZSet(zSetKey, newUser.getId(), ppp); - redisRepository.addRankData(hashKey, newUser.getId(), - new RankRedis(newUser.getId(), "aa", ppp, 1, 0, statusMessage, "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000")); - Rank userRank = Rank.builder() - .user(newUser) - .season(season) - .ppp(ppp) - .wins(1) - .losses(0) - .statusMessage(statusMessage) - .tier(tier) - .build(); - rankRepository.save(userRank); - } - - public void createMockMatchWithMockRank(User newUser, Season season, LocalDateTime startTime, LocalDateTime endTime) { - Game game = new Game(season, StatusType.END, Mode.RANK, startTime, endTime); - gameRepository.save(game); - Team myTeam = new Team(game, 0, false); - TeamUser teamUser = new TeamUser(myTeam, newUser); - Team enemyTeam = new Team(game, 0, false); - User enemyUser = createNewUser(); - TeamUser enemyTeamUser = new TeamUser(enemyTeam, enemyUser); - createUserRank(enemyUser, "status message", season); - teamRepository.save(myTeam); - teamRepository.save(enemyTeam); - teamUserRepository.save(teamUser); - teamUserRepository.save(enemyTeamUser); - - PChange pChange1 = new PChange(game, newUser, 1100, true); - PChange pChange2 = new PChange(game, enemyUser, 900, true); - pChangeRepository.save(pChange1); - pChangeRepository.save(pChange2); - } - - public void createMockMatch(User newUser, Season season, LocalDateTime startTime, LocalDateTime endTime) { - Game game = new Game(season, StatusType.END, Mode.RANK, startTime, endTime); - gameRepository.save(game); - Team myTeam = new Team(game, 0, false); - TeamUser teamUser = new TeamUser(myTeam, newUser); - Team enemyTeam = new Team(game, 0, false); - User enemyUser = createNewUser(); - TeamUser enemyTeamUser = new TeamUser(enemyTeam, enemyUser); - teamRepository.save(myTeam); - teamRepository.save(enemyTeam); - teamUserRepository.save(teamUser); - teamUserRepository.save(enemyTeamUser); - - PChange pChange1 = new PChange(game, newUser, 1100, true); - PChange pChange2 = new PChange(game, enemyUser, 900, true); - - pChangeRepository.save(pChange1); - pChangeRepository.save(pChange2); - } - - public Game createMockMatch(User newUser, Season season, LocalDateTime startTime, LocalDateTime endTime, Mode mode) { - Game game = new Game(season, StatusType.END, mode, startTime, endTime); - gameRepository.save(game); - Team myTeam = new Team(game, 0, false); - TeamUser teamUser = new TeamUser(myTeam, newUser); - Team enemyTeam = new Team(game, 0, false); - User enemyUser = createNewUser(); - TeamUser enemyTeamUser = new TeamUser(enemyTeam, enemyUser); - teamRepository.save(myTeam); - teamRepository.save(enemyTeam); - teamUserRepository.save(teamUser); - teamUserRepository.save(enemyTeamUser); - - PChange pChange1 = new PChange(game, newUser, 1100, true); - PChange pChange2 = new PChange(game, enemyUser, 900, true); - - pChangeRepository.save(pChange1); - pChangeRepository.save(pChange2); - return game; - } - - public Game createMockMatch(User newUser, Season season, LocalDateTime startTime, - LocalDateTime endTime, Mode mode, int myScore, int enemyScore) { - Game game = new Game(season, StatusType.END, mode, startTime, endTime); - gameRepository.save(game); - Team myTeam = new Team(game, myScore, myScore > enemyScore); - TeamUser teamUser = new TeamUser(myTeam, newUser); - Team enemyTeam = new Team(game, enemyScore, enemyScore > myScore); - User enemyUser = createNewUser(); - TeamUser enemyTeamUser = new TeamUser(enemyTeam, enemyUser); - teamRepository.save(myTeam); - teamRepository.save(enemyTeam); - teamUserRepository.save(teamUser); - teamUserRepository.save(enemyTeamUser); - - PChange pChange1 = new PChange(game, newUser, 1100, true); - PChange pChange2 = new PChange(game, enemyUser, 900, true); - - pChangeRepository.save(pChange1); - pChangeRepository.save(pChange2); - return game; - } - - /** - *

테스트용 토너먼트 반환. 매개변수 값들만 초기화

- * @param startTime 시작 시간 - * @param endTime 종료 시간 - * @param status 토너먼트 상태 - * @return 테스트용 토너먼트 - */ - public Tournament createTournament(LocalDateTime startTime, LocalDateTime endTime, TournamentStatus status) { - Tournament tournament = Tournament.builder() - .title("title") - .contents("contents") - .startTime(startTime) - .endTime(endTime) - .type(TournamentType.ROOKIE) - .status(status).build(); - return tournamentRepository.save(tournament); - } - - /** - * 테스트용 토너먼트 반환. - * @param title 제목 - * @param startTime 시작 시간 - * @param endTime 종료 시간 - * @param status 상태 - * @return 테스트용 토너먼트 - */ - public Tournament createTournament(String title, LocalDateTime startTime, LocalDateTime endTime, TournamentStatus status) { - Tournament tournament = Tournament.builder() - .title(title) - .contents("contents") - .startTime(startTime) - .endTime(endTime) - .type(TournamentType.ROOKIE) - .status(status).build(); - return tournamentRepository.save(tournament); - } - - /** - * 테스트용 토너먼트 반환. - * @param title 제목 - * @param contents 내용 - * @param startTime 시작 시간 - * @param endTime 종료 시간 - * @param type 타입 - * @param status 상태 - * @return 테스트용 토너먼트 - */ - public Tournament createTournament(String title, String contents, LocalDateTime startTime, LocalDateTime endTime, TournamentType type, TournamentStatus status) { - Tournament tournament = Tournament.builder() - .title(title) - .contents(contents) - .startTime(startTime) - .endTime(endTime) - .type(type) - .status(status).build(); - return tournamentRepository.save(tournament); - } - - /** - * 테스트용 토너먼트 생성 RequestDto 반환. - * @param startTime - * @param endTime - * @param type - * @return - */ - public TournamentAdminCreateRequestDto createRequestDto(LocalDateTime startTime, LocalDateTime endTime, TournamentType type) { - return new TournamentAdminCreateRequestDto( - "1st rookie tournament", - "welcome !", - startTime, - endTime, - type); - } - - /** - *

테스트용 토너먼트 반환. 매개변수 값들만 초기화

- * @param tournamentType - * @param tournamentStatus - * @return - */ - public Tournament createTournamentByEnum(TournamentType tournamentType, TournamentStatus tournamentStatus, LocalDateTime startTime) { - Tournament tournament = Tournament.builder() - .title("testTournament") - .contents("contents") - .startTime(startTime) - .endTime(startTime.plusDays(1)) - .type(tournamentType) - .status(tournamentStatus).build(); - return tournamentRepository.save(tournament); - } - - /** - * 테스트용 토너먼트 RequestDto 반환. 매개변수 값들만 초기화 - * @param startTime 시작 시간 - * @param endTime 종료 시간 - * @param type 토너먼트 종류 - * @return 테스트용 토너먼트 RequestDto - */ - public TournamentAdminUpdateRequestDto createUpdateRequestDto(LocalDateTime startTime, LocalDateTime endTime, TournamentType type) { - return new TournamentAdminUpdateRequestDto( - "title", - "contents", - startTime, - endTime, - type); - } - - /** - *

테스트용 토너먼트 게임 리스트 반환. 매개변수 값들만 초기화

- * @param tournament 토너먼트 게임에 넣어 줄 토너먼트 - * @param cnt 반환 리스트 크기, 8강기준 7개 - * @return 토너먼트 게임 리스트 - */ - public List createTournamentGameList(Tournament tournament, int cnt) { - List tournamentGameList = new ArrayList<>(); - TournamentRound [] values = TournamentRound.values(); - - while (--cnt >= 0) { - tournamentGameList.add(new TournamentGame(null, tournament, values[cnt])); - } - return tournamentGameRepository.saveAll(tournamentGameList); - } - - /** - *

토너먼트 유저 생성 및 저장

- * @param user 토너먼트 참가 신청 유저 - * @param tournament 해당 토너먼트 - * @param isJoined 참가자 1, 대기자 0 - * @return - */ - public TournamentUser createTournamentUser(User user, Tournament tournament, boolean isJoined) { - TournamentUser tournamentUser = new TournamentUser(user, tournament, isJoined, LocalDateTime.now()); - return tournamentUserRepository.save(tournamentUser); - } - - public List makeTournamentList() { - int joinUserCnt = 8; - int notJoinUserCnt = 4; - List tournamentResponseDtos = new ArrayList<>(); - - User winner = createNewUser("winner_sgo", "winner@gmail.com", RacketType.PENHOLDER, SnsType.NONE, RoleType.USER); - UserImageDto winnerImage = new UserImageDto(winner); - for (int i = 0; i < joinUserCnt + notJoinUserCnt; i++) { - User newUser = createNewUser("42gg_tester" + i, "tester" + i + "@gmail.com", RacketType.PENHOLDER, SnsType.NONE, RoleType.USER); - userRepository.save(newUser); - } - int day = 100; - for (TournamentType type : TournamentType.values()) { - for (TournamentStatus status : TournamentStatus.values()) { - for (int i = 0; i < 5; i++) { - Tournament tournament = createTournamentByEnum(type, status, LocalDateTime.now().plusDays(day++)); - tournamentResponseDtos.add(new TournamentResponseDto(tournament, winnerImage, joinUserCnt)); - tournament.updateWinner(winner); - for (int j = 0; j < joinUserCnt; j++) { - TournamentUser tournamentUser = new TournamentUser(userRepository.findByIntraId("42gg_tester" + j).get(), tournament, true, LocalDateTime.now()); - tournamentUserRepository.save(tournamentUser); - tournament.getTournamentUsers().add(tournamentUser); - } - for (int j = joinUserCnt; j < joinUserCnt + notJoinUserCnt; j++) { - TournamentUser tournamentUser = new TournamentUser(userRepository.findByIntraId("42gg_tester" + j).get(), tournament, false, LocalDateTime.now()); - tournamentUserRepository.save(tournamentUser); - tournament.getTournamentUsers().add(tournamentUser); - } - tournamentRepository.save(tournament); - } - } - } - tournamentResponseDtos.sort((o1, o2) -> o2.getStartTime().compareTo(o1.getStartTime())); - return tournamentResponseDtos; - } - - public Tournament createTournamentWithUser(int joinUserCnt, int notJoinUserCnt, String testName) { - Tournament tournament = Tournament.builder() - .title("testTournament") - .contents("contents") - .startTime(LocalDateTime.now()) - .endTime(LocalDateTime.now().plusDays(1)) - .type(TournamentType.ROOKIE) - .status(TournamentStatus.BEFORE).build(); - for (int i = 0; i < joinUserCnt + notJoinUserCnt; i++) { - User newUser = createNewUser(testName + i, "tester" + i + "@gmail.com", RacketType.PENHOLDER, SnsType.NONE, RoleType.USER); - userRepository.save(newUser); - } - for (int j = 0; j < joinUserCnt; j++) { - TournamentUser tournamentUser = new TournamentUser(userRepository.findByIntraId(testName + j).get(), tournament, true, LocalDateTime.now()); - } - for (int j = joinUserCnt; j < joinUserCnt + notJoinUserCnt; j++) { - TournamentUser tournamentUser = new TournamentUser(userRepository.findByIntraId(testName + j).get(), tournament, false, LocalDateTime.now()); - } - return tournamentRepository.save(tournament); - } - - public TournamentGame createTournamentGame(Tournament tournament, TournamentRound round, GameInfoDto gameInfoDto) { - TournamentGame tournamentGame = new TournamentGame(gameRepository.findById(gameInfoDto.getGameId()).orElseThrow(GameNotExistException::new), tournament, round); - tournamentGameRepository.save(tournamentGame); - return tournamentGame; - } - - /** - * 티어 생성 - */ - public Tier createTier(String url) { - Tier tier = new Tier(url); - tierRepository.save(tier); - return tier; - } - - /** - * 현재 시스템에 맞는 티어 7개를 생성 - */ - public ArrayList createTierSystem(String url) { - ArrayList tiers = new ArrayList<>(); - for (int i = 0; i < 7; i++) { - Tier tier = new Tier(url + i); - tierRepository.save(tier); - tiers.add(tier); - } - return tiers; - } - - public GameInfoDto createGameWithTierAndRank(User curUser, LocalDateTime startTime, LocalDateTime endTime, Season season, Mode mode, Tier tier) { - LocalDateTime now = LocalDateTime.now(); - Game game; - if (now.isBefore(startTime)) - game = new Game(season, StatusType.BEFORE, mode, startTime, endTime); - else if (now.isAfter(startTime) && now.isBefore(endTime)) - game = new Game(season, StatusType.LIVE, mode, startTime, endTime); - else - game = new Game(season, StatusType.END, mode, startTime, endTime); - gameRepository.save(game); - - User enemyUser = createNewUser(); - Team myTeam = new Team(game, -1, false); - Team enemyTeam = new Team(game, -1, false); - TeamUser teamUser = new TeamUser(myTeam, curUser); - TeamUser enemyTeamUser = new TeamUser(enemyTeam, enemyUser); - createUserRank(curUser, "statusMessage", season, tier); - createUserRank(enemyUser, "enemyUserMeassage", season, tier); - teamRepository.save(myTeam); - teamRepository.save(enemyTeam); - teamUserRepository.save(teamUser); - teamUserRepository.save(enemyTeamUser); - - return new GameInfoDto(game.getId(), myTeam.getId(), curUser.getId(), enemyTeam.getId(), - enemyUser.getId()); - } - - public CoinPolicy createCoinPolicy(User user, int attendance, int normal, int rankWin, int rankLose) { - CoinPolicy coinPolicy = CoinPolicy.builder() - .user(user) - .attendance(attendance) - .normal(normal) - .rankWin(rankWin) - .rankLose(rankLose) - .build(); - coinPolicyRepository.save(coinPolicy); - return coinPolicy; - } - - public Announcement createAnnouncement(User creator, String content) { - Announcement announcement = Announcement.builder() - .creatorIntraId(creator.getIntraId()) - .content(content) - .build(); - announcementRepository.save(announcement); - return announcement; - } - - /** - * 공지사항 여러개 생성. - * 가장 최신 이외는 갱신처리. - * - * @param creator - * @param cnt - * @return 생성된 공지사항 리스트 - */ - public ArrayList createAnnouncements(User creator, int cnt) { - return IntStream.range(0, cnt) - .mapToObj(i -> { - Announcement announcement = createAnnouncement(creator, "content" + i); - if (i != cnt - 1) announcement.update(creator.getIntraId(), LocalDateTime.now()); - return announcement; - }) - .collect(Collectors.toCollection(ArrayList::new)); - } - - public UserImage createUserImage(User user) { - UserImage userImage = new UserImage(user, "testUrl", - LocalDateTime.now(), null, true); - userImageRepository.save(userImage); - return userImage; - } - - public ArrayList createUserImages(User user, int cnt) { - return IntStream.range(0, cnt) - .mapToObj(i -> { - UserImage userImage = createUserImage(user); - if (i != cnt - 1) userImage.updateDeletedAt(LocalDateTime.now()); - return userImage; - }) - .collect(Collectors.toCollection(ArrayList::new)); - } - - public List createUsers(int cnt) { - List users = new ArrayList<>(); - for (int i = 0; i < cnt; i++) { - users.add(createNewUser("testUser" + i, "testUser" + i + "@gmail.com", RacketType.PENHOLDER, SnsType.NONE, RoleType.USER)); - } - userRepository.saveAll(users); - return users; - } - - public SlotManagement createSlotManagement(Integer interval) { - SlotManagement slotManagement = SlotManagement.builder() - .futureSlotTime(12) - .pastSlotTime(5) - .gameInterval(interval) - .openMinute(5) - .startTime(LocalDateTime.now().minusHours(2)) - .build(); - slotManagementRepository.save(slotManagement); - return slotManagement; - } - - public SlotManagement createSlot(int gameInterval) { - SlotManagement slotManagement = SlotManagement.builder() - .pastSlotTime(0) - .futureSlotTime(0) - .openMinute(0) - .gameInterval(gameInterval) - .startTime(LocalDateTime.now().minusHours(1)) - .build(); - return slotManagementRepository.save(slotManagement); - } -} +package com.gg.server.utils; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import org.springframework.stereotype.Component; + +import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; +import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; +import com.gg.server.domain.announcement.data.Announcement; +import com.gg.server.domain.announcement.data.AnnouncementRepository; +import com.gg.server.domain.coin.data.CoinPolicy; +import com.gg.server.domain.coin.data.CoinPolicyRepository; +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.data.GameRepository; +import com.gg.server.domain.game.exception.GameNotExistException; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.noti.data.Noti; +import com.gg.server.domain.noti.data.NotiRepository; +import com.gg.server.domain.noti.type.NotiType; +import com.gg.server.domain.pchange.data.PChange; +import com.gg.server.domain.pchange.data.PChangeRepository; +import com.gg.server.domain.rank.data.Rank; +import com.gg.server.domain.rank.data.RankRepository; +import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.domain.rank.redis.RankRedisRepository; +import com.gg.server.domain.rank.redis.RedisKeyManager; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.data.SeasonRepository; +import com.gg.server.domain.slotmanagement.SlotManagement; +import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; +import com.gg.server.domain.team.data.Team; +import com.gg.server.domain.team.data.TeamRepository; +import com.gg.server.domain.team.data.TeamUser; +import com.gg.server.domain.team.data.TeamUserRepository; +import com.gg.server.domain.tier.data.Tier; +import com.gg.server.domain.tier.data.TierRepository; +import com.gg.server.domain.tournament.data.Tournament; +import com.gg.server.domain.tournament.data.TournamentGame; +import com.gg.server.domain.tournament.data.TournamentGameRepository; +import com.gg.server.domain.tournament.data.TournamentRepository; +import com.gg.server.domain.tournament.data.TournamentUser; +import com.gg.server.domain.tournament.data.TournamentUserRepository; +import com.gg.server.domain.tournament.dto.TournamentResponseDto; +import com.gg.server.domain.tournament.type.TournamentRound; +import com.gg.server.domain.tournament.type.TournamentStatus; +import com.gg.server.domain.tournament.type.TournamentType; +import com.gg.server.domain.user.controller.dto.GameInfoDto; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserImage; +import com.gg.server.domain.user.data.UserImageRepository; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserImageDto; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; + +import lombok.RequiredArgsConstructor; + +@Component +@RequiredArgsConstructor +public class TestDataUtils { + private final UserRepository userRepository; + private final AuthTokenProvider tokenProvider; + private final NotiRepository notiRepository; + private final SeasonRepository seasonRepository; + private final GameRepository gameRepository; + private final TeamUserRepository teamUserRepository; + private final TeamRepository teamRepository; + private final RankRedisRepository redisRepository; + private final PChangeRepository pChangeRepository; + private final RankRepository rankRepository; + private final TierRepository tierRepository; + private final TournamentRepository tournamentRepository; + private final TournamentGameRepository tournamentGameRepository; + private final TournamentUserRepository tournamentUserRepository; + private final AnnouncementRepository announcementRepository; + private final CoinPolicyRepository coinPolicyRepository; + private final UserImageRepository userImageRepository; + private final SlotManagementRepository slotManagementRepository; + + public String getLoginAccessToken() { + User user = User.builder() + .eMail("email") + .intraId("intraId") + .racketType(RacketType.PENHOLDER) + .snsNotiOpt(SnsType.NONE) + .roleType(RoleType.USER) + .totalExp(1000) + .build(); + userRepository.save(user); + return tokenProvider.createToken(user.getId()); + } + + public String getLoginAccessTokenFromUser(User user) { + return tokenProvider.createToken(user.getId()); + } + + public String getAdminLoginAccessToken() { + User user = User.builder() + .eMail("email") + .intraId("intraId") + .racketType(RacketType.PENHOLDER) + .snsNotiOpt(SnsType.NONE) + .roleType(RoleType.ADMIN) + .totalExp(1000) + .build(); + userRepository.save(user); + return tokenProvider.createToken(user.getId()); + } + + public User createAdminUser() { + String randomId = UUID.randomUUID().toString().substring(0, 30); + User user = User.builder() + .eMail("email") + .intraId(randomId) + .racketType(RacketType.PENHOLDER) + .snsNotiOpt(SnsType.NONE) + .roleType(RoleType.ADMIN) + .totalExp(1000) + .build(); + userRepository.save(user); + return user; + } + + /** + * Item 에는 인트라 ID가 현재 10자로 제한되어 있음 + */ + public User createAdminUserForItem() { + String randomId = UUID.randomUUID().toString().substring(0, 10); + User user = User.builder() + .eMail("email") + .intraId(randomId) + .racketType(RacketType.PENHOLDER) + .snsNotiOpt(SnsType.NONE) + .roleType(RoleType.ADMIN) + .totalExp(1000) + .build(); + userRepository.save(user); + return user; + } + + public User createNewUser() { + String randomId = UUID.randomUUID().toString().substring(0, 30); + User user = User.builder() + .eMail("email") + .intraId(randomId) + .racketType(RacketType.PENHOLDER) + .snsNotiOpt(SnsType.NONE) + .roleType(RoleType.USER) + .totalExp(1000) + .build(); + userRepository.save(user); + return user; + } + + public User createNewUser(String intraId) { + User user = User.builder() + .eMail("email") + .intraId(intraId) + .racketType(RacketType.PENHOLDER) + .snsNotiOpt(SnsType.NONE) + .roleType(RoleType.USER) + .totalExp(1000) + .build(); + userRepository.save(user); + return user; + } + + public User createNewUser(String intraId, String email, RacketType racketType, + SnsType snsType, RoleType roleType) { + User user = User.builder() + .eMail(email) + .intraId(intraId) + .racketType(racketType) + .snsNotiOpt(snsType) + .roleType(roleType) + .totalExp(0) + .build(); + userRepository.save(user); + return user; + } + + public User createNewUser(int totalExp) { + String randomId = UUID.randomUUID().toString().substring(0, 30); + User user = User.builder() + .eMail("email") + .intraId(randomId) + .racketType(RacketType.PENHOLDER) + .snsNotiOpt(SnsType.NONE) + .roleType(RoleType.USER) + .totalExp(totalExp) + .build(); + userRepository.save(user); + return user; + } + + public GameInfoDto addMockDataUserLiveApi(String event, int notiCnt, String currentMatchMode, Long userId) { + User curUser = userRepository.findById(userId).get(); + for (int i = 0; i < notiCnt; i++) { + Noti noti = new Noti(curUser, NotiType.ANNOUNCE, String.valueOf(i), false); + notiRepository.save(noti); + } + LocalDateTime startTime; + LocalDateTime endTime; + Season season = createSeason(); + createUserRank(curUser, "testUserMessage", season); + Mode mode = (currentMatchMode.equals(Mode.RANK.getCode())) ? Mode.RANK : Mode.NORMAL; + createGame(curUser, LocalDateTime.now().minusMinutes(100), LocalDateTime.now().minusMinutes(85), season, mode); + createGame(curUser, LocalDateTime.now().minusMinutes(50), LocalDateTime.now().minusMinutes(35), season, mode); + LocalDateTime now = LocalDateTime.now(); + if (event.equals("match")) { + startTime = now.plusMinutes(10); + endTime = startTime.plusMinutes(15); + return createGame(curUser, startTime, endTime, season, mode); + } else if (event.equals("game")) { + startTime = now.minusMinutes(5); + endTime = startTime.plusMinutes(15); + return createGame(curUser, startTime, endTime, season, mode); + } + return null; + } + + public GameInfoDto createGame(User curUser, LocalDateTime startTime, LocalDateTime endTime, Season season, + Mode mode) { + LocalDateTime now = LocalDateTime.now(); + Game game; + if (now.isBefore(startTime)) { + game = new Game(season, StatusType.BEFORE, mode, startTime, endTime); + } else if (now.isAfter(startTime) && now.isBefore(endTime)) { + game = new Game(season, StatusType.LIVE, mode, startTime, endTime); + } else { + game = new Game(season, StatusType.END, mode, startTime, endTime); + } + Team myTeam = new Team(game, -1, false); + TeamUser teamUser = new TeamUser(myTeam, curUser); + User enemyUser = createNewUser(); + Team enemyTeam = new Team(game, -1, false); + TeamUser enemyTeamUser = new TeamUser(enemyTeam, enemyUser); + createUserRank(curUser, "statusMessage", season); + createUserRank(enemyUser, "enemyUserMeassage", season); + gameRepository.save(game); + return new GameInfoDto(game.getId(), myTeam.getId(), curUser.getId(), enemyTeam.getId(), enemyUser.getId()); + } + + public Season createSeason() { + LocalDateTime startTime = LocalDateTime.now().minusMinutes(5); + LocalDateTime endTime = startTime.plusMonths(1); + Season season = seasonRepository.findCurrentSeason(LocalDateTime.now()).orElse(null); + if (season == null) { + season = new Season("name", startTime.minusMinutes(1), endTime, 1000, 300); + } + seasonRepository.save(season); + return season; + } + + public void createUserRank(User newUser, String statusMessage, Season season) { + if (rankRepository.findByUserIdAndSeasonId(newUser.getId(), season.getId()).isPresent()) { + return; + } + String zSetKey = RedisKeyManager.getZSetKey(season.getId()); + String hashKey = RedisKeyManager.getHashKey(season.getId()); + redisRepository.addRankData(hashKey, newUser.getId(), + new RankRedis(newUser.getId(), "aa", season.getStartPpp(), 0, 0, statusMessage, + "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000")); + Rank userRank = Rank.builder() + .user(newUser) + .season(season) + .ppp(season.getStartPpp()) + .wins(0) + .losses(0) + .statusMessage(statusMessage) + .build(); + rankRepository.save(userRank); + } + + public void createUserRank(User newUser, String statusMessage, Season season, Tier tier) { + if (rankRepository.findByUserIdAndSeasonId(newUser.getId(), season.getId()).isPresent()) { + return; + } + String zSetKey = RedisKeyManager.getZSetKey(season.getId()); + String hashKey = RedisKeyManager.getHashKey(season.getId()); + redisRepository.addRankData(hashKey, newUser.getId(), + new RankRedis(newUser.getId(), "aa", season.getStartPpp(), 0, 0, statusMessage, + "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000")); + Rank userRank = Rank.builder() + .user(newUser) + .season(season) + .ppp(season.getStartPpp()) + .wins(0) + .losses(0) + .statusMessage(statusMessage) + .tier(tier) + .build(); + rankRepository.save(userRank); + } + + public void createUserRank(User newUser, String statusMessage, Season season, int ppp) { + String zSetKey = RedisKeyManager.getZSetKey(season.getId()); + String hashKey = RedisKeyManager.getHashKey(season.getId()); + Tier tier = tierRepository.findStartTier().get(); + redisRepository.addToZSet(zSetKey, newUser.getId(), ppp); + redisRepository.addRankData(hashKey, newUser.getId(), + new RankRedis(newUser.getId(), "aa", ppp, 1, 0, statusMessage, + "https://42gg-public-image.s3.ap-northeast-2.amazonaws.com/images/nheo.jpeg", "#000000")); + Rank userRank = Rank.builder() + .user(newUser) + .season(season) + .ppp(ppp) + .wins(1) + .losses(0) + .statusMessage(statusMessage) + .tier(tier) + .build(); + rankRepository.save(userRank); + } + + public void createMockMatchWithMockRank(User newUser, Season season, LocalDateTime startTime, + LocalDateTime endTime) { + Game game = new Game(season, StatusType.END, Mode.RANK, startTime, endTime); + gameRepository.save(game); + Team myTeam = new Team(game, 0, false); + TeamUser teamUser = new TeamUser(myTeam, newUser); + Team enemyTeam = new Team(game, 0, false); + User enemyUser = createNewUser(); + TeamUser enemyTeamUser = new TeamUser(enemyTeam, enemyUser); + createUserRank(enemyUser, "status message", season); + teamRepository.save(myTeam); + teamRepository.save(enemyTeam); + teamUserRepository.save(teamUser); + teamUserRepository.save(enemyTeamUser); + + PChange pChange1 = new PChange(game, newUser, 1100, true); + PChange pChange2 = new PChange(game, enemyUser, 900, true); + pChangeRepository.save(pChange1); + pChangeRepository.save(pChange2); + } + + public void createMockMatch(User newUser, Season season, LocalDateTime startTime, LocalDateTime endTime) { + Game game = new Game(season, StatusType.END, Mode.RANK, startTime, endTime); + gameRepository.save(game); + Team myTeam = new Team(game, 0, false); + TeamUser teamUser = new TeamUser(myTeam, newUser); + Team enemyTeam = new Team(game, 0, false); + User enemyUser = createNewUser(); + TeamUser enemyTeamUser = new TeamUser(enemyTeam, enemyUser); + teamRepository.save(myTeam); + teamRepository.save(enemyTeam); + teamUserRepository.save(teamUser); + teamUserRepository.save(enemyTeamUser); + + PChange pChange1 = new PChange(game, newUser, 1100, true); + PChange pChange2 = new PChange(game, enemyUser, 900, true); + + pChangeRepository.save(pChange1); + pChangeRepository.save(pChange2); + } + + public Game createMockMatch(User newUser, Season season, LocalDateTime startTime, LocalDateTime endTime, + Mode mode) { + Game game = new Game(season, StatusType.END, mode, startTime, endTime); + gameRepository.save(game); + Team myTeam = new Team(game, 0, false); + TeamUser teamUser = new TeamUser(myTeam, newUser); + Team enemyTeam = new Team(game, 0, false); + User enemyUser = createNewUser(); + TeamUser enemyTeamUser = new TeamUser(enemyTeam, enemyUser); + teamRepository.save(myTeam); + teamRepository.save(enemyTeam); + teamUserRepository.save(teamUser); + teamUserRepository.save(enemyTeamUser); + + PChange pChange1 = new PChange(game, newUser, 1100, true); + PChange pChange2 = new PChange(game, enemyUser, 900, true); + + pChangeRepository.save(pChange1); + pChangeRepository.save(pChange2); + return game; + } + + public Game createMockMatch(User newUser, Season season, LocalDateTime startTime, + LocalDateTime endTime, Mode mode, int myScore, int enemyScore) { + Game game = new Game(season, StatusType.END, mode, startTime, endTime); + gameRepository.save(game); + Team myTeam = new Team(game, myScore, myScore > enemyScore); + TeamUser teamUser = new TeamUser(myTeam, newUser); + Team enemyTeam = new Team(game, enemyScore, enemyScore > myScore); + User enemyUser = createNewUser(); + TeamUser enemyTeamUser = new TeamUser(enemyTeam, enemyUser); + teamRepository.save(myTeam); + teamRepository.save(enemyTeam); + teamUserRepository.save(teamUser); + teamUserRepository.save(enemyTeamUser); + + PChange pChange1 = new PChange(game, newUser, 1100, true); + PChange pChange2 = new PChange(game, enemyUser, 900, true); + + pChangeRepository.save(pChange1); + pChangeRepository.save(pChange2); + return game; + } + + /** + *

테스트용 토너먼트 반환. 매개변수 값들만 초기화

+ * @param startTime 시작 시간 + * @param endTime 종료 시간 + * @param status 토너먼트 상태 + * @return 테스트용 토너먼트 + */ + public Tournament createTournament(LocalDateTime startTime, LocalDateTime endTime, TournamentStatus status) { + Tournament tournament = Tournament.builder() + .title("title") + .contents("contents") + .startTime(startTime) + .endTime(endTime) + .type(TournamentType.ROOKIE) + .status(status).build(); + return tournamentRepository.save(tournament); + } + + /** + * 테스트용 토너먼트 반환. + * @param title 제목 + * @param startTime 시작 시간 + * @param endTime 종료 시간 + * @param status 상태 + * @return 테스트용 토너먼트 + */ + public Tournament createTournament(String title, LocalDateTime startTime, LocalDateTime endTime, + TournamentStatus status) { + Tournament tournament = Tournament.builder() + .title(title) + .contents("contents") + .startTime(startTime) + .endTime(endTime) + .type(TournamentType.ROOKIE) + .status(status).build(); + return tournamentRepository.save(tournament); + } + + /** + * 테스트용 토너먼트 반환. + * @param title 제목 + * @param contents 내용 + * @param startTime 시작 시간 + * @param endTime 종료 시간 + * @param type 타입 + * @param status 상태 + * @return 테스트용 토너먼트 + */ + public Tournament createTournament(String title, String contents, LocalDateTime startTime, LocalDateTime endTime, + TournamentType type, TournamentStatus status) { + Tournament tournament = Tournament.builder() + .title(title) + .contents(contents) + .startTime(startTime) + .endTime(endTime) + .type(type) + .status(status).build(); + return tournamentRepository.save(tournament); + } + + /** + * 테스트용 토너먼트 생성 RequestDto 반환. + * @param startTime + * @param endTime + * @param type + * @return + */ + public TournamentAdminCreateRequestDto createRequestDto(LocalDateTime startTime, LocalDateTime endTime, + TournamentType type) { + return new TournamentAdminCreateRequestDto( + "1st rookie tournament", + "welcome !", + startTime, + endTime, + type); + } + + /** + *

테스트용 토너먼트 반환. 매개변수 값들만 초기화

+ * @param tournamentType + * @param tournamentStatus + * @return + */ + public Tournament createTournamentByEnum(TournamentType tournamentType, TournamentStatus tournamentStatus, + LocalDateTime startTime) { + Tournament tournament = Tournament.builder() + .title("testTournament") + .contents("contents") + .startTime(startTime) + .endTime(startTime.plusDays(1)) + .type(tournamentType) + .status(tournamentStatus).build(); + return tournamentRepository.save(tournament); + } + + /** + * 테스트용 토너먼트 RequestDto 반환. 매개변수 값들만 초기화 + * @param startTime 시작 시간 + * @param endTime 종료 시간 + * @param type 토너먼트 종류 + * @return 테스트용 토너먼트 RequestDto + */ + public TournamentAdminUpdateRequestDto createUpdateRequestDto(LocalDateTime startTime, LocalDateTime endTime, + TournamentType type) { + return new TournamentAdminUpdateRequestDto( + "title", + "contents", + startTime, + endTime, + type); + } + + /** + *

테스트용 토너먼트 게임 리스트 반환. 매개변수 값들만 초기화

+ * @param tournament 토너먼트 게임에 넣어 줄 토너먼트 + * @param cnt 반환 리스트 크기, 8강기준 7개 + * @return 토너먼트 게임 리스트 + */ + public List createTournamentGameList(Tournament tournament, int cnt) { + List tournamentGameList = new ArrayList<>(); + TournamentRound[] values = TournamentRound.values(); + + while (--cnt >= 0) { + tournamentGameList.add(new TournamentGame(null, tournament, values[cnt])); + } + return tournamentGameRepository.saveAll(tournamentGameList); + } + + /** + *

토너먼트 유저 생성 및 저장

+ * @param user 토너먼트 참가 신청 유저 + * @param tournament 해당 토너먼트 + * @param isJoined 참가자 1, 대기자 0 + * @return + */ + public TournamentUser createTournamentUser(User user, Tournament tournament, boolean isJoined) { + TournamentUser tournamentUser = new TournamentUser(user, tournament, isJoined, LocalDateTime.now()); + return tournamentUserRepository.save(tournamentUser); + } + + public List makeTournamentList() { + int joinUserCnt = 8; + int notJoinUserCnt = 4; + List tournamentResponseDtos = new ArrayList<>(); + + User winner = createNewUser("winner_sgo", "winner@gmail.com", RacketType.PENHOLDER, SnsType.NONE, + RoleType.USER); + UserImageDto winnerImage = new UserImageDto(winner); + for (int i = 0; i < joinUserCnt + notJoinUserCnt; i++) { + User newUser = createNewUser("42gg_tester" + i, "tester" + i + "@gmail.com", RacketType.PENHOLDER, + SnsType.NONE, RoleType.USER); + userRepository.save(newUser); + } + int day = 100; + for (TournamentType type : TournamentType.values()) { + for (TournamentStatus status : TournamentStatus.values()) { + for (int i = 0; i < 5; i++) { + Tournament tournament = createTournamentByEnum(type, status, LocalDateTime.now().plusDays(day++)); + tournamentResponseDtos.add(new TournamentResponseDto(tournament, winnerImage, joinUserCnt)); + tournament.updateWinner(winner); + for (int j = 0; j < joinUserCnt; j++) { + TournamentUser tournamentUser = new TournamentUser( + userRepository.findByIntraId("42gg_tester" + j).get(), tournament, true, + LocalDateTime.now()); + tournamentUserRepository.save(tournamentUser); + tournament.getTournamentUsers().add(tournamentUser); + } + for (int j = joinUserCnt; j < joinUserCnt + notJoinUserCnt; j++) { + TournamentUser tournamentUser = new TournamentUser( + userRepository.findByIntraId("42gg_tester" + j).get(), tournament, false, + LocalDateTime.now()); + tournamentUserRepository.save(tournamentUser); + tournament.getTournamentUsers().add(tournamentUser); + } + tournamentRepository.save(tournament); + } + } + } + tournamentResponseDtos.sort((o1, o2) -> o2.getStartTime().compareTo(o1.getStartTime())); + return tournamentResponseDtos; + } + + public Tournament createTournamentWithUser(int joinUserCnt, int notJoinUserCnt, String testName) { + Tournament tournament = Tournament.builder() + .title("testTournament") + .contents("contents") + .startTime(LocalDateTime.now()) + .endTime(LocalDateTime.now().plusDays(1)) + .type(TournamentType.ROOKIE) + .status(TournamentStatus.BEFORE).build(); + for (int i = 0; i < joinUserCnt + notJoinUserCnt; i++) { + User newUser = createNewUser(testName + i, "tester" + i + "@gmail.com", RacketType.PENHOLDER, SnsType.NONE, + RoleType.USER); + userRepository.save(newUser); + } + for (int j = 0; j < joinUserCnt; j++) { + TournamentUser tournamentUser = new TournamentUser(userRepository.findByIntraId(testName + j).get(), + tournament, true, LocalDateTime.now()); + } + for (int j = joinUserCnt; j < joinUserCnt + notJoinUserCnt; j++) { + TournamentUser tournamentUser = new TournamentUser(userRepository.findByIntraId(testName + j).get(), + tournament, false, LocalDateTime.now()); + } + return tournamentRepository.save(tournament); + } + + public TournamentGame createTournamentGame(Tournament tournament, TournamentRound round, GameInfoDto gameInfoDto) { + TournamentGame tournamentGame = new TournamentGame( + gameRepository.findById(gameInfoDto.getGameId()).orElseThrow(GameNotExistException::new), tournament, + round); + tournamentGameRepository.save(tournamentGame); + return tournamentGame; + } + + /** + * 티어 생성 + */ + public Tier createTier(String url) { + Tier tier = new Tier(url); + tierRepository.save(tier); + return tier; + } + + /** + * 현재 시스템에 맞는 티어 7개를 생성 + */ + public ArrayList createTierSystem(String url) { + ArrayList tiers = new ArrayList<>(); + for (int i = 0; i < 7; i++) { + Tier tier = new Tier(url + i); + tierRepository.save(tier); + tiers.add(tier); + } + return tiers; + } + + public GameInfoDto createGameWithTierAndRank(User curUser, LocalDateTime startTime, LocalDateTime endTime, + Season season, Mode mode, Tier tier) { + LocalDateTime now = LocalDateTime.now(); + Game game; + if (now.isBefore(startTime)) { + game = new Game(season, StatusType.BEFORE, mode, startTime, endTime); + } else if (now.isAfter(startTime) && now.isBefore(endTime)) { + game = new Game(season, StatusType.LIVE, mode, startTime, endTime); + } else { + game = new Game(season, StatusType.END, mode, startTime, endTime); + } + gameRepository.save(game); + + User enemyUser = createNewUser(); + Team myTeam = new Team(game, -1, false); + Team enemyTeam = new Team(game, -1, false); + TeamUser teamUser = new TeamUser(myTeam, curUser); + TeamUser enemyTeamUser = new TeamUser(enemyTeam, enemyUser); + createUserRank(curUser, "statusMessage", season, tier); + createUserRank(enemyUser, "enemyUserMeassage", season, tier); + teamRepository.save(myTeam); + teamRepository.save(enemyTeam); + teamUserRepository.save(teamUser); + teamUserRepository.save(enemyTeamUser); + + return new GameInfoDto(game.getId(), myTeam.getId(), curUser.getId(), enemyTeam.getId(), + enemyUser.getId()); + } + + public CoinPolicy createCoinPolicy(User user, int attendance, int normal, int rankWin, int rankLose) { + CoinPolicy coinPolicy = CoinPolicy.builder() + .user(user) + .attendance(attendance) + .normal(normal) + .rankWin(rankWin) + .rankLose(rankLose) + .build(); + coinPolicyRepository.save(coinPolicy); + return coinPolicy; + } + + public Announcement createAnnouncement(User creator, String content) { + Announcement announcement = Announcement.builder() + .creatorIntraId(creator.getIntraId()) + .content(content) + .build(); + announcementRepository.save(announcement); + return announcement; + } + + /** + * 공지사항 여러개 생성. + * 가장 최신 이외는 갱신처리. + * + * @param creator + * @param cnt + * @return 생성된 공지사항 리스트 + */ + public ArrayList createAnnouncements(User creator, int cnt) { + return IntStream.range(0, cnt) + .mapToObj(i -> { + Announcement announcement = createAnnouncement(creator, "content" + i); + if (i != cnt - 1) { + announcement.update(creator.getIntraId(), LocalDateTime.now()); + } + return announcement; + }) + .collect(Collectors.toCollection(ArrayList::new)); + } + + public UserImage createUserImage(User user) { + UserImage userImage = new UserImage(user, "testUrl", + LocalDateTime.now(), null, true); + userImageRepository.save(userImage); + return userImage; + } + + public ArrayList createUserImages(User user, int cnt) { + return IntStream.range(0, cnt) + .mapToObj(i -> { + UserImage userImage = createUserImage(user); + if (i != cnt - 1) { + userImage.updateDeletedAt(LocalDateTime.now()); + } + return userImage; + }) + .collect(Collectors.toCollection(ArrayList::new)); + } + + public List createUsers(int cnt) { + List users = new ArrayList<>(); + for (int i = 0; i < cnt; i++) { + users.add( + createNewUser("testUser" + i, "testUser" + i + "@gmail.com", RacketType.PENHOLDER, + SnsType.NONE, + RoleType.USER)); + } + userRepository.saveAll(users); + return users; + } + + public SlotManagement createSlotManagement(Integer interval) { + SlotManagement slotManagement = SlotManagement.builder() + .futureSlotTime(12) + .pastSlotTime(5) + .gameInterval(interval) + .openMinute(5) + .startTime(LocalDateTime.now().minusHours(2)) + .build(); + slotManagementRepository.save(slotManagement); + return slotManagement; + } + + public SlotManagement createSlot(int gameInterval) { + SlotManagement slotManagement = SlotManagement.builder() + .pastSlotTime(0) + .futureSlotTime(0) + .openMinute(0) + .gameInterval(gameInterval) + .startTime(LocalDateTime.now().minusHours(1)) + .build(); + return slotManagementRepository.save(slotManagement); + } +} diff --git a/src/test/java/com/gg/server/utils/annotation/DataJpaUnitTest.java b/src/test/java/com/gg/server/utils/annotation/DataJpaUnitTest.java index db6241380..da53f256a 100644 --- a/src/test/java/com/gg/server/utils/annotation/DataJpaUnitTest.java +++ b/src/test/java/com/gg/server/utils/annotation/DataJpaUnitTest.java @@ -4,6 +4,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import org.junit.jupiter.api.Tag; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -17,4 +18,4 @@ @DataJpaTest public @interface DataJpaUnitTest { -} \ No newline at end of file +} diff --git a/src/test/java/com/gg/server/utils/annotation/IntegrationTest.java b/src/test/java/com/gg/server/utils/annotation/IntegrationTest.java index b21fdaddd..487b79276 100644 --- a/src/test/java/com/gg/server/utils/annotation/IntegrationTest.java +++ b/src/test/java/com/gg/server/utils/annotation/IntegrationTest.java @@ -1,17 +1,19 @@ package com.gg.server.utils.annotation; -import com.gg.server.utils.config.MySQLInitializer; -import com.gg.server.utils.config.RedisInitializer; -import com.gg.server.utils.config.TestRedisConfig; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import org.junit.jupiter.api.Tag; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; +import com.gg.server.utils.config.MySQLInitializer; +import com.gg.server.utils.config.RedisInitializer; +import com.gg.server.utils.config.TestRedisConfig; + /** * 통합테스트 환경의 의존성 관리를 위한 어노테이션. * @@ -27,4 +29,4 @@ @Tag(TestTypeConstant.INTEGRATION_TEST) public @interface IntegrationTest { -} \ No newline at end of file +} diff --git a/src/test/java/com/gg/server/utils/annotation/IntegrationTestAspect.java b/src/test/java/com/gg/server/utils/annotation/IntegrationTestAspect.java index e3c467f6d..88c4cbdfd 100644 --- a/src/test/java/com/gg/server/utils/annotation/IntegrationTestAspect.java +++ b/src/test/java/com/gg/server/utils/annotation/IntegrationTestAspect.java @@ -1,24 +1,25 @@ package com.gg.server.utils.annotation; -import com.gg.server.domain.rank.redis.RankRedisRepository; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.Aspect; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.gg.server.domain.rank.redis.RankRedisRepository; + @Aspect @Component public class IntegrationTestAspect { - @Autowired - private RankRedisRepository rankRedisRepository; + @Autowired + private RankRedisRepository rankRedisRepository; - /** - * 통합테스트 종료 후 redis 데이터 삭제 - */ - @After("execution(* *(..)) && @within(integrationTest)") - public void afterTest(JoinPoint joinPoint, IntegrationTest integrationTest) { - rankRedisRepository.deleteAll(); - } -} \ No newline at end of file + /** + * 통합테스트 종료 후 redis 데이터 삭제 + */ + @After("execution(* *(..)) && @within(integrationTest)") + public void afterTest(JoinPoint joinPoint, IntegrationTest integrationTest) { + rankRedisRepository.deleteAll(); + } +} diff --git a/src/test/java/com/gg/server/utils/annotation/IntegrationTestWithRedisTransaction.java b/src/test/java/com/gg/server/utils/annotation/IntegrationTestWithRedisTransaction.java index 5a2a0b5f9..73d41e34b 100644 --- a/src/test/java/com/gg/server/utils/annotation/IntegrationTestWithRedisTransaction.java +++ b/src/test/java/com/gg/server/utils/annotation/IntegrationTestWithRedisTransaction.java @@ -1,15 +1,17 @@ package com.gg.server.utils.annotation; -import com.gg.server.utils.config.MySQLInitializer; -import com.gg.server.utils.config.RedisInitializer; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import org.junit.jupiter.api.Tag; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ContextConfiguration; +import com.gg.server.utils.config.MySQLInitializer; +import com.gg.server.utils.config.RedisInitializer; + /** * 통합테스트 환경의 의존성 관리를 위한 어노테이션. * @@ -25,4 +27,4 @@ @Tag(TestTypeConstant.INTEGRATION_TEST) public @interface IntegrationTestWithRedisTransaction { -} \ No newline at end of file +} diff --git a/src/test/java/com/gg/server/utils/annotation/TestTypeConstant.java b/src/test/java/com/gg/server/utils/annotation/TestTypeConstant.java index c0d89cc16..b9ad8ebc3 100644 --- a/src/test/java/com/gg/server/utils/annotation/TestTypeConstant.java +++ b/src/test/java/com/gg/server/utils/annotation/TestTypeConstant.java @@ -13,6 +13,6 @@ */ @NoArgsConstructor(access = AccessLevel.PRIVATE) public class TestTypeConstant { - public static final String UNIT_TEST = "UnitTest"; - public static final String INTEGRATION_TEST = "IntegrationTest"; + public static final String UNIT_TEST = "UnitTest"; + public static final String INTEGRATION_TEST = "IntegrationTest"; } diff --git a/src/test/java/com/gg/server/utils/annotation/UnitTest.java b/src/test/java/com/gg/server/utils/annotation/UnitTest.java index 9a2dd50df..3b00b075c 100644 --- a/src/test/java/com/gg/server/utils/annotation/UnitTest.java +++ b/src/test/java/com/gg/server/utils/annotation/UnitTest.java @@ -4,6 +4,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import org.junit.jupiter.api.Tag; /** @@ -15,4 +16,4 @@ @Tag(TestTypeConstant.UNIT_TEST) public @interface UnitTest { -} \ No newline at end of file +} diff --git a/src/test/java/com/gg/server/utils/annotation/WebMvcUnitTest.java b/src/test/java/com/gg/server/utils/annotation/WebMvcUnitTest.java index 8f7fb7064..4ed284c7c 100644 --- a/src/test/java/com/gg/server/utils/annotation/WebMvcUnitTest.java +++ b/src/test/java/com/gg/server/utils/annotation/WebMvcUnitTest.java @@ -4,6 +4,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import org.junit.jupiter.api.Tag; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -17,4 +18,4 @@ @WebMvcTest public @interface WebMvcUnitTest { -} \ No newline at end of file +} diff --git a/src/test/java/com/gg/server/utils/config/MySQLInitializer.java b/src/test/java/com/gg/server/utils/config/MySQLInitializer.java index 1f4fde72e..127211a94 100644 --- a/src/test/java/com/gg/server/utils/config/MySQLInitializer.java +++ b/src/test/java/com/gg/server/utils/config/MySQLInitializer.java @@ -16,24 +16,24 @@ * @since : 2024/01/09 */ public class MySQLInitializer implements - ApplicationContextInitializer { - private static final String params = "?serverTimezone=Asia/Seoul&characterEncoding=UTF-8"; - private static final MySQLContainer MYSQL_CONTAINER = - new MySQLContainer<>("mysql:8.0") - .withDatabaseName("test") - .withUsername("root") - .withPassword("1234"); + ApplicationContextInitializer { + private static final String params = "?serverTimezone=Asia/Seoul&characterEncoding=UTF-8"; + private static final MySQLContainer MYSQL_CONTAINER = + new MySQLContainer<>("mysql:8.0") + .withDatabaseName("test") + .withUsername("root") + .withPassword("1234"); - static { - MYSQL_CONTAINER.start(); - } + static { + MYSQL_CONTAINER.start(); + } - @Override - public void initialize(ConfigurableApplicationContext applicationContext) { - TestPropertyValues.of( - "spring.datasource.url=" + MYSQL_CONTAINER.getJdbcUrl() + params, - "spring.datasource.username=" + MYSQL_CONTAINER.getUsername(), - "spring.datasource.password=" + MYSQL_CONTAINER.getPassword() - ).applyTo(applicationContext.getEnvironment()); - } + @Override + public void initialize(ConfigurableApplicationContext applicationContext) { + TestPropertyValues.of( + "spring.datasource.url=" + MYSQL_CONTAINER.getJdbcUrl() + params, + "spring.datasource.username=" + MYSQL_CONTAINER.getUsername(), + "spring.datasource.password=" + MYSQL_CONTAINER.getPassword() + ).applyTo(applicationContext.getEnvironment()); + } } diff --git a/src/test/java/com/gg/server/utils/config/RedisInitializer.java b/src/test/java/com/gg/server/utils/config/RedisInitializer.java index 5ecd919e3..508741dc5 100644 --- a/src/test/java/com/gg/server/utils/config/RedisInitializer.java +++ b/src/test/java/com/gg/server/utils/config/RedisInitializer.java @@ -1,26 +1,27 @@ package com.gg.server.utils.config; -import com.redis.testcontainers.RedisContainer; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; import org.testcontainers.utility.DockerImageName; +import com.redis.testcontainers.RedisContainer; + public class RedisInitializer implements - ApplicationContextInitializer { - private static final RedisContainer REDIS_CONTAINER = - new RedisContainer(DockerImageName.parse("redis:5.0.3-alpine")) - .withExposedPorts(6379); + ApplicationContextInitializer { + private static final RedisContainer REDIS_CONTAINER = + new RedisContainer(DockerImageName.parse("redis:5.0.3-alpine")) + .withExposedPorts(6379); - static { - REDIS_CONTAINER.start(); - } + static { + REDIS_CONTAINER.start(); + } - @Override - public void initialize(ConfigurableApplicationContext applicationContext) { - TestPropertyValues.of( - "spring.redis.host=" + REDIS_CONTAINER.getHost(), - "spring.redis.port=" + REDIS_CONTAINER.getMappedPort(6379) - ).applyTo(applicationContext.getEnvironment()); - } -} \ No newline at end of file + @Override + public void initialize(ConfigurableApplicationContext applicationContext) { + TestPropertyValues.of( + "spring.redis.host=" + REDIS_CONTAINER.getHost(), + "spring.redis.port=" + REDIS_CONTAINER.getMappedPort(6379) + ).applyTo(applicationContext.getEnvironment()); + } +} diff --git a/src/test/java/com/gg/server/utils/config/TestRedisConfig.java b/src/test/java/com/gg/server/utils/config/TestRedisConfig.java index 7e25e77c4..73edb0c44 100644 --- a/src/test/java/com/gg/server/utils/config/TestRedisConfig.java +++ b/src/test/java/com/gg/server/utils/config/TestRedisConfig.java @@ -19,19 +19,19 @@ @TestConfiguration public class TestRedisConfig { - @Primary - @Bean(name = "testRedisTemplate") - public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) { - final RedisTemplate redisTemplate = new RedisTemplate<>(); + @Primary + @Bean(name = "testRedisTemplate") + public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) { + final RedisTemplate redisTemplate = new RedisTemplate<>(); - redisTemplate.setConnectionFactory(redisConnectionFactory); - redisTemplate.setKeySerializer(new StringRedisSerializer()); - redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer()); + redisTemplate.setConnectionFactory(redisConnectionFactory); + redisTemplate.setKeySerializer(new StringRedisSerializer()); + redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer()); - redisTemplate.setHashKeySerializer(new GenericJackson2JsonRedisSerializer()); - redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer()); - redisTemplate.setEnableTransactionSupport(false); + redisTemplate.setHashKeySerializer(new GenericJackson2JsonRedisSerializer()); + redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer()); + redisTemplate.setEnableTransactionSupport(false); - return redisTemplate; - } + return redisTemplate; + } } From b2fe04fa11550f217f50725af0c31c036bcdb9ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=90=ED=9B=88?= Date: Mon, 5 Feb 2024 13:58:44 +0900 Subject: [PATCH 07/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20Announceme?= =?UTF-8?q?nt=20=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(#470)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AnnouncementAdminController.java | 8 +- .../service/AnnouncementAdminService.java | 27 +--- .../service/AnnouncementService.java | 8 +- .../AnnouncementAdminControllerUnitTest.java | 62 +++++++++ .../AnnouncementAdminServiceUnitTest.java | 121 ++++++++++++++++++ .../AnnouncementControllerUnitTest.java | 42 ++++++ .../data/AnnouncementUnitTest.java | 46 +++++++ .../service/AnnouncementServiceUnitTest.java | 72 +++++++++++ 8 files changed, 361 insertions(+), 25 deletions(-) create mode 100644 src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java create mode 100644 src/test/java/com/gg/server/admin/announcement/service/AnnouncementAdminServiceUnitTest.java create mode 100644 src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerUnitTest.java create mode 100644 src/test/java/com/gg/server/domain/announcement/data/AnnouncementUnitTest.java create mode 100644 src/test/java/com/gg/server/domain/announcement/service/AnnouncementServiceUnitTest.java diff --git a/src/main/java/com/gg/server/admin/announcement/controller/AnnouncementAdminController.java b/src/main/java/com/gg/server/admin/announcement/controller/AnnouncementAdminController.java index b750e1f84..2412d92df 100644 --- a/src/main/java/com/gg/server/admin/announcement/controller/AnnouncementAdminController.java +++ b/src/main/java/com/gg/server/admin/announcement/controller/AnnouncementAdminController.java @@ -42,16 +42,16 @@ public ResponseEntity getAnnouncementList( } @PostMapping("/announcement") - public ResponseEntity addaAnnouncement(@Valid @RequestBody AnnouncementAdminAddDto addDto) { + public ResponseEntity addAnnouncement(@Valid @RequestBody AnnouncementAdminAddDto addDto) { announcementAdminService.addAnnouncement(addDto); - return new ResponseEntity(HttpStatus.CREATED); + return ResponseEntity.status(HttpStatus.CREATED).build(); } @DeleteMapping("/announcement/{deleterIntraId}") - public ResponseEntity announcementModify(@PathVariable String deleterIntraId) { + public ResponseEntity announcementModify(@PathVariable String deleterIntraId) { announcementAdminService.modifyAnnouncementIsDel(deleterIntraId); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); } } diff --git a/src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java b/src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java index 24f272114..557936e75 100644 --- a/src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java +++ b/src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java @@ -33,35 +33,22 @@ public AnnouncementAdminListResponseDto findAllAnnouncement(Pageable pageable) { @Transactional public void addAnnouncement(AnnouncementAdminAddDto addDto) { - if (findAnnouncementExist() == true) { + Announcement announcement = announcementAdminRepository.findFirstByOrderByIdDesc() + .orElseThrow(AnnounceNotFoundException::new); + if (announcement.getDeletedAt() == null) { throw new AnnounceDupException(); } - Announcement announcementAdmin = Announcement.from(addDto); - - announcementAdminRepository.save(announcementAdmin); + announcementAdminRepository.save(Announcement.from(addDto)); } @Transactional public void modifyAnnouncementIsDel(String deleterIntraId) { - if (findAnnouncementExist() == false) { + Announcement announcement = announcementAdminRepository.findFirstByOrderByIdDesc() + .orElseThrow(AnnounceNotFoundException::new); + if (announcement.getDeletedAt() != null) { throw new AnnounceNotFoundException(); } - - Announcement announcement = announcementAdminRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new AnnounceNotFoundException()); announcement.update(deleterIntraId, LocalDateTime.now()); } - - private Boolean findAnnouncementExist() { - Announcement announcement = announcementAdminRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new AnnounceNotFoundException()); - - if (announcement.getDeletedAt() == null) { - return true; - } - - return false; - } - } diff --git a/src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java b/src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java index b08e645fc..62e1df9d4 100644 --- a/src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java +++ b/src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java @@ -15,10 +15,16 @@ public class AnnouncementService { private final AnnouncementRepository announcementRepository; + /** + *

가장 최근 공지를 찾아서 dto로 반환해준다.

+ *

만약 가장 최근 공지가 삭제 되었다면 dto에 빈값을 넣어서 반환해준다.

+ * @throws AnnounceNotFoundException 공지 없음 + * @return AnnouncementDto + */ @Transactional(readOnly = true) public AnnouncementDto findLastAnnouncement() { Announcement announcement = announcementRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new AnnounceNotFoundException()); + .orElseThrow(AnnounceNotFoundException::new); if (announcement.getDeletedAt() != null) { return new AnnouncementDto(""); } diff --git a/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java b/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java new file mode 100644 index 000000000..949e555e9 --- /dev/null +++ b/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java @@ -0,0 +1,62 @@ +package com.gg.server.admin.announcement.controller; + +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.Pageable; + +import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; +import com.gg.server.admin.announcement.dto.AnnouncementAdminListResponseDto; +import com.gg.server.admin.announcement.service.AnnouncementAdminService; +import com.gg.server.global.dto.PageRequestDto; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +@DisplayName("AnnouncementAdminControllerUnitTest") +class AnnouncementAdminControllerUnitTest { + @Mock + AnnouncementAdminService announcementAdminService; + @InjectMocks + AnnouncementAdminController announcementAdminController; + + @Nested + @DisplayName("GetAnnouncementList_메서드_unitTest") + class GetAnnouncementList { + @Test + @DisplayName("성공") + void success() { + given(announcementAdminService.findAllAnnouncement(any(Pageable.class))).willReturn( + new AnnouncementAdminListResponseDto()); + announcementAdminController.getAnnouncementList(new PageRequestDto(1, 5)); + } + } + + @Nested + @DisplayName("AddAnnouncement_메서드_unitTest") + class AddAnnouncement { + @Test + @DisplayName("성공") + void success() { + announcementAdminController.addAnnouncement(mock(AnnouncementAdminAddDto.class)); + } + } + + @Nested + @DisplayName("AnnouncementModify_메서드_unitTest") + class AnnouncementModify { + @Test + @DisplayName("성공") + void success() { + announcementAdminController.announcementModify("deleterIntraId"); + } + } +} diff --git a/src/test/java/com/gg/server/admin/announcement/service/AnnouncementAdminServiceUnitTest.java b/src/test/java/com/gg/server/admin/announcement/service/AnnouncementAdminServiceUnitTest.java new file mode 100644 index 000000000..9febda647 --- /dev/null +++ b/src/test/java/com/gg/server/admin/announcement/service/AnnouncementAdminServiceUnitTest.java @@ -0,0 +1,121 @@ +package com.gg.server.admin.announcement.service; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; + +import com.gg.server.admin.announcement.data.AnnouncementAdminRepository; +import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; +import com.gg.server.domain.announcement.data.Announcement; +import com.gg.server.domain.announcement.exception.AnnounceDupException; +import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +@DisplayName("AnnouncementAdminServiceUnitTest") +class AnnouncementAdminServiceUnitTest { + @Mock + AnnouncementAdminRepository announcementAdminRepository; + @InjectMocks + AnnouncementAdminService announcementAdminService; + + @Nested + @DisplayName("findAllAnnouncement_메서드_unitTest") + class FindAllAnnouncementTest { + @Test + @DisplayName("성공") + void success() { + List announcementList = new ArrayList<>(); + given(announcementAdminRepository.findAll(any(Pageable.class))) + .willReturn(new PageImpl<>(announcementList)); + announcementAdminService.findAllAnnouncement(mock(Pageable.class)); + verify(announcementAdminRepository, times(1)).findAll(any(Pageable.class)); + } + } + + @Nested + @DisplayName("addAnnouncement_메서드_unitTest") + class AddAnnouncementTest { + @Test + @DisplayName("성공") + void success() { + String intraId = "intraId"; + LocalDateTime curTime = LocalDateTime.now(); + Announcement announcement = new Announcement(); + announcement.update(intraId, curTime); + given(announcementAdminRepository.findFirstByOrderByIdDesc()).willReturn(Optional.of(announcement)); + announcementAdminService.addAnnouncement(new AnnouncementAdminAddDto()); + verify(announcementAdminRepository, times(1)).findFirstByOrderByIdDesc(); + } + + @Test + @DisplayName("AnnounceNotFound") + void announceNotFound() { + given(announcementAdminRepository.findFirstByOrderByIdDesc()).willReturn(Optional.empty()); + assertThatThrownBy(() -> announcementAdminService.addAnnouncement(new AnnouncementAdminAddDto())) + .isInstanceOf(AnnounceNotFoundException.class); + verify(announcementAdminRepository, times(1)).findFirstByOrderByIdDesc(); + } + + @Test + @DisplayName("Announce_삭제_안된_경우") + void announceNotDeleted() { + Announcement announcement = new Announcement(); + given(announcementAdminRepository.findFirstByOrderByIdDesc()).willReturn(Optional.of(announcement)); + assertThatThrownBy(() -> announcementAdminService.addAnnouncement(new AnnouncementAdminAddDto())) + .isInstanceOf(AnnounceDupException.class); + verify(announcementAdminRepository, times(1)).findFirstByOrderByIdDesc(); + } + } + + @Nested + @DisplayName("modifyAnnouncementIsDel_메서드_unitTest") + class ModifyAnnouncementIsDelTest { + final String intraId = "intraId"; + + @Test + @DisplayName("성공") + void success() { + Announcement announcement = new Announcement(); + given(announcementAdminRepository.findFirstByOrderByIdDesc()).willReturn(Optional.of(announcement)); + announcementAdminService.modifyAnnouncementIsDel(intraId); + verify(announcementAdminRepository, times(1)).findFirstByOrderByIdDesc(); + } + + @Test + @DisplayName("AnnounceNotFound") + void announceNotFound() { + given(announcementAdminRepository.findFirstByOrderByIdDesc()).willReturn(Optional.empty()); + assertThatThrownBy(() -> announcementAdminService.modifyAnnouncementIsDel(intraId)) + .isInstanceOf(AnnounceNotFoundException.class); + verify(announcementAdminRepository, times(1)).findFirstByOrderByIdDesc(); + } + + @Test + @DisplayName("삭제된_Announce_삭제") + void deleteFail() { + Announcement announcement = new Announcement(); + announcement.update(intraId, LocalDateTime.now()); + given(announcementAdminRepository.findFirstByOrderByIdDesc()).willReturn(Optional.of(announcement)); + assertThatThrownBy(() -> announcementAdminService.modifyAnnouncementIsDel(intraId)) + .isInstanceOf(AnnounceNotFoundException.class); + verify(announcementAdminRepository, times(1)).findFirstByOrderByIdDesc(); + } + } +} diff --git a/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerUnitTest.java b/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerUnitTest.java new file mode 100644 index 000000000..6555ff225 --- /dev/null +++ b/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerUnitTest.java @@ -0,0 +1,42 @@ +package com.gg.server.domain.announcement.controller; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.BDDMockito.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.domain.announcement.dto.AnnouncementDto; +import com.gg.server.domain.announcement.dto.AnnouncementResponseDto; +import com.gg.server.domain.announcement.service.AnnouncementService; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +@DisplayName("AnnouncementControllerUnitTest") +class AnnouncementControllerUnitTest { + @Mock + AnnouncementService announcementService; + @InjectMocks + AnnouncementController announcementController; + + @Nested + @DisplayName("findLastAnnounceContent_메서드_unitTest") + class FindLastAnnounceContentTest { + @Test + @DisplayName("성공") + void success() { + //given + String content = "content"; + given(announcementService.findLastAnnouncement()).willReturn(new AnnouncementDto(content)); + // when, then + assertThat(announcementController.findLastAnnounceContent()).isInstanceOf(AnnouncementResponseDto.class); + assertThat(announcementController.findLastAnnounceContent().getContent()).isEqualTo(content); + } + } +} diff --git a/src/test/java/com/gg/server/domain/announcement/data/AnnouncementUnitTest.java b/src/test/java/com/gg/server/domain/announcement/data/AnnouncementUnitTest.java new file mode 100644 index 000000000..667d568ad --- /dev/null +++ b/src/test/java/com/gg/server/domain/announcement/data/AnnouncementUnitTest.java @@ -0,0 +1,46 @@ +package com.gg.server.domain.announcement.data; + +import static org.assertj.core.api.Assertions.*; + +import java.time.LocalDateTime; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +@DisplayName("AnnouncementUnitTest") +class AnnouncementUnitTest { + final String content = "content"; + final String intraId = "intraId"; + + @Nested + @DisplayName("findLastAnnouncement_메서드_unitTest") + class FindLastAnnounceContentTest { + @Test + @DisplayName("update_메서드_unitTest") + void updateTest() { + String deleterIntraId = "deleter"; + LocalDateTime curTime = LocalDateTime.now(); + Announcement announcement = new Announcement(content, intraId); + announcement.update(deleterIntraId, curTime); + assertThat(announcement.getDeleterIntraId()).isEqualTo(deleterIntraId); + assertThat(announcement.getDeletedAt()).isEqualTo(curTime); + } + + @Test + @DisplayName("from_메서드_unitTest") + void fromTest() { + AnnouncementAdminAddDto dto = new AnnouncementAdminAddDto(content, intraId); + Announcement announcement = Announcement.from(dto); + assertThat(announcement.getContent()).isEqualTo(dto.getContent()); + assertThat(announcement.getCreatorIntraId()).isEqualTo(dto.getCreatorIntraId()); + } + } +} diff --git a/src/test/java/com/gg/server/domain/announcement/service/AnnouncementServiceUnitTest.java b/src/test/java/com/gg/server/domain/announcement/service/AnnouncementServiceUnitTest.java new file mode 100644 index 000000000..bb2631963 --- /dev/null +++ b/src/test/java/com/gg/server/domain/announcement/service/AnnouncementServiceUnitTest.java @@ -0,0 +1,72 @@ +package com.gg.server.domain.announcement.service; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.BDDMockito.*; + +import java.time.LocalDateTime; +import java.util.Optional; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.domain.announcement.data.Announcement; +import com.gg.server.domain.announcement.data.AnnouncementRepository; +import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +@DisplayName("AnnouncementServiceUnitTest") +class AnnouncementServiceUnitTest { + @Mock + AnnouncementRepository announcementRepository; + @InjectMocks + AnnouncementService announcementService; + + @Nested + @DisplayName("findLastAnnouncement_메서드_unitTest") + class FindLastAnnounceContentTest { + @Test + @DisplayName("성공") + void success() { + //given + String content = "content"; + String intraId = "intraId"; + Announcement announcement = new Announcement(content, intraId); + given(announcementRepository.findFirstByOrderByIdDesc()).willReturn(Optional.of(announcement)); + // when, then + assertThat(announcementService.findLastAnnouncement().getContent()).isEqualTo(content); + verify(announcementRepository, times(1)).findFirstByOrderByIdDesc(); + } + + @Test + @DisplayName("성공_삭제된_announcement") + void successAnnouncementDeleted() { + //given + String content = "content"; + String intraId = "intraId"; + Announcement announcement = new Announcement(content, intraId); + announcement.update(intraId, LocalDateTime.now()); + given(announcementRepository.findFirstByOrderByIdDesc()).willReturn(Optional.of(announcement)); + // when, then + assertThat(announcementService.findLastAnnouncement().getContent()).isEqualTo(""); + verify(announcementRepository, times(1)).findFirstByOrderByIdDesc(); + } + + @Test + @DisplayName("Announcement_404") + void announcementNotFound() { + //given + given(announcementRepository.findFirstByOrderByIdDesc()).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> announcementService.findLastAnnouncement()) + .isInstanceOf(AnnounceNotFoundException.class); + verify(announcementRepository, times(1)).findFirstByOrderByIdDesc(); + } + } +} From 7040877a4a206a4e69ce82bb3993b45b77c514d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=90=ED=9B=88?= Date: Mon, 5 Feb 2024 13:59:03 +0900 Subject: [PATCH 08/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20Feedback?= =?UTF-8?q?=20=EC=9C=A0=EB=8B=9B=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=EA=B8=B0=EC=A1=B4=20=EC=BF=BC=EB=A6=AC?= =?UTF-8?q?=EB=AC=B8=20=EC=88=98=EC=A0=95=20(#481)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FeedbackAdminController.java | 24 +++-- .../data/FeedbackAdminRepository.java | 9 +- .../data/FeedbackAdminRepositorySearch.java | 11 --- .../FeedbackAdminRepositorySearchImpl.java | 39 -------- .../service/FeedbackAdminService.java | 45 ++++++---- .../FeedbackAdminControllerUnitTest.java | 66 ++++++++++++++ .../service/FeedbackAdminServiceUnitTest.java | 90 +++++++++++++++++++ .../FeedbackControllerUnitTest.java | 39 ++++++++ .../service/FeedbackServiceUnitTest.java | 61 +++++++++++++ 9 files changed, 310 insertions(+), 74 deletions(-) delete mode 100644 src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearch.java delete mode 100644 src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearchImpl.java create mode 100644 src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerUnitTest.java create mode 100644 src/test/java/com/gg/server/admin/feedback/service/FeedbackAdminServiceUnitTest.java create mode 100644 src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerUnitTest.java create mode 100644 src/test/java/com/gg/server/domain/feedback/service/FeedbackServiceUnitTest.java diff --git a/src/main/java/com/gg/server/admin/feedback/controller/FeedbackAdminController.java b/src/main/java/com/gg/server/admin/feedback/controller/FeedbackAdminController.java index 693644a4d..74215e34c 100644 --- a/src/main/java/com/gg/server/admin/feedback/controller/FeedbackAdminController.java +++ b/src/main/java/com/gg/server/admin/feedback/controller/FeedbackAdminController.java @@ -29,23 +29,33 @@ public class FeedbackAdminController { private final FeedbackAdminService feedbackAdminService; + /** + *

intraId 가 없다면 전체, 있다면 타겟 유저의 피드백들을 반환해줍니다.

+ * @param req dto + * @return FeedbackListAdminResponseDto + */ @GetMapping - public FeedbackListAdminResponseDto feedbackAll(@ModelAttribute @Valid FeedbackAdminPageRequestDto req) { - + public ResponseEntity feedbackAll( + @ModelAttribute @Valid FeedbackAdminPageRequestDto req) { if (req.getIntraId() == null) { Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize(), Sort.by("isSolved").and(Sort.by("createdAt"))); - return feedbackAdminService.findAllFeedback(pageable); + return ResponseEntity.status(HttpStatus.OK).body(feedbackAdminService.findAllFeedback(pageable)); } Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize(), - Sort.by("intra_id").and(Sort.by("createdAt"))); - return feedbackAdminService.findByPartsOfIntraId(req.getIntraId(), pageable); + Sort.by("isSolved").and(Sort.by("createdAt"))); + return ResponseEntity.status(HttpStatus.OK) + .body(feedbackAdminService.findByPartsOfIntraId(req.getIntraId(), pageable)); } + /** + *

타겟 피드백의 처리 상태를 변경해줍니다.

+ * @param feedbackId 타겟 피드백 id + */ @PatchMapping("/{feedbackId}") - public ResponseEntity feedbackIsSolvedToggle(@PathVariable @NotNull Long feedbackId) { + public ResponseEntity feedbackIsSolvedToggle(@PathVariable @NotNull Long feedbackId) { feedbackAdminService.toggleFeedbackIsSolvedByAdmin(feedbackId); - return new ResponseEntity(HttpStatus.NO_CONTENT); + return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); } } diff --git a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java b/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java index 3339d0d30..7af6cac77 100644 --- a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java +++ b/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java @@ -1,8 +1,15 @@ package com.gg.server.admin.feedback.data; +import java.util.List; + import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import com.gg.server.domain.feedback.data.Feedback; -public interface FeedbackAdminRepository extends JpaRepository, FeedbackAdminRepositorySearch { +public interface FeedbackAdminRepository extends JpaRepository { + @Query(value = "select f from Feedback f join fetch f.user " + + "where f.user.intraId = :intraId order by f.user.intraId asc, f.createdAt asc") + List findFeedbacksByUserIntraId(@Param("intraId") String intraId); } diff --git a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearch.java b/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearch.java deleted file mode 100644 index 8964322dd..000000000 --- a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearch.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.gg.server.admin.feedback.data; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.repository.query.Param; - -import com.gg.server.domain.feedback.data.Feedback; - -public interface FeedbackAdminRepositorySearch { - Page findFeedbacksByUserIntraId(@Param("intraId") String intraId, Pageable pageable); -} diff --git a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearchImpl.java b/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearchImpl.java deleted file mode 100644 index 6cad3337f..000000000 --- a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepositorySearchImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.gg.server.admin.feedback.data; - -import java.util.List; - -import javax.persistence.EntityManager; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.Pageable; - -import com.gg.server.domain.feedback.data.Feedback; - -import lombok.RequiredArgsConstructor; - -@RequiredArgsConstructor -public class FeedbackAdminRepositorySearchImpl implements FeedbackAdminRepositorySearch { - - private final EntityManager em; - - public Page findFeedbacksByUserIntraId(String intraId, Pageable pageable) { - long feedbackNum = countTotalFeedbacks(intraId, pageable); - String sql = "select f from Feedback f join fetch f.user where " - + "f.user.intraId like \'%" + intraId + "%\' order by f.user.intraId asc, f.createdAt asc"; - List feedbackList = em.createQuery(sql, Feedback.class) - .setFirstResult((int)pageable.getOffset()) - .setMaxResults(pageable.getPageSize()) - .getResultList(); - Page feedbackPage = new PageImpl<>(feedbackList, pageable, feedbackNum); - return feedbackPage; - } - - private long countTotalFeedbacks(String intraId, Pageable pageable) { - String sql = "select f from Feedback f join fetch f.user where " - + "f.user.intraId like \'%" + intraId + "%\'"; - List feedbackList = em.createQuery(sql, Feedback.class) - .getResultList(); - return feedbackList.size(); - } -} diff --git a/src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java b/src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java index 4fe7adca4..9b8a67f7e 100644 --- a/src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java +++ b/src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java @@ -1,6 +1,9 @@ package com.gg.server.admin.feedback.service; +import java.util.List; + import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -18,34 +21,44 @@ public class FeedbackAdminService { private final FeedbackAdminRepository feedbackAdminRepository; + /** + *

모든 피드백을 페이지네이션으로 만들어서 반환하는 메서드입니다

+ * @param pageable + * @return FeedbackListAdminResponseDto + */ @Transactional(readOnly = true) public FeedbackListAdminResponseDto findAllFeedback(Pageable pageable) { Page feedbacks = feedbackAdminRepository.findAll(pageable); - Page feedbackAdminResponseDtos = feedbacks.map(FeedbackAdminResponseDto::new); + Page feedbackAdminResponseDto = feedbacks.map(FeedbackAdminResponseDto::new); - FeedbackListAdminResponseDto responseDto = new FeedbackListAdminResponseDto( - feedbackAdminResponseDtos.getContent(), - feedbackAdminResponseDtos.getTotalPages()); - return responseDto; + return new FeedbackListAdminResponseDto( + feedbackAdminResponseDto.getContent(), + feedbackAdminResponseDto.getTotalPages()); } + /** + *

피드백 해결상황을 변경해주는 메서드입니다.

+ * @param feedbackId 타겟 피드백 id + */ @Transactional public void toggleFeedbackIsSolvedByAdmin(Long feedbackId) { Feedback feedback = feedbackAdminRepository.findById(feedbackId).orElseThrow(FeedbackNotFoundException::new); - if (feedback.getIsSolved()) { - feedback.setIsSolved(false); - } else { - feedback.setIsSolved(true); - } + feedback.setIsSolved(!feedback.getIsSolved()); } + /** + *

타겟 유저의 피드백을 페이지네이션으로 만들어서 반환하는 메서드입니다.

+ * @param intraId 타겟 유저 intraId + * @param pageable + * @return FeedbackListAdminResponseDto + */ @Transactional(readOnly = true) public FeedbackListAdminResponseDto findByPartsOfIntraId(String intraId, Pageable pageable) { - Page feedbacks = feedbackAdminRepository.findFeedbacksByUserIntraId(intraId, pageable); - Page feedbackAdminResponseDtos = feedbacks.map(FeedbackAdminResponseDto::new); - FeedbackListAdminResponseDto responseDto = new FeedbackListAdminResponseDto( - feedbackAdminResponseDtos.getContent(), - feedbackAdminResponseDtos.getTotalPages()); - return responseDto; + List feedbackList = feedbackAdminRepository.findFeedbacksByUserIntraId(intraId); + Page feedbacks = new PageImpl<>(feedbackList, pageable, feedbackList.size()); + Page feedbackAdminResponseDto = feedbacks.map(FeedbackAdminResponseDto::new); + return new FeedbackListAdminResponseDto( + feedbackAdminResponseDto.getContent(), + feedbackAdminResponseDto.getTotalPages()); } } diff --git a/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerUnitTest.java b/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerUnitTest.java new file mode 100644 index 000000000..4556d25bb --- /dev/null +++ b/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerUnitTest.java @@ -0,0 +1,66 @@ +package com.gg.server.admin.feedback.controller; + +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.Pageable; + +import com.gg.server.admin.feedback.dto.FeedbackAdminPageRequestDto; +import com.gg.server.admin.feedback.dto.FeedbackListAdminResponseDto; +import com.gg.server.admin.feedback.service.FeedbackAdminService; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +@DisplayName("FeedbackAdminControllerUnitTest") +class FeedbackAdminControllerUnitTest { + @Mock + FeedbackAdminService feedbackAdminService; + @InjectMocks + FeedbackAdminController feedbackAdminController; + + @Nested + @DisplayName("FeedbackAllUnitTest") + class FeedbackAllUnitTest { + @Test + @DisplayName("successWithIntraId") + public void successWithIntraId() { + //given + FeedbackAdminPageRequestDto requestDto = new FeedbackAdminPageRequestDto("intraId", 2, 2); + given(feedbackAdminService.findByPartsOfIntraId(any(String.class), any(Pageable.class))) + .willReturn(mock(FeedbackListAdminResponseDto.class)); + // when, then + feedbackAdminController.feedbackAll(requestDto); + } + + @Test + @DisplayName("successWithoutIntraId") + public void successWithoutIntraId() { + //given + FeedbackAdminPageRequestDto requestDto = new FeedbackAdminPageRequestDto(null, 2, 2); + given(feedbackAdminService.findAllFeedback(any(Pageable.class))) + .willReturn(mock(FeedbackListAdminResponseDto.class)); + // when, then + feedbackAdminController.feedbackAll(requestDto); + } + } + + @Nested + @DisplayName("FeedbackIsSolvedToggleUnitTest") + class FeedbackIsSolvedToggleUnitTest { + @Test + @DisplayName("success") + public void success() { + // given + // when, then + feedbackAdminController.feedbackIsSolvedToggle(1L); + } + } +} diff --git a/src/test/java/com/gg/server/admin/feedback/service/FeedbackAdminServiceUnitTest.java b/src/test/java/com/gg/server/admin/feedback/service/FeedbackAdminServiceUnitTest.java new file mode 100644 index 000000000..12a0729b1 --- /dev/null +++ b/src/test/java/com/gg/server/admin/feedback/service/FeedbackAdminServiceUnitTest.java @@ -0,0 +1,90 @@ +package com.gg.server.admin.feedback.service; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; + +import java.util.ArrayList; +import java.util.Optional; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.test.util.ReflectionTestUtils; + +import com.gg.server.admin.feedback.data.FeedbackAdminRepository; +import com.gg.server.domain.feedback.data.Feedback; +import com.gg.server.domain.feedback.exception.FeedbackNotFoundException; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +@DisplayName("FeedbackAdminServiceUnitTest") +class FeedbackAdminServiceUnitTest { + @Mock + FeedbackAdminRepository feedbackAdminRepository; + @InjectMocks + FeedbackAdminService feedbackAdminService; + + @Nested + @DisplayName("FindAllFeedbackUnitTest") + class FindAllFeedbackUnitTest { + @Test + @DisplayName("success") + public void success() { + // given + PageImpl feedbackList = new PageImpl<>(new ArrayList<>()); + given(feedbackAdminRepository.findAll(any(Pageable.class))).willReturn(feedbackList); + feedbackAdminService.findAllFeedback(mock(Pageable.class)); + verify(feedbackAdminRepository, times(1)).findAll(any(Pageable.class)); + } + } + + @Nested + @DisplayName("ToggleFeedbackIsSolvedByAdmin") + class ToggleFeedbackIsSolvedByAdmin { + @Test + @DisplayName("success") + public void success() { + // given + Feedback feedback = new Feedback(); + ReflectionTestUtils.setField(feedback, "isSolved", true); + given(feedbackAdminRepository.findById(any(Long.class))).willReturn(Optional.of(feedback)); + // when, then + feedbackAdminService.toggleFeedbackIsSolvedByAdmin(1L); + assertThat(feedback.getIsSolved()).isFalse(); + verify(feedbackAdminRepository, times(1)).findById(any(Long.class)); + } + + @Test + @DisplayName("feedback_not_found") + public void feedbackNotFound() { + // given + given(feedbackAdminRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> feedbackAdminService.toggleFeedbackIsSolvedByAdmin(1L)) + .isInstanceOf(FeedbackNotFoundException.class); + verify(feedbackAdminRepository, times(1)).findById(any(Long.class)); + } + } + + @Nested + @DisplayName("FindByPartsOfIntraId") + class FindByPartsOfIntraId { + @Test + @DisplayName("success") + public void success() { + // given + given(feedbackAdminRepository.findFeedbacksByUserIntraId(any(String.class))).willReturn(new ArrayList<>()); + // when, then + feedbackAdminService.findByPartsOfIntraId("intraId", mock(Pageable.class)); + verify(feedbackAdminRepository, times(1)).findFeedbacksByUserIntraId(any(String.class)); + } + } +} diff --git a/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerUnitTest.java b/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerUnitTest.java new file mode 100644 index 000000000..863297d42 --- /dev/null +++ b/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerUnitTest.java @@ -0,0 +1,39 @@ +package com.gg.server.domain.feedback.controller; + +import static org.mockito.Mockito.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.domain.feedback.dto.FeedbackRequestDto; +import com.gg.server.domain.feedback.service.FeedbackService; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +@DisplayName("FeedbackAdminServiceUnitTest") +class FeedbackControllerUnitTest { + @Mock + FeedbackService feedbackService; + @InjectMocks + FeedbackController feedbackController; + + @Nested + @DisplayName("FeedbackSaveUnitTest") + class FeedbackSaveUnitTest { + @Test + @DisplayName("success") + void success() { + // given + UserDto userDto = UserDto.builder().id(1L).build(); + // when, then + feedbackController.feedbackSave(mock(FeedbackRequestDto.class), userDto); + } + } +} diff --git a/src/test/java/com/gg/server/domain/feedback/service/FeedbackServiceUnitTest.java b/src/test/java/com/gg/server/domain/feedback/service/FeedbackServiceUnitTest.java new file mode 100644 index 000000000..3b18bec6f --- /dev/null +++ b/src/test/java/com/gg/server/domain/feedback/service/FeedbackServiceUnitTest.java @@ -0,0 +1,61 @@ +package com.gg.server.domain.feedback.service; + +import static org.mockito.BDDMockito.*; + +import java.util.Optional; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.domain.feedback.data.Feedback; +import com.gg.server.domain.feedback.data.FeedbackRepository; +import com.gg.server.domain.feedback.dto.FeedbackRequestDto; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.exception.UserNotFoundException; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +@DisplayName("FeedbackServiceUnitTest") +class FeedbackServiceUnitTest { + @Mock + UserRepository userRepository; + @Mock + FeedbackRepository feedbackRepository; + @InjectMocks + FeedbackService feedbackService; + + @Nested + @DisplayName("FeedbackSaveUnitTest") + class FeedbackSaveUnitTest { + @Test + @DisplayName("success") + void success() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(mock(User.class))); + given(feedbackRepository.save(any(Feedback.class))).willReturn(mock(Feedback.class)); + // when, then + feedbackService.addFeedback(new FeedbackRequestDto(), 1L); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(feedbackRepository, times(1)).save(any(Feedback.class)); + } + + @Test + @DisplayName("user_not_found") + void userNotFound() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + Assertions.assertThatThrownBy(() -> feedbackService.addFeedback(new FeedbackRequestDto(), 1L)) + .isInstanceOf(UserNotFoundException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + } + } +} From 35b09b1c432b83242a22efc7afcb39f42f879d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=90=ED=9B=88?= Date: Mon, 5 Feb 2024 13:59:19 +0900 Subject: [PATCH 09/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20Item=20?= =?UTF-8?q?=EC=9C=A0=EB=8B=9B=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=EC=9E=90=EB=B0=94=EB=8F=85=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=EC=9E=90=EC=9E=98=ED=95=9C=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=8B=A4=EB=93=AC=EA=B8=B0=20(#507)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/item/service/ItemAdminService.java | 37 +- .../domain/item/service/ItemService.java | 87 +++- .../service/ItemAdminServiceUnitTest.java | 185 +++++++ .../server/domain/item/data/ItemUnitTest.java | 46 ++ .../item/service/ItemServiceUnitTest.java | 470 ++++++++++++++++++ 5 files changed, 796 insertions(+), 29 deletions(-) create mode 100644 src/test/java/com/gg/server/admin/item/service/ItemAdminServiceUnitTest.java create mode 100644 src/test/java/com/gg/server/domain/item/data/ItemUnitTest.java create mode 100644 src/test/java/com/gg/server/domain/item/service/ItemServiceUnitTest.java diff --git a/src/main/java/com/gg/server/admin/item/service/ItemAdminService.java b/src/main/java/com/gg/server/admin/item/service/ItemAdminService.java index 5c4267656..3c78b55eb 100644 --- a/src/main/java/com/gg/server/admin/item/service/ItemAdminService.java +++ b/src/main/java/com/gg/server/admin/item/service/ItemAdminService.java @@ -27,6 +27,11 @@ public class ItemAdminService { private final ItemAdminRepository itemAdminRepository; private final AsyncNewItemImageUploader asyncNewItemImageUploader; + /** + *

Item 히스토리를 반환한다.

+ * @param pageable + * @return + */ @Transactional(readOnly = true) public ItemListResponseDto getAllItemHistory(Pageable pageable) { Page responseDtos = itemAdminRepository.findAll(pageable) @@ -34,7 +39,17 @@ public ItemListResponseDto getAllItemHistory(Pageable pageable) { return new ItemListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); } - // 아이템 수정 시 신규 이미지가 존재하는 경우 + /** + *

아이템 수정 시 신규 이미지가 존재하는 경우

+ *

기존 아이템의 item.isVisible 를 false 로 변경한다

+ * @param itemId 타겟 아이템 + * @param itemUpdateRequestDto 타겟 아이템 변경 dto + * @param itemImageFile 신규 이미지 + * @param user 바꾸는 유저 id + * @throws IOException IOException + * @throws ItemNotFoundException 아이템 없음 + * @throws ItemNotAvailableException 접근 불가한 아이템 + */ @Transactional public void updateItem(Long itemId, ItemUpdateRequestDto itemUpdateRequestDto, MultipartFile itemImageFile, UserDto user) throws IOException { @@ -50,10 +65,17 @@ public void updateItem(Long itemId, ItemUpdateRequestDto itemUpdateRequestDto, itemAdminRepository.save(newItem); } - // 아이템 수정 시 신규 이미지가 존재하지 않는 경우 + /** + *

아이템 수정 시 신규 이미지가 존재하지 않는 경우

+ *

기존 아이템의 item.isVisible 를 false 로 변경한다

+ * @param itemId 타겟 아이템 + * @param itemUpdateRequestDto 타겟 아이템 변경 dto + * @param user 바꾸는 유저 id + * @throws ItemNotFoundException 아이템 없음 + * @throws ItemNotAvailableException 접근 불가한 아이템 + */ @Transactional - public void updateItem(Long itemId, ItemUpdateRequestDto itemUpdateRequestDto, - UserDto user) { + public void updateItem(Long itemId, ItemUpdateRequestDto itemUpdateRequestDto, UserDto user) { Item item = itemAdminRepository.findById(itemId).orElseThrow(ItemNotFoundException::new); if (!item.getIsVisible()) { throw new ItemNotAvailableException(); @@ -63,6 +85,13 @@ public void updateItem(Long itemId, ItemUpdateRequestDto itemUpdateRequestDto, itemAdminRepository.save(newItem); } + /** + *

아이템 삭제

+ *

item.isVisible 를 false 로 변경한다

+ * @param itemId 타겟 id + * @param user 삭제하는 유저 + * @throws ItemNotFoundException 아이템 없음 + */ @Transactional public void deleteItem(Long itemId, UserDto user) { Item item = itemAdminRepository.findById(itemId).orElseThrow(ItemNotFoundException::new); diff --git a/src/main/java/com/gg/server/domain/item/service/ItemService.java b/src/main/java/com/gg/server/domain/item/service/ItemService.java index 3c8a4177b..1dfa3279b 100644 --- a/src/main/java/com/gg/server/domain/item/service/ItemService.java +++ b/src/main/java/com/gg/server/domain/item/service/ItemService.java @@ -48,34 +48,43 @@ public class ItemService { private final NotiService notiService; private final UserCoinChangeService userCoinChangeService; + /** + *

모든 아이템을 가져온다.

+ * @return + */ @Transactional(readOnly = true) public ItemStoreListResponseDto getAllItems() { - List itemStoreListResponseDto = itemRepository.findAllByCreatedAtDesc() .stream().map(ItemStoreResponseDto::new).collect(Collectors.toList()); return new ItemStoreListResponseDto(itemStoreListResponseDto); } + /** + *

게스트 유저가 아닌 유저가 아이템을 구매하는 메서드 이다

+ *

할인 중 이라면 할인가를 적용하고, 구매 후 영수증을 db에 저장한다.

+ * @param itemId 타겟 아이템 Id + * @param userDto 구매 유저 정보 + * @throws ItemNotFoundException 존재하지 않는 아이템 + * @throws ItemNotPurchasableException 구매할 수 없는 아이템 + * @throws UserNotFoundException 타겟 유저 없음 + * @throws KakaoPurchaseException 게스트(카카오) 유저가 아이템을 구매하려 할때 + * @throws + */ @Transactional public void purchaseItem(Long itemId, UserDto userDto) { - Item item = itemRepository.findById(itemId) - .orElseThrow(() -> { - throw new ItemNotFoundException(); - }); + Item item = itemRepository.findById(itemId).orElseThrow(ItemNotFoundException::new); if (!item.getIsVisible()) { throw new ItemNotPurchasableException(); } //세일가격 존재할때 세일가로 결정 - Integer finalPrice; + Integer finalPrice = item.getPrice(); if (item.getDiscount() != null && item.getDiscount() > 0) { - finalPrice = item.getPrice() - (item.getPrice() * item.getDiscount() / 100); - } else { - finalPrice = item.getPrice(); + finalPrice -= (item.getPrice() * item.getDiscount() / 100); } User payUser = userRepository.findById(userDto.getId()) - .orElseThrow(() -> new UserNotFoundException()); + .orElseThrow(UserNotFoundException::new); if (payUser.getRoleType() == RoleType.GUEST) { throw new KakaoPurchaseException(); @@ -88,22 +97,29 @@ public void purchaseItem(Long itemId, UserDto userDto) { receiptRepository.save(receipt); } + /** + *

게스트 유저가 아닌 유저들 끼리 선물을 주는 메서드 이다

+ *

할인 중 이라면 할인가를 적용하고, 구매 후 영수증을 db에 저장한다.

+ * @param itemId 타겟 아이템 id + * @param ownerId 선물 받는 owner intraId + * @param userDto 구매자 id + * @throws ItemNotFoundException 존재하지 않는 아이템 + * @throws ItemNotPurchasableException 구매할 수 없는 아이템 + * @throws UserNotFoundException 타겟 유저 없음 + * @throws KakaoPurchaseException 게스트(카카오) 유저가 아이템을 구매하려 할때 + * @throws KakaoGiftException 게스트(카카오) 유저에게 선물하려 할때 + */ @Transactional public void giftItem(Long itemId, String ownerId, UserDto userDto) { - Item item = itemRepository.findById(itemId) - .orElseThrow(() -> { - throw new ItemNotFoundException(); - }); + Item item = itemRepository.findById(itemId).orElseThrow(ItemNotFoundException::new); if (!item.getIsVisible()) { throw new ItemNotPurchasableException(); } //세일가격 존재할때 세일가로 결정 - Integer finalPrice; + Integer finalPrice = item.getPrice(); if (item.getDiscount() != null && item.getDiscount() > 0) { - finalPrice = item.getPrice() - (item.getPrice() * item.getDiscount() / 100); - } else { - finalPrice = item.getPrice(); + finalPrice -= (item.getPrice() * item.getDiscount() / 100); } User payUser = userRepository.findById(userDto.getId()) @@ -128,34 +144,55 @@ public void giftItem(Long itemId, String ownerId, UserDto userDto) { notiService.createGiftNoti(owner, payUser, item.getName()); } + /** + *

유저가 구매한 아이템 중 상태가 BEFORE, USING, WAITING 인 것들을 찾는 메서드이다.

+ * @param userDto 유저 정보 + * @param pageable 페이지 + * @return + */ @Transactional(readOnly = true) public UserItemListResponseDto getItemByUser(UserDto userDto, Pageable pageable) { Page receipts = userItemRepository.findByOwnerIntraId(userDto.getIntraId(), pageable); - Page responseDtos = receipts.map(UserItemResponseDto::new); - return new UserItemListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); + Page responseDto = receipts.map(UserItemResponseDto::new); + return new UserItemListResponseDto(responseDto.getContent(), responseDto.getTotalPages()); } + /** + *

해당 아이템의 주인이 맞는지 체크한다.

+ * @param loginUser 로그인 유저 + * @param receipt 영수증 + */ public void checkItemOwner(User loginUser, Receipt receipt) { if (!receipt.getOwnerIntraId().equals(loginUser.getIntraId())) { throw new ReceiptNotOwnerException(); } } + /** + *

해당 아이템의 타입이 영수증과 맞는지 체크한다.

+ * @param receipt 영수증 + * @param itemType 아이템 타입 + */ public void checkItemType(Receipt receipt, ItemType itemType) { if (!receipt.getItem().getType().equals(itemType)) { throw new ItemTypeException(); } } + /** + *

아이템의 상태를 체크한다.

+ *

메가폰인데 ItemStatus.WAITING 가 아니거나 사용중이라면 예외 발생

+ *

메가폰이 아닌 아이템인데 ItemStatus.BEFORE 인경우 예외 발생

+ * @param receipt + */ public void checkItemStatus(Receipt receipt) { if (receipt.getItem().getType().equals(ItemType.MEGAPHONE)) { - if (!(receipt.getStatus().equals(ItemStatus.WAITING) || receipt.getStatus().equals(ItemStatus.USING))) { - throw new ItemStatusException(); - } - } else { - if (!receipt.getStatus().equals(ItemStatus.BEFORE)) { + if (!(receipt.getStatus().equals(ItemStatus.WAITING) + || receipt.getStatus().equals(ItemStatus.USING))) { throw new ItemStatusException(); } + } else if (!receipt.getStatus().equals(ItemStatus.BEFORE)) { + throw new ItemStatusException(); } } } diff --git a/src/test/java/com/gg/server/admin/item/service/ItemAdminServiceUnitTest.java b/src/test/java/com/gg/server/admin/item/service/ItemAdminServiceUnitTest.java new file mode 100644 index 000000000..d4fb85e17 --- /dev/null +++ b/src/test/java/com/gg/server/admin/item/service/ItemAdminServiceUnitTest.java @@ -0,0 +1,185 @@ +package com.gg.server.admin.item.service; + +import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static org.assertj.core.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; + +import java.util.ArrayList; +import java.util.Optional; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.web.multipart.MultipartFile; + +import com.gg.server.admin.item.data.ItemAdminRepository; +import com.gg.server.admin.item.dto.ItemUpdateRequestDto; +import com.gg.server.admin.item.exception.ItemNotFoundException; +import com.gg.server.domain.item.data.Item; +import com.gg.server.domain.item.exception.ItemNotAvailableException; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.global.utils.aws.AsyncNewItemImageUploader; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class ItemAdminServiceUnitTest { + @Mock + ItemAdminRepository itemAdminRepository; + @Mock + AsyncNewItemImageUploader asyncNewItemImageUploader; + @InjectMocks + ItemAdminService itemAdminService; + + User user; + Item item; + + @BeforeEach + void beforeEach() { + item = new Item(); + setFieldWithReflection(item, "isVisible", true); + user = new User("testUser", "", "", RacketType.NONE, RoleType.USER, 0, SnsType.NONE, 1L); + } + + @Nested + @DisplayName("getAllItemHistoryTest") + class GetAllItemHistoryTest { + @Test + @DisplayName("success") + void success() { + // given + given(itemAdminRepository.findAll(any(Pageable.class))).willReturn(new PageImpl<>(new ArrayList<>())); + // when, then + itemAdminService.getAllItemHistory(mock(Pageable.class)); + verify(itemAdminRepository, times(1)).findAll(any(Pageable.class)); + } + } + + @Nested + @DisplayName("updateItemTest 파라미터 4개 짜리") + class UpdateItem4ParamsTest { + @Test + @DisplayName("success") + void success() throws Exception { + // given + given(itemAdminRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + given(itemAdminRepository.save(any(Item.class))).willReturn(mock(Item.class)); + // when, then + itemAdminService.updateItem(1L, mock(ItemUpdateRequestDto.class), + mock(MultipartFile.class), UserDto.from(user)); + setFieldWithReflection(item, "isVisible", true); + itemAdminService.updateItem(1L, mock(ItemUpdateRequestDto.class), + null, UserDto.from(user)); + verify(itemAdminRepository, times(2)).findById(any(Long.class)); + verify(asyncNewItemImageUploader, times(1)).upload(any(), any()); + verify(itemAdminRepository, times(2)).save(any(Item.class)); + } + + @Test + @DisplayName("ItemNotAvailableTest") + void itemNotAvailableTest() throws Exception { + // given + setFieldWithReflection(item, "isVisible", false); + given(itemAdminRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + // when, then + assertThatThrownBy( + () -> itemAdminService.updateItem(1L, mock(ItemUpdateRequestDto.class), mock(MultipartFile.class), + UserDto.from(user))) + .isInstanceOf(ItemNotAvailableException.class); + verify(itemAdminRepository, times(1)).findById(any(Long.class)); + } + + @Test + @DisplayName("ItemNotFoundTest") + void itemNotFoundTest() throws Exception { + // given + given(itemAdminRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy( + () -> itemAdminService.updateItem(1L, mock(ItemUpdateRequestDto.class), mock(MultipartFile.class), + UserDto.from(user))) + .isInstanceOf(ItemNotFoundException.class); + verify(itemAdminRepository, times(1)).findById(any(Long.class)); + } + } + + @Nested + @DisplayName("updateItemTest 파라미터 3개 짜리") + class UpdateItem3ParamsTest { + @Test + @DisplayName("success") + void success() throws Exception { + // given + given(itemAdminRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + given(itemAdminRepository.save(any(Item.class))).willReturn(mock(Item.class)); + // when, then + itemAdminService.updateItem(1L, mock(ItemUpdateRequestDto.class), UserDto.from(user)); + assertThat(item.getDeleterIntraId()).isEqualTo(user.getIntraId()); + verify(itemAdminRepository, times(1)).findById(any(Long.class)); + verify(itemAdminRepository, times(1)).save(any(Item.class)); + } + + @Test + @DisplayName("ItemNotAvailableTest") + void itemNotAvailableTest() throws Exception { + // given + setFieldWithReflection(item, "isVisible", false); + given(itemAdminRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + // when, then + assertThatThrownBy( + () -> itemAdminService.updateItem(1L, mock(ItemUpdateRequestDto.class), UserDto.from(user))) + .isInstanceOf(ItemNotAvailableException.class); + verify(itemAdminRepository, times(1)).findById(any(Long.class)); + } + + @Test + @DisplayName("ItemNotFoundTest") + void itemNotFoundTest() throws Exception { + // given + given(itemAdminRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy( + () -> itemAdminService.updateItem(1L, mock(ItemUpdateRequestDto.class), UserDto.from(user))) + .isInstanceOf(ItemNotFoundException.class); + verify(itemAdminRepository, times(1)).findById(any(Long.class)); + } + } + + @Nested + @DisplayName("deleteItemTest") + class DeleteItemTest { + @Test + @DisplayName("success") + void success() { + // given + given(itemAdminRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + // when, then + itemAdminService.deleteItem(1L, UserDto.from(user)); + assertThat(item.getIsVisible()).isFalse(); + verify(itemAdminRepository, times(1)).findById(any(Long.class)); + } + + @Test + @DisplayName("ItemNotFoundTest") + void itemNotFoundTest() { + // given + given(itemAdminRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> itemAdminService.deleteItem(1L, UserDto.from(user))) + .isInstanceOf(ItemNotFoundException.class); + verify(itemAdminRepository, times(1)).findById(any(Long.class)); + } + } +} diff --git a/src/test/java/com/gg/server/domain/item/data/ItemUnitTest.java b/src/test/java/com/gg/server/domain/item/data/ItemUnitTest.java new file mode 100644 index 000000000..805a7fcc5 --- /dev/null +++ b/src/test/java/com/gg/server/domain/item/data/ItemUnitTest.java @@ -0,0 +1,46 @@ +package com.gg.server.domain.item.data; + +import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static org.assertj.core.api.Assertions.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class ItemUnitTest { + @Nested + @DisplayName("imageUpdateTest") + class ImageUpdateTest { + @Test + @DisplayName("success") + void success() { + Item item = new Item(); + String after = "after"; + setFieldWithReflection(item, "imageUri", "before"); + item.imageUpdate(after); + assertThat(item.getImageUri()).isEqualTo(after); + } + } + + @Nested + @DisplayName("setVisibilityTest") + class SetVisibilityTest { + @Test + @DisplayName("success") + void success() { + Item item = new Item(); + String intraId = "intraId"; + setFieldWithReflection(item, "isVisible", true); + item.setVisibility(intraId); + assertThat(item.getIsVisible()).isFalse(); + assertThat(item.getDeleterIntraId()).isEqualTo(intraId); + } + } + +} diff --git a/src/test/java/com/gg/server/domain/item/service/ItemServiceUnitTest.java b/src/test/java/com/gg/server/domain/item/service/ItemServiceUnitTest.java new file mode 100644 index 000000000..e52cb9b05 --- /dev/null +++ b/src/test/java/com/gg/server/domain/item/service/ItemServiceUnitTest.java @@ -0,0 +1,470 @@ +package com.gg.server.domain.item.service; + +import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static org.assertj.core.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; + +import com.gg.server.domain.coin.service.UserCoinChangeService; +import com.gg.server.domain.item.data.Item; +import com.gg.server.domain.item.data.ItemRepository; +import com.gg.server.domain.item.data.UserItemRepository; +import com.gg.server.domain.item.exception.ItemNotFoundException; +import com.gg.server.domain.item.exception.ItemNotPurchasableException; +import com.gg.server.domain.item.exception.ItemTypeException; +import com.gg.server.domain.item.exception.KakaoGiftException; +import com.gg.server.domain.item.exception.KakaoPurchaseException; +import com.gg.server.domain.item.type.ItemType; +import com.gg.server.domain.noti.service.NotiService; +import com.gg.server.domain.receipt.data.Receipt; +import com.gg.server.domain.receipt.data.ReceiptRepository; +import com.gg.server.domain.receipt.exception.ItemStatusException; +import com.gg.server.domain.receipt.exception.ReceiptNotOwnerException; +import com.gg.server.domain.receipt.type.ItemStatus; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.exception.UserNotFoundException; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class ItemServiceUnitTest { + @Mock + ItemRepository itemRepository; + @Mock + UserRepository userRepository; + @Mock + ReceiptRepository receiptRepository; + @Mock + NotiService notiService; + @Mock// 내부 로직에서 void 값 반환으로 사용하는 곳 있음 + UserCoinChangeService userCoinChangeService; + @Mock + UserItemRepository userItemRepository; + @InjectMocks + ItemService itemService; + + @Nested + @DisplayName("getAllItems method unitTest") + class GetAllItemsTest { + @Test + @DisplayName("success") + void success() { + // given + List items = new ArrayList<>(); + given(itemRepository.findAllByCreatedAtDesc()).willReturn(items); + // when, then + itemService.getAllItems(); + verify(itemRepository, times(1)).findAllByCreatedAtDesc(); + } + } + + @Nested + @DisplayName("purchaseItem method unitTest") + class PurchaseItemTest { + User payUser; + UserDto userDto; + Item item; + + @BeforeEach + void beforeEach() { + payUser = new User("", "", "", RacketType.NONE, RoleType.USER, 0, SnsType.NONE, 1L); + setFieldWithReflection(payUser, "id", 1L); + userDto = UserDto.from(payUser); + item = new Item(); + setFieldWithReflection(item, "isVisible", true); + } + + @Test + @DisplayName("success -> no discount") + void successNoDiscount() { + // given + given(itemRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(payUser)); + given(receiptRepository.save(any(Receipt.class))).willReturn(mock(Receipt.class)); + // when, then 1 + itemService.purchaseItem(1L, userDto); + // when, then 2 + setFieldWithReflection(item, "discount", 0); + itemService.purchaseItem(1L, userDto); + verify(itemRepository, times(2)).findById(any(Long.class)); + verify(userRepository, times(2)).findById(any(Long.class)); + verify(userCoinChangeService, times(2)).purchaseItemCoin(any(), any(), any()); + verify(receiptRepository, times(2)).save(any(Receipt.class)); + + } + + @Test + @DisplayName("success -> discount") + void successDiscount() { + // given + setFieldWithReflection(item, "price", 100); + setFieldWithReflection(item, "discount", 10); + given(itemRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(payUser)); + given(receiptRepository.save(any(Receipt.class))).willReturn(mock(Receipt.class)); + // when, then + itemService.purchaseItem(1L, userDto); + verify(itemRepository, times(1)).findById(any(Long.class)); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(userCoinChangeService, times(1)).purchaseItemCoin(any(), any(), any()); + verify(receiptRepository, times(1)).save(any(Receipt.class)); + } + + @Test + @DisplayName("item not found") + void itemNotFound() { + // given + given(itemRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> itemService.purchaseItem(1L, userDto)) + .isInstanceOf(ItemNotFoundException.class); + verify(itemRepository, times(1)).findById(any(Long.class)); + } + + @Test + @DisplayName("Item Not Purchasable") + void itemNotPurchasable() { + // given + setFieldWithReflection(item, "isVisible", false); + given(itemRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + // when, then + assertThatThrownBy(() -> itemService.purchaseItem(1L, userDto)) + .isInstanceOf(ItemNotPurchasableException.class); + verify(itemRepository, times(1)).findById(any(Long.class)); + } + + @Test + @DisplayName("User Not Found") + void userNotFound() { + // given + given(itemRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + given(userRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> itemService.purchaseItem(1L, userDto)) + .isInstanceOf(UserNotFoundException.class); + verify(itemRepository, times(1)).findById(any(Long.class)); + verify(userRepository, times(1)).findById(any(Long.class)); + } + + @Test + @DisplayName("GuestUser Exception") + void guestUserException() { + // given + setFieldWithReflection(payUser, "roleType", RoleType.GUEST); + given(itemRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(payUser)); + // when, then + assertThatThrownBy(() -> itemService.purchaseItem(1L, userDto)) + .isInstanceOf(KakaoPurchaseException.class); + verify(itemRepository, times(1)).findById(any(Long.class)); + verify(userRepository, times(1)).findById(any(Long.class)); + } + + } + + @Nested + @DisplayName("giftItemTest method unitTest") + class GiftItemTest { + User payUser; + User owner; + UserDto userDto; + Item item; + + @BeforeEach + void beforeEach() { + payUser = new User("", "", "", RacketType.NONE, RoleType.USER, 0, SnsType.NONE, 1L); + setFieldWithReflection(payUser, "id", 1L); + userDto = UserDto.from(payUser); + owner = new User("", "", "", RacketType.NONE, RoleType.USER, 0, SnsType.NONE, 1L); + item = new Item(); + setFieldWithReflection(item, "isVisible", true); + } + + @Test + @DisplayName("success -> No Discount") + void successNoDiscount() { + // given + given(itemRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(payUser)); + given(receiptRepository.save(any(Receipt.class))).willReturn(mock(Receipt.class)); + given(userRepository.findByIntraId(any(String.class))).willReturn(Optional.of(owner)); + // when, then 1 + itemService.giftItem(1L, "owner", userDto); + // when, then 2 + setFieldWithReflection(item, "discount", 0); + itemService.giftItem(1L, "owner", userDto); + verify(itemRepository, times(2)).findById(any(Long.class)); + verify(userRepository, times(2)).findById(any(Long.class)); + verify(userRepository, times(2)).findByIntraId(any(String.class)); + verify(userCoinChangeService, times(2)).giftItemCoin(any(), any(), any(), any()); + verify(receiptRepository, times(2)).save(any(Receipt.class)); + verify(notiService, times(2)).createGiftNoti(any(), any(), any()); + + } + + @Test + @DisplayName("success -> Discount") + void successDiscount() { + // given + setFieldWithReflection(item, "price", 100); + setFieldWithReflection(item, "discount", 10); + given(itemRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(payUser)); + given(receiptRepository.save(any(Receipt.class))).willReturn(mock(Receipt.class)); + given(userRepository.findByIntraId(any(String.class))).willReturn(Optional.of(owner)); + // when, then + itemService.giftItem(1L, "owner", userDto); + verify(itemRepository, times(1)).findById(any(Long.class)); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(userRepository, times(1)).findByIntraId(any(String.class)); + verify(userCoinChangeService, times(1)).giftItemCoin(any(), any(), any(), any()); + verify(receiptRepository, times(1)).save(any(Receipt.class)); + verify(notiService, times(1)).createGiftNoti(any(), any(), any()); + } + + @Test + @DisplayName("guest Owner") + void guestOwnerTest() { + // given + setFieldWithReflection(owner, "roleType", RoleType.GUEST); + given(itemRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(payUser)); + given(userRepository.findByIntraId(any(String.class))).willReturn(Optional.of(owner)); + // when, then + assertThatThrownBy(() -> itemService.giftItem(1L, "owner", userDto)) + .isInstanceOf(KakaoGiftException.class); + verify(itemRepository, times(1)).findById(any(Long.class)); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(userRepository, times(1)).findByIntraId(any(String.class)); + } + + @Test + @DisplayName("Owner not Found") + void ownerNotFoundTest() { + // given + setFieldWithReflection(owner, "roleType", RoleType.GUEST); + given(itemRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(payUser)); + given(userRepository.findByIntraId(any(String.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> itemService.giftItem(1L, "owner", userDto)) + .isInstanceOf(UserNotFoundException.class); + verify(itemRepository, times(1)).findById(any(Long.class)); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(userRepository, times(1)).findByIntraId(any(String.class)); + } + + @Test + @DisplayName("guest payUser") + void guestPayUserTest() { + // given + setFieldWithReflection(payUser, "roleType", RoleType.GUEST); + given(itemRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(payUser)); + // when, then + assertThatThrownBy(() -> itemService.giftItem(1L, "owner", userDto)) + .isInstanceOf(KakaoPurchaseException.class); + verify(itemRepository, times(1)).findById(any(Long.class)); + verify(userRepository, times(1)).findById(any(Long.class)); + } + + @Test + @DisplayName("payUser Not Found") + void payUserNotFoundTest() { + // given + setFieldWithReflection(payUser, "roleType", RoleType.GUEST); + given(itemRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + given(userRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> itemService.giftItem(1L, "owner", userDto)) + .isInstanceOf(UserNotFoundException.class); + verify(itemRepository, times(1)).findById(any(Long.class)); + verify(userRepository, times(1)).findById(any(Long.class)); + } + + @Test + @DisplayName("Item Not Purchasable") + void itemNotPurchasableTest() { + // given + setFieldWithReflection(item, "isVisible", false); + given(itemRepository.findById(any(Long.class))).willReturn(Optional.of(item)); + // when, then + assertThatThrownBy(() -> itemService.giftItem(1L, "owner", userDto)) + .isInstanceOf(ItemNotPurchasableException.class); + verify(itemRepository, times(1)).findById(any(Long.class)); + } + + @Test + @DisplayName("Item Not Found") + void itemNotFoundTest() { + // given + given(itemRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> itemService.giftItem(1L, "owner", userDto)) + .isInstanceOf(ItemNotFoundException.class); + verify(itemRepository, times(1)).findById(any(Long.class)); + } + } + + @Nested + @DisplayName("getItemByUser method unitTest") + class GetItemByUserTest { + @Test + @DisplayName("success") + void success() { + // given + User user = new User("intraId", "", "", RacketType.NONE, RoleType.USER, 0, SnsType.NONE, 1L); + given(userItemRepository.findByOwnerIntraId(any(String.class), any(Pageable.class))) + .willReturn(new PageImpl<>(new ArrayList<>())); + // when, then + itemService.getItemByUser(UserDto.from(user), mock(Pageable.class)); + verify(userItemRepository, times(1)).findByOwnerIntraId(any(String.class), any(Pageable.class)); + } + } + + @Nested + @DisplayName("checkItemOwner method unitTest") + class CheckItemOwnerTest { + User user; + Receipt receipt; + + @BeforeEach + void beforeEach() { + user = new User("intraId", "", "", RacketType.NONE, RoleType.USER, 0, SnsType.NONE, 1L); + receipt = new Receipt(); + setFieldWithReflection(receipt, "ownerIntraId", user.getIntraId()); + } + + @Test + @DisplayName("success") + void success() { + // given + // when, then + itemService.checkItemOwner(user, receipt); + } + + @Test + @DisplayName("Receipt Not Owner Exception") + void receiptNotOwnerTest() { + // given + setFieldWithReflection(receipt, "ownerIntraId", user.getIntraId() + "1234"); + // when, then + assertThatThrownBy(() -> itemService.checkItemOwner(user, receipt)) + .isInstanceOf(ReceiptNotOwnerException.class); + } + } + + @Nested + @DisplayName("checkItemType method unitTest") + class CheckItemTypeTest { + Receipt receipt; + + @BeforeEach + void beforeEach() { + receipt = new Receipt(); + Item item = new Item(); + setFieldWithReflection(item, "type", ItemType.MEGAPHONE); + setFieldWithReflection(receipt, "item", item); + } + + @Test + @DisplayName("success") + void success() { + // given + // when, then + itemService.checkItemType(receipt, receipt.getItem().getType()); + } + + @Test + @DisplayName("Receipt Not Owner Exception") + void receiptNotOwnerTest() { + // given + // when, then + assertThatThrownBy(() -> itemService.checkItemType(receipt, ItemType.EDGE)) + .isInstanceOf(ItemTypeException.class); + } + } + + @Nested + @DisplayName("checkItemStatus method unitTest") + class CheckItemStatusTest { + Receipt receipt; + + @BeforeEach + void beforeEach() { + receipt = new Receipt(); + Item item = new Item(); + setFieldWithReflection(item, "type", ItemType.MEGAPHONE); + setFieldWithReflection(receipt, "status", ItemStatus.BEFORE); + setFieldWithReflection(receipt, "item", item); + } + + @Test + @DisplayName("success Megaphone1") + void successMegaphone1() { + // given + setFieldWithReflection(receipt, "status", ItemStatus.USING); + // when, then + itemService.checkItemStatus(receipt); + } + + @Test + @DisplayName("success Megaphone2") + void successMegaphone2() { + // given + setFieldWithReflection(receipt, "status", ItemStatus.WAITING); + // when, then + itemService.checkItemStatus(receipt); + } + + @Test + @DisplayName("success Megaphone") + void successNotMegaphone() { + // given + setFieldWithReflection(receipt.getItem(), "type", ItemType.EDGE); + // when, then + itemService.checkItemStatus(receipt); + } + + @Test + @DisplayName("Receipt Not Owner Exception") + void failMegaphone() { + // given + // when, then + assertThatThrownBy(() -> itemService.checkItemStatus(receipt)) + .isInstanceOf(ItemStatusException.class); + } + + @Test + @DisplayName("Receipt Not Owner Exception") + void failNotMegaphone() { + // given + setFieldWithReflection(receipt.getItem(), "type", ItemType.EDGE); + setFieldWithReflection(receipt, "status", ItemStatus.USING); + // when, then + assertThatThrownBy(() -> itemService.checkItemStatus(receipt)) + .isInstanceOf(ItemStatusException.class); + } + } +} From b957e773f1a53f0e5bba2707a609bd5a9a440d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=90=ED=9B=88?= Date: Mon, 5 Feb 2024 13:59:34 +0900 Subject: [PATCH 10/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20Megaphone?= =?UTF-8?q?=20=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20(#519)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MegaphoneAdminService.java | 15 +- .../controller/MegaphoneController.java | 7 +- .../megaphone/service/MegaphoneService.java | 67 +++- .../MegaphoneAdminServiceUnitTest.java | 59 +++ .../service/MegaphoneServiceUnitTest.java | 366 ++++++++++++++++++ 5 files changed, 497 insertions(+), 17 deletions(-) create mode 100644 src/test/java/com/gg/server/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java create mode 100644 src/test/java/com/gg/server/domain/megaphone/service/MegaphoneServiceUnitTest.java diff --git a/src/main/java/com/gg/server/admin/megaphone/service/MegaphoneAdminService.java b/src/main/java/com/gg/server/admin/megaphone/service/MegaphoneAdminService.java index 4aed020c6..badb35fb2 100644 --- a/src/main/java/com/gg/server/admin/megaphone/service/MegaphoneAdminService.java +++ b/src/main/java/com/gg/server/admin/megaphone/service/MegaphoneAdminService.java @@ -15,15 +15,26 @@ public class MegaphoneAdminService { private final MegaphoneAdminRepository megaphoneAdminRepository; + /** + *

메가폰 기록을 가져옵니다.

+ * @param pageable + * @return + */ public MegaphoneHistoryResponseDto getMegaphoneHistory(Pageable pageable) { Page megaphoneHistory = megaphoneAdminRepository.findAll(pageable) .map(MegaphoneAdminResponseDto::new); return new MegaphoneHistoryResponseDto(megaphoneHistory.getContent(), megaphoneHistory.getTotalPages()); } + /** + *

intraId를 기반으로 메가폰 기록을 가져옵니다.

+ * @param intraId 타겟 인트라id + * @param pageable + * @return + */ public MegaphoneHistoryResponseDto getMegaphoneHistoryByIntraId(String intraId, Pageable pageable) { - Page megaphoneHistory = megaphoneAdminRepository.findMegaphonesByUserIntraId(intraId, - pageable).map(MegaphoneAdminResponseDto::new); + Page megaphoneHistory = megaphoneAdminRepository + .findMegaphonesByUserIntraId(intraId, pageable).map(MegaphoneAdminResponseDto::new); return new MegaphoneHistoryResponseDto(megaphoneHistory.getContent(), megaphoneHistory.getTotalPages()); } } diff --git a/src/main/java/com/gg/server/domain/megaphone/controller/MegaphoneController.java b/src/main/java/com/gg/server/domain/megaphone/controller/MegaphoneController.java index f1781c597..2d9bde346 100644 --- a/src/main/java/com/gg/server/domain/megaphone/controller/MegaphoneController.java +++ b/src/main/java/com/gg/server/domain/megaphone/controller/MegaphoneController.java @@ -1,5 +1,6 @@ package com.gg.server.domain.megaphone.controller; +import java.time.LocalTime; import java.util.List; import javax.validation.Valid; @@ -31,14 +32,14 @@ public class MegaphoneController { private final MegaphoneService megaphoneService; @PostMapping() - public ResponseEntity useMegaphone(@RequestBody @Valid MegaphoneUseRequestDto megaphoneUseRequestDto, + public ResponseEntity useMegaphone(@RequestBody @Valid MegaphoneUseRequestDto megaphoneUseRequestDto, @Parameter(hidden = true) @Login UserDto user) { - megaphoneService.useMegaphone(megaphoneUseRequestDto, user); + megaphoneService.useMegaphone(megaphoneUseRequestDto, user, LocalTime.now()); return ResponseEntity.status(HttpStatus.CREATED).build(); } @DeleteMapping("/{megaphoneId}") - public ResponseEntity deleteMegaphone(@PathVariable Long megaphoneId, + public ResponseEntity deleteMegaphone(@PathVariable Long megaphoneId, @Parameter(hidden = true) @Login UserDto user) { megaphoneService.deleteMegaphone(megaphoneId, user); return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); diff --git a/src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java b/src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java index 6d6b93238..c9f7e0942 100644 --- a/src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java +++ b/src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java @@ -9,6 +9,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.gg.server.domain.item.exception.ItemTypeException; import com.gg.server.domain.item.service.ItemService; import com.gg.server.domain.item.type.ItemType; import com.gg.server.domain.megaphone.data.Megaphone; @@ -25,6 +26,7 @@ import com.gg.server.domain.receipt.data.ReceiptRepository; import com.gg.server.domain.receipt.exception.ItemStatusException; import com.gg.server.domain.receipt.exception.ReceiptNotFoundException; +import com.gg.server.domain.receipt.exception.ReceiptNotOwnerException; import com.gg.server.domain.receipt.type.ItemStatus; import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; @@ -43,10 +45,25 @@ public class MegaphoneService { private final MegaphoneRedisRepository megaphoneRedisRepository; private final ItemService itemService; + /** + *

메가폰을 사용합니다.

+ *

00:06 ~ 23:54 분 사이에 사용 가능 합니다.

+ * @param megaphoneUseRequestDto 요청 dto + * @param user 접속 유저 + * @param localTime 현재 날짜 + * @throws UserNotFoundException 유저 없을 때 + * @throws MegaphoneTimeException 메가폰 사용 가능 기간 아닐때 + * @throws ReceiptNotFoundException 영수증 없을 때 + * @throws ItemTypeException 메가폰 아닐 때 + * @throws ReceiptNotOwnerException 영수증에 적힌 사용자가 아닐 때 + * @throws ItemStatusException 사용전인 아이템이 아닐때 + * @throws MegaphoneContentException 메가폰 내용이 없을 때 + + */ @Transactional - public void useMegaphone(MegaphoneUseRequestDto megaphoneUseRequestDto, UserDto user) { + public void useMegaphone(MegaphoneUseRequestDto megaphoneUseRequestDto, UserDto user, LocalTime localTime) { User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); - if (LocalTime.now().isAfter(LocalTime.of(23, 55)) || LocalTime.now().isBefore(LocalTime.of(0, 5))) { + if (localTime.isAfter(LocalTime.of(23, 55)) || localTime.isBefore(LocalTime.of(0, 5))) { throw new MegaphoneTimeException(); } Receipt receipt = receiptRepository.findById(megaphoneUseRequestDto.getReceiptId()) @@ -56,7 +73,7 @@ public void useMegaphone(MegaphoneUseRequestDto megaphoneUseRequestDto, UserDto if (!receipt.getStatus().equals(ItemStatus.BEFORE)) { throw new ItemStatusException(); } - if (megaphoneUseRequestDto.getContent().length() == 0) { + if (megaphoneUseRequestDto.getContent().isEmpty()) { throw new MegaphoneContentException(); } receipt.updateStatus(ItemStatus.WAITING); @@ -65,21 +82,34 @@ public void useMegaphone(MegaphoneUseRequestDto megaphoneUseRequestDto, UserDto megaphoneRepository.save(megaphone); } + /** + *

현재 사용중인 메가폰은 삭제하고, 다음날 메가폰들을 등록 시켜준다.

+ * @param today 현재 날짜. + */ @Transactional public void setMegaphoneList(LocalDate today) { megaphoneRepository.findAllByUsedAtAndReceiptStatus(today, ItemStatus.USING) .forEach(megaphone -> megaphone.getReceipt().updateStatus(ItemStatus.USED)); megaphoneRedisRepository.deleteAllMegaphone(); - List megaphones = megaphoneRepository.findAllByUsedAtAndReceiptStatus(today.plusDays(1), - ItemStatus.WAITING); + List megaphones = megaphoneRepository + .findAllByUsedAtAndReceiptStatus(today.plusDays(1), ItemStatus.WAITING); for (Megaphone megaphone : megaphones) { megaphone.getReceipt().updateStatus(ItemStatus.USING); - megaphoneRedisRepository.addMegaphone( - new MegaphoneRedis(megaphone.getId(), megaphone.getUser().getIntraId(), megaphone.getContent(), - LocalDateTime.of(megaphone.getUsedAt(), LocalTime.of(0, 0)))); + megaphoneRedisRepository.addMegaphone(new MegaphoneRedis(megaphone.getId(), + megaphone.getUser().getIntraId(), megaphone.getContent(), + LocalDateTime.of(megaphone.getUsedAt(), LocalTime.of(0, 0)))); } } + /** + *

메가폰을 삭제합니다. 관리자와 일반유저가 같이 사용하는 메서드입니다.

+ * @param megaphoneId 타겟 id + * @param user 접속 유저 + * @throws UserNotFoundException 유저가 없을 때 + * @throws MegaphoneNotFoundException 타겟 메가폰 없을 때 + * @throws ReceiptNotOwnerException 주인이 아닐 때 + * @throws ItemStatusException 아이템 상태 에러 + */ @Transactional public void deleteMegaphone(Long megaphoneId, UserDto user) { User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); @@ -95,6 +125,17 @@ public void deleteMegaphone(Long megaphoneId, UserDto user) { receipt.updateStatus(ItemStatus.DELETED); } + /** + *

메가폰 세부사항을 반환해줍니다.

+ * @param receiptId 타겟 id + * @param user 접속 유저 + * @throws UserNotFoundException 유저 없을 때 + * @throws ReceiptNotFoundException 영수증이 없을 때 + * @throws ItemTypeException 메가폰이 아닐 때 + * @throws ReceiptNotOwnerException 주인이 아닐때 + * @throws ItemStatusException 아이템의 상태 에러 + * @throws MegaphoneNotFoundException 없는 메가폰 일때 + */ public MegaphoneDetailResponseDto getMegaphoneDetail(Long receiptId, UserDto user) { User loginUser = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); Receipt receipt = receiptRepository.findById(receiptId).orElseThrow(ReceiptNotFoundException::new); @@ -105,10 +146,12 @@ public MegaphoneDetailResponseDto getMegaphoneDetail(Long receiptId, UserDto use return new MegaphoneDetailResponseDto(megaphone); } + /** + *

오늘 띄워지는 메가폰들을 가져옵니다.

+ * @return + */ public List getMegaphoneTodayList() { - return megaphoneRedisRepository.getAllMegaphone() - .stream() - .map(MegaphoneTodayListResponseDto::new) - .collect(Collectors.toList()); + return megaphoneRedisRepository.getAllMegaphone().stream() + .map(MegaphoneTodayListResponseDto::new).collect(Collectors.toList()); } } diff --git a/src/test/java/com/gg/server/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java b/src/test/java/com/gg/server/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java new file mode 100644 index 000000000..3202aee61 --- /dev/null +++ b/src/test/java/com/gg/server/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java @@ -0,0 +1,59 @@ +package com.gg.server.admin.megaphone.service; + +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; + +import java.util.ArrayList; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; + +import com.gg.server.admin.megaphone.data.MegaphoneAdminRepository; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class MegaphoneAdminServiceUnitTest { + @Mock + MegaphoneAdminRepository megaphoneAdminRepository; + @InjectMocks + MegaphoneAdminService megaphoneAdminService; + + @Nested + @DisplayName("getMegaphoneHistory 메서드 유닛 테스트") + class GetMegaphoneHistory { + @Test + @DisplayName("success") + void success() { + // given + given(megaphoneAdminRepository.findAll(any(Pageable.class))).willReturn(new PageImpl<>(new ArrayList<>())); + // when, then + megaphoneAdminService.getMegaphoneHistory(mock(Pageable.class)); + verify(megaphoneAdminRepository, times(1)).findAll(any(Pageable.class)); + } + } + + @Nested + @DisplayName("getMegaphoneHistoryByIntraId 메서드 유닛 테스트") + class GetMegaphoneHistoryByIntraId { + @Test + @DisplayName("success") + void success() { + // given + given(megaphoneAdminRepository.findMegaphonesByUserIntraId(any(String.class), any( + Pageable.class))).willReturn(new PageImpl<>(new ArrayList<>())); + // when, then + megaphoneAdminService.getMegaphoneHistoryByIntraId("testUser", mock(Pageable.class)); + verify(megaphoneAdminRepository, times(1)) + .findMegaphonesByUserIntraId(any(String.class), any(Pageable.class)); + } + } +} diff --git a/src/test/java/com/gg/server/domain/megaphone/service/MegaphoneServiceUnitTest.java b/src/test/java/com/gg/server/domain/megaphone/service/MegaphoneServiceUnitTest.java new file mode 100644 index 000000000..00dc47986 --- /dev/null +++ b/src/test/java/com/gg/server/domain/megaphone/service/MegaphoneServiceUnitTest.java @@ -0,0 +1,366 @@ +package com.gg.server.domain.megaphone.service; + +import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static org.assertj.core.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.domain.item.data.Item; +import com.gg.server.domain.item.service.ItemService; +import com.gg.server.domain.item.type.ItemType; +import com.gg.server.domain.megaphone.data.Megaphone; +import com.gg.server.domain.megaphone.data.MegaphoneRepository; +import com.gg.server.domain.megaphone.dto.MegaphoneUseRequestDto; +import com.gg.server.domain.megaphone.exception.MegaphoneContentException; +import com.gg.server.domain.megaphone.exception.MegaphoneNotFoundException; +import com.gg.server.domain.megaphone.exception.MegaphoneTimeException; +import com.gg.server.domain.megaphone.redis.MegaphoneRedisRepository; +import com.gg.server.domain.receipt.data.Receipt; +import com.gg.server.domain.receipt.data.ReceiptRepository; +import com.gg.server.domain.receipt.exception.ItemStatusException; +import com.gg.server.domain.receipt.exception.ReceiptNotFoundException; +import com.gg.server.domain.receipt.type.ItemStatus; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.exception.UserNotFoundException; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class MegaphoneServiceUnitTest { + @Mock + UserRepository userRepository; + @Mock + ReceiptRepository receiptRepository; + @Mock + MegaphoneRepository megaphoneRepository; + @Mock + MegaphoneRedisRepository megaphoneRedisRepository; + @Mock + ItemService itemService; + @InjectMocks + MegaphoneService megaphoneService; + + User user; + Receipt receipt; + Item item; + + @BeforeEach + void beforeEach() { + user = new User("", "", "", RacketType.NONE, RoleType.USER, + 0, SnsType.NONE, 1L); + setFieldWithReflection(user, "id", 1L); + item = new Item(); + receipt = new Receipt(item, "", "testUser", ItemStatus.BEFORE, LocalDateTime.now()); + } + + @Nested + @DisplayName("useMegaphone 메서드 유닛 테스트") + class UseMegaphoneUnitTest { + MegaphoneUseRequestDto megaphoneUseRequestDto; + + @BeforeEach + void beforeEach() { + setFieldWithReflection(item, "type", ItemType.MEGAPHONE); + megaphoneUseRequestDto = new MegaphoneUseRequestDto(1L, "test"); + } + + @Test + @DisplayName("success") + void success() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(user)); + given(receiptRepository.findById(any(Long.class))).willReturn(Optional.of(receipt)); + given(megaphoneRepository.save(any(Megaphone.class))).willReturn(mock(Megaphone.class)); + // when + megaphoneService.useMegaphone(megaphoneUseRequestDto, UserDto.from(user), + LocalTime.now().withHour(23).withMinute(54)); + setFieldWithReflection(receipt, "status", ItemStatus.BEFORE); + megaphoneService.useMegaphone(megaphoneUseRequestDto, UserDto.from(user), + LocalTime.now().withHour(0).withMinute(6)); + // then + assertThat(receipt.getStatus()).isEqualTo(ItemStatus.WAITING); + verify(userRepository, times(2)).findById(any(Long.class)); + verify(receiptRepository, times(2)).findById(any(Long.class)); + verify(itemService, times(2)).checkItemType(any(), any()); + verify(itemService, times(2)).checkItemOwner(any(), any()); + verify(megaphoneRepository, times(2)).save(any(Megaphone.class)); + } + + @Test + @DisplayName("MegaphoneContentException") + void megaphoneContentException() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(user)); + given(receiptRepository.findById(any(Long.class))).willReturn(Optional.of(receipt)); + setFieldWithReflection(megaphoneUseRequestDto, "content", ""); + // when, then + Assertions.assertThatThrownBy(() -> megaphoneService.useMegaphone( + megaphoneUseRequestDto, UserDto.from(user), LocalTime.now().withHour(23).withMinute(54))) + .isInstanceOf(MegaphoneContentException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(receiptRepository, times(1)).findById(any(Long.class)); + verify(itemService, times(1)).checkItemType(any(), any()); + verify(itemService, times(1)).checkItemOwner(any(), any()); + } + + @Test + @DisplayName("ItemStatusException") + void itemStatusException() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(user)); + given(receiptRepository.findById(any(Long.class))).willReturn(Optional.of(receipt)); + setFieldWithReflection(receipt, "status", ItemStatus.USING); + // when, then + Assertions.assertThatThrownBy( + () -> megaphoneService.useMegaphone(megaphoneUseRequestDto, UserDto.from(user), + LocalTime.now().withHour(23).withMinute(54))).isInstanceOf(ItemStatusException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(receiptRepository, times(1)).findById(any(Long.class)); + verify(itemService, times(1)).checkItemType(any(), any()); + verify(itemService, times(1)).checkItemOwner(any(), any()); + } + + @Test + @DisplayName("ReceiptNotFoundException") + void receiptNotFoundException() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(user)); + given(receiptRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + Assertions.assertThatThrownBy( + () -> megaphoneService.useMegaphone(megaphoneUseRequestDto, UserDto.from(user), + LocalTime.now().withHour(23).withMinute(54))).isInstanceOf(ReceiptNotFoundException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(receiptRepository, times(1)).findById(any(Long.class)); + } + + @Test + @DisplayName("MegaphoneTimeException") + void megaphoneTimeException() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(user)); + // when, then + Assertions.assertThatThrownBy( + () -> megaphoneService.useMegaphone(megaphoneUseRequestDto, UserDto.from(user), + LocalTime.now().withHour(23).withMinute(56))).isInstanceOf(MegaphoneTimeException.class); + Assertions.assertThatThrownBy( + () -> megaphoneService.useMegaphone(megaphoneUseRequestDto, UserDto.from(user), + LocalTime.now().withHour(0).withMinute(3))).isInstanceOf(MegaphoneTimeException.class); + verify(userRepository, times(2)).findById(any(Long.class)); + } + + @Test + @DisplayName("UserNotFoundException") + void userNotFoundException() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + Assertions.assertThatThrownBy( + () -> megaphoneService.useMegaphone(megaphoneUseRequestDto, UserDto.from(user), + LocalTime.now().withHour(23).withMinute(56))).isInstanceOf(UserNotFoundException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + } + } + + @Nested + @DisplayName("setMegaphoneList 메서드 유닛 테스트") + class SetMegaphoneListUnitTest { + List usingList = new ArrayList<>(); + List waitList = new ArrayList<>(); + + @BeforeEach + void beforeEach() { + waitList.add(new Megaphone(user, receipt, "test", LocalDate.now().plusDays(1))); + Receipt receiptUsing = new Receipt(item, "", "testUser", + ItemStatus.USING, LocalDateTime.now()); + usingList.add(new Megaphone(user, receiptUsing, "test", LocalDate.now())); + } + + @Test + @DisplayName("success") + void success() { + // given + given(megaphoneRepository.findAllByUsedAtAndReceiptStatus(LocalDate.now(), ItemStatus.USING)) + .willReturn(usingList); + given(megaphoneRepository.findAllByUsedAtAndReceiptStatus( + LocalDate.now().plusDays(1), ItemStatus.WAITING)) + .willReturn(waitList); + // when, then + megaphoneService.setMegaphoneList(LocalDate.now()); + assertThat(usingList.get(0).getReceipt().getStatus()).isEqualTo(ItemStatus.USED); + assertThat(waitList.get(0).getReceipt().getStatus()).isEqualTo(ItemStatus.USING); + verify(megaphoneRepository, times(1)) + .findAllByUsedAtAndReceiptStatus(LocalDate.now(), ItemStatus.USING); + verify(megaphoneRedisRepository, times(1)).deleteAllMegaphone(); + verify(megaphoneRepository, times(1)) + .findAllByUsedAtAndReceiptStatus(LocalDate.now().plusDays(1), ItemStatus.WAITING); + verify(megaphoneRedisRepository, times(waitList.size())).addMegaphone(any()); + } + } + + @Nested + @DisplayName("deleteMegaphone 메서드 유닛 테스트") + class DeleteMegaphoneUnitTest { + Megaphone megaphone; + + @BeforeEach + void beforeEach() { + megaphone = new Megaphone(user, receipt, "test", LocalDate.now()); + } + + @Test + @DisplayName("success") + void success() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(user)); + given(megaphoneRepository.findById(any(Long.class))).willReturn(Optional.of(megaphone)); + // when deleted by user + megaphoneService.deleteMegaphone(1L, UserDto.from(user)); + // when deleted by admin, using megaphone + setFieldWithReflection(user, "roleType", RoleType.ADMIN); + megaphoneService.deleteMegaphone(1L, UserDto.from(user)); + // when deleting using megaphone + setFieldWithReflection(receipt, "status", ItemStatus.USING); + megaphoneService.deleteMegaphone(1L, UserDto.from(user)); + // then + assertThat(receipt.getStatus()).isEqualTo(ItemStatus.DELETED); + verify(userRepository, times(3)).findById(any(Long.class)); + verify(megaphoneRepository, times(3)).findById(any(Long.class)); + verify(itemService, times(1)).checkItemOwner(any(), any()); + verify(itemService, times(3)).checkItemStatus(any()); + verify(megaphoneRedisRepository, times(1)).deleteMegaphoneById(any()); + } + + @Test + @DisplayName("MegaphoneNotFoundException") + void megaphoneNotFoundException() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(user)); + given(megaphoneRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> megaphoneService.deleteMegaphone(1L, UserDto.from(user))) + .isInstanceOf(MegaphoneNotFoundException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(megaphoneRepository, times(1)).findById(any(Long.class)); + } + + @Test + @DisplayName("UserNotFoundException") + void userNotFoundException() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> megaphoneService.deleteMegaphone(1L, UserDto.from(user))) + .isInstanceOf(UserNotFoundException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + } + } + + @Nested + @DisplayName("getMegaphoneDetail 메서드 유닛 테스트") + class GetMegaphoneDetailUnitTest { + Megaphone megaphone; + + @BeforeEach + void beforeEach() { + megaphone = new Megaphone(user, receipt, "test", LocalDate.now()); + } + + @Test + @DisplayName("success") + void success() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(user)); + given(receiptRepository.findById(any(Long.class))).willReturn(Optional.of(receipt)); + given(megaphoneRepository.findByReceipt(any(Receipt.class))).willReturn(Optional.of(megaphone)); + // when, then + megaphoneService.getMegaphoneDetail(1L, UserDto.from(user)); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(receiptRepository, times(1)).findById(any(Long.class)); + verify(itemService, times(1)).checkItemType(any(), any()); + verify(itemService, times(1)).checkItemOwner(any(), any()); + verify(itemService, times(1)).checkItemStatus(any()); + verify(megaphoneRepository, times(1)).findByReceipt(any(Receipt.class)); + + } + + @Test + @DisplayName("MegaphoneNotFoundException") + void megaphoneNotFoundException() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(user)); + given(receiptRepository.findById(any(Long.class))).willReturn(Optional.of(receipt)); + given(megaphoneRepository.findByReceipt(any(Receipt.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> megaphoneService.getMegaphoneDetail(1L, UserDto.from(user))) + .isInstanceOf(MegaphoneNotFoundException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(receiptRepository, times(1)).findById(any(Long.class)); + verify(itemService, times(1)).checkItemType(any(), any()); + verify(itemService, times(1)).checkItemOwner(any(), any()); + verify(itemService, times(1)).checkItemStatus(any()); + verify(megaphoneRepository, times(1)).findByReceipt(any(Receipt.class)); + } + + @Test + @DisplayName("ReceiptNotFoundException") + void receiptNotFoundException() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(user)); + given(receiptRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> megaphoneService.getMegaphoneDetail(1L, UserDto.from(user))) + .isInstanceOf(ReceiptNotFoundException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(receiptRepository, times(1)).findById(any(Long.class)); + } + + @Test + @DisplayName("UserNotFoundException") + void userNotFoundException() { + // given + given(userRepository.findById(any(Long.class))).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> megaphoneService.getMegaphoneDetail(1L, UserDto.from(user))) + .isInstanceOf(UserNotFoundException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + } + } + + @Nested + @DisplayName("getMegaphoneTodayList 메서드 유닛 테스트") + class GetMegaphoneTodayListUnitTest { + @Test + @DisplayName("success") + void success() { + // given + given(megaphoneRedisRepository.getAllMegaphone()).willReturn(new ArrayList<>()); + // when, then + megaphoneService.getMegaphoneTodayList(); + verify(megaphoneRedisRepository, times(1)).getAllMegaphone(); + } + } +} From 7dd36240d65c62edddfd33074407ffa93aa6a0c4 Mon Sep 17 00:00:00 2001 From: hannkim Date: Mon, 5 Feb 2024 14:00:45 +0900 Subject: [PATCH 11/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20MatchTourn?= =?UTF-8?q?amentService=20=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=20(#526)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/TournamentAdminService.java | 4 +- .../domain/game/service/GameService.java | 6 +- .../match/service/MatchTournamentService.java | 60 ++-- .../match/type/TournamentMatchStatus.java | 7 +- .../data/TournamentGameRepository.java | 2 + .../tournament/service/TournamentService.java | 8 +- .../domain/tournament/type/RoundNumber.java | 15 + .../tournament/type/TournamentRound.java | 32 +- .../TournamentAdminControllerTest.java | 5 +- .../match/service/MatchBothServiceTest.java | 4 +- .../service/MatchFindServiceUnitTest.java | 33 +- .../match/service/MatchServiceTest.java | 4 +- .../service/MatchTournamentServiceTest.java | 30 +- .../MatchTournamentServiceUnitTest.java | 331 ++++++++++++++++++ .../domain/match/utils/GameTestUtils.java | 27 ++ .../utils/MatchIntegrationTestUtils.java} | 80 +---- .../match/utils/TournamentGameTestUtils.java | 110 ++++++ .../match/utils/TournamentTestUtils.java | 46 +++ .../domain/match/utils/UserTestUtils.java | 35 ++ .../tournament/data/TournamentUnitTest.java | 2 +- 20 files changed, 675 insertions(+), 166 deletions(-) create mode 100644 src/main/java/com/gg/server/domain/tournament/type/RoundNumber.java create mode 100644 src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceUnitTest.java create mode 100644 src/test/java/com/gg/server/domain/match/utils/GameTestUtils.java rename src/test/java/com/gg/server/{utils/MatchTestUtils.java => domain/match/utils/MatchIntegrationTestUtils.java} (63%) create mode 100644 src/test/java/com/gg/server/domain/match/utils/TournamentGameTestUtils.java create mode 100644 src/test/java/com/gg/server/domain/match/utils/TournamentTestUtils.java create mode 100644 src/test/java/com/gg/server/domain/match/utils/UserTestUtils.java diff --git a/src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java b/src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java index bd67b9c04..ae219f476 100644 --- a/src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java +++ b/src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java @@ -331,8 +331,8 @@ public void updateTournamentGame(Long tournamentId, TournamentGameUpdateRequestD teamUsers.add(team.getTeamUsers().get(0)); } gameService.savePChange(game, teamUsers, teamUsers.get(0).getUser().getId()); - if (POSSIBLE.equals(matchStatus)) { - matchTournamentService.matchGames(tournament, nextRound); + if (REQUIRED.equals(matchStatus)) { + matchTournamentService.matchGames(tournament, nextRound.getRoundNumber()); } else if (ALREADY_MATCHED.equals(matchStatus)) { Game nextMatchedGame = tournamentGameRepository.findByTournamentIdAndTournamentRound(tournament.getId(), nextRound) diff --git a/src/main/java/com/gg/server/domain/game/service/GameService.java b/src/main/java/com/gg/server/domain/game/service/GameService.java index 47979637a..1686ba520 100644 --- a/src/main/java/com/gg/server/domain/game/service/GameService.java +++ b/src/main/java/com/gg/server/domain/game/service/GameService.java @@ -39,6 +39,7 @@ import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.data.TournamentGameRepository; import com.gg.server.domain.tournament.exception.TournamentGameNotFoundException; +import com.gg.server.domain.tournament.type.RoundNumber; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.InvalidParameterException; import com.gg.server.global.utils.ExpLevelCalculator; @@ -113,11 +114,12 @@ public void createTournamentGameResult(TournamentResultReqDto scoreDto, Long use throw new GameStatusNotMatchedException(); } updateTournamentGameScore(game, scoreDto, userId); - if (TournamentMatchStatus.POSSIBLE.equals(matchTournamentService.checkTournamentGame(game))) { + if (TournamentMatchStatus.REQUIRED.equals(matchTournamentService.checkTournamentGame(game))) { TournamentGame tournamentGame = tournamentGameRepository.findByGameId(game.getId()) .orElseThrow(TournamentGameNotFoundException::new); Tournament tournament = tournamentGame.getTournament(); - matchTournamentService.matchGames(tournament, tournamentGame.getTournamentRound().getNextRound()); + RoundNumber matchRound = tournamentGame.getTournamentRound().getNextRound().getRoundNumber(); + matchTournamentService.matchGames(tournament, matchRound); } } diff --git a/src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java b/src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java index 77d19d20c..6c412dcbd 100644 --- a/src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java +++ b/src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java @@ -1,6 +1,7 @@ package com.gg.server.domain.match.service; import static com.gg.server.domain.match.type.TournamentMatchStatus.*; +import static com.gg.server.domain.tournament.type.RoundNumber.*; import java.time.LocalDateTime; import java.util.ArrayList; @@ -38,6 +39,7 @@ import com.gg.server.domain.tournament.data.TournamentGameRepository; import com.gg.server.domain.tournament.data.TournamentUser; import com.gg.server.domain.tournament.exception.TournamentGameNotFoundException; +import com.gg.server.domain.tournament.type.RoundNumber; import com.gg.server.domain.tournament.type.TournamentRound; import com.gg.server.domain.tournament.type.TournamentStatus; import com.gg.server.domain.user.data.User; @@ -68,7 +70,7 @@ public TournamentMatchStatus checkTournamentGame(Game game) { // 토너먼트 결승전 게임일 경우, 토너먼트 상태 END로 변경 if (TournamentRound.THE_FINAL.equals(tournamentGame.getTournamentRound())) { closeTournament(tournamentGame.getTournament(), game); - return IMPOSSIBLE; + return NO_MORE_MATCHES; } // 같은 round의 모든 게임이 END인 경우, 다음 round의 토너먼트 게임 매칭 가능 @@ -80,25 +82,25 @@ public TournamentMatchStatus checkTournamentGame(Game game) { .collect(Collectors.toList()); for (TournamentGame tg : sameRoundGames) { if (!StatusType.END.equals(tg.getGame().getStatus())) { - return IMPOSSIBLE; + return UNNECESSARY; } } - if (isAlreadyExistMatchedGame(tournamentGame.getTournament(), round.getNextRound())) { + if (isAlreadyExistMatchedGame(tournamentGame.getTournament(), round.getNextRound().getRoundNumber())) { return ALREADY_MATCHED; } - return POSSIBLE; + return REQUIRED; } /** * 토너먼트 게임 매칭 * @param tournament 토너먼트 - * @param round 새로 매칭할 토너먼트 라운드 + * @param roundNumber 새로 매칭할 토너먼트 라운드 * @throws EnrolledSlotException 이미 매칭된 게임이 존재할 경우 * @throws SlotNotFoundException 슬롯이 존재하지 않을 경우 */ @Transactional - public void matchGames(Tournament tournament, TournamentRound round) { - if (isAlreadyExistMatchedGame(tournament, round)) { + public void matchGames(Tournament tournament, RoundNumber roundNumber) { + if (isAlreadyExistMatchedGame(tournament, roundNumber)) { throw new EnrolledSlotException(); } Season season = seasonFindService.findCurrentSeason(tournament.getStartTime()); @@ -106,9 +108,9 @@ public void matchGames(Tournament tournament, TournamentRound round) { .orElseThrow(SlotNotFoundException::new); int gameInterval = slotManagement.getGameInterval(); List allTournamentGames = tournamentGameRepository.findAllByTournamentId(tournament.getId()); - List tournamentGames = findSameRoundGames(allTournamentGames, round.getRoundNumber()); - List players = findSortedPlayers(tournament, round); - LocalDateTime startTime = calculateStartTime(tournament, round, gameInterval); + List tournamentGames = findSameRoundGames(allTournamentGames, roundNumber); + List players = findSortedPlayers(tournament, roundNumber); + LocalDateTime startTime = calculateStartTime(tournament, roundNumber, gameInterval); for (int i = 0; i < tournamentGames.size(); ++i) { Game game = new Game(season, StatusType.BEFORE, Mode.TOURNAMENT, startTime, @@ -133,6 +135,7 @@ public void matchGames(Tournament tournament, TournamentRound round) { * @param modifiedGame 경기 결과가 수정된 토너먼트 게임 * @param nextMatchedGame 수정된 우승자로 수정할 다음 게임 * @throws WinningTeamNotFoundException 우승팀이 존재하지 않을 경우 + * @throws LosingTeamNotFoundException 패자팀이 존재하지 않을 경우 */ @Transactional public void updateMatchedGameUser(Game modifiedGame, Game nextMatchedGame) { @@ -158,18 +161,18 @@ public void updateMatchedGameUser(Game modifiedGame, Game nextMatchedGame) { /** * @param tournament 토너먼트 - * @param round 토너먼트 라운드 + * @param roundNumber 토너먼트 라운드 * @param gameInterval 경기 간격 * @return 마지막 경기 종료 시간 + interval *

8강의 경우 토너먼트 시작 시간

*

4강, 결승일 경우 이전 라운드의 마지막 경기 종료 시간 + 15분

*/ - private LocalDateTime calculateStartTime(Tournament tournament, TournamentRound round, int gameInterval) { - if (TournamentRound.QUARTER_FINAL_1.getRoundNumber() == round.getRoundNumber()) { + private LocalDateTime calculateStartTime(Tournament tournament, RoundNumber roundNumber, int gameInterval) { + if (QUARTER_FINAL == roundNumber) { return tournament.getStartTime(); } List previousRoundTournamentGames = findSameRoundGames(tournament.getTournamentGames(), - TournamentRound.getPreviousRoundNumber(round)); + TournamentRound.getPreviousRoundNumber(roundNumber)); TournamentGame lastGame = previousRoundTournamentGames.get(previousRoundTournamentGames.size() - 1); return lastGame.getGame().getEndTime().plusMinutes(gameInterval); } @@ -177,13 +180,13 @@ private LocalDateTime calculateStartTime(Tournament tournament, TournamentRound /** * 토너먼트 라운드에 매칭될 플레이어를 찾는다. * @param tournament 토너먼트 - * @param round 매칭할 토너먼트 라운드 + * @param roundNumber 매칭할 토너먼트 라운드 * @return 토너먼트 라운드에 매칭될 플레이어 List (정렬된 상태) */ - private List findSortedPlayers(Tournament tournament, TournamentRound round) { + private List findSortedPlayers(Tournament tournament, RoundNumber roundNumber) { List players = new ArrayList<>(); - if (TournamentRound.QUARTER_FINAL_1.getRoundNumber() == round.getRoundNumber()) { + if (QUARTER_FINAL == roundNumber) { Map randomNumbers = new LinkedHashMap<>(); Random random = new Random(); while (randomNumbers.size() < Tournament.ALLOWED_JOINED_NUMBER) { @@ -199,8 +202,8 @@ private List findSortedPlayers(Tournament tournament, TournamentRound roun } } else { List previousRoundTournamentGames = findSameRoundGames(tournament.getTournamentGames(), - TournamentRound.getPreviousRoundNumber(round)); - int roundNum = round.getRoundNumber(); + TournamentRound.getPreviousRoundNumber(roundNumber)); + int roundNum = roundNumber.getRound(); for (int i = 0; i < roundNum; ++i) { User user = getWinningTeam(previousRoundTournamentGames.get(i).getGame()) .getTeamUsers().get(0).getUser(); @@ -213,15 +216,20 @@ private List findSortedPlayers(Tournament tournament, TournamentRound roun /** * round에 매칭된 게임이 이미 존재하는지 확인 * @param tournament 토너먼트 - * @param round 토너먼트 라운드 + * @param roundNumber 토너먼트 라운드 * @return true - 매칭된 게임이 존재, false - 아직 매칭된 게임이 존재하지 않음 * @throws TournamentGameNotFoundException 토너먼트 게임이 존재하지 않을 경우 */ - private boolean isAlreadyExistMatchedGame(Tournament tournament, TournamentRound round) { - TournamentGame tournamentGame = tournamentGameRepository.findByTournamentIdAndTournamentRound( - tournament.getId(), round) - .orElseThrow(TournamentGameNotFoundException::new); - return tournamentGame.getGame() != null; + private boolean isAlreadyExistMatchedGame(Tournament tournament, RoundNumber roundNumber) { + List sameRounds = TournamentRound.getSameRounds(roundNumber); + List tournamentGames = tournamentGameRepository.findByTournamentIdAndTournamentRoundIn( + tournament.getId(), sameRounds); + for (TournamentGame tournamentGame : tournamentGames) { + if (tournamentGame.getGame() != null) { + return true; + } + } + return false; } /** @@ -247,7 +255,7 @@ private void closeTournament(Tournament tournament, Game finalGame) { * @param roundNum 토너먼트 라운드 number (2, 4, 8, ...) (잘못된 roundNum일 경우 Empty List 반환한다.) * @return tournamentGames 중 roundNum과 동일한 roundNum을 가진 round 순으로 정렬된 tournamentGame List 반환 */ - private List findSameRoundGames(List tournamentGames, int roundNum) { + private List findSameRoundGames(List tournamentGames, RoundNumber roundNum) { return tournamentGames.stream() .filter(tournamentGame -> roundNum == tournamentGame.getTournamentRound().getRoundNumber()) .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) diff --git a/src/main/java/com/gg/server/domain/match/type/TournamentMatchStatus.java b/src/main/java/com/gg/server/domain/match/type/TournamentMatchStatus.java index b2e5e29bd..166dbda6f 100644 --- a/src/main/java/com/gg/server/domain/match/type/TournamentMatchStatus.java +++ b/src/main/java/com/gg/server/domain/match/type/TournamentMatchStatus.java @@ -7,9 +7,10 @@ @RequiredArgsConstructor public enum TournamentMatchStatus { // 토너먼트 매치 상태 - IMPOSSIBLE(0, "매칭 불가능"), - POSSIBLE(1, "매칭 가능"), - ALREADY_MATCHED(2, "이미 매칭됨"); + UNNECESSARY(0, "매칭 불필요함"), + REQUIRED(1, "매칭 필요함"), + ALREADY_MATCHED(2, "이미 매칭됨"), + NO_MORE_MATCHES(3, "마지막 경기로 더이상 매칭할 게임이 없음"); private final Integer value; private final String code; diff --git a/src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java b/src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java index 3e9f94e9a..de8736f01 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java +++ b/src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java @@ -12,5 +12,7 @@ public interface TournamentGameRepository extends JpaRepository findByTournamentIdAndTournamentRound(Long id, TournamentRound tournamentRound); + List findByTournamentIdAndTournamentRoundIn(Long id, List tournamentRounds); + Optional findByGameId(Long gameId); } diff --git a/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java b/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java index 4f3d9b0e3..082f935f5 100644 --- a/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java +++ b/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java @@ -1,6 +1,6 @@ package com.gg.server.domain.tournament.service; -import static com.gg.server.domain.tournament.type.TournamentRound.*; +import static com.gg.server.domain.tournament.type.RoundNumber.*; import java.time.LocalDate; import java.time.LocalDateTime; @@ -220,7 +220,7 @@ public void startTournament() { return; } imminentTournament.updateStatus(TournamentStatus.LIVE); - matchTournamentService.matchGames(imminentTournament, QUARTER_FINAL_1); + matchTournamentService.matchGames(imminentTournament, QUARTER_FINAL); } } @@ -295,7 +295,9 @@ private List getTournamentGameResDtoList(Long tournamentId nextTournamentGame)); } tournamentGameResDtoList.sort((o1, o2) -> { - if (o1.getTournamentRound().getRoundNumber() < o2.getTournamentRound().getRoundNumber()) { + if (o1.getTournamentRound().getRoundNumber().getRound() < o2.getTournamentRound() + .getRoundNumber() + .getRound()) { return 1; } if (o1.getTournamentRound().getRoundOrder() > o2.getTournamentRound().getRoundOrder()) { diff --git a/src/main/java/com/gg/server/domain/tournament/type/RoundNumber.java b/src/main/java/com/gg/server/domain/tournament/type/RoundNumber.java new file mode 100644 index 000000000..417793582 --- /dev/null +++ b/src/main/java/com/gg/server/domain/tournament/type/RoundNumber.java @@ -0,0 +1,15 @@ +package com.gg.server.domain.tournament.type; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@Getter +public enum RoundNumber { + THE_FINAL(2, "결승"), + SEMI_FINAL(4, "4강"), + QUARTER_FINAL(8, "8강"); + + private final int round; + private final String code; +} diff --git a/src/main/java/com/gg/server/domain/tournament/type/TournamentRound.java b/src/main/java/com/gg/server/domain/tournament/type/TournamentRound.java index 8952ffaa5..6b09aefba 100644 --- a/src/main/java/com/gg/server/domain/tournament/type/TournamentRound.java +++ b/src/main/java/com/gg/server/domain/tournament/type/TournamentRound.java @@ -1,5 +1,7 @@ package com.gg.server.domain.tournament.type; +import static com.gg.server.domain.tournament.type.RoundNumber.*; + import java.util.ArrayList; import java.util.List; @@ -13,22 +15,22 @@ public enum TournamentRound { // semi final -> 4강 // quarter final -> 8강 // ordinal()로 sorting 사용되고 있으므로 순서 중요 -> 이후에 리팩토링으로 해결하겠습니다. - THE_FINAL(null, 2, 1), - SEMI_FINAL_1(THE_FINAL, 4, 1), - SEMI_FINAL_2(THE_FINAL, 4, 2), - QUARTER_FINAL_1(SEMI_FINAL_1, 8, 1), - QUARTER_FINAL_2(SEMI_FINAL_1, 8, 2), - QUARTER_FINAL_3(SEMI_FINAL_2, 8, 3), - QUARTER_FINAL_4(SEMI_FINAL_2, 8, 4); + THE_FINAL(null, RoundNumber.THE_FINAL, 1), + SEMI_FINAL_1(THE_FINAL, SEMI_FINAL, 1), + SEMI_FINAL_2(THE_FINAL, SEMI_FINAL, 2), + QUARTER_FINAL_1(SEMI_FINAL_1, QUARTER_FINAL, 1), + QUARTER_FINAL_2(SEMI_FINAL_1, QUARTER_FINAL, 2), + QUARTER_FINAL_3(SEMI_FINAL_2, QUARTER_FINAL, 3), + QUARTER_FINAL_4(SEMI_FINAL_2, QUARTER_FINAL, 4); private final TournamentRound nextRound; - private final int roundNumber; + private final RoundNumber roundNumber; private final int roundOrder; - public static List getSameRounds(TournamentRound round) { + public static List getSameRounds(RoundNumber roundNumber) { List sameRounds = new ArrayList<>(); for (TournamentRound e : values()) { - if (e.roundNumber == round.roundNumber) { + if (roundNumber.equals(e.getRoundNumber())) { sameRounds.add(e); } } @@ -37,15 +39,15 @@ public static List getSameRounds(TournamentRound round) { /** * 이전 TournamentRound의 roundNum를 반환한다. - * @param round - 현재 라운드 - * @return 이전 라운드의 roundNum, 없을 경우 -1 반환 + * @param roundNumber - 현재 라운드 + * @return 이전 라운드의 roundNum, 없을 경우 null 반환 */ - public static int getPreviousRoundNumber(TournamentRound round) { + public static RoundNumber getPreviousRoundNumber(RoundNumber roundNumber) { for (TournamentRound e : values()) { - if (e.nextRound == round) { + if (e.nextRound != null && roundNumber == e.nextRound.getRoundNumber()) { return e.roundNumber; } } - return -1; + return null; } } diff --git a/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java b/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java index d4187b7dc..9cccc0164 100644 --- a/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java @@ -26,6 +26,7 @@ import com.gg.server.admin.tournament.dto.TournamentGameUpdateRequestDto; import com.gg.server.admin.tournament.service.TournamentAdminService; import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.match.utils.MatchIntegrationTestUtils; import com.gg.server.domain.pchange.data.PChangeRepository; import com.gg.server.domain.season.data.Season; import com.gg.server.domain.team.dto.TeamReqDto; @@ -43,7 +44,6 @@ import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.CustomRuntimeException; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.MatchTestUtils; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; @@ -83,7 +83,7 @@ class TournamentAdminControllerTest { PChangeRepository pChangeRepository; @Autowired - private MatchTestUtils matchTestUtils; + private MatchIntegrationTestUtils matchTestUtils; @Nested @DisplayName("토너먼트_관리_수정_컨트롤러_테스트") @@ -994,6 +994,5 @@ void updateTournamentGameEnable() throws Exception { .andExpect(status().isForbidden()) .andReturn().getResponse().getContentAsString(); } - } } diff --git a/src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java b/src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java index a7fa29104..a936e6ef2 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java +++ b/src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java @@ -26,6 +26,7 @@ import com.gg.server.domain.match.data.RedisMatchUserRepository; import com.gg.server.domain.match.exception.SlotNotFoundException; import com.gg.server.domain.match.type.Option; +import com.gg.server.domain.match.utils.MatchIntegrationTestUtils; import com.gg.server.domain.noti.data.NotiRepository; import com.gg.server.domain.penalty.redis.PenaltyUserRedisRepository; import com.gg.server.domain.rank.redis.RankRedisRepository; @@ -34,7 +35,6 @@ import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.utils.MatchTestUtils; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; @@ -58,7 +58,7 @@ class MatchBothServiceTest { @Autowired RedisTemplate redisTemplate; @Autowired - MatchTestUtils matchTestSetting; + MatchIntegrationTestUtils matchTestSetting; @Autowired GameRepository gameRepository; @Autowired diff --git a/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java b/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java index d81d099ff..e129d799a 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java +++ b/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java @@ -1,9 +1,11 @@ package com.gg.server.domain.match.service; +import static com.gg.server.domain.match.utils.GameTestUtils.createNormalGame; +import static com.gg.server.domain.match.utils.UserTestUtils.createGuestUser; +import static com.gg.server.domain.match.utils.UserTestUtils.createUser; import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; -import static org.mockito.Mockito.*; import java.time.LocalDateTime; import java.util.List; @@ -22,7 +24,6 @@ import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.match.data.RedisMatchTime; import com.gg.server.domain.match.data.RedisMatchTimeRepository; @@ -36,8 +37,6 @@ import com.gg.server.domain.season.service.SeasonFindService; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.data.Team; -import com.gg.server.domain.team.data.TeamUser; import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; import com.gg.server.domain.user.data.User; @@ -85,21 +84,10 @@ public void init() { setFieldWithReflection(tier, "id", 1L); } - private Game createGame(User user, User enemy) { - LocalDateTime startTime = LocalDateTime.of(2024, 1, 1, 0, 0); - Game game = new Game(season, StatusType.BEFORE, Mode.NORMAL, startTime, startTime.plusMinutes(15)); - Team teamA = new Team(game, -1, false); - Team teamB = new Team(game, -1, false); - new TeamUser(teamA, user); - new TeamUser(teamB, enemy); - setFieldWithReflection(game, "id", 1L); - return game; - } - @Nested @DisplayName("현재 내가 등록한 슬롯 정보 가져오기") class GetCurrentMatch { - private final User user = User.builder().roleType(RoleType.USER).intraId("hannkim").build(); + private final User user = createUser(); @BeforeEach public void init() { @@ -133,9 +121,10 @@ void successUnmatchedSlots() { void successMatchedSlot() { // given UserDto userDto = UserDto.from(user); - User enemy = User.builder().roleType(RoleType.USER).intraId("enemy").build(); + User enemy = createUser(); + Game myGame = createNormalGame(user, enemy, season); setFieldWithReflection(enemy, "id", 2L); - Game myGame = createGame(user, enemy); + setFieldWithReflection(myGame, "id", 1L); given(slotManagementRepository.findCurrent(any(LocalDateTime.class))).willReturn( Optional.of(slotManagement)); given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, user.getId())).willReturn( @@ -156,7 +145,7 @@ void successMatchedSlot() { @Nested @DisplayName("경기 매칭 가능 상태 조회") class GetAllMatchStatus { - private final User user = User.builder().roleType(RoleType.USER).intraId("hannkim").build(); + private final User user = createUser(); private SlotGenerator slotGenerator; @BeforeEach @@ -213,7 +202,7 @@ void success() { @DisplayName("GUEST 유저가 슬롯 정보를 가져온다. - 내가 등록한 슬롯 없는 경우") void successGuest() { // given - User guest = User.builder().intraId("guest").roleType(RoleType.GUEST).build(); + User guest = createGuestUser(); RankRedis redisUser = RankRedis.from(UserDto.from(guest), season.getStartPpp(), tier.getImageUri()); slotGenerator = new SlotGenerator(redisUser, slotManagement, season, Option.BOTH); given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(guest).getId())).willReturn( @@ -241,8 +230,8 @@ void successWithMySlot() { UserDto userDto = UserDto.from(user); RankRedis redisUser = RankRedis.from(userDto, season.getStartPpp(), tier.getImageUri()); String hashKey = RedisKeyManager.getHashKey(season.getId()); - User enemy = User.builder().roleType(RoleType.USER).intraId("enemy").build(); - Game game = createGame(user, enemy); + User enemy = createUser(); + Game game = createNormalGame(user, enemy, season); setFieldWithReflection(enemy, "id", 2L); setFieldWithReflection(game, "id", 1L); given(rankRedisRepository.findRankByUserId(hashKey, user.getId())).willReturn(redisUser); diff --git a/src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java b/src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java index 492459201..f28bd0131 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java +++ b/src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java @@ -35,6 +35,7 @@ import com.gg.server.domain.match.type.MatchKey; import com.gg.server.domain.match.type.Option; import com.gg.server.domain.match.type.SlotStatus; +import com.gg.server.domain.match.utils.MatchIntegrationTestUtils; import com.gg.server.domain.noti.data.Noti; import com.gg.server.domain.noti.data.NotiRepository; import com.gg.server.domain.noti.type.NotiType; @@ -57,7 +58,6 @@ import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.exception.custom.BusinessException; -import com.gg.server.utils.MatchTestUtils; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; @@ -80,7 +80,7 @@ class MatchServiceTest { @Autowired RedisTemplate redisTemplate; @Autowired - MatchTestUtils matchTestSetting; + MatchIntegrationTestUtils matchTestSetting; @Autowired GameRepository gameRepository; @Autowired diff --git a/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java b/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java index fdfae8721..c165b52f8 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java +++ b/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java @@ -1,5 +1,6 @@ package com.gg.server.domain.match.service; +import static com.gg.server.domain.tournament.type.RoundNumber.*; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; @@ -15,7 +16,6 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.transaction.annotation.Transactional; @@ -28,6 +28,8 @@ import com.gg.server.domain.match.exception.SlotNotFoundException; import com.gg.server.domain.match.exception.WinningTeamNotFoundException; import com.gg.server.domain.match.type.TournamentMatchStatus; +import com.gg.server.domain.match.utils.MatchIntegrationTestUtils; +import com.gg.server.domain.match.utils.TournamentGameTestUtils; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; import com.gg.server.domain.team.data.Team; import com.gg.server.domain.tournament.data.Tournament; @@ -35,12 +37,10 @@ import com.gg.server.domain.tournament.type.TournamentRound; import com.gg.server.domain.tournament.type.TournamentStatus; import com.gg.server.domain.user.data.User; -import com.gg.server.utils.MatchTestUtils; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; @IntegrationTest -@SpringBootTest @Transactional public class MatchTournamentServiceTest { @Autowired @@ -52,7 +52,7 @@ public class MatchTournamentServiceTest { @Autowired MatchTournamentService matchTournamentService; @Autowired - MatchTestUtils matchTestUtils; + MatchIntegrationTestUtils matchTestUtils; @MockBean NotiAdminService notiAdminService; @@ -74,10 +74,10 @@ class MatchTournament { @DisplayName("8강 경기 매칭 성공") public void quarterTest() { // when - matchTournamentService.matchGames(tournament, TournamentRound.QUARTER_FINAL_1); + matchTournamentService.matchGames(tournament, QUARTER_FINAL); // then - List quarterRounds = TournamentRound.getSameRounds(TournamentRound.QUARTER_FINAL_1); + List quarterRounds = TournamentRound.getSameRounds(QUARTER_FINAL); List quarterRoundGames = allTournamentGames.stream() .filter(o -> quarterRounds.contains(o.getTournamentRound())) .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) @@ -109,10 +109,10 @@ public void semiTest() { matchTestUtils.updateTournamentGamesResult(tournamentGames, List.of(2, 0)); // when - matchTournamentService.matchGames(tournament, TournamentRound.SEMI_FINAL_1); + matchTournamentService.matchGames(tournament, SEMI_FINAL); // then - List semiRounds = TournamentRound.getSameRounds(TournamentRound.SEMI_FINAL_1); + List semiRounds = TournamentRound.getSameRounds(SEMI_FINAL); List semiRoundGames = allTournamentGames.stream() .filter(o -> semiRounds.contains(o.getTournamentRound())) .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) @@ -124,7 +124,7 @@ public void semiTest() { assertThat(tournamentGame.getGame().getStatus()).isEqualTo(StatusType.BEFORE); } // 8강에서 이긴 유저끼리 4강에 매칭되었는지 확인 - List quarterRounds = TournamentRound.getSameRounds(TournamentRound.QUARTER_FINAL_1); + List quarterRounds = TournamentRound.getSameRounds(QUARTER_FINAL); List quarterRoundGames = allTournamentGames.stream() .filter(o -> quarterRounds.contains(o.getTournamentRound())) .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) @@ -136,7 +136,7 @@ public void semiTest() { semiTeams.add(semiRoundGame.getGame().getTeams().get(1).getTeamUsers().get(0).getUser()); } for (TournamentGame quarterRoundGame : quarterRoundGames) { - Team winningTeam = matchTestUtils.getWinningTeam(quarterRoundGame.getGame()); + Team winningTeam = TournamentGameTestUtils.getWinningTeam(quarterRoundGame.getGame()); quarterWinningTeams.add(winningTeam.getTeamUsers().get(0).getUser()); } assertThat(semiTeams).contains(quarterWinningTeams.get(0)); @@ -157,7 +157,7 @@ public void finalTest() { matchTestUtils.updateTournamentGamesResult(semiGames, List.of(2, 0)); // when - matchTournamentService.matchGames(tournament, TournamentRound.THE_FINAL); + matchTournamentService.matchGames(tournament, THE_FINAL); // then // 1개의 결승 경기가 생성되었는지 확인 @@ -180,7 +180,7 @@ public void failAlreadyMatched() { matchTestUtils.updateTournamentGamesResult(semiGames, List.of(2, 0)); // when, then - assertThatThrownBy(() -> matchTournamentService.matchGames(tournament, TournamentRound.SEMI_FINAL_1)) + assertThatThrownBy(() -> matchTournamentService.matchGames(tournament, SEMI_FINAL)) .isInstanceOf(EnrolledSlotException.class); } } @@ -210,7 +210,7 @@ public void finalEndTest() { // then // 토너먼트 상태가 END로 변경되었는지 // winner가 존재하는지 확인 - assertThat(TournamentMatchStatus.IMPOSSIBLE).isEqualTo(tournamentMatchStatus); + assertThat(TournamentMatchStatus.NO_MORE_MATCHES).isEqualTo(tournamentMatchStatus); assertThat(tournament.getStatus()).isEqualTo(TournamentStatus.END); assertThat(tournament.getWinner()).isNotNull(); assertThat(tournament.getEndTime()).isEqualTo(finalGame.getEndTime()); @@ -230,7 +230,7 @@ public void impossibleTest() { quarterGames.get(0).getGame()); // then - assertThat(tournamentMatchStatus).isEqualTo(TournamentMatchStatus.IMPOSSIBLE); + assertThat(tournamentMatchStatus).isEqualTo(TournamentMatchStatus.UNNECESSARY); } @Test @@ -267,7 +267,7 @@ public void possibleTest() { quarterGames.get(0).getGame()); // then - assertThat(tournamentMatchStatus).isEqualTo(TournamentMatchStatus.POSSIBLE); + assertThat(tournamentMatchStatus).isEqualTo(TournamentMatchStatus.REQUIRED); } } diff --git a/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceUnitTest.java b/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceUnitTest.java new file mode 100644 index 000000000..28081f52c --- /dev/null +++ b/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceUnitTest.java @@ -0,0 +1,331 @@ +package com.gg.server.domain.match.service; + +import static com.gg.server.domain.match.utils.TournamentGameTestUtils.*; +import static com.gg.server.domain.tournament.type.RoundNumber.*; +import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.mockito.BDDMockito.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.Random; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; +import com.gg.server.admin.noti.service.NotiAdminService; +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.data.GameRepository; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.match.exception.EnrolledSlotException; +import com.gg.server.domain.match.exception.WinningTeamNotFoundException; +import com.gg.server.domain.match.type.TournamentMatchStatus; +import com.gg.server.domain.match.utils.GameTestUtils; +import com.gg.server.domain.match.utils.TournamentTestUtils; +import com.gg.server.domain.match.utils.UserTestUtils; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.service.SeasonFindService; +import com.gg.server.domain.slotmanagement.SlotManagement; +import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; +import com.gg.server.domain.team.data.Team; +import com.gg.server.domain.tournament.data.Tournament; +import com.gg.server.domain.tournament.data.TournamentGame; +import com.gg.server.domain.tournament.data.TournamentGameRepository; +import com.gg.server.domain.tournament.type.RoundNumber; +import com.gg.server.domain.tournament.type.TournamentRound; +import com.gg.server.domain.tournament.type.TournamentStatus; +import com.gg.server.domain.user.data.User; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +public class MatchTournamentServiceUnitTest { + @InjectMocks + private MatchTournamentService matchTournamentService; + @Mock + private TournamentGameRepository tournamentGameRepository; + @Mock + private GameRepository gameRepository; + @Mock + private SlotManagementRepository slotManagementRepository; + @Mock + private SeasonFindService seasonFindService; + @Mock + private NotiAdminService notiAdminService; + private static final Season season = Season.builder().startTime(LocalDateTime.now()).startPpp(123).build(); + private static Long gameId; + private static Long tournamentGameId; + + @BeforeEach + void init() { + gameId = 1L; + tournamentGameId = 1L; + } + + @Nested + @DisplayName("checkTournamentGame() - 8강 경기가 진행중인 토너먼트에서 다음 라운드의 매칭 필요 유무를 확인한다.") + class CheckNextRoundTest { + private Tournament tournament; + + @BeforeEach + void init() { + tournament = TournamentTestUtils.createTournament(TournamentStatus.LIVE); + setFieldWithReflection(tournament, "id", 1L); + for (TournamentGame tournamentGame : tournament.getTournamentGames()) { + setFieldWithReflection(tournamentGame, "id", tournamentGameId++); + } + matchTournamentGames(tournament, QUARTER_FINAL, season); + List games = tournament.getTournamentGames().stream() + .filter(tournamentGame -> tournamentGame.getTournamentRound().getRoundNumber() == QUARTER_FINAL) + .map(TournamentGame::getGame).collect(Collectors.toList()); + setGameIds(games); + } + + @Test + @DisplayName("8강의 모든 게임이 종료된 경우, 4강이 매칭 필요하므로 REQUIRED 반환") + void checkRequiredMatch() { + // given + List quarterGames = getTournamentGamesByRoundNum(tournament, QUARTER_FINAL); + finishTournamentGames(quarterGames); + Random random = new Random(); + TournamentGame target = quarterGames.get(random.nextInt(quarterGames.size())); + RoundNumber nextRound = target.getTournamentRound().getNextRound().getRoundNumber(); + given(tournamentGameRepository.findByGameId(target.getGame().getId())).willReturn(Optional.of(target)); + given(tournamentGameRepository.findAllByTournamentId(tournament.getId())) + .willReturn(tournament.getTournamentGames()); + given(tournamentGameRepository.findByTournamentIdAndTournamentRoundIn( + tournament.getId(), TournamentRound.getSameRounds(nextRound))) + .willReturn(getTournamentGamesByRoundNum(tournament, nextRound)); + + // when + TournamentMatchStatus tournamentMatchStatus = matchTournamentService.checkTournamentGame(target.getGame()); + + // then + assertThat(tournamentMatchStatus).isEqualTo(TournamentMatchStatus.REQUIRED); + } + + @Test + @DisplayName("8강에 종료되지 않은 게임이 존재할 경우, 4강 매칭이 불필요하므로 UNNECESSARY 반환") + void checkUnnecessaryMatch() { + // given + TournamentGame quarterGame = getTournamentGameByRound(tournament, TournamentRound.QUARTER_FINAL_1).get(); + given(tournamentGameRepository.findByGameId(quarterGame.getGame().getId())).willReturn( + Optional.of(quarterGame)); + given(tournamentGameRepository.findAllByTournamentId(tournament.getId())) + .willReturn(tournament.getTournamentGames()); + + // when + TournamentMatchStatus matchStatus = matchTournamentService.checkTournamentGame(quarterGame.getGame()); + + // then + assertThat(matchStatus).isEqualTo(TournamentMatchStatus.UNNECESSARY); + } + + @Test + @DisplayName("결승전 게임일 경우, 매칭할 경기가 없으므로 NO_MORE_MATCHES을 반환하고 토너먼트는 종료된다.") + void checkFinalGame() { + // given + User user = UserTestUtils.createUser(); + User enemy = UserTestUtils.createUser(); + Game finalGame = GameTestUtils.createGame(user, enemy, season, Mode.TOURNAMENT); + TournamentGame finalTournamentGame = getTournamentGameByRound(tournament, TournamentRound.THE_FINAL).get(); + finalTournamentGame.updateGame(finalGame); + finishTournamentGame(finalTournamentGame); + given(tournamentGameRepository.findByGameId(finalGame.getId())).willReturn( + Optional.of(finalTournamentGame)); + + // when + TournamentMatchStatus matchStatus = matchTournamentService.checkTournamentGame(finalGame); + + // then + assertThat(matchStatus).isEqualTo(TournamentMatchStatus.NO_MORE_MATCHES); + assertThat(tournament.getStatus()).isEqualTo(TournamentStatus.END); + assertThat(tournament.getWinner()).isNotNull(); + } + + @Test + @DisplayName("다음 라운드인 4강 경기가 이미 매칭된 경우, ALREADY_MATCHED를 반환한다.") + void checkAlreadyMatched() { + // given + finishTournamentGames(getTournamentGamesByRoundNum(tournament, QUARTER_FINAL)); + matchTournamentGames(tournament, SEMI_FINAL, season); + Game targetGame = getTournamentGameByRound(tournament, TournamentRound.QUARTER_FINAL_1).get().getGame(); + given(tournamentGameRepository.findByGameId(targetGame.getId())).willReturn(Optional.of( + getTournamentGameByRound(tournament, TournamentRound.QUARTER_FINAL_1).get())); + given(tournamentGameRepository.findAllByTournamentId(tournament.getId())) + .willReturn(tournament.getTournamentGames()); + given(tournamentGameRepository.findByTournamentIdAndTournamentRoundIn( + tournament.getId(), TournamentRound.getSameRounds(SEMI_FINAL))) + .willReturn(getTournamentGamesByRoundNum(tournament, SEMI_FINAL)); + + // when + TournamentMatchStatus matchStatus = matchTournamentService.checkTournamentGame(targetGame); + + // then + assertThat(matchStatus).isEqualTo(TournamentMatchStatus.ALREADY_MATCHED); + } + } + + @Nested + @DisplayName("matchGames() - 토너먼트의 게임 매칭") + class MatchTournamentGameTest { + private Tournament tournament; + private SlotManagement slotManagement; + + @BeforeEach + void init() { + tournament = TournamentTestUtils.createTournament(TournamentStatus.LIVE); + setFieldWithReflection(tournament, "id", 1L); + for (TournamentGame tournamentGame : tournament.getTournamentGames()) { + setFieldWithReflection(tournamentGame, "id", tournamentGameId++); + } + matchTournamentGames(tournament, QUARTER_FINAL, season); + List games = tournament.getTournamentGames().stream() + .filter(tournamentGame -> tournamentGame.getTournamentRound().getRoundNumber() == QUARTER_FINAL) + .map(TournamentGame::getGame).collect(Collectors.toList()); + setGameIds(games); + + slotManagement = SlotManagement.builder() + .startTime(tournament.getStartTime()) + .gameInterval(10) + .build(); + } + + @Test + @DisplayName("이미 매칭된 8강을 매칭하려고 할 때, EnrolledSlotException 발생") + void matchAlreadyMatchedGame() { + // given + given(tournamentGameRepository.findByTournamentIdAndTournamentRoundIn( + tournament.getId(), TournamentRound.getSameRounds(QUARTER_FINAL))) + .willReturn(getTournamentGamesByRoundNum(tournament, QUARTER_FINAL)); + + // when, then + assertThatThrownBy(() -> matchTournamentService.matchGames(tournament, QUARTER_FINAL)) + .isInstanceOf(EnrolledSlotException.class); + } + + @Test + @DisplayName("4강 매칭 성공 후 noti 전송 및 게임 저장 확인") + void matchSuccess() { + // given + List quarterGames = getTournamentGamesByRoundNum(tournament, QUARTER_FINAL); + finishTournamentGames(quarterGames); + given(seasonFindService.findCurrentSeason(tournament.getStartTime())).willReturn(season); + given(slotManagementRepository.findCurrent(tournament.getStartTime())).willReturn( + Optional.of(slotManagement)); + given(tournamentGameRepository.findAllByTournamentId(tournament.getId())) + .willReturn(tournament.getTournamentGames()); + + // when + matchTournamentService.matchGames(tournament, SEMI_FINAL); + + // then + verify(gameRepository, times(SEMI_FINAL.getRound() / 2)).save(any(Game.class)); + verify(notiAdminService, times(SEMI_FINAL.getRound())).sendAnnounceNotiToUser( + any(SendNotiAdminRequestDto.class)); + List semiGames = getTournamentGamesByRoundNum(tournament, SEMI_FINAL); + for (TournamentGame semiGame : semiGames) { + assertThat(semiGame.getGame()).isNotNull(); + } + } + } + + @Nested + @DisplayName("updateMatchedGameUser() - 이전 경기 8강의 수정된 결과에 따라 다음 매칭된 4강 경기의 플레이어 수정") + class UpdateMatchResultTest { + private Tournament tournament; + + @BeforeEach + void init() { + tournament = TournamentTestUtils.createTournament(TournamentStatus.LIVE); + setFieldWithReflection(tournament, "id", 1L); + for (TournamentGame tournamentGame : tournament.getTournamentGames()) { + setFieldWithReflection(tournamentGame, "id", tournamentGameId++); + } + matchTournamentGames(tournament, QUARTER_FINAL, season); + List games = tournament.getTournamentGames().stream() + .filter(tournamentGame -> tournamentGame.getTournamentRound().getRoundNumber() == QUARTER_FINAL) + .map(TournamentGame::getGame).collect(Collectors.toList()); + setGameIds(games); + } + + @Test + @DisplayName("이전 경기 8강의 결과가 없는 경우, WinningTeamNotFoundException 발생") + void updateMatchResultWithoutWinner() { + // given + Game game = getTournamentGameByRound(tournament, TournamentRound.QUARTER_FINAL_1).get().getGame(); + + // when, then + Game nextMatchedGame = getTournamentGameByRound(tournament, TournamentRound.SEMI_FINAL_1).get().getGame(); + assertThatThrownBy(() -> matchTournamentService.updateMatchedGameUser(game, nextMatchedGame)) + .isInstanceOf(WinningTeamNotFoundException.class); + } + + @Test + @DisplayName("이미 매칭된 4강 경기의 플레이어를 성공적으로 업데이트") + void success() { + // given + finishTournamentGames(getTournamentGamesByRoundNum(tournament, QUARTER_FINAL)); + matchTournamentGames(tournament, SEMI_FINAL, season); + List semiGames = tournament.getTournamentGames().stream() + .filter(tournamentGame -> tournamentGame.getTournamentRound().getRoundNumber() == SEMI_FINAL) + .map(TournamentGame::getGame).collect(Collectors.toList()); + setGameIds(semiGames); + Game modifiedGame = getTournamentGameByRound(tournament, TournamentRound.QUARTER_FINAL_1).get().getGame(); + Game nextMatchedGame = getTournamentGameByRound(tournament, TournamentRound.SEMI_FINAL_1).get().getGame(); + Team losingTeam = getWinningTeam(modifiedGame); + Team winningTeam = getLosingTeam(modifiedGame); + losingTeam.updateScore(1, false); + winningTeam.updateScore(2, true); + + // when + matchTournamentService.updateMatchedGameUser(modifiedGame, nextMatchedGame); + + // then + List nextGameUsers = new ArrayList<>(); + nextGameUsers.add(nextMatchedGame.getTeams().get(0).getTeamUsers().get(0).getUser()); + nextGameUsers.add(nextMatchedGame.getTeams().get(1).getTeamUsers().get(0).getUser()); + + assertThat(nextGameUsers.contains(winningTeam.getTeamUsers().get(0).getUser())).isTrue(); + assertThat(nextGameUsers.contains(losingTeam.getTeamUsers().get(0).getUser())).isFalse(); + verify(notiAdminService, times(2)).sendAnnounceNotiToUser( + any(SendNotiAdminRequestDto.class)); + } + } + + private void finishTournamentGame(TournamentGame tournamentGame) { + Game game = tournamentGame.getGame(); + setFieldWithReflection(game, "status", StatusType.END); + List teams = game.getTeams(); + teams.get(0).updateScore(2, true); + teams.get(1).updateScore(1, false); + } + + private void finishTournamentGames(List tournamentGames) { + for (TournamentGame tournamentGame : tournamentGames) { + finishTournamentGame(tournamentGame); + } + } + + private void setGameId(Game game) { + setFieldWithReflection(game, "id", gameId++); + } + + private void setGameIds(List games) { + for (Game game : games) { + setGameId(game); + } + } +} diff --git a/src/test/java/com/gg/server/domain/match/utils/GameTestUtils.java b/src/test/java/com/gg/server/domain/match/utils/GameTestUtils.java new file mode 100644 index 000000000..c88104f82 --- /dev/null +++ b/src/test/java/com/gg/server/domain/match/utils/GameTestUtils.java @@ -0,0 +1,27 @@ +package com.gg.server.domain.match.utils; + +import java.time.LocalDateTime; + +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.team.data.Team; +import com.gg.server.domain.team.data.TeamUser; +import com.gg.server.domain.user.data.User; + +public class GameTestUtils { + public static Game createGame(User user, User enemy, Season season, Mode mode) { + LocalDateTime startTime = LocalDateTime.of(2024, 1, 1, 0, 0); + Game game = new Game(season, StatusType.BEFORE, mode, startTime, startTime.plusMinutes(15)); + Team teamA = new Team(game, -1, false); + Team teamB = new Team(game, -1, false); + new TeamUser(teamA, user); + new TeamUser(teamB, enemy); + return game; + } + + public static Game createNormalGame(User user, User enemy, Season season) { + return createGame(user, enemy, season, Mode.NORMAL); + } +} diff --git a/src/test/java/com/gg/server/utils/MatchTestUtils.java b/src/test/java/com/gg/server/domain/match/utils/MatchIntegrationTestUtils.java similarity index 63% rename from src/test/java/com/gg/server/utils/MatchTestUtils.java rename to src/test/java/com/gg/server/domain/match/utils/MatchIntegrationTestUtils.java index 248b46cd4..c053f5d7b 100644 --- a/src/test/java/com/gg/server/utils/MatchTestUtils.java +++ b/src/test/java/com/gg/server/domain/match/utils/MatchIntegrationTestUtils.java @@ -1,8 +1,7 @@ -package com.gg.server.utils; +package com.gg.server.domain.match.utils; import java.time.LocalDateTime; import java.util.ArrayList; -import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -12,9 +11,6 @@ import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.match.exception.WinningTeamNotFoundException; import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; @@ -23,21 +19,17 @@ import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; import com.gg.server.domain.team.data.Team; -import com.gg.server.domain.team.data.TeamUser; import com.gg.server.domain.tournament.data.Tournament; import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.type.TournamentRound; import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import lombok.RequiredArgsConstructor; @Component @RequiredArgsConstructor -public class MatchTestUtils { +public class MatchIntegrationTestUtils { private final UserRepository userRepository; private final SeasonRepository seasonRepository; private final RankRedisRepository rankRedisRepository; @@ -45,31 +37,15 @@ public class MatchTestUtils { private final GameRepository gameRepository; public User createUser() { - String randomId = UUID.randomUUID().toString().substring(0, 30); - User user = User.builder() - .eMail("email") - .intraId(randomId) - .racketType(RacketType.PENHOLDER) - .snsNotiOpt(SnsType.NONE) - .roleType(RoleType.USER) - .totalExp(1000) - .build(); + User user = UserTestUtils.createUser(); userRepository.save(user); return user; } public User createGuestUser() { - String randomId = UUID.randomUUID().toString().substring(0, 30); - User user = User.builder() - .eMail("email") - .intraId(randomId) - .racketType(RacketType.PENHOLDER) - .snsNotiOpt(SnsType.NONE) - .roleType(RoleType.GUEST) - .totalExp(1000) - .build(); - userRepository.save(user); - return user; + User guest = UserTestUtils.createGuestUser(); + userRepository.save(guest); + return guest; } public RankRedis addUsertoRankRedis(Long userId, Integer ppp, Long seasonId) { @@ -132,24 +108,11 @@ public SlotManagement makeTestSlotManagement(Integer interval) { public List matchTournamentGames(Tournament tournament, TournamentRound round) { Season season = seasonRepository.findCurrentSeason(LocalDateTime.now()) .orElseThrow(() -> new IllegalArgumentException("현재 시즌이 존재하지 않습니다.")); - List sameRounds = TournamentRound.getSameRounds(round); - List sameRoundGames = tournament.getTournamentGames().stream() - .filter(o -> sameRounds.contains(o.getTournamentRound())) - .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) - .collect(Collectors.toList()); - List previousRoundTournamentGames = findSameRoundGames(tournament.getTournamentGames(), - TournamentRound.getPreviousRoundNumber(round)); - - for (int i = 0; i < round.getRoundNumber() / 2; ++i) { - Game game = new Game(season, StatusType.BEFORE, Mode.TOURNAMENT, LocalDateTime.now(), LocalDateTime.now()); - Team team1 = new Team(game, -1, false); - Team team2 = new Team(game, -1, false); - User user1 = findMatchUser(previousRoundTournamentGames, i * 2, tournament); - User user2 = findMatchUser(previousRoundTournamentGames, i * 2 + 1, tournament); - new TeamUser(team1, user1); - new TeamUser(team2, user2); + List sameRoundGames = TournamentGameTestUtils.matchTournamentGames(tournament, + round.getRoundNumber(), season); + for (TournamentGame tournamentGame : sameRoundGames) { + Game game = tournamentGame.getGame(); gameRepository.save(game); - sameRoundGames.get(i).updateGame(game); } return sameRoundGames; } @@ -187,29 +150,6 @@ public void updateTournamentGameResult(Game game, List scores) { game.updateStatus(); game.updateStatus(); game.updateStatus(); - } - public Team getWinningTeam(Game game) { - return game.getTeams().stream() - .filter(team -> Boolean.TRUE.equals(team.getWin())) - .findAny() - .orElseThrow(WinningTeamNotFoundException::new); - } - - private User findMatchUser(List previousTournamentGames, int index, Tournament tournament) { - if (previousTournamentGames.isEmpty()) { - return tournament.getTournamentUsers().get(index).getUser(); - } - Game game = previousTournamentGames.get(index).getGame(); - return getWinningTeam(game) - .getTeamUsers().get(0).getUser(); - } - - private List findSameRoundGames(List tournamentGames, int roundNum) { - return tournamentGames.stream() - .filter(tournamentGame -> roundNum == tournamentGame.getTournamentRound().getRoundNumber()) - .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) - .collect(Collectors.toList()); - } } diff --git a/src/test/java/com/gg/server/domain/match/utils/TournamentGameTestUtils.java b/src/test/java/com/gg/server/domain/match/utils/TournamentGameTestUtils.java new file mode 100644 index 000000000..b0982f2e8 --- /dev/null +++ b/src/test/java/com/gg/server/domain/match/utils/TournamentGameTestUtils.java @@ -0,0 +1,110 @@ +package com.gg.server.domain.match.utils; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.type.Mode; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.match.exception.WinningTeamNotFoundException; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.team.data.Team; +import com.gg.server.domain.team.data.TeamUser; +import com.gg.server.domain.tournament.data.Tournament; +import com.gg.server.domain.tournament.data.TournamentGame; +import com.gg.server.domain.tournament.type.RoundNumber; +import com.gg.server.domain.tournament.type.TournamentRound; +import com.gg.server.domain.user.data.User; + +public class TournamentGameTestUtils { + + /** + * 토너먼트에서 동일한 라운드의 경기들을 매칭 (생성) + * @param tournament 토너먼트 + * @param roundNumber 해당 라운드와 동일한 라운드의 모든 경기를 매칭 + * ex ) 8강의 경우 8강의 4경기를 매칭 + * @return 매칭된 토너먼트 게임 + */ + public static List matchTournamentGames(Tournament tournament, RoundNumber roundNumber, + Season season) { + List sameRounds = TournamentRound.getSameRounds(roundNumber); + List sameRoundGames = tournament.getTournamentGames().stream() + .filter(o -> sameRounds.contains(o.getTournamentRound())) + .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) + .collect(Collectors.toList()); + RoundNumber previousRoundNumber = TournamentRound.getPreviousRoundNumber(roundNumber); + List previousRoundTournamentGames = previousRoundNumber != null + ? findSameRoundGames(tournament.getTournamentGames(), previousRoundNumber) + : new ArrayList<>(); + + for (int i = 0; i < roundNumber.getRound() / 2; ++i) { + Game game = new Game(season, StatusType.BEFORE, Mode.TOURNAMENT, LocalDateTime.now(), LocalDateTime.now()); + Team team1 = new Team(game, -1, false); + Team team2 = new Team(game, -1, false); + User user1 = findMatchUser(previousRoundTournamentGames, i * 2, tournament); + User user2 = findMatchUser(previousRoundTournamentGames, i * 2 + 1, tournament); + new TeamUser(team1, user1); + new TeamUser(team2, user2); + sameRoundGames.get(i).updateGame(game); + } + return sameRoundGames; + } + + /** + * + * @param tournament 토너먼트 + * @param roundNumber 해당 라운드와 동일한 라운드를 찾는다. + * @return 해당 라운드의 모든 토너먼트 게임을 반환한다. + */ + public static List getTournamentGamesByRoundNum(Tournament tournament, RoundNumber roundNumber) { + return tournament.getTournamentGames().stream() + .filter(tournamentGame -> roundNumber == tournamentGame.getTournamentRound().getRoundNumber()) + .collect(Collectors.toList()); + } + + /** + * + * @param tournament 토너먼트 + * @param round 해당 라운드와 동일한 라운드를 찾는다. + * @return 해당 라운드의 토너먼트 게임을 반환한다. + */ + public static Optional getTournamentGameByRound(Tournament tournament, TournamentRound round) { + return tournament.getTournamentGames().stream() + .filter(tournamentGame -> round == tournamentGame.getTournamentRound()) + .findFirst(); + } + + public static Team getWinningTeam(Game game) { + return game.getTeams().stream() + .filter(team -> Boolean.TRUE.equals(team.getWin())) + .findAny() + .orElseThrow(WinningTeamNotFoundException::new); + } + + public static Team getLosingTeam(Game game) { + return game.getTeams().stream() + .filter(team -> Boolean.FALSE.equals(team.getWin())) + .findAny() + .orElseThrow(WinningTeamNotFoundException::new); + } + + private static User findMatchUser(List previousTournamentGames, int index, Tournament tournament) { + if (previousTournamentGames.isEmpty()) { + return tournament.getTournamentUsers().get(index).getUser(); + } + Game game = previousTournamentGames.get(index).getGame(); + return getWinningTeam(game) + .getTeamUsers().get(0).getUser(); + } + + private static List findSameRoundGames(List tournamentGames, RoundNumber roundNum) { + return tournamentGames.stream() + .filter(tournamentGame -> roundNum == tournamentGame.getTournamentRound().getRoundNumber()) + .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) + .collect(Collectors.toList()); + } +} diff --git a/src/test/java/com/gg/server/domain/match/utils/TournamentTestUtils.java b/src/test/java/com/gg/server/domain/match/utils/TournamentTestUtils.java new file mode 100644 index 000000000..e827cd235 --- /dev/null +++ b/src/test/java/com/gg/server/domain/match/utils/TournamentTestUtils.java @@ -0,0 +1,46 @@ +package com.gg.server.domain.match.utils; + +import java.time.LocalDateTime; + +import com.gg.server.domain.tournament.data.Tournament; +import com.gg.server.domain.tournament.data.TournamentGame; +import com.gg.server.domain.tournament.data.TournamentUser; +import com.gg.server.domain.tournament.type.TournamentRound; +import com.gg.server.domain.tournament.type.TournamentStatus; +import com.gg.server.domain.tournament.type.TournamentType; + +public class TournamentTestUtils { + /** + * 테스트용 Tournament 객체를 생성한다. user와 tournamentGame도 함께 생성한다. + * @param status 테스트용 Tournament 객체의 status + * @return 테스트용 Tournament 객체 + */ + public static Tournament createTournament(TournamentStatus status) { + LocalDateTime startTime = LocalDateTime.of(2024, 1, 1, 0, 0); + LocalDateTime endTime = startTime.plusHours(3); + Tournament tournament = Tournament.builder() + .title("title") + .contents("contents") + .startTime(startTime) + .endTime(endTime) + .type(TournamentType.ROOKIE) + .status(status) + .build(); + createJoinedTournamentUsers(tournament); + createTournamentGames(tournament); + return tournament; + } + + private static void createJoinedTournamentUsers(Tournament tournament) { + LocalDateTime registerTime = tournament.getStartTime(); + for (int i = 0; i < Tournament.ALLOWED_JOINED_NUMBER; ++i) { + new TournamentUser(UserTestUtils.createUser(), tournament, true, registerTime); + } + } + + private static void createTournamentGames(Tournament tournament) { + for (TournamentRound round : TournamentRound.values()) { + new TournamentGame(null, tournament, round); + } + } +} diff --git a/src/test/java/com/gg/server/domain/match/utils/UserTestUtils.java b/src/test/java/com/gg/server/domain/match/utils/UserTestUtils.java new file mode 100644 index 000000000..f9434cc45 --- /dev/null +++ b/src/test/java/com/gg/server/domain/match/utils/UserTestUtils.java @@ -0,0 +1,35 @@ +package com.gg.server.domain.match.utils; + +import java.util.UUID; + +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; + +public class UserTestUtils { + public static User createUser() { + String randomId = UUID.randomUUID().toString().substring(0, 30); + return User.builder() + .eMail("email") + .intraId(randomId) + .racketType(RacketType.PENHOLDER) + .snsNotiOpt(SnsType.NONE) + .roleType(RoleType.USER) + .totalExp(1000) + .build(); + } + + public static User createGuestUser() { + String randomId = UUID.randomUUID().toString().substring(0, 30); + return User.builder() + .eMail("email") + .intraId(randomId) + .racketType(RacketType.PENHOLDER) + .snsNotiOpt(SnsType.NONE) + .roleType(RoleType.GUEST) + .totalExp(1000) + .build(); + } + +} diff --git a/src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java b/src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java index 5491c02f4..389f6d1c8 100644 --- a/src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java +++ b/src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java @@ -88,7 +88,7 @@ void addExceedTournamentGameFailed() { //then BusinessException businessException = assertThrows(BusinessException.class, - () -> tournament.addTournamentGame(mockTournamentGames.get(7))); + () -> tournament.addTournamentGame(mockTournamentGames.get(8))); assertEquals(ErrorCode.TOURNAMENT_GAME_EXCEED, businessException.getErrorCode()); assertEquals(ErrorCode.TOURNAMENT_GAME_EXCEED.getMessage(), businessException.getMessage()); } From ef0a6b5a21e04ebca497cf6e4879506eec6b9e7a Mon Sep 17 00:00:00 2001 From: Newsujin <104690611+Newsujin@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:33:09 +0900 Subject: [PATCH 12/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20NotiAdminS?= =?UTF-8?q?ervice=20=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20(#5?= =?UTF-8?q?20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: sujin --- .../admin/noti/service/NotiAdminService.java | 16 +++ .../service/NotiAdminServiceUnitTest.java | 117 ++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 src/test/java/com/gg/server/admin/noti/service/NotiAdminServiceUnitTest.java diff --git a/src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java b/src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java index da056cc0d..bd42beac2 100644 --- a/src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java +++ b/src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java @@ -26,6 +26,11 @@ public class NotiAdminService { private final UserAdminRepository userAdminRepository; private final SnsNotiService snsNotiService; + /** + * 유저에게 알림을 전송합니다. + * @param sendNotiAdminRequestDto 알림 요청 Dto + * @exception UserNotFoundException 유저가 존재하지 않을 경우 + */ @Transactional public void sendAnnounceNotiToUser(SendNotiAdminRequestDto sendNotiAdminRequestDto) { String message = sendNotiAdminRequestDto.getMessage(); @@ -37,6 +42,11 @@ public void sendAnnounceNotiToUser(SendNotiAdminRequestDto sendNotiAdminRequestD snsNotiService.sendSnsNotification(noti, UserDto.from(user)); } + /** + * 전체 알림 목록을 조회합니다. + * @param pageable 알림 목록 페이지 + * @return 알림 목록 응답 Dto + */ @Transactional(readOnly = true) public NotiListAdminResponseDto getAllNoti(Pageable pageable) { Page allNotiPage = notiAdminRepository.findAll(pageable); @@ -44,6 +54,12 @@ public NotiListAdminResponseDto getAllNoti(Pageable pageable) { return new NotiListAdminResponseDto(notiAdminDtoPage.getContent(), notiAdminDtoPage.getTotalPages()); } + /** + * 특정 유저의 알림 목록을 조회합니다. + * @param pageable 유저의 알림 목록 페이지 + * @param intraId 인트라 Id + * @return 알림 목록 응답 Dto + */ @Transactional(readOnly = true) public NotiListAdminResponseDto getFilteredNotifications(Pageable pageable, String intraId) { Page findNotis = notiAdminRepository.findNotisByUserIntraId(pageable, intraId); diff --git a/src/test/java/com/gg/server/admin/noti/service/NotiAdminServiceUnitTest.java b/src/test/java/com/gg/server/admin/noti/service/NotiAdminServiceUnitTest.java new file mode 100644 index 000000000..48756c2b6 --- /dev/null +++ b/src/test/java/com/gg/server/admin/noti/service/NotiAdminServiceUnitTest.java @@ -0,0 +1,117 @@ +package com.gg.server.admin.noti.service; + +import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; + +import java.util.Collections; +import java.util.Optional; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; + +import com.gg.server.admin.noti.data.NotiAdminRepository; +import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; +import com.gg.server.admin.user.data.UserAdminRepository; +import com.gg.server.domain.noti.data.Noti; +import com.gg.server.domain.noti.service.SnsNotiService; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.exception.UserNotFoundException; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +@DisplayName("NotiAdminServiceUnitTest") +class NotiAdminServiceUnitTest { + @Mock + UserAdminRepository userAdminRepository; + @Mock + NotiAdminRepository notiAdminRepository; + @Mock + SnsNotiService snsNotiService; + @Mock + SendNotiAdminRequestDto sendNotiAdminRequestDto; + @InjectMocks + NotiAdminService notiAdminService; + + @Nested + @DisplayName("sendAnnounceNotiToUser_메서드_unitTest") + class SendAnnounceNotiToUserTest { + @Test + @DisplayName("성공") + void success() { + //given + given(userAdminRepository.findByIntraId(any(String.class))).willReturn(Optional.of(mock(User.class))); + given(notiAdminRepository.save(any(Noti.class))).willReturn(new Noti()); + willDoNothing().given(snsNotiService).sendSnsNotification(any(Noti.class), any(UserDto.class)); + + //when + notiAdminService.sendAnnounceNotiToUser(new SendNotiAdminRequestDto("TestUser", "Message")); + + //then + verify(userAdminRepository, times(1)).findByIntraId(any(String.class)); + verify(notiAdminRepository, times(1)).save(any(Noti.class)); + verify(snsNotiService, times(1)).sendSnsNotification(any(Noti.class), any(UserDto.class)); + } + + @Test + @DisplayName("user_not_found") + void userNotFound() { + //given + SendNotiAdminRequestDto requestDto = new SendNotiAdminRequestDto("testIntraId", "TestMessage"); + when(userAdminRepository.findByIntraId(any(String.class))).thenThrow(new UserNotFoundException()); + + //when, then + assertThatThrownBy(() -> notiAdminService.sendAnnounceNotiToUser(requestDto)) + .isInstanceOf(UserNotFoundException.class); + verify(notiAdminRepository, never()).save(any(Noti.class)); + verify(snsNotiService, never()).sendSnsNotification(any(Noti.class), any(UserDto.class)); + } + } + + @Nested + @DisplayName("getAllNoti_메서드_unitTest") + class GetAllNotiTest { + @Test + @DisplayName("성공") + void success() { + //given + given(notiAdminRepository.findAll(any(Pageable.class))).willReturn(new PageImpl<>(Collections.emptyList())); + + //when + notiAdminService.getAllNoti(mock(org.springframework.data.domain.Pageable.class)); + + //then + verify(notiAdminRepository, times(1)).findAll(any(Pageable.class)); + } + } + + @Nested + @DisplayName("getFilteredNotifications_메서드_unitTest") + class GetFilteredNotificationsTest { + @Test + @DisplayName("성공") + void success() { + //given + given(notiAdminRepository.findNotisByUserIntraId(any(org.springframework.data.domain.Pageable.class), + any(String.class))) + .willReturn(new PageImpl<>(Collections.emptyList())); + + //when + notiAdminService.getFilteredNotifications(PageRequest.of(1, 1), "TestUser"); + + //then + verify(notiAdminRepository, times(1)).findNotisByUserIntraId( + any(org.springframework.data.domain.Pageable.class), any(String.class)); + } + } +} From 97e75ac007b981ce4818ea560c2783033c340d90 Mon Sep 17 00:00:00 2001 From: SeungChul Chung Date: Mon, 5 Feb 2024 14:35:20 +0900 Subject: [PATCH 13/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20tournament?= =?UTF-8?q?Controller=20=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=20(#522)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TournamentController.java | 2 + .../TournamentControllerMvcTest.java | 218 ++++++++++++++++++ 2 files changed, 220 insertions(+) create mode 100644 src/test/java/com/gg/server/domain/tournament/controller/TournamentControllerMvcTest.java diff --git a/src/main/java/com/gg/server/domain/tournament/controller/TournamentController.java b/src/main/java/com/gg/server/domain/tournament/controller/TournamentController.java index 013e2bbd5..58acfe25b 100644 --- a/src/main/java/com/gg/server/domain/tournament/controller/TournamentController.java +++ b/src/main/java/com/gg/server/domain/tournament/controller/TournamentController.java @@ -8,6 +8,7 @@ import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; @@ -31,6 +32,7 @@ @RestController @RequiredArgsConstructor @RequestMapping("/pingpong/tournaments") +@Validated public class TournamentController { private final TournamentService tournamentService; diff --git a/src/test/java/com/gg/server/domain/tournament/controller/TournamentControllerMvcTest.java b/src/test/java/com/gg/server/domain/tournament/controller/TournamentControllerMvcTest.java new file mode 100644 index 000000000..5c25a0200 --- /dev/null +++ b/src/test/java/com/gg/server/domain/tournament/controller/TournamentControllerMvcTest.java @@ -0,0 +1,218 @@ +package com.gg.server.domain.tournament.controller; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Mockito.*; + +import javax.validation.ConstraintViolationException; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.test.web.servlet.MockMvc; + +import com.gg.server.domain.tournament.dto.TournamentFilterRequestDto; +import com.gg.server.domain.tournament.dto.TournamentGameListResponseDto; +import com.gg.server.domain.tournament.dto.TournamentListResponseDto; +import com.gg.server.domain.tournament.dto.TournamentResponseDto; +import com.gg.server.domain.tournament.dto.TournamentUserRegistrationResponseDto; +import com.gg.server.domain.tournament.service.TournamentService; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.config.WebConfig; +import com.gg.server.global.security.config.SecurityConfig; +import com.gg.server.global.security.jwt.utils.TokenAuthenticationFilter; +import com.gg.server.global.utils.querytracker.LoggingInterceptor; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@WebMvcTest(controllers = TournamentController.class, excludeFilters = { + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = SecurityConfig.class), + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = WebConfig.class), + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = TokenAuthenticationFilter.class), + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = LoggingInterceptor.class)}) +class TournamentControllerMvcTest { + + @Autowired + private MockMvc mockMvc; + + @MockBean + private TournamentService tournamentService; + + @Autowired + private TournamentController tournamentController; + + @Nested + @DisplayName("getAllTournamentList") + class GetAllTournamentList { + + @DisplayName("페이지번호가 1보다 작을 경우 에러 발생") + @ParameterizedTest() + @ValueSource(ints = {-1, 0}) + void pageMustGreaterThanZero(Integer page) { + //Arrange + TournamentFilterRequestDto dto = new TournamentFilterRequestDto(page, 1, null, null); + + //Act, Assert + assertThatThrownBy(() -> tournamentController.getAllTournamentList(dto)) + .isInstanceOf(ConstraintViolationException.class); + } + + @DisplayName("사이즈가 1과 30 사이가 아닐경우 에러 발생") + @ParameterizedTest() + @ValueSource(ints = {-1, 0, 31}) + void sizeError(Integer size) { + //Arrange + TournamentFilterRequestDto dto = new TournamentFilterRequestDto(1, size, null, null); + + //Act, Assert + assertThatThrownBy(() -> tournamentController.getAllTournamentList(dto)) + .isInstanceOf(ConstraintViolationException.class); + } + + @DisplayName("Success") + @Test + void success() { + //Arrange + TournamentFilterRequestDto dto = new TournamentFilterRequestDto(1, 1, null, null); + TournamentListResponseDto resultDto = Mockito.mock(TournamentListResponseDto.class); + when(tournamentService.getAllTournamentList(any(), any(), any())).thenReturn(resultDto); + + //Act + ResponseEntity response = tournamentController.getAllTournamentList(dto); + + //Assert + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + assertThat(response.getBody()).isEqualTo(resultDto); + } + } + + @Nested + @DisplayName("getUserStatusInTournament") + class GetUserStatusInTournament { + @DisplayName("Success") + @Test + void success() { + //Arrange + UserDto userDto = Mockito.mock(UserDto.class); + TournamentUserRegistrationResponseDto resultDto = Mockito.mock(TournamentUserRegistrationResponseDto.class); + when(tournamentService.getUserStatusInTournament(any(), any())).thenReturn(resultDto); + + //Act + ResponseEntity response = tournamentController + .getUserStatusInTournament(1L, userDto); + + //Assert + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + assertThat(response.getBody()).isEqualTo(resultDto); + } + } + + @Nested + @DisplayName("getTournnament") + class GetTournnament { + @DisplayName("id가 양수가 아닐경우 에러 발생") + @ParameterizedTest() + @ValueSource(longs = {-1, 0}) + void idGreaterThanZero(Long id) { + //Act, Assert + assertThatThrownBy(() -> tournamentController.getTournnament(id)) + .isInstanceOf(ConstraintViolationException.class); + } + + @DisplayName("Success") + @Test + void success() { + //Arrange + TournamentResponseDto resultDto = Mockito.mock(TournamentResponseDto.class); + when(tournamentService.getTournament(anyLong())).thenReturn(resultDto); + + //Act + ResponseEntity response = tournamentController.getTournnament(1L); + + //Assert + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + assertThat(response.getBody()).isEqualTo(resultDto); + } + } + + @Nested + @DisplayName("cancelTournamentUserRegistration") + class CancelTournamentUserRegistration { + + @DisplayName("Success") + @Test + void success() { + //Arrange + UserDto userDto = Mockito.mock(UserDto.class); + TournamentUserRegistrationResponseDto resultDto = Mockito.mock(TournamentUserRegistrationResponseDto.class); + when(tournamentService.cancelTournamentUserRegistration(anyLong(), any())).thenReturn(resultDto); + + //Act + ResponseEntity response; + response = tournamentController.cancelTournamentUserRegistration(1L, userDto); + + //Assert + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + assertThat(response.getBody()).isEqualTo(resultDto); + } + } + + @Nested + @DisplayName("getTournamentGames") + class GetTournamentGames { + @DisplayName("id가 양수가 아닐경우 에러 발생") + @ParameterizedTest() + @ValueSource(longs = {-1, 0}) + void idGreaterThanZero(Long id) { + //Act, Assert + assertThatThrownBy(() -> tournamentController.getTournamentGames(id)) + .isInstanceOf(ConstraintViolationException.class); + } + + @DisplayName("Success") + @Test + void success() { + //Arrange + TournamentGameListResponseDto resultDto = Mockito.mock(TournamentGameListResponseDto.class); + when(tournamentService.getTournamentGames(anyLong())).thenReturn(resultDto); + + //Act + ResponseEntity response = tournamentController.getTournamentGames(1L); + + //Assert + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + assertThat(response.getBody()).isEqualTo(resultDto); + } + } + + @Nested + @DisplayName("registerTournamentUser") + class RegisterTournamentUser { + + @DisplayName("Success") + @Test + void success() { + //Arrange + UserDto userDto = Mockito.mock(UserDto.class); + TournamentUserRegistrationResponseDto resultDto = Mockito.mock(TournamentUserRegistrationResponseDto.class); + when(tournamentService.registerTournamentUser(anyLong(), any())).thenReturn(resultDto); + + //Act + ResponseEntity response; + response = tournamentController.registerTournamentUser(1L, userDto); + + //Assert + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.CREATED); + assertThat(response.getBody()).isEqualTo(resultDto); + } + } +} From 16f15d169a966e94b1eea5eb6b3e7375c1357de8 Mon Sep 17 00:00:00 2001 From: SeungChul Chung Date: Mon, 5 Feb 2024 14:35:58 +0900 Subject: [PATCH 14/32] =?UTF-8?q?=F0=9F=A7=AA=20[Test]=20tournamentservice?= =?UTF-8?q?=20=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20(#508)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/tournament/data/Tournament.java | 7 + .../dto/TournamentListResponseDto.java | 7 + .../tournament/dto/TournamentResponseDto.java | 19 +- .../tournament/service/TournamentService.java | 111 +--- .../tournament/data/TournamentUnitTest.java | 73 ++- .../service/TournamentServiceTest.java | 292 --------- .../service/TournamentServiceUnitTest.java | 618 ++++++++++++++++++ .../com/gg/server/utils/TestDataUtils.java | 19 +- 8 files changed, 767 insertions(+), 379 deletions(-) delete mode 100644 src/test/java/com/gg/server/domain/tournament/service/TournamentServiceTest.java create mode 100644 src/test/java/com/gg/server/domain/tournament/service/TournamentServiceUnitTest.java diff --git a/src/main/java/com/gg/server/domain/tournament/data/Tournament.java b/src/main/java/com/gg/server/domain/tournament/data/Tournament.java index eb554d47a..811d51434 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/Tournament.java +++ b/src/main/java/com/gg/server/domain/tournament/data/Tournament.java @@ -6,6 +6,7 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -149,4 +150,10 @@ public void updateEndTime(LocalDateTime endTime) { mustNotNull(endTime, NULL_POINT); this.endTime = endTime; } + + public Optional findTournamentUserByUserId(Long userId) { + return tournamentUsers.stream() + .filter(tournamentUser -> tournamentUser.getUser().getId().equals(userId)) + .findFirst(); + } } diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentListResponseDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentListResponseDto.java index 9185defe0..a6e3c66a8 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentListResponseDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentListResponseDto.java @@ -2,6 +2,8 @@ import java.util.List; +import org.springframework.data.domain.Page; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -13,4 +15,9 @@ public class TournamentListResponseDto { private List tournaments; private int totalPage; + + public TournamentListResponseDto(Page tournamentsDto) { + tournaments = tournamentsDto.getContent(); + totalPage = tournamentsDto.getTotalPages(); + } } diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java index ae1360059..d64abdbed 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java @@ -3,6 +3,7 @@ import java.time.LocalDateTime; import com.gg.server.domain.tournament.data.Tournament; +import com.gg.server.domain.tournament.data.TournamentUser; import com.gg.server.domain.tournament.type.TournamentStatus; import com.gg.server.domain.tournament.type.TournamentType; import com.gg.server.domain.user.dto.UserImageDto; @@ -25,7 +26,7 @@ public class TournamentResponseDto { private TournamentStatus status; private String winnerIntraId; private String winnerImageUrl; - private int playerCnt; + private long playerCnt; public TournamentResponseDto(Tournament tournament, UserImageDto winner, int playerCnt) { this.tournamentId = tournament.getId(); @@ -40,6 +41,22 @@ public TournamentResponseDto(Tournament tournament, UserImageDto winner, int pla this.playerCnt = playerCnt; } + public TournamentResponseDto(Tournament tournament) { + this.tournamentId = tournament.getId(); + this.title = tournament.getTitle(); + this.contents = tournament.getContents(); + this.startTime = tournament.getStartTime(); + this.endTime = tournament.getEndTime(); + this.type = tournament.getType(); + this.status = tournament.getStatus(); + this.playerCnt = tournament.getTournamentUsers().stream() + .filter(TournamentUser::getIsJoined).count(); + if (tournament.getWinner() != null) { + this.winnerIntraId = tournament.getWinner().getIntraId(); + this.winnerImageUrl = tournament.getWinner().getImageUri(); + } + } + public void update_player_cnt(int playerCnt) { this.playerCnt = playerCnt; } diff --git a/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java b/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java index 082f935f5..87033c7aa 100644 --- a/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java +++ b/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java @@ -1,12 +1,14 @@ package com.gg.server.domain.tournament.service; import static com.gg.server.domain.tournament.type.RoundNumber.*; +import static java.util.Comparator.*; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -40,7 +42,6 @@ import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.dto.UserImageDto; import com.gg.server.domain.user.exception.UserNotFoundException; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.BusinessException; @@ -67,22 +68,18 @@ public class TournamentService { */ public TournamentListResponseDto getAllTournamentList(Pageable pageRequest, TournamentType type, TournamentStatus status) { - - Page tournaments; + Page tournaments; if (type == null && status == null) { - tournaments = tournamentRepository.findAll(pageRequest) - .map(o -> new TournamentResponseDto(o, findTournamentWinner(o), findJoinedPlayerCnt(o))); + tournaments = tournamentRepository.findAll(pageRequest); } else if (type == null) { - tournaments = tournamentRepository.findAllByStatus(status, pageRequest) - .map(o -> new TournamentResponseDto(o, findTournamentWinner(o), findJoinedPlayerCnt(o))); + tournaments = tournamentRepository.findAllByStatus(status, pageRequest); } else if (status == null) { - tournaments = tournamentRepository.findAllByType(type, pageRequest) - .map(o -> new TournamentResponseDto(o, findTournamentWinner(o), findJoinedPlayerCnt(o))); + tournaments = tournamentRepository.findAllByType(type, pageRequest); } else { - tournaments = tournamentRepository.findAllByTypeAndStatus(type, status, pageRequest) - .map(o -> new TournamentResponseDto(o, findTournamentWinner(o), findJoinedPlayerCnt(o))); + tournaments = tournamentRepository.findAllByTypeAndStatus(type, status, pageRequest); } - return new TournamentListResponseDto(tournaments.getContent(), tournaments.getTotalPages()); + Page tournamentsDto = tournaments.map(TournamentResponseDto::new); + return new TournamentListResponseDto(tournamentsDto); } /** @@ -93,8 +90,7 @@ public TournamentListResponseDto getAllTournamentList(Pageable pageRequest, Tour public TournamentResponseDto getTournament(long tournamentId) { Tournament tournament = tournamentRepository.findById(tournamentId) .orElseThrow(TournamentNotFoundException::new); - return (new TournamentResponseDto(tournament, findTournamentWinner(tournament), - findJoinedPlayerCnt(tournament))); + return (new TournamentResponseDto(tournament)); } /** @@ -109,8 +105,8 @@ public TournamentUserRegistrationResponseDto getUserStatusInTournament(Long tour .orElseThrow(TournamentNotFoundException::new); TournamentUserStatus tournamentUserStatus = TournamentUserStatus.BEFORE; - Optional tournamentUser = tournamentUserRepository.findByTournamentIdAndUserId(tournamentId, - user.getId()); + Optional tournamentUser = targetTournament.findTournamentUserByUserId(user.getId()); + if (tournamentUser.isPresent()) { tournamentUserStatus = tournamentUser.get().getIsJoined() ? TournamentUserStatus.PLAYER : TournamentUserStatus.WAIT; @@ -182,22 +178,6 @@ public TournamentUserRegistrationResponseDto cancelTournamentUserRegistration(Lo return new TournamentUserRegistrationResponseDto(TournamentUserStatus.BEFORE); } - /** - * 진행중인 토너먼트 유무 확인 - * @param time 현재 시간 - * @return 종료되지 않은 토너먼트 있으면 true, 없으면 false - */ - public boolean isNotEndedTournament(LocalDateTime time) { - List tournamentList = tournamentRepository.findAllByStatusIsNot(TournamentStatus.END); - for (Tournament tournament : tournamentList) { - if (time.isAfter(tournament.getStartTime()) - && time.isBefore(tournament.getEndTime())) { - return false; - } - } - return true; - } - /** * 오늘 시작하는 토너먼트가 있으면 해당 토너먼트 status를 LIVE로 변경하고 8강 경기 매칭 * 참가자가 ALLOWED_JOINED_NUMBER보다 적으면 토너먼트 취소 @@ -206,18 +186,13 @@ public boolean isNotEndedTournament(LocalDateTime time) { public void startTournament() { LocalDate date = LocalDate.now(); List imminentTournaments = findImminentTournament(date); + for (Tournament imminentTournament : imminentTournaments) { List tournamentUsers = imminentTournament.getTournamentUsers(); if (tournamentUsers.size() < Tournament.ALLOWED_JOINED_NUMBER) { - for (TournamentUser tournamentUser : tournamentUsers) { - if (tournamentUser.getIsJoined().equals(true)) { - notiAdminService.sendAnnounceNotiToUser( - new SendNotiAdminRequestDto(tournamentUser.getUser().getIntraId(), - NotiType.TOURNAMENT_CANCELED.getMessage())); - } - } + sendNotification(tournamentUsers, NotiType.TOURNAMENT_CANCELED); tournamentRepository.delete(imminentTournament); - return; + continue; } imminentTournament.updateStatus(TournamentStatus.LIVE); matchTournamentService.matchGames(imminentTournament, QUARTER_FINAL); @@ -225,40 +200,30 @@ public void startTournament() { } /** - * 시작 임박한(오늘 시작하는) 토너먼트 조회 - * @param date 조회하려는 토너먼트의 시작 날짜 - * @return date 날짜에 시작하는 토너먼트 + * 토너먼트 참가중인 유저에게 알림 전송. */ - private List findImminentTournament(LocalDate date) { - List tournaments = tournamentRepository.findAllByStatus(TournamentStatus.BEFORE); - List imminentTournaments = new ArrayList<>(); + private void sendNotification(List tournamentUsers, NotiType type) { + for (TournamentUser tournamentUser : tournamentUsers) { + String message = type.getMessage(); - for (Tournament tournament : tournaments) { - LocalDate startDate = tournament.getStartTime().toLocalDate(); - if (startDate.isEqual(date)) { - imminentTournaments.add(tournament); + if (tournamentUser.getIsJoined().equals(true)) { + String intraId = tournamentUser.getUser().getIntraId(); + SendNotiAdminRequestDto dto = new SendNotiAdminRequestDto(intraId, message); + notiAdminService.sendAnnounceNotiToUser(dto); } } - return imminentTournaments; } /** - * 토너먼트 우승자 조회 - * @param tournament 토너먼트 - * @return 토너먼트 우승자 정보 - */ - private UserImageDto findTournamentWinner(Tournament tournament) { - User winner = tournament.getWinner(); - return new UserImageDto(winner); - } - - /** - * 토너먼트 참가자 수 조회 - * @param tournament 토너먼트 - * @return 토너먼트 참가자 수 + * 시작 임박한(오늘 시작하는) 토너먼트 조회 + * @param date 조회하려는 토너먼트의 시작 날짜 + * @return date 날짜에 시작하는 토너먼트 */ - private int findJoinedPlayerCnt(Tournament tournament) { - return tournamentUserRepository.countByTournamentAndIsJoined(tournament, true); + private List findImminentTournament(LocalDate date) { + List tournaments = tournamentRepository.findAllByStatus(TournamentStatus.BEFORE); + return tournaments.stream() + .filter(tournament -> tournament.getStartTime().toLocalDate().isEqual(date)) + .collect(Collectors.toList()); } /** @@ -294,17 +259,9 @@ private List getTournamentGameResDtoList(Long tournamentId new TournamentGameResDto(tournamentGame, gameTeamUser, tournamentGame.getTournamentRound(), nextTournamentGame)); } - tournamentGameResDtoList.sort((o1, o2) -> { - if (o1.getTournamentRound().getRoundNumber().getRound() < o2.getTournamentRound() - .getRoundNumber() - .getRound()) { - return 1; - } - if (o1.getTournamentRound().getRoundOrder() > o2.getTournamentRound().getRoundOrder()) { - return 1; - } - return -1; - }); + tournamentGameResDtoList.sort(comparing(TournamentGameResDto::getTournamentRound, + comparing(TournamentRound::getRoundNumber).reversed().thenComparing(TournamentRound::getRoundOrder))); + return tournamentGameResDtoList; } diff --git a/src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java b/src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java index 389f6d1c8..57a2495ac 100644 --- a/src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java +++ b/src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java @@ -6,9 +6,11 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.IntStream; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -88,7 +90,7 @@ void addExceedTournamentGameFailed() { //then BusinessException businessException = assertThrows(BusinessException.class, - () -> tournament.addTournamentGame(mockTournamentGames.get(8))); + () -> tournament.addTournamentGame(mockTournamentGames.get(7))); assertEquals(ErrorCode.TOURNAMENT_GAME_EXCEED, businessException.getErrorCode()); assertEquals(ErrorCode.TOURNAMENT_GAME_EXCEED.getMessage(), businessException.getMessage()); } @@ -350,4 +352,73 @@ void updateEndTimeSuccess() { assertEquals(endTime, tournament.getEndTime()); } } + + @Nested + @DisplayName("findTournamentUserByUserId") + class FindTournamentUserByUserId { + @Test + @DisplayName("Long null 전달 시 토너먼트 유저 없으면 exception") + void ifNullException() { + //given + Tournament tournament = tournaments.get(0); + TournamentUser tournamentUser = mockTournamentUsers.get(0); + tournament.getTournamentUsers().add(tournamentUser); + Long userId = null; + + //when, then + assertThrows(NullPointerException.class, () -> tournament.findTournamentUserByUserId(userId)); + } + + @Test + @DisplayName("Long null 전달 시 토너먼트 유저 있으면 Optional.null") + void ifNullOptionalNull() { + //given + Tournament tournament = tournaments.get(0); + Long userId = null; + + //when + Optional result = tournament.findTournamentUserByUserId(userId); + + //then + Assertions.assertThat(result).isEqualTo(Optional.empty()); + } + + @Test + @DisplayName("존재하는 토너먼트 유저면 반환") + void userFind() { + //given + Tournament tournament = tournaments.get(0); + TournamentUser tournamentUser = mockTournamentUsers.get(0); + tournament.getTournamentUsers().add(tournamentUser); + User user = mock(User.class); + when(user.getId()).thenReturn(1L); + when(tournamentUser.getUser()).thenReturn(user); + Long userId = 1L; + + //when + Optional result = tournament.findTournamentUserByUserId(userId); + + //then + Assertions.assertThat(result.get()).isEqualTo(tournamentUser); + } + + @Test + @DisplayName("존재하지 않는 토너먼트 유저면 optional.empty 반환") + void userNotFind() { + //given + Tournament tournament = tournaments.get(0); + TournamentUser tournamentUser = mockTournamentUsers.get(0); + User user = mock(User.class); + when(user.getId()).thenReturn(1L); + when(tournamentUser.getUser()).thenReturn(user); + tournament.getTournamentUsers().add(tournamentUser); + Long userId = 2L; + + //when + Optional result = tournament.findTournamentUserByUserId(userId); + + //then + Assertions.assertThat(result).isEqualTo(Optional.empty()); + } + } } diff --git a/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceTest.java b/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceTest.java deleted file mode 100644 index 3c33a25be..000000000 --- a/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceTest.java +++ /dev/null @@ -1,292 +0,0 @@ -package com.gg.server.domain.tournament.service; - -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.*; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; -import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; -import com.gg.server.domain.tournament.data.TournamentGameRepository; -import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.data.TournamentUser; -import com.gg.server.domain.tournament.data.TournamentUserRepository; -import com.gg.server.domain.tournament.dto.TournamentUserRegistrationResponseDto; -import com.gg.server.domain.tournament.exception.TournamentConflictException; -import com.gg.server.domain.tournament.exception.TournamentNotFoundException; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; -import com.gg.server.utils.ReflectionUtilsForUnitTest; -import com.gg.server.utils.annotation.UnitTest; - -@UnitTest -@ExtendWith(MockitoExtension.class) -class TournamentServiceTest { - @Mock - TournamentRepository tournamentRepository; - @Mock - TournamentGameRepository tournamentGameRepository; - @Mock - TournamentUserRepository tournamentUserRepository; - @Mock - UserRepository userRepository; - @InjectMocks - TournamentService tournamentService; - - @Nested - @DisplayName("토너먼트_유저_상태_테스트") - class UserStatusInTournamentTest { - @Test - @DisplayName("유저_상태_반환_성공") - void success() { - // given - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - LocalDateTime.now(), LocalDateTime.now().plusHours(2)); - User user = createUser("testUser"); - TournamentUser tournamentUser = new TournamentUser(user, tournament, true, LocalDateTime.now()); - given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); - given(tournamentUserRepository.findByTournamentIdAndUserId(tournament.getId(), user.getId())) - .willReturn(Optional.of(tournamentUser)); - - // when, then - TournamentUserRegistrationResponseDto responseDto = - tournamentService.getUserStatusInTournament(tournament.getId(), UserDto.from(user)); - } - - @Test - @DisplayName("찾을_수_없는_토너먼트") - void tournamentNotFound() { - // given - Long tournamentId = 1L; - User user = createUser("testUser"); - given(tournamentRepository.findById(tournamentId)).willReturn(Optional.empty()); - - // when, then - assertThatThrownBy(() -> tournamentService.getUserStatusInTournament(tournamentId, UserDto.from(user))) - .isInstanceOf(TournamentNotFoundException.class); - } - } - - @Nested - @DisplayName("토너먼트_유저_신청_테스트") - class RegisterTournamentUserTest { - @Test - @DisplayName("유저_상태_추가_성공") - void success() { - // given - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - LocalDateTime.now(), LocalDateTime.now().plusHours(2)); - User user = createUser("testUser"); - List tournamentUserList = new ArrayList<>(); - given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); - given(userRepository.findById(user.getId())).willReturn(Optional.of(user)); - given(tournamentUserRepository.findAllByUser(any(User.class))).willReturn(tournamentUserList); - - // when, then - TournamentUserRegistrationResponseDto responseDto = - tournamentService.registerTournamentUser(tournament.getId(), UserDto.from(user)); - } - - @Test - @DisplayName("찾을_수_없는_토너먼트") - void tournamentNotFound() { - // given - User user = createUser("testUser"); - given(tournamentRepository.findById(any(Long.class))).willReturn(Optional.empty()); - - // when, then - assertThatThrownBy(() -> tournamentService.registerTournamentUser(1L, UserDto.from(user))) - .isInstanceOf(TournamentNotFoundException.class); - } - - @Test - @DisplayName("db에_없는_유저") - void userNotFound() { - // given - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - LocalDateTime.now(), LocalDateTime.now().plusHours(2)); - User user = createUser("testUser"); - given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); - given(userRepository.findById(null)).willReturn(Optional.empty()); - - // when, then - assertThatThrownBy(() -> tournamentService.registerTournamentUser(tournament.getId(), UserDto.from(user))) - .isInstanceOf(UserNotFoundException.class); - } - - @Test - @DisplayName("이미_신청한_토너먼트_존재") - void conflictedRegistration() { - // given - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - LocalDateTime.now(), LocalDateTime.now().plusHours(2)); - User user = createUser("testUser"); - List tournamentUserList = new ArrayList<>(); - tournamentUserList.add(new TournamentUser(user, tournament, true, LocalDateTime.now())); - given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); - given(userRepository.findById(user.getId())).willReturn(Optional.of(user)); - given(tournamentUserRepository.findAllByUser(any(User.class))).willReturn(tournamentUserList); - - // when, then - assertThatThrownBy(() -> tournamentService.registerTournamentUser(tournament.getId(), UserDto.from(user))) - .isInstanceOf(TournamentConflictException.class); - } - } - - @Nested - @DisplayName("토너먼트_유저_참가_취소_테스트") - class CancelTournamentUserRegistration { - @Test - @DisplayName("유저_참가_취소_성공") - void success() { - // given - Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, - LocalDateTime.now(), LocalDateTime.now().plusHours(2)); - User user = createUser("testUser"); - ReflectionUtilsForUnitTest.setFieldWithReflection(user, "id", 1L); - TournamentUser tournamentUser = new TournamentUser(user, tournament, true, LocalDateTime.now()); - given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); - - // when, then - tournamentService.cancelTournamentUserRegistration(tournament.getId(), UserDto.from(user)); - } - - @Test - @DisplayName("찾을_수_없는_토너먼트") - void tournamentNotFound() { - // given - Long tournamentId = 1L; - User user = createUser("testUser"); - given(tournamentRepository.findById(tournamentId)).willReturn(Optional.empty()); - - // when, then - assertThatThrownBy( - () -> tournamentService.cancelTournamentUserRegistration(tournamentId, UserDto.from(user))) - .isInstanceOf(TournamentNotFoundException.class); - } - } - - /** - * 토너먼트 생성 requestDto - * @param startTime 토너먼트 시작 시간 - * @param endTime 토너먼트 종료 시간 - * @return - */ - private TournamentAdminCreateRequestDto createTournamentCreateRequestDto(String title, LocalDateTime startTime, - LocalDateTime endTime) { - return new TournamentAdminCreateRequestDto( - title, - "제 1회 루키전 많관부!!", - startTime, - endTime, - TournamentType.ROOKIE - ); - } - - /** - * 토너먼트 게임 테이블 생성 - * @param tournament 토너먼트 - * @param round 몇 번째 게임인지에 대한 정보 - * @return 새로 생성된 토너먼트 게임 - */ - private TournamentGame createTournamentGame(Tournament tournament, TournamentRound round) { - TournamentGame tournamentGame = new TournamentGame(null, tournament, round); - return tournamentGameRepository.save(tournamentGame); - } - - /** - * 현재 시간에서 days hours, 만큼 차이나는 시간을 구한다. - * @param days - * @param hours - * @return - */ - private LocalDateTime getTargetTime(long days, long hours) { - return LocalDateTime.now().plusDays(days).plusHours(hours); - } - - private Tournament createTournament(Long id, TournamentStatus status, LocalDateTime startTime, - LocalDateTime endTime) { - Tournament tournament = Tournament.builder() - .title(id + "st tournament") - .contents("") - .startTime(startTime) - .endTime(endTime) - .type(TournamentType.ROOKIE) - .status(status) - .build(); - ReflectionUtilsForUnitTest.setFieldWithReflection(tournament, "id", id); - return tournament; - } - - /** - *
id 부터 cnt개 만큼의 토너먼트 리스트를 반환해준다.
- * 각 토너먼트는 1시간 길이이며, 토너먼트간 1시간의 간격이 있다. - * @param id - * @param cnt - * @param startTime - * @return - */ - private List createTournaments(Long id, long cnt, LocalDateTime startTime) { - List tournamentList = new ArrayList<>(); - for (long i = 0; i < cnt; i++) { - tournamentList.add(createTournament(id++, TournamentStatus.BEFORE, - startTime.plusHours(i * 2), startTime.plusHours((i * 2 + 2)))); - } - return tournamentList; - } - - /** - * 각 매개변수로 초기화된 TournamentAdminUpdateRequestDto를 반환 - * @param startTime - * @param endTime - * @return - */ - private TournamentAdminUpdateRequestDto createTournamentAdminUpdateRequestDto(LocalDateTime startTime, - LocalDateTime endTime) { - return new TournamentAdminUpdateRequestDto( - "tournament changed", - "changed", - startTime, - endTime, - TournamentType.ROOKIE - ); - } - - /** - * 유저 생성 매서드 - intraId로만 초기화 - * @param intraId - * @return - */ - private User createUser(String intraId) { - return User.builder() - .eMail("email") - .intraId(intraId) - .racketType(RacketType.PENHOLDER) - .snsNotiOpt(SnsType.NONE) - .roleType(RoleType.USER) - .totalExp(1000) - .build(); - } -} diff --git a/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceUnitTest.java b/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceUnitTest.java new file mode 100644 index 000000000..0d19084af --- /dev/null +++ b/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceUnitTest.java @@ -0,0 +1,618 @@ +package com.gg.server.domain.tournament.service; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.IntStream; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; + +import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; +import com.gg.server.admin.noti.service.NotiAdminService; +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.game.data.GameRepository; +import com.gg.server.domain.game.dto.GameTeamUser; +import com.gg.server.domain.game.type.StatusType; +import com.gg.server.domain.match.service.MatchTournamentService; +import com.gg.server.domain.tournament.data.Tournament; +import com.gg.server.domain.tournament.data.TournamentGame; +import com.gg.server.domain.tournament.data.TournamentGameRepository; +import com.gg.server.domain.tournament.data.TournamentRepository; +import com.gg.server.domain.tournament.data.TournamentUser; +import com.gg.server.domain.tournament.data.TournamentUserRepository; +import com.gg.server.domain.tournament.dto.TournamentGameListResponseDto; +import com.gg.server.domain.tournament.dto.TournamentResponseDto; +import com.gg.server.domain.tournament.dto.TournamentUserRegistrationResponseDto; +import com.gg.server.domain.tournament.exception.TournamentConflictException; +import com.gg.server.domain.tournament.exception.TournamentNotFoundException; +import com.gg.server.domain.tournament.type.TournamentRound; +import com.gg.server.domain.tournament.type.TournamentStatus; +import com.gg.server.domain.tournament.type.TournamentType; +import com.gg.server.domain.tournament.type.TournamentUserStatus; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.exception.UserNotFoundException; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.utils.ReflectionUtilsForUnitTest; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class TournamentServiceUnitTest { + @Mock + TournamentRepository tournamentRepository; + @Mock + TournamentGameRepository tournamentGameRepository; + @Mock + TournamentUserRepository tournamentUserRepository; + @Mock + UserRepository userRepository; + @Mock + MatchTournamentService matchTournamentService; + @Mock + NotiAdminService notiAdminService; + @Mock + GameRepository gameRepository; + @InjectMocks + TournamentService tournamentService; + + @Nested + @DisplayName("getAllTournamentList") + class GetAllTournamentList { + Pageable pageRequest; + Page page; + Page responseDto; + + @BeforeEach + void init() { + pageRequest = PageRequest.of(1, 10); + page = mock(Page.class); + responseDto = mock(Page.class); + + when(page.map(any(Function.class))).thenReturn(responseDto); + when(responseDto.getContent()).thenReturn(mock(List.class)); + when(responseDto.getTotalPages()).thenReturn(10); + } + + @Test + @DisplayName("type == null && status == null") + void typeAndStatusNull() { + //Arrange + TournamentType type = null; + TournamentStatus status = null; + when(tournamentRepository.findAll(pageRequest)).thenReturn(page); + + //Act + tournamentService.getAllTournamentList(pageRequest, type, status); + + //Assert + verify(tournamentRepository, times(1)).findAll(pageRequest); + } + + @Test + @DisplayName("type == null") + void typeNull() { + //Arrange + TournamentType type = null; + TournamentStatus status = TournamentStatus.LIVE; + when(tournamentRepository.findAllByStatus(status, pageRequest)).thenReturn(page); + + //Act + tournamentService.getAllTournamentList(pageRequest, type, status); + + //Assert + verify(tournamentRepository, times(1)) + .findAllByStatus(status, pageRequest); + } + + @Test + @DisplayName("status == null") + void statusNull() { + //Arrange + TournamentType type = TournamentType.ROOKIE; + TournamentStatus status = null; + when(tournamentRepository.findAllByType(type, pageRequest)).thenReturn(page); + + //Act + tournamentService.getAllTournamentList(pageRequest, type, status); + + //Assert + verify(tournamentRepository, times(1)) + .findAllByType(type, pageRequest); + } + + @Test + @DisplayName("statusAndTypeNotNull") + void statusAndTypeNotNull() { + //Arrange + TournamentType type = TournamentType.ROOKIE; + TournamentStatus status = TournamentStatus.LIVE; + when(tournamentRepository + .findAllByTypeAndStatus(type, status, pageRequest)) + .thenReturn(page); + + //Act + tournamentService.getAllTournamentList(pageRequest, type, status); + + //Assert + verify(tournamentRepository, times(1)) + .findAllByTypeAndStatus(type, status, pageRequest); + } + + } + + @Nested + @DisplayName("getTournament") + class GetTournament { + @Test + @DisplayName("success") + void success() { + //Arrange + Long id = 1L; + Tournament tournament = mock(Tournament.class); + when(tournamentRepository.findById(id)).thenReturn(Optional.of(tournament)); + + //Act + TournamentResponseDto dto = tournamentService.getTournament(id); + + //Assert + verify(tournamentRepository, times(1)).findById(id); + Assertions.assertThat(dto).isNotNull(); + } + + @Test + @DisplayName("TournamentNotFound") + void tournamentNotFound() { + //Arrange + Long id = 1L; + when(tournamentRepository.findById(id)).thenReturn(Optional.empty()); + + //Act, Assert + assertThatThrownBy(() -> tournamentService.getTournament(id)) + .isInstanceOf(TournamentNotFoundException.class); + } + } + + @Nested + @DisplayName("getUserStatusInTournament") + class GetUserStatusInTournament { + Tournament tournament; + TournamentUser tournamentUser; + UserDto requestDto; + + @BeforeEach + void init() { + tournament = mock(Tournament.class); + tournamentUser = mock(TournamentUser.class); + requestDto = mock(UserDto.class); + } + + @Test + @DisplayName("찾을_수_없는_토너먼트") + void tournamentNotFound() { + // given + Long tournamentId = 1L; + given(tournamentRepository.findById(tournamentId)).willReturn(Optional.empty()); + + // when, then + assertThatThrownBy(() -> tournamentService + .getUserStatusInTournament(tournamentId, requestDto)) + .isInstanceOf(TournamentNotFoundException.class); + } + + @Test + @DisplayName("토너먼트 참가중인 유저") + void player() { + // given + given(tournamentRepository.findById(tournament.getId())) + .willReturn(Optional.of(tournament)); + + given(tournament.findTournamentUserByUserId(requestDto.getId())) + .willReturn(Optional.of(tournamentUser)); + + given(tournamentUser.getIsJoined()) + .willReturn(true); + + // when + TournamentUserRegistrationResponseDto responseDto = + tournamentService.getUserStatusInTournament(tournament.getId(), requestDto); + + // then + Assertions.assertThat(responseDto.getStatus()).isEqualTo(TournamentUserStatus.PLAYER); + } + + @Test + @DisplayName("토너먼트 대기중인 유저") + void waitPlayer() { + // given + given(tournamentRepository.findById(tournament.getId())) + .willReturn(Optional.of(tournament)); + + given(tournament.findTournamentUserByUserId(requestDto.getId())) + .willReturn(Optional.of(tournamentUser)); + + given(tournamentUser.getIsJoined()) + .willReturn(false); + + // when + TournamentUserRegistrationResponseDto responseDto = + tournamentService.getUserStatusInTournament(tournament.getId(), requestDto); + + // then + Assertions.assertThat(responseDto.getStatus()).isEqualTo(TournamentUserStatus.WAIT); + } + + @Test + @DisplayName("토너먼트 신청하지 않은 유저") + void beforePlayer() { + // given + given(tournamentRepository.findById(tournament.getId())) + .willReturn(Optional.of(tournament)); + + given(tournament.findTournamentUserByUserId(requestDto.getId())) + .willReturn(Optional.empty()); + + // when + TournamentUserRegistrationResponseDto responseDto = + tournamentService.getUserStatusInTournament(tournament.getId(), requestDto); + + // then + Assertions.assertThat(responseDto.getStatus()).isEqualTo(TournamentUserStatus.BEFORE); + } + } + + @Nested + @DisplayName("토너먼트_유저_신청_테스트") + class RegisterTournamentUserTest { + @Test + @DisplayName("유저_상태_추가_성공") + void success() { + // given + Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, + LocalDateTime.now(), LocalDateTime.now().plusHours(2)); + User user = createUser("testUser"); + List tournamentUserList = new ArrayList<>(); + given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); + given(userRepository.findById(user.getId())).willReturn(Optional.of(user)); + given(tournamentUserRepository.findAllByUser(any(User.class))).willReturn(tournamentUserList); + + // when, then + TournamentUserRegistrationResponseDto responseDto = + tournamentService.registerTournamentUser(tournament.getId(), UserDto.from(user)); + } + + @Test + @DisplayName("찾을_수_없는_토너먼트") + void tournamentNotFound() { + // given + User user = createUser("testUser"); + given(tournamentRepository.findById(any(Long.class))).willReturn(Optional.empty()); + + // when, then + assertThatThrownBy(() -> tournamentService.registerTournamentUser(1L, UserDto.from(user))) + .isInstanceOf(TournamentNotFoundException.class); + } + + @Test + @DisplayName("db에_없는_유저") + void userNotFound() { + // given + Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, + LocalDateTime.now(), LocalDateTime.now().plusHours(2)); + User user = createUser("testUser"); + given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); + given(userRepository.findById(null)).willReturn(Optional.empty()); + + // when, then + assertThatThrownBy(() -> tournamentService.registerTournamentUser(tournament.getId(), UserDto.from(user))) + .isInstanceOf(UserNotFoundException.class); + } + + @Test + @DisplayName("이미_신청한_토너먼트_존재") + void conflictedRegistration() { + // given + Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, + LocalDateTime.now(), LocalDateTime.now().plusHours(2)); + User user = createUser("testUser"); + List tournamentUserList = new ArrayList<>(); + tournamentUserList.add(new TournamentUser(user, tournament, true, LocalDateTime.now())); + given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); + given(userRepository.findById(user.getId())).willReturn(Optional.of(user)); + given(tournamentUserRepository.findAllByUser(any(User.class))).willReturn(tournamentUserList); + + // when, then + assertThatThrownBy(() -> tournamentService.registerTournamentUser(tournament.getId(), UserDto.from(user))) + .isInstanceOf(TournamentConflictException.class); + } + } + + @Nested + @DisplayName("토너먼트_유저_참가_취소_테스트") + class CancelTournamentUserRegistration { + @Test + @DisplayName("유저_참가_취소_성공") + void success() { + // given + Tournament tournament = createTournament(1L, TournamentStatus.BEFORE, + LocalDateTime.now(), LocalDateTime.now().plusHours(2)); + User user = createUser("testUser"); + ReflectionUtilsForUnitTest.setFieldWithReflection(user, "id", 1L); + TournamentUser tournamentUser = new TournamentUser(user, tournament, true, LocalDateTime.now()); + given(tournamentRepository.findById(tournament.getId())).willReturn(Optional.of(tournament)); + + // when, then + tournamentService.cancelTournamentUserRegistration(tournament.getId(), UserDto.from(user)); + } + + @Test + @DisplayName("찾을_수_없는_토너먼트") + void tournamentNotFound() { + // given + Long tournamentId = 1L; + User user = createUser("testUser"); + given(tournamentRepository.findById(tournamentId)).willReturn(Optional.empty()); + + // when, then + assertThatThrownBy( + () -> tournamentService.cancelTournamentUserRegistration(tournamentId, UserDto.from(user))) + .isInstanceOf(TournamentNotFoundException.class); + } + } + + @Nested + @DisplayName("startTournament") + class StartTournament { + @Test + @DisplayName("금일 진행하는 토너먼트 없음") + void tournamentNotFound() { + //Arrange + List tournaments = new ArrayList<>(); + IntStream.range(0, 2).forEach((i) -> tournaments.add(i, mock(Tournament.class))); + + when(tournaments.get(0).getStartTime()).thenReturn(LocalDateTime.now().minusDays(1)); + when(tournaments.get(1).getStartTime()).thenReturn(LocalDateTime.now().plusDays(1)); + + when(tournamentRepository.findAllByStatus((TournamentStatus.BEFORE))).thenReturn(tournaments); + + //Act + tournamentService.startTournament(); + + //Assert + verify(tournaments.get(0), times(1)).getStartTime(); + verify(tournaments.get(1), times(1)).getStartTime(); + verify(tournaments.get(0), times(0)).updateStatus(TournamentStatus.LIVE); + verify(tournaments.get(1), times(0)).updateStatus(TournamentStatus.LIVE); + verify(notiAdminService, times(0)).sendAnnounceNotiToUser(any(SendNotiAdminRequestDto.class)); + verify(matchTournamentService, times(0)).matchGames(any(), any()); + } + + @Test + @DisplayName("금일 진행하는 토너먼트 모두 인원수 미달") + void everyTournamentNotFull() { + //Arrange + User user = mock(User.class); + List tournaments = new ArrayList<>(); + List tournamentUsers = new ArrayList<>(); + IntStream.range(0, 2).forEach((i) -> tournaments.add(i, mock(Tournament.class))); + IntStream.range(0, 7).forEach((i) -> tournamentUsers.add(i, mock(TournamentUser.class))); + + when(user.getIntraId()).thenReturn("testUser"); + when(tournaments.get(0).getStartTime()).thenReturn(LocalDateTime.now()); + when(tournaments.get(1).getStartTime()).thenReturn(LocalDateTime.now()); + when(tournamentRepository.findAllByStatus((TournamentStatus.BEFORE))).thenReturn(tournaments); + + tournaments.stream().forEach((t) -> when(t.getTournamentUsers()).thenReturn(tournamentUsers)); + + tournamentUsers.stream().forEach((t) -> when(t.getIsJoined()).thenReturn(true)); + tournamentUsers.stream().forEach((t) -> when(t.getUser()).thenReturn(user)); + + //Act + tournamentService.startTournament(); + + //Assert + verify(tournaments.get(0), times(1)) + .getStartTime(); + verify(tournaments.get(1), times(1)) + .getStartTime(); + verify(tournaments.get(0), times(0)) + .updateStatus(TournamentStatus.LIVE); + verify(tournaments.get(1), times(0)) + .updateStatus(TournamentStatus.LIVE); + verify(notiAdminService, times(14)) + .sendAnnounceNotiToUser(any(SendNotiAdminRequestDto.class)); + verify(matchTournamentService, times(0)) + .matchGames(any(), any()); + } + + @Test + @DisplayName("하나만 인원수 미달") + void oneTournamentNotFull() { + //Arrange + User user = mock(User.class); + List tournaments = new ArrayList<>(); + List notFullTournamentUsers = new ArrayList<>(); + List fullTournamentUsers = new ArrayList<>(); + IntStream.range(0, 2).forEach((i) -> tournaments.add(i, mock(Tournament.class))); + IntStream.range(0, 7).forEach((i) -> notFullTournamentUsers.add(i, mock(TournamentUser.class))); + IntStream.range(0, 16).forEach((i) -> fullTournamentUsers.add(i, mock(TournamentUser.class))); + + when(user.getIntraId()).thenReturn("testUser"); + when(tournaments.get(0).getStartTime()).thenReturn(LocalDateTime.now()); + when(tournaments.get(1).getStartTime()).thenReturn(LocalDateTime.now()); + when(tournamentRepository.findAllByStatus((TournamentStatus.BEFORE))).thenReturn(tournaments); + + when(tournaments.get(0).getTournamentUsers()).thenReturn(notFullTournamentUsers); + when(tournaments.get(1).getTournamentUsers()).thenReturn(fullTournamentUsers); + + IntStream.range(0, 4).forEach((i) -> when(notFullTournamentUsers.get(i).getIsJoined()).thenReturn(true)); + IntStream.range(0, 4).forEach((i) -> when(notFullTournamentUsers.get(i).getUser()).thenReturn(user)); + IntStream.range(4, 7).forEach((i) -> when(notFullTournamentUsers.get(i).getIsJoined()).thenReturn(false)); + + //Act + tournamentService.startTournament(); + + //Assert + verify(tournaments.get(0), times(1)) + .getStartTime(); + verify(tournaments.get(1), times(1)) + .getStartTime(); + verify(tournaments.get(0), times(0)) + .updateStatus(TournamentStatus.LIVE); + verify(tournaments.get(1), times(1)) + .updateStatus(TournamentStatus.LIVE); + verify(notiAdminService, times(4)) + .sendAnnounceNotiToUser(any(SendNotiAdminRequestDto.class)); + verify(matchTournamentService, times(1)) + .matchGames(any(), any()); + } + } + + @Nested + @DisplayName("getTournamentGames") + class GetTournamentGames { + + List existTournamentGames; + + void init() { + existTournamentGames = new ArrayList<>(); + + IntStream.range(0, 7) + .forEach((i) -> existTournamentGames.add(i, mock(TournamentGame.class))); + when(existTournamentGames.get(0).getTournamentRound()).thenReturn( + TournamentRound.QUARTER_FINAL_4); + when(existTournamentGames.get(1).getTournamentRound()).thenReturn( + TournamentRound.QUARTER_FINAL_3); + when(existTournamentGames.get(2).getTournamentRound()).thenReturn( + TournamentRound.QUARTER_FINAL_2); + when(existTournamentGames.get(3).getTournamentRound()).thenReturn( + TournamentRound.QUARTER_FINAL_1); + when(existTournamentGames.get(4).getTournamentRound()).thenReturn( + TournamentRound.SEMI_FINAL_2); + when(existTournamentGames.get(5).getTournamentRound()).thenReturn( + TournamentRound.SEMI_FINAL_1); + when(existTournamentGames.get(6).getTournamentRound()).thenReturn( + TournamentRound.THE_FINAL); + } + + @Test + @DisplayName("토너먼트 게임 존재하지 않음") + void tournamentGameNotExist() { + // given + Long tournamentId = 1L; + List tournamentGames = new ArrayList<>(); + when(tournamentGameRepository.findAllByTournamentId(any(Long.class))).thenReturn( + tournamentGames); + + // when + TournamentGameListResponseDto result = tournamentService.getTournamentGames( + tournamentId); + + // then + Assertions.assertThat(result.getGames()).isEmpty(); + Assertions.assertThat(result.getTournamentId()).isEqualTo(tournamentId); + verify(tournamentGameRepository, times(1)).findAllByTournamentId(any(Long.class)); + verify(gameRepository, times(0)).findTeamsByGameId(any(Long.class)); + } + + @Test + @DisplayName("토너먼트 게임 존재하지만 게임 존재하지 않음") + void tournamentGameExistGameNotExist() { + // given + init(); + Long tournamentId = 1L; + when(tournamentGameRepository.findAllByTournamentId(any(Long.class))).thenReturn( + existTournamentGames); + + // when + TournamentGameListResponseDto result = tournamentService.getTournamentGames( + tournamentId); + + // then + Assertions.assertThat(result.getGames()).size().isEqualTo(7); + Assertions.assertThat(result.getTournamentId()).isEqualTo(tournamentId); + verify(tournamentGameRepository, times(1)).findAllByTournamentId(any(Long.class)); + verify(gameRepository, times(0)).findTeamsByGameId(any(Long.class)); + } + + @Test + @DisplayName("토너먼트 게임, 게임 모두 존재") + void tournamentGameAndGameExist() { + // given + init(); + Long tournamentId = 1L; + + GameTeamUser gameTeamUser = mock(GameTeamUser.class); + when(tournamentGameRepository.findAllByTournamentId(any(Long.class))).thenReturn( + existTournamentGames); + when(gameRepository.findTeamsByGameId(any(Long.class))).thenReturn( + Optional.of(gameTeamUser)); + when(gameTeamUser.getStatus()).thenReturn(StatusType.LIVE); + + IntStream.range(0, 7).forEach((i) -> { + when(existTournamentGames.get(i).getGame()).thenReturn(mock(Game.class)); + when(existTournamentGames.get(i).getGame().getId()).thenReturn((long)i); + }); + + // when + TournamentGameListResponseDto result = tournamentService.getTournamentGames( + tournamentId); + + // then + Assertions.assertThat(result.getGames()).size().isEqualTo(7); + Assertions.assertThat(result.getTournamentId()).isEqualTo(tournamentId); + verify(tournamentGameRepository, times(1)).findAllByTournamentId(any(Long.class)); + verify(gameRepository, times(7)).findTeamsByGameId(any(Long.class)); + } + } + + private Tournament createTournament(Long id, TournamentStatus status, LocalDateTime startTime, + LocalDateTime endTime) { + Tournament tournament = Tournament.builder() + .title(id + "st tournament") + .contents("") + .startTime(startTime) + .endTime(endTime) + .type(TournamentType.ROOKIE) + .status(status) + .build(); + ReflectionUtilsForUnitTest.setFieldWithReflection(tournament, "id", id); + return tournament; + } + + /** + * 유저 생성 매서드 - intraId로만 초기화 + * @param intraId + * @return + */ + private User createUser(String intraId) { + return User.builder() + .eMail("email") + .intraId(intraId) + .racketType(RacketType.PENHOLDER) + .snsNotiOpt(SnsType.NONE) + .roleType(RoleType.USER) + .totalExp(1000) + .build(); + } +} diff --git a/src/test/java/com/gg/server/utils/TestDataUtils.java b/src/test/java/com/gg/server/utils/TestDataUtils.java index cbc2730bb..e7f60e07d 100644 --- a/src/test/java/com/gg/server/utils/TestDataUtils.java +++ b/src/test/java/com/gg/server/utils/TestDataUtils.java @@ -454,7 +454,8 @@ public Tournament createTournament(String title, LocalDateTime startTime, LocalD * @param status 상태 * @return 테스트용 토너먼트 */ - public Tournament createTournament(String title, String contents, LocalDateTime startTime, LocalDateTime endTime, + public Tournament createTournament(String title, String contents, LocalDateTime startTime, LocalDateTime + endTime, TournamentType type, TournamentStatus status) { Tournament tournament = Tournament.builder() .title(title) @@ -563,7 +564,8 @@ public List makeTournamentList() { for (TournamentType type : TournamentType.values()) { for (TournamentStatus status : TournamentStatus.values()) { for (int i = 0; i < 5; i++) { - Tournament tournament = createTournamentByEnum(type, status, LocalDateTime.now().plusDays(day++)); + Tournament tournament = createTournamentByEnum(type, status, + LocalDateTime.now().plusDays(day++)); tournamentResponseDtos.add(new TournamentResponseDto(tournament, winnerImage, joinUserCnt)); tournament.updateWinner(winner); for (int j = 0; j < joinUserCnt; j++) { @@ -571,14 +573,14 @@ public List makeTournamentList() { userRepository.findByIntraId("42gg_tester" + j).get(), tournament, true, LocalDateTime.now()); tournamentUserRepository.save(tournamentUser); - tournament.getTournamentUsers().add(tournamentUser); + // tournament.getTournamentUsers().add(tournamentUser); } for (int j = joinUserCnt; j < joinUserCnt + notJoinUserCnt; j++) { TournamentUser tournamentUser = new TournamentUser( userRepository.findByIntraId("42gg_tester" + j).get(), tournament, false, LocalDateTime.now()); tournamentUserRepository.save(tournamentUser); - tournament.getTournamentUsers().add(tournamentUser); + // tournament.getTournamentUsers().add(tournamentUser); } tournamentRepository.save(tournament); } @@ -597,7 +599,8 @@ public Tournament createTournamentWithUser(int joinUserCnt, int notJoinUserCnt, .type(TournamentType.ROOKIE) .status(TournamentStatus.BEFORE).build(); for (int i = 0; i < joinUserCnt + notJoinUserCnt; i++) { - User newUser = createNewUser(testName + i, "tester" + i + "@gmail.com", RacketType.PENHOLDER, SnsType.NONE, + User newUser = createNewUser(testName + i, "tester" + i + "@gmail.com", RacketType.PENHOLDER, + SnsType.NONE, RoleType.USER); userRepository.save(newUser); } @@ -612,7 +615,8 @@ public Tournament createTournamentWithUser(int joinUserCnt, int notJoinUserCnt, return tournamentRepository.save(tournament); } - public TournamentGame createTournamentGame(Tournament tournament, TournamentRound round, GameInfoDto gameInfoDto) { + public TournamentGame createTournamentGame(Tournament tournament, TournamentRound round, GameInfoDto + gameInfoDto) { TournamentGame tournamentGame = new TournamentGame( gameRepository.findById(gameInfoDto.getGameId()).orElseThrow(GameNotExistException::new), tournament, round); @@ -735,8 +739,7 @@ public List createUsers(int cnt) { List users = new ArrayList<>(); for (int i = 0; i < cnt; i++) { users.add( - createNewUser("testUser" + i, "testUser" + i + "@gmail.com", RacketType.PENHOLDER, - SnsType.NONE, + createNewUser("testUser" + i, "testUser" + i + "@gmail.com", RacketType.PENHOLDER, SnsType.NONE, RoleType.USER)); } userRepository.saveAll(users); From 8a236858a718f06256cdc94796f871e7bd16ea2b Mon Sep 17 00:00:00 2001 From: SeungJun Go <105098279+kokomong2@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:39:56 +0900 Subject: [PATCH 15/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20pchange=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20(#521)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pchange/service/PChangeService.java | 23 +++ .../domain/pchange/data/PChangeDataTest.java | 40 +++++ .../pchange/service/PChangeServiceTest.java | 139 ++++++++++++++++++ 3 files changed, 202 insertions(+) create mode 100644 src/test/java/com/gg/server/domain/pchange/data/PChangeDataTest.java create mode 100644 src/test/java/com/gg/server/domain/pchange/service/PChangeServiceTest.java diff --git a/src/main/java/com/gg/server/domain/pchange/service/PChangeService.java b/src/main/java/com/gg/server/domain/pchange/service/PChangeService.java index 211992afa..01fbe9c02 100644 --- a/src/main/java/com/gg/server/domain/pchange/service/PChangeService.java +++ b/src/main/java/com/gg/server/domain/pchange/service/PChangeService.java @@ -18,11 +18,26 @@ public class PChangeService { private final PChangeRepository pChangeRepository; + /** + * PPP 변화를 저장 한다. + * + * @param game 게임 + * @param user 유저 + * @param pppResult PPP 변화량 + * @param isChecked 확인 여부 + */ @Transactional public void addPChange(Game game, User user, Integer pppResult, Boolean isChecked) { pChangeRepository.save(new PChange(game, user, pppResult, isChecked)); } + /** + * 경험치 변화 이력을 조회 한다. + * + * @param gameId 게임 아이디 + * @param userId 유저 아이디 + * @return 경험치 변화 이력 + */ public List findExpChangeHistory(Long gameId, Long userId) { List pChanges = pChangeRepository.findExpHistory(userId, gameId); if (pChanges.isEmpty()) { @@ -31,6 +46,14 @@ public List findExpChangeHistory(Long gameId, Long userId) { return pChanges; } + /** + * PPP 변화 이력을 조회 한다. + * + * @param gameId 게임 아이디 + * @param userId 유저 아이디 + * @param seasonId 시즌 아이디 + * @return PPP 변화 이력 + */ public List findPPPChangeHistory(Long gameId, Long userId, Long seasonId) { List pChanges = pChangeRepository.findPPPHistory(userId, gameId, seasonId); if (pChanges.isEmpty()) { diff --git a/src/test/java/com/gg/server/domain/pchange/data/PChangeDataTest.java b/src/test/java/com/gg/server/domain/pchange/data/PChangeDataTest.java new file mode 100644 index 000000000..0dd971c73 --- /dev/null +++ b/src/test/java/com/gg/server/domain/pchange/data/PChangeDataTest.java @@ -0,0 +1,40 @@ +package com.gg.server.domain.pchange.data; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +public class PChangeDataTest { + + @Test + public void checkPChangeTest() { + + //given + PChange pChange = new PChange(); + + //when + pChange.checkPChange(); + + //then + Assertions.assertThat(pChange.getIsChecked()).isEqualTo(true); + } + + @Test + public void updatePPPTest() { + + //given + PChange pChange = new PChange(); + int testPPP = 4242; + + //when + pChange.updatePPP(testPPP); + + //then + Assertions.assertThat(pChange.getPppResult()).isEqualTo(testPPP); + } +} diff --git a/src/test/java/com/gg/server/domain/pchange/service/PChangeServiceTest.java b/src/test/java/com/gg/server/domain/pchange/service/PChangeServiceTest.java new file mode 100644 index 000000000..ad40bac85 --- /dev/null +++ b/src/test/java/com/gg/server/domain/pchange/service/PChangeServiceTest.java @@ -0,0 +1,139 @@ +package com.gg.server.domain.pchange.service; + +import static org.junit.Assert.*; +import static org.mockito.BDDMockito.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.domain.game.data.Game; +import com.gg.server.domain.pchange.data.PChange; +import com.gg.server.domain.pchange.data.PChangeRepository; +import com.gg.server.domain.pchange.exception.PChangeNotExistException; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.utils.ReflectionUtilsForUnitTest; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class PChangeServiceTest { + @Mock + private PChangeRepository pChangeRepository; + + @InjectMocks + private PChangeService pChangeService; + + @Test + @DisplayName("addPChange Success Test") + public void testAddPChange() { + Game game = new Game(); + User user = new User("intra", "email", "image", RacketType.PENHOLDER, + RoleType.USER, 1000, SnsType.NONE, 4242L); + Integer pppResult = 42; + Boolean isChecked = true; + + // given + PChange pchange = new PChange(game, user, 4242, true); + given(pChangeRepository.save(any(PChange.class))).willReturn(pchange); + + // when + pChangeService.addPChange(game, user, pppResult, isChecked); + + // then + verify(pChangeRepository, times(1)).save(any(PChange.class)); + } + + @Nested + @DisplayName("FindExpChangeHistory Test") + class TestFindExpChangeHistory { + + @Test + @DisplayName("성공") + public void successFindExpChangeHistory() { + PChange pChange = new PChange(); + ReflectionUtilsForUnitTest.setFieldWithReflection(pChange, "game", mock(Game.class)); + ReflectionUtilsForUnitTest.setFieldWithReflection(pChange, "user", mock(User.class)); + + // given + List lst = new ArrayList<>(); + lst.add(pChange); + when(pChangeRepository.findExpHistory(any(Long.class), any(Long.class))).thenReturn(lst); + + // when + pChangeService.findExpChangeHistory(1L, 1L); + + // then + verify(pChangeRepository, times(1)).findExpHistory(1L, 1L); + } + + @Test + @DisplayName("실패 : nowExistGameId") + public void pchangeNotExistExceptionTest() { + Long gameId = 1L; + Long userId = 1L; + + // given + when(pChangeRepository.findExpHistory(userId, gameId)).thenReturn(new ArrayList<>()); + + // when, then + assertThrows(PChangeNotExistException.class, () -> pChangeService.findExpChangeHistory(gameId, userId)); + + } + + } + + @Nested + @DisplayName("FindPPPChangeHistory Test") + class TestFindPPPChangeHistory { + + @Test + @DisplayName("성공") + public void success() { + Long gameId = 1L; + Long userId = 1L; + Long seasonId = 1L; + + PChange pChange = new PChange(); + ReflectionUtilsForUnitTest.setFieldWithReflection(pChange, "game", mock(Game.class)); + ReflectionUtilsForUnitTest.setFieldWithReflection(pChange, "user", mock(User.class)); + + List pChangeList = new ArrayList<>(); + pChangeList.add(pChange); + // given + when(pChangeRepository.findPPPHistory(userId, gameId, seasonId)).thenReturn(pChangeList); + + // when + pChangeService.findPPPChangeHistory(gameId, userId, seasonId); + + // then + verify(pChangeRepository, times(1)).findPPPHistory(userId, gameId, seasonId); + } + + @Test + @DisplayName("실패 : notExist") + public void notExist() { + Long gameId = 1L; + Long userId = 1L; + Long seasonId = 1L; + + // given + when(pChangeRepository.findPPPHistory(userId, gameId, seasonId)).thenReturn(new ArrayList<>()); + + // when, then + assertThrows(PChangeNotExistException.class, () -> { + pChangeService.findPPPChangeHistory(gameId, userId, seasonId); + }); + } + } +} From c01b1a60c1c39b5280040921b72a6992cc00f0e7 Mon Sep 17 00:00:00 2001 From: yoahn <46748334+AYoungSn@users.noreply.github.com> Date: Mon, 5 Feb 2024 17:14:42 +0900 Subject: [PATCH 16/32] =?UTF-8?q?[REFACT]=20#529=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=ED=8F=B4=EB=8D=94=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20(#531)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/AnnouncementAdminRepository.java | 2 +- .../dto/AnnouncementAdminResponseDto.java | 2 +- .../service/AnnouncementAdminService.java | 2 +- .../coin/data/CoinPolicyAdminRepository.java | 2 +- .../coin/dto/CoinPolicyAdminResponseDto.java | 2 +- .../admin/coin/service/CoinAdminService.java | 4 +- .../coin/service/CoinPolicyAdminService.java | 4 +- .../data/FeedbackAdminRepository.java | 2 +- .../dto/FeedbackAdminResponseDto.java | 4 +- .../service/FeedbackAdminService.java | 2 +- .../admin/game/data/GameAdminRepository.java | 8 +-- .../admin/game/dto/GameLogAdminDto.java | 2 +- .../admin/game/service/GameAdminService.java | 16 +++--- .../admin/item/data/ItemAdminRepository.java | 2 +- .../item/dto/ItemHistoryResponseDto.java | 2 +- .../admin/item/dto/ItemUpdateRequestDto.java | 2 +- .../admin/item/service/ItemAdminService.java | 2 +- .../data/MegaphoneAdminRepository.java | 2 +- .../dto/MegaphoneAdminResponseDto.java | 2 +- .../admin/noti/data/NotiAdminRepository.java | 2 +- .../noti/data/NotiAdminRepositoryCustom.java | 2 +- .../data/NotiAdminRepositoryCustomImpl.java | 2 +- .../server/admin/noti/dto/NotiAdminDto.java | 4 +- .../admin/noti/service/NotiAdminService.java | 6 +-- .../pchange/data/PChangeAdminRepository.java | 2 +- .../data/PChangeAdminRepositoryCustom.java | 2 +- .../PChangeAdminRepositoryCustomImpl.java | 2 +- .../penalty/data/PenaltyAdminRepository.java | 2 +- .../data/PenaltyAdminRepositoryCustom.java | 2 +- .../PenaltyAdminRepositoryCustomImpl.java | 2 +- .../data/PenaltyUserAdminRedisRepository.java | 2 +- .../penalty/dto/PenaltyUserResponseDto.java | 4 +- .../penalty/service/PenaltyAdminService.java | 6 +-- .../admin/rank/service/RankAdminService.java | 10 ++-- .../rank/service/RankRedisAdminService.java | 8 +-- .../receipt/data/ReceiptAdminRepository.java | 2 +- .../data/ReceiptAdminRepositorySearch.java | 2 +- .../admin/receipt/dto/ReceiptResponseDto.java | 6 +-- .../receipt/service/ReceiptAdminService.java | 2 +- .../season/data/SeasonAdminRepository.java | 2 +- .../admin/season/dto/SeasonAdminDto.java | 2 +- .../season/service/SeasonAdminService.java | 2 +- .../admin/team/data/TeamAdminRepository.java | 4 +- .../team/data/TeamUserAdminRepository.java | 4 +- .../dto/TournamentAdminCreateRequestDto.java | 2 +- .../dto/TournamentAdminUpdateRequestDto.java | 2 +- .../service/TournamentAdminService.java | 24 ++++----- .../admin/user/data/UserAdminRepository.java | 2 +- .../user/data/UserImageAdminRepository.java | 4 +- .../server/admin/user/dto/UserAdminDto.java | 10 ++-- .../user/dto/UserDetailAdminResponseDto.java | 4 +- .../admin/user/dto/UserImageAdminDto.java | 2 +- .../admin/user/dto/UserSearchAdminDto.java | 4 +- .../user/dto/UserUpdateAdminRequestDto.java | 2 +- .../admin/user/service/UserAdminService.java | 10 ++-- .../{domain/game/data => data/game}/Game.java | 8 ++- .../pchange/data => data/game}/PChange.java | 5 +- .../{domain/rank/data => data/game}/Rank.java | 6 +-- .../season/data => data/game}/Season.java | 2 +- .../{domain/team/data => data/game}/Team.java | 3 +- .../team/data => data/game}/TeamUser.java | 4 +- .../{domain/tier/data => data/game}/Tier.java | 2 +- .../data => data/game}/Tournament.java | 8 +-- .../data => data/game}/TournamentGame.java | 5 +- .../data => data/game}/TournamentUser.java | 4 +- .../rank => data/game}/redis/RankRedis.java | 4 +- .../{domain => data}/game/type/Mode.java | 6 +-- .../game}/type/RoundNumber.java | 2 +- .../game/type/StatusType.java | 2 +- .../game}/type/TournamentRound.java | 4 +- .../game}/type/TournamentStatus.java | 2 +- .../game}/type/TournamentType.java | 2 +- .../game}/type/TournamentUserStatus.java | 2 +- .../data => data/manage}/Announcement.java | 2 +- .../coin/data => data/manage}/CoinPolicy.java | 4 +- .../data => data/manage}/Feedback.java | 6 +-- .../penalty/data => data/manage}/Penalty.java | 4 +- .../manage}/redis/RedisPenaltyUser.java | 2 +- .../manage}/type/FeedbackType.java | 2 +- .../data => data/match}/RedisMatchTime.java | 4 +- .../data => data/match}/RedisMatchUser.java | 4 +- .../{domain => data}/match/type/MatchKey.java | 2 +- .../{domain => data}/match/type/Option.java | 2 +- .../match/type/SlotStatus.java | 2 +- .../match/type/TournamentMatchStatus.java | 2 +- .../{domain/noti/data => data/noti}/Noti.java | 6 +-- .../{domain => data}/noti/type/NotiType.java | 2 +- .../coin/data => data/store}/CoinHistory.java | 4 +- .../item/data => data/store}/Item.java | 4 +- .../data => data/store}/Megaphone.java | 5 +- .../receipt/data => data/store}/Receipt.java | 5 +- .../store}/redis/MegaphoneRedis.java | 2 +- .../coin => data/store}/type/HistoryType.java | 2 +- .../store}/type/ItemStatus.java | 2 +- .../item => data/store}/type/ItemType.java | 2 +- .../{domain/user/data => data/user}/User.java | 12 ++--- .../user/data => data/user}/UserImage.java | 2 +- .../user/type/BackgroundType.java | 2 +- .../{domain => data}/user/type/EdgeType.java | 2 +- .../{domain => data}/user/type/OauthType.java | 2 +- .../user/type/RacketType.java | 2 +- .../{domain => data}/user/type/RoleType.java | 2 +- .../{domain => data}/user/type/SnsType.java | 2 +- .../data/AnnouncementRepository.java | 2 + .../announcement/dto/AnnouncementDto.java | 2 +- .../service/AnnouncementService.java | 2 +- .../coin/data/CoinHistoryRepository.java | 3 +- .../coin/data/CoinPolicyRepository.java | 2 + .../coin/service/CoinHistoryService.java | 8 +-- .../coin/service/UserCoinChangeService.java | 8 +-- .../feedback/data/FeedbackRepository.java | 2 + .../feedback/dto/FeedbackRequestDto.java | 2 +- .../feedback/service/FeedbackService.java | 4 +- .../gg/server/domain/game/GameController.java | 2 +- .../domain/game/data/GameRepository.java | 5 +- .../game/data/GameRepositoryCustom.java | 2 + .../domain/game/data/GameRepositoryImpl.java | 3 +- .../domain/game/dto/GameResultResDto.java | 2 +- .../server/domain/game/dto/GameTeamInfo.java | 4 +- .../server/domain/game/dto/GameTeamUser.java | 4 +- .../domain/game/dto/GameTeamUserInfo.java | 4 +- .../game/dto/request/GameListReqDto.java | 2 +- .../domain/game/service/GameFindService.java | 6 +-- .../domain/game/service/GameService.java | 18 +++---- .../game/service/GameStatusService.java | 8 +-- .../domain/item/data/ItemRepository.java | 2 + .../domain/item/data/UserItemRepository.java | 2 +- .../domain/item/dto/ItemStoreResponseDto.java | 4 +- .../domain/item/dto/UserItemResponseDto.java | 8 +-- .../domain/item/service/ItemService.java | 12 ++--- .../match/controller/MatchController.java | 2 +- .../match/data/RedisMatchTimeRepository.java | 3 +- .../match/data/RedisMatchUserRepository.java | 5 +- .../server/domain/match/dto/GameAddDto.java | 6 +-- .../domain/match/dto/MatchRequestDto.java | 2 +- .../domain/match/dto/MatchStatusDto.java | 6 +-- .../domain/match/dto/SlotStatusDto.java | 2 +- .../match/service/GameUpdateService.java | 10 ++-- .../match/service/MatchFindService.java | 20 ++++---- .../domain/match/service/MatchService.java | 22 ++++---- .../match/service/MatchTournamentService.java | 34 ++++++------- .../domain/match/utils/MatchCalculator.java | 6 +-- .../domain/match/utils/SlotGenerator.java | 16 +++--- .../megaphone/data/MegaphoneRepository.java | 5 +- .../dto/MegaphoneDetailResponseDto.java | 2 +- .../dto/MegaphoneTodayListResponseDto.java | 2 +- .../redis/MegaphoneRedisRepository.java | 2 + .../megaphone/service/MegaphoneService.java | 14 +++--- .../domain/noti/data/NotiRepository.java | 3 +- .../gg/server/domain/noti/dto/NotiDto.java | 4 +- .../domain/noti/dto/NotiResponseDto.java | 4 +- .../server/domain/noti/dto/UserNotiDto.java | 2 +- .../domain/noti/service/NotiService.java | 6 +-- .../domain/noti/service/SnsNotiService.java | 4 +- .../noti/service/sns/NotiMailSender.java | 2 +- .../noti/service/sns/SlackbotService.java | 2 +- .../pchange/data/PChangeRepository.java | 3 +- .../pchange/data/PChangeRepositoryCustom.java | 2 + .../pchange/data/PChangeRepositoryImpl.java | 2 + .../pchange/service/PChangeService.java | 6 +-- .../penalty/data/PenaltyRepository.java | 2 + .../redis/PenaltyUserRedisRepository.java | 1 + .../penalty/service/PenaltyService.java | 6 +-- .../domain/rank/data/RankRepository.java | 1 + .../gg/server/domain/rank/dto/ExpRankDto.java | 2 +- .../gg/server/domain/rank/dto/RankDto.java | 4 +- .../rank/redis/RankRedisRepository.java | 1 + .../domain/rank/redis/RankRedisService.java | 11 ++-- .../domain/rank/service/RankFindService.java | 2 +- .../domain/rank/service/RankService.java | 6 +-- .../rank/service/RedisUploadService.java | 2 +- .../receipt/data/ReceiptRepository.java | 2 + .../domain/season/data/SeasonRepository.java | 2 + .../server/domain/season/dto/CurSeason.java | 2 +- .../domain/season/dto/SeasonResDto.java | 2 +- .../season/service/SeasonFindService.java | 4 +- .../domain/team/data/TeamRepository.java | 2 + .../domain/team/data/TeamUserRepository.java | 2 + .../gg/server/domain/team/dto/GameUser.java | 2 +- .../domain/tier/data/TierRepository.java | 2 + .../domain/tier/service/TierService.java | 6 +-- .../data/TournamentGameRepository.java | 3 +- .../tournament/data/TournamentRepository.java | 5 +- .../data/TournamentUserRepository.java | 4 +- .../dto/TournamentFilterRequestDto.java | 4 +- .../tournament/dto/TournamentGameResDto.java | 4 +- .../tournament/dto/TournamentResponseDto.java | 8 +-- .../dto/TournamentUserListResponseDto.java | 2 +- ...TournamentUserRegistrationResponseDto.java | 2 +- .../dto/TournamentUserResponseDto.java | 2 +- .../tournament/service/TournamentService.java | 22 ++++---- .../user/controller/UserController.java | 6 +-- .../domain/user/data/UserImageRepository.java | 3 ++ .../domain/user/data/UserRepository.java | 1 + .../user/dto/CoinHistoryResponseDto.java | 2 +- .../user/dto/UserDetailResponseDto.java | 10 ++-- .../gg/server/domain/user/dto/UserDto.java | 8 +-- .../domain/user/dto/UserHistoryData.java | 2 +- .../server/domain/user/dto/UserImageDto.java | 4 +- .../domain/user/dto/UserLiveResponseDto.java | 2 +- .../domain/user/dto/UserModifyRequestDto.java | 4 +- .../user/dto/UserNormalDetailResponseDto.java | 2 +- .../domain/user/service/UserCoinService.java | 4 +- .../domain/user/service/UserFindService.java | 6 +-- .../domain/user/service/UserService.java | 34 ++++++------- .../server/global/security/UserPrincipal.java | 4 +- .../OAuthAuthenticationSuccessHandler.java | 4 +- .../global/security/info/OAuthUserInfo.java | 2 +- .../info/impl/FortyTwoOAuthUserInfo.java | 2 +- .../info/impl/KakaoOAuthUserInfo.java | 2 +- .../service/CustomOAuth2UserService.java | 12 ++--- .../service/CustomUserDetailsService.java | 2 +- .../server/global/utils/ItemImageHandler.java | 2 +- .../server/global/utils/UserImageHandler.java | 2 +- .../LoginMemberArgumentResolver.java | 2 +- .../utils/aws/AsyncNewItemImageUploader.java | 2 +- .../utils/aws/AsyncNewUserImageUploader.java | 4 +- .../AnnouncementAdminControllerTest.java | 2 +- .../AnnouncementAdminServiceUnitTest.java | 2 +- .../CoinPolicyAdminControllerTest.java | 4 +- .../FeedbackAdminControllerTest.java | 6 +-- .../service/FeedbackAdminServiceUnitTest.java | 2 +- .../controller/GameAdminControllerTest.java | 10 ++-- .../controller/ItemAdminControllerTest.java | 4 +- .../service/ItemAdminServiceUnitTest.java | 10 ++-- .../controller/NotiAdminControllerTest.java | 6 +-- .../service/NotiAdminServiceUnitTest.java | 4 +- .../PenaltyAdminControllerTest.java | 12 ++--- .../ReceiptAdminControllerTest.java | 6 +-- .../season/SeasonAdminControllerTest.java | 4 +- .../TournamentAdminControllerTest.java | 18 +++---- .../TournamentAdminUserControllerTest.java | 10 ++-- .../service/TournamentAdminServiceTest.java | 22 ++++---- .../controller/UserAdminControllerTest.java | 4 +- .../game/data => data/game}/GameUnitTest.java | 3 +- .../data => data/game}/PChangeDataTest.java | 2 +- .../team/data => data/game}/TeamUnitTest.java | 2 +- .../game}/TournamentGameUnitTest.java | 11 ++-- .../game}/TournamentUnitTest.java | 10 ++-- .../game}/TournamentUserUnitTest.java | 13 +++-- .../manage}/AnnouncementUnitTest.java | 2 +- .../data => data/store}/ItemUnitTest.java | 2 +- .../AnnouncementControllerTest.java | 4 +- .../service/AnnouncementServiceUnitTest.java | 2 +- .../coin/service/CoinHistoryServiceTest.java | 6 +-- .../service/UserCoinChangeServiceTest.java | 14 +++--- .../controller/FeedbackControllerTest.java | 4 +- .../service/FeedbackServiceUnitTest.java | 4 +- .../domain/game/GameControllerTest.java | 32 ++++++------ .../domain/game/service/GameDBTest.java | 12 ++--- .../game/service/GameFindServiceTest.java | 14 +++--- .../domain/game/service/GameServiceTest.java | 20 ++++---- .../game/service/GameStatusServiceTest.java | 20 ++++---- .../ItemStoreListControllerTest.java | 2 +- .../item/service/ItemServiceUnitTest.java | 17 +++---- .../match/dto/MatchStatusDtoUnitTest.java | 4 +- .../match/service/MatchBothServiceTest.java | 8 +-- .../service/MatchFindServiceUnitTest.java | 22 ++++---- .../match/service/MatchServiceTest.java | 32 ++++++------ .../service/MatchTournamentServiceTest.java | 25 +++++----- .../MatchTournamentServiceUnitTest.java | 26 +++++----- .../domain/match/utils/GameTestUtils.java | 14 +++--- .../utils/MatchIntegrationTestUtils.java | 16 +++--- .../match/utils/TournamentGameTestUtils.java | 22 ++++---- .../match/utils/TournamentTestUtils.java | 12 ++--- .../domain/match/utils/UserTestUtils.java | 8 +-- .../controller/MegaphoneControllerTest.java | 18 +++---- .../service/MegaphoneServiceUnitTest.java | 19 ++++--- .../noti/controller/NotiControllerTest.java | 6 +-- .../domain/noti/service/NotiServiceTest.java | 6 +-- .../pchange/service/PChangeServiceTest.java | 12 ++--- .../rank/controller/RankControllerTest.java | 4 +- .../rank/controller/RankV2ControllerTest.java | 2 +- .../rank/redis/RankRedisRepositoryTest.java | 1 + .../domain/rank/service/RankServiceTest.java | 4 +- .../domain/season/SeasonTestController.java | 2 +- .../domain/season/SeasonTriggerTest.java | 4 +- .../TournamentFindControllerTest.java | 16 +++--- .../TournamentGameControllerTest.java | 20 ++++---- .../controller/TournamentSchedulerTest.java | 6 +-- .../service/TournamentServiceUnitTest.java | 26 +++++----- .../user/controller/UserControllerTest.java | 34 ++++++------- .../com/gg/server/utils/ItemTestUtils.java | 10 ++-- .../com/gg/server/utils/TestDataUtils.java | 50 +++++++++---------- 284 files changed, 875 insertions(+), 827 deletions(-) rename src/main/java/com/gg/server/{domain/game/data => data/game}/Game.java (92%) rename src/main/java/com/gg/server/{domain/pchange/data => data/game}/PChange.java (92%) rename src/main/java/com/gg/server/{domain/rank/data => data/game}/Rank.java (93%) rename src/main/java/com/gg/server/{domain/season/data => data/game}/Season.java (97%) rename src/main/java/com/gg/server/{domain/team/data => data/game}/Team.java (95%) rename src/main/java/com/gg/server/{domain/team/data => data/game}/TeamUser.java (93%) rename src/main/java/com/gg/server/{domain/tier/data => data/game}/Tier.java (94%) rename src/main/java/com/gg/server/{domain/tournament/data => data/game}/Tournament.java (95%) rename src/main/java/com/gg/server/{domain/tournament/data => data/game}/TournamentGame.java (91%) rename src/main/java/com/gg/server/{domain/tournament/data => data/game}/TournamentUser.java (94%) rename src/main/java/com/gg/server/{domain/rank => data/game}/redis/RankRedis.java (96%) rename src/main/java/com/gg/server/{domain => data}/game/type/Mode.java (88%) rename src/main/java/com/gg/server/{domain/tournament => data/game}/type/RoundNumber.java (84%) rename src/main/java/com/gg/server/{domain => data}/game/type/StatusType.java (94%) rename src/main/java/com/gg/server/{domain/tournament => data/game}/type/TournamentRound.java (93%) rename src/main/java/com/gg/server/{domain/tournament => data/game}/type/TournamentStatus.java (94%) rename src/main/java/com/gg/server/{domain/tournament => data/game}/type/TournamentType.java (93%) rename src/main/java/com/gg/server/{domain/tournament => data/game}/type/TournamentUserStatus.java (87%) rename src/main/java/com/gg/server/{domain/announcement/data => data/manage}/Announcement.java (96%) rename src/main/java/com/gg/server/{domain/coin/data => data/manage}/CoinPolicy.java (95%) rename src/main/java/com/gg/server/{domain/feedback/data => data/manage}/Feedback.java (89%) rename src/main/java/com/gg/server/{domain/penalty/data => data/manage}/Penalty.java (94%) rename src/main/java/com/gg/server/{domain/penalty => data/manage}/redis/RedisPenaltyUser.java (96%) rename src/main/java/com/gg/server/{domain/feedback => data/manage}/type/FeedbackType.java (93%) rename src/main/java/com/gg/server/{domain/match/data => data/match}/RedisMatchTime.java (91%) rename src/main/java/com/gg/server/{domain/match/data => data/match}/RedisMatchUser.java (86%) rename src/main/java/com/gg/server/{domain => data}/match/type/MatchKey.java (93%) rename src/main/java/com/gg/server/{domain => data}/match/type/Option.java (95%) rename src/main/java/com/gg/server/{domain => data}/match/type/SlotStatus.java (93%) rename src/main/java/com/gg/server/{domain => data}/match/type/TournamentMatchStatus.java (91%) rename src/main/java/com/gg/server/{domain/noti/data => data/noti}/Noti.java (91%) rename src/main/java/com/gg/server/{domain => data}/noti/type/NotiType.java (97%) rename src/main/java/com/gg/server/{domain/coin/data => data/store}/CoinHistory.java (93%) rename src/main/java/com/gg/server/{domain/item/data => data/store}/Item.java (97%) rename src/main/java/com/gg/server/{domain/megaphone/data => data/store}/Megaphone.java (89%) rename src/main/java/com/gg/server/{domain/receipt/data => data/store}/Receipt.java (92%) rename src/main/java/com/gg/server/{domain/megaphone => data/store}/redis/MegaphoneRedis.java (94%) rename src/main/java/com/gg/server/{domain/coin => data/store}/type/HistoryType.java (87%) rename src/main/java/com/gg/server/{domain/receipt => data/store}/type/ItemStatus.java (86%) rename src/main/java/com/gg/server/{domain/item => data/store}/type/ItemType.java (78%) rename src/main/java/com/gg/server/{domain/user/data => data/user}/User.java (92%) rename src/main/java/com/gg/server/{domain/user/data => data/user}/UserImage.java (97%) rename src/main/java/com/gg/server/{domain => data}/user/type/BackgroundType.java (96%) rename src/main/java/com/gg/server/{domain => data}/user/type/EdgeType.java (96%) rename src/main/java/com/gg/server/{domain => data}/user/type/OauthType.java (95%) rename src/main/java/com/gg/server/{domain => data}/user/type/RacketType.java (93%) rename src/main/java/com/gg/server/{domain => data}/user/type/RoleType.java (92%) rename src/main/java/com/gg/server/{domain => data}/user/type/SnsType.java (91%) rename src/test/java/com/gg/server/{domain/game/data => data/game}/GameUnitTest.java (97%) rename src/test/java/com/gg/server/{domain/pchange/data => data/game}/PChangeDataTest.java (94%) rename src/test/java/com/gg/server/{domain/team/data => data/game}/TeamUnitTest.java (98%) rename src/test/java/com/gg/server/{domain/tournament/data => data/game}/TournamentGameUnitTest.java (66%) rename src/test/java/com/gg/server/{domain/tournament/data => data/game}/TournamentUnitTest.java (97%) rename src/test/java/com/gg/server/{domain/tournament/data => data/game}/TournamentUserUnitTest.java (71%) rename src/test/java/com/gg/server/{domain/announcement/data => data/manage}/AnnouncementUnitTest.java (96%) rename src/test/java/com/gg/server/{domain/item/data => data/store}/ItemUnitTest.java (96%) diff --git a/src/main/java/com/gg/server/admin/announcement/data/AnnouncementAdminRepository.java b/src/main/java/com/gg/server/admin/announcement/data/AnnouncementAdminRepository.java index 8a3ed6b4f..984eca2ba 100644 --- a/src/main/java/com/gg/server/admin/announcement/data/AnnouncementAdminRepository.java +++ b/src/main/java/com/gg/server/admin/announcement/data/AnnouncementAdminRepository.java @@ -4,7 +4,7 @@ import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.announcement.data.Announcement; +import com.gg.server.data.manage.Announcement; public interface AnnouncementAdminRepository extends JpaRepository { diff --git a/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminResponseDto.java b/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminResponseDto.java index c7ad638d4..cd67b49b8 100644 --- a/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminResponseDto.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import com.gg.server.domain.announcement.data.Announcement; +import com.gg.server.data.manage.Announcement; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java b/src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java index 557936e75..2e2486308 100644 --- a/src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java +++ b/src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java @@ -11,7 +11,7 @@ import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; import com.gg.server.admin.announcement.dto.AnnouncementAdminListResponseDto; import com.gg.server.admin.announcement.dto.AnnouncementAdminResponseDto; -import com.gg.server.domain.announcement.data.Announcement; +import com.gg.server.data.manage.Announcement; import com.gg.server.domain.announcement.exception.AnnounceDupException; import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; diff --git a/src/main/java/com/gg/server/admin/coin/data/CoinPolicyAdminRepository.java b/src/main/java/com/gg/server/admin/coin/data/CoinPolicyAdminRepository.java index 292472f7e..ce2aab775 100644 --- a/src/main/java/com/gg/server/admin/coin/data/CoinPolicyAdminRepository.java +++ b/src/main/java/com/gg/server/admin/coin/data/CoinPolicyAdminRepository.java @@ -4,7 +4,7 @@ import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.coin.data.CoinPolicy; +import com.gg.server.data.manage.CoinPolicy; public interface CoinPolicyAdminRepository extends JpaRepository { Optional findFirstByOrderByIdDesc(); diff --git a/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminResponseDto.java b/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminResponseDto.java index d1aa2a11e..8e7a8130b 100644 --- a/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminResponseDto.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import com.gg.server.domain.coin.data.CoinPolicy; +import com.gg.server.data.manage.CoinPolicy; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java b/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java index 3fe706cb9..65e8227c7 100644 --- a/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java +++ b/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java @@ -4,9 +4,9 @@ import org.springframework.transaction.annotation.Transactional; import com.gg.server.admin.coin.dto.CoinUpdateRequestDto; -import com.gg.server.domain.coin.data.CoinHistory; +import com.gg.server.data.store.CoinHistory; +import com.gg.server.data.user.User; import com.gg.server.domain.coin.service.CoinHistoryService; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.exception.UserNotFoundException; diff --git a/src/main/java/com/gg/server/admin/coin/service/CoinPolicyAdminService.java b/src/main/java/com/gg/server/admin/coin/service/CoinPolicyAdminService.java index 1f84d2206..f01aec8cc 100644 --- a/src/main/java/com/gg/server/admin/coin/service/CoinPolicyAdminService.java +++ b/src/main/java/com/gg/server/admin/coin/service/CoinPolicyAdminService.java @@ -10,8 +10,8 @@ import com.gg.server.admin.coin.dto.CoinPolicyAdminListResponseDto; import com.gg.server.admin.coin.dto.CoinPolicyAdminResponseDto; import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.domain.coin.data.CoinPolicy; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.manage.CoinPolicy; +import com.gg.server.data.user.User; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; diff --git a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java b/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java index 7af6cac77..d247b58d3 100644 --- a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java +++ b/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java @@ -6,7 +6,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.domain.feedback.data.Feedback; +import com.gg.server.data.manage.Feedback; public interface FeedbackAdminRepository extends JpaRepository { @Query(value = "select f from Feedback f join fetch f.user " diff --git a/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminResponseDto.java b/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminResponseDto.java index a2bafaba5..ec0c98669 100644 --- a/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminResponseDto.java @@ -2,8 +2,8 @@ import java.time.LocalDateTime; -import com.gg.server.domain.feedback.data.Feedback; -import com.gg.server.domain.feedback.type.FeedbackType; +import com.gg.server.data.manage.Feedback; +import com.gg.server.data.manage.type.FeedbackType; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java b/src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java index 9b8a67f7e..26201726f 100644 --- a/src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java +++ b/src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java @@ -11,7 +11,7 @@ import com.gg.server.admin.feedback.data.FeedbackAdminRepository; import com.gg.server.admin.feedback.dto.FeedbackAdminResponseDto; import com.gg.server.admin.feedback.dto.FeedbackListAdminResponseDto; -import com.gg.server.domain.feedback.data.Feedback; +import com.gg.server.data.manage.Feedback; import com.gg.server.domain.feedback.exception.FeedbackNotFoundException; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java b/src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java index 576cb41c6..1c78b38c1 100644 --- a/src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java +++ b/src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java @@ -9,11 +9,11 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.season.data.Season; public interface GameAdminRepository extends JpaRepository { diff --git a/src/main/java/com/gg/server/admin/game/dto/GameLogAdminDto.java b/src/main/java/com/gg/server/admin/game/dto/GameLogAdminDto.java index 17b4a731a..80523ccda 100644 --- a/src/main/java/com/gg/server/admin/game/dto/GameLogAdminDto.java +++ b/src/main/java/com/gg/server/admin/game/dto/GameLogAdminDto.java @@ -3,8 +3,8 @@ import java.time.Duration; import java.time.LocalDateTime; +import com.gg.server.data.game.type.StatusType; import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.game.type.StatusType; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/game/service/GameAdminService.java b/src/main/java/com/gg/server/admin/game/service/GameAdminService.java index edccc8fba..b7a9511dc 100644 --- a/src/main/java/com/gg/server/admin/game/service/GameAdminService.java +++ b/src/main/java/com/gg/server/admin/game/service/GameAdminService.java @@ -24,23 +24,23 @@ import com.gg.server.admin.season.data.SeasonAdminRepository; import com.gg.server.admin.team.data.TeamUserAdminRepository; import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.PChange; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.user.User; import com.gg.server.domain.game.dto.GameTeamUser; import com.gg.server.domain.game.exception.GameNotExistException; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.match.data.RedisMatchUserRepository; -import com.gg.server.domain.pchange.data.PChange; import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisService; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.dto.CurSeason; import com.gg.server.domain.season.exception.SeasonNotFoundException; import com.gg.server.domain.season.service.SeasonService; -import com.gg.server.domain.team.data.TeamUser; import com.gg.server.domain.tier.service.TierService; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.exception.UserNotFoundException; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/item/data/ItemAdminRepository.java b/src/main/java/com/gg/server/admin/item/data/ItemAdminRepository.java index dc289869f..39496ecf7 100644 --- a/src/main/java/com/gg/server/admin/item/data/ItemAdminRepository.java +++ b/src/main/java/com/gg/server/admin/item/data/ItemAdminRepository.java @@ -4,7 +4,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.item.data.Item; +import com.gg.server.data.store.Item; public interface ItemAdminRepository extends JpaRepository { Page findAll(Pageable pageable); diff --git a/src/main/java/com/gg/server/admin/item/dto/ItemHistoryResponseDto.java b/src/main/java/com/gg/server/admin/item/dto/ItemHistoryResponseDto.java index 07a6f7a3e..d6937d47a 100644 --- a/src/main/java/com/gg/server/admin/item/dto/ItemHistoryResponseDto.java +++ b/src/main/java/com/gg/server/admin/item/dto/ItemHistoryResponseDto.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import com.gg.server.domain.item.data.Item; +import com.gg.server.data.store.Item; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/item/dto/ItemUpdateRequestDto.java b/src/main/java/com/gg/server/admin/item/dto/ItemUpdateRequestDto.java index f51616d53..7b5d841d8 100644 --- a/src/main/java/com/gg/server/admin/item/dto/ItemUpdateRequestDto.java +++ b/src/main/java/com/gg/server/admin/item/dto/ItemUpdateRequestDto.java @@ -2,7 +2,7 @@ import javax.validation.constraints.NotNull; -import com.gg.server.domain.item.type.ItemType; +import com.gg.server.data.store.type.ItemType; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/item/service/ItemAdminService.java b/src/main/java/com/gg/server/admin/item/service/ItemAdminService.java index 3c78b55eb..680d96f11 100644 --- a/src/main/java/com/gg/server/admin/item/service/ItemAdminService.java +++ b/src/main/java/com/gg/server/admin/item/service/ItemAdminService.java @@ -13,7 +13,7 @@ import com.gg.server.admin.item.dto.ItemListResponseDto; import com.gg.server.admin.item.dto.ItemUpdateRequestDto; import com.gg.server.admin.item.exception.ItemNotFoundException; -import com.gg.server.domain.item.data.Item; +import com.gg.server.data.store.Item; import com.gg.server.domain.item.exception.ItemNotAvailableException; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.utils.aws.AsyncNewItemImageUploader; diff --git a/src/main/java/com/gg/server/admin/megaphone/data/MegaphoneAdminRepository.java b/src/main/java/com/gg/server/admin/megaphone/data/MegaphoneAdminRepository.java index e8b39bf54..113a801f4 100644 --- a/src/main/java/com/gg/server/admin/megaphone/data/MegaphoneAdminRepository.java +++ b/src/main/java/com/gg/server/admin/megaphone/data/MegaphoneAdminRepository.java @@ -4,7 +4,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.megaphone.data.Megaphone; +import com.gg.server.data.store.Megaphone; public interface MegaphoneAdminRepository extends JpaRepository { Page findMegaphonesByUserIntraId(String intraId, Pageable pageable); diff --git a/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneAdminResponseDto.java b/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneAdminResponseDto.java index 7dba27a8c..423580aa0 100644 --- a/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneAdminResponseDto.java @@ -1,6 +1,6 @@ package com.gg.server.admin.megaphone.dto; -import com.gg.server.domain.megaphone.data.Megaphone; +import com.gg.server.data.store.Megaphone; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepository.java b/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepository.java index 35c136cf9..37619e5e8 100644 --- a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepository.java +++ b/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepository.java @@ -5,7 +5,7 @@ import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; public interface NotiAdminRepository extends JpaRepository, NotiAdminRepositoryCustom { diff --git a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustom.java b/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustom.java index fd886f9e4..be72cbda7 100644 --- a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustom.java +++ b/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustom.java @@ -4,7 +4,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.repository.query.Param; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; public interface NotiAdminRepositoryCustom { diff --git a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustomImpl.java b/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustomImpl.java index 6460fd8fa..0184554e4 100644 --- a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustomImpl.java +++ b/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustomImpl.java @@ -8,7 +8,7 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/noti/dto/NotiAdminDto.java b/src/main/java/com/gg/server/admin/noti/dto/NotiAdminDto.java index 77e4e32f4..25ac5fa5b 100644 --- a/src/main/java/com/gg/server/admin/noti/dto/NotiAdminDto.java +++ b/src/main/java/com/gg/server/admin/noti/dto/NotiAdminDto.java @@ -3,8 +3,8 @@ import java.time.LocalDateTime; import java.util.Objects; -import com.gg.server.domain.noti.data.Noti; -import com.gg.server.domain.noti.type.NotiType; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.noti.type.NotiType; import lombok.AccessLevel; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java b/src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java index bd42beac2..8c7d73828 100644 --- a/src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java +++ b/src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java @@ -10,10 +10,10 @@ import com.gg.server.admin.noti.dto.NotiListAdminResponseDto; import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.noti.type.NotiType; +import com.gg.server.data.user.User; import com.gg.server.domain.noti.service.SnsNotiService; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; diff --git a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepository.java b/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepository.java index 32ee9fa0d..0be9061ef 100644 --- a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepository.java +++ b/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepository.java @@ -2,7 +2,7 @@ import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.pchange.data.PChange; +import com.gg.server.data.game.PChange; public interface PChangeAdminRepository extends JpaRepository, PChangeAdminRepositoryCustom { } diff --git a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustom.java b/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustom.java index 0cbdf1f02..3e298204b 100644 --- a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustom.java +++ b/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustom.java @@ -2,7 +2,7 @@ import java.util.List; -import com.gg.server.domain.pchange.data.PChange; +import com.gg.server.data.game.PChange; public interface PChangeAdminRepositoryCustom { List findByTeamUser(Long userId); diff --git a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustomImpl.java b/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustomImpl.java index 4aacf7474..25c2dbe8d 100644 --- a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustomImpl.java +++ b/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustomImpl.java @@ -5,7 +5,7 @@ import javax.persistence.EntityManager; import javax.persistence.LockModeType; -import com.gg.server.domain.pchange.data.PChange; +import com.gg.server.data.game.PChange; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepository.java b/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepository.java index da1980ae2..49873c42a 100644 --- a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepository.java +++ b/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepository.java @@ -10,7 +10,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.domain.penalty.data.Penalty; +import com.gg.server.data.manage.Penalty; public interface PenaltyAdminRepository extends JpaRepository, PenaltyAdminRepositoryCustom { @EntityGraph(attributePaths = {"user"}) diff --git a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustom.java b/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustom.java index f0b843ad7..11da5b328 100644 --- a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustom.java +++ b/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustom.java @@ -5,7 +5,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import com.gg.server.domain.penalty.data.Penalty; +import com.gg.server.data.manage.Penalty; public interface PenaltyAdminRepositoryCustom { Page findAllCurrent(Pageable pageable, LocalDateTime targetTime); diff --git a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustomImpl.java b/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustomImpl.java index 14b778331..22121bbc5 100644 --- a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustomImpl.java +++ b/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustomImpl.java @@ -9,7 +9,7 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import com.gg.server.domain.penalty.data.Penalty; +import com.gg.server.data.manage.Penalty; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/penalty/data/PenaltyUserAdminRedisRepository.java b/src/main/java/com/gg/server/admin/penalty/data/PenaltyUserAdminRedisRepository.java index 45f56531f..0f6b08333 100644 --- a/src/main/java/com/gg/server/admin/penalty/data/PenaltyUserAdminRedisRepository.java +++ b/src/main/java/com/gg/server/admin/penalty/data/PenaltyUserAdminRedisRepository.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Repository; import com.gg.server.admin.penalty.type.PenaltyKey; -import com.gg.server.domain.penalty.redis.RedisPenaltyUser; +import com.gg.server.data.manage.redis.RedisPenaltyUser; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/penalty/dto/PenaltyUserResponseDto.java b/src/main/java/com/gg/server/admin/penalty/dto/PenaltyUserResponseDto.java index e3f6e75a4..0e3e1aac0 100644 --- a/src/main/java/com/gg/server/admin/penalty/dto/PenaltyUserResponseDto.java +++ b/src/main/java/com/gg/server/admin/penalty/dto/PenaltyUserResponseDto.java @@ -2,8 +2,8 @@ import java.time.LocalDateTime; -import com.gg.server.domain.penalty.data.Penalty; -import com.gg.server.domain.penalty.redis.RedisPenaltyUser; +import com.gg.server.data.manage.Penalty; +import com.gg.server.data.manage.redis.RedisPenaltyUser; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java b/src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java index 0b1947870..9fc0a9d12 100644 --- a/src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java +++ b/src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java @@ -13,13 +13,13 @@ import com.gg.server.admin.penalty.data.PenaltyUserAdminRedisRepository; import com.gg.server.admin.penalty.dto.PenaltyListResponseDto; import com.gg.server.admin.penalty.dto.PenaltyUserResponseDto; -import com.gg.server.domain.penalty.data.Penalty; +import com.gg.server.data.manage.Penalty; +import com.gg.server.data.manage.redis.RedisPenaltyUser; +import com.gg.server.data.user.User; import com.gg.server.domain.penalty.exception.PenaltyExpiredException; import com.gg.server.domain.penalty.exception.PenaltyNotFoundException; import com.gg.server.domain.penalty.exception.RedisPenaltyUserNotFoundException; -import com.gg.server.domain.penalty.redis.RedisPenaltyUser; import com.gg.server.domain.penalty.type.PenaltyType; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.service.UserFindService; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/rank/service/RankAdminService.java b/src/main/java/com/gg/server/admin/rank/service/RankAdminService.java index 999d6df11..18ea1ad87 100644 --- a/src/main/java/com/gg/server/admin/rank/service/RankAdminService.java +++ b/src/main/java/com/gg/server/admin/rank/service/RankAdminService.java @@ -1,6 +1,6 @@ package com.gg.server.admin.rank.service; -import static com.gg.server.domain.user.type.RoleType.*; +import static com.gg.server.data.user.type.RoleType.*; import java.time.LocalDateTime; import java.util.ArrayList; @@ -11,16 +11,16 @@ import com.gg.server.admin.season.dto.SeasonAdminDto; import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.domain.rank.data.Rank; +import com.gg.server.data.game.Rank; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Tier; +import com.gg.server.data.user.User; import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.data.SeasonRepository; import com.gg.server.domain.season.exception.SeasonForbiddenException; import com.gg.server.domain.season.exception.SeasonTimeBeforeException; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.User; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/rank/service/RankRedisAdminService.java b/src/main/java/com/gg/server/admin/rank/service/RankRedisAdminService.java index 02ebb98b2..e1be5d898 100644 --- a/src/main/java/com/gg/server/admin/rank/service/RankRedisAdminService.java +++ b/src/main/java/com/gg/server/admin/rank/service/RankRedisAdminService.java @@ -1,6 +1,6 @@ package com.gg.server.admin.rank.service; -import static com.gg.server.domain.user.type.RoleType.*; +import static com.gg.server.data.user.type.RoleType.*; import java.util.List; @@ -8,13 +8,13 @@ import org.springframework.transaction.annotation.Transactional; import com.gg.server.admin.season.dto.SeasonAdminDto; -import com.gg.server.domain.rank.redis.RankRedis; +import com.gg.server.data.game.Tier; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.user.User; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; diff --git a/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepository.java b/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepository.java index 2e0d0879c..072208f6f 100644 --- a/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepository.java +++ b/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepository.java @@ -4,7 +4,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.receipt.data.Receipt; +import com.gg.server.data.store.Receipt; public interface ReceiptAdminRepository extends JpaRepository, ReceiptAdminRepositorySearch { Page findAll(Pageable pageable); diff --git a/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepositorySearch.java b/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepositorySearch.java index 2c3a3b218..8a837de74 100644 --- a/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepositorySearch.java +++ b/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepositorySearch.java @@ -5,7 +5,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.domain.receipt.data.Receipt; +import com.gg.server.data.store.Receipt; public interface ReceiptAdminRepositorySearch { @Query(value = "select re from Receipt re where re.purchaserIntraId = :intraId or re.ownerIntraId = :intraId") diff --git a/src/main/java/com/gg/server/admin/receipt/dto/ReceiptResponseDto.java b/src/main/java/com/gg/server/admin/receipt/dto/ReceiptResponseDto.java index a10d2b0c3..1946bfa11 100644 --- a/src/main/java/com/gg/server/admin/receipt/dto/ReceiptResponseDto.java +++ b/src/main/java/com/gg/server/admin/receipt/dto/ReceiptResponseDto.java @@ -2,9 +2,9 @@ import java.time.LocalDateTime; -import com.gg.server.domain.item.data.Item; -import com.gg.server.domain.receipt.data.Receipt; -import com.gg.server.domain.receipt.type.ItemStatus; +import com.gg.server.data.store.Item; +import com.gg.server.data.store.Receipt; +import com.gg.server.data.store.type.ItemStatus; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java b/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java index 0d397c701..8c93e1f91 100644 --- a/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java +++ b/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java @@ -8,7 +8,7 @@ import com.gg.server.admin.receipt.data.ReceiptAdminRepository; import com.gg.server.admin.receipt.dto.ReceiptListResponseDto; import com.gg.server.admin.receipt.dto.ReceiptResponseDto; -import com.gg.server.domain.receipt.data.Receipt; +import com.gg.server.data.store.Receipt; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java b/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java index 0f3a8b28b..7dc837025 100644 --- a/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java +++ b/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java @@ -8,7 +8,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.domain.season.data.Season; +import com.gg.server.data.game.Season; public interface SeasonAdminRepository extends JpaRepository { /* 입력시간과 모드로 입력시간 이후 가장 가까운 시즌 가져오기 */ diff --git a/src/main/java/com/gg/server/admin/season/dto/SeasonAdminDto.java b/src/main/java/com/gg/server/admin/season/dto/SeasonAdminDto.java index 1db9a9e24..32e7fedc4 100644 --- a/src/main/java/com/gg/server/admin/season/dto/SeasonAdminDto.java +++ b/src/main/java/com/gg/server/admin/season/dto/SeasonAdminDto.java @@ -3,7 +3,7 @@ import java.time.LocalDateTime; import com.gg.server.admin.season.type.SeasonStatus; -import com.gg.server.domain.season.data.Season; +import com.gg.server.data.game.Season; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java b/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java index 7bb99bb12..1314e95b9 100644 --- a/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java +++ b/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java @@ -13,7 +13,7 @@ import com.gg.server.admin.season.dto.SeasonAdminDto; import com.gg.server.admin.season.dto.SeasonCreateRequestDto; import com.gg.server.admin.season.dto.SeasonUpdateRequestDto; -import com.gg.server.domain.season.data.Season; +import com.gg.server.data.game.Season; import com.gg.server.domain.season.exception.SeasonForbiddenException; import com.gg.server.domain.season.exception.SeasonNotFoundException; import com.gg.server.domain.season.exception.SeasonTimeBeforeException; diff --git a/src/main/java/com/gg/server/admin/team/data/TeamAdminRepository.java b/src/main/java/com/gg/server/admin/team/data/TeamAdminRepository.java index d16b8fa2c..da251ac04 100644 --- a/src/main/java/com/gg/server/admin/team/data/TeamAdminRepository.java +++ b/src/main/java/com/gg/server/admin/team/data/TeamAdminRepository.java @@ -4,8 +4,8 @@ import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.team.data.Team; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Team; public interface TeamAdminRepository extends JpaRepository { List findAllByGame(Game game); diff --git a/src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java b/src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java index 088988a63..ab0a71d0a 100644 --- a/src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java +++ b/src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java @@ -6,8 +6,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.user.User; public interface TeamUserAdminRepository extends JpaRepository { @Query("SELECT tu.user FROM TeamUser tu WHERE tu.team.id = :teamId") diff --git a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminCreateRequestDto.java b/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminCreateRequestDto.java index 8b7d81955..699351c7f 100644 --- a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminCreateRequestDto.java +++ b/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminCreateRequestDto.java @@ -7,7 +7,7 @@ import org.hibernate.validator.constraints.Length; import org.springframework.format.annotation.DateTimeFormat; -import com.gg.server.domain.tournament.type.TournamentType; +import com.gg.server.data.game.type.TournamentType; import lombok.AccessLevel; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminUpdateRequestDto.java b/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminUpdateRequestDto.java index 127c8565f..46d22ecc7 100644 --- a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminUpdateRequestDto.java +++ b/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminUpdateRequestDto.java @@ -10,7 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat.ISO; -import com.gg.server.domain.tournament.type.TournamentType; +import com.gg.server.data.game.type.TournamentType; import lombok.AccessLevel; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java b/src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java index ae219f476..4d6c9666b 100644 --- a/src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java +++ b/src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java @@ -1,6 +1,6 @@ package com.gg.server.admin.tournament.service; -import static com.gg.server.domain.match.type.TournamentMatchStatus.*; +import static com.gg.server.data.match.type.TournamentMatchStatus.*; import java.time.LocalDate; import java.time.LocalDateTime; @@ -15,32 +15,32 @@ import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; import com.gg.server.admin.tournament.dto.TournamentGameUpdateRequestDto; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Team; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.TournamentUser; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.game.type.TournamentRound; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.match.type.TournamentMatchStatus; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.exception.ScoreNotInvalidException; import com.gg.server.domain.game.service.GameService; -import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.match.exception.SlotNotFoundException; import com.gg.server.domain.match.service.MatchTournamentService; -import com.gg.server.domain.match.type.TournamentMatchStatus; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.data.Team; -import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.data.TournamentGameRepository; import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.data.TournamentUser; import com.gg.server.domain.tournament.data.TournamentUserRepository; import com.gg.server.domain.tournament.dto.TournamentUserListResponseDto; import com.gg.server.domain.tournament.exception.TournamentConflictException; import com.gg.server.domain.tournament.exception.TournamentGameNotFoundException; import com.gg.server.domain.tournament.exception.TournamentNotFoundException; import com.gg.server.domain.tournament.exception.TournamentUpdateException; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.exception.UserNotFoundException; import com.gg.server.global.config.ConstantConfig; diff --git a/src/main/java/com/gg/server/admin/user/data/UserAdminRepository.java b/src/main/java/com/gg/server/admin/user/data/UserAdminRepository.java index d30e731cf..cdd9f8eaf 100644 --- a/src/main/java/com/gg/server/admin/user/data/UserAdminRepository.java +++ b/src/main/java/com/gg/server/admin/user/data/UserAdminRepository.java @@ -6,7 +6,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.user.User; public interface UserAdminRepository extends JpaRepository { Optional findByIntraId(String intraId); diff --git a/src/main/java/com/gg/server/admin/user/data/UserImageAdminRepository.java b/src/main/java/com/gg/server/admin/user/data/UserImageAdminRepository.java index e9f29e54a..3a523b7d1 100644 --- a/src/main/java/com/gg/server/admin/user/data/UserImageAdminRepository.java +++ b/src/main/java/com/gg/server/admin/user/data/UserImageAdminRepository.java @@ -8,8 +8,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserImage; +import com.gg.server.data.user.User; +import com.gg.server.data.user.UserImage; public interface UserImageAdminRepository extends JpaRepository { Optional findTopByUserAndIsCurrentIsTrueOrderByCreatedAtDesc(User user); diff --git a/src/main/java/com/gg/server/admin/user/dto/UserAdminDto.java b/src/main/java/com/gg/server/admin/user/dto/UserAdminDto.java index f60d19503..b22c3c891 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserAdminDto.java +++ b/src/main/java/com/gg/server/admin/user/dto/UserAdminDto.java @@ -1,10 +1,10 @@ package com.gg.server.admin.user.dto; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserImage; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.UserImage; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/user/dto/UserDetailAdminResponseDto.java b/src/main/java/com/gg/server/admin/user/dto/UserDetailAdminResponseDto.java index 071e21e02..9dc762736 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserDetailAdminResponseDto.java +++ b/src/main/java/com/gg/server/admin/user/dto/UserDetailAdminResponseDto.java @@ -1,7 +1,7 @@ package com.gg.server.admin.user.dto; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.user.User; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/user/dto/UserImageAdminDto.java b/src/main/java/com/gg/server/admin/user/dto/UserImageAdminDto.java index ad3cefba5..13c00c082 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserImageAdminDto.java +++ b/src/main/java/com/gg/server/admin/user/dto/UserImageAdminDto.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import com.gg.server.domain.user.data.UserImage; +import com.gg.server.data.user.UserImage; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminDto.java b/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminDto.java index 6ec679b84..535010e5d 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminDto.java +++ b/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminDto.java @@ -1,7 +1,7 @@ package com.gg.server.admin.user.dto; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RoleType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RoleType; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/user/dto/UserUpdateAdminRequestDto.java b/src/main/java/com/gg/server/admin/user/dto/UserUpdateAdminRequestDto.java index e96db7aaa..f5cfbde79 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserUpdateAdminRequestDto.java +++ b/src/main/java/com/gg/server/admin/user/dto/UserUpdateAdminRequestDto.java @@ -1,6 +1,6 @@ package com.gg.server.admin.user.dto; -import com.gg.server.domain.user.type.RacketType; +import com.gg.server.data.user.type.RacketType; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/user/service/UserAdminService.java b/src/main/java/com/gg/server/admin/user/service/UserAdminService.java index 2f0043728..9b99edacb 100644 --- a/src/main/java/com/gg/server/admin/user/service/UserAdminService.java +++ b/src/main/java/com/gg/server/admin/user/service/UserAdminService.java @@ -21,17 +21,17 @@ import com.gg.server.admin.user.dto.UserSearchAdminDto; import com.gg.server.admin.user.dto.UserSearchAdminResponseDto; import com.gg.server.admin.user.dto.UserUpdateAdminRequestDto; -import com.gg.server.domain.rank.data.Rank; +import com.gg.server.data.game.Rank; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.user.User; +import com.gg.server.data.user.UserImage; import com.gg.server.domain.rank.data.RankRepository; import com.gg.server.domain.rank.exception.RankNotFoundException; import com.gg.server.domain.rank.exception.RedisDataNotFoundException; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.exception.SeasonNotFoundException; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserImage; import com.gg.server.domain.user.exception.UserNotFoundException; import com.gg.server.domain.user.service.UserFindService; import com.gg.server.global.utils.aws.AsyncNewUserImageUploader; diff --git a/src/main/java/com/gg/server/domain/game/data/Game.java b/src/main/java/com/gg/server/data/game/Game.java similarity index 92% rename from src/main/java/com/gg/server/domain/game/data/Game.java rename to src/main/java/com/gg/server/data/game/Game.java index bd978277e..828962177 100644 --- a/src/main/java/com/gg/server/domain/game/data/Game.java +++ b/src/main/java/com/gg/server/data/game/Game.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game.data; +package com.gg.server.data.game; import java.time.LocalDateTime; import java.util.ArrayList; @@ -20,11 +20,9 @@ import org.hibernate.annotations.DynamicUpdate; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; import com.gg.server.domain.match.dto.GameAddDto; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.team.data.Team; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.utils.BusinessChecker; diff --git a/src/main/java/com/gg/server/domain/pchange/data/PChange.java b/src/main/java/com/gg/server/data/game/PChange.java similarity index 92% rename from src/main/java/com/gg/server/domain/pchange/data/PChange.java rename to src/main/java/com/gg/server/data/game/PChange.java index cf6bc3811..662d9dc94 100644 --- a/src/main/java/com/gg/server/domain/pchange/data/PChange.java +++ b/src/main/java/com/gg/server/data/game/PChange.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.pchange.data; +package com.gg.server.data.game; import javax.persistence.Column; import javax.persistence.Entity; @@ -10,8 +10,7 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.user.User; import com.gg.server.global.utils.BaseTimeEntity; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/rank/data/Rank.java b/src/main/java/com/gg/server/data/game/Rank.java similarity index 93% rename from src/main/java/com/gg/server/domain/rank/data/Rank.java rename to src/main/java/com/gg/server/data/game/Rank.java index d40b40bb0..a52d9bc26 100644 --- a/src/main/java/com/gg/server/domain/rank/data/Rank.java +++ b/src/main/java/com/gg/server/data/game/Rank.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.data; +package com.gg.server.data.game; import java.io.Serializable; @@ -16,9 +16,7 @@ import org.hibernate.annotations.DynamicUpdate; import com.gg.server.admin.user.dto.UserUpdateAdminRequestDto; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.tier.data.Tier; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.user.User; import com.gg.server.global.utils.BaseTimeEntity; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/season/data/Season.java b/src/main/java/com/gg/server/data/game/Season.java similarity index 97% rename from src/main/java/com/gg/server/domain/season/data/Season.java rename to src/main/java/com/gg/server/data/game/Season.java index 27f4c8ac0..0b8beb164 100644 --- a/src/main/java/com/gg/server/domain/season/data/Season.java +++ b/src/main/java/com/gg/server/data/game/Season.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.season.data; +package com.gg.server.data.game; import java.time.LocalDateTime; diff --git a/src/main/java/com/gg/server/domain/team/data/Team.java b/src/main/java/com/gg/server/data/game/Team.java similarity index 95% rename from src/main/java/com/gg/server/domain/team/data/Team.java rename to src/main/java/com/gg/server/data/game/Team.java index 225c41e39..53e0ee928 100644 --- a/src/main/java/com/gg/server/domain/team/data/Team.java +++ b/src/main/java/com/gg/server/data/game/Team.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.team.data; +package com.gg.server.data.game; import java.util.ArrayList; import java.util.List; @@ -17,7 +17,6 @@ import org.hibernate.annotations.DynamicUpdate; -import com.gg.server.domain.game.data.Game; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.utils.BusinessChecker; diff --git a/src/main/java/com/gg/server/domain/team/data/TeamUser.java b/src/main/java/com/gg/server/data/game/TeamUser.java similarity index 93% rename from src/main/java/com/gg/server/domain/team/data/TeamUser.java rename to src/main/java/com/gg/server/data/game/TeamUser.java index 08cc3c63b..ab44ccaec 100644 --- a/src/main/java/com/gg/server/domain/team/data/TeamUser.java +++ b/src/main/java/com/gg/server/data/game/TeamUser.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.team.data; +package com.gg.server.data.game; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -9,7 +9,7 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.user.User; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.utils.BusinessChecker; diff --git a/src/main/java/com/gg/server/domain/tier/data/Tier.java b/src/main/java/com/gg/server/data/game/Tier.java similarity index 94% rename from src/main/java/com/gg/server/domain/tier/data/Tier.java rename to src/main/java/com/gg/server/data/game/Tier.java index f18205386..5b934c6da 100644 --- a/src/main/java/com/gg/server/domain/tier/data/Tier.java +++ b/src/main/java/com/gg/server/data/game/Tier.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tier.data; +package com.gg.server.data.game; import java.io.Serializable; diff --git a/src/main/java/com/gg/server/domain/tournament/data/Tournament.java b/src/main/java/com/gg/server/data/game/Tournament.java similarity index 95% rename from src/main/java/com/gg/server/domain/tournament/data/Tournament.java rename to src/main/java/com/gg/server/data/game/Tournament.java index 811d51434..0f46a52eb 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/Tournament.java +++ b/src/main/java/com/gg/server/data/game/Tournament.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.data; +package com.gg.server.data.game; import static com.gg.server.global.exception.ErrorCode.*; import static com.gg.server.global.utils.BusinessChecker.*; @@ -22,9 +22,9 @@ import javax.persistence.OneToOne; import javax.validation.constraints.NotNull; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; +import com.gg.server.data.user.User; import com.gg.server.global.utils.BaseTimeEntity; import lombok.AccessLevel; diff --git a/src/main/java/com/gg/server/domain/tournament/data/TournamentGame.java b/src/main/java/com/gg/server/data/game/TournamentGame.java similarity index 91% rename from src/main/java/com/gg/server/domain/tournament/data/TournamentGame.java rename to src/main/java/com/gg/server/data/game/TournamentGame.java index 22886c0c4..014c32744 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/TournamentGame.java +++ b/src/main/java/com/gg/server/data/game/TournamentGame.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.data; +package com.gg.server.data.game; import javax.persistence.Column; import javax.persistence.Entity; @@ -13,8 +13,7 @@ import javax.persistence.OneToOne; import javax.validation.constraints.NotNull; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.tournament.type.TournamentRound; +import com.gg.server.data.game.type.TournamentRound; import com.gg.server.global.utils.BaseTimeEntity; import lombok.AccessLevel; diff --git a/src/main/java/com/gg/server/domain/tournament/data/TournamentUser.java b/src/main/java/com/gg/server/data/game/TournamentUser.java similarity index 94% rename from src/main/java/com/gg/server/domain/tournament/data/TournamentUser.java rename to src/main/java/com/gg/server/data/game/TournamentUser.java index 3b8679f17..6ec35100b 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/TournamentUser.java +++ b/src/main/java/com/gg/server/data/game/TournamentUser.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.data; +package com.gg.server.data.game; import java.time.LocalDateTime; @@ -12,7 +12,7 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.user.User; import com.gg.server.global.utils.BaseTimeEntity; import lombok.AccessLevel; diff --git a/src/main/java/com/gg/server/domain/rank/redis/RankRedis.java b/src/main/java/com/gg/server/data/game/redis/RankRedis.java similarity index 96% rename from src/main/java/com/gg/server/domain/rank/redis/RankRedis.java rename to src/main/java/com/gg/server/data/game/redis/RankRedis.java index 8f00453f4..43b53e62b 100644 --- a/src/main/java/com/gg/server/domain/rank/redis/RankRedis.java +++ b/src/main/java/com/gg/server/data/game/redis/RankRedis.java @@ -1,10 +1,10 @@ -package com.gg.server.domain.rank.redis; +package com.gg.server.data.game.redis; import java.io.Serializable; import org.springframework.data.redis.core.RedisHash; -import com.gg.server.domain.rank.data.Rank; +import com.gg.server.data.game.Rank; import com.gg.server.domain.user.dto.UserDto; import lombok.AccessLevel; diff --git a/src/main/java/com/gg/server/domain/game/type/Mode.java b/src/main/java/com/gg/server/data/game/type/Mode.java similarity index 88% rename from src/main/java/com/gg/server/domain/game/type/Mode.java rename to src/main/java/com/gg/server/data/game/type/Mode.java index 9445a3377..d6893b381 100644 --- a/src/main/java/com/gg/server/domain/game/type/Mode.java +++ b/src/main/java/com/gg/server/data/game/type/Mode.java @@ -1,11 +1,11 @@ -package com.gg.server.domain.game.type; +package com.gg.server.data.game.type; import java.util.List; import java.util.Locale; import com.fasterxml.jackson.annotation.JsonCreator; -import com.gg.server.domain.match.data.RedisMatchUser; -import com.gg.server.domain.match.type.Option; +import com.gg.server.data.match.RedisMatchUser; +import com.gg.server.data.match.type.Option; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/tournament/type/RoundNumber.java b/src/main/java/com/gg/server/data/game/type/RoundNumber.java similarity index 84% rename from src/main/java/com/gg/server/domain/tournament/type/RoundNumber.java rename to src/main/java/com/gg/server/data/game/type/RoundNumber.java index 417793582..f940fab96 100644 --- a/src/main/java/com/gg/server/domain/tournament/type/RoundNumber.java +++ b/src/main/java/com/gg/server/data/game/type/RoundNumber.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.type; +package com.gg.server.data.game.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/game/type/StatusType.java b/src/main/java/com/gg/server/data/game/type/StatusType.java similarity index 94% rename from src/main/java/com/gg/server/domain/game/type/StatusType.java rename to src/main/java/com/gg/server/data/game/type/StatusType.java index 5ba5b094d..f16dbe702 100644 --- a/src/main/java/com/gg/server/domain/game/type/StatusType.java +++ b/src/main/java/com/gg/server/data/game/type/StatusType.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game.type; +package com.gg.server.data.game.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/domain/tournament/type/TournamentRound.java b/src/main/java/com/gg/server/data/game/type/TournamentRound.java similarity index 93% rename from src/main/java/com/gg/server/domain/tournament/type/TournamentRound.java rename to src/main/java/com/gg/server/data/game/type/TournamentRound.java index 6b09aefba..33a969f87 100644 --- a/src/main/java/com/gg/server/domain/tournament/type/TournamentRound.java +++ b/src/main/java/com/gg/server/data/game/type/TournamentRound.java @@ -1,6 +1,6 @@ -package com.gg.server.domain.tournament.type; +package com.gg.server.data.game.type; -import static com.gg.server.domain.tournament.type.RoundNumber.*; +import static com.gg.server.data.game.type.RoundNumber.*; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/gg/server/domain/tournament/type/TournamentStatus.java b/src/main/java/com/gg/server/data/game/type/TournamentStatus.java similarity index 94% rename from src/main/java/com/gg/server/domain/tournament/type/TournamentStatus.java rename to src/main/java/com/gg/server/data/game/type/TournamentStatus.java index df0d2360c..327310b06 100644 --- a/src/main/java/com/gg/server/domain/tournament/type/TournamentStatus.java +++ b/src/main/java/com/gg/server/data/game/type/TournamentStatus.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.type; +package com.gg.server.data.game.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/domain/tournament/type/TournamentType.java b/src/main/java/com/gg/server/data/game/type/TournamentType.java similarity index 93% rename from src/main/java/com/gg/server/domain/tournament/type/TournamentType.java rename to src/main/java/com/gg/server/data/game/type/TournamentType.java index 7bfd1d923..17ed4a069 100644 --- a/src/main/java/com/gg/server/domain/tournament/type/TournamentType.java +++ b/src/main/java/com/gg/server/data/game/type/TournamentType.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.type; +package com.gg.server.data.game.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/domain/tournament/type/TournamentUserStatus.java b/src/main/java/com/gg/server/data/game/type/TournamentUserStatus.java similarity index 87% rename from src/main/java/com/gg/server/domain/tournament/type/TournamentUserStatus.java rename to src/main/java/com/gg/server/data/game/type/TournamentUserStatus.java index 931ba307a..95778ad02 100644 --- a/src/main/java/com/gg/server/domain/tournament/type/TournamentUserStatus.java +++ b/src/main/java/com/gg/server/data/game/type/TournamentUserStatus.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.type; +package com.gg.server.data.game.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/announcement/data/Announcement.java b/src/main/java/com/gg/server/data/manage/Announcement.java similarity index 96% rename from src/main/java/com/gg/server/domain/announcement/data/Announcement.java rename to src/main/java/com/gg/server/data/manage/Announcement.java index b960f8285..538f13350 100644 --- a/src/main/java/com/gg/server/domain/announcement/data/Announcement.java +++ b/src/main/java/com/gg/server/data/manage/Announcement.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.announcement.data; +package com.gg.server.data.manage; import java.time.LocalDateTime; diff --git a/src/main/java/com/gg/server/domain/coin/data/CoinPolicy.java b/src/main/java/com/gg/server/data/manage/CoinPolicy.java similarity index 95% rename from src/main/java/com/gg/server/domain/coin/data/CoinPolicy.java rename to src/main/java/com/gg/server/data/manage/CoinPolicy.java index fd895fb16..74a745692 100644 --- a/src/main/java/com/gg/server/domain/coin/data/CoinPolicy.java +++ b/src/main/java/com/gg/server/data/manage/CoinPolicy.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.coin.data; +package com.gg.server.data.manage; import java.time.LocalDateTime; @@ -14,7 +14,7 @@ import org.springframework.data.annotation.CreatedDate; import com.gg.server.admin.coin.dto.CoinPolicyAdminAddDto; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.user.User; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/com/gg/server/domain/feedback/data/Feedback.java b/src/main/java/com/gg/server/data/manage/Feedback.java similarity index 89% rename from src/main/java/com/gg/server/domain/feedback/data/Feedback.java rename to src/main/java/com/gg/server/data/manage/Feedback.java index d50e55350..4e31e3568 100644 --- a/src/main/java/com/gg/server/domain/feedback/data/Feedback.java +++ b/src/main/java/com/gg/server/data/manage/Feedback.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.feedback.data; +package com.gg.server.data.manage; import javax.persistence.Column; import javax.persistence.Entity; @@ -12,8 +12,8 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.domain.feedback.type.FeedbackType; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.manage.type.FeedbackType; +import com.gg.server.data.user.User; import com.gg.server.global.utils.BaseTimeEntity; import lombok.Builder; diff --git a/src/main/java/com/gg/server/domain/penalty/data/Penalty.java b/src/main/java/com/gg/server/data/manage/Penalty.java similarity index 94% rename from src/main/java/com/gg/server/domain/penalty/data/Penalty.java rename to src/main/java/com/gg/server/data/manage/Penalty.java index 566cc7494..69582fcb9 100644 --- a/src/main/java/com/gg/server/domain/penalty/data/Penalty.java +++ b/src/main/java/com/gg/server/data/manage/Penalty.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.penalty.data; +package com.gg.server.data.manage; import java.time.LocalDateTime; @@ -14,8 +14,8 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; +import com.gg.server.data.user.User; import com.gg.server.domain.penalty.type.PenaltyType; -import com.gg.server.domain.user.data.User; import com.gg.server.global.utils.BaseTimeEntity; import lombok.AccessLevel; diff --git a/src/main/java/com/gg/server/domain/penalty/redis/RedisPenaltyUser.java b/src/main/java/com/gg/server/data/manage/redis/RedisPenaltyUser.java similarity index 96% rename from src/main/java/com/gg/server/domain/penalty/redis/RedisPenaltyUser.java rename to src/main/java/com/gg/server/data/manage/redis/RedisPenaltyUser.java index a688fb428..7fb8848b1 100644 --- a/src/main/java/com/gg/server/domain/penalty/redis/RedisPenaltyUser.java +++ b/src/main/java/com/gg/server/data/manage/redis/RedisPenaltyUser.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.penalty.redis; +package com.gg.server.data.manage.redis; import java.time.LocalDateTime; diff --git a/src/main/java/com/gg/server/domain/feedback/type/FeedbackType.java b/src/main/java/com/gg/server/data/manage/type/FeedbackType.java similarity index 93% rename from src/main/java/com/gg/server/domain/feedback/type/FeedbackType.java rename to src/main/java/com/gg/server/data/manage/type/FeedbackType.java index 4d792bdd3..2a1437538 100644 --- a/src/main/java/com/gg/server/domain/feedback/type/FeedbackType.java +++ b/src/main/java/com/gg/server/data/manage/type/FeedbackType.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.feedback.type; +package com.gg.server.data.manage.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/domain/match/data/RedisMatchTime.java b/src/main/java/com/gg/server/data/match/RedisMatchTime.java similarity index 91% rename from src/main/java/com/gg/server/domain/match/data/RedisMatchTime.java rename to src/main/java/com/gg/server/data/match/RedisMatchTime.java index ed3b7d068..35227c83d 100644 --- a/src/main/java/com/gg/server/domain/match/data/RedisMatchTime.java +++ b/src/main/java/com/gg/server/data/match/RedisMatchTime.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.data; +package com.gg.server.data.match; import java.io.Serializable; import java.time.LocalDateTime; @@ -11,7 +11,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import com.gg.server.domain.match.type.Option; +import com.gg.server.data.match.type.Option; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/match/data/RedisMatchUser.java b/src/main/java/com/gg/server/data/match/RedisMatchUser.java similarity index 86% rename from src/main/java/com/gg/server/domain/match/data/RedisMatchUser.java rename to src/main/java/com/gg/server/data/match/RedisMatchUser.java index 1e9f71af3..ee4714587 100644 --- a/src/main/java/com/gg/server/domain/match/data/RedisMatchUser.java +++ b/src/main/java/com/gg/server/data/match/RedisMatchUser.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.data; +package com.gg.server.data.match; import java.io.Serializable; @@ -6,7 +6,7 @@ import org.springframework.data.redis.core.RedisHash; -import com.gg.server.domain.match.type.Option; +import com.gg.server.data.match.type.Option; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/match/type/MatchKey.java b/src/main/java/com/gg/server/data/match/type/MatchKey.java similarity index 93% rename from src/main/java/com/gg/server/domain/match/type/MatchKey.java rename to src/main/java/com/gg/server/data/match/type/MatchKey.java index eb9899f9b..786e219b2 100644 --- a/src/main/java/com/gg/server/domain/match/type/MatchKey.java +++ b/src/main/java/com/gg/server/data/match/type/MatchKey.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.type; +package com.gg.server.data.match.type; import java.time.LocalDateTime; diff --git a/src/main/java/com/gg/server/domain/match/type/Option.java b/src/main/java/com/gg/server/data/match/type/Option.java similarity index 95% rename from src/main/java/com/gg/server/domain/match/type/Option.java rename to src/main/java/com/gg/server/data/match/type/Option.java index c4afa31ea..53134baaa 100644 --- a/src/main/java/com/gg/server/domain/match/type/Option.java +++ b/src/main/java/com/gg/server/data/match/type/Option.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.type; +package com.gg.server.data.match.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/domain/match/type/SlotStatus.java b/src/main/java/com/gg/server/data/match/type/SlotStatus.java similarity index 93% rename from src/main/java/com/gg/server/domain/match/type/SlotStatus.java rename to src/main/java/com/gg/server/data/match/type/SlotStatus.java index 4dce03a4f..6160212d1 100644 --- a/src/main/java/com/gg/server/domain/match/type/SlotStatus.java +++ b/src/main/java/com/gg/server/data/match/type/SlotStatus.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.type; +package com.gg.server.data.match.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/domain/match/type/TournamentMatchStatus.java b/src/main/java/com/gg/server/data/match/type/TournamentMatchStatus.java similarity index 91% rename from src/main/java/com/gg/server/domain/match/type/TournamentMatchStatus.java rename to src/main/java/com/gg/server/data/match/type/TournamentMatchStatus.java index 166dbda6f..62e37d112 100644 --- a/src/main/java/com/gg/server/domain/match/type/TournamentMatchStatus.java +++ b/src/main/java/com/gg/server/data/match/type/TournamentMatchStatus.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.type; +package com.gg.server.data.match.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/noti/data/Noti.java b/src/main/java/com/gg/server/data/noti/Noti.java similarity index 91% rename from src/main/java/com/gg/server/domain/noti/data/Noti.java rename to src/main/java/com/gg/server/data/noti/Noti.java index dab870760..ae37bad76 100644 --- a/src/main/java/com/gg/server/domain/noti/data/Noti.java +++ b/src/main/java/com/gg/server/data/noti/Noti.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.noti.data; +package com.gg.server.data.noti; import javax.persistence.Column; import javax.persistence.Entity; @@ -12,8 +12,8 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.noti.type.NotiType; +import com.gg.server.data.user.User; import com.gg.server.global.utils.BaseTimeEntity; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/noti/type/NotiType.java b/src/main/java/com/gg/server/data/noti/type/NotiType.java similarity index 97% rename from src/main/java/com/gg/server/domain/noti/type/NotiType.java rename to src/main/java/com/gg/server/data/noti/type/NotiType.java index a74fe2bfb..ee831b11e 100644 --- a/src/main/java/com/gg/server/domain/noti/type/NotiType.java +++ b/src/main/java/com/gg/server/data/noti/type/NotiType.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.noti.type; +package com.gg.server.data.noti.type; import java.util.Arrays; import java.util.Locale; diff --git a/src/main/java/com/gg/server/domain/coin/data/CoinHistory.java b/src/main/java/com/gg/server/data/store/CoinHistory.java similarity index 93% rename from src/main/java/com/gg/server/domain/coin/data/CoinHistory.java rename to src/main/java/com/gg/server/data/store/CoinHistory.java index cbaa82680..b8ffa6c9b 100644 --- a/src/main/java/com/gg/server/domain/coin/data/CoinHistory.java +++ b/src/main/java/com/gg/server/data/store/CoinHistory.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.coin.data; +package com.gg.server.data.store; import java.time.LocalDateTime; @@ -13,7 +13,7 @@ import org.springframework.data.annotation.CreatedDate; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.user.User; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/item/data/Item.java b/src/main/java/com/gg/server/data/store/Item.java similarity index 97% rename from src/main/java/com/gg/server/domain/item/data/Item.java rename to src/main/java/com/gg/server/data/store/Item.java index 6f5e5a56b..6717955f9 100644 --- a/src/main/java/com/gg/server/domain/item/data/Item.java +++ b/src/main/java/com/gg/server/data/store/Item.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.item.data; +package com.gg.server.data.store; import java.time.LocalDateTime; @@ -12,7 +12,7 @@ import javax.validation.constraints.NotNull; import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.domain.item.type.ItemType; +import com.gg.server.data.store.type.ItemType; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/megaphone/data/Megaphone.java b/src/main/java/com/gg/server/data/store/Megaphone.java similarity index 89% rename from src/main/java/com/gg/server/domain/megaphone/data/Megaphone.java rename to src/main/java/com/gg/server/data/store/Megaphone.java index 2ed2d0247..989cb7cd4 100644 --- a/src/main/java/com/gg/server/domain/megaphone/data/Megaphone.java +++ b/src/main/java/com/gg/server/data/store/Megaphone.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.megaphone.data; +package com.gg.server.data.store; import java.time.LocalDate; @@ -12,8 +12,7 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.domain.receipt.data.Receipt; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.user.User; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/receipt/data/Receipt.java b/src/main/java/com/gg/server/data/store/Receipt.java similarity index 92% rename from src/main/java/com/gg/server/domain/receipt/data/Receipt.java rename to src/main/java/com/gg/server/data/store/Receipt.java index f7c1f03a8..b10e4bf9e 100644 --- a/src/main/java/com/gg/server/domain/receipt/data/Receipt.java +++ b/src/main/java/com/gg/server/data/store/Receipt.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.receipt.data; +package com.gg.server.data.store; import java.time.LocalDateTime; @@ -14,8 +14,7 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.domain.item.data.Item; -import com.gg.server.domain.receipt.type.ItemStatus; +import com.gg.server.data.store.type.ItemStatus; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedis.java b/src/main/java/com/gg/server/data/store/redis/MegaphoneRedis.java similarity index 94% rename from src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedis.java rename to src/main/java/com/gg/server/data/store/redis/MegaphoneRedis.java index eed95626c..c498977cc 100644 --- a/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedis.java +++ b/src/main/java/com/gg/server/data/store/redis/MegaphoneRedis.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.megaphone.redis; +package com.gg.server.data.store.redis; import java.time.LocalDateTime; diff --git a/src/main/java/com/gg/server/domain/coin/type/HistoryType.java b/src/main/java/com/gg/server/data/store/type/HistoryType.java similarity index 87% rename from src/main/java/com/gg/server/domain/coin/type/HistoryType.java rename to src/main/java/com/gg/server/data/store/type/HistoryType.java index 3242e6ed9..18305a2dd 100644 --- a/src/main/java/com/gg/server/domain/coin/type/HistoryType.java +++ b/src/main/java/com/gg/server/data/store/type/HistoryType.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.coin.type; +package com.gg.server.data.store.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/receipt/type/ItemStatus.java b/src/main/java/com/gg/server/data/store/type/ItemStatus.java similarity index 86% rename from src/main/java/com/gg/server/domain/receipt/type/ItemStatus.java rename to src/main/java/com/gg/server/data/store/type/ItemStatus.java index fdcae3e08..a75506edb 100644 --- a/src/main/java/com/gg/server/domain/receipt/type/ItemStatus.java +++ b/src/main/java/com/gg/server/data/store/type/ItemStatus.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.receipt.type; +package com.gg.server.data.store.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/item/type/ItemType.java b/src/main/java/com/gg/server/data/store/type/ItemType.java similarity index 78% rename from src/main/java/com/gg/server/domain/item/type/ItemType.java rename to src/main/java/com/gg/server/data/store/type/ItemType.java index 77fd7d812..51583e48d 100644 --- a/src/main/java/com/gg/server/domain/item/type/ItemType.java +++ b/src/main/java/com/gg/server/data/store/type/ItemType.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.item.type; +package com.gg.server.data.store.type; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/data/User.java b/src/main/java/com/gg/server/data/user/User.java similarity index 92% rename from src/main/java/com/gg/server/domain/user/data/User.java rename to src/main/java/com/gg/server/data/user/User.java index 68b77c36a..e05c91946 100644 --- a/src/main/java/com/gg/server/domain/user/data/User.java +++ b/src/main/java/com/gg/server/data/user/User.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.data; +package com.gg.server.data.user; import java.io.Serializable; @@ -14,12 +14,12 @@ import org.hibernate.annotations.DynamicUpdate; import com.gg.server.admin.user.dto.UserUpdateAdminRequestDto; +import com.gg.server.data.user.type.BackgroundType; +import com.gg.server.data.user.type.EdgeType; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.item.exception.InsufficientGgcoinException; -import com.gg.server.domain.user.type.BackgroundType; -import com.gg.server.domain.user.type.EdgeType; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.utils.BaseTimeEntity; import lombok.AccessLevel; diff --git a/src/main/java/com/gg/server/domain/user/data/UserImage.java b/src/main/java/com/gg/server/data/user/UserImage.java similarity index 97% rename from src/main/java/com/gg/server/domain/user/data/UserImage.java rename to src/main/java/com/gg/server/data/user/UserImage.java index 604441701..b798239ea 100644 --- a/src/main/java/com/gg/server/domain/user/data/UserImage.java +++ b/src/main/java/com/gg/server/data/user/UserImage.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.data; +package com.gg.server.data.user; import java.time.LocalDateTime; diff --git a/src/main/java/com/gg/server/domain/user/type/BackgroundType.java b/src/main/java/com/gg/server/data/user/type/BackgroundType.java similarity index 96% rename from src/main/java/com/gg/server/domain/user/type/BackgroundType.java rename to src/main/java/com/gg/server/data/user/type/BackgroundType.java index 67c8b9427..5b790d4ac 100644 --- a/src/main/java/com/gg/server/domain/user/type/BackgroundType.java +++ b/src/main/java/com/gg/server/data/user/type/BackgroundType.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.type; +package com.gg.server.data.user.type; import java.util.Random; diff --git a/src/main/java/com/gg/server/domain/user/type/EdgeType.java b/src/main/java/com/gg/server/data/user/type/EdgeType.java similarity index 96% rename from src/main/java/com/gg/server/domain/user/type/EdgeType.java rename to src/main/java/com/gg/server/data/user/type/EdgeType.java index 744097dfa..4db3159be 100644 --- a/src/main/java/com/gg/server/domain/user/type/EdgeType.java +++ b/src/main/java/com/gg/server/data/user/type/EdgeType.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.type; +package com.gg.server.data.user.type; import java.util.Random; diff --git a/src/main/java/com/gg/server/domain/user/type/OauthType.java b/src/main/java/com/gg/server/data/user/type/OauthType.java similarity index 95% rename from src/main/java/com/gg/server/domain/user/type/OauthType.java rename to src/main/java/com/gg/server/data/user/type/OauthType.java index c1398cfbc..0bfda350b 100644 --- a/src/main/java/com/gg/server/domain/user/type/OauthType.java +++ b/src/main/java/com/gg/server/data/user/type/OauthType.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.type; +package com.gg.server.data.user.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/domain/user/type/RacketType.java b/src/main/java/com/gg/server/data/user/type/RacketType.java similarity index 93% rename from src/main/java/com/gg/server/domain/user/type/RacketType.java rename to src/main/java/com/gg/server/data/user/type/RacketType.java index 6f3aada53..39ca89116 100644 --- a/src/main/java/com/gg/server/domain/user/type/RacketType.java +++ b/src/main/java/com/gg/server/data/user/type/RacketType.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.type; +package com.gg.server.data.user.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/domain/user/type/RoleType.java b/src/main/java/com/gg/server/data/user/type/RoleType.java similarity index 92% rename from src/main/java/com/gg/server/domain/user/type/RoleType.java rename to src/main/java/com/gg/server/data/user/type/RoleType.java index bb525ae39..81382949d 100644 --- a/src/main/java/com/gg/server/domain/user/type/RoleType.java +++ b/src/main/java/com/gg/server/data/user/type/RoleType.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.type; +package com.gg.server.data.user.type; import java.util.Arrays; diff --git a/src/main/java/com/gg/server/domain/user/type/SnsType.java b/src/main/java/com/gg/server/data/user/type/SnsType.java similarity index 91% rename from src/main/java/com/gg/server/domain/user/type/SnsType.java rename to src/main/java/com/gg/server/data/user/type/SnsType.java index 4060f08b1..f04af49a7 100644 --- a/src/main/java/com/gg/server/domain/user/type/SnsType.java +++ b/src/main/java/com/gg/server/data/user/type/SnsType.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.type; +package com.gg.server.data.user.type; import java.util.Arrays; diff --git a/src/main/java/com/gg/server/domain/announcement/data/AnnouncementRepository.java b/src/main/java/com/gg/server/domain/announcement/data/AnnouncementRepository.java index dea9ba727..b992738ef 100644 --- a/src/main/java/com/gg/server/domain/announcement/data/AnnouncementRepository.java +++ b/src/main/java/com/gg/server/domain/announcement/data/AnnouncementRepository.java @@ -4,6 +4,8 @@ import org.springframework.data.jpa.repository.JpaRepository; +import com.gg.server.data.manage.Announcement; + public interface AnnouncementRepository extends JpaRepository { Optional findFirstByOrderByIdDesc(); } diff --git a/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementDto.java b/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementDto.java index d21beae2f..f635584fe 100644 --- a/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementDto.java +++ b/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementDto.java @@ -1,6 +1,6 @@ package com.gg.server.domain.announcement.dto; -import com.gg.server.domain.announcement.data.Announcement; +import com.gg.server.data.manage.Announcement; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java b/src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java index 62e1df9d4..6a10ddaa0 100644 --- a/src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java +++ b/src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java @@ -3,7 +3,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.announcement.data.Announcement; +import com.gg.server.data.manage.Announcement; import com.gg.server.domain.announcement.data.AnnouncementRepository; import com.gg.server.domain.announcement.dto.AnnouncementDto; import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; diff --git a/src/main/java/com/gg/server/domain/coin/data/CoinHistoryRepository.java b/src/main/java/com/gg/server/domain/coin/data/CoinHistoryRepository.java index 956400b60..d1cd63487 100644 --- a/src/main/java/com/gg/server/domain/coin/data/CoinHistoryRepository.java +++ b/src/main/java/com/gg/server/domain/coin/data/CoinHistoryRepository.java @@ -10,7 +10,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.store.CoinHistory; +import com.gg.server.data.user.User; public interface CoinHistoryRepository extends JpaRepository { @Query("SELECT CASE WHEN COUNT(ch) > 0 THEN true ELSE false END FROM CoinHistory ch " diff --git a/src/main/java/com/gg/server/domain/coin/data/CoinPolicyRepository.java b/src/main/java/com/gg/server/domain/coin/data/CoinPolicyRepository.java index f60f7ac7b..0a08de823 100644 --- a/src/main/java/com/gg/server/domain/coin/data/CoinPolicyRepository.java +++ b/src/main/java/com/gg/server/domain/coin/data/CoinPolicyRepository.java @@ -4,6 +4,8 @@ import org.springframework.data.jpa.repository.JpaRepository; +import com.gg.server.data.manage.CoinPolicy; + public interface CoinPolicyRepository extends JpaRepository { Optional findTopByOrderByCreatedAtDesc(); diff --git a/src/main/java/com/gg/server/domain/coin/service/CoinHistoryService.java b/src/main/java/com/gg/server/domain/coin/service/CoinHistoryService.java index 4ae1e109a..50aad0a6d 100644 --- a/src/main/java/com/gg/server/domain/coin/service/CoinHistoryService.java +++ b/src/main/java/com/gg/server/domain/coin/service/CoinHistoryService.java @@ -5,13 +5,13 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.coin.data.CoinHistory; +import com.gg.server.data.store.CoinHistory; +import com.gg.server.data.store.Item; +import com.gg.server.data.store.type.HistoryType; +import com.gg.server.data.user.User; import com.gg.server.domain.coin.data.CoinHistoryRepository; import com.gg.server.domain.coin.data.CoinPolicyRepository; import com.gg.server.domain.coin.exception.CoinPolicyNotFoundException; -import com.gg.server.domain.coin.type.HistoryType; -import com.gg.server.domain.item.data.Item; -import com.gg.server.domain.user.data.User; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/coin/service/UserCoinChangeService.java b/src/main/java/com/gg/server/domain/coin/service/UserCoinChangeService.java index 0e94cc929..81f6c77ee 100644 --- a/src/main/java/com/gg/server/domain/coin/service/UserCoinChangeService.java +++ b/src/main/java/com/gg/server/domain/coin/service/UserCoinChangeService.java @@ -5,14 +5,14 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.gg.server.data.game.Team; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.store.Item; +import com.gg.server.data.user.User; import com.gg.server.domain.coin.data.CoinPolicyRepository; import com.gg.server.domain.coin.dto.UserGameCoinResultDto; import com.gg.server.domain.coin.exception.CoinPolicyNotFoundException; import com.gg.server.domain.game.service.GameFindService; -import com.gg.server.domain.item.data.Item; -import com.gg.server.domain.team.data.Team; -import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.exception.UserAlreadyAttendanceException; import com.gg.server.domain.user.exception.UserNotFoundException; diff --git a/src/main/java/com/gg/server/domain/feedback/data/FeedbackRepository.java b/src/main/java/com/gg/server/domain/feedback/data/FeedbackRepository.java index 615e6a65a..0a8fbd658 100644 --- a/src/main/java/com/gg/server/domain/feedback/data/FeedbackRepository.java +++ b/src/main/java/com/gg/server/domain/feedback/data/FeedbackRepository.java @@ -2,6 +2,8 @@ import org.springframework.data.jpa.repository.JpaRepository; +import com.gg.server.data.manage.Feedback; + public interface FeedbackRepository extends JpaRepository { Feedback findFirstByOrderByIdDesc(); } diff --git a/src/main/java/com/gg/server/domain/feedback/dto/FeedbackRequestDto.java b/src/main/java/com/gg/server/domain/feedback/dto/FeedbackRequestDto.java index ee6e8d6d1..8dfa1ec7a 100644 --- a/src/main/java/com/gg/server/domain/feedback/dto/FeedbackRequestDto.java +++ b/src/main/java/com/gg/server/domain/feedback/dto/FeedbackRequestDto.java @@ -4,7 +4,7 @@ import org.hibernate.validator.constraints.Length; -import com.gg.server.domain.feedback.type.FeedbackType; +import com.gg.server.data.manage.type.FeedbackType; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/feedback/service/FeedbackService.java b/src/main/java/com/gg/server/domain/feedback/service/FeedbackService.java index 028e24d71..6797ab8eb 100644 --- a/src/main/java/com/gg/server/domain/feedback/service/FeedbackService.java +++ b/src/main/java/com/gg/server/domain/feedback/service/FeedbackService.java @@ -3,10 +3,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.feedback.data.Feedback; +import com.gg.server.data.manage.Feedback; +import com.gg.server.data.user.User; import com.gg.server.domain.feedback.data.FeedbackRepository; import com.gg.server.domain.feedback.dto.FeedbackRequestDto; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.exception.UserNotFoundException; diff --git a/src/main/java/com/gg/server/domain/game/GameController.java b/src/main/java/com/gg/server/domain/game/GameController.java index 239125b00..c4b53d163 100644 --- a/src/main/java/com/gg/server/domain/game/GameController.java +++ b/src/main/java/com/gg/server/domain/game/GameController.java @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import com.gg.server.data.game.type.Mode; import com.gg.server.domain.game.dto.GameListResDto; import com.gg.server.domain.game.dto.GamePChangeResultResDto; import com.gg.server.domain.game.dto.GameTeamInfo; @@ -28,7 +29,6 @@ import com.gg.server.domain.game.exception.ScoreNotMatchedException; import com.gg.server.domain.game.service.GameFindService; import com.gg.server.domain.game.service.GameService; -import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.rank.redis.RankRedisService; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.exception.ErrorCode; diff --git a/src/main/java/com/gg/server/domain/game/data/GameRepository.java b/src/main/java/com/gg/server/domain/game/data/GameRepository.java index c6d6cb8cb..745aeea0e 100644 --- a/src/main/java/com/gg/server/domain/game/data/GameRepository.java +++ b/src/main/java/com/gg/server/domain/game/data/GameRepository.java @@ -14,10 +14,11 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; import com.gg.server.domain.game.dto.GameTeamUser; import com.gg.server.domain.game.dto.GameTeamUserInfo; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.team.dto.GameUser; public interface GameRepository extends JpaRepository, GameRepositoryCustom { diff --git a/src/main/java/com/gg/server/domain/game/data/GameRepositoryCustom.java b/src/main/java/com/gg/server/domain/game/data/GameRepositoryCustom.java index 308e47909..d28668aa8 100644 --- a/src/main/java/com/gg/server/domain/game/data/GameRepositoryCustom.java +++ b/src/main/java/com/gg/server/domain/game/data/GameRepositoryCustom.java @@ -2,6 +2,8 @@ import java.util.Optional; +import com.gg.server.data.game.Game; + public interface GameRepositoryCustom { Optional getLatestGameByUser(Long userId); } diff --git a/src/main/java/com/gg/server/domain/game/data/GameRepositoryImpl.java b/src/main/java/com/gg/server/domain/game/data/GameRepositoryImpl.java index a5824571f..b85dbca0d 100644 --- a/src/main/java/com/gg/server/domain/game/data/GameRepositoryImpl.java +++ b/src/main/java/com/gg/server/domain/game/data/GameRepositoryImpl.java @@ -5,7 +5,8 @@ import javax.persistence.EntityManager; import javax.persistence.NoResultException; -import com.gg.server.domain.team.data.TeamUser; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.TeamUser; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/game/dto/GameResultResDto.java b/src/main/java/com/gg/server/domain/game/dto/GameResultResDto.java index 5a537deb4..0e6286273 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GameResultResDto.java +++ b/src/main/java/com/gg/server/domain/game/dto/GameResultResDto.java @@ -7,7 +7,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import com.gg.server.domain.game.type.Mode; +import com.gg.server.data.game.type.Mode; import com.gg.server.domain.team.dto.TeamUserInfoDto; import com.gg.server.domain.team.dto.TeamUserListDto; diff --git a/src/main/java/com/gg/server/domain/game/dto/GameTeamInfo.java b/src/main/java/com/gg/server/domain/game/dto/GameTeamInfo.java index dc6e656c1..05aa98c35 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GameTeamInfo.java +++ b/src/main/java/com/gg/server/domain/game/dto/GameTeamInfo.java @@ -3,9 +3,9 @@ import java.time.LocalDateTime; import java.util.List; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; import com.gg.server.domain.game.exception.GameDataConsistencyException; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.team.dto.MatchTeamsInfoDto; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/game/dto/GameTeamUser.java b/src/main/java/com/gg/server/domain/game/dto/GameTeamUser.java index c94a63db6..b3fb75467 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GameTeamUser.java +++ b/src/main/java/com/gg/server/domain/game/dto/GameTeamUser.java @@ -2,8 +2,8 @@ import java.time.LocalDateTime; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; public interface GameTeamUser { Long getGameId(); diff --git a/src/main/java/com/gg/server/domain/game/dto/GameTeamUserInfo.java b/src/main/java/com/gg/server/domain/game/dto/GameTeamUserInfo.java index d7a71b9dc..bff4af5a0 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GameTeamUserInfo.java +++ b/src/main/java/com/gg/server/domain/game/dto/GameTeamUserInfo.java @@ -2,8 +2,8 @@ import java.time.LocalDateTime; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; public interface GameTeamUserInfo { Long getGameId(); diff --git a/src/main/java/com/gg/server/domain/game/dto/request/GameListReqDto.java b/src/main/java/com/gg/server/domain/game/dto/request/GameListReqDto.java index 60f21069f..330981327 100644 --- a/src/main/java/com/gg/server/domain/game/dto/request/GameListReqDto.java +++ b/src/main/java/com/gg/server/domain/game/dto/request/GameListReqDto.java @@ -1,6 +1,6 @@ package com.gg.server.domain.game.dto.request; -import com.gg.server.domain.game.type.StatusType; +import com.gg.server.data.game.type.StatusType; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/game/service/GameFindService.java b/src/main/java/com/gg/server/domain/game/service/GameFindService.java index da10217ce..6ff9c538a 100644 --- a/src/main/java/com/gg/server/domain/game/service/GameFindService.java +++ b/src/main/java/com/gg/server/domain/game/service/GameFindService.java @@ -10,14 +10,14 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.dto.GameListResDto; import com.gg.server.domain.game.dto.GameResultResDto; import com.gg.server.domain.game.dto.GameTeamUser; import com.gg.server.domain.game.exception.GameNotExistException; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/game/service/GameService.java b/src/main/java/com/gg/server/domain/game/service/GameService.java index 1686ba520..1286fee4f 100644 --- a/src/main/java/com/gg/server/domain/game/service/GameService.java +++ b/src/main/java/com/gg/server/domain/game/service/GameService.java @@ -8,9 +8,17 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.PChange; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.type.RoundNumber; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.match.type.TournamentMatchStatus; import com.gg.server.domain.coin.dto.UserGameCoinResultDto; import com.gg.server.domain.coin.service.UserCoinChangeService; -import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.dto.GamePChangeResultResDto; import com.gg.server.domain.game.dto.GamePPPChangeResultResDto; @@ -22,24 +30,16 @@ import com.gg.server.domain.game.exception.GameNotExistException; import com.gg.server.domain.game.exception.GameStatusNotMatchedException; import com.gg.server.domain.game.exception.ScoreAlreadyEnteredException; -import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.match.service.MatchTournamentService; -import com.gg.server.domain.match.type.TournamentMatchStatus; -import com.gg.server.domain.pchange.data.PChange; import com.gg.server.domain.pchange.data.PChangeRepository; import com.gg.server.domain.pchange.exception.PChangeNotExistException; import com.gg.server.domain.pchange.service.PChangeService; import com.gg.server.domain.rank.redis.RankRedisService; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.team.data.TeamUser; import com.gg.server.domain.team.data.TeamUserRepository; import com.gg.server.domain.team.exception.TeamIdNotMatchException; import com.gg.server.domain.tier.service.TierService; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.data.TournamentGameRepository; import com.gg.server.domain.tournament.exception.TournamentGameNotFoundException; -import com.gg.server.domain.tournament.type.RoundNumber; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.InvalidParameterException; import com.gg.server.global.utils.ExpLevelCalculator; diff --git a/src/main/java/com/gg/server/domain/game/service/GameStatusService.java b/src/main/java/com/gg/server/domain/game/service/GameStatusService.java index 899319685..588d5360c 100644 --- a/src/main/java/com/gg/server/domain/game/service/GameStatusService.java +++ b/src/main/java/com/gg/server/domain/game/service/GameStatusService.java @@ -8,16 +8,16 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.noti.type.NotiType; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.exception.GameDataConsistencyException; -import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.noti.data.Noti; import com.gg.server.domain.noti.dto.UserNotiDto; import com.gg.server.domain.noti.service.NotiService; import com.gg.server.domain.noti.service.SnsNotiService; -import com.gg.server.domain.noti.type.NotiType; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; import com.gg.server.domain.team.dto.GameUser; diff --git a/src/main/java/com/gg/server/domain/item/data/ItemRepository.java b/src/main/java/com/gg/server/domain/item/data/ItemRepository.java index 3623e681c..efcdaffe6 100644 --- a/src/main/java/com/gg/server/domain/item/data/ItemRepository.java +++ b/src/main/java/com/gg/server/domain/item/data/ItemRepository.java @@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import com.gg.server.data.store.Item; + public interface ItemRepository extends JpaRepository { @Query("SELECT i FROM Item i WHERE i.isVisible = true ORDER BY i.createdAt DESC") List findAllByCreatedAtDesc(); diff --git a/src/main/java/com/gg/server/domain/item/data/UserItemRepository.java b/src/main/java/com/gg/server/domain/item/data/UserItemRepository.java index 444594917..2d5c232d4 100644 --- a/src/main/java/com/gg/server/domain/item/data/UserItemRepository.java +++ b/src/main/java/com/gg/server/domain/item/data/UserItemRepository.java @@ -6,7 +6,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.domain.receipt.data.Receipt; +import com.gg.server.data.store.Receipt; public interface UserItemRepository extends JpaRepository { diff --git a/src/main/java/com/gg/server/domain/item/dto/ItemStoreResponseDto.java b/src/main/java/com/gg/server/domain/item/dto/ItemStoreResponseDto.java index fa0b1eb47..fe7f60574 100644 --- a/src/main/java/com/gg/server/domain/item/dto/ItemStoreResponseDto.java +++ b/src/main/java/com/gg/server/domain/item/dto/ItemStoreResponseDto.java @@ -1,7 +1,7 @@ package com.gg.server.domain.item.dto; -import com.gg.server.domain.item.data.Item; -import com.gg.server.domain.item.type.ItemType; +import com.gg.server.data.store.Item; +import com.gg.server.data.store.type.ItemType; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/item/dto/UserItemResponseDto.java b/src/main/java/com/gg/server/domain/item/dto/UserItemResponseDto.java index dbd4e1ca9..2bd814427 100644 --- a/src/main/java/com/gg/server/domain/item/dto/UserItemResponseDto.java +++ b/src/main/java/com/gg/server/domain/item/dto/UserItemResponseDto.java @@ -1,9 +1,9 @@ package com.gg.server.domain.item.dto; -import com.gg.server.domain.item.data.Item; -import com.gg.server.domain.item.type.ItemType; -import com.gg.server.domain.receipt.data.Receipt; -import com.gg.server.domain.receipt.type.ItemStatus; +import com.gg.server.data.store.Item; +import com.gg.server.data.store.Receipt; +import com.gg.server.data.store.type.ItemStatus; +import com.gg.server.data.store.type.ItemType; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/item/service/ItemService.java b/src/main/java/com/gg/server/domain/item/service/ItemService.java index 1dfa3279b..1f7ec7407 100644 --- a/src/main/java/com/gg/server/domain/item/service/ItemService.java +++ b/src/main/java/com/gg/server/domain/item/service/ItemService.java @@ -9,8 +9,13 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.gg.server.data.store.Item; +import com.gg.server.data.store.Receipt; +import com.gg.server.data.store.type.ItemStatus; +import com.gg.server.data.store.type.ItemType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RoleType; import com.gg.server.domain.coin.service.UserCoinChangeService; -import com.gg.server.domain.item.data.Item; import com.gg.server.domain.item.data.ItemRepository; import com.gg.server.domain.item.data.UserItemRepository; import com.gg.server.domain.item.dto.ItemStoreListResponseDto; @@ -22,18 +27,13 @@ import com.gg.server.domain.item.exception.ItemTypeException; import com.gg.server.domain.item.exception.KakaoGiftException; import com.gg.server.domain.item.exception.KakaoPurchaseException; -import com.gg.server.domain.item.type.ItemType; import com.gg.server.domain.noti.service.NotiService; -import com.gg.server.domain.receipt.data.Receipt; import com.gg.server.domain.receipt.data.ReceiptRepository; import com.gg.server.domain.receipt.exception.ItemStatusException; import com.gg.server.domain.receipt.exception.ReceiptNotOwnerException; -import com.gg.server.domain.receipt.type.ItemStatus; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.type.RoleType; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/match/controller/MatchController.java b/src/main/java/com/gg/server/domain/match/controller/MatchController.java index ca93a142a..6955b4494 100644 --- a/src/main/java/com/gg/server/domain/match/controller/MatchController.java +++ b/src/main/java/com/gg/server/domain/match/controller/MatchController.java @@ -15,12 +15,12 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import com.gg.server.data.match.type.Option; import com.gg.server.domain.match.dto.MatchRequestDto; import com.gg.server.domain.match.dto.MatchStatusResponseListDto; import com.gg.server.domain.match.dto.SlotStatusResponseListDto; import com.gg.server.domain.match.service.MatchFindService; import com.gg.server.domain.match.service.MatchService; -import com.gg.server.domain.match.type.Option; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.utils.argumentresolver.Login; diff --git a/src/main/java/com/gg/server/domain/match/data/RedisMatchTimeRepository.java b/src/main/java/com/gg/server/domain/match/data/RedisMatchTimeRepository.java index e8deea3d9..1cc9e49ac 100644 --- a/src/main/java/com/gg/server/domain/match/data/RedisMatchTimeRepository.java +++ b/src/main/java/com/gg/server/domain/match/data/RedisMatchTimeRepository.java @@ -11,7 +11,8 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; -import com.gg.server.domain.match.type.MatchKey; +import com.gg.server.data.match.RedisMatchUser; +import com.gg.server.data.match.type.MatchKey; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/match/data/RedisMatchUserRepository.java b/src/main/java/com/gg/server/domain/match/data/RedisMatchUserRepository.java index 511012a23..a9797bab6 100644 --- a/src/main/java/com/gg/server/domain/match/data/RedisMatchUserRepository.java +++ b/src/main/java/com/gg/server/domain/match/data/RedisMatchUserRepository.java @@ -10,9 +10,10 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; +import com.gg.server.data.match.RedisMatchTime; +import com.gg.server.data.match.type.MatchKey; +import com.gg.server.data.match.type.Option; import com.gg.server.domain.match.exception.PastSlotException; -import com.gg.server.domain.match.type.MatchKey; -import com.gg.server.domain.match.type.Option; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/match/dto/GameAddDto.java b/src/main/java/com/gg/server/domain/match/dto/GameAddDto.java index 1b1d6921f..87053451a 100644 --- a/src/main/java/com/gg/server/domain/match/dto/GameAddDto.java +++ b/src/main/java/com/gg/server/domain/match/dto/GameAddDto.java @@ -3,9 +3,9 @@ import java.time.LocalDateTime; import java.util.List; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.match.data.RedisMatchUser; -import com.gg.server.domain.season.data.Season; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.match.RedisMatchUser; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/match/dto/MatchRequestDto.java b/src/main/java/com/gg/server/domain/match/dto/MatchRequestDto.java index 0207507cb..ccb88fa40 100644 --- a/src/main/java/com/gg/server/domain/match/dto/MatchRequestDto.java +++ b/src/main/java/com/gg/server/domain/match/dto/MatchRequestDto.java @@ -7,7 +7,7 @@ import org.springframework.format.annotation.DateTimeFormat; import com.fasterxml.jackson.annotation.JsonProperty; -import com.gg.server.domain.match.type.Option; +import com.gg.server.data.match.type.Option; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/match/dto/MatchStatusDto.java b/src/main/java/com/gg/server/domain/match/dto/MatchStatusDto.java index 5a423fce7..f7b9b4e39 100644 --- a/src/main/java/com/gg/server/domain/match/dto/MatchStatusDto.java +++ b/src/main/java/com/gg/server/domain/match/dto/MatchStatusDto.java @@ -4,9 +4,9 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonFormat; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.match.data.RedisMatchTime; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.match.RedisMatchTime; import com.gg.server.domain.slotmanagement.SlotManagement; import lombok.AccessLevel; diff --git a/src/main/java/com/gg/server/domain/match/dto/SlotStatusDto.java b/src/main/java/com/gg/server/domain/match/dto/SlotStatusDto.java index 52af02224..73ac51cb2 100644 --- a/src/main/java/com/gg/server/domain/match/dto/SlotStatusDto.java +++ b/src/main/java/com/gg/server/domain/match/dto/SlotStatusDto.java @@ -3,7 +3,7 @@ import java.time.LocalDateTime; import com.fasterxml.jackson.annotation.JsonFormat; -import com.gg.server.domain.match.type.SlotStatus; +import com.gg.server.data.match.type.SlotStatus; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/match/service/GameUpdateService.java b/src/main/java/com/gg/server/domain/match/service/GameUpdateService.java index 66142ac21..1a737f55e 100644 --- a/src/main/java/com/gg/server/domain/match/service/GameUpdateService.java +++ b/src/main/java/com/gg/server/domain/match/service/GameUpdateService.java @@ -5,20 +5,20 @@ import org.springframework.stereotype.Service; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Team; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.match.dto.GameAddDto; import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.noti.data.Noti; import com.gg.server.domain.noti.service.NotiService; import com.gg.server.domain.noti.service.SnsNotiService; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.data.Team; import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUser; import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; diff --git a/src/main/java/com/gg/server/domain/match/service/MatchFindService.java b/src/main/java/com/gg/server/domain/match/service/MatchFindService.java index 7cd274edc..8e5e4d0c7 100644 --- a/src/main/java/com/gg/server/domain/match/service/MatchFindService.java +++ b/src/main/java/com/gg/server/domain/match/service/MatchFindService.java @@ -10,33 +10,33 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Tier; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.match.RedisMatchTime; +import com.gg.server.data.match.RedisMatchUser; +import com.gg.server.data.match.type.Option; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RoleType; import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.match.data.RedisMatchTime; import com.gg.server.domain.match.data.RedisMatchTimeRepository; -import com.gg.server.domain.match.data.RedisMatchUser; import com.gg.server.domain.match.data.RedisMatchUserRepository; import com.gg.server.domain.match.dto.MatchStatusDto; import com.gg.server.domain.match.dto.MatchStatusResponseListDto; import com.gg.server.domain.match.dto.SlotStatusResponseListDto; import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.match.type.Option; import com.gg.server.domain.match.utils.SlotGenerator; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.service.SeasonFindService; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.type.RoleType; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/match/service/MatchService.java b/src/main/java/com/gg/server/domain/match/service/MatchService.java index 6e87a1775..08cb83ed6 100644 --- a/src/main/java/com/gg/server/domain/match/service/MatchService.java +++ b/src/main/java/com/gg/server/domain/match/service/MatchService.java @@ -9,34 +9,34 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.match.RedisMatchTime; +import com.gg.server.data.match.RedisMatchUser; +import com.gg.server.data.match.type.Option; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.exception.GameAlreadyExistException; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.match.data.RedisMatchTime; import com.gg.server.domain.match.data.RedisMatchTimeRepository; -import com.gg.server.domain.match.data.RedisMatchUser; import com.gg.server.domain.match.data.RedisMatchUserRepository; import com.gg.server.domain.match.dto.GameAddDto; import com.gg.server.domain.match.exception.EnrolledSlotException; import com.gg.server.domain.match.exception.PenaltyUserSlotException; import com.gg.server.domain.match.exception.SlotCountException; import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.match.type.Option; import com.gg.server.domain.match.utils.MatchCalculator; import com.gg.server.domain.penalty.service.PenaltyService; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.service.SeasonFindService; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tournament.data.Tournament; import com.gg.server.domain.tournament.data.TournamentRepository; import com.gg.server.domain.tournament.exception.TournamentConflictException; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; diff --git a/src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java b/src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java index 6c412dcbd..f06526ed0 100644 --- a/src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java +++ b/src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java @@ -1,7 +1,7 @@ package com.gg.server.domain.match.service; -import static com.gg.server.domain.match.type.TournamentMatchStatus.*; -import static com.gg.server.domain.tournament.type.RoundNumber.*; +import static com.gg.server.data.game.type.RoundNumber.*; +import static com.gg.server.data.match.type.TournamentMatchStatus.*; import java.time.LocalDateTime; import java.util.ArrayList; @@ -18,31 +18,31 @@ import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; import com.gg.server.admin.noti.service.NotiAdminService; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Team; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.TournamentUser; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.RoundNumber; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.game.type.TournamentRound; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.match.type.TournamentMatchStatus; +import com.gg.server.data.noti.type.NotiType; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.match.exception.EnrolledSlotException; import com.gg.server.domain.match.exception.LosingTeamNotFoundException; import com.gg.server.domain.match.exception.SlotNotFoundException; import com.gg.server.domain.match.exception.WinningTeamNotFoundException; -import com.gg.server.domain.match.type.TournamentMatchStatus; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.service.SeasonFindService; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.data.Team; -import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.data.TournamentGameRepository; -import com.gg.server.domain.tournament.data.TournamentUser; import com.gg.server.domain.tournament.exception.TournamentGameNotFoundException; -import com.gg.server.domain.tournament.type.RoundNumber; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.user.data.User; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/match/utils/MatchCalculator.java b/src/main/java/com/gg/server/domain/match/utils/MatchCalculator.java index 8d9a08af8..0c100f3da 100644 --- a/src/main/java/com/gg/server/domain/match/utils/MatchCalculator.java +++ b/src/main/java/com/gg/server/domain/match/utils/MatchCalculator.java @@ -3,9 +3,9 @@ import java.util.List; import java.util.Optional; -import com.gg.server.domain.match.data.RedisMatchUser; -import com.gg.server.domain.match.type.Option; -import com.gg.server.domain.match.type.SlotStatus; +import com.gg.server.data.match.RedisMatchUser; +import com.gg.server.data.match.type.Option; +import com.gg.server.data.match.type.SlotStatus; public class MatchCalculator { private final Integer pppGap; diff --git a/src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java b/src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java index d1210791a..a30fd96fe 100644 --- a/src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java +++ b/src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java @@ -6,16 +6,16 @@ import java.util.List; import java.util.Set; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.match.data.RedisMatchTime; -import com.gg.server.domain.match.data.RedisMatchUser; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.match.RedisMatchTime; +import com.gg.server.data.match.RedisMatchUser; +import com.gg.server.data.match.type.Option; +import com.gg.server.data.match.type.SlotStatus; import com.gg.server.domain.match.dto.SlotStatusDto; import com.gg.server.domain.match.dto.SlotStatusResponseListDto; -import com.gg.server.domain.match.type.Option; -import com.gg.server.domain.match.type.SlotStatus; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.slotmanagement.SlotManagement; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/megaphone/data/MegaphoneRepository.java b/src/main/java/com/gg/server/domain/megaphone/data/MegaphoneRepository.java index 39d42c843..04c2fe49b 100644 --- a/src/main/java/com/gg/server/domain/megaphone/data/MegaphoneRepository.java +++ b/src/main/java/com/gg/server/domain/megaphone/data/MegaphoneRepository.java @@ -6,8 +6,9 @@ import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.receipt.data.Receipt; -import com.gg.server.domain.receipt.type.ItemStatus; +import com.gg.server.data.store.Megaphone; +import com.gg.server.data.store.Receipt; +import com.gg.server.data.store.type.ItemStatus; public interface MegaphoneRepository extends JpaRepository { List findAllByUsedAtAndReceiptStatus(LocalDate date, ItemStatus itemStatus); diff --git a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneDetailResponseDto.java b/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneDetailResponseDto.java index e3247796f..5c2a227ef 100644 --- a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneDetailResponseDto.java +++ b/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneDetailResponseDto.java @@ -1,6 +1,6 @@ package com.gg.server.domain.megaphone.dto; -import com.gg.server.domain.megaphone.data.Megaphone; +import com.gg.server.data.store.Megaphone; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneTodayListResponseDto.java b/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneTodayListResponseDto.java index fec51363e..7eff7d867 100644 --- a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneTodayListResponseDto.java +++ b/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneTodayListResponseDto.java @@ -1,6 +1,6 @@ package com.gg.server.domain.megaphone.dto; -import com.gg.server.domain.megaphone.redis.MegaphoneRedis; +import com.gg.server.data.store.redis.MegaphoneRedis; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedisRepository.java b/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedisRepository.java index 55517bdfc..2c19c57aa 100644 --- a/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedisRepository.java +++ b/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedisRepository.java @@ -6,6 +6,8 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; +import com.gg.server.data.store.redis.MegaphoneRedis; + import lombok.RequiredArgsConstructor; @Repository diff --git a/src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java b/src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java index c9f7e0942..8180d2a5e 100644 --- a/src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java +++ b/src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java @@ -9,10 +9,15 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.gg.server.data.store.Megaphone; +import com.gg.server.data.store.Receipt; +import com.gg.server.data.store.redis.MegaphoneRedis; +import com.gg.server.data.store.type.ItemStatus; +import com.gg.server.data.store.type.ItemType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RoleType; import com.gg.server.domain.item.exception.ItemTypeException; import com.gg.server.domain.item.service.ItemService; -import com.gg.server.domain.item.type.ItemType; -import com.gg.server.domain.megaphone.data.Megaphone; import com.gg.server.domain.megaphone.data.MegaphoneRepository; import com.gg.server.domain.megaphone.dto.MegaphoneDetailResponseDto; import com.gg.server.domain.megaphone.dto.MegaphoneTodayListResponseDto; @@ -20,19 +25,14 @@ import com.gg.server.domain.megaphone.exception.MegaphoneContentException; import com.gg.server.domain.megaphone.exception.MegaphoneNotFoundException; import com.gg.server.domain.megaphone.exception.MegaphoneTimeException; -import com.gg.server.domain.megaphone.redis.MegaphoneRedis; import com.gg.server.domain.megaphone.redis.MegaphoneRedisRepository; -import com.gg.server.domain.receipt.data.Receipt; import com.gg.server.domain.receipt.data.ReceiptRepository; import com.gg.server.domain.receipt.exception.ItemStatusException; import com.gg.server.domain.receipt.exception.ReceiptNotFoundException; import com.gg.server.domain.receipt.exception.ReceiptNotOwnerException; -import com.gg.server.domain.receipt.type.ItemStatus; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.type.RoleType; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/noti/data/NotiRepository.java b/src/main/java/com/gg/server/domain/noti/data/NotiRepository.java index a25a6ff95..a104720e8 100644 --- a/src/main/java/com/gg/server/domain/noti/data/NotiRepository.java +++ b/src/main/java/com/gg/server/domain/noti/data/NotiRepository.java @@ -5,7 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.user.User; public interface NotiRepository extends JpaRepository, NotiRepositoryCustom { List findByUser(User user); diff --git a/src/main/java/com/gg/server/domain/noti/dto/NotiDto.java b/src/main/java/com/gg/server/domain/noti/dto/NotiDto.java index 38a38dbc2..70ceddcdc 100644 --- a/src/main/java/com/gg/server/domain/noti/dto/NotiDto.java +++ b/src/main/java/com/gg/server/domain/noti/dto/NotiDto.java @@ -3,8 +3,8 @@ import java.time.LocalDateTime; import java.util.Objects; -import com.gg.server.domain.noti.data.Noti; -import com.gg.server.domain.noti.type.NotiType; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.noti.type.NotiType; import com.gg.server.domain.user.dto.UserDto; import lombok.Builder; diff --git a/src/main/java/com/gg/server/domain/noti/dto/NotiResponseDto.java b/src/main/java/com/gg/server/domain/noti/dto/NotiResponseDto.java index 0a9425f38..3a64213be 100644 --- a/src/main/java/com/gg/server/domain/noti/dto/NotiResponseDto.java +++ b/src/main/java/com/gg/server/domain/noti/dto/NotiResponseDto.java @@ -3,8 +3,8 @@ import java.time.LocalDateTime; import java.util.Objects; -import com.gg.server.domain.noti.data.Noti; -import com.gg.server.domain.noti.type.NotiType; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.noti.type.NotiType; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/com/gg/server/domain/noti/dto/UserNotiDto.java b/src/main/java/com/gg/server/domain/noti/dto/UserNotiDto.java index 4c9c2b78e..d7f004f4c 100644 --- a/src/main/java/com/gg/server/domain/noti/dto/UserNotiDto.java +++ b/src/main/java/com/gg/server/domain/noti/dto/UserNotiDto.java @@ -1,7 +1,7 @@ package com.gg.server.domain.noti.dto; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.team.dto.GameUser; -import com.gg.server.domain.user.type.SnsType; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/noti/service/NotiService.java b/src/main/java/com/gg/server/domain/noti/service/NotiService.java index 6ad3dc340..56d3ee8c8 100644 --- a/src/main/java/com/gg/server/domain/noti/service/NotiService.java +++ b/src/main/java/com/gg/server/domain/noti/service/NotiService.java @@ -8,12 +8,12 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.noti.type.NotiType; +import com.gg.server.data.user.User; import com.gg.server.domain.noti.data.NotiRepository; import com.gg.server.domain.noti.dto.NotiDto; import com.gg.server.domain.noti.dto.NotiResponseDto; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; diff --git a/src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java b/src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java index e0b0cc0ae..f63ec95fd 100644 --- a/src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java +++ b/src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java @@ -3,12 +3,12 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.noti.dto.UserNotiDto; import com.gg.server.domain.noti.service.sns.NotiMailSender; import com.gg.server.domain.noti.service.sns.SlackbotService; import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.type.SnsType; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java b/src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java index cf441c614..e801211d1 100644 --- a/src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java +++ b/src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java @@ -7,7 +7,7 @@ import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.stereotype.Component; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; import com.gg.server.domain.noti.dto.UserNotiDto; import com.gg.server.domain.noti.service.NotiService; import com.gg.server.domain.user.dto.UserDto; diff --git a/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java b/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java index 8f3985b9d..414f40293 100644 --- a/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java +++ b/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java @@ -21,7 +21,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; import com.gg.server.domain.noti.dto.UserNotiDto; import com.gg.server.domain.noti.exception.SlackJsonParseException; import com.gg.server.domain.noti.exception.SlackSendException; diff --git a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepository.java b/src/main/java/com/gg/server/domain/pchange/data/PChangeRepository.java index 9cb907299..6057f6a66 100644 --- a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepository.java +++ b/src/main/java/com/gg/server/domain/pchange/data/PChangeRepository.java @@ -7,7 +7,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.domain.game.type.Mode; +import com.gg.server.data.game.PChange; +import com.gg.server.data.game.type.Mode; public interface PChangeRepository extends JpaRepository, PChangeRepositoryCustom { diff --git a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryCustom.java b/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryCustom.java index 0b2bff37b..c3fd6bdb3 100644 --- a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryCustom.java +++ b/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryCustom.java @@ -2,6 +2,8 @@ import java.util.List; +import com.gg.server.data.game.PChange; + public interface PChangeRepositoryCustom { List findPChangesHistory(String intraId, Long seasonId); diff --git a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryImpl.java b/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryImpl.java index ad51b95ed..2360120b0 100644 --- a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryImpl.java +++ b/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryImpl.java @@ -6,6 +6,8 @@ import org.springframework.stereotype.Repository; +import com.gg.server.data.game.PChange; + import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/gg/server/domain/pchange/service/PChangeService.java b/src/main/java/com/gg/server/domain/pchange/service/PChangeService.java index 01fbe9c02..0bd9ca4e4 100644 --- a/src/main/java/com/gg/server/domain/pchange/service/PChangeService.java +++ b/src/main/java/com/gg/server/domain/pchange/service/PChangeService.java @@ -5,11 +5,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.pchange.data.PChange; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.PChange; +import com.gg.server.data.user.User; import com.gg.server.domain.pchange.data.PChangeRepository; import com.gg.server.domain.pchange.exception.PChangeNotExistException; -import com.gg.server.domain.user.data.User; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/penalty/data/PenaltyRepository.java b/src/main/java/com/gg/server/domain/penalty/data/PenaltyRepository.java index 69efc952f..13940f9cf 100644 --- a/src/main/java/com/gg/server/domain/penalty/data/PenaltyRepository.java +++ b/src/main/java/com/gg/server/domain/penalty/data/PenaltyRepository.java @@ -2,6 +2,8 @@ import org.springframework.data.jpa.repository.JpaRepository; +import com.gg.server.data.manage.Penalty; + public interface PenaltyRepository extends JpaRepository { } diff --git a/src/main/java/com/gg/server/domain/penalty/redis/PenaltyUserRedisRepository.java b/src/main/java/com/gg/server/domain/penalty/redis/PenaltyUserRedisRepository.java index 986aee9f9..4054d6edb 100644 --- a/src/main/java/com/gg/server/domain/penalty/redis/PenaltyUserRedisRepository.java +++ b/src/main/java/com/gg/server/domain/penalty/redis/PenaltyUserRedisRepository.java @@ -9,6 +9,7 @@ import org.springframework.stereotype.Repository; import com.gg.server.admin.penalty.type.PenaltyKey; +import com.gg.server.data.manage.redis.RedisPenaltyUser; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/penalty/service/PenaltyService.java b/src/main/java/com/gg/server/domain/penalty/service/PenaltyService.java index 1d6ea1280..a8f293b64 100644 --- a/src/main/java/com/gg/server/domain/penalty/service/PenaltyService.java +++ b/src/main/java/com/gg/server/domain/penalty/service/PenaltyService.java @@ -5,12 +5,12 @@ import org.springframework.stereotype.Service; -import com.gg.server.domain.penalty.data.Penalty; +import com.gg.server.data.manage.Penalty; +import com.gg.server.data.manage.redis.RedisPenaltyUser; +import com.gg.server.data.user.User; import com.gg.server.domain.penalty.data.PenaltyRepository; import com.gg.server.domain.penalty.redis.PenaltyUserRedisRepository; -import com.gg.server.domain.penalty.redis.RedisPenaltyUser; import com.gg.server.domain.penalty.type.PenaltyType; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.service.UserFindService; diff --git a/src/main/java/com/gg/server/domain/rank/data/RankRepository.java b/src/main/java/com/gg/server/domain/rank/data/RankRepository.java index 90ac36dff..f698d1424 100644 --- a/src/main/java/com/gg/server/domain/rank/data/RankRepository.java +++ b/src/main/java/com/gg/server/domain/rank/data/RankRepository.java @@ -10,6 +10,7 @@ import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import com.gg.server.data.game.Rank; import com.gg.server.domain.rank.dto.RankV2Dto; @Repository diff --git a/src/main/java/com/gg/server/domain/rank/dto/ExpRankDto.java b/src/main/java/com/gg/server/domain/rank/dto/ExpRankDto.java index e60833a81..711748bdc 100644 --- a/src/main/java/com/gg/server/domain/rank/dto/ExpRankDto.java +++ b/src/main/java/com/gg/server/domain/rank/dto/ExpRankDto.java @@ -1,6 +1,6 @@ package com.gg.server.domain.rank.dto; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.user.User; import com.gg.server.global.utils.ExpLevelCalculator; import lombok.AccessLevel; diff --git a/src/main/java/com/gg/server/domain/rank/dto/RankDto.java b/src/main/java/com/gg/server/domain/rank/dto/RankDto.java index 626361002..095619da8 100644 --- a/src/main/java/com/gg/server/domain/rank/dto/RankDto.java +++ b/src/main/java/com/gg/server/domain/rank/dto/RankDto.java @@ -1,7 +1,7 @@ package com.gg.server.domain.rank.dto; -import com.gg.server.domain.rank.redis.RankRedis; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.user.User; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/com/gg/server/domain/rank/redis/RankRedisRepository.java b/src/main/java/com/gg/server/domain/rank/redis/RankRedisRepository.java index 80911b2a7..29df5cb90 100644 --- a/src/main/java/com/gg/server/domain/rank/redis/RankRedisRepository.java +++ b/src/main/java/com/gg/server/domain/rank/redis/RankRedisRepository.java @@ -10,6 +10,7 @@ import org.springframework.data.redis.core.ZSetOperations; import org.springframework.stereotype.Repository; +import com.gg.server.data.game.redis.RankRedis; import com.gg.server.domain.rank.exception.RedisDataNotFoundException; @Repository diff --git a/src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java b/src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java index d3009187a..71f490a72 100644 --- a/src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java +++ b/src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java @@ -8,15 +8,16 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Rank; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.game.Tier; +import com.gg.server.data.game.redis.RankRedis; import com.gg.server.domain.pchange.service.PChangeService; -import com.gg.server.domain.rank.data.Rank; import com.gg.server.domain.rank.data.RankRepository; import com.gg.server.domain.rank.exception.RankNotFoundException; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.NotExistException; diff --git a/src/main/java/com/gg/server/domain/rank/service/RankFindService.java b/src/main/java/com/gg/server/domain/rank/service/RankFindService.java index d71e2aa95..df217917d 100644 --- a/src/main/java/com/gg/server/domain/rank/service/RankFindService.java +++ b/src/main/java/com/gg/server/domain/rank/service/RankFindService.java @@ -2,7 +2,7 @@ import org.springframework.stereotype.Service; -import com.gg.server.domain.rank.data.Rank; +import com.gg.server.data.game.Rank; import com.gg.server.domain.rank.data.RankRepository; import com.gg.server.domain.rank.exception.RankNotFoundException; diff --git a/src/main/java/com/gg/server/domain/rank/service/RankService.java b/src/main/java/com/gg/server/domain/rank/service/RankService.java index bdad84a73..ba32cdc54 100644 --- a/src/main/java/com/gg/server/domain/rank/service/RankService.java +++ b/src/main/java/com/gg/server/domain/rank/service/RankService.java @@ -11,6 +11,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.user.User; import com.gg.server.domain.rank.data.RankRepository; import com.gg.server.domain.rank.dto.ExpRankDto; import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; @@ -18,12 +21,9 @@ import com.gg.server.domain.rank.dto.RankDto; import com.gg.server.domain.rank.dto.RankPageResponseDto; import com.gg.server.domain.rank.exception.RedisDataNotFoundException; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; diff --git a/src/main/java/com/gg/server/domain/rank/service/RedisUploadService.java b/src/main/java/com/gg/server/domain/rank/service/RedisUploadService.java index 19a6c2a02..d5d2e3940 100644 --- a/src/main/java/com/gg/server/domain/rank/service/RedisUploadService.java +++ b/src/main/java/com/gg/server/domain/rank/service/RedisUploadService.java @@ -10,8 +10,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.gg.server.data.game.redis.RankRedis; import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; import com.gg.server.domain.season.data.SeasonRepository; diff --git a/src/main/java/com/gg/server/domain/receipt/data/ReceiptRepository.java b/src/main/java/com/gg/server/domain/receipt/data/ReceiptRepository.java index 22463618d..a21621f09 100644 --- a/src/main/java/com/gg/server/domain/receipt/data/ReceiptRepository.java +++ b/src/main/java/com/gg/server/domain/receipt/data/ReceiptRepository.java @@ -2,5 +2,7 @@ import org.springframework.data.jpa.repository.JpaRepository; +import com.gg.server.data.store.Receipt; + public interface ReceiptRepository extends JpaRepository { } diff --git a/src/main/java/com/gg/server/domain/season/data/SeasonRepository.java b/src/main/java/com/gg/server/domain/season/data/SeasonRepository.java index 39833da0a..1ba8b10ff 100644 --- a/src/main/java/com/gg/server/domain/season/data/SeasonRepository.java +++ b/src/main/java/com/gg/server/domain/season/data/SeasonRepository.java @@ -8,6 +8,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import com.gg.server.data.game.Season; + public interface SeasonRepository extends JpaRepository { @Query("select s from Season s where s.startTime <= :now and s.endTime >= :now") Optional findCurrentSeason(@Param("now") LocalDateTime now); diff --git a/src/main/java/com/gg/server/domain/season/dto/CurSeason.java b/src/main/java/com/gg/server/domain/season/dto/CurSeason.java index 2cc8dbe50..d47bc28a8 100644 --- a/src/main/java/com/gg/server/domain/season/dto/CurSeason.java +++ b/src/main/java/com/gg/server/domain/season/dto/CurSeason.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import com.gg.server.domain.season.data.Season; +import com.gg.server.data.game.Season; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/season/dto/SeasonResDto.java b/src/main/java/com/gg/server/domain/season/dto/SeasonResDto.java index c36cc03cf..a1f4d5352 100644 --- a/src/main/java/com/gg/server/domain/season/dto/SeasonResDto.java +++ b/src/main/java/com/gg/server/domain/season/dto/SeasonResDto.java @@ -1,6 +1,6 @@ package com.gg.server.domain.season.dto; -import com.gg.server.domain.season.data.Season; +import com.gg.server.data.game.Season; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/season/service/SeasonFindService.java b/src/main/java/com/gg/server/domain/season/service/SeasonFindService.java index 061d6ce62..3e67f0c2a 100644 --- a/src/main/java/com/gg/server/domain/season/service/SeasonFindService.java +++ b/src/main/java/com/gg/server/domain/season/service/SeasonFindService.java @@ -5,10 +5,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.exception.GameNotExistException; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.data.SeasonRepository; import com.gg.server.domain.season.exception.SeasonNotFoundException; diff --git a/src/main/java/com/gg/server/domain/team/data/TeamRepository.java b/src/main/java/com/gg/server/domain/team/data/TeamRepository.java index 483699ebb..83e00226b 100644 --- a/src/main/java/com/gg/server/domain/team/data/TeamRepository.java +++ b/src/main/java/com/gg/server/domain/team/data/TeamRepository.java @@ -6,6 +6,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import com.gg.server.data.game.Team; + public interface TeamRepository extends JpaRepository { @Query("select t from Team t where t.game.id=:gameId") List findAllBy(@Param("gameId") Long gameId); diff --git a/src/main/java/com/gg/server/domain/team/data/TeamUserRepository.java b/src/main/java/com/gg/server/domain/team/data/TeamUserRepository.java index 0c5e67700..bfa8a5dc7 100644 --- a/src/main/java/com/gg/server/domain/team/data/TeamUserRepository.java +++ b/src/main/java/com/gg/server/domain/team/data/TeamUserRepository.java @@ -7,6 +7,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import com.gg.server.data.game.TeamUser; + public interface TeamUserRepository extends JpaRepository { @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) diff --git a/src/main/java/com/gg/server/domain/team/dto/GameUser.java b/src/main/java/com/gg/server/domain/team/dto/GameUser.java index 59dc9a953..d432737b0 100644 --- a/src/main/java/com/gg/server/domain/team/dto/GameUser.java +++ b/src/main/java/com/gg/server/domain/team/dto/GameUser.java @@ -1,6 +1,6 @@ package com.gg.server.domain.team.dto; -import com.gg.server.domain.user.type.SnsType; +import com.gg.server.data.user.type.SnsType; public interface GameUser { Long getGameId(); diff --git a/src/main/java/com/gg/server/domain/tier/data/TierRepository.java b/src/main/java/com/gg/server/domain/tier/data/TierRepository.java index 26f5c9ce2..f1583fdfe 100644 --- a/src/main/java/com/gg/server/domain/tier/data/TierRepository.java +++ b/src/main/java/com/gg/server/domain/tier/data/TierRepository.java @@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import com.gg.server.data.game.Tier; + public interface TierRepository extends JpaRepository { @Query("SELECT t FROM Tier t WHERE t.id = (SELECT MIN(t.id) FROM Tier t)") diff --git a/src/main/java/com/gg/server/domain/tier/service/TierService.java b/src/main/java/com/gg/server/domain/tier/service/TierService.java index 220c5cb7f..59cd0dce4 100644 --- a/src/main/java/com/gg/server/domain/tier/service/TierService.java +++ b/src/main/java/com/gg/server/domain/tier/service/TierService.java @@ -6,10 +6,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.rank.data.Rank; +import com.gg.server.data.game.Rank; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Tier; import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java b/src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java index de8736f01..1d205ca9e 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java +++ b/src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java @@ -5,7 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.tournament.type.TournamentRound; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.type.TournamentRound; public interface TournamentGameRepository extends JpaRepository { List findAllByTournamentId(Long tournamentId); diff --git a/src/main/java/com/gg/server/domain/tournament/data/TournamentRepository.java b/src/main/java/com/gg/server/domain/tournament/data/TournamentRepository.java index 5a85a3a33..839e20930 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/TournamentRepository.java +++ b/src/main/java/com/gg/server/domain/tournament/data/TournamentRepository.java @@ -12,8 +12,9 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; public interface TournamentRepository extends JpaRepository { List findAllByStatusIsNot(TournamentStatus status); diff --git a/src/main/java/com/gg/server/domain/tournament/data/TournamentUserRepository.java b/src/main/java/com/gg/server/domain/tournament/data/TournamentUserRepository.java index 768ebf1b0..1fad69e44 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/TournamentUserRepository.java +++ b/src/main/java/com/gg/server/domain/tournament/data/TournamentUserRepository.java @@ -5,7 +5,9 @@ import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentUser; +import com.gg.server.data.user.User; public interface TournamentUserRepository extends JpaRepository { diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentFilterRequestDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentFilterRequestDto.java index 1307697b1..545001e3c 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentFilterRequestDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentFilterRequestDto.java @@ -1,7 +1,7 @@ package com.gg.server.domain.tournament.dto; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; import com.gg.server.global.dto.PageRequestDto; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameResDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameResDto.java index ec70f4f27..bc3561330 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameResDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameResDto.java @@ -1,9 +1,9 @@ package com.gg.server.domain.tournament.dto; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.type.TournamentRound; import com.gg.server.domain.game.dto.GameResultResDto; import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.tournament.data.TournamentGame; -import com.gg.server.domain.tournament.type.TournamentRound; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java index d64abdbed..74bd2c790 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java @@ -2,10 +2,10 @@ import java.time.LocalDateTime; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentUser; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentUser; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; import com.gg.server.domain.user.dto.UserImageDto; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserListResponseDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserListResponseDto.java index 1ed2c6629..52252302e 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserListResponseDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserListResponseDto.java @@ -4,7 +4,7 @@ import java.util.Comparator; import java.util.List; -import com.gg.server.domain.tournament.data.TournamentUser; +import com.gg.server.data.game.TournamentUser; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserRegistrationResponseDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserRegistrationResponseDto.java index c7c05b683..aeef0ce04 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserRegistrationResponseDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserRegistrationResponseDto.java @@ -1,6 +1,6 @@ package com.gg.server.domain.tournament.dto; -import com.gg.server.domain.tournament.type.TournamentUserStatus; +import com.gg.server.data.game.type.TournamentUserStatus; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserResponseDto.java b/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserResponseDto.java index 4b02bba3e..25cc5a32e 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserResponseDto.java +++ b/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserResponseDto.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import com.gg.server.domain.tournament.data.TournamentUser; +import com.gg.server.data.game.TournamentUser; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java b/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java index 87033c7aa..75ad90484 100644 --- a/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java +++ b/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java @@ -1,6 +1,5 @@ package com.gg.server.domain.tournament.service; -import static com.gg.server.domain.tournament.type.RoundNumber.*; import static java.util.Comparator.*; import java.time.LocalDate; @@ -17,15 +16,21 @@ import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; import com.gg.server.admin.noti.service.NotiAdminService; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.TournamentUser; +import com.gg.server.data.game.type.RoundNumber; +import com.gg.server.data.game.type.TournamentRound; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; +import com.gg.server.data.game.type.TournamentUserStatus; +import com.gg.server.data.noti.type.NotiType; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.dto.GameTeamUser; import com.gg.server.domain.match.service.MatchTournamentService; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.data.TournamentGameRepository; import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.data.TournamentUser; import com.gg.server.domain.tournament.data.TournamentUserRepository; import com.gg.server.domain.tournament.dto.TournamentGameListResponseDto; import com.gg.server.domain.tournament.dto.TournamentGameResDto; @@ -35,11 +40,6 @@ import com.gg.server.domain.tournament.exception.TournamentConflictException; import com.gg.server.domain.tournament.exception.TournamentNotFoundException; import com.gg.server.domain.tournament.exception.TournamentUpdateException; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; -import com.gg.server.domain.tournament.type.TournamentUserStatus; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; @@ -195,7 +195,7 @@ public void startTournament() { continue; } imminentTournament.updateStatus(TournamentStatus.LIVE); - matchTournamentService.matchGames(imminentTournament, QUARTER_FINAL); + matchTournamentService.matchGames(imminentTournament, RoundNumber.QUARTER_FINAL); } } diff --git a/src/main/java/com/gg/server/domain/user/controller/UserController.java b/src/main/java/com/gg/server/domain/user/controller/UserController.java index c4f5ec477..422026503 100644 --- a/src/main/java/com/gg/server/domain/user/controller/UserController.java +++ b/src/main/java/com/gg/server/domain/user/controller/UserController.java @@ -26,7 +26,9 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import com.gg.server.domain.game.type.Mode; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.user.type.OauthType; +import com.gg.server.data.user.type.RoleType; import com.gg.server.domain.user.dto.UserAccessTokenDto; import com.gg.server.domain.user.dto.UserAttendanceResponseDto; import com.gg.server.domain.user.dto.UserBackgroundDto; @@ -49,8 +51,6 @@ import com.gg.server.domain.user.service.UserAuthenticationService; import com.gg.server.domain.user.service.UserCoinService; import com.gg.server.domain.user.service.UserService; -import com.gg.server.domain.user.type.OauthType; -import com.gg.server.domain.user.type.RoleType; import com.gg.server.global.dto.PageRequestDto; import com.gg.server.global.security.cookie.CookieUtil; import com.gg.server.global.security.jwt.utils.TokenHeaders; diff --git a/src/main/java/com/gg/server/domain/user/data/UserImageRepository.java b/src/main/java/com/gg/server/domain/user/data/UserImageRepository.java index 79a0538cd..7e42ca75b 100644 --- a/src/main/java/com/gg/server/domain/user/data/UserImageRepository.java +++ b/src/main/java/com/gg/server/domain/user/data/UserImageRepository.java @@ -4,6 +4,9 @@ import org.springframework.data.jpa.repository.JpaRepository; +import com.gg.server.data.user.User; +import com.gg.server.data.user.UserImage; + public interface UserImageRepository extends JpaRepository { Optional findTopByUserAndIsCurrentIsTrueOrderByIdDesc(User user); } diff --git a/src/main/java/com/gg/server/domain/user/data/UserRepository.java b/src/main/java/com/gg/server/domain/user/data/UserRepository.java index b497bd43d..c12fbf4c5 100644 --- a/src/main/java/com/gg/server/domain/user/data/UserRepository.java +++ b/src/main/java/com/gg/server/domain/user/data/UserRepository.java @@ -10,6 +10,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import com.gg.server.data.user.User; import com.gg.server.domain.rank.dto.ExpRankV2Dto; public interface UserRepository extends JpaRepository { diff --git a/src/main/java/com/gg/server/domain/user/dto/CoinHistoryResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/CoinHistoryResponseDto.java index 1f6b3024e..a00ede8ed 100644 --- a/src/main/java/com/gg/server/domain/user/dto/CoinHistoryResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/CoinHistoryResponseDto.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import com.gg.server.domain.coin.data.CoinHistory; +import com.gg.server.data.store.CoinHistory; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserDetailResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/UserDetailResponseDto.java index 7379affcc..51f458561 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserDetailResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserDetailResponseDto.java @@ -1,10 +1,10 @@ package com.gg.server.domain.user.dto; -import com.gg.server.domain.tier.data.Tier; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.BackgroundType; -import com.gg.server.domain.user.type.EdgeType; -import com.gg.server.domain.user.type.SnsType; +import com.gg.server.data.game.Tier; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.BackgroundType; +import com.gg.server.data.user.type.EdgeType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.global.utils.ExpLevelCalculator; import lombok.AccessLevel; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserDto.java b/src/main/java/com/gg/server/domain/user/dto/UserDto.java index d87ac08b5..a1b9e0d8a 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserDto.java @@ -1,9 +1,9 @@ package com.gg.server.domain.user.dto; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserHistoryData.java b/src/main/java/com/gg/server/domain/user/dto/UserHistoryData.java index 1161d0223..39cc6edf9 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserHistoryData.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserHistoryData.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import com.gg.server.domain.pchange.data.PChange; +import com.gg.server.data.game.PChange; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserImageDto.java b/src/main/java/com/gg/server/domain/user/dto/UserImageDto.java index 4796d2efd..de372f7bb 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserImageDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserImageDto.java @@ -1,7 +1,7 @@ package com.gg.server.domain.user.dto; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.EdgeType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.EdgeType; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserLiveResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/UserLiveResponseDto.java index 6aa8a0c59..5f239136c 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserLiveResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserLiveResponseDto.java @@ -1,6 +1,6 @@ package com.gg.server.domain.user.dto; -import com.gg.server.domain.game.type.Mode; +import com.gg.server.data.game.type.Mode; import lombok.AccessLevel; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserModifyRequestDto.java b/src/main/java/com/gg/server/domain/user/dto/UserModifyRequestDto.java index 3e140a02b..b7bc1e8d2 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserModifyRequestDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserModifyRequestDto.java @@ -1,7 +1,7 @@ package com.gg.server.domain.user.dto; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.SnsType; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.SnsType; import lombok.AccessLevel; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserNormalDetailResponseDto.java b/src/main/java/com/gg/server/domain/user/dto/UserNormalDetailResponseDto.java index 32c13a1d7..19d83ad16 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserNormalDetailResponseDto.java +++ b/src/main/java/com/gg/server/domain/user/dto/UserNormalDetailResponseDto.java @@ -1,6 +1,6 @@ package com.gg.server.domain.user.dto; -import com.gg.server.domain.user.type.EdgeType; +import com.gg.server.data.user.type.EdgeType; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/user/service/UserCoinService.java b/src/main/java/com/gg/server/domain/user/service/UserCoinService.java index 5ab77b438..cf096f146 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserCoinService.java +++ b/src/main/java/com/gg/server/domain/user/service/UserCoinService.java @@ -5,9 +5,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.coin.data.CoinHistory; +import com.gg.server.data.store.CoinHistory; +import com.gg.server.data.user.User; import com.gg.server.domain.coin.data.CoinHistoryRepository; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.CoinHistoryResponseDto; import com.gg.server.domain.user.dto.UserCoinHistoryListResponseDto; diff --git a/src/main/java/com/gg/server/domain/user/service/UserFindService.java b/src/main/java/com/gg/server/domain/user/service/UserFindService.java index e2f2e042e..ec67650db 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserFindService.java +++ b/src/main/java/com/gg/server/domain/user/service/UserFindService.java @@ -5,13 +5,13 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.user.User; import com.gg.server.domain.rank.exception.RedisDataNotFoundException; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.exception.UserNotFoundException; diff --git a/src/main/java/com/gg/server/domain/user/service/UserService.java b/src/main/java/com/gg/server/domain/user/service/UserService.java index 702881e57..d5e406293 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserService.java +++ b/src/main/java/com/gg/server/domain/user/service/UserService.java @@ -16,36 +16,41 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.PChange; +import com.gg.server.data.game.Rank; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Tier; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.store.Receipt; +import com.gg.server.data.store.type.ItemStatus; +import com.gg.server.data.store.type.ItemType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.UserImage; +import com.gg.server.data.user.type.BackgroundType; +import com.gg.server.data.user.type.EdgeType; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.coin.service.CoinHistoryService; import com.gg.server.domain.coin.service.UserCoinChangeService; -import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.item.service.ItemService; -import com.gg.server.domain.item.type.ItemType; import com.gg.server.domain.match.data.RedisMatchUserRepository; import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.pchange.data.PChange; import com.gg.server.domain.pchange.data.PChangeRepository; import com.gg.server.domain.pchange.exception.PChangeNotExistException; -import com.gg.server.domain.rank.data.Rank; import com.gg.server.domain.rank.exception.RankNotFoundException; import com.gg.server.domain.rank.exception.RedisDataNotFoundException; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; import com.gg.server.domain.rank.service.RankFindService; -import com.gg.server.domain.receipt.data.Receipt; import com.gg.server.domain.receipt.data.ReceiptRepository; import com.gg.server.domain.receipt.exception.ReceiptNotFoundException; -import com.gg.server.domain.receipt.type.ItemStatus; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserImage; import com.gg.server.domain.user.data.UserImageRepository; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserAttendanceResponseDto; @@ -67,11 +72,6 @@ import com.gg.server.domain.user.exception.UserImageTypeException; import com.gg.server.domain.user.exception.UserNotFoundException; import com.gg.server.domain.user.exception.UserTextColorException; -import com.gg.server.domain.user.type.BackgroundType; -import com.gg.server.domain.user.type.EdgeType; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.utils.ExpLevelCalculator; import com.gg.server.global.utils.aws.AsyncNewUserImageUploader; diff --git a/src/main/java/com/gg/server/global/security/UserPrincipal.java b/src/main/java/com/gg/server/global/security/UserPrincipal.java index 92c4c9f81..e71f15a74 100644 --- a/src/main/java/com/gg/server/global/security/UserPrincipal.java +++ b/src/main/java/com/gg/server/global/security/UserPrincipal.java @@ -10,8 +10,8 @@ import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.oauth2.core.user.OAuth2User; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RoleType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RoleType; import lombok.Getter; diff --git a/src/main/java/com/gg/server/global/security/handler/OAuthAuthenticationSuccessHandler.java b/src/main/java/com/gg/server/global/security/handler/OAuthAuthenticationSuccessHandler.java index 61b5d38be..97b890b27 100644 --- a/src/main/java/com/gg/server/global/security/handler/OAuthAuthenticationSuccessHandler.java +++ b/src/main/java/com/gg/server/global/security/handler/OAuthAuthenticationSuccessHandler.java @@ -12,10 +12,10 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.util.UriComponentsBuilder; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RoleType; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.type.RoleType; import com.gg.server.global.security.UserPrincipal; import com.gg.server.global.security.config.properties.AppProperties; import com.gg.server.global.security.cookie.CookieUtil; diff --git a/src/main/java/com/gg/server/global/security/info/OAuthUserInfo.java b/src/main/java/com/gg/server/global/security/info/OAuthUserInfo.java index 3701ed585..004e1133c 100644 --- a/src/main/java/com/gg/server/global/security/info/OAuthUserInfo.java +++ b/src/main/java/com/gg/server/global/security/info/OAuthUserInfo.java @@ -2,7 +2,7 @@ import java.util.Map; -import com.gg.server.domain.user.type.RoleType; +import com.gg.server.data.user.type.RoleType; public abstract class OAuthUserInfo { protected Map attributes; diff --git a/src/main/java/com/gg/server/global/security/info/impl/FortyTwoOAuthUserInfo.java b/src/main/java/com/gg/server/global/security/info/impl/FortyTwoOAuthUserInfo.java index 0e8084e39..43ae02a5c 100644 --- a/src/main/java/com/gg/server/global/security/info/impl/FortyTwoOAuthUserInfo.java +++ b/src/main/java/com/gg/server/global/security/info/impl/FortyTwoOAuthUserInfo.java @@ -4,7 +4,7 @@ import org.springframework.beans.factory.annotation.Value; -import com.gg.server.domain.user.type.RoleType; +import com.gg.server.data.user.type.RoleType; import com.gg.server.global.security.info.OAuthUserInfo; public class FortyTwoOAuthUserInfo extends OAuthUserInfo { diff --git a/src/main/java/com/gg/server/global/security/info/impl/KakaoOAuthUserInfo.java b/src/main/java/com/gg/server/global/security/info/impl/KakaoOAuthUserInfo.java index 760c0b493..488500a85 100644 --- a/src/main/java/com/gg/server/global/security/info/impl/KakaoOAuthUserInfo.java +++ b/src/main/java/com/gg/server/global/security/info/impl/KakaoOAuthUserInfo.java @@ -4,7 +4,7 @@ import org.springframework.beans.factory.annotation.Value; -import com.gg.server.domain.user.type.RoleType; +import com.gg.server.data.user.type.RoleType; import com.gg.server.global.security.info.OAuthUserInfo; public class KakaoOAuthUserInfo extends OAuthUserInfo { diff --git a/src/main/java/com/gg/server/global/security/service/CustomOAuth2UserService.java b/src/main/java/com/gg/server/global/security/service/CustomOAuth2UserService.java index 570fd6b23..dce1ea7f7 100644 --- a/src/main/java/com/gg/server/global/security/service/CustomOAuth2UserService.java +++ b/src/main/java/com/gg/server/global/security/service/CustomOAuth2UserService.java @@ -12,20 +12,20 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.rank.data.Rank; +import com.gg.server.data.game.Rank; +import com.gg.server.data.game.Tier; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.security.UserPrincipal; import com.gg.server.global.security.info.OAuthUserInfo; import com.gg.server.global.security.info.OAuthUserInfoFactory; diff --git a/src/main/java/com/gg/server/global/security/service/CustomUserDetailsService.java b/src/main/java/com/gg/server/global/security/service/CustomUserDetailsService.java index c58d1921d..047f0d048 100644 --- a/src/main/java/com/gg/server/global/security/service/CustomUserDetailsService.java +++ b/src/main/java/com/gg/server/global/security/service/CustomUserDetailsService.java @@ -5,7 +5,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.user.User; import com.gg.server.domain.user.exception.UserNotFoundException; import com.gg.server.domain.user.service.UserFindService; import com.gg.server.global.security.UserPrincipal; diff --git a/src/main/java/com/gg/server/global/utils/ItemImageHandler.java b/src/main/java/com/gg/server/global/utils/ItemImageHandler.java index e132c2d1e..62f3d7524 100644 --- a/src/main/java/com/gg/server/global/utils/ItemImageHandler.java +++ b/src/main/java/com/gg/server/global/utils/ItemImageHandler.java @@ -12,7 +12,7 @@ import com.amazonaws.services.s3.model.CannedAccessControlList; import com.amazonaws.services.s3.model.ObjectMetadata; import com.amazonaws.services.s3.model.PutObjectRequest; -import com.gg.server.domain.item.data.Item; +import com.gg.server.data.store.Item; @Component public class ItemImageHandler { diff --git a/src/main/java/com/gg/server/global/utils/UserImageHandler.java b/src/main/java/com/gg/server/global/utils/UserImageHandler.java index 647f19ea5..136e2e6d0 100644 --- a/src/main/java/com/gg/server/global/utils/UserImageHandler.java +++ b/src/main/java/com/gg/server/global/utils/UserImageHandler.java @@ -12,7 +12,7 @@ import com.amazonaws.services.s3.model.CannedAccessControlList; import com.amazonaws.services.s3.model.ObjectMetadata; import com.amazonaws.services.s3.model.PutObjectRequest; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.user.User; import com.gg.server.domain.user.data.UserImageRepository; @Component diff --git a/src/main/java/com/gg/server/global/utils/argumentresolver/LoginMemberArgumentResolver.java b/src/main/java/com/gg/server/global/utils/argumentresolver/LoginMemberArgumentResolver.java index 7052f6c40..e06721a83 100644 --- a/src/main/java/com/gg/server/global/utils/argumentresolver/LoginMemberArgumentResolver.java +++ b/src/main/java/com/gg/server/global/utils/argumentresolver/LoginMemberArgumentResolver.java @@ -8,7 +8,7 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.ModelAndViewContainer; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.user.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; diff --git a/src/main/java/com/gg/server/global/utils/aws/AsyncNewItemImageUploader.java b/src/main/java/com/gg/server/global/utils/aws/AsyncNewItemImageUploader.java index e092bf97d..245737fd5 100644 --- a/src/main/java/com/gg/server/global/utils/aws/AsyncNewItemImageUploader.java +++ b/src/main/java/com/gg/server/global/utils/aws/AsyncNewItemImageUploader.java @@ -7,7 +7,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import com.gg.server.domain.item.data.Item; +import com.gg.server.data.store.Item; import com.gg.server.global.utils.ItemImageHandler; @Component diff --git a/src/main/java/com/gg/server/global/utils/aws/AsyncNewUserImageUploader.java b/src/main/java/com/gg/server/global/utils/aws/AsyncNewUserImageUploader.java index ace0e6e7a..35c429afb 100644 --- a/src/main/java/com/gg/server/global/utils/aws/AsyncNewUserImageUploader.java +++ b/src/main/java/com/gg/server/global/utils/aws/AsyncNewUserImageUploader.java @@ -12,8 +12,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserImage; +import com.gg.server.data.user.User; +import com.gg.server.data.user.UserImage; import com.gg.server.domain.user.data.UserImageRepository; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.global.utils.UserImageHandler; diff --git a/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerTest.java b/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerTest.java index 6ce5c4f5a..6ad68339b 100644 --- a/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerTest.java @@ -17,7 +17,7 @@ import com.gg.server.admin.announcement.data.AnnouncementAdminRepository; import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; import com.gg.server.admin.announcement.dto.AnnouncementAdminListResponseDto; -import com.gg.server.domain.announcement.data.Announcement; +import com.gg.server.data.manage.Announcement; import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; diff --git a/src/test/java/com/gg/server/admin/announcement/service/AnnouncementAdminServiceUnitTest.java b/src/test/java/com/gg/server/admin/announcement/service/AnnouncementAdminServiceUnitTest.java index 9febda647..b73d753bc 100644 --- a/src/test/java/com/gg/server/admin/announcement/service/AnnouncementAdminServiceUnitTest.java +++ b/src/test/java/com/gg/server/admin/announcement/service/AnnouncementAdminServiceUnitTest.java @@ -21,7 +21,7 @@ import com.gg.server.admin.announcement.data.AnnouncementAdminRepository; import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; -import com.gg.server.domain.announcement.data.Announcement; +import com.gg.server.data.manage.Announcement; import com.gg.server.domain.announcement.exception.AnnounceDupException; import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; import com.gg.server.utils.annotation.UnitTest; diff --git a/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerTest.java b/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerTest.java index 2c5929f2b..f42352706 100644 --- a/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerTest.java @@ -19,9 +19,9 @@ import com.gg.server.admin.coin.data.CoinPolicyAdminRepository; import com.gg.server.admin.coin.dto.CoinPolicyAdminAddDto; import com.gg.server.admin.coin.dto.CoinPolicyAdminListResponseDto; -import com.gg.server.domain.coin.data.CoinPolicy; +import com.gg.server.data.manage.CoinPolicy; +import com.gg.server.data.user.User; import com.gg.server.domain.coin.exception.CoinPolicyNotFoundException; -import com.gg.server.domain.user.data.User; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; diff --git a/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerTest.java b/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerTest.java index fa704b25f..f5b1e846e 100644 --- a/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerTest.java @@ -15,9 +15,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.gg.server.admin.feedback.data.FeedbackAdminRepository; import com.gg.server.admin.feedback.dto.FeedbackListAdminResponseDto; -import com.gg.server.domain.feedback.data.Feedback; -import com.gg.server.domain.feedback.type.FeedbackType; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.manage.Feedback; +import com.gg.server.data.manage.type.FeedbackType; +import com.gg.server.data.user.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; diff --git a/src/test/java/com/gg/server/admin/feedback/service/FeedbackAdminServiceUnitTest.java b/src/test/java/com/gg/server/admin/feedback/service/FeedbackAdminServiceUnitTest.java index 12a0729b1..ea49763bf 100644 --- a/src/test/java/com/gg/server/admin/feedback/service/FeedbackAdminServiceUnitTest.java +++ b/src/test/java/com/gg/server/admin/feedback/service/FeedbackAdminServiceUnitTest.java @@ -19,7 +19,7 @@ import org.springframework.test.util.ReflectionTestUtils; import com.gg.server.admin.feedback.data.FeedbackAdminRepository; -import com.gg.server.domain.feedback.data.Feedback; +import com.gg.server.data.manage.Feedback; import com.gg.server.domain.feedback.exception.FeedbackNotFoundException; import com.gg.server.utils.annotation.UnitTest; diff --git a/src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java b/src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java index 95c67602f..36e20171b 100644 --- a/src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java @@ -26,19 +26,19 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.gg.server.admin.game.dto.GameLogListAdminResponseDto; import com.gg.server.admin.game.dto.RankGamePPPModifyReqDto; +import com.gg.server.data.game.Rank; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Tier; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.dto.GameTeamUser; import com.gg.server.domain.game.dto.request.RankResultReqDto; import com.gg.server.domain.game.service.GameService; -import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.match.service.GameUpdateService; -import com.gg.server.domain.rank.data.Rank; import com.gg.server.domain.rank.data.RankRepository; import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.user.controller.dto.GameInfoDto; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; diff --git a/src/test/java/com/gg/server/admin/item/controller/ItemAdminControllerTest.java b/src/test/java/com/gg/server/admin/item/controller/ItemAdminControllerTest.java index 1f3b99635..e12f18574 100644 --- a/src/test/java/com/gg/server/admin/item/controller/ItemAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/item/controller/ItemAdminControllerTest.java @@ -27,8 +27,8 @@ import com.gg.server.admin.item.dto.ItemListResponseDto; import com.gg.server.admin.item.dto.ItemUpdateRequestDto; import com.gg.server.admin.item.service.ItemAdminService; -import com.gg.server.domain.item.data.Item; -import com.gg.server.domain.item.type.ItemType; +import com.gg.server.data.store.Item; +import com.gg.server.data.store.type.ItemType; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.global.utils.ItemImageHandler; diff --git a/src/test/java/com/gg/server/admin/item/service/ItemAdminServiceUnitTest.java b/src/test/java/com/gg/server/admin/item/service/ItemAdminServiceUnitTest.java index d4fb85e17..6b49f9809 100644 --- a/src/test/java/com/gg/server/admin/item/service/ItemAdminServiceUnitTest.java +++ b/src/test/java/com/gg/server/admin/item/service/ItemAdminServiceUnitTest.java @@ -23,13 +23,13 @@ import com.gg.server.admin.item.data.ItemAdminRepository; import com.gg.server.admin.item.dto.ItemUpdateRequestDto; import com.gg.server.admin.item.exception.ItemNotFoundException; -import com.gg.server.domain.item.data.Item; +import com.gg.server.data.store.Item; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.item.exception.ItemNotAvailableException; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.utils.aws.AsyncNewItemImageUploader; import com.gg.server.utils.annotation.UnitTest; diff --git a/src/test/java/com/gg/server/admin/noti/controller/NotiAdminControllerTest.java b/src/test/java/com/gg/server/admin/noti/controller/NotiAdminControllerTest.java index deced8bdf..82e415c56 100644 --- a/src/test/java/com/gg/server/admin/noti/controller/NotiAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/noti/controller/NotiAdminControllerTest.java @@ -27,10 +27,10 @@ import com.gg.server.admin.noti.dto.NotiListAdminResponseDto; import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; import com.gg.server.admin.noti.service.NotiAdminService; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.noti.type.NotiType; +import com.gg.server.data.user.User; import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; diff --git a/src/test/java/com/gg/server/admin/noti/service/NotiAdminServiceUnitTest.java b/src/test/java/com/gg/server/admin/noti/service/NotiAdminServiceUnitTest.java index 48756c2b6..41fa58b77 100644 --- a/src/test/java/com/gg/server/admin/noti/service/NotiAdminServiceUnitTest.java +++ b/src/test/java/com/gg/server/admin/noti/service/NotiAdminServiceUnitTest.java @@ -21,9 +21,9 @@ import com.gg.server.admin.noti.data.NotiAdminRepository; import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.user.User; import com.gg.server.domain.noti.service.SnsNotiService; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; import com.gg.server.utils.annotation.UnitTest; diff --git a/src/test/java/com/gg/server/admin/penalty/controller/PenaltyAdminControllerTest.java b/src/test/java/com/gg/server/admin/penalty/controller/PenaltyAdminControllerTest.java index e823e120e..e693f0d33 100644 --- a/src/test/java/com/gg/server/admin/penalty/controller/PenaltyAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/penalty/controller/PenaltyAdminControllerTest.java @@ -32,14 +32,14 @@ import com.gg.server.admin.penalty.dto.PenaltyListResponseDto; import com.gg.server.admin.penalty.dto.PenaltyRequestDto; import com.gg.server.admin.penalty.service.PenaltyAdminService; -import com.gg.server.domain.penalty.data.Penalty; -import com.gg.server.domain.penalty.redis.RedisPenaltyUser; +import com.gg.server.data.manage.Penalty; +import com.gg.server.data.manage.redis.RedisPenaltyUser; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.penalty.type.PenaltyType; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; diff --git a/src/test/java/com/gg/server/admin/receipt/controller/ReceiptAdminControllerTest.java b/src/test/java/com/gg/server/admin/receipt/controller/ReceiptAdminControllerTest.java index 6e4197952..8e975eb0d 100644 --- a/src/test/java/com/gg/server/admin/receipt/controller/ReceiptAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/receipt/controller/ReceiptAdminControllerTest.java @@ -21,9 +21,9 @@ import com.gg.server.admin.receipt.data.ReceiptAdminRepository; import com.gg.server.admin.receipt.dto.ReceiptListResponseDto; import com.gg.server.admin.receipt.service.ReceiptAdminService; -import com.gg.server.domain.item.data.Item; -import com.gg.server.domain.item.type.ItemType; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.store.Item; +import com.gg.server.data.store.type.ItemType; +import com.gg.server.data.user.User; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.ItemTestUtils; import com.gg.server.utils.TestDataUtils; diff --git a/src/test/java/com/gg/server/admin/season/SeasonAdminControllerTest.java b/src/test/java/com/gg/server/admin/season/SeasonAdminControllerTest.java index b0c7f7a44..876158f3d 100644 --- a/src/test/java/com/gg/server/admin/season/SeasonAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/season/SeasonAdminControllerTest.java @@ -25,14 +25,14 @@ import com.gg.server.admin.season.dto.SeasonListAdminResponseDto; import com.gg.server.admin.season.dto.SeasonUpdateRequestDto; import com.gg.server.admin.season.service.SeasonAdminService; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Tier; import com.gg.server.domain.rank.data.RankRepository; import com.gg.server.domain.rank.exception.RedisDataNotFoundException; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.exception.SeasonForbiddenException; import com.gg.server.domain.season.exception.SeasonNotFoundException; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; diff --git a/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java b/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java index 9cccc0164..1d113eb35 100644 --- a/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java @@ -25,22 +25,22 @@ import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; import com.gg.server.admin.tournament.dto.TournamentGameUpdateRequestDto; import com.gg.server.admin.tournament.service.TournamentAdminService; -import com.gg.server.domain.game.type.Mode; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.TournamentUser; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.TournamentRound; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; +import com.gg.server.data.user.User; import com.gg.server.domain.match.utils.MatchIntegrationTestUtils; import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.team.dto.TeamReqDto; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.data.TournamentGameRepository; import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.data.TournamentUser; import com.gg.server.domain.tournament.data.TournamentUserRepository; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; import com.gg.server.domain.user.controller.dto.GameInfoDto; -import com.gg.server.domain.user.data.User; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.CustomRuntimeException; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; diff --git a/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminUserControllerTest.java b/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminUserControllerTest.java index c3739223f..336dc3401 100644 --- a/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminUserControllerTest.java +++ b/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminUserControllerTest.java @@ -15,12 +15,12 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.tournament.data.Tournament; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.tournament.dto.TournamentUserListResponseDto; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; diff --git a/src/test/java/com/gg/server/admin/tournament/service/TournamentAdminServiceTest.java b/src/test/java/com/gg/server/admin/tournament/service/TournamentAdminServiceTest.java index ebf569e7e..5c1099e82 100644 --- a/src/test/java/com/gg/server/admin/tournament/service/TournamentAdminServiceTest.java +++ b/src/test/java/com/gg/server/admin/tournament/service/TournamentAdminServiceTest.java @@ -20,28 +20,28 @@ import com.gg.server.admin.tournament.dto.TournamentAdminAddUserRequestDto; import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.TournamentUser; +import com.gg.server.data.game.type.TournamentRound; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.data.TournamentGameRepository; import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.data.TournamentUser; import com.gg.server.domain.tournament.data.TournamentUserRepository; import com.gg.server.domain.tournament.exception.TournamentConflictException; import com.gg.server.domain.tournament.exception.TournamentNotFoundException; import com.gg.server.domain.tournament.exception.TournamentUpdateException; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.config.ConstantConfig; import com.gg.server.utils.ReflectionUtilsForUnitTest; import com.gg.server.utils.annotation.UnitTest; diff --git a/src/test/java/com/gg/server/admin/user/controller/UserAdminControllerTest.java b/src/test/java/com/gg/server/admin/user/controller/UserAdminControllerTest.java index d5877e8a9..7131e984c 100644 --- a/src/test/java/com/gg/server/admin/user/controller/UserAdminControllerTest.java +++ b/src/test/java/com/gg/server/admin/user/controller/UserAdminControllerTest.java @@ -29,8 +29,8 @@ import com.gg.server.admin.user.dto.UserSearchAdminDto; import com.gg.server.admin.user.dto.UserSearchAdminResponseDto; import com.gg.server.admin.user.service.UserAdminService; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserImage; +import com.gg.server.data.user.User; +import com.gg.server.data.user.UserImage; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.exception.UserNotFoundException; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; diff --git a/src/test/java/com/gg/server/domain/game/data/GameUnitTest.java b/src/test/java/com/gg/server/data/game/GameUnitTest.java similarity index 97% rename from src/test/java/com/gg/server/domain/game/data/GameUnitTest.java rename to src/test/java/com/gg/server/data/game/GameUnitTest.java index a0d2c7740..e7dfb810b 100644 --- a/src/test/java/com/gg/server/domain/game/data/GameUnitTest.java +++ b/src/test/java/com/gg/server/data/game/GameUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game.data; +package com.gg.server.data.game; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; @@ -13,7 +13,6 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import com.gg.server.domain.team.data.Team; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.BusinessException; import com.gg.server.utils.annotation.UnitTest; diff --git a/src/test/java/com/gg/server/domain/pchange/data/PChangeDataTest.java b/src/test/java/com/gg/server/data/game/PChangeDataTest.java similarity index 94% rename from src/test/java/com/gg/server/domain/pchange/data/PChangeDataTest.java rename to src/test/java/com/gg/server/data/game/PChangeDataTest.java index 0dd971c73..df4294887 100644 --- a/src/test/java/com/gg/server/domain/pchange/data/PChangeDataTest.java +++ b/src/test/java/com/gg/server/data/game/PChangeDataTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.pchange.data; +package com.gg.server.data.game; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/com/gg/server/domain/team/data/TeamUnitTest.java b/src/test/java/com/gg/server/data/game/TeamUnitTest.java similarity index 98% rename from src/test/java/com/gg/server/domain/team/data/TeamUnitTest.java rename to src/test/java/com/gg/server/data/game/TeamUnitTest.java index c8aaf50e5..aa07492a7 100644 --- a/src/test/java/com/gg/server/domain/team/data/TeamUnitTest.java +++ b/src/test/java/com/gg/server/data/game/TeamUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.team.data; +package com.gg.server.data.game; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; diff --git a/src/test/java/com/gg/server/domain/tournament/data/TournamentGameUnitTest.java b/src/test/java/com/gg/server/data/game/TournamentGameUnitTest.java similarity index 66% rename from src/test/java/com/gg/server/domain/tournament/data/TournamentGameUnitTest.java rename to src/test/java/com/gg/server/data/game/TournamentGameUnitTest.java index 6986213b8..0fda86517 100644 --- a/src/test/java/com/gg/server/domain/tournament/data/TournamentGameUnitTest.java +++ b/src/test/java/com/gg/server/data/game/TournamentGameUnitTest.java @@ -1,4 +1,6 @@ -package com.gg.server.domain.tournament.data; +package com.gg.server.data.game; + +import java.time.LocalDateTime; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; @@ -6,7 +8,8 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; import com.gg.server.utils.annotation.UnitTest; @UnitTest @@ -22,7 +25,9 @@ class UpdateGame { @DisplayName("TournamentGame의 게임 업데이트 성공") void updateSuccess() { //given - tournamentGame = new TournamentGame(); + tournamentGame = new TournamentGame(new Game(), + new Tournament("", "", LocalDateTime.now(), LocalDateTime.now(), + TournamentType.MASTER, TournamentStatus.BEFORE), null); Game game = Mockito.mock(Game.class); //when diff --git a/src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java b/src/test/java/com/gg/server/data/game/TournamentUnitTest.java similarity index 97% rename from src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java rename to src/test/java/com/gg/server/data/game/TournamentUnitTest.java index 57a2495ac..5034de6cc 100644 --- a/src/test/java/com/gg/server/domain/tournament/data/TournamentUnitTest.java +++ b/src/test/java/com/gg/server/data/game/TournamentUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.data; +package com.gg.server.data.game; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; @@ -16,8 +16,9 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; +import com.gg.server.data.user.User; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.BusinessException; import com.gg.server.utils.annotation.UnitTest; @@ -41,7 +42,8 @@ void setUp() { .collect(Collectors.toCollection(ArrayList::new)); tournaments = IntStream.range(0, 10) - .mapToObj(i -> new Tournament()) + .mapToObj(i -> new Tournament("", "", LocalDateTime.now(), LocalDateTime.now(), + TournamentType.MASTER, TournamentStatus.END)) .collect(Collectors.toCollection(ArrayList::new)); } diff --git a/src/test/java/com/gg/server/domain/tournament/data/TournamentUserUnitTest.java b/src/test/java/com/gg/server/data/game/TournamentUserUnitTest.java similarity index 71% rename from src/test/java/com/gg/server/domain/tournament/data/TournamentUserUnitTest.java rename to src/test/java/com/gg/server/data/game/TournamentUserUnitTest.java index 1ca91031a..5af6b5a5d 100644 --- a/src/test/java/com/gg/server/domain/tournament/data/TournamentUserUnitTest.java +++ b/src/test/java/com/gg/server/data/game/TournamentUserUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.data; +package com.gg.server.data.game; import java.time.LocalDateTime; @@ -8,7 +8,9 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; +import com.gg.server.data.user.User; import com.gg.server.utils.annotation.UnitTest; @UnitTest @@ -26,7 +28,8 @@ class DeleteTournament { void deleteSuccess() { //given user = Mockito.mock(User.class); - tournament = new Tournament(); + tournament = new Tournament("", "", LocalDateTime.now(), LocalDateTime.now(), + TournamentType.MASTER, TournamentStatus.END); tournamentUser = new TournamentUser(user, tournament, false, LocalDateTime.now()); //when @@ -44,7 +47,9 @@ class UpdateIsJoined { @DisplayName("참가 정보 업데이트 성공") void updateSuccess() { //given - tournamentUser = new TournamentUser(); + tournamentUser = new TournamentUser(null, + new Tournament("", "", LocalDateTime.now(), LocalDateTime.now(), null, null), + false, LocalDateTime.now()); boolean isjoined = true; //when diff --git a/src/test/java/com/gg/server/domain/announcement/data/AnnouncementUnitTest.java b/src/test/java/com/gg/server/data/manage/AnnouncementUnitTest.java similarity index 96% rename from src/test/java/com/gg/server/domain/announcement/data/AnnouncementUnitTest.java rename to src/test/java/com/gg/server/data/manage/AnnouncementUnitTest.java index 667d568ad..9b29a98c2 100644 --- a/src/test/java/com/gg/server/domain/announcement/data/AnnouncementUnitTest.java +++ b/src/test/java/com/gg/server/data/manage/AnnouncementUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.announcement.data; +package com.gg.server.data.manage; import static org.assertj.core.api.Assertions.*; diff --git a/src/test/java/com/gg/server/domain/item/data/ItemUnitTest.java b/src/test/java/com/gg/server/data/store/ItemUnitTest.java similarity index 96% rename from src/test/java/com/gg/server/domain/item/data/ItemUnitTest.java rename to src/test/java/com/gg/server/data/store/ItemUnitTest.java index 805a7fcc5..c324f4013 100644 --- a/src/test/java/com/gg/server/domain/item/data/ItemUnitTest.java +++ b/src/test/java/com/gg/server/data/store/ItemUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.item.data; +package com.gg.server.data.store; import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; import static org.assertj.core.api.Assertions.*; diff --git a/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerTest.java b/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerTest.java index 8f1e3ce24..f1162b682 100644 --- a/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerTest.java +++ b/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerTest.java @@ -15,10 +15,10 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.announcement.data.Announcement; +import com.gg.server.data.manage.Announcement; +import com.gg.server.data.user.User; import com.gg.server.domain.announcement.data.AnnouncementRepository; import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; -import com.gg.server.domain.user.data.User; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; diff --git a/src/test/java/com/gg/server/domain/announcement/service/AnnouncementServiceUnitTest.java b/src/test/java/com/gg/server/domain/announcement/service/AnnouncementServiceUnitTest.java index bb2631963..2378ead57 100644 --- a/src/test/java/com/gg/server/domain/announcement/service/AnnouncementServiceUnitTest.java +++ b/src/test/java/com/gg/server/domain/announcement/service/AnnouncementServiceUnitTest.java @@ -14,7 +14,7 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.domain.announcement.data.Announcement; +import com.gg.server.data.manage.Announcement; import com.gg.server.domain.announcement.data.AnnouncementRepository; import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; import com.gg.server.utils.annotation.UnitTest; diff --git a/src/test/java/com/gg/server/domain/coin/service/CoinHistoryServiceTest.java b/src/test/java/com/gg/server/domain/coin/service/CoinHistoryServiceTest.java index 8cc1d8cff..6db5702dc 100644 --- a/src/test/java/com/gg/server/domain/coin/service/CoinHistoryServiceTest.java +++ b/src/test/java/com/gg/server/domain/coin/service/CoinHistoryServiceTest.java @@ -10,11 +10,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.coin.data.CoinHistory; +import com.gg.server.data.manage.CoinPolicy; +import com.gg.server.data.store.CoinHistory; +import com.gg.server.data.user.User; import com.gg.server.domain.coin.data.CoinHistoryRepository; -import com.gg.server.domain.coin.data.CoinPolicy; import com.gg.server.domain.coin.data.CoinPolicyRepository; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; diff --git a/src/test/java/com/gg/server/domain/coin/service/UserCoinChangeServiceTest.java b/src/test/java/com/gg/server/domain/coin/service/UserCoinChangeServiceTest.java index 632ea5567..0c663e37e 100644 --- a/src/test/java/com/gg/server/domain/coin/service/UserCoinChangeServiceTest.java +++ b/src/test/java/com/gg/server/domain/coin/service/UserCoinChangeServiceTest.java @@ -10,19 +10,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.manage.CoinPolicy; +import com.gg.server.data.store.Item; +import com.gg.server.data.store.type.ItemType; +import com.gg.server.data.user.User; import com.gg.server.domain.coin.data.CoinHistoryRepository; -import com.gg.server.domain.coin.data.CoinPolicy; import com.gg.server.domain.coin.data.CoinPolicyRepository; import com.gg.server.domain.coin.dto.UserGameCoinResultDto; import com.gg.server.domain.coin.exception.CoinHistoryNotFoundException; import com.gg.server.domain.coin.exception.CoinPolicyNotFoundException; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.item.data.Item; import com.gg.server.domain.item.data.ItemRepository; -import com.gg.server.domain.item.type.ItemType; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; diff --git a/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerTest.java b/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerTest.java index 106e5da02..262a2f062 100644 --- a/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerTest.java +++ b/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerTest.java @@ -14,10 +14,10 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.feedback.data.Feedback; +import com.gg.server.data.manage.Feedback; +import com.gg.server.data.manage.type.FeedbackType; import com.gg.server.domain.feedback.data.FeedbackRepository; import com.gg.server.domain.feedback.dto.FeedbackRequestDto; -import com.gg.server.domain.feedback.type.FeedbackType; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; diff --git a/src/test/java/com/gg/server/domain/feedback/service/FeedbackServiceUnitTest.java b/src/test/java/com/gg/server/domain/feedback/service/FeedbackServiceUnitTest.java index 3b18bec6f..b33fc7489 100644 --- a/src/test/java/com/gg/server/domain/feedback/service/FeedbackServiceUnitTest.java +++ b/src/test/java/com/gg/server/domain/feedback/service/FeedbackServiceUnitTest.java @@ -13,10 +13,10 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.domain.feedback.data.Feedback; +import com.gg.server.data.manage.Feedback; +import com.gg.server.data.user.User; import com.gg.server.domain.feedback.data.FeedbackRepository; import com.gg.server.domain.feedback.dto.FeedbackRequestDto; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.exception.UserNotFoundException; import com.gg.server.utils.annotation.UnitTest; diff --git a/src/test/java/com/gg/server/domain/game/GameControllerTest.java b/src/test/java/com/gg/server/domain/game/GameControllerTest.java index 8c0bf64c0..072814db9 100644 --- a/src/test/java/com/gg/server/domain/game/GameControllerTest.java +++ b/src/test/java/com/gg/server/domain/game/GameControllerTest.java @@ -24,7 +24,22 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.PChange; +import com.gg.server.data.game.Rank; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Team; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.game.Tier; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.dto.GameListResDto; import com.gg.server.domain.game.dto.GameTeamInfo; @@ -32,32 +47,17 @@ import com.gg.server.domain.game.dto.request.TournamentResultReqDto; import com.gg.server.domain.game.service.GameFindService; import com.gg.server.domain.game.service.GameService; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.pchange.data.PChange; import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.rank.data.Rank; import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RankRedisService; import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.team.data.Team; import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUser; import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; diff --git a/src/test/java/com/gg/server/domain/game/service/GameDBTest.java b/src/test/java/com/gg/server/domain/game/service/GameDBTest.java index b4e6d62e1..8c6af0ff8 100644 --- a/src/test/java/com/gg/server/domain/game/service/GameDBTest.java +++ b/src/test/java/com/gg/server/domain/game/service/GameDBTest.java @@ -18,17 +18,17 @@ import org.springframework.transaction.annotation.Transactional; import com.gg.server.admin.game.service.GameAdminService; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Team; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.pchange.data.PChangeRepository; import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.team.data.Team; import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUser; import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.user.data.User; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; diff --git a/src/test/java/com/gg/server/domain/game/service/GameFindServiceTest.java b/src/test/java/com/gg/server/domain/game/service/GameFindServiceTest.java index 7e276ad32..0daa11303 100644 --- a/src/test/java/com/gg/server/domain/game/service/GameFindServiceTest.java +++ b/src/test/java/com/gg/server/domain/game/service/GameFindServiceTest.java @@ -16,21 +16,21 @@ import org.springframework.data.domain.Sort; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Tier; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.dto.GameListResDto; import com.gg.server.domain.game.dto.GameResultResDto; import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; diff --git a/src/test/java/com/gg/server/domain/game/service/GameServiceTest.java b/src/test/java/com/gg/server/domain/game/service/GameServiceTest.java index c618e7d6f..a61fcf1b3 100644 --- a/src/test/java/com/gg/server/domain/game/service/GameServiceTest.java +++ b/src/test/java/com/gg/server/domain/game/service/GameServiceTest.java @@ -10,26 +10,26 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Rank; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Team; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.game.Tier; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.dto.request.RankResultReqDto; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.rank.data.Rank; import com.gg.server.domain.rank.data.RankRepository; import com.gg.server.domain.rank.exception.RankNotFoundException; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.team.data.Team; import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUser; import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; diff --git a/src/test/java/com/gg/server/domain/game/service/GameStatusServiceTest.java b/src/test/java/com/gg/server/domain/game/service/GameStatusServiceTest.java index 0578b6dac..cd33bc9f1 100644 --- a/src/test/java/com/gg/server/domain/game/service/GameStatusServiceTest.java +++ b/src/test/java/com/gg/server/domain/game/service/GameStatusServiceTest.java @@ -10,23 +10,23 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Team; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.data.SeasonRepository; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.data.Team; import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUser; import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; diff --git a/src/test/java/com/gg/server/domain/item/controller/ItemStoreListControllerTest.java b/src/test/java/com/gg/server/domain/item/controller/ItemStoreListControllerTest.java index 8b8821b3a..3ee0b3086 100644 --- a/src/test/java/com/gg/server/domain/item/controller/ItemStoreListControllerTest.java +++ b/src/test/java/com/gg/server/domain/item/controller/ItemStoreListControllerTest.java @@ -1,6 +1,6 @@ package com.gg.server.domain.item.controller; -import static com.gg.server.domain.item.type.ItemType.*; +import static com.gg.server.data.store.type.ItemType.*; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; diff --git a/src/test/java/com/gg/server/domain/item/service/ItemServiceUnitTest.java b/src/test/java/com/gg/server/domain/item/service/ItemServiceUnitTest.java index e52cb9b05..16b0a8877 100644 --- a/src/test/java/com/gg/server/domain/item/service/ItemServiceUnitTest.java +++ b/src/test/java/com/gg/server/domain/item/service/ItemServiceUnitTest.java @@ -4,7 +4,6 @@ import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; -import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.List; @@ -21,8 +20,15 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; +import com.gg.server.data.store.Item; +import com.gg.server.data.store.Receipt; +import com.gg.server.data.store.type.ItemStatus; +import com.gg.server.data.store.type.ItemType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.coin.service.UserCoinChangeService; -import com.gg.server.domain.item.data.Item; import com.gg.server.domain.item.data.ItemRepository; import com.gg.server.domain.item.data.UserItemRepository; import com.gg.server.domain.item.exception.ItemNotFoundException; @@ -30,20 +36,13 @@ import com.gg.server.domain.item.exception.ItemTypeException; import com.gg.server.domain.item.exception.KakaoGiftException; import com.gg.server.domain.item.exception.KakaoPurchaseException; -import com.gg.server.domain.item.type.ItemType; import com.gg.server.domain.noti.service.NotiService; -import com.gg.server.domain.receipt.data.Receipt; import com.gg.server.domain.receipt.data.ReceiptRepository; import com.gg.server.domain.receipt.exception.ItemStatusException; import com.gg.server.domain.receipt.exception.ReceiptNotOwnerException; -import com.gg.server.domain.receipt.type.ItemStatus; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.utils.annotation.UnitTest; @UnitTest diff --git a/src/test/java/com/gg/server/domain/match/dto/MatchStatusDtoUnitTest.java b/src/test/java/com/gg/server/domain/match/dto/MatchStatusDtoUnitTest.java index 60b289d45..a5218f933 100644 --- a/src/test/java/com/gg/server/domain/match/dto/MatchStatusDtoUnitTest.java +++ b/src/test/java/com/gg/server/domain/match/dto/MatchStatusDtoUnitTest.java @@ -11,8 +11,8 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.type.Mode; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.type.Mode; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.utils.annotation.UnitTest; diff --git a/src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java b/src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java index a936e6ef2..47cf93aa9 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java +++ b/src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java @@ -20,20 +20,20 @@ import com.gg.server.admin.penalty.data.PenaltyAdminRepository; import com.gg.server.admin.penalty.type.PenaltyKey; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.match.type.Option; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.match.data.RedisMatchTimeRepository; import com.gg.server.domain.match.data.RedisMatchUserRepository; import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.match.type.Option; import com.gg.server.domain.match.utils.MatchIntegrationTestUtils; import com.gg.server.domain.noti.data.NotiRepository; import com.gg.server.domain.penalty.redis.PenaltyUserRedisRepository; import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; diff --git a/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java b/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java index e129d799a..fbcfc03e1 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java +++ b/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java @@ -1,8 +1,7 @@ package com.gg.server.domain.match.service; -import static com.gg.server.domain.match.utils.GameTestUtils.createNormalGame; -import static com.gg.server.domain.match.utils.UserTestUtils.createGuestUser; -import static com.gg.server.domain.match.utils.UserTestUtils.createUser; +import static com.gg.server.domain.match.utils.GameTestUtils.*; +import static com.gg.server.domain.match.utils.UserTestUtils.*; import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; @@ -22,27 +21,26 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Tier; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.match.RedisMatchTime; +import com.gg.server.data.match.type.Option; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.match.data.RedisMatchTime; import com.gg.server.domain.match.data.RedisMatchTimeRepository; import com.gg.server.domain.match.data.RedisMatchUserRepository; -import com.gg.server.domain.match.type.Option; import com.gg.server.domain.match.utils.SlotGenerator; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.service.SeasonFindService; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.type.RoleType; import com.gg.server.utils.annotation.UnitTest; @UnitTest diff --git a/src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java b/src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java index f28bd0131..2de6c6779 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java +++ b/src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java @@ -20,11 +20,24 @@ import org.springframework.transaction.annotation.Transactional; import com.gg.server.admin.penalty.data.PenaltyAdminRepository; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Tier; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; +import com.gg.server.data.manage.redis.RedisPenaltyUser; +import com.gg.server.data.match.RedisMatchUser; +import com.gg.server.data.match.type.MatchKey; +import com.gg.server.data.match.type.Option; +import com.gg.server.data.match.type.SlotStatus; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.noti.type.NotiType; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.type.Mode; import com.gg.server.domain.match.data.RedisMatchTimeRepository; -import com.gg.server.domain.match.data.RedisMatchUser; import com.gg.server.domain.match.data.RedisMatchUserRepository; import com.gg.server.domain.match.dto.MatchStatusDto; import com.gg.server.domain.match.dto.MatchStatusResponseListDto; @@ -32,30 +45,17 @@ import com.gg.server.domain.match.dto.SlotStatusResponseListDto; import com.gg.server.domain.match.exception.EnrolledSlotException; import com.gg.server.domain.match.exception.PenaltyUserSlotException; -import com.gg.server.domain.match.type.MatchKey; -import com.gg.server.domain.match.type.Option; -import com.gg.server.domain.match.type.SlotStatus; import com.gg.server.domain.match.utils.MatchIntegrationTestUtils; -import com.gg.server.domain.noti.data.Noti; import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.noti.type.NotiType; import com.gg.server.domain.penalty.redis.PenaltyUserRedisRepository; -import com.gg.server.domain.penalty.redis.RedisPenaltyUser; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; import com.gg.server.domain.rank.service.RedisUploadService; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tournament.data.Tournament; import com.gg.server.domain.tournament.data.TournamentRepository; import com.gg.server.domain.tournament.exception.TournamentConflictException; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.exception.custom.BusinessException; import com.gg.server.utils.TestDataUtils; diff --git a/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java b/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java index c165b52f8..f63218097 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java +++ b/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java @@ -1,6 +1,6 @@ package com.gg.server.domain.match.service; -import static com.gg.server.domain.tournament.type.RoundNumber.*; +import static com.gg.server.data.game.type.RoundNumber.*; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; @@ -21,22 +21,23 @@ import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; import com.gg.server.admin.noti.service.NotiAdminService; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Team; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.type.RoundNumber; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.game.type.TournamentRound; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.match.type.TournamentMatchStatus; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.match.exception.EnrolledSlotException; import com.gg.server.domain.match.exception.SlotNotFoundException; import com.gg.server.domain.match.exception.WinningTeamNotFoundException; -import com.gg.server.domain.match.type.TournamentMatchStatus; import com.gg.server.domain.match.utils.MatchIntegrationTestUtils; import com.gg.server.domain.match.utils.TournamentGameTestUtils; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.data.Team; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.user.data.User; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; @@ -74,10 +75,10 @@ class MatchTournament { @DisplayName("8강 경기 매칭 성공") public void quarterTest() { // when - matchTournamentService.matchGames(tournament, QUARTER_FINAL); + matchTournamentService.matchGames(tournament, RoundNumber.QUARTER_FINAL); // then - List quarterRounds = TournamentRound.getSameRounds(QUARTER_FINAL); + List quarterRounds = TournamentRound.getSameRounds(RoundNumber.QUARTER_FINAL); List quarterRoundGames = allTournamentGames.stream() .filter(o -> quarterRounds.contains(o.getTournamentRound())) .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) diff --git a/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceUnitTest.java b/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceUnitTest.java index 28081f52c..a82c84207 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceUnitTest.java +++ b/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceUnitTest.java @@ -1,7 +1,7 @@ package com.gg.server.domain.match.service; +import static com.gg.server.data.game.type.RoundNumber.*; import static com.gg.server.domain.match.utils.TournamentGameTestUtils.*; -import static com.gg.server.domain.tournament.type.RoundNumber.*; import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; @@ -25,28 +25,28 @@ import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; import com.gg.server.admin.noti.service.NotiAdminService; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Team; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.RoundNumber; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.game.type.TournamentRound; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.match.type.TournamentMatchStatus; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.match.exception.EnrolledSlotException; import com.gg.server.domain.match.exception.WinningTeamNotFoundException; -import com.gg.server.domain.match.type.TournamentMatchStatus; import com.gg.server.domain.match.utils.GameTestUtils; import com.gg.server.domain.match.utils.TournamentTestUtils; import com.gg.server.domain.match.utils.UserTestUtils; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.service.SeasonFindService; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.data.Team; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.data.TournamentGameRepository; -import com.gg.server.domain.tournament.type.RoundNumber; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.user.data.User; import com.gg.server.utils.annotation.UnitTest; @UnitTest diff --git a/src/test/java/com/gg/server/domain/match/utils/GameTestUtils.java b/src/test/java/com/gg/server/domain/match/utils/GameTestUtils.java index c88104f82..6dd369a0b 100644 --- a/src/test/java/com/gg/server/domain/match/utils/GameTestUtils.java +++ b/src/test/java/com/gg/server/domain/match/utils/GameTestUtils.java @@ -2,13 +2,13 @@ import java.time.LocalDateTime; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.team.data.Team; -import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.user.data.User; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Team; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.user.User; public class GameTestUtils { public static Game createGame(User user, User enemy, Season season, Mode mode) { diff --git a/src/test/java/com/gg/server/domain/match/utils/MatchIntegrationTestUtils.java b/src/test/java/com/gg/server/domain/match/utils/MatchIntegrationTestUtils.java index c053f5d7b..33fd7dcfc 100644 --- a/src/test/java/com/gg/server/domain/match/utils/MatchIntegrationTestUtils.java +++ b/src/test/java/com/gg/server/domain/match/utils/MatchIntegrationTestUtils.java @@ -9,20 +9,20 @@ import org.springframework.stereotype.Component; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Team; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.game.type.TournamentRound; +import com.gg.server.data.user.User; import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.data.SeasonRepository; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.data.Team; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import lombok.RequiredArgsConstructor; diff --git a/src/test/java/com/gg/server/domain/match/utils/TournamentGameTestUtils.java b/src/test/java/com/gg/server/domain/match/utils/TournamentGameTestUtils.java index b0982f2e8..df709fde3 100644 --- a/src/test/java/com/gg/server/domain/match/utils/TournamentGameTestUtils.java +++ b/src/test/java/com/gg/server/domain/match/utils/TournamentGameTestUtils.java @@ -7,18 +7,18 @@ import java.util.Optional; import java.util.stream.Collectors; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Team; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.RoundNumber; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.game.type.TournamentRound; +import com.gg.server.data.user.User; import com.gg.server.domain.match.exception.WinningTeamNotFoundException; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.team.data.Team; -import com.gg.server.domain.team.data.TeamUser; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; -import com.gg.server.domain.tournament.type.RoundNumber; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.user.data.User; public class TournamentGameTestUtils { diff --git a/src/test/java/com/gg/server/domain/match/utils/TournamentTestUtils.java b/src/test/java/com/gg/server/domain/match/utils/TournamentTestUtils.java index e827cd235..6a480ea1f 100644 --- a/src/test/java/com/gg/server/domain/match/utils/TournamentTestUtils.java +++ b/src/test/java/com/gg/server/domain/match/utils/TournamentTestUtils.java @@ -2,12 +2,12 @@ import java.time.LocalDateTime; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; -import com.gg.server.domain.tournament.data.TournamentUser; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.TournamentUser; +import com.gg.server.data.game.type.TournamentRound; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; public class TournamentTestUtils { /** diff --git a/src/test/java/com/gg/server/domain/match/utils/UserTestUtils.java b/src/test/java/com/gg/server/domain/match/utils/UserTestUtils.java index f9434cc45..4374e87f7 100644 --- a/src/test/java/com/gg/server/domain/match/utils/UserTestUtils.java +++ b/src/test/java/com/gg/server/domain/match/utils/UserTestUtils.java @@ -2,10 +2,10 @@ import java.util.UUID; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; public class UserTestUtils { public static User createUser() { diff --git a/src/test/java/com/gg/server/domain/megaphone/controller/MegaphoneControllerTest.java b/src/test/java/com/gg/server/domain/megaphone/controller/MegaphoneControllerTest.java index 29ff626a6..8a8e5fa8e 100644 --- a/src/test/java/com/gg/server/domain/megaphone/controller/MegaphoneControllerTest.java +++ b/src/test/java/com/gg/server/domain/megaphone/controller/MegaphoneControllerTest.java @@ -18,18 +18,18 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.domain.item.data.Item; -import com.gg.server.domain.item.type.ItemType; -import com.gg.server.domain.megaphone.data.Megaphone; +import com.gg.server.data.store.Item; +import com.gg.server.data.store.Megaphone; +import com.gg.server.data.store.Receipt; +import com.gg.server.data.store.type.ItemStatus; +import com.gg.server.data.store.type.ItemType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.megaphone.data.MegaphoneRepository; import com.gg.server.domain.megaphone.dto.MegaphoneUseRequestDto; -import com.gg.server.domain.receipt.data.Receipt; import com.gg.server.domain.receipt.data.ReceiptRepository; -import com.gg.server.domain.receipt.type.ItemStatus; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.ItemTestUtils; import com.gg.server.utils.TestDataUtils; diff --git a/src/test/java/com/gg/server/domain/megaphone/service/MegaphoneServiceUnitTest.java b/src/test/java/com/gg/server/domain/megaphone/service/MegaphoneServiceUnitTest.java index 00dc47986..4cebd0543 100644 --- a/src/test/java/com/gg/server/domain/megaphone/service/MegaphoneServiceUnitTest.java +++ b/src/test/java/com/gg/server/domain/megaphone/service/MegaphoneServiceUnitTest.java @@ -4,7 +4,6 @@ import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; -import static org.mockito.Mockito.*; import java.time.LocalDate; import java.time.LocalDateTime; @@ -23,28 +22,28 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.domain.item.data.Item; +import com.gg.server.data.store.Item; +import com.gg.server.data.store.Megaphone; +import com.gg.server.data.store.Receipt; +import com.gg.server.data.store.type.ItemStatus; +import com.gg.server.data.store.type.ItemType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.item.service.ItemService; -import com.gg.server.domain.item.type.ItemType; -import com.gg.server.domain.megaphone.data.Megaphone; import com.gg.server.domain.megaphone.data.MegaphoneRepository; import com.gg.server.domain.megaphone.dto.MegaphoneUseRequestDto; import com.gg.server.domain.megaphone.exception.MegaphoneContentException; import com.gg.server.domain.megaphone.exception.MegaphoneNotFoundException; import com.gg.server.domain.megaphone.exception.MegaphoneTimeException; import com.gg.server.domain.megaphone.redis.MegaphoneRedisRepository; -import com.gg.server.domain.receipt.data.Receipt; import com.gg.server.domain.receipt.data.ReceiptRepository; import com.gg.server.domain.receipt.exception.ItemStatusException; import com.gg.server.domain.receipt.exception.ReceiptNotFoundException; -import com.gg.server.domain.receipt.type.ItemStatus; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.utils.annotation.UnitTest; @UnitTest diff --git a/src/test/java/com/gg/server/domain/noti/controller/NotiControllerTest.java b/src/test/java/com/gg/server/domain/noti/controller/NotiControllerTest.java index 80d539795..0784ece3f 100644 --- a/src/test/java/com/gg/server/domain/noti/controller/NotiControllerTest.java +++ b/src/test/java/com/gg/server/domain/noti/controller/NotiControllerTest.java @@ -16,12 +16,12 @@ import org.springframework.test.web.servlet.MockMvc; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.noti.type.NotiType; +import com.gg.server.data.user.User; import com.gg.server.domain.noti.data.NotiRepository; import com.gg.server.domain.noti.dto.NotiListResponseDto; import com.gg.server.domain.noti.service.NotiService; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; diff --git a/src/test/java/com/gg/server/domain/noti/service/NotiServiceTest.java b/src/test/java/com/gg/server/domain/noti/service/NotiServiceTest.java index 3bca32208..0536dd740 100644 --- a/src/test/java/com/gg/server/domain/noti/service/NotiServiceTest.java +++ b/src/test/java/com/gg/server/domain/noti/service/NotiServiceTest.java @@ -11,10 +11,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.noti.type.NotiType; +import com.gg.server.data.user.User; import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; diff --git a/src/test/java/com/gg/server/domain/pchange/service/PChangeServiceTest.java b/src/test/java/com/gg/server/domain/pchange/service/PChangeServiceTest.java index ad40bac85..f492211e7 100644 --- a/src/test/java/com/gg/server/domain/pchange/service/PChangeServiceTest.java +++ b/src/test/java/com/gg/server/domain/pchange/service/PChangeServiceTest.java @@ -14,14 +14,14 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.domain.game.data.Game; -import com.gg.server.domain.pchange.data.PChange; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.PChange; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.pchange.data.PChangeRepository; import com.gg.server.domain.pchange.exception.PChangeNotExistException; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.utils.ReflectionUtilsForUnitTest; import com.gg.server.utils.annotation.UnitTest; diff --git a/src/test/java/com/gg/server/domain/rank/controller/RankControllerTest.java b/src/test/java/com/gg/server/domain/rank/controller/RankControllerTest.java index b8500f4ac..089e6ee60 100644 --- a/src/test/java/com/gg/server/domain/rank/controller/RankControllerTest.java +++ b/src/test/java/com/gg/server/domain/rank/controller/RankControllerTest.java @@ -18,14 +18,14 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; +import com.gg.server.data.game.Season; +import com.gg.server.data.user.User; import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; import com.gg.server.domain.rank.dto.RankDto; import com.gg.server.domain.rank.dto.RankPageResponseDto; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.service.RedisUploadService; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.user.data.User; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; diff --git a/src/test/java/com/gg/server/domain/rank/controller/RankV2ControllerTest.java b/src/test/java/com/gg/server/domain/rank/controller/RankV2ControllerTest.java index 2bd4ab106..0676fb52a 100644 --- a/src/test/java/com/gg/server/domain/rank/controller/RankV2ControllerTest.java +++ b/src/test/java/com/gg/server/domain/rank/controller/RankV2ControllerTest.java @@ -19,10 +19,10 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.servlet.MockMvc; +import com.gg.server.data.user.User; import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; import com.gg.server.domain.rank.dto.RankPageResponseDto; import com.gg.server.domain.rank.service.RankService; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.global.config.WebConfig; diff --git a/src/test/java/com/gg/server/domain/rank/redis/RankRedisRepositoryTest.java b/src/test/java/com/gg/server/domain/rank/redis/RankRedisRepositoryTest.java index 04df8e200..f932f235d 100644 --- a/src/test/java/com/gg/server/domain/rank/redis/RankRedisRepositoryTest.java +++ b/src/test/java/com/gg/server/domain/rank/redis/RankRedisRepositoryTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import com.gg.server.data.game.redis.RankRedis; import com.gg.server.domain.rank.exception.RedisDataNotFoundException; import com.gg.server.utils.annotation.IntegrationTest; diff --git a/src/test/java/com/gg/server/domain/rank/service/RankServiceTest.java b/src/test/java/com/gg/server/domain/rank/service/RankServiceTest.java index 76b0a7b45..8366da1d8 100644 --- a/src/test/java/com/gg/server/domain/rank/service/RankServiceTest.java +++ b/src/test/java/com/gg/server/domain/rank/service/RankServiceTest.java @@ -17,15 +17,15 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; +import com.gg.server.data.game.Season; +import com.gg.server.data.user.User; import com.gg.server.domain.rank.data.RankRepository; import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; import com.gg.server.domain.rank.dto.ExpRankV2Dto; import com.gg.server.domain.rank.dto.RankPageResponseDto; import com.gg.server.domain.rank.dto.RankV2Dto; import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; diff --git a/src/test/java/com/gg/server/domain/season/SeasonTestController.java b/src/test/java/com/gg/server/domain/season/SeasonTestController.java index f5abe5578..7b65f7e08 100644 --- a/src/test/java/com/gg/server/domain/season/SeasonTestController.java +++ b/src/test/java/com/gg/server/domain/season/SeasonTestController.java @@ -17,7 +17,7 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.season.data.Season; +import com.gg.server.data.game.Season; import com.gg.server.domain.season.data.SeasonRepository; import com.gg.server.domain.season.dto.SeasonListResDto; import com.gg.server.domain.season.dto.SeasonResDto; diff --git a/src/test/java/com/gg/server/domain/season/SeasonTriggerTest.java b/src/test/java/com/gg/server/domain/season/SeasonTriggerTest.java index 8625189b8..ff21d4b19 100644 --- a/src/test/java/com/gg/server/domain/season/SeasonTriggerTest.java +++ b/src/test/java/com/gg/server/domain/season/SeasonTriggerTest.java @@ -15,8 +15,8 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.season.data.Season; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.type.Mode; import com.gg.server.domain.season.data.SeasonRepository; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; diff --git a/src/test/java/com/gg/server/domain/tournament/controller/TournamentFindControllerTest.java b/src/test/java/com/gg/server/domain/tournament/controller/TournamentFindControllerTest.java index 8b2d599f1..339232baf 100644 --- a/src/test/java/com/gg/server/domain/tournament/controller/TournamentFindControllerTest.java +++ b/src/test/java/com/gg/server/domain/tournament/controller/TournamentFindControllerTest.java @@ -19,17 +19,17 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentUser; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentUser; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.tournament.data.TournamentUserRepository; import com.gg.server.domain.tournament.dto.TournamentListResponseDto; import com.gg.server.domain.tournament.dto.TournamentResponseDto; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.exception.ErrorCode; import com.gg.server.global.exception.custom.CustomRuntimeException; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; diff --git a/src/test/java/com/gg/server/domain/tournament/controller/TournamentGameControllerTest.java b/src/test/java/com/gg/server/domain/tournament/controller/TournamentGameControllerTest.java index 80fa5794a..f5d745a1b 100644 --- a/src/test/java/com/gg/server/domain/tournament/controller/TournamentGameControllerTest.java +++ b/src/test/java/com/gg/server/domain/tournament/controller/TournamentGameControllerTest.java @@ -17,19 +17,19 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.season.data.Season; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.TournamentRound; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.tournament.dto.TournamentGameListResponseDto; import com.gg.server.domain.tournament.dto.TournamentGameResDto; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.tournament.type.TournamentStatus; import com.gg.server.domain.user.controller.dto.GameInfoDto; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; diff --git a/src/test/java/com/gg/server/domain/tournament/controller/TournamentSchedulerTest.java b/src/test/java/com/gg/server/domain/tournament/controller/TournamentSchedulerTest.java index 413cb8993..64be308a0 100644 --- a/src/test/java/com/gg/server/domain/tournament/controller/TournamentSchedulerTest.java +++ b/src/test/java/com/gg/server/domain/tournament/controller/TournamentSchedulerTest.java @@ -17,13 +17,13 @@ import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; import com.gg.server.admin.noti.service.NotiAdminService; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.type.TournamentStatus; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.data.TournamentGameRepository; import com.gg.server.domain.tournament.service.TournamentService; -import com.gg.server.domain.tournament.type.TournamentStatus; import com.gg.server.utils.TestDataUtils; import com.gg.server.utils.annotation.IntegrationTest; diff --git a/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceUnitTest.java b/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceUnitTest.java index 0d19084af..12676750b 100644 --- a/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceUnitTest.java +++ b/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceUnitTest.java @@ -26,33 +26,33 @@ import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; import com.gg.server.admin.noti.service.NotiAdminService; -import com.gg.server.domain.game.data.Game; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.TournamentUser; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.game.type.TournamentRound; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; +import com.gg.server.data.game.type.TournamentUserStatus; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.game.type.StatusType; import com.gg.server.domain.match.service.MatchTournamentService; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.data.TournamentGameRepository; import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.data.TournamentUser; import com.gg.server.domain.tournament.data.TournamentUserRepository; import com.gg.server.domain.tournament.dto.TournamentGameListResponseDto; import com.gg.server.domain.tournament.dto.TournamentResponseDto; import com.gg.server.domain.tournament.dto.TournamentUserRegistrationResponseDto; import com.gg.server.domain.tournament.exception.TournamentConflictException; import com.gg.server.domain.tournament.exception.TournamentNotFoundException; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; -import com.gg.server.domain.tournament.type.TournamentUserStatus; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.utils.ReflectionUtilsForUnitTest; import com.gg.server.utils.annotation.UnitTest; diff --git a/src/test/java/com/gg/server/domain/user/controller/UserControllerTest.java b/src/test/java/com/gg/server/domain/user/controller/UserControllerTest.java index 26f2967f0..f4086548e 100644 --- a/src/test/java/com/gg/server/domain/user/controller/UserControllerTest.java +++ b/src/test/java/com/gg/server/domain/user/controller/UserControllerTest.java @@ -27,31 +27,36 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.gg.server.admin.item.dto.ItemUpdateRequestDto; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.Rank; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Tier; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.store.Item; +import com.gg.server.data.store.Receipt; +import com.gg.server.data.store.type.ItemStatus; +import com.gg.server.data.store.type.ItemType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.BackgroundType; +import com.gg.server.data.user.type.EdgeType; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.coin.data.CoinHistoryRepository; import com.gg.server.domain.coin.data.CoinPolicyRepository; import com.gg.server.domain.coin.service.CoinHistoryService; -import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.dto.request.RankResultReqDto; import com.gg.server.domain.game.service.GameService; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.item.data.Item; -import com.gg.server.domain.item.type.ItemType; -import com.gg.server.domain.rank.data.Rank; import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.receipt.data.Receipt; import com.gg.server.domain.receipt.data.ReceiptRepository; -import com.gg.server.domain.receipt.type.ItemStatus; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; import com.gg.server.domain.user.controller.dto.GameInfoDto; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.CoinHistoryResponseDto; import com.gg.server.domain.user.dto.UserAttendanceResponseDto; @@ -66,11 +71,6 @@ import com.gg.server.domain.user.dto.UserSearchResponseDto; import com.gg.server.domain.user.dto.UserTextColorDto; import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.type.BackgroundType; -import com.gg.server.domain.user.type.EdgeType; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import com.gg.server.global.utils.UserImageHandler; import com.gg.server.utils.ItemTestUtils; diff --git a/src/test/java/com/gg/server/utils/ItemTestUtils.java b/src/test/java/com/gg/server/utils/ItemTestUtils.java index 5a4db6967..3990c63e8 100644 --- a/src/test/java/com/gg/server/utils/ItemTestUtils.java +++ b/src/test/java/com/gg/server/utils/ItemTestUtils.java @@ -6,14 +6,14 @@ import org.springframework.stereotype.Component; import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.domain.item.data.Item; +import com.gg.server.data.store.Item; +import com.gg.server.data.store.Megaphone; +import com.gg.server.data.store.Receipt; +import com.gg.server.data.store.type.ItemStatus; +import com.gg.server.data.user.User; import com.gg.server.domain.item.data.ItemRepository; -import com.gg.server.domain.megaphone.data.Megaphone; import com.gg.server.domain.megaphone.data.MegaphoneRepository; -import com.gg.server.domain.receipt.data.Receipt; import com.gg.server.domain.receipt.data.ReceiptRepository; -import com.gg.server.domain.receipt.type.ItemStatus; -import com.gg.server.domain.user.data.User; import lombok.AllArgsConstructor; diff --git a/src/test/java/com/gg/server/utils/TestDataUtils.java b/src/test/java/com/gg/server/utils/TestDataUtils.java index e7f60e07d..66ad35023 100644 --- a/src/test/java/com/gg/server/utils/TestDataUtils.java +++ b/src/test/java/com/gg/server/utils/TestDataUtils.java @@ -11,54 +11,54 @@ import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; -import com.gg.server.domain.announcement.data.Announcement; +import com.gg.server.data.game.Game; +import com.gg.server.data.game.PChange; +import com.gg.server.data.game.Rank; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Team; +import com.gg.server.data.game.TeamUser; +import com.gg.server.data.game.Tier; +import com.gg.server.data.game.Tournament; +import com.gg.server.data.game.TournamentGame; +import com.gg.server.data.game.TournamentUser; +import com.gg.server.data.game.redis.RankRedis; +import com.gg.server.data.game.type.Mode; +import com.gg.server.data.game.type.StatusType; +import com.gg.server.data.game.type.TournamentRound; +import com.gg.server.data.game.type.TournamentStatus; +import com.gg.server.data.game.type.TournamentType; +import com.gg.server.data.manage.Announcement; +import com.gg.server.data.manage.CoinPolicy; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.noti.type.NotiType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.UserImage; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.announcement.data.AnnouncementRepository; -import com.gg.server.domain.coin.data.CoinPolicy; import com.gg.server.domain.coin.data.CoinPolicyRepository; -import com.gg.server.domain.game.data.Game; import com.gg.server.domain.game.data.GameRepository; import com.gg.server.domain.game.exception.GameNotExistException; -import com.gg.server.domain.game.type.Mode; -import com.gg.server.domain.game.type.StatusType; -import com.gg.server.domain.noti.data.Noti; import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.pchange.data.PChange; import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.rank.data.Rank; import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedis; import com.gg.server.domain.rank.redis.RankRedisRepository; import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.Season; import com.gg.server.domain.season.data.SeasonRepository; import com.gg.server.domain.slotmanagement.SlotManagement; import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.data.Team; import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUser; import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.tier.data.Tier; import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tournament.data.Tournament; -import com.gg.server.domain.tournament.data.TournamentGame; import com.gg.server.domain.tournament.data.TournamentGameRepository; import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.data.TournamentUser; import com.gg.server.domain.tournament.data.TournamentUserRepository; import com.gg.server.domain.tournament.dto.TournamentResponseDto; -import com.gg.server.domain.tournament.type.TournamentRound; -import com.gg.server.domain.tournament.type.TournamentStatus; -import com.gg.server.domain.tournament.type.TournamentType; import com.gg.server.domain.user.controller.dto.GameInfoDto; -import com.gg.server.domain.user.data.User; -import com.gg.server.domain.user.data.UserImage; import com.gg.server.domain.user.data.UserImageRepository; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserImageDto; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.security.jwt.utils.AuthTokenProvider; import lombok.RequiredArgsConstructor; From 34e533a928f7b1bc4b9a6307c5bd89d867efa9e1 Mon Sep 17 00:00:00 2001 From: Hyunkyu Lee <88573971+wken5577@users.noreply.github.com> Date: Mon, 5 Feb 2024 21:24:17 +0900 Subject: [PATCH 17/32] [Fix] refactoring api call slack api (#493) --- .../noti/service/sns/SlackbotService.java | 75 ++++--------------- .../server/global/utils/external/ApiUtil.java | 52 +++++++++++++ 2 files changed, 68 insertions(+), 59 deletions(-) create mode 100644 src/main/java/com/gg/server/global/utils/external/ApiUtil.java diff --git a/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java b/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java index 414f40293..085dc543e 100644 --- a/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java +++ b/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java @@ -6,49 +6,36 @@ import java.util.Map; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import com.gg.server.data.noti.Noti; import com.gg.server.domain.noti.dto.UserNotiDto; -import com.gg.server.domain.noti.exception.SlackJsonParseException; import com.gg.server.domain.noti.exception.SlackSendException; -import com.gg.server.domain.noti.exception.SlackUserGetFailedException; import com.gg.server.domain.noti.service.NotiService; import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.utils.external.ApiUtil; import lombok.Getter; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @Component @Slf4j +@RequiredArgsConstructor public class SlackbotService { @Value("${slack.xoxbToken}") private String authenticationToken; - private final RestTemplate restTemplate; - private final ObjectMapper objectMapper; private final NotiService notiService; + private final ApiUtil apiUtil; - public SlackbotService(RestTemplateBuilder builder, ObjectMapper objectMapper, NotiService notiService) { - this.restTemplate = builder.build(); - this.objectMapper = objectMapper; - this.notiService = notiService; - } - - private String getSlackUserId(String intraId) throws SlackUserGetFailedException { + private String getSlackUserId(String intraId) { String userEmail = intraId + intraEmailSuffix; HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); @@ -57,40 +44,24 @@ private String getSlackUserId(String intraId) throws SlackUserGetFailedException MultiValueMap parameters = new LinkedMultiValueMap<>(); parameters.add("email", userEmail); - HttpEntity> request = new HttpEntity<>(parameters, headers); - - ResponseEntity responseEntity = restTemplate - .exchange(userIdGetUrl, HttpMethod.POST, request, SlackUserInfoResponse.class); - if (!responseEntity.getBody().ok) { - throw new SlackUserGetFailedException(); - } - return responseEntity.getBody().user.id; + SlackUserInfoResponse res = apiUtil.apiCall(userIdGetUrl, SlackUserInfoResponse.class, + headers, parameters, HttpMethod.POST); + return res.user.id; } - private String getDmChannelId(String slackUserId) throws SlackJsonParseException { + private String getDmChannelId(String slackUserId) { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.add(HttpHeaders.AUTHORIZATION, authenticationPrefix + authenticationToken); httpHeaders.setContentType(MediaType.APPLICATION_JSON); - Map map = new HashMap<>(); - map.put("users", slackUserId); - String contentBody = null; - try { - contentBody = objectMapper.writeValueAsString(map); - } catch (JsonProcessingException e) { - throw new SlackJsonParseException(); - } + Map bodyMap = new HashMap<>(); + bodyMap.put("users", slackUserId); - HttpEntity entity = new HttpEntity<>(contentBody, httpHeaders); + ConversationResponse res = apiUtil.apiCall(conversationsUrl, ConversationResponse.class, + httpHeaders, bodyMap, HttpMethod.POST); - ResponseEntity responseEntity = restTemplate - .exchange(conversationsUrl, HttpMethod.POST, entity, ConversationResponse.class); - if (!responseEntity.getBody().ok) { - log.error("fail to get user dm channel id"); - throw new SlackUserGetFailedException(); - } - return responseEntity.getBody().channel.id; + return res.channel.id; } @Async("asyncExecutor") @@ -113,7 +84,7 @@ public void send(UserDto user, Noti noti) { } } - private void startSendNoti(String intraId, Noti noti) throws SlackSendException { + private void startSendNoti(String intraId, Noti noti) { String slackUserId = getSlackUserId(intraId); String slackChannelId = getDmChannelId(slackUserId); String message = notiService.getMessage(noti); @@ -126,21 +97,7 @@ private void startSendNoti(String intraId, Noti noti) throws SlackSendException Map map = new HashMap<>(); map.put("channel", slackChannelId); map.put("text", message); - String contentBody = null; - try { - contentBody = objectMapper.writeValueAsString(map); - } catch (JsonProcessingException e) { - log.error("start send Slack Noti", e); - throw new SlackJsonParseException(); - } - - HttpEntity entity = new HttpEntity<>(contentBody, httpHeaders); - - ResponseEntity respEntity = restTemplate - .exchange(sendMessageUrl, HttpMethod.POST, entity, String.class); - if (respEntity.getStatusCode() != HttpStatus.OK) { - throw new SlackSendException(); - } + apiUtil.apiCall(sendMessageUrl, String.class, httpHeaders, map, HttpMethod.POST); } @Getter diff --git a/src/main/java/com/gg/server/global/utils/external/ApiUtil.java b/src/main/java/com/gg/server/global/utils/external/ApiUtil.java new file mode 100644 index 000000000..1df10fd0d --- /dev/null +++ b/src/main/java/com/gg/server/global/utils/external/ApiUtil.java @@ -0,0 +1,52 @@ +package com.gg.server.global.utils.external; + +import java.util.Map; + +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class ApiUtil { + private final RestTemplate restTemplate; + private final ObjectMapper objectMapper; + + public ApiUtil(ObjectMapper objectMapper, RestTemplateBuilder restTemplateBuilder) { + this.objectMapper = objectMapper; + this.restTemplate = restTemplateBuilder.build(); + } + + public T apiCall(String url, Class responseType, HttpHeaders headers, + MultiValueMap parameters, HttpMethod method) { + HttpEntity> request = new HttpEntity<>(parameters, headers); + ResponseEntity res = restTemplate.exchange(url, method, request, responseType); + if (!res.getStatusCode().is2xxSuccessful()) { + throw new RuntimeException("api call error"); + } + return res.getBody(); + } + + public T apiCall(String url, Class responseType, HttpHeaders headers, + Map bodyJson, HttpMethod method) { + String contentBody = null; + try { + contentBody = objectMapper.writeValueAsString(bodyJson); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + HttpEntity request = new HttpEntity<>(contentBody, headers); + ResponseEntity res = restTemplate.exchange(url, method, request, responseType); + if (!res.getStatusCode().is2xxSuccessful()) { + throw new RuntimeException("api call error"); + } + return res.getBody(); + } +} From eed6fd42b20517c651f17c8343f4b44360966b5a Mon Sep 17 00:00:00 2001 From: Hyunkyu Lee <88573971+wken5577@users.noreply.github.com> Date: Mon, 5 Feb 2024 21:24:48 +0900 Subject: [PATCH 18/32] =?UTF-8?q?[BUG]=20top3=20rank=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20(#530)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/data/UserRepository.java | 2 ++ .../domain/user/service/UserService.java | 20 ++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gg/server/domain/user/data/UserRepository.java b/src/main/java/com/gg/server/domain/user/data/UserRepository.java index c12fbf4c5..dc60db2ce 100644 --- a/src/main/java/com/gg/server/domain/user/data/UserRepository.java +++ b/src/main/java/com/gg/server/domain/user/data/UserRepository.java @@ -16,6 +16,8 @@ public interface UserRepository extends JpaRepository { Optional findByIntraId(String intraId); + List findByIntraIdIn(List intraIds); + Optional getUserByIntraId(String intraId); Page findByIntraIdContains(Pageable pageable, String intraId); diff --git a/src/main/java/com/gg/server/domain/user/service/UserService.java b/src/main/java/com/gg/server/domain/user/service/UserService.java index d5e406293..084c55e80 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserService.java +++ b/src/main/java/com/gg/server/domain/user/service/UserService.java @@ -41,6 +41,8 @@ import com.gg.server.domain.noti.data.NotiRepository; import com.gg.server.domain.pchange.data.PChangeRepository; import com.gg.server.domain.pchange.exception.PChangeNotExistException; +import com.gg.server.domain.rank.data.RankRepository; +import com.gg.server.domain.rank.dto.RankV2Dto; import com.gg.server.domain.rank.exception.RankNotFoundException; import com.gg.server.domain.rank.exception.RedisDataNotFoundException; import com.gg.server.domain.rank.redis.RankRedisRepository; @@ -97,6 +99,7 @@ public class UserService { private final UserImageRepository userImageRepository; private final ItemService itemService; private final TierRepository tierRepository; + private final RankRepository rankRepository; /** * @param intraId @@ -260,19 +263,18 @@ public UserImageResponseDto getRankedUserImagesByPPP(Long seasonId) { targetSeason = seasonFindService.findSeasonById(seasonId); } try { - String zSetKey = RedisKeyManager.getZSetKey(targetSeason.getId()); - List userIds = rankRedisRepository.getUserIdsByRangeFromZSet(zSetKey, 0, 2); - List users = userRepository.findUsersByIdIn(userIds); List userImages = new ArrayList<>(); - userIds.forEach(userId -> { + List dtos = rankRepository.findPppRankBySeasonId(0, 3, targetSeason.getId()); + List users = userRepository.findByIntraIdIn( + dtos.stream().map(RankV2Dto::getIntraId).collect(Collectors.toList())); + for (RankV2Dto dto : dtos) { User user = users.stream() - .filter(u -> u.getId().equals(userId)) + .filter(u -> u.getIntraId().equals(dto.getIntraId())) .findFirst() .orElseThrow(UserNotFoundException::new); - Tier tier = rankFindService.findByUserIdAndSeasonId(user.getId(), targetSeason.getId()).getTier(); - userImages.add( - new UserImageDto(user.getIntraId(), user.getImageUri(), user.getEdge(), tier.getImageUri())); - }); + userImages.add(new UserImageDto(user.getIntraId(), user.getImageUri(), + user.getEdge(), dto.getTierImageUri())); + } return new UserImageResponseDto(userImages); } catch (RedisDataNotFoundException ex) { return new UserImageResponseDto(new ArrayList<>()); From 87059c63587f28c0d58a240a64e8b4b7b58dc3a3 Mon Sep 17 00:00:00 2001 From: SeungChul Chung Date: Wed, 14 Feb 2024 14:21:39 +0900 Subject: [PATCH 19/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20TierServic?= =?UTF-8?q?e=20=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(#536)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gg/server/data/game/Rank.java | 4 + .../domain/tier/service/TierService.java | 52 +++--- .../tier/service/TierServiceUnitTest.java | 172 ++++++++++++++++++ 3 files changed, 202 insertions(+), 26 deletions(-) create mode 100644 src/test/java/com/gg/server/domain/tier/service/TierServiceUnitTest.java diff --git a/src/main/java/com/gg/server/data/game/Rank.java b/src/main/java/com/gg/server/data/game/Rank.java index a52d9bc26..f593675de 100644 --- a/src/main/java/com/gg/server/data/game/Rank.java +++ b/src/main/java/com/gg/server/data/game/Rank.java @@ -107,4 +107,8 @@ public void modifyUserRank(Integer ppp, int wins, int losses) { public void updateTier(Tier tier) { this.tier = tier; } + + public boolean isParticipated() { + return wins + losses > 0; + } } diff --git a/src/main/java/com/gg/server/domain/tier/service/TierService.java b/src/main/java/com/gg/server/domain/tier/service/TierService.java index 59cd0dce4..5724ee592 100644 --- a/src/main/java/com/gg/server/domain/tier/service/TierService.java +++ b/src/main/java/com/gg/server/domain/tier/service/TierService.java @@ -20,6 +20,20 @@ public class TierService { private final TierRepository tierRepository; private final RankRepository rankRepository; + /** + * 해당 시즌 랭킹의 티어를 모두 업데이트한다. + *

+ * 참여한적 없으면 0번 티어.
+ * ppp 970 미만 1번 티어.
+ * ppp 1010 미만 2번 티어.
+ * ppp 1050 미만 || 상위 30프로 미만 3번 티어.
+ * ppp 1050 이상 && 상위 10프로 미만 4번 티어.
+ * ppp 1050 이상 && 상위 10프로 이상 5번 티어.
+ * 최상위 3명 6번티어. + *

+ * + * @param season + */ @Transactional public void updateAllTier(Season season) { List rankList = rankRepository.findAllBySeasonIdOrderByPppDesc(season.getId()); @@ -31,34 +45,20 @@ public void updateAllTier(Season season) { for (int i = 0; i < rankList.size(); i++) { Rank rank = rankList.get(i); - if (rank.getWins() == 0 && rank.getLosses() == 0) { + if (!rank.isParticipated()) { rank.updateTier(tierList.get(0)); + } else if (i < 3) { + rank.updateTier(tierList.get(6)); + } else if (rank.getPpp() < 970) { + rank.updateTier(tierList.get(1)); + } else if (rank.getPpp() < 1010) { + rank.updateTier(tierList.get(2)); + } else if (rank.getPpp() < 1050 || rank.getPpp() < top30percentPpp) { + rank.updateTier(tierList.get(3)); + } else if (rank.getPpp() < top10percentPpp) { + rank.updateTier(tierList.get(4)); } else { - if (i < 3) { - rank.updateTier(tierList.get(6)); - continue; - } - if (rank.getPpp() < 970) { - // 970 미만 - rank.updateTier(tierList.get(1)); - } else if (rank.getPpp() < 1010) { - // 970 - 1009 - rank.updateTier(tierList.get(2)); - } else if (rank.getPpp() < 1050) { - // 1010 - 1049 - rank.updateTier(tierList.get(3)); - } else if (rank.getPpp() >= 1050) { - if (rank.getPpp() >= top30percentPpp && rank.getPpp() < top10percentPpp) { - // 1050 이상, 30% 이상, 10% 미만 - rank.updateTier(tierList.get(4)); - } else if (rank.getPpp() >= top10percentPpp) { - // 1050 이상, 10% 이상 - rank.updateTier(tierList.get(5)); - } else { - // 1050 이상, 30% 미만 - rank.updateTier(tierList.get(3)); - } - } + rank.updateTier(tierList.get(5)); } } } diff --git a/src/test/java/com/gg/server/domain/tier/service/TierServiceUnitTest.java b/src/test/java/com/gg/server/domain/tier/service/TierServiceUnitTest.java new file mode 100644 index 000000000..e14086d62 --- /dev/null +++ b/src/test/java/com/gg/server/domain/tier/service/TierServiceUnitTest.java @@ -0,0 +1,172 @@ +package com.gg.server.domain.tier.service; + +import static org.mockito.Mockito.*; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import org.springframework.data.domain.Sort; + +import com.gg.server.data.game.Rank; +import com.gg.server.data.game.Season; +import com.gg.server.data.game.Tier; +import com.gg.server.data.user.User; +import com.gg.server.domain.rank.data.RankRepository; +import com.gg.server.domain.tier.data.TierRepository; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class TierServiceUnitTest { + + @Mock + TierRepository tierRepository; + @Mock + RankRepository rankRepository; + @InjectMocks + TierService tierService; + + @Nested + @DisplayName("UpdateAllTier") + class UpdateAllTier { + List tiers; + + Season season; + + @BeforeEach + void init() { + tiers = IntStream.range(0, 7).mapToObj((i) -> mock(Tier.class)).collect(Collectors.toList()); + when(tierRepository.findAll(any(Sort.class))).thenReturn(tiers); + season = mock(Season.class); + when(season.getId()).thenReturn(1L); + } + + @ParameterizedTest + @DisplayName("랭크 게임 미참여시 0번 티어") + @ValueSource(ints = {1, 3, 5, 7}) + @MockitoSettings(strictness = Strictness.LENIENT) + void notParticipant(int size) { + //Arrange + List rankList = IntStream.range(0, size) + .mapToObj((i) -> new Rank(mock(User.class), season, 1000, 0, 0, "", mock(Tier.class))) + .collect(Collectors.toList()); + when(rankRepository.findAllBySeasonIdOrderByPppDesc(any())).thenReturn(rankList); + when(rankRepository.countRealRankPlayers(any())).thenReturn(0L); + + //Act + tierService.updateAllTier(season); + + //Assert + Assertions.assertThat(rankList).allMatch((rank) -> rank.getTier().equals(tiers.get(0))); + } + + @ParameterizedTest + @DisplayName("참여한 유저 중 ppp 최대 3명 6번 티어") + @ValueSource(ints = {1, 3, 5, 7}) + @MockitoSettings(strictness = Strictness.LENIENT) + void top3(int size) { + //Arrange + List rankList = IntStream.range(0, size) + .mapToObj((i) -> new Rank(mock(User.class), season, 900 + 10 * i, 0, 1, "", mock(Tier.class))) + .sorted(Comparator.comparing(Rank::getPpp).reversed()) + .collect(Collectors.toList()); + when(rankRepository.findAllBySeasonIdOrderByPppDesc(any())).thenReturn(rankList); + when(rankRepository.countRealRankPlayers(any())).thenReturn((long)size); + + //Act + tierService.updateAllTier(season); + long cnt = rankList.stream().filter((rank) -> rank.getTier().equals(tiers.get(6))).count(); + + //Assert + Assertions.assertThat(cnt).isEqualTo(Math.min(3, size)); + } + + /** + * 개선 필요: 최상위 3명이 기본 ppp보다 낮을 경우 6번 티어가 0명이 된다. + * 게임상 재현은 불가능하지만 코드상 버그로 판단. + */ + @ParameterizedTest + @DisplayName("전체 티어 조건 검증") + @ValueSource(ints = {100}) + @MockitoSettings(strictness = Strictness.LENIENT) + void allTierCondition(int size) { + //Arrange + ArrayList rankArrayList = IntStream.range(0, size) + .mapToObj((i) -> new Rank(mock(User.class), season, 900 + 10 * i, 1, 0, "", mock(Tier.class))) + .collect(Collectors.toCollection(ArrayList::new)); + when(rankRepository.countRealRankPlayers(any())).thenReturn((long)size); + + IntStream.range(0, 100) + .mapToObj((i) -> new Rank(mock(User.class), season, 1000, 0, 0, "", mock(Tier.class))) + .forEach(rankArrayList::add); + when(rankRepository.countRealRankPlayers(any())).thenReturn((long)size); + + List rankList = rankArrayList.stream() + .sorted(Comparator.comparing(Rank::getPpp).reversed()) + .collect(Collectors.toList()); + when(rankRepository.findAllBySeasonIdOrderByPppDesc(any())).thenReturn(rankList); + + //Act + tierService.updateAllTier(season); + + List tier0 = rankList.stream() + .filter((rank) -> rank.getTier().equals(tiers.get(0))) + .collect(Collectors.toList()); + + List tier1 = rankList.stream() + .filter((rank) -> rank.getTier().equals(tiers.get(1))) + .collect(Collectors.toList()); + + List tier2 = rankList.stream() + .filter((rank) -> rank.getTier().equals(tiers.get(2))) + .collect(Collectors.toList()); + + List tier3 = rankList.stream() + .filter((rank) -> rank.getTier().equals(tiers.get(3))) + .collect(Collectors.toList()); + + List tier4 = rankList.stream() + .filter((rank) -> rank.getTier().equals(tiers.get(4))) + .sorted(Comparator.comparing(Rank::getPpp)) + .collect(Collectors.toList()); + Integer tier4MinPPP = tier4.get(0).getPpp(); + + List tier5 = rankList.stream() + .filter((rank) -> rank.getTier().equals(tiers.get(5))) + .sorted(Comparator.comparing(Rank::getPpp)) + .collect(Collectors.toList()); + Integer tier5MinPPP = tier5.get(0).getPpp(); + + List tier6 = rankList.stream() + .filter((rank) -> rank.getTier().equals(tiers.get(6))) + .sorted(Comparator.comparing(Rank::getPpp)) + .collect(Collectors.toList()); + Integer tier6MinPPP = tier6.get(0).getPpp(); + + //Assert + Assertions.assertThat(tier0).allMatch((rank) -> rank.getWins() == 0 && rank.getLosses() == 0); + Assertions.assertThat(tier1).allMatch((rank) -> rank.getPpp() < 970); + Assertions.assertThat(tier2).allMatch((rank) -> rank.getPpp() < 1010); + Assertions.assertThat(tier3).allMatch((rank) -> rank.getPpp() < tier4MinPPP); + Assertions.assertThat(tier4).allMatch((rank) -> rank.getPpp() < tier5MinPPP); + Assertions.assertThat(tier5).allMatch((rank) -> rank.getPpp() <= tier6MinPPP); + Assertions.assertThat(tier6.size()).isEqualTo(Math.min(3, size)); + } + } + +} From c311f573bad80eb38c8f73c55bfb583b00f20713 Mon Sep 17 00:00:00 2001 From: SeungChul Chung Date: Wed, 14 Feb 2024 14:24:27 +0900 Subject: [PATCH 20/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20UserAuthen?= =?UTF-8?q?ticationService=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20(#543)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/UserAuthenticationService.java | 6 ++ .../UserAuthenticationServiceUnitTest.java | 65 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 src/test/java/com/gg/server/domain/user/service/UserAuthenticationServiceUnitTest.java diff --git a/src/main/java/com/gg/server/domain/user/service/UserAuthenticationService.java b/src/main/java/com/gg/server/domain/user/service/UserAuthenticationService.java index 9010b08a1..a5f1ab2af 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserAuthenticationService.java +++ b/src/main/java/com/gg/server/domain/user/service/UserAuthenticationService.java @@ -14,6 +14,12 @@ public class UserAuthenticationService { private final JwtRedisRepository jwtRedisRepository; private final AuthTokenProvider tokenProvider; + /** + * Refresh 토큰으로 Access 토큰을 재발급. + * @throws TokenNotValidException 일치하는 Refresh 토큰 없는 경우 + * @param refreshToken Refresh 토큰 + * @return String Access 토큰 + */ public String regenerate(String refreshToken) { Long userId = jwtRedisRepository.getUserIdFromRefToken(refreshToken); if (userId == null) { diff --git a/src/test/java/com/gg/server/domain/user/service/UserAuthenticationServiceUnitTest.java b/src/test/java/com/gg/server/domain/user/service/UserAuthenticationServiceUnitTest.java new file mode 100644 index 000000000..1b4b0ba6e --- /dev/null +++ b/src/test/java/com/gg/server/domain/user/service/UserAuthenticationServiceUnitTest.java @@ -0,0 +1,65 @@ +package com.gg.server.domain.user.service; + +import static org.mockito.Mockito.*; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.domain.user.exception.TokenNotValidException; +import com.gg.server.global.security.jwt.repository.JwtRedisRepository; +import com.gg.server.global.security.jwt.utils.AuthTokenProvider; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class UserAuthenticationServiceUnitTest { + @Mock + JwtRedisRepository jwtRedisRepository; + + @Mock + AuthTokenProvider tokenProvider; + + @InjectMocks + UserAuthenticationService userAuthenticationService; + + @Nested + @DisplayName("regenerate") + class Regenerate { + @Test + @DisplayName("새로운 access token 반환") + void generateNewAccessToken() { + //Arrange + String refreshToken = "valid token"; + String newAccessToken = "new_access_token"; + Long userId = 1L; + + when(jwtRedisRepository.getUserIdFromRefToken(refreshToken)).thenReturn(userId); + when(tokenProvider.createToken(userId)).thenReturn(newAccessToken); + + //Act + String accessToken = userAuthenticationService.regenerate(refreshToken); + + //Assert + Assertions.assertThat(accessToken).isEqualTo(newAccessToken); + } + + @Test + @DisplayName("유효하지 않은 refreshToken TokenNotValidException 발생") + void refreshTokenInvalid() { + //Arrange + String refreshToken = "invalid token"; + + when(jwtRedisRepository.getUserIdFromRefToken(refreshToken)).thenReturn(null); + + //Act, Assert + Assertions.assertThatThrownBy(() -> userAuthenticationService.regenerate(refreshToken)) + .isInstanceOf(TokenNotValidException.class); + } + } +} From 8d778b1582b7f08397201819f7fe1b97cf56100b Mon Sep 17 00:00:00 2001 From: Newsujin <104690611+Newsujin@users.noreply.github.com> Date: Wed, 14 Feb 2024 14:24:38 +0900 Subject: [PATCH 21/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20NotiDomain?= =?UTF-8?q?Service=20=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20(#?= =?UTF-8?q?537)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: sujin --- .../domain/noti/service/NotiService.java | 68 +++- .../domain/noti/service/SnsNotiService.java | 12 + .../noti/service/sns/NotiMailSender.java | 12 + .../noti/service/NotiServiceUnitTest.java | 326 ++++++++++++++++++ .../noti/service/SnsNotiServiceUnitTest.java | 107 ++++++ .../service/sns/NotiMailSenderUnitTest.java | 67 ++++ 6 files changed, 586 insertions(+), 6 deletions(-) create mode 100644 src/test/java/com/gg/server/domain/noti/service/NotiServiceUnitTest.java create mode 100644 src/test/java/com/gg/server/domain/noti/service/SnsNotiServiceUnitTest.java create mode 100644 src/test/java/com/gg/server/domain/noti/service/sns/NotiMailSenderUnitTest.java diff --git a/src/main/java/com/gg/server/domain/noti/service/NotiService.java b/src/main/java/com/gg/server/domain/noti/service/NotiService.java index 56d3ee8c8..6c82fdd9c 100644 --- a/src/main/java/com/gg/server/domain/noti/service/NotiService.java +++ b/src/main/java/com/gg/server/domain/noti/service/NotiService.java @@ -29,6 +29,12 @@ public class NotiService { private final UserRepository userRepository; private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); + /** + * UserDto를 이용하여 User의 알림 목록을 조회합니다. + * @param userDto 유저 Dto + * @exception UserNotFoundException 유저가 존재하지 않을 경우 + * @return 알림 목록 + */ @Transactional(readOnly = true) public List findNotiByUser(UserDto userDto) { User user = userRepository.findById(userDto.getId()).orElseThrow(UserNotFoundException::new); @@ -39,6 +45,13 @@ public List findNotiByUser(UserDto userDto) { return notiResponseDtoList; } + /** + * UserDto와 notiId를 이용하여 User의 알림 목록을 조회합니다. + * @param userDto 유저 Dto + * @param notiId 알림 Id + * @exception UserNotFoundException 유저가 존재하지 않을 경우 + * @return 알림 목록 + */ @Transactional public NotiDto findNotiByIdAndUser(UserDto userDto, Long notiId) { User user = userRepository.findById(userDto.getId()).orElseThrow(UserNotFoundException::new); @@ -47,6 +60,11 @@ public NotiDto findNotiByIdAndUser(UserDto userDto, Long notiId) { return NotiDto.from(noti); } + /** + * 알림을 읽음 처리합니다. + * @param userDto 유저 Dto + * @exception UserNotFoundException 유저가 존재하지 않을 경우 + */ @Transactional public void modifyNotiCheckedByUser(UserDto userDto) { User user = userRepository.findById(userDto.getId()).orElseThrow(UserNotFoundException::new); @@ -56,17 +74,32 @@ public void modifyNotiCheckedByUser(UserDto userDto) { }); } + /** + * 알림을 제거합니다. + * @param notiId 알림 Id + */ @Transactional public void removeNotiById(Long notiId) { notiRepository.deleteById(notiId); } + /** + * 알림 목록 전체를 제거합니다. + * @param userDto 유저 Dto + * @exception UserNotFoundException 유저가 존재하지 않을 경우 + */ @Transactional public void removeAllNotisByUser(UserDto userDto) { User user = userRepository.findById(userDto.getId()).orElseThrow(UserNotFoundException::new); notiRepository.deleteAllByUser(user); } + /** + * 매칭 성사 알림을 생성합니다. + * @param user 유저 + * @param startTime 경기 시작 시간 + * @return 매칭 성사 알림 + */ @Transactional public Noti createMatched(User user, LocalDateTime startTime) { String notiMessage = startTime.format(DateTimeFormatter.ofPattern("HH:mm")) + "에 신청한 매칭이 성사되었습니다."; @@ -75,6 +108,12 @@ public Noti createMatched(User user, LocalDateTime startTime) { return noti; } + /** + * 매칭 취소 알림을 생성합니다. + * @param user 유저 + * @param startTime 경기 시작 시간 + * @return 매칭 취소 알림 + */ @Transactional public Noti createMatchCancel(User user, LocalDateTime startTime) { String notiMessage = startTime.format(DateTimeFormatter.ofPattern("HH:mm")) + "에 신청한 매칭이 상대에 의해 취소되었습니다."; @@ -83,6 +122,13 @@ public Noti createMatchCancel(User user, LocalDateTime startTime) { return noti; } + /** + * 아이템 선물 알림을 생성합니다. + * @param ownerUser 선물 받은 유저 + * @param payUser 선물한 유저 + * @param itemName 아이템 이름 + * @return 아이템 선물 알림 + */ @Transactional public Noti createGiftNoti(User ownerUser, User payUser, String itemName) { String notiMessage = "ଘ(੭ˊᵕˋ)੭* ੈ✩ " + payUser.getIntraId() + "님에게 " + itemName + " 아이템을 선물받았어요!"; @@ -91,24 +137,34 @@ public Noti createGiftNoti(User ownerUser, User payUser, String itemName) { return noti; } + /** + * 경기 임박 알림을 생성합니다. + * @param user 유저 + * @param enemyIntra 상대팀 인트라 아이디 + * @param notiType 알림 타입 + * @param gameOpenMinute 게임 시간 + * @return 경기 임박 알림 + */ public Noti createImminentNoti(User user, String enemyIntra, NotiType notiType, Integer gameOpenMinute) { String msg = "님과 경기 " + gameOpenMinute + "분 전 입니다. 서두르세요!"; return notiRepository.save(new Noti(user, notiType, msg, false)); } + /** + * 알림 메시지를 가져옵니다. + * @param noti 알림 + * @return 알림 메시지 + */ public String getMessage(Noti noti) { String message; if (noti.getType() != NotiType.ANNOUNCE) { - message = notiMsg(noti.getType()); + message = + "🧚: \"새로운 알림이 도착했핑.\"\n" + "🧚: \"" + noti.getType().getMessage() + "\"\n\n 🏓42GG와 함께하는 행복한 탁구생활🏓" + + "\n$$지금 즉시 접속$$ ----> https://42gg.kr"; } else { message = "🧚: \"새로운 알림이 도착했핑.\"\n" + "🧚: \"" + noti.getType().getMessage() + "\"\n\n공지사항: " + noti.getMessage() + "\n\n 🏓42GG와 함께하는 행복한 탁구생활🏓" + "\n$$지금 즉시 접속$$ ----> https://42gg.kr"; } return message; } - - public String notiMsg(NotiType notiType) { - return "🧚: \"새로운 알림이 도착했핑.\"\n" + "🧚: \"" + notiType.getMessage() + "\"\n\n 🏓42GG와 함께하는 행복한 탁구생활🏓" - + "\n$$지금 즉시 접속$$ ----> https://42gg.kr"; - } } diff --git a/src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java b/src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java index f63ec95fd..b127cff83 100644 --- a/src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java +++ b/src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java @@ -23,6 +23,12 @@ public SnsNotiService(NotiMailSender notiMailSender, SlackbotService slackbotSer this.slackbotService = slackbotService; } + /** + * 유저가 설정해둔 알림 옵션(email, slack, both, none)에 따라 알림을 전송합니다. + * UserNotiDto 이용 + * @param noti 알림 + * @param user 유저 + */ @Transactional(readOnly = true) public void sendSnsNotification(Noti noti, UserNotiDto user) { log.info("Send Sns Noti"); @@ -40,6 +46,12 @@ public void sendSnsNotification(Noti noti, UserNotiDto user) { } } + /** + * 유저가 설정해둔 알림 옵션(email, slack, both, none)에 따라 알림을 전송합니다. + * UserDto 이용 + * @param noti 알림 + * @param user 유저 + */ @Transactional(readOnly = true) public void sendSnsNotification(Noti noti, UserDto user) { log.info("Send Sns Noti"); diff --git a/src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java b/src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java index e801211d1..c743f938c 100644 --- a/src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java +++ b/src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java @@ -24,6 +24,12 @@ public class NotiMailSender { private final AsyncMailSender asyncMailSender; private final NotiService notiService; + /** + * 알림을 전송합니다. + * UserNotiDto 이용 + * @param user 유저 + * @param noti 알림 + */ public void send(UserNotiDto user, Noti noti) { MimeMessage message = javaMailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message); @@ -39,6 +45,12 @@ public void send(UserNotiDto user, Noti noti) { asyncMailSender.send(message); } + /** + * 알림을 전송합니다. + * UserDto 이용 + * @param user 유저 + * @param noti 알림 + */ public void send(UserDto user, Noti noti) { MimeMessage message = javaMailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message); diff --git a/src/test/java/com/gg/server/domain/noti/service/NotiServiceUnitTest.java b/src/test/java/com/gg/server/domain/noti/service/NotiServiceUnitTest.java new file mode 100644 index 000000000..41f7f185f --- /dev/null +++ b/src/test/java/com/gg/server/domain/noti/service/NotiServiceUnitTest.java @@ -0,0 +1,326 @@ +package com.gg.server.domain.noti.service; + +import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.mockito.BDDMockito.*; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Optional; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.domain.noti.data.Noti; +import com.gg.server.domain.noti.data.NotiRepository; +import com.gg.server.domain.noti.type.NotiType; +import com.gg.server.domain.user.data.User; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.exception.UserNotFoundException; +import com.gg.server.domain.user.type.RacketType; +import com.gg.server.domain.user.type.RoleType; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.global.exception.custom.NotExistException; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +@DisplayName("NotiServiceUnitTest") +class NotiServiceUnitTest { + @Mock + NotiRepository notiRepository; + @Mock + UserRepository userRepository; + @InjectMocks + NotiService notiService; + + @Nested + @DisplayName("findNotiByUser 메서드 테스트") + class FindNotiByUserTest { + @Test + @DisplayName("success") + void success() { + //given + Long userId = 1L; + UserDto userDto = mock(UserDto.class); + when(userDto.getId()).thenReturn(userId); + User user = new User("username", "email@example.com", "password", RacketType.NONE, RoleType.USER, + 0, SnsType.NONE, userId); + when(userRepository.findById(userId)).thenReturn(Optional.of(user)); + when(notiRepository.findAllByUserOrderByIdDesc(user)).thenReturn(List.of(new Noti())); + //when + notiService.findNotiByUser(userDto); + //then + verify(userRepository, times(1)).findById(userId); + verify(notiRepository, times(1)).findAllByUserOrderByIdDesc(user); + } + + @Test + @DisplayName("userNotFoundException") + void userNotFoundException() { + //given + UserDto userDto = mock(UserDto.class); + when(userRepository.findById(any(Long.class))).thenReturn(Optional.empty()); + //when, then + assertThatThrownBy(() -> notiService.findNotiByUser(userDto)) + .isInstanceOf(UserNotFoundException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(notiRepository, never()).findAllByUserOrderByIdDesc(any(User.class)); + + } + } + + @Nested + @DisplayName("findNotiByIdAndUser 메서드 테스트") + class FindNotiByIdAndUserTest { + @Test + @DisplayName("success") + void success() { + //given + Long userId = 1L; + UserDto userDto = mock(UserDto.class); + when(userDto.getId()).thenReturn(userId); + given(userRepository.findById(any(long.class))).willReturn(Optional.of(mock(User.class))); + given(notiRepository.findByIdAndUser(any(Long.class), any(User.class))).willReturn( + Optional.of(mock(Noti.class))); + //when + notiService.findNotiByIdAndUser(userDto, 1L); + //then + verify(userRepository, times(1)).findById(userId); + verify(notiRepository, times(1)).findByIdAndUser(any(Long.class), any(User.class)); + } + + @Test + @DisplayName("userNotFoundException") + void userNotFoundException() { + //given + Long userId = 1L; + UserDto userDto = mock(UserDto.class); + when(userDto.getId()).thenReturn(userId); + given(userRepository.findById(any(long.class))).willReturn(Optional.empty()); + //when, then + assertThatThrownBy(() -> notiService.findNotiByIdAndUser(userDto, 1L)) + .isInstanceOf(UserNotFoundException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(notiRepository, never()).findByIdAndUser(any(Long.class), any(User.class)); + } + + @Test + @DisplayName("notExistException") + void notExistException() { + //given + Long userId = 1L; + UserDto userDto = mock(UserDto.class); + when(userDto.getId()).thenReturn(userId); + User user = new User("username", "email@example.com", "password", RacketType.NONE, RoleType.USER, + 0, SnsType.NONE, userId); + given(userRepository.findById(any(long.class))).willReturn(Optional.of(mock(User.class))); + given(notiRepository.findByIdAndUser(any(Long.class), any(User.class))).willReturn(Optional.empty()); + //when, then + assertThatThrownBy(() -> notiService.findNotiByIdAndUser(userDto, 1L)) + .isInstanceOf(NotExistException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(notiRepository, times(1)).findByIdAndUser(any(Long.class), any(User.class)); + } + } + + @Nested + @DisplayName("modifyNotiCheckedByUser 메서드 테스트") + class ModifyNotiCheckedByUserTest { + @Test + @DisplayName("success") + void success() { + //given + Long userId = 1L; + UserDto userDto = mock(UserDto.class); + when(userDto.getId()).thenReturn(userId); + User user = new User("username", "email@example.com", "password", RacketType.NONE, RoleType.USER, + 0, SnsType.NONE, userId); + List notis = List.of(new Noti()); + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(mock(User.class))); + given(notiRepository.findAllByUser(any(User.class))).willReturn(notis); + //when + notiService.modifyNotiCheckedByUser(userDto); + //then + verify(userRepository, times(1)).findById(any(Long.class)); + verify(notiRepository, times(1)).findAllByUser(any(User.class)); + } + + @Test + @DisplayName("userNotFoundException") + void userNotFoundException() { + //given + Long userId = 1L; + UserDto userDto = mock(UserDto.class); + when(userDto.getId()).thenReturn(userId); + given(userRepository.findById(any(long.class))).willReturn(Optional.empty()); + //when, then + assertThatThrownBy(() -> notiService.modifyNotiCheckedByUser(userDto)) + .isInstanceOf(UserNotFoundException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(notiRepository, never()).findAllByUser(any(User.class)); + } + } + + @Nested + @DisplayName("removeNotiById 메서드 테스트") + class RemoveNotiByIdTest { + @Test + @DisplayName("success") + void success() { + //when + notiService.removeNotiById(1L); + //then + verify(notiRepository, times(1)).deleteById(any(Long.class)); + } + } + + @Nested + @DisplayName("removeAllNotisByUser 메서드 테스트") + class RemoveAllNotisByUserTest { + @Test + @DisplayName("success") + void success() { + //given + given(userRepository.findById(any(Long.class))).willReturn(Optional.of(mock(User.class))); + //when + notiService.removeAllNotisByUser(mock(UserDto.class)); + //then + verify(userRepository, times(1)).findById(any(Long.class)); + verify(notiRepository, times(1)).deleteAllByUser(any(User.class)); + } + + @Test + @DisplayName("userNotFoundException") + void userNotFoundException() { + //given + given(userRepository.findById(any(Long.class))).willReturn(Optional.empty()); + //when, then + assertThatThrownBy(() -> notiService.removeAllNotisByUser(mock(UserDto.class))) + .isInstanceOf(UserNotFoundException.class); + verify(userRepository, times(1)).findById(any(Long.class)); + verify(notiRepository, never()).deleteAllByUser(any(User.class)); + } + } + + @Nested + @DisplayName("createMatched 메서드 테스트") + class CreateMatchedTest { + @Test + @DisplayName("success") + void success() { + //given + User user = mock(User.class); + LocalDateTime startTime = LocalDateTime.now(); + //when + Noti result = notiService.createMatched(user, startTime); + //then + verify(notiRepository, times(1)).save(any(Noti.class)); + assertThat(result.getUser()).isEqualTo(user); + assertThat(result.getType()).isEqualTo(NotiType.MATCHED); + assertThat(result.getMessage()).isEqualTo( + startTime.format(DateTimeFormatter.ofPattern("HH:mm")) + "에 신청한 매칭이 성사되었습니다."); + assertThat(result.getIsChecked()).isEqualTo(false); + } + } + + @Nested + @DisplayName("createMatchCancel 메서드 테스트") + class CreateMatchCancelTest { + @Test + @DisplayName("success") + void success() { + //given + User user = mock(User.class); + LocalDateTime startTime = LocalDateTime.now(); + //when + Noti result = notiService.createMatchCancel(user, startTime); + //then + verify(notiRepository, times(1)).save(any(Noti.class)); + assertThat(result.getUser()).isEqualTo(user); + assertThat(result.getType()).isEqualTo(NotiType.CANCELEDBYMAN); + assertThat(result.getMessage()).isEqualTo( + startTime.format(DateTimeFormatter.ofPattern("HH:mm")) + "에 신청한 매칭이 상대에 의해 취소되었습니다."); + assertThat(result.getIsChecked()).isEqualTo(false); + } + } + + @Nested + @DisplayName("createGiftNoti 메서드 테스트") + class CreateGiftNotiTest { + @Test + @DisplayName("success") + void success() { + //given + User ownerUser = mock(User.class); + User payUser = mock(User.class); + String itemName = "테스트 아이템"; + //when + Noti result = notiService.createGiftNoti(ownerUser, payUser, itemName); + //then + verify(notiRepository, times(1)).save(any(Noti.class)); + assertThat(result.getType()).isEqualTo(NotiType.GIFT); + assertThat(result.getMessage()).isEqualTo( + "ଘ(੭ˊᵕˋ)੭* ੈ✩ " + payUser.getIntraId() + "님에게 " + itemName + " 아이템을 선물받았어요!"); + assertThat(result.getIsChecked()).isEqualTo(false); + } + } + + @Nested + @DisplayName("createImminentNoti 메서드 테스트") + class CreateImminentNotiTest { + @Test + @DisplayName("success") + void success() { + //given + String enemyIntra = "testEnemyIntra"; + NotiType notiType = NotiType.IMMINENT; + Integer gameOpenMinute = 15; + given(notiRepository.save(any(Noti.class))).willReturn(mock(Noti.class)); + //when + Noti result = notiService.createImminentNoti(mock(User.class), enemyIntra, notiType, gameOpenMinute); + //then + verify(notiRepository, times(1)).save(any(Noti.class)); + assertThat(result).isNotNull(); + } + } + + // @MockitoSettings(strictness = Strictness.LENIENT) + @Nested + @DisplayName("getMessage 메서드 테스트") + class GetMessageTest { + @Test + @DisplayName("공지사항 알림 메시지") + void announce() { + //given + Noti noti = mock(Noti.class); + when(noti.getType()).thenReturn(NotiType.ANNOUNCE); + when(noti.getMessage()).thenReturn("testMessage"); + //when + String message = notiService.getMessage(noti); + //then + assertThat(message).contains("새로운 알림이 도착했핑", "testMessage", "공지사항", "42GG와 함께하는 행복한 탁구생활", + "$$지금 즉시 접속$$ ----> https://42gg.kr"); + } + + @Test + @DisplayName("공지사항 외 알림 메시지") + void nonannounce() { + //given + Noti noti = mock(Noti.class); + when(noti.getType()).thenReturn(NotiType.MATCHED); + //when + String message = notiService.getMessage(noti); + //then + assertThat(message).doesNotContain("공지사항"); + assertThat(message).contains("새로운 알림이 도착했핑", "42GG와 함께하는 행복한 탁구생활", + "$$지금 즉시 접속$$ ----> https://42gg.kr"); + } + } +} diff --git a/src/test/java/com/gg/server/domain/noti/service/SnsNotiServiceUnitTest.java b/src/test/java/com/gg/server/domain/noti/service/SnsNotiServiceUnitTest.java new file mode 100644 index 000000000..25e6b78ed --- /dev/null +++ b/src/test/java/com/gg/server/domain/noti/service/SnsNotiServiceUnitTest.java @@ -0,0 +1,107 @@ +package com.gg.server.domain.noti.service; + +import static org.mockito.Mockito.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.domain.noti.data.Noti; +import com.gg.server.domain.noti.dto.UserNotiDto; +import com.gg.server.domain.noti.service.sns.NotiMailSender; +import com.gg.server.domain.noti.service.sns.SlackbotService; +import com.gg.server.domain.team.dto.GameUser; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.type.SnsType; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +@DisplayName("SnsNotiServiceTest") +class SnsNotiServiceUnitTest { + @Mock + NotiMailSender notiMailSender; + @Mock + SlackbotService slackbotService; + @InjectMocks + SnsNotiService snsNotiService; + + @Nested + @DisplayName("sendSnsNotification 메서드 Test") + class SendSnsNotificationTest { + @Test + @DisplayName("Email") + void sendSnsNotificationWithEmail() { + //given + Noti noti = new Noti(); + UserDto userDto = mock(UserDto.class); + when(userDto.getSnsNotiOpt()).thenReturn(SnsType.EMAIL); + //when + snsNotiService.sendSnsNotification(noti, userDto); + //then + verify(slackbotService, never()).send(any(UserDto.class), any(Noti.class)); + verify(notiMailSender, times(1)).send(any(UserDto.class), any(Noti.class)); + } + + @Test + @DisplayName("Slack") + void sendSnsNotificationWithSlack() { + //given + Noti noti = new Noti(); + UserDto userDto = mock(UserDto.class); + when(userDto.getSnsNotiOpt()).thenReturn(SnsType.SLACK); + //when + snsNotiService.sendSnsNotification(noti, userDto); + //then + verify(notiMailSender, never()).send(any(UserDto.class), any(Noti.class)); + verify(slackbotService, times(1)).send(any(UserDto.class), any(Noti.class)); + } + + @Test + @DisplayName("Both") + void sendSnsNotificationWithBoth() { + //given + Noti noti = new Noti(); + UserDto userDto = mock(UserDto.class); + when(userDto.getSnsNotiOpt()).thenReturn(SnsType.BOTH); + //when + snsNotiService.sendSnsNotification(noti, userDto); + //then + verify(notiMailSender, times(1)).send(any(UserDto.class), any(Noti.class)); + verify(slackbotService, times(1)).send(any(UserDto.class), any(Noti.class)); + } + + @Test + @DisplayName("None") + void sendSnsNotificationWithNone() { + //given + Noti noti = new Noti(); + UserDto userDto = mock(UserDto.class); + when(userDto.getSnsNotiOpt()).thenReturn(SnsType.NONE); + //when + snsNotiService.sendSnsNotification(noti, userDto); + //then + verify(notiMailSender, never()).send(any(UserDto.class), any(Noti.class)); + verify(slackbotService, never()).send(any(UserDto.class), any(Noti.class)); + } + + @Test + @DisplayName("sendSnsNotificationWithUserNotiDto") + void sendSnsNotificationWithUserNotiDto() { + //given + Noti noti = new Noti(); + GameUser gameUser = mock(GameUser.class); + when(gameUser.getSnsNotiOpt()).thenReturn(SnsType.EMAIL); + UserNotiDto user = new UserNotiDto(gameUser); + //when + snsNotiService.sendSnsNotification(noti, user); + //then + verify(notiMailSender, times(1)).send(user, noti); + verify(slackbotService, never()).send(any(UserNotiDto.class), any(Noti.class)); + } + } +} diff --git a/src/test/java/com/gg/server/domain/noti/service/sns/NotiMailSenderUnitTest.java b/src/test/java/com/gg/server/domain/noti/service/sns/NotiMailSenderUnitTest.java new file mode 100644 index 000000000..355997eac --- /dev/null +++ b/src/test/java/com/gg/server/domain/noti/service/sns/NotiMailSenderUnitTest.java @@ -0,0 +1,67 @@ +package com.gg.server.domain.noti.service.sns; + +import static org.mockito.Mockito.*; + +import javax.mail.internet.MimeMessage; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.mail.javamail.JavaMailSender; + +import com.gg.server.domain.noti.data.Noti; +import com.gg.server.domain.noti.dto.UserNotiDto; +import com.gg.server.domain.noti.service.NotiService; +import com.gg.server.domain.team.dto.GameUser; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.global.utils.AsyncMailSender; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +@DisplayName("NotiMailSenderUnitTest") +class NotiMailSenderUnitTest { + @Mock + JavaMailSender javaMailSender; + @Mock + AsyncMailSender asyncMailSender; + @Mock + NotiService notiService; + @InjectMocks + NotiMailSender notiMailSender; + + @Test + @DisplayName("UserNotiDto를 이용하여 유저 이메일로 메일 보내기") + void sendToUserEmailByUserNotiDto() { + // given + GameUser gameUser = mock(GameUser.class); + MimeMessage mimeMessage = mock(MimeMessage.class); + when(gameUser.getEmail()).thenReturn("testEmail"); + when(javaMailSender.createMimeMessage()).thenReturn(mimeMessage); + when(notiService.getMessage(any(Noti.class))).thenReturn("Test message"); + // when + notiMailSender.send(new UserNotiDto(gameUser), new Noti()); + // then + verify(javaMailSender).createMimeMessage(); + verify(asyncMailSender).send(mimeMessage); + } + + @Test + @DisplayName("UserDto를 이용하여 유저 이메일로 메일 보내기") + void sendToUserEmailByUserDto() { + // given + UserDto userDto = mock(UserDto.class); + MimeMessage mimeMessage = mock(MimeMessage.class); + when(userDto.getEMail()).thenReturn("testEmail"); + when(javaMailSender.createMimeMessage()).thenReturn(mimeMessage); + when(notiService.getMessage(any(Noti.class))).thenReturn("Test message"); + // when + notiMailSender.send(userDto, new Noti()); + // then + verify(javaMailSender).createMimeMessage(); + verify(asyncMailSender).send(mimeMessage); + } +} From 17cad83756a3f3d3510f5913e96d6d7bd682e211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=90=ED=9B=88?= Date: Wed, 14 Feb 2024 14:24:53 +0900 Subject: [PATCH 22/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20Season=20?= =?UTF-8?q?=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20(#535)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../season/data/SeasonAdminRepository.java | 2 + .../season/service/SeasonAdminService.java | 139 ++++--- .../service/SeasonAdminServiceUnitTest.java | 375 ++++++++++++++++++ .../season/service/SeasonServiceUnitTest.java | 65 +++ 4 files changed, 524 insertions(+), 57 deletions(-) create mode 100644 src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java create mode 100644 src/test/java/com/gg/server/domain/season/service/SeasonServiceUnitTest.java diff --git a/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java b/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java index 7dc837025..c3b69b0b4 100644 --- a/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java +++ b/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java @@ -22,4 +22,6 @@ public interface SeasonAdminRepository extends JpaRepository { Optional findCurrentSeason(@Param("now") LocalDateTime now); List findAllByOrderByStartTimeDesc(); + + List findAllByOrderByStartTimeAsc(); } diff --git a/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java b/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java index 1314e95b9..65aa52743 100644 --- a/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java +++ b/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java @@ -27,6 +27,10 @@ public class SeasonAdminService { private final RankRedisAdminService rankRedisAdminService; private final RankAdminService rankAdminService; + /** + *

모든 시즌을 찾아서 반환해주는 메서드입니다.

+ * @return + */ public List findAllSeasons() { List seasons = seasonAdminRepository.findAllByOrderByStartTimeDesc(); List dtoList = new ArrayList<>(); @@ -37,6 +41,11 @@ public List findAllSeasons() { return dtoList; } + /** + *

현재 시간보다 이후의 시간에 시작하는 새로운 시즌을 추가한다.

+ *

새로운 시즌을 예약하는 메서드이다. 예약 중인 시즌이 여러개일 수 도 있다.

+ * @param createDto dto + */ @Transactional public void createSeason(SeasonCreateRequestDto createDto) { Season newSeason = new Season(createDto); @@ -46,81 +55,83 @@ public void createSeason(SeasonCreateRequestDto createDto) { checkSeasonAtDB(); - Long seasonId = newSeason.getId(); - SeasonAdminDto seasonAdminDto = findSeasonById(seasonId); - - if (LocalDateTime.now().isBefore(seasonAdminDto.getStartTime())) { - rankAdminService.addAllUserRankByNewSeason(seasonAdminDto); - rankRedisAdminService.addAllUserRankByNewSeason(seasonAdminDto); - } + SeasonAdminDto seasonAdminDto = new SeasonAdminDto(newSeason); + rankAdminService.addAllUserRankByNewSeason(seasonAdminDto); + rankRedisAdminService.addAllUserRankByNewSeason(seasonAdminDto); } + /** + *

타겟 시즌을 찾는 메서드입니다.

+ * @param seasonId 타겟 시즌 아이디 + * @return + */ @Transactional public SeasonAdminDto findSeasonById(Long seasonId) { - Season season = seasonAdminRepository.findById(seasonId).orElseThrow(() -> new SeasonNotFoundException()); + Season season = seasonAdminRepository.findById(seasonId).orElseThrow(SeasonNotFoundException::new); return new SeasonAdminDto(season); } + /** + *

예약된 시즌을 삭제한다.

+ * @param seasonId 타겟 예약 시즌 아이디 + */ @Transactional public void deleteSeason(Long seasonId) { - SeasonAdminDto seasonDto = findSeasonById(seasonId); - - Season season = seasonAdminRepository.findById(seasonDto.getSeasonId()) - .orElseThrow(() -> new SeasonNotFoundException()); + Season season = seasonAdminRepository.findById(seasonId).orElseThrow(SeasonNotFoundException::new); detach(season); - - if (LocalDateTime.now().isBefore(seasonDto.getStartTime())) { - rankAdminService.deleteAllUserRankBySeason(seasonDto); - rankRedisAdminService.deleteSeasonRankBySeasonId(seasonDto.getSeasonId()); - seasonAdminRepository.delete(season); - } + SeasonAdminDto seasonDto = new SeasonAdminDto(season); + rankAdminService.deleteAllUserRankBySeason(seasonDto); + rankRedisAdminService.deleteSeasonRankBySeasonId(seasonId); + seasonAdminRepository.delete(season); checkSeasonAtDB(); } + /** + *

예약된 시즌을 정보를 수정합니다.

+ *

현재 시즌은 수정 버튼이 있지만 구현이 안되어 있어서 에러가 발생함. -> 추후 수정해야함

+ * @param seasonId + * @param updateDto + */ @Transactional public void updateSeason(Long seasonId, SeasonUpdateRequestDto updateDto) { - Season season = seasonAdminRepository.findById(seasonId) - .orElseThrow(() -> new SeasonNotFoundException()); + Season season = seasonAdminRepository.findById(seasonId).orElseThrow(SeasonNotFoundException::new); if (LocalDateTime.now().isAfter(season.getStartTime())) { throw new SeasonForbiddenException(); } + // 예약 시즌 수정 + detach(season); + season.setSeasonName(updateDto.getSeasonName()); + season.setStartTime(updateDto.getStartTime()); + season.setStartPpp(updateDto.getStartPpp()); + season.setPppGap(updateDto.getPppGap()); + insert(season); + seasonAdminRepository.save(season); + checkSeasonAtDB(); - if (LocalDateTime.now().isBefore(season.getStartTime())) { - detach(season); - season.setSeasonName(updateDto.getSeasonName()); - season.setStartTime(updateDto.getStartTime()); - season.setStartPpp(updateDto.getStartPpp()); - season.setPppGap(updateDto.getPppGap()); - insert(season); - seasonAdminRepository.save(season); - checkSeasonAtDB(); - } + SeasonAdminDto seasonAdminDto = new SeasonAdminDto(season); + rankAdminService.deleteAllUserRankBySeason(seasonAdminDto); + rankAdminService.addAllUserRankByNewSeason(seasonAdminDto); + rankRedisAdminService.deleteSeasonRankBySeasonId(seasonAdminDto.getSeasonId()); + rankRedisAdminService.addAllUserRankByNewSeason(seasonAdminDto); - SeasonAdminDto seasonAdminDto = findSeasonById(seasonId); - if (LocalDateTime.now().isBefore(seasonAdminDto.getStartTime())) { - rankAdminService.deleteAllUserRankBySeason(seasonAdminDto); - rankAdminService.addAllUserRankByNewSeason(seasonAdminDto); - rankRedisAdminService.deleteSeasonRankBySeasonId(seasonAdminDto.getSeasonId()); - rankRedisAdminService.addAllUserRankByNewSeason(seasonAdminDto); - } } + /** + *

추가 하고자하는 season이 현재 시간부터 24시간 후가 아니면 에러

+ * @param season + */ private void insert(Season season) { - List beforeSeasons = seasonAdminRepository.findBeforeSeasons(season.getStartTime()); - Season beforeSeason; - if (beforeSeasons.isEmpty()) { - beforeSeason = null; - } else { - beforeSeason = beforeSeasons.get(0).getId() != season.getId() ? beforeSeasons.get(0) : beforeSeasons.get(1); + if (LocalDateTime.now().plusHours(24).isAfter(season.getStartTime())) { + throw new SeasonTimeBeforeException(); } + + List beforeSeasons = seasonAdminRepository.findBeforeSeasons(season.getStartTime()); + Season beforeSeason = beforeSeasons.isEmpty() ? null : beforeSeasons.get(0); List afterSeasons = seasonAdminRepository.findAfterSeasons(season.getStartTime()); Season afterSeason = afterSeasons.isEmpty() ? null : afterSeasons.get(0); - if (LocalDateTime.now().plusHours(24).isAfter(season.getStartTime())) { - throw new SeasonTimeBeforeException(); - } if (beforeSeason != null) { if (beforeSeason.getStartTime().plusDays(1).isAfter(season.getStartTime())) { throw new SeasonForbiddenException(); @@ -134,36 +145,50 @@ private void insert(Season season) { } } + /** + *

타겟 시즌의 앞뒤 시즌끼리 이어주는 메서드이다

+ * @param season + */ private void detach(Season season) { + // 이미 해당 시즌 중간 || 이전 시즌 + if ((LocalDateTime.now().isAfter(season.getStartTime()) && LocalDateTime.now().isBefore(season.getEndTime())) + || season.getEndTime().isBefore(LocalDateTime.now())) { + throw new SeasonForbiddenException(); + } + List beforeSeasons = seasonAdminRepository.findBeforeSeasons(season.getStartTime()); Season beforeSeason = beforeSeasons.isEmpty() ? null : beforeSeasons.get(0); List afterSeasons = seasonAdminRepository.findAfterSeasons(season.getStartTime()); Season afterSeason = afterSeasons.isEmpty() ? null : afterSeasons.get(0); - if ((LocalDateTime.now().isAfter(season.getStartTime()) && LocalDateTime.now().isBefore(season.getEndTime())) - || season.getEndTime().isBefore(LocalDateTime.now())) { - throw new SeasonForbiddenException(); - } if (beforeSeason != null) { if (afterSeason != null) { beforeSeason.setEndTime(afterSeason.getStartTime().minusSeconds(1)); } else { - beforeSeason.setEndTime(LocalDateTime.of(9999, 12, 31, 23, 59, 59)); + beforeSeason.setEndTime( + LocalDateTime.of(9999, 12, 31, 23, 59, 59)); } } } + /** + *

시즌들의 시작, 종료 시간 체크 메서드이다

+ */ private void checkSeasonAtDB() { - List seasons = seasonAdminRepository.findAll(); - for (int i = 0; i < seasons.size(); i++) { - for (int j = i + 1; j < seasons.size(); j++) { - if (isOverlap(seasons.get(i), seasons.get(j))) { - throw new SeasonForbiddenException(); - } + List seasons = seasonAdminRepository.findAllByOrderByStartTimeAsc(); + for (int i = 1; i < seasons.size(); i++) { + if (isOverlap(seasons.get(i - 1), seasons.get(i))) { + throw new SeasonForbiddenException(); } } } + /** + *

시즌끼리의 겹치는 기간이 있는지 판별하느 메서드 입니다.

+ * @param season1 + * @param season2 + * @return + */ private boolean isOverlap(Season season1, Season season2) { LocalDateTime start1 = season1.getStartTime(); LocalDateTime end1 = season1.getEndTime(); diff --git a/src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java b/src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java new file mode 100644 index 000000000..bc3101bff --- /dev/null +++ b/src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java @@ -0,0 +1,375 @@ +package com.gg.server.admin.season.service; + +import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static org.assertj.core.api.Assertions.*; +import static org.mockito.BDDMockito.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.admin.rank.service.RankAdminService; +import com.gg.server.admin.rank.service.RankRedisAdminService; +import com.gg.server.admin.season.data.SeasonAdminRepository; +import com.gg.server.admin.season.dto.SeasonCreateRequestDto; +import com.gg.server.admin.season.dto.SeasonUpdateRequestDto; +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.exception.SeasonForbiddenException; +import com.gg.server.domain.season.exception.SeasonNotFoundException; +import com.gg.server.domain.season.exception.SeasonTimeBeforeException; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class SeasonAdminServiceUnitTest { + @Mock + SeasonAdminRepository seasonAdminRepository; + @Mock + RankRedisAdminService rankRedisAdminService; + @Mock + RankAdminService rankAdminService; + @InjectMocks + SeasonAdminService seasonAdminService; + + int beforeSeasonCnt = 3; + int afterSeasonCnt = 2; + List beforeSeasons = new ArrayList<>(); + List afterSeasons = new ArrayList<>(); + + @BeforeEach + void beforeEach() { + LocalDateTime time = LocalDateTime.now(); + beforeSeasons.clear(); + afterSeasons.clear(); + for (int i = 0; i < beforeSeasonCnt; i++) { + beforeSeasons.add(new Season("season" + i, + time.minusDays(i + 1).minusSeconds(1), time.minusDays(i).minusSeconds(2), 1000, 200)); + } + for (int i = 0; i < afterSeasonCnt; i++) { + afterSeasons.add(new Season("season" + (i + beforeSeasonCnt), + time.plusDays(i + 3).minusSeconds(1), time.plusDays(i + 4).minusSeconds(2), 1000, 200)); + } + } + + @Nested + @DisplayName("findAllSeasons() 유닛 테스트") + class FindAllSeasons { + @Test + @DisplayName("success") + void success() { + // given + given(seasonAdminRepository.findAllByOrderByStartTimeDesc()).willReturn(beforeSeasons); + // when, then + seasonAdminService.findAllSeasons(); + verify(seasonAdminRepository, times(1)).findAllByOrderByStartTimeDesc(); + } + } + + @Nested + @DisplayName("createSeason() 유닛 테스트") + class CreateSeason { + SeasonCreateRequestDto requestDto; + Season season; + ArrayList beforeSeasonsAsc; + + @BeforeEach + void beforeEach() { + requestDto = new SeasonCreateRequestDto("season", LocalDateTime.now().plusDays(1).plusSeconds(1), + 1000, 200); + season = new Season(requestDto); + setFieldWithReflection(beforeSeasons.get(0), "id", 2L); + beforeSeasonsAsc = new ArrayList<>(beforeSeasons); + Collections.reverse(beforeSeasonsAsc); + } + + @Test + @DisplayName("success_이전시즌x&예약시즌x") + void success1() { + // given + given(seasonAdminRepository.findBeforeSeasons(any(LocalDateTime.class))).willReturn(new ArrayList<>()); + given(seasonAdminRepository.findAfterSeasons(any(LocalDateTime.class))).willReturn(new ArrayList<>()); + given(seasonAdminRepository.save(any())).willReturn(mock(Season.class)); + given(seasonAdminRepository.findAllByOrderByStartTimeAsc()).willReturn(new ArrayList<>()); + // when, then + seasonAdminService.createSeason(requestDto); + verify(seasonAdminRepository, times(1)).findBeforeSeasons(any()); + verify(seasonAdminRepository, times(1)).findAfterSeasons(any()); + verify(seasonAdminRepository, times(1)).save(any()); + verify(seasonAdminRepository, times(1)).findAllByOrderByStartTimeAsc(); + verify(rankAdminService, times(1)).addAllUserRankByNewSeason(any()); + verify(rankRedisAdminService, times(1)).addAllUserRankByNewSeason(any()); + } + + @Test + @DisplayName("success_이전시즌o&예약시즌x") + void success2() { + // given + given(seasonAdminRepository.findBeforeSeasons(any(LocalDateTime.class))).willReturn(beforeSeasons); + given(seasonAdminRepository.findAfterSeasons(any(LocalDateTime.class))).willReturn(new ArrayList<>()); + given(seasonAdminRepository.save(any())).willReturn(mock(Season.class)); + given(seasonAdminRepository.findAllByOrderByStartTimeAsc()).willReturn(beforeSeasonsAsc); + // when, then + seasonAdminService.createSeason(requestDto); + assertThat(beforeSeasons.get(0).getEndTime()).isEqualTo(requestDto.getStartTime().minusSeconds(1)); + } + + @Test + @DisplayName("success_이전시즌x&예약시즌o") + void success3() { + // given + given(seasonAdminRepository.findBeforeSeasons(any(LocalDateTime.class))).willReturn(new ArrayList<>()); + given(seasonAdminRepository.findAfterSeasons(any(LocalDateTime.class))).willReturn(afterSeasons); + given(seasonAdminRepository.save(any())).willReturn(mock(Season.class)); + given(seasonAdminRepository.findAllByOrderByStartTimeAsc()).willReturn(afterSeasons); + // when, then + seasonAdminService.createSeason(requestDto); + } + + @Test + @DisplayName("success_이전시즌o&예약시즌o") + void success4() { + // given + ArrayList seasons = new ArrayList<>(beforeSeasonsAsc); + seasons.add(season); + setFieldWithReflection(season, "endTime", afterSeasons.get(0).getStartTime().minusSeconds(1)); + seasons.addAll(afterSeasons); + given(seasonAdminRepository.findBeforeSeasons(any(LocalDateTime.class))).willReturn(beforeSeasons); + given(seasonAdminRepository.findAfterSeasons(any(LocalDateTime.class))).willReturn(afterSeasons); + given(seasonAdminRepository.save(any())).willReturn(mock(Season.class)); + given(seasonAdminRepository.findAllByOrderByStartTimeAsc()).willReturn(seasons); + // when, then + seasonAdminService.createSeason(requestDto); + } + + @Test + @DisplayName("isOverlap 매서드 모든조건 체크 1") + void isOverlap1() { + // given + given(seasonAdminRepository.findBeforeSeasons(any(LocalDateTime.class))).willReturn(beforeSeasons); + given(seasonAdminRepository.findAfterSeasons(any(LocalDateTime.class))).willReturn(new ArrayList<>()); + given(seasonAdminRepository.save(any())).willReturn(mock(Season.class)); + given(seasonAdminRepository.findAllByOrderByStartTimeAsc()).willReturn(beforeSeasonsAsc); + // when, then + beforeSeasonsAsc.get(1).setEndTime(beforeSeasonsAsc.get(1).getStartTime()); + seasonAdminService.createSeason(requestDto); + } + + @Test + @DisplayName("isOverlap 매서드 모든조건 체크 2") + void isOverlap2() { + // given + given(seasonAdminRepository.findBeforeSeasons(any(LocalDateTime.class))).willReturn(beforeSeasons); + given(seasonAdminRepository.findAfterSeasons(any(LocalDateTime.class))).willReturn(new ArrayList<>()); + given(seasonAdminRepository.save(any())).willReturn(mock(Season.class)); + given(seasonAdminRepository.findAllByOrderByStartTimeAsc()).willReturn(beforeSeasonsAsc); + // when, then + beforeSeasonsAsc.get(0).setEndTime(beforeSeasonsAsc.get(0).getStartTime()); + seasonAdminService.createSeason(requestDto); + } + + @Test + @DisplayName("isOverlap 매서드 모든조건 체크 3") + void isOverlap3() { + // given + given(seasonAdminRepository.findBeforeSeasons(any(LocalDateTime.class))).willReturn(beforeSeasons); + given(seasonAdminRepository.findAfterSeasons(any(LocalDateTime.class))).willReturn(new ArrayList<>()); + given(seasonAdminRepository.save(any())).willReturn(mock(Season.class)); + given(seasonAdminRepository.findAllByOrderByStartTimeAsc()).willReturn(beforeSeasons); + // when, then 1 + seasonAdminService.createSeason(requestDto); + } + + @Test + @DisplayName("SeasonForbiddenException_1") + void seasonForbiddenException1() { + // given + ArrayList seasons = new ArrayList<>(beforeSeasonsAsc); + seasons.add(season); + setFieldWithReflection(season, "endTime", afterSeasons.get(0).getEndTime()); + seasons.addAll(afterSeasons); + given(seasonAdminRepository.findBeforeSeasons(any(LocalDateTime.class))).willReturn(beforeSeasons); + given(seasonAdminRepository.findAfterSeasons(any(LocalDateTime.class))).willReturn(afterSeasons); + given(seasonAdminRepository.save(any())).willReturn(mock(Season.class)); + given(seasonAdminRepository.findAllByOrderByStartTimeAsc()).willReturn(seasons); + // when, then + assertThatThrownBy(() -> seasonAdminService.createSeason(requestDto)) + .isInstanceOf(SeasonForbiddenException.class); + } + + @Test + @DisplayName("SeasonForbiddenException_2") + void seasonForbiddenException2() { + // given + setFieldWithReflection(beforeSeasonsAsc.get(0), "startTime", season.getStartTime().minusHours(23)); + given(seasonAdminRepository.findBeforeSeasons(any(LocalDateTime.class))).willReturn(beforeSeasonsAsc); + given(seasonAdminRepository.findAfterSeasons(any(LocalDateTime.class))).willReturn(new ArrayList<>()); + // when, then + assertThatThrownBy(() -> seasonAdminService.createSeason(requestDto)) + .isInstanceOf(SeasonForbiddenException.class); + } + + @Test + @DisplayName("SeasonTimeBeforeException") + void seasonTimeBeforeException() { + // given + setFieldWithReflection(requestDto, "startTime", LocalDateTime.now().plusHours(23).plusMinutes(59)); + // when, then + assertThatThrownBy(() -> seasonAdminService.createSeason(requestDto)) + .isInstanceOf(SeasonTimeBeforeException.class); + } + } + + @Nested + @DisplayName("findSeasonById() 유닛 테스트") + class FindSeasonById { + @Test + @DisplayName("success") + void success() { + // given + given(seasonAdminRepository.findById(any())).willReturn( + Optional.of(afterSeasons.get(afterSeasons.size() - 1))); + // when, then + seasonAdminService.findSeasonById(1L); + verify(seasonAdminRepository, times(1)).findById(any()); + } + + @Test + @DisplayName("SeasonNotFoundException") + void seasonNotFoundException() { + // given + given(seasonAdminRepository.findById(any())).willReturn(Optional.empty()); + // when, then + assertThatThrownBy(() -> seasonAdminService.findSeasonById(1L)) + .isInstanceOf(SeasonNotFoundException.class); + } + } + + @Nested + @DisplayName("deleteSeason() 유닛 테스트") + class DeleteSeason { + Season season; + + @BeforeEach + void beforeEach() { + season = new Season(1L, "season", LocalDateTime.now().plusDays(1).plusSeconds(1), + LocalDateTime.of(9999, 12, 31, 23, 59, 59), + 1000, 200); + } + + @Test + @DisplayName("success_이전시즌x&예약시즌x") + void success1() { + // given + given(seasonAdminRepository.findById(any())).willReturn(Optional.of(season)); + given(seasonAdminRepository.findBeforeSeasons(any(LocalDateTime.class))).willReturn(new ArrayList<>()); + given(seasonAdminRepository.findAfterSeasons(any(LocalDateTime.class))).willReturn(new ArrayList<>()); + // when, then + seasonAdminService.deleteSeason(1L); + verify(seasonAdminRepository, times(1)).findById(any()); + verify(seasonAdminRepository, times(1)).findBeforeSeasons(any(LocalDateTime.class)); + verify(seasonAdminRepository, times(1)).findAfterSeasons(any(LocalDateTime.class)); + verify(rankAdminService, times(1)).deleteAllUserRankBySeason(any()); + verify(rankRedisAdminService, times(1)).deleteSeasonRankBySeasonId(any()); + verify(seasonAdminRepository, times(1)).delete(any()); + } + + @Test + @DisplayName("success_이전시즌o&예약시즌x") + void success2() { + // given + given(seasonAdminRepository.findById(any())).willReturn(Optional.of(season)); + given(seasonAdminRepository.findBeforeSeasons(any(LocalDateTime.class))).willReturn(beforeSeasons); + given(seasonAdminRepository.findAfterSeasons(any(LocalDateTime.class))).willReturn(new ArrayList<>()); + // when, then + seasonAdminService.deleteSeason(1L); + assertThat(beforeSeasons.get(0).getEndTime()) + .isEqualTo(LocalDateTime.of(9999, 12, 31, 23, 59, 59)); + } + + @Test + @DisplayName("success_이전시즌o&예약시즌o") + void success3() { + // given + given(seasonAdminRepository.findById(any())).willReturn(Optional.of(season)); + given(seasonAdminRepository.findBeforeSeasons(any(LocalDateTime.class))).willReturn(beforeSeasons); + given(seasonAdminRepository.findAfterSeasons(any(LocalDateTime.class))).willReturn(afterSeasons); + // when, then + seasonAdminService.deleteSeason(1L); + assertThat(beforeSeasons.get(0).getEndTime()).isEqualTo(afterSeasons.get(0).getStartTime().minusSeconds(1)); + } + + @Test + @DisplayName("SeasonForbiddenException") + void seasonForbiddenException() { + // given + setFieldWithReflection(season, "startTime", LocalDateTime.now().minusHours(2)); + given(seasonAdminRepository.findById(any())).willReturn(Optional.of(season)); + // when, then 1 + assertThatThrownBy(() -> seasonAdminService.deleteSeason(1L)) + .isInstanceOf(SeasonForbiddenException.class); + // when, then 1 + setFieldWithReflection(season, "endTime", LocalDateTime.now().minusHours(1)); + assertThatThrownBy(() -> seasonAdminService.deleteSeason(1L)) + .isInstanceOf(SeasonForbiddenException.class); + } + } + + @Nested + @DisplayName("updateSeason() 유닛 테스트") + class UpdateSeason { + Season season; + SeasonUpdateRequestDto requestDto; + + @BeforeEach + void beforeEach() { + season = new Season(1L, "season", LocalDateTime.now().plusDays(1).plusSeconds(1), + LocalDateTime.of(9999, 12, 31, 23, 59, 59), + 1000, 200); + requestDto = new SeasonUpdateRequestDto("season", + LocalDateTime.now().plusDays(2), 1000, 500); + } + + @Test + @DisplayName("success") + void success() { + // given + given(seasonAdminRepository.findById(any())).willReturn(Optional.of(season)); + given(seasonAdminRepository.findBeforeSeasons(any())).willReturn(new ArrayList<>()); + given(seasonAdminRepository.findAfterSeasons(any())).willReturn(new ArrayList<>()); + given(seasonAdminRepository.save(any())).willReturn(mock(Season.class)); + // when, then + seasonAdminService.updateSeason(1L, requestDto); + + verify(seasonAdminRepository, times(1)).findById(any()); + verify(seasonAdminRepository, times(2)).findBeforeSeasons(any()); + verify(seasonAdminRepository, times(2)).findAfterSeasons(any()); + verify(seasonAdminRepository, times(1)).save(any()); + verify(rankAdminService, times(1)).deleteAllUserRankBySeason(any()); + verify(rankAdminService, times(1)).addAllUserRankByNewSeason(any()); + verify(rankRedisAdminService, times(1)).deleteSeasonRankBySeasonId(any()); + verify(rankRedisAdminService, times(1)).addAllUserRankByNewSeason(any()); + } + + @Test + @DisplayName("SeasonForbiddenException") + void seasonForbiddenException() { + // given + setFieldWithReflection(season, "startTime", LocalDateTime.now().minusHours(1)); + given(seasonAdminRepository.findById(any())).willReturn(Optional.of(season)); + // when, then + assertThatThrownBy(() -> seasonAdminService.updateSeason(1L, requestDto)) + .isInstanceOf(SeasonForbiddenException.class); + } + } +} diff --git a/src/test/java/com/gg/server/domain/season/service/SeasonServiceUnitTest.java b/src/test/java/com/gg/server/domain/season/service/SeasonServiceUnitTest.java new file mode 100644 index 000000000..fd89eb8fe --- /dev/null +++ b/src/test/java/com/gg/server/domain/season/service/SeasonServiceUnitTest.java @@ -0,0 +1,65 @@ +package com.gg.server.domain.season.service; + +import static org.mockito.BDDMockito.*; + +import java.util.ArrayList; +import java.util.Optional; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.domain.season.data.Season; +import com.gg.server.domain.season.data.SeasonRepository; +import com.gg.server.domain.season.exception.SeasonNotFoundException; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class SeasonServiceUnitTest { + @Mock + SeasonRepository seasonRepository; + @InjectMocks + SeasonService seasonService; + + @Nested + @DisplayName("seasonList 메서드 유닛 테스트") + class SeasonList { + @Test + @DisplayName("success") + void success() { + // given + given(seasonRepository.findActiveSeasonsDesc(any())).willReturn(new ArrayList<>()); + // when, then + seasonService.seasonList(); + } + } + + @Nested + @DisplayName("getCurSeason 메서드 유닛 테스트") + class GetCurSeason { + @Test + @DisplayName("success") + void success() { + // given + given(seasonRepository.findCurrentSeason(any())).willReturn(Optional.of(mock(Season.class))); + // when, then + seasonService.getCurSeason(); + } + + @Test + @DisplayName("SeasonNotFoundException") + void seasonNotFoundException() { + // given + given(seasonRepository.findCurrentSeason(any())).willReturn(Optional.empty()); + // when, then + Assertions.assertThatThrownBy(() -> seasonService.getCurSeason()) + .isInstanceOf(SeasonNotFoundException.class); + } + } +} From 3209165381abb98105458d894dd03507a6e50640 Mon Sep 17 00:00:00 2001 From: SeungChul Chung Date: Wed, 14 Feb 2024 14:41:33 +0900 Subject: [PATCH 23/32] =?UTF-8?q?=F0=9F=90=9B=20[Fix]=20=ED=8F=B4=EB=8D=94?= =?UTF-8?q?=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD=20(#547)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../season/service/SeasonAdminServiceUnitTest.java | 2 +- .../domain/noti/service/NotiServiceUnitTest.java | 12 ++++++------ .../domain/noti/service/SnsNotiServiceUnitTest.java | 4 ++-- .../noti/service/sns/NotiMailSenderUnitTest.java | 2 +- .../domain/season/service/SeasonServiceUnitTest.java | 2 +- .../domain/user/service/UserFindServiceUnitTest.java | 8 ++++++++ .../com/gg/server/utils/annotation/UnitTest.java | 3 +++ 7 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 src/test/java/com/gg/server/domain/user/service/UserFindServiceUnitTest.java diff --git a/src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java b/src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java index bc3101bff..34ec010c5 100644 --- a/src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java +++ b/src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java @@ -24,7 +24,7 @@ import com.gg.server.admin.season.data.SeasonAdminRepository; import com.gg.server.admin.season.dto.SeasonCreateRequestDto; import com.gg.server.admin.season.dto.SeasonUpdateRequestDto; -import com.gg.server.domain.season.data.Season; +import com.gg.server.data.game.Season; import com.gg.server.domain.season.exception.SeasonForbiddenException; import com.gg.server.domain.season.exception.SeasonNotFoundException; import com.gg.server.domain.season.exception.SeasonTimeBeforeException; diff --git a/src/test/java/com/gg/server/domain/noti/service/NotiServiceUnitTest.java b/src/test/java/com/gg/server/domain/noti/service/NotiServiceUnitTest.java index 41f7f185f..588882a2f 100644 --- a/src/test/java/com/gg/server/domain/noti/service/NotiServiceUnitTest.java +++ b/src/test/java/com/gg/server/domain/noti/service/NotiServiceUnitTest.java @@ -16,16 +16,16 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.noti.type.NotiType; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.noti.type.NotiType; -import com.gg.server.domain.user.data.User; import com.gg.server.domain.user.data.UserRepository; import com.gg.server.domain.user.dto.UserDto; import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.type.RacketType; -import com.gg.server.domain.user.type.RoleType; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.global.exception.custom.NotExistException; import com.gg.server.utils.annotation.UnitTest; diff --git a/src/test/java/com/gg/server/domain/noti/service/SnsNotiServiceUnitTest.java b/src/test/java/com/gg/server/domain/noti/service/SnsNotiServiceUnitTest.java index 25e6b78ed..221bb707b 100644 --- a/src/test/java/com/gg/server/domain/noti/service/SnsNotiServiceUnitTest.java +++ b/src/test/java/com/gg/server/domain/noti/service/SnsNotiServiceUnitTest.java @@ -10,13 +10,13 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; +import com.gg.server.data.user.type.SnsType; import com.gg.server.domain.noti.dto.UserNotiDto; import com.gg.server.domain.noti.service.sns.NotiMailSender; import com.gg.server.domain.noti.service.sns.SlackbotService; import com.gg.server.domain.team.dto.GameUser; import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.type.SnsType; import com.gg.server.utils.annotation.UnitTest; @UnitTest diff --git a/src/test/java/com/gg/server/domain/noti/service/sns/NotiMailSenderUnitTest.java b/src/test/java/com/gg/server/domain/noti/service/sns/NotiMailSenderUnitTest.java index 355997eac..ee33c67e3 100644 --- a/src/test/java/com/gg/server/domain/noti/service/sns/NotiMailSenderUnitTest.java +++ b/src/test/java/com/gg/server/domain/noti/service/sns/NotiMailSenderUnitTest.java @@ -12,7 +12,7 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.mail.javamail.JavaMailSender; -import com.gg.server.domain.noti.data.Noti; +import com.gg.server.data.noti.Noti; import com.gg.server.domain.noti.dto.UserNotiDto; import com.gg.server.domain.noti.service.NotiService; import com.gg.server.domain.team.dto.GameUser; diff --git a/src/test/java/com/gg/server/domain/season/service/SeasonServiceUnitTest.java b/src/test/java/com/gg/server/domain/season/service/SeasonServiceUnitTest.java index fd89eb8fe..5970e1674 100644 --- a/src/test/java/com/gg/server/domain/season/service/SeasonServiceUnitTest.java +++ b/src/test/java/com/gg/server/domain/season/service/SeasonServiceUnitTest.java @@ -14,7 +14,7 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.domain.season.data.Season; +import com.gg.server.data.game.Season; import com.gg.server.domain.season.data.SeasonRepository; import com.gg.server.domain.season.exception.SeasonNotFoundException; import com.gg.server.utils.annotation.UnitTest; diff --git a/src/test/java/com/gg/server/domain/user/service/UserFindServiceUnitTest.java b/src/test/java/com/gg/server/domain/user/service/UserFindServiceUnitTest.java new file mode 100644 index 000000000..4abe49cb6 --- /dev/null +++ b/src/test/java/com/gg/server/domain/user/service/UserFindServiceUnitTest.java @@ -0,0 +1,8 @@ +package com.gg.server.domain.user.service; + +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +class UserFindServiceUnitTest { + +} diff --git a/src/test/java/com/gg/server/utils/annotation/UnitTest.java b/src/test/java/com/gg/server/utils/annotation/UnitTest.java index 3b00b075c..37d01fc5e 100644 --- a/src/test/java/com/gg/server/utils/annotation/UnitTest.java +++ b/src/test/java/com/gg/server/utils/annotation/UnitTest.java @@ -6,6 +6,8 @@ import java.lang.annotation.Target; import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; /** * Unit 테스트를 위한 어노테이션 @@ -14,6 +16,7 @@ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Tag(TestTypeConstant.UNIT_TEST) +@ExtendWith(MockitoExtension.class) public @interface UnitTest { } From 7e534c4bcfaa457cda0d227c86157fbe934e5127 Mon Sep 17 00:00:00 2001 From: yoahn <46748334+AYoungSn@users.noreply.github.com> Date: Mon, 19 Feb 2024 14:27:40 +0900 Subject: [PATCH 24/32] [FIX] #568 season admin controller test error fix (#569) --- .../server/admin/season/data/SeasonAdminRepository.java | 9 +++++++++ .../server/admin/season/service/SeasonAdminService.java | 8 +++----- .../admin/season/service/SeasonAdminServiceUnitTest.java | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java b/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java index c3b69b0b4..0fff1c5d4 100644 --- a/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java +++ b/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java @@ -5,6 +5,7 @@ import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -24,4 +25,12 @@ public interface SeasonAdminRepository extends JpaRepository { List findAllByOrderByStartTimeDesc(); List findAllByOrderByStartTimeAsc(); + + @Modifying(clearAutomatically = true, flushAutomatically = true) + @Query(value = "UPDATE Season s SET s.seasonName = :seasonName, s.startTime = :startTime, " + + "s.startPpp = :startPpp, s.pppGap = :pppGap " + + "WHERE s.id = :id") + void updateReserveSeasonById(@Param("id") Long seasonId, @Param("seasonName") String seasonName, + @Param("startTime") LocalDateTime startTime, + @Param("startPpp") Integer startPpp, @Param("pppGap") Integer pppGap); } diff --git a/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java b/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java index 65aa52743..a0d98c0bf 100644 --- a/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java +++ b/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java @@ -102,10 +102,9 @@ public void updateSeason(Long seasonId, SeasonUpdateRequestDto updateDto) { } // 예약 시즌 수정 detach(season); - season.setSeasonName(updateDto.getSeasonName()); - season.setStartTime(updateDto.getStartTime()); - season.setStartPpp(updateDto.getStartPpp()); - season.setPppGap(updateDto.getPppGap()); + seasonAdminRepository.updateReserveSeasonById(seasonId, updateDto.getSeasonName(), updateDto.getStartTime(), + updateDto.getStartPpp(), updateDto.getPppGap()); + season = seasonAdminRepository.findById(seasonId).orElseThrow(SeasonNotFoundException::new); insert(season); seasonAdminRepository.save(season); checkSeasonAtDB(); @@ -126,7 +125,6 @@ private void insert(Season season) { if (LocalDateTime.now().plusHours(24).isAfter(season.getStartTime())) { throw new SeasonTimeBeforeException(); } - List beforeSeasons = seasonAdminRepository.findBeforeSeasons(season.getStartTime()); Season beforeSeason = beforeSeasons.isEmpty() ? null : beforeSeasons.get(0); List afterSeasons = seasonAdminRepository.findAfterSeasons(season.getStartTime()); diff --git a/src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java b/src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java index 34ec010c5..1e6b197ac 100644 --- a/src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java +++ b/src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java @@ -351,7 +351,7 @@ void success() { // when, then seasonAdminService.updateSeason(1L, requestDto); - verify(seasonAdminRepository, times(1)).findById(any()); + verify(seasonAdminRepository, times(2)).findById(any()); verify(seasonAdminRepository, times(2)).findBeforeSeasons(any()); verify(seasonAdminRepository, times(2)).findAfterSeasons(any()); verify(seasonAdminRepository, times(1)).save(any()); From e4821616affd21e7da3896bedfc0c6d8949c3834 Mon Sep 17 00:00:00 2001 From: yoahn <46748334+AYoungSn@users.noreply.github.com> Date: Mon, 19 Feb 2024 17:02:34 +0900 Subject: [PATCH 25/32] =?UTF-8?q?[REFACT]=20#576=20test-deploy=20pipeline?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20(#577)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: sujin --- .github/workflows/test-deploy.yml | 115 +++++++++--------- .../admin/coin/service/CoinAdminService.java | 5 + .../coin/service/CoinAdminServiceTest.java | 64 ++++++++++ 3 files changed, 128 insertions(+), 56 deletions(-) create mode 100644 src/test/java/com/gg/server/admin/coin/service/CoinAdminServiceTest.java diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml index ccf2fa2fe..3ddb998d3 100644 --- a/.github/workflows/test-deploy.yml +++ b/.github/workflows/test-deploy.yml @@ -16,7 +16,7 @@ env: DOCKER_USER: ${{ secrets.DOCKER_USER }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} IMAGE_NAME: wken5577/test-migrate-server - + permissions: contents: read @@ -26,63 +26,66 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'temurin' - - - name: Make application ymls - run: | - cd ./src/main/resources - echo "${{ secrets.MIGRATE_APPLICATION_YML }}" | base64 -d > application.yml - shell: bash - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + + - name: Make application ymls + run: | + cd ./src/main/resources + echo "${{ secrets.MIGRATE_APPLICATION_YML }}" | base64 -d > application.yml + shell: bash + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: username: ${{ env.DOCKER_USER }} password: ${{ env.DOCKER_PASSWORD }} - - - name: Build with Gradle - run: ./gradlew clean test build - - - name: build new docker image as latest tag - run: | - docker build -t ${{ env.IMAGE_NAME }}:latest . - docker push ${{ env.IMAGE_NAME }}:latest - - - name: Get Github Actions IP - id: ip - uses: haythem/public-ip@v1.3 - - - name: AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - aws-access-key-id: ${{ secrets.AWS_TEST_MIGRATE_SECURITY_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_TEST_MIGRATE_SECURITY_SECRET_KEY }} - aws-region: ap-northeast-2 - - - name: Add Github Actions IP to Security group - run: | + + - name: Test with Gradle + run: ./gradlew clean test + + - name: Build with Gradle + run: ./gradlew clean build -x test + + - name: build new docker image as latest tag + run: | + docker build -t ${{ env.IMAGE_NAME }}:latest . + docker push ${{ env.IMAGE_NAME }}:latest + + - name: Get Github Actions IP + id: ip + uses: haythem/public-ip@v1.3 + + - name: AWS Credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_TEST_MIGRATE_SECURITY_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_TEST_MIGRATE_SECURITY_SECRET_KEY }} + aws-region: ap-northeast-2 + + - name: Add Github Actions IP to Security group + run: | aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_TEST_MIGRATE_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 - - name: executing docker-compose up on test server - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.TEST_MIGRATE_SERVER_HOST }} - username: ${{ secrets.TEST_MIGRATE_SERVER_USERNAME }} - key: ${{ secrets.TEST_MIGRATE_SERVER_PEM }} - script: | - cd /home/ec2-user/docker - docker-compose down tomcat - docker rmi ${{ env.IMAGE_NAME }}:latest - docker-compose up tomcat -d - docker-compose up prometheus -d - - - name: Remove Github Actions IP From Security Group - run: | + - name: executing docker-compose up on test server + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.TEST_MIGRATE_SERVER_HOST }} + username: ${{ secrets.TEST_MIGRATE_SERVER_USERNAME }} + key: ${{ secrets.TEST_MIGRATE_SERVER_PEM }} + script: | + cd /home/ec2-user/docker + docker-compose down tomcat + docker rmi ${{ env.IMAGE_NAME }}:latest + docker-compose up tomcat -d + docker-compose up prometheus -d + + - name: Remove Github Actions IP From Security Group + run: | aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_TEST_MIGRATE_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 diff --git a/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java b/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java index 65e8227c7..6af21dae7 100644 --- a/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java +++ b/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java @@ -18,6 +18,11 @@ public class CoinAdminService { private final UserRepository userRepository; private final CoinHistoryService coinHistoryService; + /*** + * 유저의 코인 정보를 업데이트합니다. + * @param coinUpdateRequestDto 코인 업데이트에 필요한 Dto + * @throws UserNotFoundException 유저가 존재하지 않을 경우 + */ @Transactional public void updateUserCoin(CoinUpdateRequestDto coinUpdateRequestDto) { User user = userRepository.findByIntraId(coinUpdateRequestDto.getIntraId()) diff --git a/src/test/java/com/gg/server/admin/coin/service/CoinAdminServiceTest.java b/src/test/java/com/gg/server/admin/coin/service/CoinAdminServiceTest.java new file mode 100644 index 000000000..e73356a0b --- /dev/null +++ b/src/test/java/com/gg/server/admin/coin/service/CoinAdminServiceTest.java @@ -0,0 +1,64 @@ +package com.gg.server.admin.coin.service; + +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; + +import java.util.Optional; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.admin.coin.dto.CoinUpdateRequestDto; +import com.gg.server.data.store.CoinHistory; +import com.gg.server.data.user.User; +import com.gg.server.domain.coin.service.CoinHistoryService; +import com.gg.server.domain.user.data.UserRepository; +import com.gg.server.domain.user.exception.UserNotFoundException; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +@DisplayName("CoinAdminServiceTest") +class CoinAdminServiceTest { + @Mock + UserRepository userRepository; + @Mock + CoinHistoryService coinHistoryService; + @InjectMocks + CoinAdminService coinAdminService; + + @Nested + @DisplayName("updateUserCoin 메서드 unitTest") + class UpdateUserCoinTest { + @Test + @DisplayName("성공") + void success() { + //given + CoinUpdateRequestDto requestDto = new CoinUpdateRequestDto("testId", 10, "test"); + User user = mock(User.class); + given(userRepository.findByIntraId(any(String.class))).willReturn(Optional.of(user)); + //when + coinAdminService.updateUserCoin(requestDto); + //then + verify(user).addGgCoin(requestDto.getChange()); + verify(coinHistoryService).addCoinHistory(any(CoinHistory.class)); + } + + @Test + @DisplayName("UserNotFound") + void userNotFound() { + //given + CoinUpdateRequestDto requestDto = new CoinUpdateRequestDto("testId", 10, "test"); + given(userRepository.findByIntraId(requestDto.getIntraId())).willReturn(Optional.empty()); + //when, then + Assertions.assertThatThrownBy(() -> coinAdminService.updateUserCoin(requestDto)) + .isInstanceOf(UserNotFoundException.class); + } + } +} From 4a8f3948423af9bdf18c50e5ab2236d88f6fd284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=90=ED=9B=88?= Date: Tue, 20 Feb 2024 16:21:01 +0900 Subject: [PATCH 26/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20Receipt=20?= =?UTF-8?q?=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20(#545)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../receipt/service/ReceiptAdminService.java | 19 +++++-- .../service/ReceiptAdminServiceUnitTest.java | 57 +++++++++++++++++++ 2 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 src/test/java/com/gg/server/admin/receipt/service/ReceiptAdminServiceUnitTest.java diff --git a/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java b/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java index 8c93e1f91..5575352e7 100644 --- a/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java +++ b/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java @@ -17,16 +17,27 @@ public class ReceiptAdminService { private final ReceiptAdminRepository receiptAdminRepository; + /** + *

모든 영수증 데이터를 가져옵니다.

+ * @param pageable + * @return + */ @Transactional(readOnly = true) public ReceiptListResponseDto getAllReceipt(Pageable pageable) { - Page responseDtos = receiptAdminRepository.findAll(pageable).map(ReceiptResponseDto::new); - return new ReceiptListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); + Page responseDto = receiptAdminRepository.findAll(pageable).map(ReceiptResponseDto::new); + return new ReceiptListResponseDto(responseDto.getContent(), responseDto.getTotalPages()); } + /** + *

특정 유저가 사용한 영수증 내역을 가져옵니다.

+ * @param intraId + * @param pageable + * @return + */ @Transactional(readOnly = true) public ReceiptListResponseDto findByIntraId(String intraId, Pageable pageable) { Page receipts = receiptAdminRepository.findReceiptByIntraId(intraId, pageable); - Page responseDtos = receipts.map(ReceiptResponseDto::new); - return new ReceiptListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); + Page responseDto = receipts.map(ReceiptResponseDto::new); + return new ReceiptListResponseDto(responseDto.getContent(), responseDto.getTotalPages()); } } diff --git a/src/test/java/com/gg/server/admin/receipt/service/ReceiptAdminServiceUnitTest.java b/src/test/java/com/gg/server/admin/receipt/service/ReceiptAdminServiceUnitTest.java new file mode 100644 index 000000000..3006aec28 --- /dev/null +++ b/src/test/java/com/gg/server/admin/receipt/service/ReceiptAdminServiceUnitTest.java @@ -0,0 +1,57 @@ +package com.gg.server.admin.receipt.service; + +import static org.mockito.BDDMockito.*; + +import java.util.ArrayList; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; + +import com.gg.server.admin.receipt.data.ReceiptAdminRepository; +import com.gg.server.data.store.Receipt; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class ReceiptAdminServiceUnitTest { + @Mock + ReceiptAdminRepository receiptAdminRepository; + @InjectMocks + ReceiptAdminService receiptAdminService; + + @Nested + @DisplayName("getAllReceipt 메서드 유닛 테스트") + class GetAllReceipt { + @Test + @DisplayName("success") + void success() { + // given + ArrayList receipts = new ArrayList<>(); + given(receiptAdminRepository.findAll(any(Pageable.class))).willReturn(new PageImpl<>(receipts)); + // when, then + receiptAdminService.getAllReceipt(mock(Pageable.class)); + } + } + + @Nested + @DisplayName("findByIntraId 메서드 유닛 테스트") + class FindByIntraId { + @Test + @DisplayName("success") + void success() { + // given + ArrayList receipts = new ArrayList<>(); + given(receiptAdminRepository.findReceiptByIntraId(any(String.class), any(Pageable.class))) + .willReturn(new PageImpl<>(receipts)); + // when, then + receiptAdminService.findByIntraId("intraId", mock(Pageable.class)); + } + } +} From c1fb9ecdf1c1496e5777aba4c58f52b6f576dadf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=90=ED=9B=88?= Date: Tue, 20 Feb 2024 16:39:58 +0900 Subject: [PATCH 27/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20Slot=20man?= =?UTF-8?q?agement=20=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20(#?= =?UTF-8?q?571)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: yoahn <46748334+AYoungSn@users.noreply.github.com> --- .../service/SlotAdminService.java | 21 ++- .../service/SlotAdminServiceUnitTest.java | 156 ++++++++++++++++++ 2 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/gg/server/admin/slotmanagement/service/SlotAdminServiceUnitTest.java diff --git a/src/main/java/com/gg/server/admin/slotmanagement/service/SlotAdminService.java b/src/main/java/com/gg/server/admin/slotmanagement/service/SlotAdminService.java index 44c253b49..d05fb3896 100644 --- a/src/main/java/com/gg/server/admin/slotmanagement/service/SlotAdminService.java +++ b/src/main/java/com/gg/server/admin/slotmanagement/service/SlotAdminService.java @@ -22,6 +22,10 @@ public class SlotAdminService { private final AdminSlotManagementsRepository adminSlotManagementRepository; + /** + *

현재 슬롯 정보를 가져온다.

+ * @return + */ @Transactional(readOnly = true) public SlotListAdminResponseDto getSlotSetting() { List slotManagements = adminSlotManagementRepository.findAfterNowSlotManagement( @@ -34,6 +38,10 @@ public SlotListAdminResponseDto getSlotSetting() { return new SlotListAdminResponseDto(dtoList); } + /** + *

새로운 슬롯을 추가한다.

+ * @param requestDto + */ @Transactional public void addSlotSetting(SlotCreateRequestDto requestDto) { checkVaildSlotManagement(requestDto); @@ -44,6 +52,9 @@ public void addSlotSetting(SlotCreateRequestDto requestDto) { adminSlotManagementRepository.save(slotManagement); } + /** + *

현재 시간보다 이후 혹은 종료 시간이 이후인 슬롯 정보를 삭제한다.

+ */ @Transactional public void delSlotSetting() { List slotManagements = adminSlotManagementRepository.findAfterNowSlotManagement( @@ -59,6 +70,10 @@ public void delSlotSetting() { beforeSlotManagement.setNullEndTime(); } + /** + *

서비스 로직 조건에 맞는지 체크

+ * @param requestDto + */ private void checkVaildSlotManagement(SlotCreateRequestDto requestDto) { if (requestDto.getPastSlotTime() > 23) { throw new SlotManagementForbiddenException(); @@ -74,9 +89,13 @@ private void checkVaildSlotManagement(SlotCreateRequestDto requestDto) { } } + /** + *

서비스 로직 조건에 맞는지 체크

+ * @param endTime + */ private void updateNowSlotManagementEndTime(LocalDateTime endTime) { SlotManagement nowSlotManagement = adminSlotManagementRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new SlotManagementNotFoundException()); + .orElseThrow(SlotManagementNotFoundException::new); LocalDateTime nowFutureSlotTime = LocalDateTime.now().isAfter(nowSlotManagement.getStartTime()) ? LocalDateTime.now().plusHours(nowSlotManagement.getFutureSlotTime()) diff --git a/src/test/java/com/gg/server/admin/slotmanagement/service/SlotAdminServiceUnitTest.java b/src/test/java/com/gg/server/admin/slotmanagement/service/SlotAdminServiceUnitTest.java new file mode 100644 index 000000000..60daac251 --- /dev/null +++ b/src/test/java/com/gg/server/admin/slotmanagement/service/SlotAdminServiceUnitTest.java @@ -0,0 +1,156 @@ +package com.gg.server.admin.slotmanagement.service; + +import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static org.assertj.core.api.Assertions.*; +import static org.mockito.BDDMockito.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; + +import com.gg.server.admin.slotmanagement.data.AdminSlotManagementsRepository; +import com.gg.server.admin.slotmanagement.dto.SlotCreateRequestDto; +import com.gg.server.domain.slotmanagement.SlotManagement; +import com.gg.server.domain.slotmanagement.exception.SlotManagementForbiddenException; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +class SlotAdminServiceUnitTest { + @Mock + AdminSlotManagementsRepository adminSlotManagementRepository; + @InjectMocks + SlotAdminService slotAdminService; + + List slotManagementList; + List requestDtoList; + + @BeforeEach + void beforeEach() { + slotManagementList = new ArrayList<>(); + slotManagementList.add(new SlotManagement(12, 11, 5, 15, + LocalDateTime.now().plusHours(1), null)); + requestDtoList = new ArrayList<>(); + // success case + requestDtoList.add(new SlotCreateRequestDto(12, 11, 15, 5, + LocalDateTime.now().plusDays(1))); + // Exception case + requestDtoList.add(new SlotCreateRequestDto(24, 11, 15, 5, + LocalDateTime.now().plusHours(1))); + requestDtoList.add(new SlotCreateRequestDto(12, 13, 15, 5, + LocalDateTime.now())); + requestDtoList.add(new SlotCreateRequestDto(12, 11, 13, 5, + LocalDateTime.now())); + requestDtoList.add(new SlotCreateRequestDto(12, 11, 12, 5, + LocalDateTime.now())); + requestDtoList.add(new SlotCreateRequestDto(15, 11, 10, 5, + LocalDateTime.now())); + } + + @Nested + @DisplayName("getSlotSetting 매서드 단위 테스트") + @MockitoSettings(strictness = Strictness.LENIENT) + class GetSlotSetting { + @Test + @DisplayName("success") + void success() { + // given + given(adminSlotManagementRepository.findAfterNowSlotManagement(any())) + .willReturn(slotManagementList); + // when, then + slotAdminService.getSlotSetting(); + + verify(adminSlotManagementRepository, times(1)).findAfterNowSlotManagement(any()); + } + } + + @Nested + @DisplayName("addSlotSetting 매서드 단위 테스트") + @MockitoSettings(strictness = Strictness.LENIENT) + class AddSlotSetting { + @BeforeEach + void beforeEach() { + // given + given(adminSlotManagementRepository.findFirstByOrderByIdDesc()) + .willReturn(Optional.of(slotManagementList.get(0))); + given(adminSlotManagementRepository.save(any())).willReturn(mock(SlotManagement.class)); + } + + @Test + @DisplayName("success") + void success() { + // when, then + slotAdminService.addSlotSetting(requestDtoList.get(0)); + verify(adminSlotManagementRepository, times(1)).findFirstByOrderByIdDesc(); + } + + @Test + @DisplayName("checkVaildSlotManagement에서 발생하는 Exception") + void checkVaildSlotManagement() { + //when, then + for (int i = 1; i < requestDtoList.size(); i++) { + int idx = i; + assertThatThrownBy(() -> slotAdminService.addSlotSetting(requestDtoList.get(idx))) + .isInstanceOf(SlotManagementForbiddenException.class); + } + } + + @Test + @DisplayName("updateNowSlotManagementEndTime에서 발생하는 Exception") + void updateNowSlotManagementEndTime() { + //when, then + setFieldWithReflection(slotManagementList.get(0), "endTime", LocalDateTime.now()); + assertThatThrownBy(() -> slotAdminService.addSlotSetting(requestDtoList.get(0))) + .isInstanceOf(SlotManagementForbiddenException.class); + setFieldWithReflection(slotManagementList.get(0), "startTime", LocalDateTime.now()); + setFieldWithReflection(requestDtoList.get(0), "startTime", LocalDateTime.now()); + assertThatThrownBy(() -> slotAdminService.addSlotSetting(requestDtoList.get(0))) + .isInstanceOf(SlotManagementForbiddenException.class); + } + } + + @Nested + @DisplayName("delSlotSetting 매서드 단위 테스트") + @MockitoSettings(strictness = Strictness.LENIENT) + class DelSlotSetting { + @BeforeEach + void beforeEach() { + // given + slotManagementList.add( + new SlotManagement(12, 11, 5, 15, + LocalDateTime.now(), LocalDateTime.now().plusHours(1))); + given(adminSlotManagementRepository.findAfterNowSlotManagement(any())) + .willReturn(slotManagementList); + } + + @Test + @DisplayName("success") + void success() { + // when, then + slotAdminService.delSlotSetting(); + verify(adminSlotManagementRepository, times(1)).findAfterNowSlotManagement(any()); + verify(adminSlotManagementRepository, times(1)).delete(any()); + } + + @Test + @DisplayName("SlotManagementForbiddenException") + void slotManagementForbiddenException() { + // when, then + setFieldWithReflection(slotManagementList.get(1), "endTime", null); + assertThatThrownBy(() -> slotAdminService.delSlotSetting()) + .isInstanceOf(SlotManagementForbiddenException.class); + setFieldWithReflection(slotManagementList.get(0), "startTime", LocalDateTime.now()); + assertThatThrownBy(() -> slotAdminService.delSlotSetting()) + .isInstanceOf(SlotManagementForbiddenException.class); + } + } +} From 62f19e4f142b52bec2b2151baadb972d6e2059cf Mon Sep 17 00:00:00 2001 From: SeungJun Go <105098279+kokomong2@users.noreply.github.com> Date: Tue, 20 Feb 2024 16:47:49 +0900 Subject: [PATCH 28/32] =?UTF-8?q?=F0=9F=A7=AA=20[Unit=20Test]=20Penalty=20?= =?UTF-8?q?=EB=8B=A8=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20(#574)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: hannkim Co-authored-by: yoahn <46748334+AYoungSn@users.noreply.github.com> --- .../penalty/service/PenaltyAdminService.java | 25 ++ .../service/PenaltyAdminServiceTest.java | 215 ++++++++++++++++++ .../gg/server/data/manage/PenaltyTest.java | 26 +++ .../penalty/service/PenaltyServiceTest.java | 102 +++++++++ 4 files changed, 368 insertions(+) create mode 100644 src/test/java/com/gg/server/admin/penalty/service/PenaltyAdminServiceTest.java create mode 100644 src/test/java/com/gg/server/data/manage/PenaltyTest.java create mode 100644 src/test/java/com/gg/server/domain/penalty/service/PenaltyServiceTest.java diff --git a/src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java b/src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java index 9fc0a9d12..296d7b5e7 100644 --- a/src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java +++ b/src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java @@ -31,6 +31,12 @@ public class PenaltyAdminService { private final UserFindService userFindService; private final PenaltyAdminRepository penaltyRepository; + /** + * 패널티 부여 + * @param intraId + * @param penaltyTime + * @param reason + */ @Transactional public void givePenalty(String intraId, Integer penaltyTime, String reason) { User user = userFindService.findByIntraId(intraId); @@ -54,6 +60,12 @@ public void givePenalty(String intraId, Integer penaltyTime, String reason) { penaltyUserAdminRedisRepository.addPenaltyUser(penaltyUser, releaseTime); } + /** + * 모든 패널티 조회 + * @param pageable + * @param current + * @return PenaltyListResponseDto + */ @Transactional(readOnly = true) public PenaltyListResponseDto getAllPenalties(Pageable pageable, Boolean current) { Page allPenalties; @@ -66,6 +78,12 @@ public PenaltyListResponseDto getAllPenalties(Pageable pageable, Boolean current return new PenaltyListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); } + /** + * 패널티 삭제 + * 패널티 시간이 지났을 경우 삭제 불가능 + * redis 에서도 삭제 + * @param penaltyId + */ @Transactional public void deletePenalty(Long penaltyId) { Penalty penalty = penaltyRepository.findById(penaltyId).orElseThrow(() @@ -83,6 +101,13 @@ public void deletePenalty(Long penaltyId) { penaltyRepository.delete(penalty); } + /** + * intraId 로 패널티 리스트 조회 + * @param pageable + * @param intraId + * @param current + * @return PenaltyListResponseDto + */ @Transactional(readOnly = true) public PenaltyListResponseDto getAllPenaltiesByIntraId(Pageable pageable, String intraId, Boolean current) { Page allPenalties; diff --git a/src/test/java/com/gg/server/admin/penalty/service/PenaltyAdminServiceTest.java b/src/test/java/com/gg/server/admin/penalty/service/PenaltyAdminServiceTest.java new file mode 100644 index 000000000..35ea869e8 --- /dev/null +++ b/src/test/java/com/gg/server/admin/penalty/service/PenaltyAdminServiceTest.java @@ -0,0 +1,215 @@ +package com.gg.server.admin.penalty.service; + +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.BDDMockito.*; + +import java.time.LocalDateTime; +import java.util.Optional; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +import com.gg.server.admin.penalty.data.PenaltyAdminRepository; +import com.gg.server.admin.penalty.data.PenaltyUserAdminRedisRepository; +import com.gg.server.data.manage.Penalty; +import com.gg.server.data.manage.redis.RedisPenaltyUser; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; +import com.gg.server.domain.penalty.exception.PenaltyExpiredException; +import com.gg.server.domain.penalty.exception.PenaltyNotFoundException; +import com.gg.server.domain.penalty.exception.RedisPenaltyUserNotFoundException; +import com.gg.server.domain.penalty.type.PenaltyType; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.service.UserFindService; +import com.gg.server.utils.ReflectionUtilsForUnitTest; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class PenaltyAdminServiceTest { + + @Mock + PenaltyUserAdminRedisRepository penaltyUserAdminRedisRepository; + @Mock + UserFindService userFindService; + @Mock + PenaltyAdminRepository penaltyRepository; + @InjectMocks + PenaltyAdminService penaltyAdminService; + + @Nested + @DisplayName("givePenalty - 유저에게 penalty 부여 한다") + class GivePenaltyTest { + User user; + UserDto userDto; + int penaltyTime; + + @BeforeEach + void beforeEach() { + user = new User("intra", "email", "image", RacketType.PENHOLDER, + RoleType.USER, 1000, SnsType.NONE, 4242L); + userDto = UserDto.from(user); + penaltyTime = 1; + given(userFindService.findByIntraId(userDto.getIntraId())).willReturn(user); + doNothing().when(penaltyUserAdminRedisRepository) + .addPenaltyUser(any(RedisPenaltyUser.class), any(LocalDateTime.class)); + } + + @Test + @DisplayName("Success - redis 에 PenaltyUser 가 있을 때") + void success1() { + RedisPenaltyUser redisPenaltyUser = new RedisPenaltyUser(); + redisPenaltyUser.updateReleaseTime(LocalDateTime.now(), penaltyTime); + Optional optional = Optional.of(redisPenaltyUser); + Penalty penalty = new Penalty(user, PenaltyType.CANCEL, "[AUTO] 매칭 취소", redisPenaltyUser.getReleaseTime(), + penaltyTime); + + given(penaltyUserAdminRedisRepository.findByIntraId(userDto.getIntraId())).willReturn( + optional); // redis 에 PenaltyUser 가 있을때 + given(penaltyRepository.save(any(Penalty.class))).willReturn(penalty); + + // when, then + penaltyAdminService.givePenalty(user.getIntraId(), penaltyTime, "reason"); + } + + @Test + @DisplayName("Success - redis 에 PenaltyUser 가 없을 때") + void success2() { + // given + Penalty penalty = new Penalty(user, PenaltyType.CANCEL, "[AUTO] 매칭 취소", LocalDateTime.now(), penaltyTime); + + given(penaltyUserAdminRedisRepository.findByIntraId(user.getIntraId())).willReturn( + Optional.empty()); // redis 에 PenaltyUser 가 없을때 + given(penaltyRepository.save(any(Penalty.class))).willReturn(penalty); + + // when, then + penaltyAdminService.givePenalty(user.getIntraId(), penaltyTime, "reason"); + } + } + + @Nested + @DisplayName("getAllPenalties - 모든 penalty 를 가져온다") + class GetAllPenaltiesTest { + + @Test + @DisplayName("Success - 현재 penalty 를 가져온다, Boolean current = true") + void success1() { + //given + given(penaltyRepository.findAllCurrent(any(Pageable.class), any(LocalDateTime.class))).willReturn( + Page.empty()); + //when, then + penaltyAdminService.getAllPenalties(Pageable.unpaged(), true); + } + + @Test + @DisplayName("Success - 모든 penalty 를 가져온다, Boolean current = false") + void success2() { + //given + given(penaltyRepository.findAll(any(Pageable.class))).willReturn(Page.empty()); + //when, then + penaltyAdminService.getAllPenalties(Pageable.unpaged(), false); + } + } + + @Nested + @DisplayName("deletePenalty 테스트 - redis에 있는 penalty 삭제, 뒤 시간 penalty 시간 당기고 penalty 삭제, ") + class DeletePenaltyTest { + Penalty penalty; + + @BeforeEach + void beforeEach() { + User user = new User("intra", "email", "image", RacketType.PENHOLDER, + RoleType.USER, 1000, SnsType.NONE, 4242L); + penalty = new Penalty(user, PenaltyType.NOSHOW, "noshow 패널티", LocalDateTime.now(), 10); + ReflectionUtilsForUnitTest.setFieldWithReflection(penalty, "id", 1L); + } + + @Test + @DisplayName("Success - penalty 삭제") + void success() { + //given + given(penaltyRepository.findById(1L)).willReturn(Optional.of(penalty)); + given(penaltyUserAdminRedisRepository.findByIntraId(anyString())) + .willReturn(Optional.of(new RedisPenaltyUser())); + doNothing() + .when(penaltyUserAdminRedisRepository).deletePenaltyInUser(any(RedisPenaltyUser.class), anyInt()); + doNothing() + .when(penaltyRepository).delete(any(Penalty.class)); + //when, then + penaltyAdminService.deletePenalty(1L); + } + + @Test + @DisplayName("Fail - penalty 삭제, penalty 시간이 지났을 경우") + void fail() { + ReflectionUtilsForUnitTest.setFieldWithReflection(penalty, "startTime", + LocalDateTime.now().minusMinutes(20)); + //given + given(penaltyRepository.findById(1L)).willReturn(Optional.of(penalty)); + //when, then + Assertions.assertThrows(PenaltyExpiredException.class, () -> { + penaltyAdminService.deletePenalty(1L); + }); + } + + @Test + @DisplayName("Fail - penalty 삭제, penalty 가 없을 경우") + void fail2() { + //given + given(penaltyRepository.findById(1L)).willReturn(Optional.empty()); + //when, then + Assertions.assertThrows(PenaltyNotFoundException.class, () -> { + penaltyAdminService.deletePenalty(1L); + }); + } + + @Test + @DisplayName("Fail - penalty 삭제, redis 에 penalty 가 없을 경우") + void fail3() { + //given + given(penaltyRepository.findById(1L)).willReturn(Optional.of(penalty)); + given(penaltyUserAdminRedisRepository.findByIntraId(anyString())) + .willReturn(Optional.empty()); + //when, then + Assertions.assertThrows(RedisPenaltyUserNotFoundException.class, () -> { + penaltyAdminService.deletePenalty(1L); + }); + } + } + + @Nested + @DisplayName("getAllPenaltiesByIntraId - intraId 로 패널티 리스트 조회") + class GetAllPenaltiesByIntraIdTest { + + @Test + @DisplayName("Success - 현재 penalty 들을 가져온다, Boolean current = true") + void success1() { + //given + given(penaltyRepository.findAllCurrentByIntraId(any(Pageable.class), any(LocalDateTime.class), anyString())) + .willReturn(Page.empty()); + //when, then + penaltyAdminService.getAllPenaltiesByIntraId(Pageable.unpaged(), "intra", true); + } + + @Test + @DisplayName("Success - 모든 penalty 를 가져 온다, Boolean current = false") + void success2() { + //given + given(penaltyRepository.findAllByIntraId(any(Pageable.class), anyString())) + .willReturn(Page.empty()); + //when, then + penaltyAdminService.getAllPenaltiesByIntraId(Pageable.unpaged(), "intra", false); + } + } +} diff --git a/src/test/java/com/gg/server/data/manage/PenaltyTest.java b/src/test/java/com/gg/server/data/manage/PenaltyTest.java new file mode 100644 index 000000000..cb22a9a92 --- /dev/null +++ b/src/test/java/com/gg/server/data/manage/PenaltyTest.java @@ -0,0 +1,26 @@ +package com.gg.server.data.manage; + +import static org.junit.jupiter.api.Assertions.*; + +import java.time.LocalDateTime; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class PenaltyTest { + + @Test + void updateStartTime() { + // given + Penalty penalty = new Penalty(); + // when + penalty.updateStartTime(LocalDateTime.now()); + // then + assertNotNull(penalty.getStartTime()); + } +} diff --git a/src/test/java/com/gg/server/domain/penalty/service/PenaltyServiceTest.java b/src/test/java/com/gg/server/domain/penalty/service/PenaltyServiceTest.java new file mode 100644 index 000000000..f07ceee01 --- /dev/null +++ b/src/test/java/com/gg/server/domain/penalty/service/PenaltyServiceTest.java @@ -0,0 +1,102 @@ +package com.gg.server.domain.penalty.service; + +import static org.mockito.BDDMockito.*; + +import java.time.LocalDateTime; +import java.util.Optional; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import com.gg.server.data.manage.Penalty; +import com.gg.server.data.manage.redis.RedisPenaltyUser; +import com.gg.server.data.user.User; +import com.gg.server.data.user.type.RacketType; +import com.gg.server.data.user.type.RoleType; +import com.gg.server.data.user.type.SnsType; +import com.gg.server.domain.penalty.data.PenaltyRepository; +import com.gg.server.domain.penalty.redis.PenaltyUserRedisRepository; +import com.gg.server.domain.penalty.type.PenaltyType; +import com.gg.server.domain.user.dto.UserDto; +import com.gg.server.domain.user.service.UserFindService; +import com.gg.server.utils.annotation.UnitTest; + +@UnitTest +@ExtendWith(MockitoExtension.class) +class PenaltyServiceTest { + @Mock + PenaltyRepository penaltyRepository; + @Mock + PenaltyUserRedisRepository penaltyUserRedisRepository; + @Mock + UserFindService userFindService; + @InjectMocks + PenaltyService penaltyService; + + @Nested + @DisplayName("givePenalty - User에게 penalty 부여 한다") + class GivePenaltyTest { + + User user; + UserDto userDto; + int penaltyTime; + + @BeforeEach + void beforeEach() { + user = new User("intra", "email", "image", RacketType.PENHOLDER, + RoleType.USER, 1000, SnsType.NONE, 4242L); + userDto = UserDto.from(user); + penaltyTime = 1; + given(userFindService.findUserById(userDto.getId())).willReturn(user); + doNothing().when(penaltyUserRedisRepository) + .addPenaltyUser(any(RedisPenaltyUser.class), any(LocalDateTime.class)); + } + + @Test + @DisplayName("Success : redis 에 PenaltyUser 가 있을때") + void success1() { + RedisPenaltyUser redisPenaltyUser = new RedisPenaltyUser(); + redisPenaltyUser.updateReleaseTime(LocalDateTime.now(), penaltyTime); + Optional optional = Optional.of(redisPenaltyUser); + Penalty penalty = new Penalty(user, PenaltyType.CANCEL, "[AUTO] 매칭 취소", redisPenaltyUser.getReleaseTime(), + penaltyTime); + + given(penaltyUserRedisRepository.findByIntraId(userDto.getIntraId())).willReturn( + optional); // redis 에 PenaltyUser 가 있을때 + given(penaltyRepository.save(any(Penalty.class))).willReturn(penalty); + + // when, then + penaltyService.givePenalty(userDto, penaltyTime); + } + + @Test + @DisplayName("Success : redis 에 PenaltyUser 가 없을때") + void success2() { + // given + Penalty penalty = new Penalty(user, PenaltyType.CANCEL, "[AUTO] 매칭 취소", LocalDateTime.now(), penaltyTime); + + given(penaltyUserRedisRepository.findByIntraId(userDto.getIntraId())).willReturn( + Optional.empty()); // redis 에 PenaltyUser 가 없을때 + given(penaltyRepository.save(any(Penalty.class))).willReturn(penalty); + + // when, then + penaltyService.givePenalty(userDto, penaltyTime); + } + } + + @Test + @DisplayName("isPenaltyUser - Redis 에 PenaltyUser 가 존재 하는지 확인 한다") + void isPenaltyUser() { + //given + given(penaltyUserRedisRepository.findByIntraId("intraId")).willReturn(Optional.of(new RedisPenaltyUser())); + + //when then + penaltyService.isPenaltyUser("intraId"); + } +} From 900aa36b8d68cf78566a2516dd9a07e3a8134323 Mon Sep 17 00:00:00 2001 From: hannkim Date: Fri, 23 Feb 2024 18:16:24 +0900 Subject: [PATCH 29/32] =?UTF-8?q?=F0=9F=94=A8=20[Refactor]=20Multi=20modul?= =?UTF-8?q?e=20=EC=A0=81=EC=9A=A9=20(#587)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: yoahn <46748334+AYoungSn@users.noreply.github.com> Co-authored-by: wken5577 Co-authored-by: Hyunkyu Lee <88573971+wken5577@users.noreply.github.com> Co-authored-by: AYoungSn --- .github/workflows/test-code-validation.yml | 22 +- .gitignore | 9 +- Dockerfile | 2 +- build.gradle | 382 +++++++++--------- codecov.yml | 10 +- gg-pingpong-admin-repo/build.gradle | 25 ++ .../admin/repo/game}/GameAdminRepository.java | 12 +- .../repo/game}/PChangeAdminRepository.java | 4 +- .../game}/PChangeAdminRepositoryCustom.java | 4 +- .../PChangeAdminRepositoryCustomImpl.java | 5 +- .../admin/repo/game}/TeamAdminRepository.java | 6 +- .../repo/game}/TeamUserAdminRepository.java | 6 +- .../admin/repo/game/out}/GameTeamUser.java | 6 +- .../AdminSlotManagementsRepository.java | 4 +- .../manage}/AnnouncementAdminRepository.java | 4 +- .../repo/manage}/FeedbackAdminRepository.java | 4 +- .../repo/manage}/PenaltyAdminRepository.java | 4 +- .../manage}/PenaltyAdminRepositoryCustom.java | 4 +- .../PenaltyAdminRepositoryCustomImpl.java | 5 +- .../PenaltyUserAdminRedisRepository.java | 7 +- .../admin/repo/noti}/NotiAdminRepository.java | 4 +- .../repo/noti}/NotiAdminRepositoryCustom.java | 4 +- .../noti}/NotiAdminRepositoryCustomImpl.java | 5 +- .../repo/season}/SeasonAdminRepository.java | 7 +- .../store}/CoinPolicyAdminRepository.java | 4 +- .../repo/store}/ItemAdminRepository.java | 4 +- .../repo/store}/MegaphoneAdminRepository.java | 4 +- .../repo/store}/ReceiptAdminRepository.java | 4 +- .../store}/ReceiptAdminRepositorySearch.java | 4 +- .../admin/repo/user}/UserAdminRepository.java | 4 +- .../repo/user}/UserImageAdminRepository.java | 6 +- gg-pingpong-api/build.gradle | 53 +++ .../pingpong/api/PingpongApiApplication.java | 14 + .../game/controller/GameAdminController.java | 19 +- .../GameLogListAdminResponseDto.java | 3 +- .../api}/admin/game/dto/GameLogAdminDto.java | 7 +- .../api}/admin/game/dto/GameTeamAdminDto.java | 2 +- .../game/dto/GameUserLogAdminReqDto.java | 5 +- .../game/dto/RankGamePPPModifyReqDto.java | 2 +- .../admin/game/service/GameAdminService.java | 59 ++- .../AnnouncementAdminController.java | 11 +- .../controller/FeedbackAdminController.java | 9 +- .../controller/PenaltyAdminController.java | 11 +- .../controller/SlotAdminController.java | 9 +- .../request}/FeedbackAdminPageRequestDto.java | 5 +- .../request}/PenaltyRequestDto.java | 2 +- .../request}/SlotCreateRequestDto.java | 2 +- .../AnnouncementAdminListResponseDto.java | 2 +- .../AnnouncementAdminResponseDto.java | 5 +- .../response}/FeedbackAdminResponseDto.java | 7 +- .../FeedbackListAdminResponseDto.java | 2 +- .../response}/PenaltyListResponseDto.java | 2 +- .../response}/PenaltyUserResponseDto.java | 7 +- .../response}/SlotListAdminResponseDto.java | 3 +- .../manage}/dto/AnnouncementAdminAddDto.java | 2 +- .../api/admin/manage}/dto/SlotAdminDto.java | 5 +- .../service/AnnouncementAdminService.java | 19 +- .../manage}/service/FeedbackAdminService.java | 13 +- .../manage}/service/PenaltyAdminService.java | 52 +-- .../manage}/service/SlotAdminService.java | 41 +- .../noti/controller/NotiAdminController.java | 11 +- .../request}/NotiListAdminRequestDto.java | 5 +- .../request}/SendNotiAdminRequestDto.java | 2 +- .../response}/NotiListAdminResponseDto.java | 3 +- .../api}/admin/noti/dto/NotiAdminDto.java | 7 +- .../admin/noti/service/NotiAdminService.java | 25 +- .../admin/rank/service/RankAdminService.java | 29 +- .../rank/service/RankRedisAdminService.java | 28 +- .../controller/SeasonAdminController.java | 13 +- .../request}/SeasonCreateRequestDto.java | 12 +- .../request}/SeasonUpdateRequestDto.java | 2 +- .../response}/SeasonListAdminResponseDto.java | 3 +- .../api}/admin/season/dto/SeasonAdminDto.java | 7 +- .../season/service/SeasonAdminService.java | 27 +- .../api}/admin/season/type/SeasonStatus.java | 2 +- .../controller/CoinAdminController.java | 7 +- .../controller/CoinPolicyAdminController.java | 15 +- .../controller/ItemAdminController.java | 19 +- .../controller/MegaphoneAdminController.java | 9 +- .../controller/ReceiptAdminController.java | 9 +- .../request}/CoinUpdateRequestDto.java | 2 +- .../request}/ItemUpdateRequestDto.java | 23 +- .../request}/ReceiptAdminPageRequestDto.java | 5 +- .../CoinPolicyAdminListResponseDto.java | 2 +- .../response}/CoinPolicyAdminResponseDto.java | 5 +- .../response}/ItemHistoryResponseDto.java | 5 +- .../response}/ItemListResponseDto.java | 2 +- .../response}/MegaphoneAdminResponseDto.java | 5 +- .../MegaphoneHistoryResponseDto.java | 2 +- .../response}/ReceiptListResponseDto.java | 2 +- .../response}/ReceiptResponseDto.java | 9 +- .../store}/dto/CoinPolicyAdminAddDto.java | 2 +- .../admin/store/service/CoinAdminService.java | 28 ++ .../service/CoinPolicyAdminService.java | 24 +- .../store}/service/ItemAdminService.java | 25 +- .../store}/service/MegaphoneAdminService.java | 9 +- .../store/service/ReceiptAdminService.java | 31 ++ .../controller/TournamentAdminController.java | 17 +- .../TournamentAdminAddUserRequestDto.java | 2 +- .../TournamentAdminCreateRequestDto.java | 5 +- .../TournamentAdminUpdateRequestDto.java | 8 +- .../TournamentGameUpdateRequestDto.java | 5 +- .../TournamentAdminAddUserResponseDto.java | 2 +- .../service/TournamentAdminService.java | 77 ++-- .../user/controller/UserAdminController.java | 21 +- .../request}/UserSearchAdminRequestDto.java | 5 +- .../request}/UserUpdateAdminRequestDto.java | 5 +- .../response}/UserDetailAdminResponseDto.java | 7 +- .../UserImageListAdminResponseDto.java | 3 +- .../response}/UserSearchAdminResponseDto.java | 3 +- .../api}/admin/user/dto/UserAdminDto.java | 13 +- .../admin/user/dto/UserImageAdminDto.java | 5 +- .../admin/user/dto/UserSearchAdminDto.java | 7 +- .../admin/user/service/UserAdminService.java | 63 +-- .../api}/global/config/AWSConfig.java | 2 +- .../global/config/AsyncConfiguration.java | 2 +- .../api}/global/config/ConstantConfig.java | 2 +- .../api}/global/config/JpaAuditingConfig.java | 2 +- .../pingpong/api/global/config/JpaConfig.java | 11 + .../api}/global/config/RedisConfig.java | 2 +- .../api}/global/config/SwaggerConfig.java | 4 +- .../global/config/TimeZoneConfiguration.java | 2 +- .../api}/global/config/WebConfig.java | 11 +- .../api}/global/dto/PageRequestDto.java | 2 +- .../exception/GlobalExceptionHandler.java | 18 +- .../api}/global/log/annotation/Trace.java | 2 +- .../api}/global/log/aspect/TraceAspect.java | 15 +- .../api}/global/log/domain/TraceId.java | 2 +- .../api}/global/log/domain/TraceStatus.java | 2 +- .../global/log/pointcut/TracePointcut.java | 4 +- .../api}/global/log/service/LogTrace.java | 4 +- .../log/service/ThreadLocalLogTrace.java | 8 +- .../global/scheduler/AbstractScheduler.java | 2 +- .../global/scheduler/GameStatusScheduler.java | 5 +- .../global/scheduler/MegaphoneScheduler.java | 5 +- .../global/scheduler/TournamentScheduler.java | 7 +- .../api}/global/security/UserPrincipal.java | 7 +- .../config/RestAuthenticationEntryPoint.java | 2 +- .../security/config/SecurityConfig.java | 13 +- .../config/properties/AppProperties.java | 2 +- .../config/properties/CorsProperties.java | 2 +- .../global/security/cookie/CookieUtil.java | 5 +- .../OAuthAuthenticationSuccessHandler.java | 25 +- .../global/security/info/OAuthUserInfo.java | 4 +- .../security/info/OAuthUserInfoFactory.java | 6 +- .../global/security/info/ProviderType.java | 2 +- .../info/impl/FortyTwoOAuthUserInfo.java | 6 +- .../info/impl/KakaoOAuthUserInfo.java | 6 +- .../jwt/repository/JwtRedisRepository.java | 2 +- .../security/jwt/utils/AuthTokenProvider.java | 5 +- .../jwt/utils/TokenAuthenticationFilter.java | 7 +- .../security/jwt/utils/TokenHeaders.java | 2 +- ...izationRequestBasedOnCookieRepository.java | 4 +- .../service/CustomOAuth2UserService.java | 43 +- .../service/CustomUserDetailsService.java | 11 +- .../api}/global/utils/ApplicationYmlRead.java | 2 +- .../api}/global/utils/AsyncMailSender.java | 2 +- .../pingpong/api}/global/utils/EloRating.java | 2 +- .../api}/global/utils/ExpLevelCalculator.java | 2 +- .../api}/global/utils/FileDownloader.java | 2 +- .../api}/global/utils/HeaderUtil.java | 2 +- .../api}/global/utils/ImageResizingUtil.java | 4 +- .../api}/global/utils/ItemImageHandler.java | 5 +- .../api}/global/utils/JpegMultipartFile.java | 2 +- .../api}/global/utils/UserImageHandler.java | 7 +- .../global/utils/argumentresolver/Login.java | 2 +- .../LoginMemberArgumentResolver.java | 13 +- .../utils/aws/AsyncNewItemImageUploader.java | 6 +- .../utils/aws/AsyncNewUserImageUploader.java | 13 +- .../api}/global/utils/external/ApiUtil.java | 2 +- .../utils/querytracker/ApiQueryCounter.java | 2 +- .../querytracker/ApiQueryCounterAop.java | 2 +- .../utils/querytracker/ApiQueryInspector.java | 2 +- .../querytracker/ConnectionProxyHandler.java | 2 +- .../querytracker/LoggingInterceptor.java | 2 +- .../PreparedStatementProxyHandler.java | 2 +- .../user/game/controller}/GameController.java | 41 +- .../controller}/request/GameListReqDto.java | 5 +- .../request/NormalGameListReqDto.java | 5 +- .../request/NormalResultReqDto.java | 2 +- .../request/RankGameListReqDto.java | 2 +- .../controller}/request/RankResultReqDto.java | 2 +- .../request/TournamentResultReqDto.java | 6 +- .../controller/response}/GameListResDto.java | 2 +- .../response}/GamePChangeResultResDto.java | 6 +- .../response}/GamePPPChangeResultResDto.java | 5 +- .../response}/GameResultResDto.java | 9 +- .../api/user}/game/dto/GameTeamInfo.java | 11 +- .../api/user/game}/dto/MatchTeamsInfoDto.java | 5 +- .../pingpong/api/user/game}/dto/TeamInfo.java | 5 +- .../api/user/game}/dto/TeamReqDto.java | 2 +- .../api/user/game}/dto/TeamUserInfoDto.java | 4 +- .../api/user/game}/dto/TeamUserListDto.java | 2 +- .../user}/game/service/GameFindService.java | 22 +- .../api/user}/game/service/GameService.java | 72 ++-- .../user}/game/service/GameStatusService.java | 31 +- .../user/game}/service/PChangeService.java | 13 +- .../controller/AnnouncementController.java | 7 +- .../controller/FeedbackController.java | 13 +- .../request}/FeedbackRequestDto.java | 5 +- .../response}/AnnouncementResponseDto.java | 2 +- .../api/user/manage}/dto/AnnouncementDto.java | 5 +- .../redis/PenaltyUserRedisRepository.java | 7 +- .../manage}/service/AnnouncementService.java | 11 +- .../user/manage}/service/FeedbackService.java | 15 +- .../user/manage}/service/PenaltyService.java | 19 +- .../match/controller/MatchController.java | 19 +- .../controller/request}/MatchRequestDto.java | 4 +- .../response}/MatchStatusResponseListDto.java | 3 +- .../response}/SlotStatusResponseListDto.java | 3 +- .../api/user/match/dto/GameAddDto.java | 44 ++ .../api/user}/match/dto/MatchStatusDto.java | 10 +- .../api/user}/match/dto/SlotStatusDto.java | 4 +- .../match/service/GameUpdateService.java | 40 +- .../user}/match/service/MatchFindService.java | 60 +-- .../api/user}/match/service/MatchService.java | 69 ++-- .../match/service/MatchTournamentService.java | 61 ++- .../user}/match/utils/MatchCalculator.java | 8 +- .../api/user}/match/utils/SlotGenerator.java | 25 +- .../user}/noti/controller/NotiController.java | 13 +- .../request/NotiFindByUserRequestDto.java | 4 + .../response/NotiFindByUserResponseDto.java | 4 + .../response}/NotiListResponseDto.java | 2 +- .../controller/response}/NotiResponseDto.java | 7 +- .../pingpong/api/user}/noti/dto/NotiDto.java | 9 +- .../api/user}/noti/dto/UserNotiDto.java | 7 +- .../api/user}/noti/service/NotiService.java | 25 +- .../user}/noti/service/SnsNotiService.java | 15 +- .../noti/service/sns/NotiMailSender.java | 13 +- .../noti/service/sns/SlackbotService.java | 17 +- .../user}/noti/service/sns/SlackbotUtils.java | 2 +- .../user}/rank/controller/RankController.java | 15 +- .../rank/controller/RankV2Controller.java | 15 +- .../response}/ExpRankPageResponseDto.java | 3 +- .../response}/RankPageResponseDto.java | 3 +- .../api/user}/rank/dto/ExpRankDto.java | 8 +- .../pingpong/api/user}/rank/dto/RankDto.java | 8 +- .../user}/rank/redis/RankRedisService.java | 33 +- .../user/rank/redis}/RedisUploadService.java | 24 +- .../user}/rank/service/RankFindService.java | 11 +- .../api/user}/rank/service/RankService.java | 43 +- .../api/user/rank}/service/TierService.java | 13 +- .../season/controller}/SeasonController.java | 7 +- .../response}/SeasonListResDto.java | 2 +- .../controller/response}/SeasonResDto.java | 5 +- .../api/user}/season/dto/CurSeason.java | 5 +- .../season/service/SeasonFindService.java | 38 ++ .../user}/season/service/SeasonService.java | 11 +- .../store}/controller/ItemController.java | 17 +- .../controller/MegaphoneController.java | 15 +- .../request}/ItemGiftRequestDto.java | 2 +- .../request}/MegaphoneUseRequestDto.java | 2 +- .../response}/ItemStoreListResponseDto.java | 2 +- .../response}/ItemStoreResponseDto.java | 7 +- .../response}/MegaphoneDetailResponseDto.java | 5 +- .../MegaphoneTodayListResponseDto.java | 5 +- .../response}/UserItemListResponseDto.java | 2 +- .../response}/UserItemResponseDto.java | 11 +- .../store}/dto/UserGameCoinResultDto.java | 2 +- .../redis/MegaphoneRedisRepository.java | 5 +- .../store}/service/CoinHistoryService.java | 17 +- .../api/user/store}/service/ItemService.java | 52 ++- .../user/store}/service/MegaphoneService.java | 50 ++- .../store}/service/UserCoinChangeService.java | 25 +- .../controller/TournamentController.java | 19 +- .../request}/TournamentFilterRequestDto.java | 9 +- .../TournamentGameListResponseDto.java | 2 +- .../response}/TournamentGameResDto.java | 11 +- .../response}/TournamentListResponseDto.java | 2 +- .../response}/TournamentResponseDto.java | 13 +- .../TournamentUserListResponseDto.java | 5 +- ...TournamentUserRegistrationResponseDto.java | 5 +- .../response}/TournamentUserResponseDto.java | 5 +- .../tournament/service/TournamentService.java | 65 ++- .../user}/user/controller/UserController.java | 61 ++- .../request}/UserModifyRequestDto.java | 7 +- .../request}/UserProfileImageRequestDto.java | 2 +- .../response}/CoinHistoryResponseDto.java | 5 +- .../response}/UserAttendanceResponseDto.java | 2 +- .../UserCoinHistoryListResponseDto.java | 2 +- .../response}/UserCoinResponseDto.java | 2 +- .../response}/UserDetailResponseDto.java | 15 +- .../response}/UserHistoryResponseDto.java | 3 +- .../response}/UserImageResponseDto.java | 3 +- .../response}/UserLiveResponseDto.java | 5 +- .../UserNormalDetailResponseDto.java | 5 +- .../response}/UserRankResponseDto.java | 2 +- .../response}/UserSearchResponseDto.java | 2 +- .../user}/user/dto/UserAccessTokenDto.java | 2 +- .../api/user}/user/dto/UserBackgroundDto.java | 2 +- .../pingpong/api/user}/user/dto/UserDto.java | 11 +- .../api/user}/user/dto/UserEdgeDto.java | 2 +- .../api/user}/user/dto/UserHistoryData.java | 5 +- .../api/user}/user/dto/UserImageDto.java | 7 +- .../api/user}/user/dto/UserOauthDto.java | 2 +- .../api/user}/user/dto/UserTextColorDto.java | 2 +- .../service/UserAuthenticationService.java | 9 +- .../user}/user/service/UserCoinService.java | 19 +- .../user}/user/service/UserFindService.java | 21 +- .../api/user}/user/service/UserService.java | 125 +++--- .../service/UserTextColorCheckService.java | 2 +- .../db/migration/V1.1__migration_42gg_5th.sql | 0 ...V1.2__update_tournament_content_column.sql | 0 .../main/resources/db/migration/V1__init.sql | 0 .../src}/main/resources/logback-spring.xml | 12 +- .../ServerPingpongApiApplicationTests.java | 6 +- .../AnnouncementAdminControllerFailTest.java | 10 +- .../AnnouncementAdminControllerTest.java | 18 +- .../AnnouncementAdminControllerUnitTest.java | 14 +- .../AnnouncementAdminServiceUnitTest.java | 15 +- .../controller/CoinAdminControllerTest.java | 12 +- .../CoinPolicyAdminControllerFailTest.java | 12 +- .../CoinPolicyAdminControllerTest.java | 22 +- .../coin/service/CoinAdminServiceTest.java | 17 +- .../FeedbackAdminControllerTest.java | 20 +- .../FeedbackAdminControllerUnitTest.java | 11 +- .../service/FeedbackAdminServiceUnitTest.java | 11 +- .../controller/GameAdminControllerTest.java | 40 +- .../controller/ItemAdminControllerTest.java | 27 +- .../service/ItemAdminServiceUnitTest.java | 43 +- .../MegaphoneAdminControllerTest.java | 9 +- .../MegaphoneAdminServiceUnitTest.java | 8 +- .../controller/NotiAdminControllerTest.java | 28 +- .../service/NotiAdminServiceUnitTest.java | 26 +- .../PenaltyAdminControllerTest.java | 35 +- .../ReceiptAdminControllerTest.java | 25 +- .../service/ReceiptAdminServiceUnitTest.java | 9 +- .../SeasonAdminControllerTest.java | 40 +- .../service/SeasonAdminServiceUnitTest.java | 32 +- .../SlotAdminControllerFailTest.java | 16 +- .../controller/SlotAdminControllerTest.java | 20 +- .../service/SlotAdminServiceUnitTest.java | 15 +- .../TournamentAdminControllerTest.java | 54 +-- .../TournamentAdminUserControllerTest.java | 20 +- .../service/TournamentAdminServiceTest.java | 58 +-- .../controller/UserAdminControllerTest.java | 32 +- .../pingpong/api}/data/game/GameUnitTest.java | 10 +- .../api}/data/game/PChangeDataTest.java | 5 +- .../pingpong/api}/data/game/TeamUnitTest.java | 10 +- .../data/game/TournamentGameUnitTest.java | 11 +- .../data/game/TournamentUserUnitTest.java | 12 +- .../data/manage/AnnouncementUnitTest.java | 9 +- .../api}/data/store/ItemUnitTest.java | 7 +- .../AnnouncementControllerTest.java | 16 +- .../AnnouncementControllerUnitTest.java | 11 +- .../service/AnnouncementServiceUnitTest.java | 11 +- .../coin/service/CoinHistoryServiceTest.java | 22 +- .../service/UserCoinChangeServiceTest.java | 57 +-- .../controller/FeedbackControllerTest.java | 16 +- .../FeedbackControllerUnitTest.java | 11 +- .../service/FeedbackServiceUnitTest.java | 17 +- .../api/user}/game/GameControllerTest.java | 83 ++-- .../api/user}/game/service/GameDBTest.java | 33 +- .../game/service/GameFindServiceTest.java | 45 +-- .../user}/game/service/GameServiceTest.java | 58 +-- .../game/service/GameStatusServiceTest.java | 43 +- .../controller/ItemGiftControllerTest.java | 14 +- .../ItemPurchaseControllerTest.java | 12 +- .../ItemStoreListControllerTest.java | 18 +- .../UserItemResponseControllerTest.java | 9 +- .../item/service/ItemServiceUnitTest.java | 53 +-- .../match/dto/MatchStatusDtoUnitTest.java | 10 +- .../match/service/MatchBothServiceTest.java | 41 +- .../service/MatchFindServiceUnitTest.java | 59 +-- .../user}/match/service/MatchServiceTest.java | 94 ++--- .../service/MatchTournamentServiceTest.java | 46 +-- .../MatchTournamentServiceUnitTest.java | 58 +-- .../api/user}/match/utils/GameTestUtils.java | 16 +- .../utils/MatchIntegrationTestUtils.java | 33 +- .../match/utils/TournamentGameTestUtils.java | 26 +- .../match/utils/TournamentTestUtils.java | 14 +- .../api/user}/match/utils/UserTestUtils.java | 10 +- .../controller/MegaphoneControllerTest.java | 39 +- .../service/MegaphoneServiceUnitTest.java | 51 +-- .../noti/controller/NotiControllerTest.java | 29 +- .../user}/noti/service/NotiServiceTest.java | 21 +- .../noti/service/NotiServiceUnitTest.java | 34 +- .../noti/service/SnsNotiServiceUnitTest.java | 18 +- .../service/sns/NotiMailSenderUnitTest.java | 16 +- .../pchange/service/PChangeServiceTest.java | 23 +- .../rank/controller/RankControllerTest.java | 25 +- .../rank/controller/RankV2ControllerTest.java | 24 +- .../rank/redis/RankRedisRepositoryTest.java | 9 +- .../user}/rank/redis/RedisTestService.java | 2 +- .../rank/redis/RedisTransactionTest.java | 4 +- .../user}/rank/service/RankServiceTest.java | 24 +- .../user}/season/SeasonTestController.java | 27 +- .../api/user}/season/SeasonTriggerTest.java | 14 +- .../season/service/SeasonServiceUnitTest.java | 10 +- .../tier/service/TierServiceUnitTest.java | 17 +- .../TournamentControllerMvcTest.java | 26 +- .../TournamentFindControllerTest.java | 36 +- .../TournamentGameControllerTest.java | 36 +- .../controller/TournamentSchedulerTest.java | 24 +- .../service/TournamentServiceUnitTest.java | 64 +-- .../user/controller/UserControllerTest.java | 104 ++--- .../UserAuthenticationServiceUnitTest.java | 10 +- .../user/service/UserFindServiceUnitTest.java | 8 + .../utils/ReflectionUtilsForUnitTest.java | 6 +- .../src}/test/resources/application.yml | 0 gg-pingpong-data/build.gradle | 20 + .../gg/pingpong/data}/BaseTimeEntity.java | 2 +- .../java/gg/pingpong}/data/game/Game.java | 23 +- .../java/gg/pingpong}/data/game/PChange.java | 7 +- .../java/gg/pingpong}/data/game/Team.java | 7 +- .../java/gg/pingpong}/data/game/TeamUser.java | 9 +- .../java/gg/pingpong/data/game/type/Mode.java | 27 ++ .../pingpong}/data/game/type/StatusType.java | 2 +- .../pingpong}/data/manage/Announcement.java | 12 +- .../gg/pingpong}/data/manage/Feedback.java | 9 +- .../gg/pingpong}/data/manage/Penalty.java | 9 +- .../pingpong/data/manage}/SlotManagement.java | 21 +- .../data/manage/redis/RedisPenaltyUser.java | 2 +- .../data/manage/type/FeedbackType.java | 2 +- .../data/manage}/type/PenaltyKey.java | 2 +- .../data/manage}/type/PenaltyType.java | 2 +- .../pingpong}/data/match/RedisMatchTime.java | 4 +- .../pingpong}/data/match/RedisMatchUser.java | 5 +- .../pingpong}/data/match/type/MatchKey.java | 2 +- .../gg/pingpong}/data/match/type/Option.java | 4 +- .../pingpong}/data/match/type/SlotStatus.java | 2 +- .../match/type/TournamentMatchStatus.java | 2 +- .../java/gg/pingpong}/data/noti/Noti.java | 9 +- .../gg/pingpong}/data/noti/type/NotiType.java | 2 +- .../java/gg/pingpong/data/rank}/Rank.java | 15 +- .../java/gg/pingpong/data/rank}/Tier.java | 2 +- .../pingpong/data/rank}/redis/RankRedis.java | 14 +- .../java/gg/pingpong/data/season}/Season.java | 11 +- .../gg/pingpong}/data/store/CoinHistory.java | 5 +- .../gg/pingpong/data/store}/CoinPolicy.java | 16 +- .../java/gg/pingpong}/data/store/Item.java | 21 +- .../gg/pingpong}/data/store/Megaphone.java | 5 +- .../java/gg/pingpong}/data/store/Receipt.java | 5 +- .../data/store/redis/MegaphoneRedis.java | 2 +- .../data/store/type/HistoryType.java | 2 +- .../pingpong}/data/store/type/ItemStatus.java | 2 +- .../pingpong}/data/store/type/ItemType.java | 2 +- .../pingpong/data/tournament}/Tournament.java | 15 +- .../data/tournament}/TournamentGame.java | 8 +- .../data/tournament}/TournamentUser.java | 7 +- .../data/tournament}/type/RoundNumber.java | 2 +- .../tournament}/type/TournamentRound.java | 4 +- .../tournament}/type/TournamentStatus.java | 2 +- .../data/tournament}/type/TournamentType.java | 2 +- .../type/TournamentUserStatus.java | 2 +- .../java/gg/pingpong}/data/user/User.java | 28 +- .../gg/pingpong}/data/user/UserImage.java | 2 +- .../data/user/type/BackgroundType.java | 2 +- .../gg/pingpong}/data/user/type/EdgeType.java | 2 +- .../pingpong}/data/user/type/OauthType.java | 2 +- .../pingpong}/data/user/type/RacketType.java | 2 +- .../gg/pingpong}/data/user/type/RoleType.java | 2 +- .../gg/pingpong}/data/user/type/SnsType.java | 2 +- .../data/tournament}/TournamentUnitTest.java | 14 +- gg-pingpong-repo/build.gradle | 25 ++ .../pingpong/repo/game}/GameRepository.java | 14 +- .../repo/game}/GameRepositoryCustom.java | 4 +- .../repo/game}/GameRepositoryImpl.java | 7 +- .../repo/game}/PChangeRepository.java | 6 +- .../repo/game}/PChangeRepositoryCustom.java | 4 +- .../repo/game}/PChangeRepositoryImpl.java | 5 +- .../pingpong/repo/game}/TeamRepository.java | 4 +- .../repo/game}/TeamUserRepository.java | 4 +- .../pingpong/repo/game/out/GameTeamUser.java | 50 +++ .../repo/game/out}/GameTeamUserInfo.java | 6 +- .../gg/pingpong/repo/game/out}/GameUser.java | 4 +- .../repo/manage}/AnnouncementRepository.java | 4 +- .../repo/manage}/FeedbackRepository.java | 4 +- .../repo/manage}/PenaltyRepository.java | 4 +- .../manage}/SlotManagementRepository.java | 4 +- .../repo/match}/RedisMatchTimeRepository.java | 7 +- .../repo/match}/RedisMatchUserRepository.java | 11 +- .../pingpong/repo/noti}/NotiRepository.java | 6 +- .../repo/noti}/NotiRepositoryCustom.java | 2 +- .../repo/noti}/NotiRepositoryImpl.java | 2 +- .../pingpong/repo/rank}/RankRepository.java | 5 +- .../gg/pingpong/repo/rank}/RankV2Dto.java | 2 +- .../pingpong/repo/rank}/TierRepository.java | 4 +- .../repo}/rank/redis/RankRedisRepository.java | 6 +- .../repo/season}/SeasonRepository.java | 4 +- .../repo/store}/CoinHistoryRepository.java | 6 +- .../repo/store}/CoinPolicyRepository.java | 4 +- .../pingpong/repo/store}/ItemRepository.java | 4 +- .../repo/store}/MegaphoneRepository.java | 8 +- .../repo/store}/ReceiptRepository.java | 4 +- .../repo/store}/UserItemRepository.java | 4 +- .../TournamentGameRepository.java | 6 +- .../tournarment}/TournamentRepository.java | 8 +- .../TournamentUserRepository.java | 8 +- .../gg/pingpong/repo/user}/ExpRankV2Dto.java | 2 +- .../repo/user}/UserImageRepository.java | 6 +- .../pingpong/repo/user}/UserRepository.java | 5 +- gg-pingpong-utils/build.gradle | 103 +++++ .../gg/pingpong/utils}/RedisKeyManager.java | 2 +- .../utils/exception}/BusinessChecker.java | 6 +- .../pingpong/utils}/exception/ErrorCode.java | 2 +- .../utils}/exception/ErrorResponse.java | 2 +- .../announcement}/AnnounceDupException.java | 6 +- .../AnnounceNotFoundException.java | 6 +- .../coin}/CoinHistoryNotFoundException.java | 6 +- .../coin}/CoinPolicyNotFoundException.java | 6 +- .../custom/AuthenticationException.java | 4 +- .../exception/custom/BusinessException.java | 4 +- .../custom/CustomRuntimeException.java | 5 +- .../custom/DBConsistencyException.java | 5 +- .../custom/DuplicationException.java | 4 +- .../exception/custom/ExpiredException.java | 4 +- .../exception/custom/FileException.java | 4 +- .../exception/custom/ForbiddenException.java | 4 +- .../custom/InvalidParameterException.java | 4 +- .../exception/custom/NotExistException.java | 4 +- .../custom/PageNotFoundException.java | 4 +- .../exception/custom/ParseException.java | 4 +- .../exception/custom/SendException.java | 4 +- .../feedback}/FeedbackNotFoundException.java | 6 +- .../game}/GameAlreadyExistException.java | 6 +- .../game}/GameDataConsistencyException.java | 6 +- .../game}/GameNotExistException.java | 6 +- .../game}/GameStatusNotMatchedException.java | 6 +- .../game}/NotRecentlyGameException.java | 6 +- .../game}/ScoreAlreadyEnteredException.java | 6 +- .../game}/ScoreNotInvalidException.java | 6 +- .../game}/ScoreNotMatchedException.java | 6 +- .../item}/InsufficientGgcoinException.java | 6 +- .../item}/ItemImageLargeException.java | 6 +- .../item}/ItemImageTypeException.java | 6 +- .../item}/ItemNotAvailableException.java | 6 +- .../item}/ItemNotFoundException.java | 6 +- .../item}/ItemNotPurchasableException.java | 6 +- .../exception/item}/ItemTypeException.java | 6 +- .../exception/item}/KakaoGiftException.java | 6 +- .../item}/KakaoPurchaseException.java | 6 +- .../match}/EnrolledSlotException.java | 6 +- .../match}/LosingTeamNotFoundException.java | 6 +- .../match}/OptionInvalidException.java | 6 +- .../exception/match}/PastSlotException.java | 6 +- .../match}/PenaltyUserSlotException.java | 6 +- .../exception/match}/SlotCountException.java | 6 +- .../match}/SlotNotFoundException.java | 6 +- .../match}/WinningTeamNotFoundException.java | 6 +- .../megaphone}/MegaphoneContentException.java | 6 +- .../MegaphoneNotFoundException.java | 6 +- .../megaphone}/MegaphoneTimeException.java | 6 +- .../noti}/SlackJsonParseException.java | 6 +- .../exception/noti}/SlackSendException.java | 6 +- .../noti}/SlackUserGetFailedException.java | 6 +- .../pchange}/PChangeNotExistException.java | 6 +- .../penalty}/PenaltyExpiredException.java | 6 +- .../penalty}/PenaltyNotFoundException.java | 6 +- .../RedisPenaltyUserNotFoundException.java | 6 +- .../rank}/RankNotFoundException.java | 6 +- .../exception/rank}/RankUpdateException.java | 6 +- .../rank}/RedisDataNotFoundException.java | 6 +- .../receipt}/ItemStatusException.java | 6 +- .../receipt}/ReceiptNotFoundException.java | 6 +- .../receipt}/ReceiptNotOwnerException.java | 6 +- .../season}/SeasonForbiddenException.java | 6 +- .../season}/SeasonNotFoundException.java | 6 +- .../season}/SeasonTimeBeforeException.java | 6 +- .../SlotManagementForbiddenException.java | 6 +- .../SlotManagementNotFoundException.java | 6 +- .../team}/TeamIdNotMatchException.java | 6 +- .../team}/TeamNotFoundException.java | 6 +- .../tier}/TierNotFoundException.java | 6 +- .../TournamentConflictException.java | 6 +- .../TournamentGameNotFoundException.java | 6 +- .../TournamentNotFoundException.java | 6 +- .../TournamentUpdateException.java | 6 +- .../KakaoOauth2AlreadyExistException.java | 6 +- .../user}/KakaoOauth2NotFoundException.java | 6 +- .../user}/TokenNotValidException.java | 6 +- .../user}/UserAlreadyAttendanceException.java | 6 +- .../user}/UserImageLargeException.java | 6 +- .../user}/UserImageNullException.java | 6 +- .../user}/UserImageTypeException.java | 6 +- .../user}/UserNotFoundException.java | 6 +- .../user}/UserTextColorException.java | 6 +- .../gg/pingpong}/utils/ItemTestUtils.java | 27 +- .../gg/pingpong}/utils/TestDataUtils.java | 104 +++-- .../utils/annotation/DataJpaUnitTest.java | 2 +- .../utils/annotation/IntegrationTest.java | 8 +- .../annotation/IntegrationTestAspect.java | 4 +- .../IntegrationTestWithRedisTransaction.java | 6 +- .../utils/annotation/TestTypeConstant.java | 2 +- .../pingpong}/utils/annotation/UnitTest.java | 2 +- .../utils/annotation/WebMvcUnitTest.java | 2 +- .../utils/config/MySQLInitializer.java | 2 +- .../utils/config/RedisInitializer.java | 2 +- .../utils/config/TestRedisConfig.java | 2 +- .../gg/pingpong/utils}/dto/GameInfoDto.java | 2 +- gradlew.bat | 182 ++++----- naver-checkstyle-rules.xml | 1 + settings.gradle | 6 + src/main/java/com/gg/server/Application.java | 13 - .../admin/coin/service/CoinAdminService.java | 34 -- .../receipt/service/ReceiptAdminService.java | 43 -- .../com/gg/server/data/game/type/Mode.java | 43 -- .../item/exception/ItemNotFoundException.java | 10 - .../server/domain/match/dto/GameAddDto.java | 32 -- .../noti/dto/NotiFindByUserRequestDto.java | 4 - .../noti/dto/NotiFindByUserResponseDto.java | 4 - .../exception/PChangeNotExistException.java | 10 - .../season/service/SeasonFindService.java | 39 -- .../service/PenaltyAdminServiceTest.java | 215 ---------- .../gg/server/data/manage/PenaltyTest.java | 26 -- .../penalty/service/PenaltyServiceTest.java | 102 ----- .../user/service/UserFindServiceUnitTest.java | 8 - 607 files changed, 4013 insertions(+), 4248 deletions(-) create mode 100644 gg-pingpong-admin-repo/build.gradle rename {src/main/java/com/gg/server/admin/game/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game}/GameAdminRepository.java (87%) rename {src/main/java/com/gg/server/admin/pchange/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game}/PChangeAdminRepository.java (68%) rename {src/main/java/com/gg/server/admin/pchange/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game}/PChangeAdminRepositoryCustom.java (59%) rename {src/main/java/com/gg/server/admin/pchange/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game}/PChangeAdminRepositoryCustomImpl.java (88%) rename {src/main/java/com/gg/server/admin/team/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game}/TeamAdminRepository.java (64%) rename {src/main/java/com/gg/server/admin/team/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game}/TeamUserAdminRepository.java (83%) rename {src/main/java/com/gg/server/domain/game/dto => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/out}/GameTeamUser.java (81%) rename {src/main/java/com/gg/server/admin/slotmanagement/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage}/AdminSlotManagementsRepository.java (87%) rename {src/main/java/com/gg/server/admin/announcement/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage}/AnnouncementAdminRepository.java (71%) rename {src/main/java/com/gg/server/admin/feedback/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage}/FeedbackAdminRepository.java (85%) rename {src/main/java/com/gg/server/admin/penalty/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage}/PenaltyAdminRepository.java (90%) rename {src/main/java/com/gg/server/admin/penalty/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage}/PenaltyAdminRepositoryCustom.java (83%) rename {src/main/java/com/gg/server/admin/penalty/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage}/PenaltyAdminRepositoryCustomImpl.java (97%) rename {src/main/java/com/gg/server/admin/penalty/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage}/PenaltyUserAdminRedisRepository.java (93%) rename {src/main/java/com/gg/server/admin/noti/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti}/NotiAdminRepository.java (84%) rename {src/main/java/com/gg/server/admin/noti/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti}/NotiAdminRepositoryCustom.java (79%) rename {src/main/java/com/gg/server/admin/noti/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti}/NotiAdminRepositoryCustomImpl.java (93%) rename {src/main/java/com/gg/server/admin/season/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/season}/SeasonAdminRepository.java (88%) rename {src/main/java/com/gg/server/admin/coin/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store}/CoinPolicyAdminRepository.java (73%) rename {src/main/java/com/gg/server/admin/item/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store}/ItemAdminRepository.java (78%) rename {src/main/java/com/gg/server/admin/megaphone/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store}/MegaphoneAdminRepository.java (78%) rename {src/main/java/com/gg/server/admin/receipt/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store}/ReceiptAdminRepository.java (79%) rename {src/main/java/com/gg/server/admin/receipt/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store}/ReceiptAdminRepositorySearch.java (84%) rename {src/main/java/com/gg/server/admin/user/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/user}/UserAdminRepository.java (86%) rename {src/main/java/com/gg/server/admin/user/data => gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/user}/UserImageAdminRepository.java (94%) create mode 100644 gg-pingpong-api/build.gradle create mode 100644 gg-pingpong-api/src/main/java/gg/pingpong/api/PingpongApiApplication.java rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/game/controller/GameAdminController.java (82%) rename {src/main/java/com/gg/server/admin/game/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/controller/response}/GameLogListAdminResponseDto.java (71%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/game/dto/GameLogAdminDto.java (88%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/game/dto/GameTeamAdminDto.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/game/dto/GameUserLogAdminReqDto.java (78%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/game/dto/RankGamePPPModifyReqDto.java (95%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/game/service/GameAdminService.java (83%) rename {src/main/java/com/gg/server/admin/announcement => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage}/controller/AnnouncementAdminController.java (85%) rename {src/main/java/com/gg/server/admin/feedback => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage}/controller/FeedbackAdminController.java (88%) rename {src/main/java/com/gg/server/admin/penalty => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage}/controller/PenaltyAdminController.java (87%) rename {src/main/java/com/gg/server/admin/slotmanagement => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage}/controller/SlotAdminController.java (82%) rename {src/main/java/com/gg/server/admin/feedback/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/request}/FeedbackAdminPageRequestDto.java (70%) rename {src/main/java/com/gg/server/admin/penalty/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/request}/PenaltyRequestDto.java (87%) rename {src/main/java/com/gg/server/admin/slotmanagement/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/request}/SlotCreateRequestDto.java (95%) rename {src/main/java/com/gg/server/admin/announcement/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response}/AnnouncementAdminListResponseDto.java (83%) rename {src/main/java/com/gg/server/admin/announcement/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response}/AnnouncementAdminResponseDto.java (88%) rename {src/main/java/com/gg/server/admin/feedback/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response}/FeedbackAdminResponseDto.java (80%) rename {src/main/java/com/gg/server/admin/feedback/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response}/FeedbackListAdminResponseDto.java (87%) rename {src/main/java/com/gg/server/admin/penalty/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response}/PenaltyListResponseDto.java (82%) rename {src/main/java/com/gg/server/admin/penalty/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response}/PenaltyUserResponseDto.java (86%) rename {src/main/java/com/gg/server/admin/slotmanagement/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response}/SlotListAdminResponseDto.java (71%) rename {src/main/java/com/gg/server/admin/announcement => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage}/dto/AnnouncementAdminAddDto.java (88%) rename {src/main/java/com/gg/server/admin/slotmanagement => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage}/dto/SlotAdminDto.java (87%) rename {src/main/java/com/gg/server/admin/announcement => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage}/service/AnnouncementAdminService.java (70%) rename {src/main/java/com/gg/server/admin/feedback => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage}/service/FeedbackAdminService.java (84%) rename {src/main/java/com/gg/server/admin/penalty => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage}/service/PenaltyAdminService.java (76%) rename {src/main/java/com/gg/server/admin/slotmanagement => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage}/service/SlotAdminService.java (70%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/noti/controller/NotiAdminController.java (82%) rename {src/main/java/com/gg/server/admin/noti/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/request}/NotiListAdminRequestDto.java (72%) rename {src/main/java/com/gg/server/admin/noti/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/request}/SendNotiAdminRequestDto.java (92%) rename {src/main/java/com/gg/server/admin/noti/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/response}/NotiListAdminResponseDto.java (88%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/noti/dto/NotiAdminDto.java (92%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/noti/service/NotiAdminService.java (77%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/rank/service/RankAdminService.java (66%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/rank/service/RankRedisAdminService.java (66%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/season/controller/SeasonAdminController.java (81%) rename {src/main/java/com/gg/server/admin/season/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/request}/SeasonCreateRequestDto.java (78%) rename {src/main/java/com/gg/server/admin/season/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/request}/SeasonUpdateRequestDto.java (92%) rename {src/main/java/com/gg/server/admin/season/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/response}/SeasonListAdminResponseDto.java (71%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/season/dto/SeasonAdminDto.java (89%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/season/service/SeasonAdminService.java (90%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/season/type/SeasonStatus.java (84%) rename {src/main/java/com/gg/server/admin/coin => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store}/controller/CoinAdminController.java (80%) rename {src/main/java/com/gg/server/admin/coin => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store}/controller/CoinPolicyAdminController.java (79%) rename {src/main/java/com/gg/server/admin/item => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store}/controller/ItemAdminController.java (82%) rename {src/main/java/com/gg/server/admin/megaphone => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store}/controller/MegaphoneAdminController.java (82%) rename {src/main/java/com/gg/server/admin/receipt => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store}/controller/ReceiptAdminController.java (80%) rename {src/main/java/com/gg/server/admin/coin/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request}/CoinUpdateRequestDto.java (89%) rename {src/main/java/com/gg/server/admin/item/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request}/ItemUpdateRequestDto.java (68%) rename {src/main/java/com/gg/server/admin/receipt/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request}/ReceiptAdminPageRequestDto.java (70%) rename {src/main/java/com/gg/server/admin/coin/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response}/CoinPolicyAdminListResponseDto.java (83%) rename {src/main/java/com/gg/server/admin/coin/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response}/CoinPolicyAdminResponseDto.java (88%) rename {src/main/java/com/gg/server/admin/item/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response}/ItemHistoryResponseDto.java (94%) rename {src/main/java/com/gg/server/admin/item/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response}/ItemListResponseDto.java (82%) rename {src/main/java/com/gg/server/admin/megaphone/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response}/MegaphoneAdminResponseDto.java (85%) rename {src/main/java/com/gg/server/admin/megaphone/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response}/MegaphoneHistoryResponseDto.java (87%) rename {src/main/java/com/gg/server/admin/receipt/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response}/ReceiptListResponseDto.java (82%) rename {src/main/java/com/gg/server/admin/receipt/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response}/ReceiptResponseDto.java (87%) rename {src/main/java/com/gg/server/admin/coin => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store}/dto/CoinPolicyAdminAddDto.java (95%) create mode 100644 gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinAdminService.java rename {src/main/java/com/gg/server/admin/coin => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store}/service/CoinPolicyAdminService.java (60%) rename {src/main/java/com/gg/server/admin/item => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store}/service/ItemAdminService.java (80%) rename {src/main/java/com/gg/server/admin/megaphone => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store}/service/MegaphoneAdminService.java (82%) create mode 100644 gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ReceiptAdminService.java rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/tournament/controller/TournamentAdminController.java (88%) rename {src/main/java/com/gg/server/admin/tournament/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request}/TournamentAdminAddUserRequestDto.java (85%) rename {src/main/java/com/gg/server/admin/tournament/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request}/TournamentAdminCreateRequestDto.java (90%) rename {src/main/java/com/gg/server/admin/tournament/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request}/TournamentAdminUpdateRequestDto.java (85%) rename {src/main/java/com/gg/server/admin/tournament/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request}/TournamentGameUpdateRequestDto.java (86%) rename {src/main/java/com/gg/server/admin/tournament/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/response}/TournamentAdminAddUserResponseDto.java (83%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/tournament/service/TournamentAdminService.java (86%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/user/controller/UserAdminController.java (87%) rename {src/main/java/com/gg/server/admin/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/request}/UserSearchAdminRequestDto.java (77%) rename {src/main/java/com/gg/server/admin/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/request}/UserUpdateAdminRequestDto.java (87%) rename {src/main/java/com/gg/server/admin/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response}/UserDetailAdminResponseDto.java (93%) rename {src/main/java/com/gg/server/admin/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response}/UserImageListAdminResponseDto.java (71%) rename {src/main/java/com/gg/server/admin/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response}/UserSearchAdminResponseDto.java (85%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/user/dto/UserAdminDto.java (81%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/user/dto/UserImageAdminDto.java (88%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/user/dto/UserSearchAdminDto.java (83%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/admin/user/service/UserAdminService.java (81%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/config/AWSConfig.java (96%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/config/AsyncConfiguration.java (96%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/config/ConstantConfig.java (92%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/config/JpaAuditingConfig.java (84%) create mode 100644 gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/JpaConfig.java rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/config/RedisConfig.java (99%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/config/SwaggerConfig.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/config/TimeZoneConfiguration.java (88%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/config/WebConfig.java (74%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/dto/PageRequestDto.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/exception/GlobalExceptionHandler.java (90%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/log/annotation/Trace.java (84%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/log/aspect/TraceAspect.java (75%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/log/domain/TraceId.java (93%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/log/domain/TraceStatus.java (87%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/log/pointcut/TracePointcut.java (76%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/log/service/LogTrace.java (60%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/log/service/ThreadLocalLogTrace.java (92%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/scheduler/AbstractScheduler.java (95%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/scheduler/GameStatusScheduler.java (86%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/scheduler/MegaphoneScheduler.java (83%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/scheduler/TournamentScheduler.java (81%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/UserPrincipal.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/config/RestAuthenticationEntryPoint.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/config/SecurityConfig.java (89%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/config/properties/AppProperties.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/config/properties/CorsProperties.java (87%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/cookie/CookieUtil.java (95%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/handler/OAuthAuthenticationSuccessHandler.java (87%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/info/OAuthUserInfo.java (83%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/info/OAuthUserInfoFactory.java (71%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/info/ProviderType.java (89%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/info/impl/FortyTwoOAuthUserInfo.java (84%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/info/impl/KakaoOAuthUserInfo.java (86%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/jwt/repository/JwtRedisRepository.java (93%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/jwt/utils/AuthTokenProvider.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/jwt/utils/TokenAuthenticationFilter.java (93%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/jwt/utils/TokenHeaders.java (74%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/repository/OAuthAuthorizationRequestBasedOnCookieRepository.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/service/CustomOAuth2UserService.java (74%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/security/service/CustomUserDetailsService.java (75%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/ApplicationYmlRead.java (93%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/AsyncMailSender.java (93%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/EloRating.java (91%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/ExpLevelCalculator.java (97%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/FileDownloader.java (97%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/HeaderUtil.java (93%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/ImageResizingUtil.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/ItemImageHandler.java (95%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/JpegMultipartFile.java (96%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/UserImageHandler.java (95%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/argumentresolver/Login.java (82%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/argumentresolver/LoginMemberArgumentResolver.java (82%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/aws/AsyncNewItemImageUploader.java (86%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/aws/AsyncNewUserImageUploader.java (88%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/external/ApiUtil.java (97%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/querytracker/ApiQueryCounter.java (84%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/querytracker/ApiQueryCounterAop.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/querytracker/ApiQueryInspector.java (93%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/querytracker/ConnectionProxyHandler.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/querytracker/LoggingInterceptor.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-api/src/main/java/gg/pingpong/api}/global/utils/querytracker/PreparedStatementProxyHandler.java (95%) rename {src/main/java/com/gg/server/domain/game => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller}/GameController.java (82%) rename {src/main/java/com/gg/server/domain/game/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller}/request/GameListReqDto.java (73%) rename {src/main/java/com/gg/server/domain/game/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller}/request/NormalGameListReqDto.java (72%) rename {src/main/java/com/gg/server/domain/game/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller}/request/NormalResultReqDto.java (85%) rename {src/main/java/com/gg/server/domain/game/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller}/request/RankGameListReqDto.java (89%) rename {src/main/java/com/gg/server/domain/game/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller}/request/RankResultReqDto.java (94%) rename {src/main/java/com/gg/server/domain/game/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller}/request/TournamentResultReqDto.java (86%) rename {src/main/java/com/gg/server/domain/game/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response}/GameListResDto.java (93%) rename {src/main/java/com/gg/server/domain/game/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response}/GamePChangeResultResDto.java (91%) rename {src/main/java/com/gg/server/domain/game/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response}/GamePPPChangeResultResDto.java (88%) rename {src/main/java/com/gg/server/domain/game/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response}/GameResultResDto.java (92%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/game/dto/GameTeamInfo.java (87%) rename {src/main/java/com/gg/server/domain/team => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game}/dto/MatchTeamsInfoDto.java (91%) rename {src/main/java/com/gg/server/domain/team => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game}/dto/TeamInfo.java (90%) rename {src/main/java/com/gg/server/domain/team => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game}/dto/TeamReqDto.java (94%) rename {src/main/java/com/gg/server/domain/team => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game}/dto/TeamUserInfoDto.java (93%) rename {src/main/java/com/gg/server/domain/team => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game}/dto/TeamUserListDto.java (97%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/game/service/GameFindService.java (91%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/game/service/GameService.java (83%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/game/service/GameStatusService.java (78%) rename {src/main/java/com/gg/server/domain/pchange => gg-pingpong-api/src/main/java/gg/pingpong/api/user/game}/service/PChangeService.java (83%) rename {src/main/java/com/gg/server/domain/announcement => gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage}/controller/AnnouncementController.java (75%) rename {src/main/java/com/gg/server/domain/feedback => gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage}/controller/FeedbackController.java (74%) rename {src/main/java/com/gg/server/domain/feedback/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/request}/FeedbackRequestDto.java (84%) rename {src/main/java/com/gg/server/domain/announcement/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/response}/AnnouncementResponseDto.java (72%) rename {src/main/java/com/gg/server/domain/announcement => gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage}/dto/AnnouncementDto.java (77%) rename {src/main/java/com/gg/server/domain/penalty => gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage}/redis/PenaltyUserRedisRepository.java (86%) rename {src/main/java/com/gg/server/domain/announcement => gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage}/service/AnnouncementService.java (74%) rename {src/main/java/com/gg/server/domain/feedback => gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage}/service/FeedbackService.java (63%) rename {src/main/java/com/gg/server/domain/penalty => gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage}/service/PenaltyService.java (78%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/match/controller/MatchController.java (80%) rename {src/main/java/com/gg/server/domain/match/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/request}/MatchRequestDto.java (86%) rename {src/main/java/com/gg/server/domain/match/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/response}/MatchStatusResponseListDto.java (80%) rename {src/main/java/com/gg/server/domain/match/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/response}/SlotStatusResponseListDto.java (82%) create mode 100644 gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/GameAddDto.java rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/match/dto/MatchStatusDto.java (88%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/match/dto/SlotStatusDto.java (92%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/match/service/GameUpdateService.java (71%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/match/service/MatchFindService.java (74%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/match/service/MatchService.java (82%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/match/service/MatchTournamentService.java (86%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/match/utils/MatchCalculator.java (94%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/match/utils/SlotGenerator.java (86%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/noti/controller/NotiController.java (76%) create mode 100644 gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/request/NotiFindByUserRequestDto.java create mode 100644 gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response/NotiFindByUserResponseDto.java rename {src/main/java/com/gg/server/domain/noti/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response}/NotiListResponseDto.java (92%) rename {src/main/java/com/gg/server/domain/noti/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response}/NotiResponseDto.java (91%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/noti/dto/NotiDto.java (88%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/noti/dto/UserNotiDto.java (76%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/noti/service/NotiService.java (90%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/noti/service/SnsNotiService.java (84%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/noti/service/sns/NotiMailSender.java (86%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/noti/service/sns/SlackbotService.java (88%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/noti/service/sns/SlackbotUtils.java (89%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/rank/controller/RankController.java (78%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/rank/controller/RankV2Controller.java (80%) rename {src/main/java/com/gg/server/domain/rank/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/controller/response}/ExpRankPageResponseDto.java (77%) rename {src/main/java/com/gg/server/domain/rank/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/controller/response}/RankPageResponseDto.java (75%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/rank/dto/ExpRankDto.java (87%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/rank/dto/RankDto.java (85%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/rank/redis/RankRedisService.java (90%) rename {src/main/java/com/gg/server/domain/rank/service => gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis}/RedisUploadService.java (71%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/rank/service/RankFindService.java (57%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/rank/service/RankService.java (85%) rename {src/main/java/com/gg/server/domain/tier => gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank}/service/TierService.java (88%) rename {src/main/java/com/gg/server/domain/season => gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller}/SeasonController.java (73%) rename {src/main/java/com/gg/server/domain/season/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/response}/SeasonListResDto.java (82%) rename {src/main/java/com/gg/server/domain/season/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/response}/SeasonResDto.java (82%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/season/dto/CurSeason.java (86%) create mode 100644 gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonFindService.java rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/season/service/SeasonService.java (71%) rename {src/main/java/com/gg/server/domain/item => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store}/controller/ItemController.java (79%) rename {src/main/java/com/gg/server/domain/megaphone => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store}/controller/MegaphoneController.java (81%) rename {src/main/java/com/gg/server/domain/item/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/request}/ItemGiftRequestDto.java (78%) rename {src/main/java/com/gg/server/domain/megaphone/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/request}/MegaphoneUseRequestDto.java (89%) rename {src/main/java/com/gg/server/domain/item/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response}/ItemStoreListResponseDto.java (84%) rename {src/main/java/com/gg/server/domain/item/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response}/ItemStoreResponseDto.java (86%) rename {src/main/java/com/gg/server/domain/megaphone/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response}/MegaphoneDetailResponseDto.java (80%) rename {src/main/java/com/gg/server/domain/megaphone/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response}/MegaphoneTodayListResponseDto.java (79%) rename {src/main/java/com/gg/server/domain/item/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response}/UserItemListResponseDto.java (87%) rename {src/main/java/com/gg/server/domain/item/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response}/UserItemResponseDto.java (74%) rename {src/main/java/com/gg/server/domain/coin => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store}/dto/UserGameCoinResultDto.java (90%) rename {src/main/java/com/gg/server/domain/megaphone => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store}/redis/MegaphoneRedisRepository.java (90%) rename {src/main/java/com/gg/server/domain/coin => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store}/service/CoinHistoryService.java (85%) rename {src/main/java/com/gg/server/domain/item => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store}/service/ItemService.java (81%) rename {src/main/java/com/gg/server/domain/megaphone => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store}/service/MegaphoneService.java (79%) rename {src/main/java/com/gg/server/domain/coin => gg-pingpong-api/src/main/java/gg/pingpong/api/user/store}/service/UserCoinChangeService.java (81%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/tournament/controller/TournamentController.java (85%) rename {src/main/java/com/gg/server/domain/tournament/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/request}/TournamentFilterRequestDto.java (60%) rename {src/main/java/com/gg/server/domain/tournament/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response}/TournamentGameListResponseDto.java (90%) rename {src/main/java/com/gg/server/domain/tournament/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response}/TournamentGameResDto.java (77%) rename {src/main/java/com/gg/server/domain/tournament/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response}/TournamentListResponseDto.java (89%) rename {src/main/java/com/gg/server/domain/tournament/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response}/TournamentResponseDto.java (84%) rename {src/main/java/com/gg/server/domain/tournament/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response}/TournamentUserListResponseDto.java (85%) rename {src/main/java/com/gg/server/domain/tournament/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response}/TournamentUserRegistrationResponseDto.java (68%) rename {src/main/java/com/gg/server/domain/tournament/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response}/TournamentUserResponseDto.java (85%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/tournament/service/TournamentService.java (84%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/user/controller/UserController.java (77%) rename {src/main/java/com/gg/server/domain/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/request}/UserModifyRequestDto.java (69%) rename {src/main/java/com/gg/server/domain/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/request}/UserProfileImageRequestDto.java (82%) rename {src/main/java/com/gg/server/domain/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response}/CoinHistoryResponseDto.java (81%) rename {src/main/java/com/gg/server/domain/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response}/UserAttendanceResponseDto.java (82%) rename {src/main/java/com/gg/server/domain/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response}/UserCoinHistoryListResponseDto.java (83%) rename {src/main/java/com/gg/server/domain/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response}/UserCoinResponseDto.java (79%) rename {src/main/java/com/gg/server/domain/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response}/UserDetailResponseDto.java (81%) rename {src/main/java/com/gg/server/domain/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response}/UserHistoryResponseDto.java (69%) rename {src/main/java/com/gg/server/domain/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response}/UserImageResponseDto.java (68%) rename {src/main/java/com/gg/server/domain/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response}/UserLiveResponseDto.java (77%) rename {src/main/java/com/gg/server/domain/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response}/UserNormalDetailResponseDto.java (80%) rename {src/main/java/com/gg/server/domain/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response}/UserRankResponseDto.java (87%) rename {src/main/java/com/gg/server/domain/user/dto => gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response}/UserSearchResponseDto.java (80%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/user/dto/UserAccessTokenDto.java (79%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/user/dto/UserBackgroundDto.java (86%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/user/dto/UserDto.java (83%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/user/dto/UserEdgeDto.java (86%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/user/dto/UserHistoryData.java (79%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/user/dto/UserImageDto.java (82%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/user/dto/UserOauthDto.java (78%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/user/dto/UserTextColorDto.java (87%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/user/service/UserAuthenticationService.java (74%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/user/service/UserCoinService.java (71%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/user/service/UserFindService.java (68%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/user/service/UserService.java (80%) rename {src/main/java/com/gg/server/domain => gg-pingpong-api/src/main/java/gg/pingpong/api/user}/user/service/UserTextColorCheckService.java (93%) rename {src => gg-pingpong-api/src}/main/resources/db/migration/V1.1__migration_42gg_5th.sql (100%) rename {src => gg-pingpong-api/src}/main/resources/db/migration/V1.2__update_tournament_content_column.sql (100%) rename {src => gg-pingpong-api/src}/main/resources/db/migration/V1__init.sql (100%) rename {src => gg-pingpong-api/src}/main/resources/logback-spring.xml (94%) rename src/test/java/com/gg/server/ServerApplicationTests.java => gg-pingpong-api/src/test/java/gg/pingpong/api/ServerPingpongApiApplicationTests.java (76%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/announcement/controller/AnnouncementAdminControllerFailTest.java (89%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/announcement/controller/AnnouncementAdminControllerTest.java (90%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java (76%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/announcement/service/AnnouncementAdminServiceUnitTest.java (89%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/coin/controller/CoinAdminControllerTest.java (85%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/coin/controller/CoinPolicyAdminControllerFailTest.java (84%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/coin/controller/CoinPolicyAdminControllerTest.java (85%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/coin/service/CoinAdminServiceTest.java (77%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/feedback/controller/FeedbackAdminControllerTest.java (89%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/feedback/controller/FeedbackAdminControllerUnitTest.java (81%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/feedback/service/FeedbackAdminServiceUnitTest.java (89%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/game/controller/GameAdminControllerTest.java (90%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/item/controller/ItemAdminControllerTest.java (87%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/item/service/ItemAdminServiceUnitTest.java (81%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/megaphone/controller/MegaphoneAdminControllerTest.java (86%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java (88%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/noti/controller/NotiAdminControllerTest.java (88%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/noti/service/NotiAdminServiceUnitTest.java (80%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/penalty/controller/PenaltyAdminControllerTest.java (94%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/receipt/controller/ReceiptAdminControllerTest.java (87%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/receipt/service/ReceiptAdminServiceUnitTest.java (85%) rename {src/test/java/com/gg/server/admin/season => gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/controller}/SeasonAdminControllerTest.java (86%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/season/service/SeasonAdminServiceUnitTest.java (93%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/slotmanagement/controller/SlotAdminControllerFailTest.java (91%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/slotmanagement/controller/SlotAdminControllerTest.java (91%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/slotmanagement/service/SlotAdminServiceUnitTest.java (90%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/tournament/controller/TournamentAdminControllerTest.java (95%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/tournament/controller/TournamentAdminUserControllerTest.java (86%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/tournament/service/TournamentAdminServiceTest.java (93%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/admin/user/controller/UserAdminControllerTest.java (91%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/data/game/GameUnitTest.java (91%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/data/game/PChangeDataTest.java (85%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/data/game/TeamUnitTest.java (92%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/data/game/TournamentGameUnitTest.java (72%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/data/game/TournamentUserUnitTest.java (81%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/data/manage/AnnouncementUnitTest.java (82%) rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/data/store/ItemUnitTest.java (84%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/announcement/controller/AnnouncementControllerTest.java (83%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/announcement/controller/AnnouncementControllerUnitTest.java (75%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/announcement/service/AnnouncementServiceUnitTest.java (86%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/coin/service/CoinHistoryServiceTest.java (90%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/coin/service/UserCoinChangeServiceTest.java (81%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/feedback/controller/FeedbackControllerTest.java (83%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/feedback/controller/FeedbackControllerUnitTest.java (70%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/feedback/service/FeedbackServiceUnitTest.java (77%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/game/GameControllerTest.java (93%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/game/service/GameDBTest.java (78%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/game/service/GameFindServiceTest.java (71%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/game/service/GameServiceTest.java (67%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/game/service/GameStatusServiceTest.java (73%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/item/controller/ItemGiftControllerTest.java (83%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/item/controller/ItemPurchaseControllerTest.java (84%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/item/controller/ItemStoreListControllerTest.java (87%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/item/controller/UserItemResponseControllerTest.java (87%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/item/service/ItemServiceUnitTest.java (91%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/match/dto/MatchStatusDtoUnitTest.java (93%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/match/service/MatchBothServiceTest.java (82%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/match/service/MatchFindServiceUnitTest.java (84%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/match/service/MatchServiceTest.java (90%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/match/service/MatchTournamentServiceTest.java (91%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/match/service/MatchTournamentServiceUnitTest.java (88%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/match/utils/GameTestUtils.java (65%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/match/utils/MatchIntegrationTestUtils.java (85%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/match/utils/TournamentGameTestUtils.java (86%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/match/utils/TournamentTestUtils.java (77%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/match/utils/UserTestUtils.java (75%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/megaphone/controller/MegaphoneControllerTest.java (83%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/megaphone/service/MegaphoneServiceUnitTest.java (90%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/noti/controller/NotiControllerTest.java (85%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/noti/service/NotiServiceTest.java (81%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/noti/service/NotiServiceUnitTest.java (93%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/noti/service/SnsNotiServiceUnitTest.java (87%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/noti/service/sns/NotiMailSenderUnitTest.java (82%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/pchange/service/PChangeServiceTest.java (85%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/rank/controller/RankControllerTest.java (88%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/rank/controller/RankV2ControllerTest.java (79%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/rank/redis/RankRedisRepositoryTest.java (96%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/rank/redis/RedisTestService.java (94%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/rank/redis/RedisTransactionTest.java (94%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/rank/service/RankServiceTest.java (86%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/season/SeasonTestController.java (73%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/season/SeasonTriggerTest.java (86%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/season/service/SeasonServiceUnitTest.java (85%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/tier/service/TierServiceUnitTest.java (93%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/tournament/controller/TournamentControllerMvcTest.java (88%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/tournament/controller/TournamentFindControllerTest.java (95%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/tournament/controller/TournamentGameControllerTest.java (77%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/tournament/controller/TournamentSchedulerTest.java (82%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/tournament/service/TournamentServiceUnitTest.java (91%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/user/controller/UserControllerTest.java (88%) rename {src/test/java/com/gg/server/domain => gg-pingpong-api/src/test/java/gg/pingpong/api/user}/user/service/UserAuthenticationServiceUnitTest.java (84%) create mode 100644 gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserFindServiceUnitTest.java rename {src/test/java/com/gg/server => gg-pingpong-api/src/test/java/gg/pingpong/api}/utils/ReflectionUtilsForUnitTest.java (81%) rename {src => gg-pingpong-api/src}/test/resources/application.yml (100%) create mode 100644 gg-pingpong-data/build.gradle rename {src/main/java/com/gg/server/global/utils => gg-pingpong-data/src/main/java/gg/pingpong/data}/BaseTimeEntity.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/game/Game.java (83%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/game/PChange.java (92%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/game/Team.java (92%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/game/TeamUser.java (86%) create mode 100644 gg-pingpong-data/src/main/java/gg/pingpong/data/game/type/Mode.java rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/game/type/StatusType.java (95%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/manage/Announcement.java (79%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/manage/Feedback.java (87%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/manage/Penalty.java (89%) rename {src/main/java/com/gg/server/domain/slotmanagement => gg-pingpong-data/src/main/java/gg/pingpong/data/manage}/SlotManagement.java (75%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/manage/redis/RedisPenaltyUser.java (96%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/manage/type/FeedbackType.java (94%) rename {src/main/java/com/gg/server/admin/penalty => gg-pingpong-data/src/main/java/gg/pingpong/data/manage}/type/PenaltyKey.java (81%) rename {src/main/java/com/gg/server/domain/penalty => gg-pingpong-data/src/main/java/gg/pingpong/data/manage}/type/PenaltyType.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/match/RedisMatchTime.java (92%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/match/RedisMatchUser.java (87%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/match/type/MatchKey.java (93%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/match/type/Option.java (87%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/match/type/SlotStatus.java (93%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/match/type/TournamentMatchStatus.java (91%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/noti/Noti.java (89%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/noti/type/NotiType.java (97%) rename {src/main/java/com/gg/server/data/game => gg-pingpong-data/src/main/java/gg/pingpong/data/rank}/Rank.java (83%) rename {src/main/java/com/gg/server/data/game => gg-pingpong-data/src/main/java/gg/pingpong/data/rank}/Tier.java (95%) rename {src/main/java/com/gg/server/data/game => gg-pingpong-data/src/main/java/gg/pingpong/data/rank}/redis/RankRedis.java (86%) rename {src/main/java/com/gg/server/data/game => gg-pingpong-data/src/main/java/gg/pingpong/data/season}/Season.java (78%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/store/CoinHistory.java (93%) rename {src/main/java/com/gg/server/data/manage => gg-pingpong-data/src/main/java/gg/pingpong/data/store}/CoinPolicy.java (80%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/store/Item.java (78%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/store/Megaphone.java (94%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/store/Receipt.java (95%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/store/redis/MegaphoneRedis.java (95%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/store/type/HistoryType.java (87%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/store/type/ItemStatus.java (87%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/store/type/ItemType.java (79%) rename {src/main/java/com/gg/server/data/game => gg-pingpong-data/src/main/java/gg/pingpong/data/tournament}/Tournament.java (92%) rename {src/main/java/com/gg/server/data/game => gg-pingpong-data/src/main/java/gg/pingpong/data/tournament}/TournamentGame.java (90%) rename {src/main/java/com/gg/server/data/game => gg-pingpong-data/src/main/java/gg/pingpong/data/tournament}/TournamentUser.java (93%) rename {src/main/java/com/gg/server/data/game => gg-pingpong-data/src/main/java/gg/pingpong/data/tournament}/type/RoundNumber.java (85%) rename {src/main/java/com/gg/server/data/game => gg-pingpong-data/src/main/java/gg/pingpong/data/tournament}/type/TournamentRound.java (93%) rename {src/main/java/com/gg/server/data/game => gg-pingpong-data/src/main/java/gg/pingpong/data/tournament}/type/TournamentStatus.java (94%) rename {src/main/java/com/gg/server/data/game => gg-pingpong-data/src/main/java/gg/pingpong/data/tournament}/type/TournamentType.java (94%) rename {src/main/java/com/gg/server/data/game => gg-pingpong-data/src/main/java/gg/pingpong/data/tournament}/type/TournamentUserStatus.java (88%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/user/User.java (81%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/user/UserImage.java (97%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/user/type/BackgroundType.java (96%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/user/type/EdgeType.java (96%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/user/type/OauthType.java (95%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/user/type/RacketType.java (93%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/user/type/RoleType.java (92%) rename {src/main/java/com/gg/server => gg-pingpong-data/src/main/java/gg/pingpong}/data/user/type/SnsType.java (92%) rename {src/test/java/com/gg/server/data/game => gg-pingpong-data/src/test/java/gg/pingpong/data/tournament}/TournamentUnitTest.java (97%) create mode 100644 gg-pingpong-repo/build.gradle rename {src/main/java/com/gg/server/domain/game/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/game}/GameRepository.java (95%) rename {src/main/java/com/gg/server/domain/game/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/game}/GameRepositoryCustom.java (61%) rename {src/main/java/com/gg/server/domain/game/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/game}/GameRepositoryImpl.java (87%) rename {src/main/java/com/gg/server/domain/pchange/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/game}/PChangeRepository.java (90%) rename {src/main/java/com/gg/server/domain/pchange/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/game}/PChangeRepositoryCustom.java (76%) rename {src/main/java/com/gg/server/domain/pchange/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/game}/PChangeRepositoryImpl.java (95%) rename {src/main/java/com/gg/server/domain/team/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/game}/TeamRepository.java (83%) rename {src/main/java/com/gg/server/domain/team/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/game}/TeamUserRepository.java (91%) create mode 100644 gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameTeamUser.java rename {src/main/java/com/gg/server/domain/game/dto => gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out}/GameTeamUserInfo.java (69%) rename {src/main/java/com/gg/server/domain/team/dto => gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out}/GameUser.java (62%) rename {src/main/java/com/gg/server/domain/announcement/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage}/AnnouncementRepository.java (70%) rename {src/main/java/com/gg/server/domain/feedback/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage}/FeedbackRepository.java (67%) rename {src/main/java/com/gg/server/domain/penalty/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage}/PenaltyRepository.java (62%) rename {src/main/java/com/gg/server/domain/slotmanagement/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage}/SlotManagementRepository.java (87%) rename {src/main/java/com/gg/server/domain/match/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/match}/RedisMatchTimeRepository.java (93%) rename {src/main/java/com/gg/server/domain/match/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/match}/RedisMatchUserRepository.java (88%) rename {src/main/java/com/gg/server/domain/noti/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti}/NotiRepository.java (78%) rename {src/main/java/com/gg/server/domain/noti/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti}/NotiRepositoryCustom.java (68%) rename {src/main/java/com/gg/server/domain/noti/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti}/NotiRepositoryImpl.java (92%) rename {src/main/java/com/gg/server/domain/rank/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank}/RankRepository.java (96%) rename {src/main/java/com/gg/server/domain/rank/dto => gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank}/RankV2Dto.java (82%) rename {src/main/java/com/gg/server/domain/tier/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank}/TierRepository.java (82%) rename {src/main/java/com/gg/server/domain => gg-pingpong-repo/src/main/java/gg/pingpong/repo}/rank/redis/RankRedisRepository.java (97%) rename {src/main/java/com/gg/server/domain/season/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/season}/SeasonRepository.java (92%) rename {src/main/java/com/gg/server/domain/coin/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/store}/CoinHistoryRepository.java (89%) rename {src/main/java/com/gg/server/domain/coin/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/store}/CoinPolicyRepository.java (73%) rename {src/main/java/com/gg/server/domain/item/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/store}/ItemRepository.java (81%) rename {src/main/java/com/gg/server/domain/megaphone/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/store}/MegaphoneRepository.java (69%) rename {src/main/java/com/gg/server/domain/receipt/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/store}/ReceiptRepository.java (62%) rename {src/main/java/com/gg/server/domain/item/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/store}/UserItemRepository.java (88%) rename {src/main/java/com/gg/server/domain/tournament/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment}/TournamentGameRepository.java (78%) rename {src/main/java/com/gg/server/domain/tournament/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment}/TournamentRepository.java (87%) rename {src/main/java/com/gg/server/domain/tournament/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment}/TournamentUserRepository.java (78%) rename {src/main/java/com/gg/server/domain/rank/dto => gg-pingpong-repo/src/main/java/gg/pingpong/repo/user}/ExpRankV2Dto.java (82%) rename {src/main/java/com/gg/server/domain/user/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/user}/UserImageRepository.java (67%) rename {src/main/java/com/gg/server/domain/user/data => gg-pingpong-repo/src/main/java/gg/pingpong/repo/user}/UserRepository.java (94%) create mode 100644 gg-pingpong-utils/build.gradle rename {src/main/java/com/gg/server/domain/rank/redis => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/RedisKeyManager.java (92%) rename {src/main/java/com/gg/server/global/utils => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception}/BusinessChecker.java (86%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/ErrorCode.java (99%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/ErrorResponse.java (88%) rename {src/main/java/com/gg/server/domain/announcement/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/announcement}/AnnounceDupException.java (52%) rename {src/main/java/com/gg/server/domain/announcement/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/announcement}/AnnounceNotFoundException.java (53%) rename {src/main/java/com/gg/server/domain/coin/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/coin}/CoinHistoryNotFoundException.java (56%) rename {src/main/java/com/gg/server/domain/coin/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/coin}/CoinPolicyNotFoundException.java (55%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/custom/AuthenticationException.java (68%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/custom/BusinessException.java (73%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/custom/CustomRuntimeException.java (80%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/custom/DBConsistencyException.java (67%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/custom/DuplicationException.java (64%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/custom/ExpiredException.java (62%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/custom/FileException.java (62%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/custom/ForbiddenException.java (63%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/custom/InvalidParameterException.java (65%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/custom/NotExistException.java (67%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/custom/PageNotFoundException.java (74%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/custom/ParseException.java (62%) rename {src/main/java/com/gg/server/global => gg-pingpong-utils/src/main/java/gg/pingpong/utils}/exception/custom/SendException.java (62%) rename {src/main/java/com/gg/server/domain/feedback/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/feedback}/FeedbackNotFoundException.java (54%) rename {src/main/java/com/gg/server/domain/game/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game}/GameAlreadyExistException.java (56%) rename {src/main/java/com/gg/server/domain/game/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game}/GameDataConsistencyException.java (55%) rename {src/main/java/com/gg/server/domain/game/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game}/GameNotExistException.java (52%) rename {src/main/java/com/gg/server/domain/game/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game}/GameStatusNotMatchedException.java (55%) rename {src/main/java/com/gg/server/admin/game/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game}/NotRecentlyGameException.java (54%) rename {src/main/java/com/gg/server/domain/game/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game}/ScoreAlreadyEnteredException.java (53%) rename {src/main/java/com/gg/server/domain/game/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game}/ScoreNotInvalidException.java (54%) rename {src/main/java/com/gg/server/domain/game/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game}/ScoreNotMatchedException.java (54%) rename {src/main/java/com/gg/server/domain/item/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item}/InsufficientGgcoinException.java (54%) rename {src/main/java/com/gg/server/domain/item/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item}/ItemImageLargeException.java (53%) rename {src/main/java/com/gg/server/domain/item/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item}/ItemImageTypeException.java (55%) rename {src/main/java/com/gg/server/domain/item/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item}/ItemNotAvailableException.java (54%) rename {src/main/java/com/gg/server/admin/item/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item}/ItemNotFoundException.java (51%) rename {src/main/java/com/gg/server/domain/item/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item}/ItemNotPurchasableException.java (57%) rename {src/main/java/com/gg/server/domain/item/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item}/ItemTypeException.java (52%) rename {src/main/java/com/gg/server/domain/item/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item}/KakaoGiftException.java (55%) rename {src/main/java/com/gg/server/domain/item/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item}/KakaoPurchaseException.java (57%) rename {src/main/java/com/gg/server/domain/match/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match}/EnrolledSlotException.java (52%) rename {src/main/java/com/gg/server/domain/match/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match}/LosingTeamNotFoundException.java (56%) rename {src/main/java/com/gg/server/domain/match/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match}/OptionInvalidException.java (52%) rename {src/main/java/com/gg/server/domain/match/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match}/PastSlotException.java (54%) rename {src/main/java/com/gg/server/domain/match/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match}/PenaltyUserSlotException.java (58%) rename {src/main/java/com/gg/server/domain/match/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match}/SlotCountException.java (54%) rename {src/main/java/com/gg/server/domain/match/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match}/SlotNotFoundException.java (53%) rename {src/main/java/com/gg/server/domain/match/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match}/WinningTeamNotFoundException.java (56%) rename {src/main/java/com/gg/server/domain/megaphone/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone}/MegaphoneContentException.java (53%) rename {src/main/java/com/gg/server/domain/megaphone/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone}/MegaphoneNotFoundException.java (53%) rename {src/main/java/com/gg/server/domain/megaphone/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone}/MegaphoneTimeException.java (54%) rename {src/main/java/com/gg/server/domain/noti/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti}/SlackJsonParseException.java (54%) rename {src/main/java/com/gg/server/domain/noti/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti}/SlackSendException.java (50%) rename {src/main/java/com/gg/server/domain/noti/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti}/SlackUserGetFailedException.java (54%) rename {src/main/java/com/gg/server/admin/pchange/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/pchange}/PChangeNotExistException.java (54%) rename {src/main/java/com/gg/server/domain/penalty/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty}/PenaltyExpiredException.java (53%) rename {src/main/java/com/gg/server/domain/penalty/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty}/PenaltyNotFoundException.java (53%) rename {src/main/java/com/gg/server/domain/penalty/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty}/RedisPenaltyUserNotFoundException.java (58%) rename {src/main/java/com/gg/server/domain/rank/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank}/RankNotFoundException.java (54%) rename {src/main/java/com/gg/server/domain/rank/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank}/RankUpdateException.java (52%) rename {src/main/java/com/gg/server/domain/rank/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank}/RedisDataNotFoundException.java (55%) rename {src/main/java/com/gg/server/domain/receipt/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt}/ItemStatusException.java (53%) rename {src/main/java/com/gg/server/domain/receipt/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt}/ReceiptNotFoundException.java (53%) rename {src/main/java/com/gg/server/domain/receipt/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt}/ReceiptNotOwnerException.java (54%) rename {src/main/java/com/gg/server/domain/season/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season}/SeasonForbiddenException.java (54%) rename {src/main/java/com/gg/server/domain/season/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season}/SeasonNotFoundException.java (62%) rename {src/main/java/com/gg/server/domain/season/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season}/SeasonTimeBeforeException.java (54%) rename {src/main/java/com/gg/server/domain/slotmanagement/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/slotmanagement}/SlotManagementForbiddenException.java (56%) rename {src/main/java/com/gg/server/domain/slotmanagement/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/slotmanagement}/SlotManagementNotFoundException.java (56%) rename {src/main/java/com/gg/server/domain/team/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/team}/TeamIdNotMatchException.java (54%) rename {src/main/java/com/gg/server/domain/team/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/team}/TeamNotFoundException.java (53%) rename {src/main/java/com/gg/server/domain/tier/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tier}/TierNotFoundException.java (54%) rename {src/main/java/com/gg/server/domain/tournament/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament}/TournamentConflictException.java (64%) rename {src/main/java/com/gg/server/domain/tournament/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament}/TournamentGameNotFoundException.java (57%) rename {src/main/java/com/gg/server/domain/tournament/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament}/TournamentNotFoundException.java (65%) rename {src/main/java/com/gg/server/domain/tournament/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament}/TournamentUpdateException.java (65%) rename {src/main/java/com/gg/server/domain/user/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user}/KakaoOauth2AlreadyExistException.java (55%) rename {src/main/java/com/gg/server/domain/user/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user}/KakaoOauth2NotFoundException.java (54%) rename {src/main/java/com/gg/server/domain/user/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user}/TokenNotValidException.java (50%) rename {src/main/java/com/gg/server/domain/user/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user}/UserAlreadyAttendanceException.java (56%) rename {src/main/java/com/gg/server/domain/user/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user}/UserImageLargeException.java (53%) rename {src/main/java/com/gg/server/domain/user/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user}/UserImageNullException.java (53%) rename {src/main/java/com/gg/server/domain/user/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user}/UserImageTypeException.java (55%) rename {src/main/java/com/gg/server/domain/user/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user}/UserNotFoundException.java (52%) rename {src/main/java/com/gg/server/domain/user/exception => gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user}/UserTextColorException.java (54%) rename {src/test/java/com/gg/server => gg-pingpong-utils/src/testFixtures/java/gg/pingpong}/utils/ItemTestUtils.java (67%) rename {src/test/java/com/gg/server => gg-pingpong-utils/src/testFixtures/java/gg/pingpong}/utils/TestDataUtils.java (89%) rename {src/test/java/com/gg/server => gg-pingpong-utils/src/testFixtures/java/gg/pingpong}/utils/annotation/DataJpaUnitTest.java (92%) rename {src/test/java/com/gg/server => gg-pingpong-utils/src/testFixtures/java/gg/pingpong}/utils/annotation/IntegrationTest.java (81%) rename {src/test/java/com/gg/server => gg-pingpong-utils/src/testFixtures/java/gg/pingpong}/utils/annotation/IntegrationTestAspect.java (85%) rename {src/test/java/com/gg/server => gg-pingpong-utils/src/testFixtures/java/gg/pingpong}/utils/annotation/IntegrationTestWithRedisTransaction.java (84%) rename {src/test/java/com/gg/server => gg-pingpong-utils/src/testFixtures/java/gg/pingpong}/utils/annotation/TestTypeConstant.java (89%) rename {src/test/java/com/gg/server => gg-pingpong-utils/src/testFixtures/java/gg/pingpong}/utils/annotation/UnitTest.java (92%) rename {src/test/java/com/gg/server => gg-pingpong-utils/src/testFixtures/java/gg/pingpong}/utils/annotation/WebMvcUnitTest.java (92%) rename {src/test/java/com/gg/server => gg-pingpong-utils/src/testFixtures/java/gg/pingpong}/utils/config/MySQLInitializer.java (97%) rename {src/test/java/com/gg/server => gg-pingpong-utils/src/testFixtures/java/gg/pingpong}/utils/config/RedisInitializer.java (96%) rename {src/test/java/com/gg/server => gg-pingpong-utils/src/testFixtures/java/gg/pingpong}/utils/config/TestRedisConfig.java (97%) rename {src/test/java/com/gg/server/domain/user/controller => gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils}/dto/GameInfoDto.java (82%) delete mode 100644 src/main/java/com/gg/server/Application.java delete mode 100644 src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java delete mode 100644 src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java delete mode 100644 src/main/java/com/gg/server/data/game/type/Mode.java delete mode 100644 src/main/java/com/gg/server/domain/item/exception/ItemNotFoundException.java delete mode 100644 src/main/java/com/gg/server/domain/match/dto/GameAddDto.java delete mode 100644 src/main/java/com/gg/server/domain/noti/dto/NotiFindByUserRequestDto.java delete mode 100644 src/main/java/com/gg/server/domain/noti/dto/NotiFindByUserResponseDto.java delete mode 100644 src/main/java/com/gg/server/domain/pchange/exception/PChangeNotExistException.java delete mode 100644 src/main/java/com/gg/server/domain/season/service/SeasonFindService.java delete mode 100644 src/test/java/com/gg/server/admin/penalty/service/PenaltyAdminServiceTest.java delete mode 100644 src/test/java/com/gg/server/data/manage/PenaltyTest.java delete mode 100644 src/test/java/com/gg/server/domain/penalty/service/PenaltyServiceTest.java delete mode 100644 src/test/java/com/gg/server/domain/user/service/UserFindServiceUnitTest.java diff --git a/.github/workflows/test-code-validation.yml b/.github/workflows/test-code-validation.yml index 20862e44d..36fb0c0fb 100644 --- a/.github/workflows/test-code-validation.yml +++ b/.github/workflows/test-code-validation.yml @@ -15,29 +15,35 @@ jobs: java-version: 11 - name: Grant execute permission for gradlew run: chmod +x gradlew + - name: ️👶 Unit Test with Gradle - run: ./gradlew --console verbose clean unitTestCoverage - - name: mv for separate report folder - run: mv ./build/reports/jacoco/test ./build/reports/jacoco/unitTest - - name: mv for separate report name - run: mv ./build/reports/jacoco/unitTest/jacocoTestReport.xml ./build/reports/jacoco/unitTest/unitTestReport.xml + run: ./gradlew --console verbose clean unitTestCoverage unitTestCoverageReport -x test + + # - name: mv for separate report folder + # run: mv ./gg-pingpong-utils/build/reports/jacoco/unitTestCoverageReport ./build/reports/jacoco/unitTest + + # - name: mv for separate report name + # run: mv ./build/reports/jacoco/unitTest/jacocoTestReport.xml ./build/reports/jacoco/unitTest/unitTestReport.xml + - name: 📲 Upload unitTest coverage to Codecov uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true - files: ./build/reports/jacoco/unitTest/unitTestReport.xml + files: ./gg-pingpong-utils/build/reports/jacoco/unitTestCoverageReport/unitTestCoverageReport.xml flags: unitTest name: codecov-unit verbose: true + - name: 👨‍👨‍👧‍👦 Integration Test with Gradle - run: ./gradlew --console verbose clean integrationTestCoverage + run: ./gradlew --console verbose clean integrationTestCoverage integrationTestCoverageReport -x test + - name: 📲 Upload integrationTest coverage to Codecov uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true - files: ./build/reports/jacoco/test/jacocoTestReport.xml + files: ./gg-pingpong-utils/build/reports/jacoco/integrationTestCoverageReport/integrationTestCoverageReport.xml flags: integrationTest name: codecov-integration verbose: true diff --git a/.gitignore b/.gitignore index 509fcea84..443c346ca 100644 --- a/.gitignore +++ b/.gitignore @@ -4,13 +4,8 @@ build/ !gradle/wrapper/gradle-wrapper.jar !**/src/main/**/build/ !**/src/test/**/build/ -src/main/resources/application.yml -src/main/resources/application-local.yml -src/main/resources/application-main.yml -src/main/resources/application-test.yml +gg-pingpong-api/src/main/resources/application.yml .DS_Store -src/test/resources/application.yml -src/test/resources/application-local.yml python /logs @@ -54,4 +49,4 @@ pingping.pem ./logs/* ### git commit message convention file ### -.gitmessage.txt \ No newline at end of file +.gitmessage.txt diff --git a/Dockerfile b/Dockerfile index c5fcce172..c3ec4961c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM openjdk:11-jdk WORKDIR /app -ARG JAR_FILE=build/libs/server-42gg.jar +ARG JAR_FILE=gg-pingpong-api/build/libs/gg-pingpong-api-42gg.jar COPY ${JAR_FILE} . diff --git a/build.gradle b/build.gradle index e91a7ac69..6991e8f20 100644 --- a/build.gradle +++ b/build.gradle @@ -12,16 +12,8 @@ editorconfig { excludes = ['build'] } -checkstyle { - maxWarnings = 0 - configFile = file("${rootDir}/naver-checkstyle-rules.xml") - configProperties = ["suppressionFile": "${rootDir}/naver-checkstyle-suppressions.xml"] - toolVersion = "8.24" -} - - springBoot { - mainClass = "com.gg.server.Application" + mainClass = "gg.pingpong.api.PingPongApiApplication" } group = 'io.42pp' @@ -42,224 +34,248 @@ ext { set('snippetsDir', file("build/generated-snippets")) } -dependencies { - /* spring */ - implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-mail' - annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' - - /* database */ - runtimeOnly 'mysql:mysql-connector-java' - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' - - /* redis */ - implementation 'org.springframework.boot:spring-boot-starter-data-redis' - implementation 'org.springframework.session:spring-session-data-redis' - implementation 'org.redisson:redisson:3.17.3' - - /* oauth */ - implementation 'org.springframework.boot:spring-boot-starter-security' - implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' - - /* JSON Web Token */ - implementation 'io.jsonwebtoken:jjwt-api:0.11.2' - implementation 'io.jsonwebtoken:jjwt-impl:0.11.2' - implementation 'io.jsonwebtoken:jjwt-jackson:0.11.2' - - /* test */ - testImplementation 'org.springframework.boot:spring-boot-starter-test' - testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' - - /* lombok */ - implementation 'org.projectlombok:lombok:1.18.26' - annotationProcessor 'org.projectlombok:lombok' - compileOnly 'org.projectlombok:lombok' - - /* SHA256 */ - implementation 'com.google.guava:guava:31.0.1-jre' - - /* When..? Error */ - implementation 'org.apache.commons:commons-lang3:3.12.0' +subprojects { + apply plugin: 'java' + apply plugin: 'org.springframework.boot' + apply plugin: 'io.spring.dependency-management' + apply plugin: 'jacoco' + apply plugin: 'checkstyle' + + checkstyle { + maxWarnings = 0 + configFile = file("${rootDir}/naver-checkstyle-rules.xml") + configProperties = ["suppressionFile": "${rootDir}/naver-checkstyle-suppressions.xml"] + toolVersion = "8.24" + } - /* REST template */ - implementation 'org.apache.httpcomponents:httpcore:4.4.15' - implementation 'org.apache.httpcomponents:httpclient:4.5.13' + dependencies { + /* database */ + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' - /* S3 Image Bucket */ - implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' - implementation 'org.springframework:spring-test:5.3.20' - implementation "com.amazonaws:aws-java-sdk-s3:1.12.281" + /* redis */ + implementation 'org.springframework.boot:spring-boot-starter-data-redis' + implementation 'org.redisson:redisson:3.17.3' - testImplementation 'org.springframework.security:spring-security-test' + /* spring doc */ + implementation 'org.springdoc:springdoc-openapi-ui:1.6.6' - //test에서 lombok 사용 - testImplementation 'org.projectlombok:lombok' - testCompileOnly 'org.projectlombok:lombok' - testAnnotationProcessor 'org.projectlombok:lombok' + /* lombok */ + implementation 'org.projectlombok:lombok:1.18.26' + annotationProcessor 'org.projectlombok:lombok' + compileOnly 'org.projectlombok:lombok' - /* spring doc */ - implementation 'org.springdoc:springdoc-openapi-ui:1.6.6' + /* test */ + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' - /* flyway */ - implementation 'org.flywaydb:flyway-core' + //test에서 lombok 사용 + testImplementation 'org.projectlombok:lombok' + testCompileOnly 'org.projectlombok:lombok' + testAnnotationProcessor 'org.projectlombok:lombok' - /* elk-logstash */ - implementation 'net.logstash.logback:logstash-logback-encoder:6.3' + /* elk-logstash */ + implementation 'net.logstash.logback:logstash-logback-encoder:6.3' - //actuator 추가 - implementation 'org.springframework.boot:spring-boot-starter-actuator' + //actuator 추가 + implementation 'org.springframework.boot:spring-boot-starter-actuator' - //prometheus 추가 - implementation 'io.micrometer:micrometer-registry-prometheus' + //prometheus 추가 + implementation 'io.micrometer:micrometer-registry-prometheus' - //testcontainers 추가 - testImplementation "org.testcontainers:mysql:1.19.3" - testImplementation "com.redis:testcontainers-redis:2.0.1" - testImplementation "org.junit.jupiter:junit-jupiter:5.8.1" - testImplementation "org.testcontainers:testcontainers:1.19.3" - testImplementation "org.testcontainers:junit-jupiter:1.19.3" -} + //testcontainers 추가 + testImplementation "org.testcontainers:mysql:1.19.3" + testImplementation "com.redis:testcontainers-redis:2.0.1" + testImplementation "org.junit.jupiter:junit-jupiter:5.8.1" + testImplementation "org.testcontainers:testcontainers:1.19.3" + testImplementation "org.testcontainers:junit-jupiter:1.19.3" + } //테스트 커버리지 측정도구 -jacoco { - toolVersion = "0.8.8" -} + jacoco { + toolVersion = "0.8.8" + } // dto, 외부 연동 서비스는 테스트에서 제외 -def jacocoExcludes = [ - '*Application*', - "**/config/*", - "**/security/*", - "**/dto/*", - "**/aws/*", - "*NotiMailSender*", - '*SlackbotService*', -] + def jacocoExcludes = [ + '*Application*', + "**/config/*", + "**/security/*", + "**/dto/*", + "**/aws/*", + "*NotiMailSender*", + '*SlackbotService*', + ] //커버리지 리포트 생성 -jacocoTestReport { + jacocoTestReport { - reports { - xml.enabled true - html.enabled true - csv.enabled false - } + reports { + xml.enabled true + html.enabled true + csv.enabled false + } - afterEvaluate { - //dto 및 외부 연동 서비스는 테스트에서 제외 - classDirectories.setFrom(files(classDirectories.files.collect { - fileTree(dir: it, exclude: jacocoExcludes) - }) - ) + afterEvaluate { + //dto 및 외부 연동 서비스는 테스트에서 제외 + classDirectories.setFrom(files(classDirectories.files.collect { + fileTree(dir: it, exclude: jacocoExcludes) + }) + ) + } } -} // 커버리지 검증 설정 -jacocoTestCoverageVerification { - - violationRules { - rule { - enabled = true - element = 'CLASS' - - //브랜치 커버리지 - limit { - counter = 'BRANCH' - value = 'COVEREDRATIO' - minimum = 0.00 - } - - //메소드 커버리지 - limit { - counter = 'METHOD' - value = 'COVEREDRATIO' - minimum = 0.00 - } - - //라인 커버리지 - limit { - counter = 'LINE' - value = 'COVEREDRATIO' - minimum = 0.00 + jacocoTestCoverageVerification { + + violationRules { + rule { + enabled = true + element = 'CLASS' + + //브랜치 커버리지 + limit { + counter = 'BRANCH' + value = 'COVEREDRATIO' + minimum = 0.00 + } + + //메소드 커버리지 + limit { + counter = 'METHOD' + value = 'COVEREDRATIO' + minimum = 0.00 + } + + //라인 커버리지 + limit { + counter = 'LINE' + value = 'COVEREDRATIO' + minimum = 0.00 + } + + //검증에서 제외할 패키지, 클래스 + excludes = jacocoExcludes } - - //검증에서 제외할 패키지, 클래스 - excludes = jacocoExcludes } } -} //전체 테스트 -test { - description = 'Runs the total tests.' - useJUnitPlatform() -} + test { + description = 'Runs the total tests.' + useJUnitPlatform() + } //유닛 테스트 -task unitTest(type: Test) { - group = 'verification' - description = 'Runs the unit tests.' - useJUnitPlatform { - includeTags 'UnitTest' - excludeTags 'IntegrationTest' - } + task unitTest(type: Test) { + group = 'verification' + description = 'Runs the unit tests.' + useJUnitPlatform { + includeTags 'UnitTest' + excludeTags 'IntegrationTest' + } - jacoco { - destinationFile = file("$buildDir/jacoco/test.exec") - } + jacoco { + destinationFile = file("$buildDir/jacoco/test.exec") + } -} + } //통합 테스트 -task integrationTest(type: Test) { - group = 'verification' - description = 'Runs the integration tests.' - useJUnitPlatform { - includeTags 'IntegrationTest' - excludeTags 'UnitTest' - } + task integrationTest(type: Test) { + group = 'verification' + description = 'Runs the integration tests.' + useJUnitPlatform { + includeTags 'IntegrationTest' + excludeTags 'UnitTest' + } - jacoco { - destinationFile = file("$buildDir/jacoco/test.exec") + jacoco { + destinationFile = file("$buildDir/jacoco/test.exec") + } } -} //전체 테스트, 리포트 생성, 검증 -task totalTestCoverage(type: Test) { - group 'verification' - description 'Runs the total tests with coverage' + task totalTestCoverage(type: Test) { + group 'verification' + description 'Runs the total tests with coverage' - dependsOn(':test', - ':jacocoTestReport', - ':jacocoTestCoverageVerification') + dependsOn(project.tasks.findByName('test'), + project.tasks.findByName('jacocoTestReport'), + project.tasks.findByName('jacocoTestCoverageVerification')) - tasks['jacocoTestReport'].mustRunAfter(tasks['test']) - tasks['jacocoTestCoverageVerification'].mustRunAfter(tasks['jacocoTestReport']) -} + tasks['jacocoTestReport'].mustRunAfter(tasks['test']) + tasks['jacocoTestCoverageVerification'].mustRunAfter(tasks['jacocoTestReport']) + } //유닛 테스트, 리포트 생성, 검증 -task unitTestCoverage(type: Test) { - group 'verification' - description 'Runs the unit tests with coverage' + task unitTestCoverage(type: Test) { + group 'verification' + description 'Runs the unit tests with coverage' - dependsOn(':unitTest', - ':jacocoTestReport', - ':jacocoTestCoverageVerification') + dependsOn(project.tasks.findByName('unitTest'), + project.tasks.findByName('jacocoTestReport'), + project.tasks.findByName('jacocoTestCoverageVerification')) - tasks['jacocoTestReport'].mustRunAfter(tasks['unitTest']) - tasks['jacocoTestCoverageVerification'].mustRunAfter(tasks['jacocoTestReport']) -} + tasks['jacocoTestReport'].mustRunAfter(tasks['unitTest']) + tasks['jacocoTestCoverageVerification'].mustRunAfter(tasks['jacocoTestReport']) + } //통합 테스트, 리포트 생성, 검증 -task integrationTestCoverage(type: Test) { - group 'verification' - description 'Runs the integration tests with coverage' + task integrationTestCoverage(type: Test) { + group 'verification' + description 'Runs the integration tests with coverage' + + dependsOn(project.tasks.findByName('integrationTest'), + project.tasks.findByName('jacocoTestReport'), + project.tasks.findByName('jacocoTestCoverageVerification')) - dependsOn(':integrationTest', - ':jacocoTestReport', - ':jacocoTestCoverageVerification') + tasks['jacocoTestReport'].mustRunAfter(tasks['integrationTest']) + tasks['jacocoTestCoverageVerification'].mustRunAfter(tasks['jacocoTestReport']) + } - tasks['jacocoTestReport'].mustRunAfter(tasks['integrationTest']) - tasks['jacocoTestCoverageVerification'].mustRunAfter(tasks['jacocoTestReport']) } + +project(':gg-pingpong-api') { + bootJar { enabled = true } + jar { enabled = true } + dependencies { + implementation project(':gg-pingpong-data') + implementation project(':gg-pingpong-repo') + implementation project(':gg-pingpong-admin-repo') + implementation project(':gg-pingpong-utils') + } +} + +project(':gg-pingpong-repo') { + bootJar { enabled = false } + jar { enabled = true } + dependencies { + implementation project(':gg-pingpong-data') + implementation project(':gg-pingpong-utils') + } +} + +project(':gg-pingpong-admin-repo') { + bootJar { enabled = false } + jar { enabled = true } + dependencies { + implementation project(':gg-pingpong-data') + implementation project(':gg-pingpong-utils') + } +} + +project(':gg-pingpong-data') { + bootJar { enabled = false } + jar { enabled = true } + dependencies { + implementation project(':gg-pingpong-utils') + } +} + +project(':gg-pingpong-utils') { + bootJar { enabled = false } + jar { enabled = true } + dependencies { + } +} + diff --git a/codecov.yml b/codecov.yml index 253397514..1c5086536 100644 --- a/codecov.yml +++ b/codecov.yml @@ -12,7 +12,13 @@ coverage: flags: unitTest: paths: - - src/main/java/com/gg/server/ + - gg-pingpong-api/src/main/java/gg/pingpong/api + - gg-pingpong-repo/src/main/java/gg/pingpong/repo + - gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo + - gg-pingpong-data/src/main/java/gg/pingpong/data integrationTest: paths: - - src/main/java/com/gg/server/ \ No newline at end of file + - gg-pingpong-api/src/main/java/gg/pingpong/api + - gg-pingpong-repo/src/main/java/gg/pingpong/repo + - gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo + - gg-pingpong-data/src/main/java/gg/pingpong/data diff --git a/gg-pingpong-admin-repo/build.gradle b/gg-pingpong-admin-repo/build.gradle new file mode 100644 index 000000000..1674e3932 --- /dev/null +++ b/gg-pingpong-admin-repo/build.gradle @@ -0,0 +1,25 @@ +plugins { + id 'java' +} + +group 'gg.pingpong.admin.repo' +version '42gg' + +repositories { + mavenCentral() +} + +dependencies { + /* database */ + runtimeOnly 'mysql:mysql-connector-java' + /* flyway */ + implementation 'org.flywaydb:flyway-core' + + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' + testImplementation testFixtures(project(':gg-pingpong-utils')) +} + +test { + useJUnitPlatform() +} diff --git a/src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/GameAdminRepository.java similarity index 87% rename from src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/GameAdminRepository.java index 1c78b38c1..76fbd6b28 100644 --- a/src/main/java/com/gg/server/admin/game/data/GameAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/GameAdminRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.game.data; +package gg.pingpong.admin.repo.game; import java.util.List; import java.util.Optional; @@ -9,11 +9,11 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.domain.game.dto.GameTeamUser; +import gg.pingpong.admin.repo.game.out.GameTeamUser; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.season.Season; public interface GameAdminRepository extends JpaRepository { diff --git a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepository.java similarity index 68% rename from src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepository.java index 0be9061ef..e9a68edb4 100644 --- a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepository.java @@ -1,8 +1,8 @@ -package com.gg.server.admin.pchange.data; +package gg.pingpong.admin.repo.game; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.game.PChange; +import gg.pingpong.data.game.PChange; public interface PChangeAdminRepository extends JpaRepository, PChangeAdminRepositoryCustom { } diff --git a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustom.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepositoryCustom.java similarity index 59% rename from src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustom.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepositoryCustom.java index 3e298204b..ac3e7e9c1 100644 --- a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustom.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepositoryCustom.java @@ -1,8 +1,8 @@ -package com.gg.server.admin.pchange.data; +package gg.pingpong.admin.repo.game; import java.util.List; -import com.gg.server.data.game.PChange; +import gg.pingpong.data.game.PChange; public interface PChangeAdminRepositoryCustom { List findByTeamUser(Long userId); diff --git a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustomImpl.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepositoryCustomImpl.java similarity index 88% rename from src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustomImpl.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepositoryCustomImpl.java index 25c2dbe8d..1de405780 100644 --- a/src/main/java/com/gg/server/admin/pchange/data/PChangeAdminRepositoryCustomImpl.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepositoryCustomImpl.java @@ -1,12 +1,11 @@ -package com.gg.server.admin.pchange.data; +package gg.pingpong.admin.repo.game; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.LockModeType; -import com.gg.server.data.game.PChange; - +import gg.pingpong.data.game.PChange; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/main/java/com/gg/server/admin/team/data/TeamAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/TeamAdminRepository.java similarity index 64% rename from src/main/java/com/gg/server/admin/team/data/TeamAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/TeamAdminRepository.java index da251ac04..d4b7d97e7 100644 --- a/src/main/java/com/gg/server/admin/team/data/TeamAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/TeamAdminRepository.java @@ -1,11 +1,11 @@ -package com.gg.server.admin.team.data; +package gg.pingpong.admin.repo.game; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Team; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.Team; public interface TeamAdminRepository extends JpaRepository { List findAllByGame(Game game); diff --git a/src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/TeamUserAdminRepository.java similarity index 83% rename from src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/TeamUserAdminRepository.java index ab0a71d0a..def7afa33 100644 --- a/src/main/java/com/gg/server/admin/team/data/TeamUserAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/TeamUserAdminRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.team.data; +package gg.pingpong.admin.repo.game; import java.util.List; @@ -6,8 +6,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.user.User; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.user.User; public interface TeamUserAdminRepository extends JpaRepository { @Query("SELECT tu.user FROM TeamUser tu WHERE tu.team.id = :teamId") diff --git a/src/main/java/com/gg/server/domain/game/dto/GameTeamUser.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/out/GameTeamUser.java similarity index 81% rename from src/main/java/com/gg/server/domain/game/dto/GameTeamUser.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/out/GameTeamUser.java index b3fb75467..719d25d95 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GameTeamUser.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/out/GameTeamUser.java @@ -1,9 +1,9 @@ -package com.gg.server.domain.game.dto; +package gg.pingpong.admin.repo.game.out; import java.time.LocalDateTime; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; public interface GameTeamUser { Long getGameId(); diff --git a/src/main/java/com/gg/server/admin/slotmanagement/data/AdminSlotManagementsRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/AdminSlotManagementsRepository.java similarity index 87% rename from src/main/java/com/gg/server/admin/slotmanagement/data/AdminSlotManagementsRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/AdminSlotManagementsRepository.java index c029b281a..0666ea175 100644 --- a/src/main/java/com/gg/server/admin/slotmanagement/data/AdminSlotManagementsRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/AdminSlotManagementsRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.slotmanagement.data; +package gg.pingpong.admin.repo.manage; import java.time.LocalDateTime; import java.util.List; @@ -8,7 +8,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.domain.slotmanagement.SlotManagement; +import gg.pingpong.data.manage.SlotManagement; public interface AdminSlotManagementsRepository extends JpaRepository { @Query("select slot from SlotManagement slot " diff --git a/src/main/java/com/gg/server/admin/announcement/data/AnnouncementAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/AnnouncementAdminRepository.java similarity index 71% rename from src/main/java/com/gg/server/admin/announcement/data/AnnouncementAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/AnnouncementAdminRepository.java index 984eca2ba..19b94298f 100644 --- a/src/main/java/com/gg/server/admin/announcement/data/AnnouncementAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/AnnouncementAdminRepository.java @@ -1,10 +1,10 @@ -package com.gg.server.admin.announcement.data; +package gg.pingpong.admin.repo.manage; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.manage.Announcement; +import gg.pingpong.data.manage.Announcement; public interface AnnouncementAdminRepository extends JpaRepository { diff --git a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/FeedbackAdminRepository.java similarity index 85% rename from src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/FeedbackAdminRepository.java index d247b58d3..a10ba2b63 100644 --- a/src/main/java/com/gg/server/admin/feedback/data/FeedbackAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/FeedbackAdminRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.feedback.data; +package gg.pingpong.admin.repo.manage; import java.util.List; @@ -6,7 +6,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.manage.Feedback; +import gg.pingpong.data.manage.Feedback; public interface FeedbackAdminRepository extends JpaRepository { @Query(value = "select f from Feedback f join fetch f.user " diff --git a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepository.java similarity index 90% rename from src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepository.java index 49873c42a..7699c3666 100644 --- a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.penalty.data; +package gg.pingpong.admin.repo.manage; import java.time.LocalDateTime; import java.util.List; @@ -10,7 +10,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.manage.Penalty; +import gg.pingpong.data.manage.Penalty; public interface PenaltyAdminRepository extends JpaRepository, PenaltyAdminRepositoryCustom { @EntityGraph(attributePaths = {"user"}) diff --git a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustom.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepositoryCustom.java similarity index 83% rename from src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustom.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepositoryCustom.java index 11da5b328..4fb32696c 100644 --- a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustom.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepositoryCustom.java @@ -1,11 +1,11 @@ -package com.gg.server.admin.penalty.data; +package gg.pingpong.admin.repo.manage; import java.time.LocalDateTime; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import com.gg.server.data.manage.Penalty; +import gg.pingpong.data.manage.Penalty; public interface PenaltyAdminRepositoryCustom { Page findAllCurrent(Pageable pageable, LocalDateTime targetTime); diff --git a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustomImpl.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepositoryCustomImpl.java similarity index 97% rename from src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustomImpl.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepositoryCustomImpl.java index 22121bbc5..1056928fa 100644 --- a/src/main/java/com/gg/server/admin/penalty/data/PenaltyAdminRepositoryCustomImpl.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepositoryCustomImpl.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.penalty.data; +package gg.pingpong.admin.repo.manage; import java.time.LocalDateTime; import java.util.List; @@ -9,8 +9,7 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import com.gg.server.data.manage.Penalty; - +import gg.pingpong.data.manage.Penalty; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/main/java/com/gg/server/admin/penalty/data/PenaltyUserAdminRedisRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyUserAdminRedisRepository.java similarity index 93% rename from src/main/java/com/gg/server/admin/penalty/data/PenaltyUserAdminRedisRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyUserAdminRedisRepository.java index 0f6b08333..1edc3f96d 100644 --- a/src/main/java/com/gg/server/admin/penalty/data/PenaltyUserAdminRedisRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyUserAdminRedisRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.penalty.data; +package gg.pingpong.admin.repo.manage; import java.time.Duration; import java.time.LocalDateTime; @@ -11,9 +11,8 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; -import com.gg.server.admin.penalty.type.PenaltyKey; -import com.gg.server.data.manage.redis.RedisPenaltyUser; - +import gg.pingpong.data.manage.redis.RedisPenaltyUser; +import gg.pingpong.data.manage.type.PenaltyKey; import lombok.RequiredArgsConstructor; @Repository diff --git a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepository.java similarity index 84% rename from src/main/java/com/gg/server/admin/noti/data/NotiAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepository.java index 37619e5e8..b6581f917 100644 --- a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepository.java @@ -1,11 +1,11 @@ -package com.gg.server.admin.noti.data; +package gg.pingpong.admin.repo.noti; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.noti.Noti; +import gg.pingpong.data.noti.Noti; public interface NotiAdminRepository extends JpaRepository, NotiAdminRepositoryCustom { diff --git a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustom.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepositoryCustom.java similarity index 79% rename from src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustom.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepositoryCustom.java index be72cbda7..bfb54b43f 100644 --- a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustom.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepositoryCustom.java @@ -1,10 +1,10 @@ -package com.gg.server.admin.noti.data; +package gg.pingpong.admin.repo.noti; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.query.Param; -import com.gg.server.data.noti.Noti; +import gg.pingpong.data.noti.Noti; public interface NotiAdminRepositoryCustom { diff --git a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustomImpl.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepositoryCustomImpl.java similarity index 93% rename from src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustomImpl.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepositoryCustomImpl.java index 0184554e4..ce01adb85 100644 --- a/src/main/java/com/gg/server/admin/noti/data/NotiAdminRepositoryCustomImpl.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepositoryCustomImpl.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.noti.data; +package gg.pingpong.admin.repo.noti; import java.util.List; @@ -8,8 +8,7 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import com.gg.server.data.noti.Noti; - +import gg.pingpong.data.noti.Noti; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/season/SeasonAdminRepository.java similarity index 88% rename from src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/season/SeasonAdminRepository.java index 0fff1c5d4..b60655855 100644 --- a/src/main/java/com/gg/server/admin/season/data/SeasonAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/season/SeasonAdminRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.season.data; +package gg.pingpong.admin.repo.season; import java.time.LocalDateTime; import java.util.List; @@ -9,7 +9,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.game.Season; +import gg.pingpong.data.season.Season; public interface SeasonAdminRepository extends JpaRepository { /* 입력시간과 모드로 입력시간 이후 가장 가까운 시즌 가져오기 */ @@ -27,7 +27,8 @@ public interface SeasonAdminRepository extends JpaRepository { List findAllByOrderByStartTimeAsc(); @Modifying(clearAutomatically = true, flushAutomatically = true) - @Query(value = "UPDATE Season s SET s.seasonName = :seasonName, s.startTime = :startTime, " + @Query(value = "UPDATE Season s " + + "SET s.seasonName = :seasonName, s.startTime = :startTime, " + "s.startPpp = :startPpp, s.pppGap = :pppGap " + "WHERE s.id = :id") void updateReserveSeasonById(@Param("id") Long seasonId, @Param("seasonName") String seasonName, diff --git a/src/main/java/com/gg/server/admin/coin/data/CoinPolicyAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/CoinPolicyAdminRepository.java similarity index 73% rename from src/main/java/com/gg/server/admin/coin/data/CoinPolicyAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/CoinPolicyAdminRepository.java index ce2aab775..8374052d4 100644 --- a/src/main/java/com/gg/server/admin/coin/data/CoinPolicyAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/CoinPolicyAdminRepository.java @@ -1,10 +1,10 @@ -package com.gg.server.admin.coin.data; +package gg.pingpong.admin.repo.store; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.manage.CoinPolicy; +import gg.pingpong.data.store.CoinPolicy; public interface CoinPolicyAdminRepository extends JpaRepository { Optional findFirstByOrderByIdDesc(); diff --git a/src/main/java/com/gg/server/admin/item/data/ItemAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ItemAdminRepository.java similarity index 78% rename from src/main/java/com/gg/server/admin/item/data/ItemAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ItemAdminRepository.java index 39496ecf7..b937fb23a 100644 --- a/src/main/java/com/gg/server/admin/item/data/ItemAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ItemAdminRepository.java @@ -1,10 +1,10 @@ -package com.gg.server.admin.item.data; +package gg.pingpong.admin.repo.store; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.store.Item; +import gg.pingpong.data.store.Item; public interface ItemAdminRepository extends JpaRepository { Page findAll(Pageable pageable); diff --git a/src/main/java/com/gg/server/admin/megaphone/data/MegaphoneAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/MegaphoneAdminRepository.java similarity index 78% rename from src/main/java/com/gg/server/admin/megaphone/data/MegaphoneAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/MegaphoneAdminRepository.java index 113a801f4..1123e4991 100644 --- a/src/main/java/com/gg/server/admin/megaphone/data/MegaphoneAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/MegaphoneAdminRepository.java @@ -1,10 +1,10 @@ -package com.gg.server.admin.megaphone.data; +package gg.pingpong.admin.repo.store; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.store.Megaphone; +import gg.pingpong.data.store.Megaphone; public interface MegaphoneAdminRepository extends JpaRepository { Page findMegaphonesByUserIntraId(String intraId, Pageable pageable); diff --git a/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ReceiptAdminRepository.java similarity index 79% rename from src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ReceiptAdminRepository.java index 072208f6f..02c73cc7b 100644 --- a/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ReceiptAdminRepository.java @@ -1,10 +1,10 @@ -package com.gg.server.admin.receipt.data; +package gg.pingpong.admin.repo.store; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.store.Receipt; +import gg.pingpong.data.store.Receipt; public interface ReceiptAdminRepository extends JpaRepository, ReceiptAdminRepositorySearch { Page findAll(Pageable pageable); diff --git a/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepositorySearch.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ReceiptAdminRepositorySearch.java similarity index 84% rename from src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepositorySearch.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ReceiptAdminRepositorySearch.java index 8a837de74..552ca349d 100644 --- a/src/main/java/com/gg/server/admin/receipt/data/ReceiptAdminRepositorySearch.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ReceiptAdminRepositorySearch.java @@ -1,11 +1,11 @@ -package com.gg.server.admin.receipt.data; +package gg.pingpong.admin.repo.store; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.store.Receipt; +import gg.pingpong.data.store.Receipt; public interface ReceiptAdminRepositorySearch { @Query(value = "select re from Receipt re where re.purchaserIntraId = :intraId or re.ownerIntraId = :intraId") diff --git a/src/main/java/com/gg/server/admin/user/data/UserAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/user/UserAdminRepository.java similarity index 86% rename from src/main/java/com/gg/server/admin/user/data/UserAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/user/UserAdminRepository.java index cdd9f8eaf..601d910cb 100644 --- a/src/main/java/com/gg/server/admin/user/data/UserAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/user/UserAdminRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.user.data; +package gg.pingpong.admin.repo.user; import java.util.Optional; @@ -6,7 +6,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.user.User; +import gg.pingpong.data.user.User; public interface UserAdminRepository extends JpaRepository { Optional findByIntraId(String intraId); diff --git a/src/main/java/com/gg/server/admin/user/data/UserImageAdminRepository.java b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/user/UserImageAdminRepository.java similarity index 94% rename from src/main/java/com/gg/server/admin/user/data/UserImageAdminRepository.java rename to gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/user/UserImageAdminRepository.java index 3a523b7d1..34f17e6c3 100644 --- a/src/main/java/com/gg/server/admin/user/data/UserImageAdminRepository.java +++ b/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/user/UserImageAdminRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.user.data; +package gg.pingpong.admin.repo.user; import java.util.Optional; @@ -8,8 +8,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.user.User; -import com.gg.server.data.user.UserImage; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.UserImage; public interface UserImageAdminRepository extends JpaRepository { Optional findTopByUserAndIsCurrentIsTrueOrderByCreatedAtDesc(User user); diff --git a/gg-pingpong-api/build.gradle b/gg-pingpong-api/build.gradle new file mode 100644 index 000000000..d926ad787 --- /dev/null +++ b/gg-pingpong-api/build.gradle @@ -0,0 +1,53 @@ +plugins { + id 'java' +} + +group 'gg.pingpong.api' +version '42gg' + +repositories { + mavenCentral() +} + +dependencies { + /* spring */ + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-mail' + annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' + + implementation 'org.springframework.session:spring-session-data-redis' + + /* oauth */ + implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' + + /* JSON Web Token */ + implementation 'io.jsonwebtoken:jjwt-api:0.11.2' + implementation 'io.jsonwebtoken:jjwt-impl:0.11.2' + implementation 'io.jsonwebtoken:jjwt-jackson:0.11.2' + + /* StringUtils */ + implementation 'org.apache.commons:commons-lang3:3.12.0' + + /* REST template */ + implementation 'org.apache.httpcomponents:httpcore:4.4.15' + implementation 'org.apache.httpcomponents:httpclient:4.5.13' + /* HttpHeaders */ + implementation 'com.google.guava:guava:31.0.1-jre' + + /* S3 Image Bucket */ + implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' + implementation 'org.springframework:spring-test:5.3.20' + implementation "com.amazonaws:aws-java-sdk-s3:1.12.281" + + testImplementation 'org.springframework.security:spring-security-test' + + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' + testImplementation testFixtures(project(':gg-pingpong-utils')) +} + +test { + useJUnitPlatform() +} diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/PingpongApiApplication.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/PingpongApiApplication.java new file mode 100644 index 000000000..5ed8ac248 --- /dev/null +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/PingpongApiApplication.java @@ -0,0 +1,14 @@ +package gg.pingpong.api; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication(scanBasePackages = {"gg.pingpong.admin.repo", "gg.pingpong.data", "gg.pingpong.repo", + "gg.pingpong.api", "gg.pingpong.utils"}) +public class PingpongApiApplication { + + public static void main(String[] args) { + SpringApplication.run(PingpongApiApplication.class, args); + } + +} diff --git a/src/main/java/com/gg/server/admin/game/controller/GameAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/controller/GameAdminController.java similarity index 82% rename from src/main/java/com/gg/server/admin/game/controller/GameAdminController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/controller/GameAdminController.java index 21311a7e0..0beadf359 100644 --- a/src/main/java/com/gg/server/admin/game/controller/GameAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/controller/GameAdminController.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.game.controller; +package gg.pingpong.api.admin.game.controller; import javax.validation.Valid; import javax.validation.constraints.Positive; @@ -16,15 +16,14 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.admin.game.dto.GameLogListAdminResponseDto; -import com.gg.server.admin.game.dto.GameUserLogAdminReqDto; -import com.gg.server.admin.game.dto.RankGamePPPModifyReqDto; -import com.gg.server.admin.game.service.GameAdminService; -import com.gg.server.domain.rank.redis.RankRedisService; -import com.gg.server.global.dto.PageRequestDto; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.InvalidParameterException; - +import gg.pingpong.api.admin.game.controller.response.GameLogListAdminResponseDto; +import gg.pingpong.api.admin.game.dto.GameUserLogAdminReqDto; +import gg.pingpong.api.admin.game.dto.RankGamePPPModifyReqDto; +import gg.pingpong.api.admin.game.service.GameAdminService; +import gg.pingpong.api.global.dto.PageRequestDto; +import gg.pingpong.api.user.rank.redis.RankRedisService; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.InvalidParameterException; import lombok.RequiredArgsConstructor; @RestController diff --git a/src/main/java/com/gg/server/admin/game/dto/GameLogListAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/controller/response/GameLogListAdminResponseDto.java similarity index 71% rename from src/main/java/com/gg/server/admin/game/dto/GameLogListAdminResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/controller/response/GameLogListAdminResponseDto.java index be826c2d7..72e342644 100644 --- a/src/main/java/com/gg/server/admin/game/dto/GameLogListAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/controller/response/GameLogListAdminResponseDto.java @@ -1,7 +1,8 @@ -package com.gg.server.admin.game.dto; +package gg.pingpong.api.admin.game.controller.response; import java.util.List; +import gg.pingpong.api.admin.game.dto.GameLogAdminDto; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/game/dto/GameLogAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/GameLogAdminDto.java similarity index 88% rename from src/main/java/com/gg/server/admin/game/dto/GameLogAdminDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/GameLogAdminDto.java index 80523ccda..b5615e6fb 100644 --- a/src/main/java/com/gg/server/admin/game/dto/GameLogAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/GameLogAdminDto.java @@ -1,11 +1,10 @@ -package com.gg.server.admin.game.dto; +package gg.pingpong.api.admin.game.dto; import java.time.Duration; import java.time.LocalDateTime; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.domain.game.dto.GameTeamUser; - +import gg.pingpong.admin.repo.game.out.GameTeamUser; +import gg.pingpong.data.game.type.StatusType; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/game/dto/GameTeamAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/GameTeamAdminDto.java similarity index 94% rename from src/main/java/com/gg/server/admin/game/dto/GameTeamAdminDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/GameTeamAdminDto.java index dbfa836cf..757da8285 100644 --- a/src/main/java/com/gg/server/admin/game/dto/GameTeamAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/GameTeamAdminDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.game.dto; +package gg.pingpong.api.admin.game.dto; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/src/main/java/com/gg/server/admin/game/dto/GameUserLogAdminReqDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/GameUserLogAdminReqDto.java similarity index 78% rename from src/main/java/com/gg/server/admin/game/dto/GameUserLogAdminReqDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/GameUserLogAdminReqDto.java index 45d2530e4..ea4b42050 100644 --- a/src/main/java/com/gg/server/admin/game/dto/GameUserLogAdminReqDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/GameUserLogAdminReqDto.java @@ -1,9 +1,8 @@ -package com.gg.server.admin.game.dto; +package gg.pingpong.api.admin.game.dto; import javax.validation.constraints.NotNull; -import com.gg.server.global.dto.PageRequestDto; - +import gg.pingpong.api.global.dto.PageRequestDto; import lombok.Getter; @Getter diff --git a/src/main/java/com/gg/server/admin/game/dto/RankGamePPPModifyReqDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/RankGamePPPModifyReqDto.java similarity index 95% rename from src/main/java/com/gg/server/admin/game/dto/RankGamePPPModifyReqDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/RankGamePPPModifyReqDto.java index 688c31dbe..20815eb7c 100644 --- a/src/main/java/com/gg/server/admin/game/dto/RankGamePPPModifyReqDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/RankGamePPPModifyReqDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.game.dto; +package gg.pingpong.api.admin.game.dto; import javax.validation.constraints.Max; import javax.validation.constraints.NotNull; diff --git a/src/main/java/com/gg/server/admin/game/service/GameAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/service/GameAdminService.java similarity index 83% rename from src/main/java/com/gg/server/admin/game/service/GameAdminService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/service/GameAdminService.java index b7a9511dc..0bc773a13 100644 --- a/src/main/java/com/gg/server/admin/game/service/GameAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/service/GameAdminService.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.game.service; +package gg.pingpong.api.admin.game.service; import java.util.ArrayList; import java.util.List; @@ -14,35 +14,34 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.game.data.GameAdminRepository; -import com.gg.server.admin.game.dto.GameLogAdminDto; -import com.gg.server.admin.game.dto.GameLogListAdminResponseDto; -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; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.PChange; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.game.exception.GameNotExistException; -import com.gg.server.domain.match.data.RedisMatchUserRepository; -import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.rank.redis.RankRedisService; -import com.gg.server.domain.season.dto.CurSeason; -import com.gg.server.domain.season.exception.SeasonNotFoundException; -import com.gg.server.domain.season.service.SeasonService; -import com.gg.server.domain.tier.service.TierService; -import com.gg.server.domain.user.exception.UserNotFoundException; - +import gg.pingpong.admin.repo.game.GameAdminRepository; +import gg.pingpong.admin.repo.game.PChangeAdminRepository; +import gg.pingpong.admin.repo.game.TeamUserAdminRepository; +import gg.pingpong.admin.repo.game.out.GameTeamUser; +import gg.pingpong.admin.repo.season.SeasonAdminRepository; +import gg.pingpong.admin.repo.user.UserAdminRepository; +import gg.pingpong.api.admin.game.controller.response.GameLogListAdminResponseDto; +import gg.pingpong.api.admin.game.dto.GameLogAdminDto; +import gg.pingpong.api.admin.game.dto.RankGamePPPModifyReqDto; +import gg.pingpong.api.user.rank.redis.RankRedisService; +import gg.pingpong.api.user.rank.service.TierService; +import gg.pingpong.api.user.season.dto.CurSeason; +import gg.pingpong.api.user.season.service.SeasonService; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.PChange; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.PChangeRepository; +import gg.pingpong.repo.match.RedisMatchUserRepository; +import gg.pingpong.utils.exception.game.GameNotExistException; +import gg.pingpong.utils.exception.game.NotRecentlyGameException; +import gg.pingpong.utils.exception.pchange.PChangeNotExistException; +import gg.pingpong.utils.exception.season.SeasonNotFoundException; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/gg/server/admin/announcement/controller/AnnouncementAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/AnnouncementAdminController.java similarity index 85% rename from src/main/java/com/gg/server/admin/announcement/controller/AnnouncementAdminController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/AnnouncementAdminController.java index 2412d92df..7f9ef0498 100644 --- a/src/main/java/com/gg/server/admin/announcement/controller/AnnouncementAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/AnnouncementAdminController.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.announcement.controller; +package gg.pingpong.api.admin.manage.controller; import javax.validation.Valid; @@ -17,11 +17,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; -import com.gg.server.admin.announcement.dto.AnnouncementAdminListResponseDto; -import com.gg.server.admin.announcement.service.AnnouncementAdminService; -import com.gg.server.global.dto.PageRequestDto; - +import gg.pingpong.api.admin.manage.controller.response.AnnouncementAdminListResponseDto; +import gg.pingpong.api.admin.manage.dto.AnnouncementAdminAddDto; +import gg.pingpong.api.admin.manage.service.AnnouncementAdminService; +import gg.pingpong.api.global.dto.PageRequestDto; import lombok.AllArgsConstructor; @RestController diff --git a/src/main/java/com/gg/server/admin/feedback/controller/FeedbackAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/FeedbackAdminController.java similarity index 88% rename from src/main/java/com/gg/server/admin/feedback/controller/FeedbackAdminController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/FeedbackAdminController.java index 74215e34c..48dd58025 100644 --- a/src/main/java/com/gg/server/admin/feedback/controller/FeedbackAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/FeedbackAdminController.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.feedback.controller; +package gg.pingpong.api.admin.manage.controller; import javax.validation.Valid; import javax.validation.constraints.NotNull; @@ -16,10 +16,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.admin.feedback.dto.FeedbackAdminPageRequestDto; -import com.gg.server.admin.feedback.dto.FeedbackListAdminResponseDto; -import com.gg.server.admin.feedback.service.FeedbackAdminService; - +import gg.pingpong.api.admin.manage.controller.request.FeedbackAdminPageRequestDto; +import gg.pingpong.api.admin.manage.controller.response.FeedbackListAdminResponseDto; +import gg.pingpong.api.admin.manage.service.FeedbackAdminService; import lombok.RequiredArgsConstructor; @RestController diff --git a/src/main/java/com/gg/server/admin/penalty/controller/PenaltyAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/PenaltyAdminController.java similarity index 87% rename from src/main/java/com/gg/server/admin/penalty/controller/PenaltyAdminController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/PenaltyAdminController.java index 5215175c2..69375f5de 100644 --- a/src/main/java/com/gg/server/admin/penalty/controller/PenaltyAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/PenaltyAdminController.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.penalty.controller; +package gg.pingpong.api.admin.manage.controller; import javax.validation.Valid; import javax.validation.constraints.Min; @@ -19,11 +19,10 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.admin.penalty.dto.PenaltyListResponseDto; -import com.gg.server.admin.penalty.dto.PenaltyRequestDto; -import com.gg.server.admin.penalty.service.PenaltyAdminService; -import com.gg.server.global.dto.PageRequestDto; - +import gg.pingpong.api.admin.manage.controller.request.PenaltyRequestDto; +import gg.pingpong.api.admin.manage.controller.response.PenaltyListResponseDto; +import gg.pingpong.api.admin.manage.service.PenaltyAdminService; +import gg.pingpong.api.global.dto.PageRequestDto; import lombok.RequiredArgsConstructor; @RestController diff --git a/src/main/java/com/gg/server/admin/slotmanagement/controller/SlotAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/SlotAdminController.java similarity index 82% rename from src/main/java/com/gg/server/admin/slotmanagement/controller/SlotAdminController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/SlotAdminController.java index b2fef7d1d..f885221e4 100644 --- a/src/main/java/com/gg/server/admin/slotmanagement/controller/SlotAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/SlotAdminController.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.slotmanagement.controller; +package gg.pingpong.api.admin.manage.controller; import javax.validation.Valid; @@ -11,10 +11,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.admin.slotmanagement.dto.SlotCreateRequestDto; -import com.gg.server.admin.slotmanagement.dto.SlotListAdminResponseDto; -import com.gg.server.admin.slotmanagement.service.SlotAdminService; - +import gg.pingpong.api.admin.manage.controller.request.SlotCreateRequestDto; +import gg.pingpong.api.admin.manage.controller.response.SlotListAdminResponseDto; +import gg.pingpong.api.admin.manage.service.SlotAdminService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminPageRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/request/FeedbackAdminPageRequestDto.java similarity index 70% rename from src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminPageRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/request/FeedbackAdminPageRequestDto.java index cf22d56ce..80fbdb426 100644 --- a/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminPageRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/request/FeedbackAdminPageRequestDto.java @@ -1,7 +1,6 @@ -package com.gg.server.admin.feedback.dto; - -import com.gg.server.global.dto.PageRequestDto; +package gg.pingpong.api.admin.manage.controller.request; +import gg.pingpong.api.global.dto.PageRequestDto; import lombok.Getter; @Getter diff --git a/src/main/java/com/gg/server/admin/penalty/dto/PenaltyRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/request/PenaltyRequestDto.java similarity index 87% rename from src/main/java/com/gg/server/admin/penalty/dto/PenaltyRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/request/PenaltyRequestDto.java index b4092ebc8..abf067516 100644 --- a/src/main/java/com/gg/server/admin/penalty/dto/PenaltyRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/request/PenaltyRequestDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.penalty.dto; +package gg.pingpong.api.admin.manage.controller.request; import javax.validation.constraints.PositiveOrZero; diff --git a/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotCreateRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/request/SlotCreateRequestDto.java similarity index 95% rename from src/main/java/com/gg/server/admin/slotmanagement/dto/SlotCreateRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/request/SlotCreateRequestDto.java index 4cf6b9bee..2a6d6c9a1 100644 --- a/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotCreateRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/request/SlotCreateRequestDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.slotmanagement.dto; +package gg.pingpong.api.admin.manage.controller.request; import java.time.LocalDateTime; diff --git a/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/AnnouncementAdminListResponseDto.java similarity index 83% rename from src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminListResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/AnnouncementAdminListResponseDto.java index b516b46ee..0b91213d6 100644 --- a/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/AnnouncementAdminListResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.announcement.dto; +package gg.pingpong.api.admin.manage.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/AnnouncementAdminResponseDto.java similarity index 88% rename from src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/AnnouncementAdminResponseDto.java index cd67b49b8..20395bd6f 100644 --- a/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/AnnouncementAdminResponseDto.java @@ -1,9 +1,8 @@ -package com.gg.server.admin.announcement.dto; +package gg.pingpong.api.admin.manage.controller.response; import java.time.LocalDateTime; -import com.gg.server.data.manage.Announcement; - +import gg.pingpong.data.manage.Announcement; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/FeedbackAdminResponseDto.java similarity index 80% rename from src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/FeedbackAdminResponseDto.java index ec0c98669..f0cf5059b 100644 --- a/src/main/java/com/gg/server/admin/feedback/dto/FeedbackAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/FeedbackAdminResponseDto.java @@ -1,10 +1,9 @@ -package com.gg.server.admin.feedback.dto; +package gg.pingpong.api.admin.manage.controller.response; import java.time.LocalDateTime; -import com.gg.server.data.manage.Feedback; -import com.gg.server.data.manage.type.FeedbackType; - +import gg.pingpong.data.manage.Feedback; +import gg.pingpong.data.manage.type.FeedbackType; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/feedback/dto/FeedbackListAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/FeedbackListAdminResponseDto.java similarity index 87% rename from src/main/java/com/gg/server/admin/feedback/dto/FeedbackListAdminResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/FeedbackListAdminResponseDto.java index 7447d8c5b..6d0b2203d 100644 --- a/src/main/java/com/gg/server/admin/feedback/dto/FeedbackListAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/FeedbackListAdminResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.feedback.dto; +package gg.pingpong.api.admin.manage.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/admin/penalty/dto/PenaltyListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/PenaltyListResponseDto.java similarity index 82% rename from src/main/java/com/gg/server/admin/penalty/dto/PenaltyListResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/PenaltyListResponseDto.java index 99a868fb4..28ecebbbf 100644 --- a/src/main/java/com/gg/server/admin/penalty/dto/PenaltyListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/PenaltyListResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.penalty.dto; +package gg.pingpong.api.admin.manage.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/admin/penalty/dto/PenaltyUserResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/PenaltyUserResponseDto.java similarity index 86% rename from src/main/java/com/gg/server/admin/penalty/dto/PenaltyUserResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/PenaltyUserResponseDto.java index 0e3e1aac0..97e6d2e81 100644 --- a/src/main/java/com/gg/server/admin/penalty/dto/PenaltyUserResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/PenaltyUserResponseDto.java @@ -1,10 +1,9 @@ -package com.gg.server.admin.penalty.dto; +package gg.pingpong.api.admin.manage.controller.response; import java.time.LocalDateTime; -import com.gg.server.data.manage.Penalty; -import com.gg.server.data.manage.redis.RedisPenaltyUser; - +import gg.pingpong.data.manage.Penalty; +import gg.pingpong.data.manage.redis.RedisPenaltyUser; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotListAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/SlotListAdminResponseDto.java similarity index 71% rename from src/main/java/com/gg/server/admin/slotmanagement/dto/SlotListAdminResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/SlotListAdminResponseDto.java index aea0e9440..1010bc65a 100644 --- a/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotListAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/SlotListAdminResponseDto.java @@ -1,7 +1,8 @@ -package com.gg.server.admin.slotmanagement.dto; +package gg.pingpong.api.admin.manage.controller.response; import java.util.List; +import gg.pingpong.api.admin.manage.dto.SlotAdminDto; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminAddDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/dto/AnnouncementAdminAddDto.java similarity index 88% rename from src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminAddDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/dto/AnnouncementAdminAddDto.java index 36140d7f1..3e168a342 100644 --- a/src/main/java/com/gg/server/admin/announcement/dto/AnnouncementAdminAddDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/dto/AnnouncementAdminAddDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.announcement.dto; +package gg.pingpong.api.admin.manage.dto; import javax.validation.constraints.NotNull; diff --git a/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/dto/SlotAdminDto.java similarity index 87% rename from src/main/java/com/gg/server/admin/slotmanagement/dto/SlotAdminDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/dto/SlotAdminDto.java index 07853d666..346662b89 100644 --- a/src/main/java/com/gg/server/admin/slotmanagement/dto/SlotAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/dto/SlotAdminDto.java @@ -1,9 +1,8 @@ -package com.gg.server.admin.slotmanagement.dto; +package gg.pingpong.api.admin.manage.dto; import java.time.LocalDateTime; -import com.gg.server.domain.slotmanagement.SlotManagement; - +import gg.pingpong.data.manage.SlotManagement; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/AnnouncementAdminService.java similarity index 70% rename from src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/AnnouncementAdminService.java index 2e2486308..5b689d054 100644 --- a/src/main/java/com/gg/server/admin/announcement/service/AnnouncementAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/AnnouncementAdminService.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.announcement.service; +package gg.pingpong.api.admin.manage.service; import java.time.LocalDateTime; @@ -7,14 +7,13 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.announcement.data.AnnouncementAdminRepository; -import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; -import com.gg.server.admin.announcement.dto.AnnouncementAdminListResponseDto; -import com.gg.server.admin.announcement.dto.AnnouncementAdminResponseDto; -import com.gg.server.data.manage.Announcement; -import com.gg.server.domain.announcement.exception.AnnounceDupException; -import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; - +import gg.pingpong.admin.repo.manage.AnnouncementAdminRepository; +import gg.pingpong.api.admin.manage.controller.response.AnnouncementAdminListResponseDto; +import gg.pingpong.api.admin.manage.controller.response.AnnouncementAdminResponseDto; +import gg.pingpong.api.admin.manage.dto.AnnouncementAdminAddDto; +import gg.pingpong.data.manage.Announcement; +import gg.pingpong.utils.exception.announcement.AnnounceDupException; +import gg.pingpong.utils.exception.announcement.AnnounceNotFoundException; import lombok.AllArgsConstructor; @Service @@ -39,7 +38,7 @@ public void addAnnouncement(AnnouncementAdminAddDto addDto) { throw new AnnounceDupException(); } - announcementAdminRepository.save(Announcement.from(addDto)); + announcementAdminRepository.save(Announcement.from(addDto.getContent(), addDto.getCreatorIntraId())); } @Transactional diff --git a/src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/FeedbackAdminService.java similarity index 84% rename from src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/FeedbackAdminService.java index 26201726f..727593e2a 100644 --- a/src/main/java/com/gg/server/admin/feedback/service/FeedbackAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/FeedbackAdminService.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.feedback.service; +package gg.pingpong.api.admin.manage.service; import java.util.List; @@ -8,12 +8,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.feedback.data.FeedbackAdminRepository; -import com.gg.server.admin.feedback.dto.FeedbackAdminResponseDto; -import com.gg.server.admin.feedback.dto.FeedbackListAdminResponseDto; -import com.gg.server.data.manage.Feedback; -import com.gg.server.domain.feedback.exception.FeedbackNotFoundException; - +import gg.pingpong.admin.repo.manage.FeedbackAdminRepository; +import gg.pingpong.api.admin.manage.controller.response.FeedbackAdminResponseDto; +import gg.pingpong.api.admin.manage.controller.response.FeedbackListAdminResponseDto; +import gg.pingpong.data.manage.Feedback; +import gg.pingpong.utils.exception.feedback.FeedbackNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/PenaltyAdminService.java similarity index 76% rename from src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/PenaltyAdminService.java index 296d7b5e7..16c3607f1 100644 --- a/src/main/java/com/gg/server/admin/penalty/service/PenaltyAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/PenaltyAdminService.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.penalty.service; +package gg.pingpong.api.admin.manage.service; import java.time.LocalDateTime; import java.util.List; @@ -9,19 +9,18 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.penalty.data.PenaltyAdminRepository; -import com.gg.server.admin.penalty.data.PenaltyUserAdminRedisRepository; -import com.gg.server.admin.penalty.dto.PenaltyListResponseDto; -import com.gg.server.admin.penalty.dto.PenaltyUserResponseDto; -import com.gg.server.data.manage.Penalty; -import com.gg.server.data.manage.redis.RedisPenaltyUser; -import com.gg.server.data.user.User; -import com.gg.server.domain.penalty.exception.PenaltyExpiredException; -import com.gg.server.domain.penalty.exception.PenaltyNotFoundException; -import com.gg.server.domain.penalty.exception.RedisPenaltyUserNotFoundException; -import com.gg.server.domain.penalty.type.PenaltyType; -import com.gg.server.domain.user.service.UserFindService; - +import gg.pingpong.admin.repo.manage.PenaltyAdminRepository; +import gg.pingpong.admin.repo.manage.PenaltyUserAdminRedisRepository; +import gg.pingpong.api.admin.manage.controller.response.PenaltyListResponseDto; +import gg.pingpong.api.admin.manage.controller.response.PenaltyUserResponseDto; +import gg.pingpong.api.user.user.service.UserFindService; +import gg.pingpong.data.manage.Penalty; +import gg.pingpong.data.manage.redis.RedisPenaltyUser; +import gg.pingpong.data.manage.type.PenaltyType; +import gg.pingpong.data.user.User; +import gg.pingpong.utils.exception.penalty.PenaltyExpiredException; +import gg.pingpong.utils.exception.penalty.PenaltyNotFoundException; +import gg.pingpong.utils.exception.penalty.RedisPenaltyUserNotFoundException; import lombok.RequiredArgsConstructor; @Service @@ -31,12 +30,6 @@ public class PenaltyAdminService { private final UserFindService userFindService; private final PenaltyAdminRepository penaltyRepository; - /** - * 패널티 부여 - * @param intraId - * @param penaltyTime - * @param reason - */ @Transactional public void givePenalty(String intraId, Integer penaltyTime, String reason) { User user = userFindService.findByIntraId(intraId); @@ -60,12 +53,6 @@ public void givePenalty(String intraId, Integer penaltyTime, String reason) { penaltyUserAdminRedisRepository.addPenaltyUser(penaltyUser, releaseTime); } - /** - * 모든 패널티 조회 - * @param pageable - * @param current - * @return PenaltyListResponseDto - */ @Transactional(readOnly = true) public PenaltyListResponseDto getAllPenalties(Pageable pageable, Boolean current) { Page allPenalties; @@ -78,12 +65,6 @@ public PenaltyListResponseDto getAllPenalties(Pageable pageable, Boolean current return new PenaltyListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); } - /** - * 패널티 삭제 - * 패널티 시간이 지났을 경우 삭제 불가능 - * redis 에서도 삭제 - * @param penaltyId - */ @Transactional public void deletePenalty(Long penaltyId) { Penalty penalty = penaltyRepository.findById(penaltyId).orElseThrow(() @@ -101,13 +82,6 @@ public void deletePenalty(Long penaltyId) { penaltyRepository.delete(penalty); } - /** - * intraId 로 패널티 리스트 조회 - * @param pageable - * @param intraId - * @param current - * @return PenaltyListResponseDto - */ @Transactional(readOnly = true) public PenaltyListResponseDto getAllPenaltiesByIntraId(Pageable pageable, String intraId, Boolean current) { Page allPenalties; diff --git a/src/main/java/com/gg/server/admin/slotmanagement/service/SlotAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/SlotAdminService.java similarity index 70% rename from src/main/java/com/gg/server/admin/slotmanagement/service/SlotAdminService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/SlotAdminService.java index d05fb3896..267260d1c 100644 --- a/src/main/java/com/gg/server/admin/slotmanagement/service/SlotAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/SlotAdminService.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.slotmanagement.service; +package gg.pingpong.api.admin.manage.service; import java.time.LocalDateTime; import java.util.ArrayList; @@ -7,14 +7,13 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.slotmanagement.data.AdminSlotManagementsRepository; -import com.gg.server.admin.slotmanagement.dto.SlotAdminDto; -import com.gg.server.admin.slotmanagement.dto.SlotCreateRequestDto; -import com.gg.server.admin.slotmanagement.dto.SlotListAdminResponseDto; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.exception.SlotManagementForbiddenException; -import com.gg.server.domain.slotmanagement.exception.SlotManagementNotFoundException; - +import gg.pingpong.admin.repo.manage.AdminSlotManagementsRepository; +import gg.pingpong.api.admin.manage.controller.request.SlotCreateRequestDto; +import gg.pingpong.api.admin.manage.controller.response.SlotListAdminResponseDto; +import gg.pingpong.api.admin.manage.dto.SlotAdminDto; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.utils.exception.slotmanagement.SlotManagementForbiddenException; +import gg.pingpong.utils.exception.slotmanagement.SlotManagementNotFoundException; import lombok.RequiredArgsConstructor; @Service @@ -22,10 +21,6 @@ public class SlotAdminService { private final AdminSlotManagementsRepository adminSlotManagementRepository; - /** - *

현재 슬롯 정보를 가져온다.

- * @return - */ @Transactional(readOnly = true) public SlotListAdminResponseDto getSlotSetting() { List slotManagements = adminSlotManagementRepository.findAfterNowSlotManagement( @@ -38,23 +33,17 @@ public SlotListAdminResponseDto getSlotSetting() { return new SlotListAdminResponseDto(dtoList); } - /** - *

새로운 슬롯을 추가한다.

- * @param requestDto - */ @Transactional public void addSlotSetting(SlotCreateRequestDto requestDto) { checkVaildSlotManagement(requestDto); requestDto.updateStartTime(); updateNowSlotManagementEndTime(requestDto.getStartTime()); - SlotManagement slotManagement = new SlotManagement(requestDto); + SlotManagement slotManagement = new SlotManagement(requestDto.getPastSlotTime(), requestDto.getFutureSlotTime(), + requestDto.getInterval(), requestDto.getOpenMinute(), requestDto.getStartTime()); adminSlotManagementRepository.save(slotManagement); } - /** - *

현재 시간보다 이후 혹은 종료 시간이 이후인 슬롯 정보를 삭제한다.

- */ @Transactional public void delSlotSetting() { List slotManagements = adminSlotManagementRepository.findAfterNowSlotManagement( @@ -70,10 +59,6 @@ public void delSlotSetting() { beforeSlotManagement.setNullEndTime(); } - /** - *

서비스 로직 조건에 맞는지 체크

- * @param requestDto - */ private void checkVaildSlotManagement(SlotCreateRequestDto requestDto) { if (requestDto.getPastSlotTime() > 23) { throw new SlotManagementForbiddenException(); @@ -89,13 +74,9 @@ private void checkVaildSlotManagement(SlotCreateRequestDto requestDto) { } } - /** - *

서비스 로직 조건에 맞는지 체크

- * @param endTime - */ private void updateNowSlotManagementEndTime(LocalDateTime endTime) { SlotManagement nowSlotManagement = adminSlotManagementRepository.findFirstByOrderByIdDesc() - .orElseThrow(SlotManagementNotFoundException::new); + .orElseThrow(() -> new SlotManagementNotFoundException()); LocalDateTime nowFutureSlotTime = LocalDateTime.now().isAfter(nowSlotManagement.getStartTime()) ? LocalDateTime.now().plusHours(nowSlotManagement.getFutureSlotTime()) diff --git a/src/main/java/com/gg/server/admin/noti/controller/NotiAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/NotiAdminController.java similarity index 82% rename from src/main/java/com/gg/server/admin/noti/controller/NotiAdminController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/NotiAdminController.java index 61672cd1d..7c37774c4 100644 --- a/src/main/java/com/gg/server/admin/noti/controller/NotiAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/NotiAdminController.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.noti.controller; +package gg.pingpong.api.admin.noti.controller; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -12,11 +12,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.admin.noti.dto.NotiListAdminRequestDto; -import com.gg.server.admin.noti.dto.NotiListAdminResponseDto; -import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; -import com.gg.server.admin.noti.service.NotiAdminService; - +import gg.pingpong.api.admin.noti.controller.request.NotiListAdminRequestDto; +import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; +import gg.pingpong.api.admin.noti.controller.response.NotiListAdminResponseDto; +import gg.pingpong.api.admin.noti.service.NotiAdminService; import lombok.AllArgsConstructor; @RestController diff --git a/src/main/java/com/gg/server/admin/noti/dto/NotiListAdminRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/request/NotiListAdminRequestDto.java similarity index 72% rename from src/main/java/com/gg/server/admin/noti/dto/NotiListAdminRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/request/NotiListAdminRequestDto.java index 6d00cdd1a..2d545d127 100644 --- a/src/main/java/com/gg/server/admin/noti/dto/NotiListAdminRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/request/NotiListAdminRequestDto.java @@ -1,7 +1,6 @@ -package com.gg.server.admin.noti.dto; - -import com.gg.server.global.dto.PageRequestDto; +package gg.pingpong.api.admin.noti.controller.request; +import gg.pingpong.api.global.dto.PageRequestDto; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/gg/server/admin/noti/dto/SendNotiAdminRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/request/SendNotiAdminRequestDto.java similarity index 92% rename from src/main/java/com/gg/server/admin/noti/dto/SendNotiAdminRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/request/SendNotiAdminRequestDto.java index 576aba015..54ccfd78f 100644 --- a/src/main/java/com/gg/server/admin/noti/dto/SendNotiAdminRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/request/SendNotiAdminRequestDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.noti.dto; +package gg.pingpong.api.admin.noti.controller.request; import java.util.Objects; diff --git a/src/main/java/com/gg/server/admin/noti/dto/NotiListAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/response/NotiListAdminResponseDto.java similarity index 88% rename from src/main/java/com/gg/server/admin/noti/dto/NotiListAdminResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/response/NotiListAdminResponseDto.java index 67ac4dc2f..88c084f9d 100644 --- a/src/main/java/com/gg/server/admin/noti/dto/NotiListAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/controller/response/NotiListAdminResponseDto.java @@ -1,10 +1,11 @@ -package com.gg.server.admin.noti.dto; +package gg.pingpong.api.admin.noti.controller.response; import java.util.List; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonInclude; +import gg.pingpong.api.admin.noti.dto.NotiAdminDto; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/noti/dto/NotiAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/dto/NotiAdminDto.java similarity index 92% rename from src/main/java/com/gg/server/admin/noti/dto/NotiAdminDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/dto/NotiAdminDto.java index 25ac5fa5b..ab153e291 100644 --- a/src/main/java/com/gg/server/admin/noti/dto/NotiAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/dto/NotiAdminDto.java @@ -1,11 +1,10 @@ -package com.gg.server.admin.noti.dto; +package gg.pingpong.api.admin.noti.dto; import java.time.LocalDateTime; import java.util.Objects; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.noti.type.NotiType; - +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.noti.type.NotiType; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/service/NotiAdminService.java similarity index 77% rename from src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/service/NotiAdminService.java index 8c7d73828..02102ec22 100644 --- a/src/main/java/com/gg/server/admin/noti/service/NotiAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/service/NotiAdminService.java @@ -1,22 +1,21 @@ -package com.gg.server.admin.noti.service; +package gg.pingpong.api.admin.noti.service; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.noti.data.NotiAdminRepository; -import com.gg.server.admin.noti.dto.NotiAdminDto; -import com.gg.server.admin.noti.dto.NotiListAdminResponseDto; -import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; -import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.noti.type.NotiType; -import com.gg.server.data.user.User; -import com.gg.server.domain.noti.service.SnsNotiService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; - +import gg.pingpong.admin.repo.noti.NotiAdminRepository; +import gg.pingpong.admin.repo.user.UserAdminRepository; +import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; +import gg.pingpong.api.admin.noti.controller.response.NotiListAdminResponseDto; +import gg.pingpong.api.admin.noti.dto.NotiAdminDto; +import gg.pingpong.api.user.noti.service.SnsNotiService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.noti.type.NotiType; +import gg.pingpong.data.user.User; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.AllArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/admin/rank/service/RankAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/rank/service/RankAdminService.java similarity index 66% rename from src/main/java/com/gg/server/admin/rank/service/RankAdminService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/rank/service/RankAdminService.java index 18ea1ad87..4b507141c 100644 --- a/src/main/java/com/gg/server/admin/rank/service/RankAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/rank/service/RankAdminService.java @@ -1,6 +1,6 @@ -package com.gg.server.admin.rank.service; +package gg.pingpong.api.admin.rank.service; -import static com.gg.server.data.user.type.RoleType.*; +import static gg.pingpong.data.user.type.RoleType.*; import java.time.LocalDateTime; import java.util.ArrayList; @@ -9,19 +9,18 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.season.dto.SeasonAdminDto; -import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.data.game.Rank; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Tier; -import com.gg.server.data.user.User; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.season.exception.SeasonForbiddenException; -import com.gg.server.domain.season.exception.SeasonTimeBeforeException; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tier.exception.TierNotFoundException; - +import gg.pingpong.admin.repo.user.UserAdminRepository; +import gg.pingpong.api.admin.season.dto.SeasonAdminDto; +import gg.pingpong.data.rank.Rank; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.TierRepository; +import gg.pingpong.repo.season.SeasonRepository; +import gg.pingpong.utils.exception.season.SeasonForbiddenException; +import gg.pingpong.utils.exception.season.SeasonTimeBeforeException; +import gg.pingpong.utils.exception.tier.TierNotFoundException; import lombok.AllArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/admin/rank/service/RankRedisAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/rank/service/RankRedisAdminService.java similarity index 66% rename from src/main/java/com/gg/server/admin/rank/service/RankRedisAdminService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/rank/service/RankRedisAdminService.java index e1be5d898..e12e46aa4 100644 --- a/src/main/java/com/gg/server/admin/rank/service/RankRedisAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/rank/service/RankRedisAdminService.java @@ -1,23 +1,21 @@ -package com.gg.server.admin.rank.service; +package gg.pingpong.api.admin.rank.service; -import static com.gg.server.data.user.type.RoleType.*; +import static gg.pingpong.data.user.type.RoleType.*; import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.season.dto.SeasonAdminDto; -import com.gg.server.data.game.Tier; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.user.User; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; - +import gg.pingpong.api.admin.season.dto.SeasonAdminDto; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.rank.TierRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.exception.tier.TierNotFoundException; import lombok.AllArgsConstructor; @Service @@ -36,8 +34,8 @@ public void addAllUserRankByNewSeason(SeasonAdminDto seasonAdminDto) { users.forEach(user -> { if (user.getRoleType() != GUEST) { - UserDto userDto = UserDto.from(user); - RankRedis userRank = RankRedis.from(userDto, seasonAdminDto.getStartPpp(), tier.getImageUri()); + RankRedis userRank = RankRedis.from(user.getId(), user.getIntraId(), user.getTextColor(), + seasonAdminDto.getStartPpp(), tier.getImageUri()); rankRedisRepository.addRankData(redisHashKey, user.getId(), userRank); } diff --git a/src/main/java/com/gg/server/admin/season/controller/SeasonAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/SeasonAdminController.java similarity index 81% rename from src/main/java/com/gg/server/admin/season/controller/SeasonAdminController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/SeasonAdminController.java index cf67394bf..b7d4f4634 100644 --- a/src/main/java/com/gg/server/admin/season/controller/SeasonAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/SeasonAdminController.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.season.controller; +package gg.pingpong.api.admin.season.controller; import java.util.List; @@ -15,12 +15,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.admin.season.dto.SeasonAdminDto; -import com.gg.server.admin.season.dto.SeasonCreateRequestDto; -import com.gg.server.admin.season.dto.SeasonListAdminResponseDto; -import com.gg.server.admin.season.dto.SeasonUpdateRequestDto; -import com.gg.server.admin.season.service.SeasonAdminService; - +import gg.pingpong.api.admin.season.controller.request.SeasonCreateRequestDto; +import gg.pingpong.api.admin.season.controller.request.SeasonUpdateRequestDto; +import gg.pingpong.api.admin.season.controller.response.SeasonListAdminResponseDto; +import gg.pingpong.api.admin.season.dto.SeasonAdminDto; +import gg.pingpong.api.admin.season.service.SeasonAdminService; import lombok.AllArgsConstructor; @RestController diff --git a/src/main/java/com/gg/server/admin/season/dto/SeasonCreateRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/request/SeasonCreateRequestDto.java similarity index 78% rename from src/main/java/com/gg/server/admin/season/dto/SeasonCreateRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/request/SeasonCreateRequestDto.java index 055f1514d..fbfee0765 100644 --- a/src/main/java/com/gg/server/admin/season/dto/SeasonCreateRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/request/SeasonCreateRequestDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.season.dto; +package gg.pingpong.api.admin.season.controller.request; import java.time.LocalDateTime; @@ -7,6 +7,7 @@ import org.springframework.format.annotation.DateTimeFormat; +import gg.pingpong.data.season.Season; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -29,6 +30,15 @@ public class SeasonCreateRequestDto { @NotNull(message = "plz. pppGap") private Integer pppGap; + public Season toSeason() { + return Season.builder() + .seasonName(seasonName) + .startTime(startTime) + .startPpp(startPpp) + .pppGap(pppGap) + .build(); + } + public String toString() { return "SeasonCreateRequestAdminDto{" + '\'' + "seasonName=" + seasonName + '\'' diff --git a/src/main/java/com/gg/server/admin/season/dto/SeasonUpdateRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/request/SeasonUpdateRequestDto.java similarity index 92% rename from src/main/java/com/gg/server/admin/season/dto/SeasonUpdateRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/request/SeasonUpdateRequestDto.java index 51859cbf0..dcb48ca09 100644 --- a/src/main/java/com/gg/server/admin/season/dto/SeasonUpdateRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/request/SeasonUpdateRequestDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.season.dto; +package gg.pingpong.api.admin.season.controller.request; import java.time.LocalDateTime; diff --git a/src/main/java/com/gg/server/admin/season/dto/SeasonListAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/response/SeasonListAdminResponseDto.java similarity index 71% rename from src/main/java/com/gg/server/admin/season/dto/SeasonListAdminResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/response/SeasonListAdminResponseDto.java index 334d6b0c2..673630738 100644 --- a/src/main/java/com/gg/server/admin/season/dto/SeasonListAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/response/SeasonListAdminResponseDto.java @@ -1,7 +1,8 @@ -package com.gg.server.admin.season.dto; +package gg.pingpong.api.admin.season.controller.response; import java.util.List; +import gg.pingpong.api.admin.season.dto.SeasonAdminDto; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/season/dto/SeasonAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/dto/SeasonAdminDto.java similarity index 89% rename from src/main/java/com/gg/server/admin/season/dto/SeasonAdminDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/dto/SeasonAdminDto.java index 32e7fedc4..3da375a6f 100644 --- a/src/main/java/com/gg/server/admin/season/dto/SeasonAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/dto/SeasonAdminDto.java @@ -1,10 +1,9 @@ -package com.gg.server.admin.season.dto; +package gg.pingpong.api.admin.season.dto; import java.time.LocalDateTime; -import com.gg.server.admin.season.type.SeasonStatus; -import com.gg.server.data.game.Season; - +import gg.pingpong.api.admin.season.type.SeasonStatus; +import gg.pingpong.data.season.Season; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/service/SeasonAdminService.java similarity index 90% rename from src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/service/SeasonAdminService.java index a0d98c0bf..89e05eeac 100644 --- a/src/main/java/com/gg/server/admin/season/service/SeasonAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/service/SeasonAdminService.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.season.service; +package gg.pingpong.api.admin.season.service; import java.time.LocalDateTime; import java.util.ArrayList; @@ -7,17 +7,16 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.rank.service.RankAdminService; -import com.gg.server.admin.rank.service.RankRedisAdminService; -import com.gg.server.admin.season.data.SeasonAdminRepository; -import com.gg.server.admin.season.dto.SeasonAdminDto; -import com.gg.server.admin.season.dto.SeasonCreateRequestDto; -import com.gg.server.admin.season.dto.SeasonUpdateRequestDto; -import com.gg.server.data.game.Season; -import com.gg.server.domain.season.exception.SeasonForbiddenException; -import com.gg.server.domain.season.exception.SeasonNotFoundException; -import com.gg.server.domain.season.exception.SeasonTimeBeforeException; - +import gg.pingpong.admin.repo.season.SeasonAdminRepository; +import gg.pingpong.api.admin.rank.service.RankAdminService; +import gg.pingpong.api.admin.rank.service.RankRedisAdminService; +import gg.pingpong.api.admin.season.controller.request.SeasonCreateRequestDto; +import gg.pingpong.api.admin.season.controller.request.SeasonUpdateRequestDto; +import gg.pingpong.api.admin.season.dto.SeasonAdminDto; +import gg.pingpong.data.season.Season; +import gg.pingpong.utils.exception.season.SeasonForbiddenException; +import gg.pingpong.utils.exception.season.SeasonNotFoundException; +import gg.pingpong.utils.exception.season.SeasonTimeBeforeException; import lombok.AllArgsConstructor; @Service @@ -48,7 +47,8 @@ public List findAllSeasons() { */ @Transactional public void createSeason(SeasonCreateRequestDto createDto) { - Season newSeason = new Season(createDto); + + Season newSeason = createDto.toSeason(); insert(newSeason); seasonAdminRepository.save(newSeason); @@ -125,6 +125,7 @@ private void insert(Season season) { if (LocalDateTime.now().plusHours(24).isAfter(season.getStartTime())) { throw new SeasonTimeBeforeException(); } + List beforeSeasons = seasonAdminRepository.findBeforeSeasons(season.getStartTime()); Season beforeSeason = beforeSeasons.isEmpty() ? null : beforeSeasons.get(0); List afterSeasons = seasonAdminRepository.findAfterSeasons(season.getStartTime()); diff --git a/src/main/java/com/gg/server/admin/season/type/SeasonStatus.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/type/SeasonStatus.java similarity index 84% rename from src/main/java/com/gg/server/admin/season/type/SeasonStatus.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/type/SeasonStatus.java index d2ef056ec..ba6b81288 100644 --- a/src/main/java/com/gg/server/admin/season/type/SeasonStatus.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/type/SeasonStatus.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.season.type; +package gg.pingpong.api.admin.season.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/coin/controller/CoinAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/CoinAdminController.java similarity index 80% rename from src/main/java/com/gg/server/admin/coin/controller/CoinAdminController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/CoinAdminController.java index 8470432d2..b86d71050 100644 --- a/src/main/java/com/gg/server/admin/coin/controller/CoinAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/CoinAdminController.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.coin.controller; +package gg.pingpong.api.admin.store.controller; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -7,9 +7,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.admin.coin.dto.CoinUpdateRequestDto; -import com.gg.server.admin.coin.service.CoinAdminService; - +import gg.pingpong.api.admin.store.controller.request.CoinUpdateRequestDto; +import gg.pingpong.api.admin.store.service.CoinAdminService; import lombok.RequiredArgsConstructor; @RestController diff --git a/src/main/java/com/gg/server/admin/coin/controller/CoinPolicyAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/CoinPolicyAdminController.java similarity index 79% rename from src/main/java/com/gg/server/admin/coin/controller/CoinPolicyAdminController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/CoinPolicyAdminController.java index 0bf3a5aed..5a6b8f406 100644 --- a/src/main/java/com/gg/server/admin/coin/controller/CoinPolicyAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/CoinPolicyAdminController.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.coin.controller; +package gg.pingpong.api.admin.store.controller; import javax.validation.Valid; @@ -15,13 +15,12 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.admin.coin.dto.CoinPolicyAdminAddDto; -import com.gg.server.admin.coin.dto.CoinPolicyAdminListResponseDto; -import com.gg.server.admin.coin.service.CoinPolicyAdminService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.dto.PageRequestDto; -import com.gg.server.global.utils.argumentresolver.Login; - +import gg.pingpong.api.admin.store.controller.response.CoinPolicyAdminListResponseDto; +import gg.pingpong.api.admin.store.dto.CoinPolicyAdminAddDto; +import gg.pingpong.api.admin.store.service.CoinPolicyAdminService; +import gg.pingpong.api.global.dto.PageRequestDto; +import gg.pingpong.api.global.utils.argumentresolver.Login; +import gg.pingpong.api.user.user.dto.UserDto; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/item/controller/ItemAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/ItemAdminController.java similarity index 82% rename from src/main/java/com/gg/server/admin/item/controller/ItemAdminController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/ItemAdminController.java index f2c769822..e6a8a1aad 100644 --- a/src/main/java/com/gg/server/admin/item/controller/ItemAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/ItemAdminController.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.item.controller; +package gg.pingpong.api.admin.store.controller; import java.io.IOException; @@ -20,15 +20,14 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import com.gg.server.admin.item.dto.ItemListResponseDto; -import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.admin.item.service.ItemAdminService; -import com.gg.server.domain.item.exception.ItemImageLargeException; -import com.gg.server.domain.item.exception.ItemImageTypeException; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.dto.PageRequestDto; -import com.gg.server.global.utils.argumentresolver.Login; - +import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; +import gg.pingpong.api.admin.store.controller.response.ItemListResponseDto; +import gg.pingpong.api.admin.store.service.ItemAdminService; +import gg.pingpong.api.global.dto.PageRequestDto; +import gg.pingpong.api.global.utils.argumentresolver.Login; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.utils.exception.item.ItemImageLargeException; +import gg.pingpong.utils.exception.item.ItemImageTypeException; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/megaphone/controller/MegaphoneAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/MegaphoneAdminController.java similarity index 82% rename from src/main/java/com/gg/server/admin/megaphone/controller/MegaphoneAdminController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/MegaphoneAdminController.java index e4d736895..79e67c696 100644 --- a/src/main/java/com/gg/server/admin/megaphone/controller/MegaphoneAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/MegaphoneAdminController.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.megaphone.controller; +package gg.pingpong.api.admin.store.controller; import javax.validation.Valid; @@ -11,10 +11,9 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.admin.megaphone.dto.MegaphoneHistoryResponseDto; -import com.gg.server.admin.megaphone.service.MegaphoneAdminService; -import com.gg.server.global.dto.PageRequestDto; - +import gg.pingpong.api.admin.store.controller.response.MegaphoneHistoryResponseDto; +import gg.pingpong.api.admin.store.service.MegaphoneAdminService; +import gg.pingpong.api.global.dto.PageRequestDto; import lombok.RequiredArgsConstructor; @RestController diff --git a/src/main/java/com/gg/server/admin/receipt/controller/ReceiptAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/ReceiptAdminController.java similarity index 80% rename from src/main/java/com/gg/server/admin/receipt/controller/ReceiptAdminController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/ReceiptAdminController.java index 829b25a82..733aac2ba 100644 --- a/src/main/java/com/gg/server/admin/receipt/controller/ReceiptAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/ReceiptAdminController.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.receipt.controller; +package gg.pingpong.api.admin.store.controller; import javax.validation.Valid; @@ -10,10 +10,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.admin.receipt.dto.ReceiptAdminPageRequestDto; -import com.gg.server.admin.receipt.dto.ReceiptListResponseDto; -import com.gg.server.admin.receipt.service.ReceiptAdminService; - +import gg.pingpong.api.admin.store.controller.request.ReceiptAdminPageRequestDto; +import gg.pingpong.api.admin.store.controller.response.ReceiptListResponseDto; +import gg.pingpong.api.admin.store.service.ReceiptAdminService; import lombok.RequiredArgsConstructor; @RestController diff --git a/src/main/java/com/gg/server/admin/coin/dto/CoinUpdateRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request/CoinUpdateRequestDto.java similarity index 89% rename from src/main/java/com/gg/server/admin/coin/dto/CoinUpdateRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request/CoinUpdateRequestDto.java index 97e59c6aa..04cf48535 100644 --- a/src/main/java/com/gg/server/admin/coin/dto/CoinUpdateRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request/CoinUpdateRequestDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.coin.dto; +package gg.pingpong.api.admin.store.controller.request; import javax.validation.constraints.NotNull; diff --git a/src/main/java/com/gg/server/admin/item/dto/ItemUpdateRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request/ItemUpdateRequestDto.java similarity index 68% rename from src/main/java/com/gg/server/admin/item/dto/ItemUpdateRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request/ItemUpdateRequestDto.java index 7b5d841d8..f899e3d7b 100644 --- a/src/main/java/com/gg/server/admin/item/dto/ItemUpdateRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request/ItemUpdateRequestDto.java @@ -1,9 +1,11 @@ -package com.gg.server.admin.item.dto; +package gg.pingpong.api.admin.store.controller.request; -import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; -import com.gg.server.data.store.type.ItemType; +import javax.validation.constraints.NotNull; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.store.type.ItemType; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -30,6 +32,21 @@ public class ItemUpdateRequestDto { @NotNull(message = "[Request] 아이템 타입은 Null 일 수 없습니다.") private ItemType itemType; + public Item toItem(String imageUrl, String userIntraId) { + return Item.builder() + .name(name) + .mainContent(mainContent) + .subContent(subContent) + .price(price) + .discount(discount) + .imageUri(imageUrl) + .isVisible(true) + .type(itemType) + .createdAt(LocalDateTime.now()) + .creatorIntraId(userIntraId) + .build(); + } + @Override public String toString() { return "ItemUpdateRequestDto{" diff --git a/src/main/java/com/gg/server/admin/receipt/dto/ReceiptAdminPageRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request/ReceiptAdminPageRequestDto.java similarity index 70% rename from src/main/java/com/gg/server/admin/receipt/dto/ReceiptAdminPageRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request/ReceiptAdminPageRequestDto.java index 8437b9329..89a895eaa 100644 --- a/src/main/java/com/gg/server/admin/receipt/dto/ReceiptAdminPageRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request/ReceiptAdminPageRequestDto.java @@ -1,7 +1,6 @@ -package com.gg.server.admin.receipt.dto; - -import com.gg.server.global.dto.PageRequestDto; +package gg.pingpong.api.admin.store.controller.request; +import gg.pingpong.api.global.dto.PageRequestDto; import lombok.Getter; @Getter diff --git a/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/CoinPolicyAdminListResponseDto.java similarity index 83% rename from src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminListResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/CoinPolicyAdminListResponseDto.java index 8ac8d68f3..f78d98f94 100644 --- a/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/CoinPolicyAdminListResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.coin.dto; +package gg.pingpong.api.admin.store.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/CoinPolicyAdminResponseDto.java similarity index 88% rename from src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/CoinPolicyAdminResponseDto.java index 8e7a8130b..295db5445 100644 --- a/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/CoinPolicyAdminResponseDto.java @@ -1,9 +1,8 @@ -package com.gg.server.admin.coin.dto; +package gg.pingpong.api.admin.store.controller.response; import java.time.LocalDateTime; -import com.gg.server.data.manage.CoinPolicy; - +import gg.pingpong.data.store.CoinPolicy; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/item/dto/ItemHistoryResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ItemHistoryResponseDto.java similarity index 94% rename from src/main/java/com/gg/server/admin/item/dto/ItemHistoryResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ItemHistoryResponseDto.java index d6937d47a..e756f39b7 100644 --- a/src/main/java/com/gg/server/admin/item/dto/ItemHistoryResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ItemHistoryResponseDto.java @@ -1,9 +1,8 @@ -package com.gg.server.admin.item.dto; +package gg.pingpong.api.admin.store.controller.response; import java.time.LocalDateTime; -import com.gg.server.data.store.Item; - +import gg.pingpong.data.store.Item; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/item/dto/ItemListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ItemListResponseDto.java similarity index 82% rename from src/main/java/com/gg/server/admin/item/dto/ItemListResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ItemListResponseDto.java index b7f8dc8f2..d885cfe76 100644 --- a/src/main/java/com/gg/server/admin/item/dto/ItemListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ItemListResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.item.dto; +package gg.pingpong.api.admin.store.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/MegaphoneAdminResponseDto.java similarity index 85% rename from src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneAdminResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/MegaphoneAdminResponseDto.java index 423580aa0..8d7d7ec93 100644 --- a/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/MegaphoneAdminResponseDto.java @@ -1,7 +1,6 @@ -package com.gg.server.admin.megaphone.dto; - -import com.gg.server.data.store.Megaphone; +package gg.pingpong.api.admin.store.controller.response; +import gg.pingpong.data.store.Megaphone; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneHistoryResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/MegaphoneHistoryResponseDto.java similarity index 87% rename from src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneHistoryResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/MegaphoneHistoryResponseDto.java index bb5ac60d4..9ff53a483 100644 --- a/src/main/java/com/gg/server/admin/megaphone/dto/MegaphoneHistoryResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/MegaphoneHistoryResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.megaphone.dto; +package gg.pingpong.api.admin.store.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/admin/receipt/dto/ReceiptListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ReceiptListResponseDto.java similarity index 82% rename from src/main/java/com/gg/server/admin/receipt/dto/ReceiptListResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ReceiptListResponseDto.java index f9b69c700..04eee49d9 100644 --- a/src/main/java/com/gg/server/admin/receipt/dto/ReceiptListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ReceiptListResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.receipt.dto; +package gg.pingpong.api.admin.store.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/admin/receipt/dto/ReceiptResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ReceiptResponseDto.java similarity index 87% rename from src/main/java/com/gg/server/admin/receipt/dto/ReceiptResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ReceiptResponseDto.java index 1946bfa11..0a257d8d8 100644 --- a/src/main/java/com/gg/server/admin/receipt/dto/ReceiptResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ReceiptResponseDto.java @@ -1,11 +1,10 @@ -package com.gg.server.admin.receipt.dto; +package gg.pingpong.api.admin.store.controller.response; import java.time.LocalDateTime; -import com.gg.server.data.store.Item; -import com.gg.server.data.store.Receipt; -import com.gg.server.data.store.type.ItemStatus; - +import gg.pingpong.data.store.Item; +import gg.pingpong.data.store.Receipt; +import gg.pingpong.data.store.type.ItemStatus; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminAddDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/dto/CoinPolicyAdminAddDto.java similarity index 95% rename from src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminAddDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/dto/CoinPolicyAdminAddDto.java index e79c697ca..25d8d75eb 100644 --- a/src/main/java/com/gg/server/admin/coin/dto/CoinPolicyAdminAddDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/dto/CoinPolicyAdminAddDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.coin.dto; +package gg.pingpong.api.admin.store.dto; import javax.validation.constraints.NotNull; import javax.validation.constraints.PositiveOrZero; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinAdminService.java new file mode 100644 index 000000000..d25c3339f --- /dev/null +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinAdminService.java @@ -0,0 +1,28 @@ +package gg.pingpong.api.admin.store.service; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import gg.pingpong.api.admin.store.controller.request.CoinUpdateRequestDto; +import gg.pingpong.api.user.store.service.CoinHistoryService; +import gg.pingpong.data.store.CoinHistory; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.exception.user.UserNotFoundException; +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class CoinAdminService { + private final UserRepository userRepository; + private final CoinHistoryService coinHistoryService; + + @Transactional + public void updateUserCoin(CoinUpdateRequestDto coinUpdateRequestDto) { + User user = userRepository.findByIntraId(coinUpdateRequestDto.getIntraId()) + .orElseThrow(UserNotFoundException::new); + user.addGgCoin(coinUpdateRequestDto.getChange()); + coinHistoryService.addCoinHistory(new CoinHistory(user, coinUpdateRequestDto.getContent(), + coinUpdateRequestDto.getChange())); + } +} diff --git a/src/main/java/com/gg/server/admin/coin/service/CoinPolicyAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinPolicyAdminService.java similarity index 60% rename from src/main/java/com/gg/server/admin/coin/service/CoinPolicyAdminService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinPolicyAdminService.java index f01aec8cc..57157b48a 100644 --- a/src/main/java/com/gg/server/admin/coin/service/CoinPolicyAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinPolicyAdminService.java @@ -1,20 +1,19 @@ -package com.gg.server.admin.coin.service; +package gg.pingpong.api.admin.store.service; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.coin.data.CoinPolicyAdminRepository; -import com.gg.server.admin.coin.dto.CoinPolicyAdminAddDto; -import com.gg.server.admin.coin.dto.CoinPolicyAdminListResponseDto; -import com.gg.server.admin.coin.dto.CoinPolicyAdminResponseDto; -import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.data.manage.CoinPolicy; -import com.gg.server.data.user.User; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; - +import gg.pingpong.admin.repo.store.CoinPolicyAdminRepository; +import gg.pingpong.admin.repo.user.UserAdminRepository; +import gg.pingpong.api.admin.store.controller.response.CoinPolicyAdminListResponseDto; +import gg.pingpong.api.admin.store.controller.response.CoinPolicyAdminResponseDto; +import gg.pingpong.api.admin.store.dto.CoinPolicyAdminAddDto; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.store.CoinPolicy; +import gg.pingpong.data.user.User; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.AllArgsConstructor; @Service @@ -36,7 +35,8 @@ public CoinPolicyAdminListResponseDto findAllCoinPolicy(Pageable pageable) { public void addCoinPolicy(UserDto userDto, CoinPolicyAdminAddDto addDto) { User user = userAdminRepository.findByIntraId(userDto.getIntraId()).orElseThrow(UserNotFoundException::new); - CoinPolicy coinPolicy = CoinPolicy.from(user, addDto); + CoinPolicy coinPolicy = CoinPolicy.from(user, addDto.getAttendance(), addDto.getNormal(), + addDto.getRankWin(), addDto.getRankLose()); coinPolicyAdminRepository.save(coinPolicy); } } diff --git a/src/main/java/com/gg/server/admin/item/service/ItemAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ItemAdminService.java similarity index 80% rename from src/main/java/com/gg/server/admin/item/service/ItemAdminService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ItemAdminService.java index 680d96f11..77df9f02e 100644 --- a/src/main/java/com/gg/server/admin/item/service/ItemAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ItemAdminService.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.item.service; +package gg.pingpong.api.admin.store.service; import java.io.IOException; @@ -8,16 +8,15 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import com.gg.server.admin.item.data.ItemAdminRepository; -import com.gg.server.admin.item.dto.ItemHistoryResponseDto; -import com.gg.server.admin.item.dto.ItemListResponseDto; -import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.admin.item.exception.ItemNotFoundException; -import com.gg.server.data.store.Item; -import com.gg.server.domain.item.exception.ItemNotAvailableException; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.utils.aws.AsyncNewItemImageUploader; - +import gg.pingpong.admin.repo.store.ItemAdminRepository; +import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; +import gg.pingpong.api.admin.store.controller.response.ItemHistoryResponseDto; +import gg.pingpong.api.admin.store.controller.response.ItemListResponseDto; +import gg.pingpong.api.global.utils.aws.AsyncNewItemImageUploader; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.store.Item; +import gg.pingpong.utils.exception.item.ItemNotAvailableException; +import gg.pingpong.utils.exception.item.ItemNotFoundException; import lombok.RequiredArgsConstructor; @Service @@ -58,7 +57,7 @@ public void updateItem(Long itemId, ItemUpdateRequestDto itemUpdateRequestDto, throw new ItemNotAvailableException(); } item.setVisibility(user.getIntraId()); - Item newItem = new Item(itemUpdateRequestDto, user.getIntraId(), null); + Item newItem = itemUpdateRequestDto.toItem(null, user.getIntraId()); if (itemImageFile != null) { asyncNewItemImageUploader.upload(newItem, itemImageFile); } @@ -81,7 +80,7 @@ public void updateItem(Long itemId, ItemUpdateRequestDto itemUpdateRequestDto, U throw new ItemNotAvailableException(); } item.setVisibility(user.getIntraId()); - Item newItem = new Item(itemUpdateRequestDto, user.getIntraId(), item.getImageUri()); + Item newItem = itemUpdateRequestDto.toItem(item.getImageUri(), user.getIntraId()); itemAdminRepository.save(newItem); } diff --git a/src/main/java/com/gg/server/admin/megaphone/service/MegaphoneAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/MegaphoneAdminService.java similarity index 82% rename from src/main/java/com/gg/server/admin/megaphone/service/MegaphoneAdminService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/MegaphoneAdminService.java index badb35fb2..e4eea3c0b 100644 --- a/src/main/java/com/gg/server/admin/megaphone/service/MegaphoneAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/MegaphoneAdminService.java @@ -1,13 +1,12 @@ -package com.gg.server.admin.megaphone.service; +package gg.pingpong.api.admin.store.service; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; -import com.gg.server.admin.megaphone.data.MegaphoneAdminRepository; -import com.gg.server.admin.megaphone.dto.MegaphoneAdminResponseDto; -import com.gg.server.admin.megaphone.dto.MegaphoneHistoryResponseDto; - +import gg.pingpong.admin.repo.store.MegaphoneAdminRepository; +import gg.pingpong.api.admin.store.controller.response.MegaphoneAdminResponseDto; +import gg.pingpong.api.admin.store.controller.response.MegaphoneHistoryResponseDto; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ReceiptAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ReceiptAdminService.java new file mode 100644 index 000000000..05fadc1d1 --- /dev/null +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ReceiptAdminService.java @@ -0,0 +1,31 @@ +package gg.pingpong.api.admin.store.service; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import gg.pingpong.admin.repo.store.ReceiptAdminRepository; +import gg.pingpong.api.admin.store.controller.response.ReceiptListResponseDto; +import gg.pingpong.api.admin.store.controller.response.ReceiptResponseDto; +import gg.pingpong.data.store.Receipt; +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class ReceiptAdminService { + private final ReceiptAdminRepository receiptAdminRepository; + + @Transactional(readOnly = true) + public ReceiptListResponseDto getAllReceipt(Pageable pageable) { + Page responseDtos = receiptAdminRepository.findAll(pageable).map(ReceiptResponseDto::new); + return new ReceiptListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); + } + + @Transactional(readOnly = true) + public ReceiptListResponseDto findByIntraId(String intraId, Pageable pageable) { + Page receipts = receiptAdminRepository.findReceiptByIntraId(intraId, pageable); + Page responseDtos = receipts.map(ReceiptResponseDto::new); + return new ReceiptListResponseDto(responseDtos.getContent(), responseDtos.getTotalPages()); + } +} diff --git a/src/main/java/com/gg/server/admin/tournament/controller/TournamentAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminController.java similarity index 88% rename from src/main/java/com/gg/server/admin/tournament/controller/TournamentAdminController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminController.java index 47e0e8ecc..d7bc2ac5d 100644 --- a/src/main/java/com/gg/server/admin/tournament/controller/TournamentAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminController.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.tournament.controller; +package gg.pingpong.api.admin.tournament.controller; import javax.validation.Valid; import javax.validation.constraints.Positive; @@ -16,14 +16,13 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.admin.tournament.dto.TournamentAdminAddUserRequestDto; -import com.gg.server.admin.tournament.dto.TournamentAdminAddUserResponseDto; -import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; -import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; -import com.gg.server.admin.tournament.dto.TournamentGameUpdateRequestDto; -import com.gg.server.admin.tournament.service.TournamentAdminService; -import com.gg.server.domain.tournament.dto.TournamentUserListResponseDto; - +import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminAddUserRequestDto; +import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminCreateRequestDto; +import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminUpdateRequestDto; +import gg.pingpong.api.admin.tournament.controller.request.TournamentGameUpdateRequestDto; +import gg.pingpong.api.admin.tournament.controller.response.TournamentAdminAddUserResponseDto; +import gg.pingpong.api.admin.tournament.service.TournamentAdminService; +import gg.pingpong.api.user.tournament.controller.response.TournamentUserListResponseDto; import lombok.AllArgsConstructor; @RestController diff --git a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminAddUserRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminAddUserRequestDto.java similarity index 85% rename from src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminAddUserRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminAddUserRequestDto.java index bdc863500..afb5164e5 100644 --- a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminAddUserRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminAddUserRequestDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.tournament.dto; +package gg.pingpong.api.admin.tournament.controller.request; import javax.validation.constraints.NotNull; diff --git a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminCreateRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminCreateRequestDto.java similarity index 90% rename from src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminCreateRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminCreateRequestDto.java index 699351c7f..294e0b78f 100644 --- a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminCreateRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminCreateRequestDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.tournament.dto; +package gg.pingpong.api.admin.tournament.controller.request; import java.time.LocalDateTime; @@ -7,8 +7,7 @@ import org.hibernate.validator.constraints.Length; import org.springframework.format.annotation.DateTimeFormat; -import com.gg.server.data.game.type.TournamentType; - +import gg.pingpong.data.tournament.type.TournamentType; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminUpdateRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminUpdateRequestDto.java similarity index 85% rename from src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminUpdateRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminUpdateRequestDto.java index 46d22ecc7..9dbfd00a1 100644 --- a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminUpdateRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminUpdateRequestDto.java @@ -1,17 +1,14 @@ -package com.gg.server.admin.tournament.dto; +package gg.pingpong.api.admin.tournament.controller.request; import java.time.LocalDateTime; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; import javax.validation.constraints.NotNull; import org.hibernate.validator.constraints.Length; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat.ISO; -import com.gg.server.data.game.type.TournamentType; - +import gg.pingpong.data.tournament.type.TournamentType; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -38,6 +35,5 @@ public class TournamentAdminUpdateRequestDto { private LocalDateTime endTime; @NotNull(message = "토너먼트 종류가 필요합니다.") - @Enumerated(EnumType.STRING) private TournamentType type; } diff --git a/src/main/java/com/gg/server/admin/tournament/dto/TournamentGameUpdateRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentGameUpdateRequestDto.java similarity index 86% rename from src/main/java/com/gg/server/admin/tournament/dto/TournamentGameUpdateRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentGameUpdateRequestDto.java index 317dafcbc..7229861cc 100644 --- a/src/main/java/com/gg/server/admin/tournament/dto/TournamentGameUpdateRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentGameUpdateRequestDto.java @@ -1,10 +1,9 @@ -package com.gg.server.admin.tournament.dto; +package gg.pingpong.api.admin.tournament.controller.request; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import com.gg.server.domain.team.dto.TeamReqDto; - +import gg.pingpong.api.user.game.dto.TeamReqDto; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminAddUserResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/response/TournamentAdminAddUserResponseDto.java similarity index 83% rename from src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminAddUserResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/response/TournamentAdminAddUserResponseDto.java index 083ea72c9..5bf87d581 100644 --- a/src/main/java/com/gg/server/admin/tournament/dto/TournamentAdminAddUserResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/response/TournamentAdminAddUserResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.tournament.dto; +package gg.pingpong.api.admin.tournament.controller.response; import lombok.AccessLevel; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/service/TournamentAdminService.java similarity index 86% rename from src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/service/TournamentAdminService.java index 4d6c9666b..4dfeac73b 100644 --- a/src/main/java/com/gg/server/admin/tournament/service/TournamentAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/service/TournamentAdminService.java @@ -1,6 +1,6 @@ -package com.gg.server.admin.tournament.service; +package gg.pingpong.api.admin.tournament.service; -import static com.gg.server.data.match.type.TournamentMatchStatus.*; +import static gg.pingpong.data.match.type.TournamentMatchStatus.*; import java.time.LocalDate; import java.time.LocalDateTime; @@ -10,43 +10,42 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.tournament.dto.TournamentAdminAddUserRequestDto; -import com.gg.server.admin.tournament.dto.TournamentAdminAddUserResponseDto; -import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; -import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; -import com.gg.server.admin.tournament.dto.TournamentGameUpdateRequestDto; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Team; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.TournamentUser; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.match.type.TournamentMatchStatus; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.exception.ScoreNotInvalidException; -import com.gg.server.domain.game.service.GameService; -import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.match.service.MatchTournamentService; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tournament.data.TournamentGameRepository; -import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.data.TournamentUserRepository; -import com.gg.server.domain.tournament.dto.TournamentUserListResponseDto; -import com.gg.server.domain.tournament.exception.TournamentConflictException; -import com.gg.server.domain.tournament.exception.TournamentGameNotFoundException; -import com.gg.server.domain.tournament.exception.TournamentNotFoundException; -import com.gg.server.domain.tournament.exception.TournamentUpdateException; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.global.config.ConstantConfig; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.InvalidParameterException; - +import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminAddUserRequestDto; +import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminCreateRequestDto; +import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminUpdateRequestDto; +import gg.pingpong.api.admin.tournament.controller.request.TournamentGameUpdateRequestDto; +import gg.pingpong.api.admin.tournament.controller.response.TournamentAdminAddUserResponseDto; +import gg.pingpong.api.global.config.ConstantConfig; +import gg.pingpong.api.user.game.service.GameService; +import gg.pingpong.api.user.match.service.MatchTournamentService; +import gg.pingpong.api.user.tournament.controller.response.TournamentUserListResponseDto; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.match.type.TournamentMatchStatus; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.TournamentUser; +import gg.pingpong.data.tournament.type.TournamentRound; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.repo.tournarment.TournamentGameRepository; +import gg.pingpong.repo.tournarment.TournamentRepository; +import gg.pingpong.repo.tournarment.TournamentUserRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.InvalidParameterException; +import gg.pingpong.utils.exception.game.ScoreNotInvalidException; +import gg.pingpong.utils.exception.match.SlotNotFoundException; +import gg.pingpong.utils.exception.tournament.TournamentConflictException; +import gg.pingpong.utils.exception.tournament.TournamentGameNotFoundException; +import gg.pingpong.utils.exception.tournament.TournamentNotFoundException; +import gg.pingpong.utils.exception.tournament.TournamentUpdateException; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/admin/user/controller/UserAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/UserAdminController.java similarity index 87% rename from src/main/java/com/gg/server/admin/user/controller/UserAdminController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/UserAdminController.java index a260d2e41..e9185d4d1 100644 --- a/src/main/java/com/gg/server/admin/user/controller/UserAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/UserAdminController.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.user.controller; +package gg.pingpong.api.admin.user.controller; import java.io.IOException; @@ -18,16 +18,15 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import com.gg.server.admin.user.dto.UserDetailAdminResponseDto; -import com.gg.server.admin.user.dto.UserImageListAdminResponseDto; -import com.gg.server.admin.user.dto.UserSearchAdminRequestDto; -import com.gg.server.admin.user.dto.UserSearchAdminResponseDto; -import com.gg.server.admin.user.dto.UserUpdateAdminRequestDto; -import com.gg.server.admin.user.service.UserAdminService; -import com.gg.server.domain.user.exception.UserImageLargeException; -import com.gg.server.domain.user.exception.UserImageTypeException; -import com.gg.server.global.dto.PageRequestDto; - +import gg.pingpong.api.admin.user.controller.request.UserSearchAdminRequestDto; +import gg.pingpong.api.admin.user.controller.request.UserUpdateAdminRequestDto; +import gg.pingpong.api.admin.user.controller.response.UserDetailAdminResponseDto; +import gg.pingpong.api.admin.user.controller.response.UserImageListAdminResponseDto; +import gg.pingpong.api.admin.user.controller.response.UserSearchAdminResponseDto; +import gg.pingpong.api.admin.user.service.UserAdminService; +import gg.pingpong.api.global.dto.PageRequestDto; +import gg.pingpong.utils.exception.user.UserImageLargeException; +import gg.pingpong.utils.exception.user.UserImageTypeException; import lombok.AllArgsConstructor; @RestController diff --git a/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/request/UserSearchAdminRequestDto.java similarity index 77% rename from src/main/java/com/gg/server/admin/user/dto/UserSearchAdminRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/request/UserSearchAdminRequestDto.java index e60edae04..13eb69f47 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/request/UserSearchAdminRequestDto.java @@ -1,7 +1,6 @@ -package com.gg.server.admin.user.dto; - -import com.gg.server.global.dto.PageRequestDto; +package gg.pingpong.api.admin.user.controller.request; +import gg.pingpong.api.global.dto.PageRequestDto; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/gg/server/admin/user/dto/UserUpdateAdminRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/request/UserUpdateAdminRequestDto.java similarity index 87% rename from src/main/java/com/gg/server/admin/user/dto/UserUpdateAdminRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/request/UserUpdateAdminRequestDto.java index f5cfbde79..25e3f0c44 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserUpdateAdminRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/request/UserUpdateAdminRequestDto.java @@ -1,7 +1,6 @@ -package com.gg.server.admin.user.dto; - -import com.gg.server.data.user.type.RacketType; +package gg.pingpong.api.admin.user.controller.request; +import gg.pingpong.data.user.type.RacketType; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/user/dto/UserDetailAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response/UserDetailAdminResponseDto.java similarity index 93% rename from src/main/java/com/gg/server/admin/user/dto/UserDetailAdminResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response/UserDetailAdminResponseDto.java index 9dc762736..8440e0f2f 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserDetailAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response/UserDetailAdminResponseDto.java @@ -1,8 +1,7 @@ -package com.gg.server.admin.user.dto; - -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.user.User; +package gg.pingpong.api.admin.user.controller.response; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.user.User; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/user/dto/UserImageListAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response/UserImageListAdminResponseDto.java similarity index 71% rename from src/main/java/com/gg/server/admin/user/dto/UserImageListAdminResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response/UserImageListAdminResponseDto.java index 11c731298..0ce28e093 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserImageListAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response/UserImageListAdminResponseDto.java @@ -1,7 +1,8 @@ -package com.gg.server.admin.user.dto; +package gg.pingpong.api.admin.user.controller.response; import java.util.List; +import gg.pingpong.api.admin.user.dto.UserImageAdminDto; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response/UserSearchAdminResponseDto.java similarity index 85% rename from src/main/java/com/gg/server/admin/user/dto/UserSearchAdminResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response/UserSearchAdminResponseDto.java index fcc0ae89f..03afcd776 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response/UserSearchAdminResponseDto.java @@ -1,8 +1,9 @@ -package com.gg.server.admin.user.dto; +package gg.pingpong.api.admin.user.controller.response; import java.util.List; import java.util.stream.Collectors; +import gg.pingpong.api.admin.user.dto.UserSearchAdminDto; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/user/dto/UserAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserAdminDto.java similarity index 81% rename from src/main/java/com/gg/server/admin/user/dto/UserAdminDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserAdminDto.java index b22c3c891..e2f6ff4e4 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserAdminDto.java @@ -1,11 +1,10 @@ -package com.gg.server.admin.user.dto; - -import com.gg.server.data.user.User; -import com.gg.server.data.user.UserImage; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; +package gg.pingpong.api.admin.user.dto; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.UserImage; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/gg/server/admin/user/dto/UserImageAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserImageAdminDto.java similarity index 88% rename from src/main/java/com/gg/server/admin/user/dto/UserImageAdminDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserImageAdminDto.java index 13c00c082..29bcdfe22 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserImageAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserImageAdminDto.java @@ -1,9 +1,8 @@ -package com.gg.server.admin.user.dto; +package gg.pingpong.api.admin.user.dto; import java.time.LocalDateTime; -import com.gg.server.data.user.UserImage; - +import gg.pingpong.data.user.UserImage; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserSearchAdminDto.java similarity index 83% rename from src/main/java/com/gg/server/admin/user/dto/UserSearchAdminDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserSearchAdminDto.java index 535010e5d..7d2766c6a 100644 --- a/src/main/java/com/gg/server/admin/user/dto/UserSearchAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserSearchAdminDto.java @@ -1,8 +1,7 @@ -package com.gg.server.admin.user.dto; - -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RoleType; +package gg.pingpong.api.admin.user.dto; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RoleType; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/admin/user/service/UserAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/service/UserAdminService.java similarity index 81% rename from src/main/java/com/gg/server/admin/user/service/UserAdminService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/service/UserAdminService.java index 9b99edacb..7b5052fb4 100644 --- a/src/main/java/com/gg/server/admin/user/service/UserAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/service/UserAdminService.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.user.service; +package gg.pingpong.api.admin.user.service; import java.io.IOException; import java.time.LocalDateTime; @@ -11,31 +11,31 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import com.gg.server.admin.rank.service.RankRedisAdminService; -import com.gg.server.admin.season.data.SeasonAdminRepository; -import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.admin.user.data.UserImageAdminRepository; -import com.gg.server.admin.user.dto.UserDetailAdminResponseDto; -import com.gg.server.admin.user.dto.UserImageAdminDto; -import com.gg.server.admin.user.dto.UserImageListAdminResponseDto; -import com.gg.server.admin.user.dto.UserSearchAdminDto; -import com.gg.server.admin.user.dto.UserSearchAdminResponseDto; -import com.gg.server.admin.user.dto.UserUpdateAdminRequestDto; -import com.gg.server.data.game.Rank; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.user.User; -import com.gg.server.data.user.UserImage; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.exception.RankNotFoundException; -import com.gg.server.domain.rank.exception.RedisDataNotFoundException; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.exception.SeasonNotFoundException; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.service.UserFindService; -import com.gg.server.global.utils.aws.AsyncNewUserImageUploader; - +import gg.pingpong.admin.repo.season.SeasonAdminRepository; +import gg.pingpong.admin.repo.user.UserAdminRepository; +import gg.pingpong.admin.repo.user.UserImageAdminRepository; +import gg.pingpong.api.admin.rank.service.RankRedisAdminService; +import gg.pingpong.api.admin.user.controller.request.UserUpdateAdminRequestDto; +import gg.pingpong.api.admin.user.controller.response.UserDetailAdminResponseDto; +import gg.pingpong.api.admin.user.controller.response.UserImageListAdminResponseDto; +import gg.pingpong.api.admin.user.controller.response.UserSearchAdminResponseDto; +import gg.pingpong.api.admin.user.dto.UserImageAdminDto; +import gg.pingpong.api.admin.user.dto.UserSearchAdminDto; +import gg.pingpong.api.global.utils.aws.AsyncNewUserImageUploader; +import gg.pingpong.api.user.user.service.UserFindService; +import gg.pingpong.data.rank.Rank; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.UserImage; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.exception.rank.RankNotFoundException; +import gg.pingpong.utils.exception.rank.RedisDataNotFoundException; +import gg.pingpong.utils.exception.season.SeasonNotFoundException; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.AllArgsConstructor; @Service @@ -86,7 +86,7 @@ public UserSearchAdminResponseDto findByPartsOfIntraId(String intraId, Pageable public UserDetailAdminResponseDto getUserDetailByIntraId(String intraId) { User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); Season currSeason = seasonAdminRepository.findCurrentSeason(LocalDateTime.now()) - .orElseThrow(() -> new SeasonNotFoundException()); + .orElseThrow(SeasonNotFoundException::new); try { RankRedis userCurrRank = rankRedisRepository.findRankByUserId( RedisKeyManager.getHashKey(currSeason.getId()), @@ -105,7 +105,8 @@ public void updateUserDetail(String intraId, .orElseThrow(() -> new SeasonNotFoundException()); User user = userAdminRepository.findByIntraId(intraId).orElseThrow(UserNotFoundException::new); - user.modifyUserDetail(userUpdateAdminRequestDto); + user.modifyUserDetail(userUpdateAdminRequestDto.getEmail(), userUpdateAdminRequestDto.getRacketType(), + RoleType.of(userUpdateAdminRequestDto.getRoleType()), userUpdateAdminRequestDto.getCoin()); if (userImageFile != null) { asyncNewUserImageUploader.update(intraId, userImageFile); } @@ -114,11 +115,13 @@ public void updateUserDetail(String intraId, private void updateUserRank(Long userId, Long currSeasonId, UserUpdateAdminRequestDto updateReq) { Rank userCurrRank = rankRepository.findByUserIdAndSeasonId(userId, currSeasonId) - .orElseThrow(() -> new RankNotFoundException()); + .orElseThrow(RankNotFoundException::new); RankRedis userCurrRankRedis = rankRedisRepository.findRankByUserId(RedisKeyManager.getHashKey(currSeasonId), userId); - userCurrRank.modifyUserRank(updateReq); + userCurrRank.modifyUserRank(updateReq.getPpp(), + updateReq.getWins(), + updateReq.getLosses()); userCurrRank.setStatusMessage(updateReq.getStatusMessage()); userCurrRankRedis.changedRank(updateReq.getPpp(), diff --git a/src/main/java/com/gg/server/global/config/AWSConfig.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/AWSConfig.java similarity index 96% rename from src/main/java/com/gg/server/global/config/AWSConfig.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/AWSConfig.java index ba9e35ab9..358d0dd99 100644 --- a/src/main/java/com/gg/server/global/config/AWSConfig.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/AWSConfig.java @@ -1,4 +1,4 @@ -package com.gg.server.global.config; +package gg.pingpong.api.global.config; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; diff --git a/src/main/java/com/gg/server/global/config/AsyncConfiguration.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/AsyncConfiguration.java similarity index 96% rename from src/main/java/com/gg/server/global/config/AsyncConfiguration.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/AsyncConfiguration.java index dec8efe83..de843ca2c 100644 --- a/src/main/java/com/gg/server/global/config/AsyncConfiguration.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/AsyncConfiguration.java @@ -1,4 +1,4 @@ -package com.gg.server.global.config; +package gg.pingpong.api.global.config; import java.util.concurrent.Executor; diff --git a/src/main/java/com/gg/server/global/config/ConstantConfig.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/ConstantConfig.java similarity index 92% rename from src/main/java/com/gg/server/global/config/ConstantConfig.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/ConstantConfig.java index fc5299997..e06151534 100644 --- a/src/main/java/com/gg/server/global/config/ConstantConfig.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/ConstantConfig.java @@ -1,4 +1,4 @@ -package com.gg.server.global.config; +package gg.pingpong.api.global.config; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/src/main/java/com/gg/server/global/config/JpaAuditingConfig.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/JpaAuditingConfig.java similarity index 84% rename from src/main/java/com/gg/server/global/config/JpaAuditingConfig.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/JpaAuditingConfig.java index cad341081..5405f9fbe 100644 --- a/src/main/java/com/gg/server/global/config/JpaAuditingConfig.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/JpaAuditingConfig.java @@ -1,4 +1,4 @@ -package com.gg.server.global.config; +package gg.pingpong.api.global.config; import org.springframework.context.annotation.Configuration; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/JpaConfig.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/JpaConfig.java new file mode 100644 index 000000000..eb18297a6 --- /dev/null +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/JpaConfig.java @@ -0,0 +1,11 @@ +package gg.pingpong.api.global.config; + +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; + +@Configuration +@EnableJpaRepositories(basePackages = {"gg.pingpong.repo", "gg.pingpong.admin.repo"}) +@EntityScan(basePackages = "gg.pingpong.data") +public class JpaConfig { +} diff --git a/src/main/java/com/gg/server/global/config/RedisConfig.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/RedisConfig.java similarity index 99% rename from src/main/java/com/gg/server/global/config/RedisConfig.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/RedisConfig.java index 6663f61d1..90726d80c 100644 --- a/src/main/java/com/gg/server/global/config/RedisConfig.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/RedisConfig.java @@ -1,4 +1,4 @@ -package com.gg.server.global.config; +package gg.pingpong.api.global.config; import java.time.Duration; diff --git a/src/main/java/com/gg/server/global/config/SwaggerConfig.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/SwaggerConfig.java similarity index 94% rename from src/main/java/com/gg/server/global/config/SwaggerConfig.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/SwaggerConfig.java index 5f13738ca..7af1049e5 100644 --- a/src/main/java/com/gg/server/global/config/SwaggerConfig.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/SwaggerConfig.java @@ -1,4 +1,4 @@ -package com.gg.server.global.config; +package gg.pingpong.api.global.config; import org.springdoc.core.GroupedOpenApi; import org.springframework.context.annotation.Bean; @@ -18,7 +18,7 @@ public GroupedOpenApi group1() { return GroupedOpenApi.builder() .group("pingpong") .pathsToMatch("/pingpong/**") - .packagesToScan("com.gg.server.domain") + .packagesToScan("gg.pingpong.api.user") .build(); } diff --git a/src/main/java/com/gg/server/global/config/TimeZoneConfiguration.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/TimeZoneConfiguration.java similarity index 88% rename from src/main/java/com/gg/server/global/config/TimeZoneConfiguration.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/TimeZoneConfiguration.java index a71ff7603..c19f8d3ea 100644 --- a/src/main/java/com/gg/server/global/config/TimeZoneConfiguration.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/TimeZoneConfiguration.java @@ -1,4 +1,4 @@ -package com.gg.server.global.config; +package gg.pingpong.api.global.config; import java.util.TimeZone; diff --git a/src/main/java/com/gg/server/global/config/WebConfig.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/WebConfig.java similarity index 74% rename from src/main/java/com/gg/server/global/config/WebConfig.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/WebConfig.java index 9924a798a..623654413 100644 --- a/src/main/java/com/gg/server/global/config/WebConfig.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/WebConfig.java @@ -1,4 +1,4 @@ -package com.gg.server.global.config; +package gg.pingpong.api.global.config; import java.util.List; @@ -7,11 +7,10 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.global.utils.argumentresolver.LoginMemberArgumentResolver; -import com.gg.server.global.utils.querytracker.LoggingInterceptor; - +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.global.utils.argumentresolver.LoginMemberArgumentResolver; +import gg.pingpong.api.global.utils.querytracker.LoggingInterceptor; +import gg.pingpong.repo.user.UserRepository; import lombok.RequiredArgsConstructor; @Configuration diff --git a/src/main/java/com/gg/server/global/dto/PageRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/dto/PageRequestDto.java similarity index 94% rename from src/main/java/com/gg/server/global/dto/PageRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/dto/PageRequestDto.java index 12a1c5ea6..868992210 100644 --- a/src/main/java/com/gg/server/global/dto/PageRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/dto/PageRequestDto.java @@ -1,4 +1,4 @@ -package com.gg.server.global.dto; +package gg.pingpong.api.global.dto; import javax.validation.constraints.Max; import javax.validation.constraints.Min; diff --git a/src/main/java/com/gg/server/global/exception/GlobalExceptionHandler.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/exception/GlobalExceptionHandler.java similarity index 90% rename from src/main/java/com/gg/server/global/exception/GlobalExceptionHandler.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/exception/GlobalExceptionHandler.java index f99c58373..c400ac1de 100644 --- a/src/main/java/com/gg/server/global/exception/GlobalExceptionHandler.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/exception/GlobalExceptionHandler.java @@ -1,4 +1,4 @@ -package com.gg.server.global.exception; +package gg.pingpong.api.global.exception; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -12,14 +12,16 @@ import com.amazonaws.AmazonServiceException; import com.amazonaws.SdkClientException; -import com.gg.server.global.exception.custom.AuthenticationException; -import com.gg.server.global.exception.custom.CustomRuntimeException; -import com.gg.server.global.exception.custom.DBConsistencyException; -import com.gg.server.global.exception.custom.DuplicationException; -import com.gg.server.global.exception.custom.ForbiddenException; -import com.gg.server.global.exception.custom.NotExistException; -import com.gg.server.global.exception.custom.PageNotFoundException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.ErrorResponse; +import gg.pingpong.utils.exception.custom.AuthenticationException; +import gg.pingpong.utils.exception.custom.CustomRuntimeException; +import gg.pingpong.utils.exception.custom.DBConsistencyException; +import gg.pingpong.utils.exception.custom.DuplicationException; +import gg.pingpong.utils.exception.custom.ForbiddenException; +import gg.pingpong.utils.exception.custom.NotExistException; +import gg.pingpong.utils.exception.custom.PageNotFoundException; import lombok.extern.slf4j.Slf4j; @Slf4j diff --git a/src/main/java/com/gg/server/global/log/annotation/Trace.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/annotation/Trace.java similarity index 84% rename from src/main/java/com/gg/server/global/log/annotation/Trace.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/annotation/Trace.java index 2a71f4788..cf362b3c0 100644 --- a/src/main/java/com/gg/server/global/log/annotation/Trace.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/annotation/Trace.java @@ -1,4 +1,4 @@ -package com.gg.server.global.log.annotation; +package gg.pingpong.api.global.log.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/com/gg/server/global/log/aspect/TraceAspect.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/aspect/TraceAspect.java similarity index 75% rename from src/main/java/com/gg/server/global/log/aspect/TraceAspect.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/aspect/TraceAspect.java index 2b5e26916..0e41ba5fa 100644 --- a/src/main/java/com/gg/server/global/log/aspect/TraceAspect.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/aspect/TraceAspect.java @@ -1,4 +1,4 @@ -package com.gg.server.global.log.aspect; +package gg.pingpong.api.global.log.aspect; import java.util.Arrays; @@ -9,9 +9,8 @@ import org.aspectj.lang.reflect.MethodSignature; import org.springframework.stereotype.Component; -import com.gg.server.global.log.domain.TraceStatus; -import com.gg.server.global.log.service.LogTrace; - +import gg.pingpong.api.global.log.domain.TraceStatus; +import gg.pingpong.api.global.log.service.LogTrace; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -22,19 +21,19 @@ public class TraceAspect { private final LogTrace logTrace; - @Pointcut("execution(* com.gg.server.admin..*(..))") + @Pointcut("execution(* gg.pingpong.api.admin..*(..))") public void allAdmin() { } - @Pointcut("execution(* com.gg.server.domain..*(..))") + @Pointcut("execution(* gg.pingpong.api.user..*(..))") public void allDomain() { } - @Pointcut("execution(* com.gg.server.global.security..*(..))") + @Pointcut("execution(* gg.pingpong.api.global.security..*(..))") public void securityDomain() { } - @Pointcut("execution(* com.gg.server.global.scheduler..*(..))") + @Pointcut("execution(* gg.pingpong.api.global.scheduler..*(..))") public void scheduler() { } diff --git a/src/main/java/com/gg/server/global/log/domain/TraceId.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/domain/TraceId.java similarity index 93% rename from src/main/java/com/gg/server/global/log/domain/TraceId.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/domain/TraceId.java index 53985fe51..b4e3c1ada 100644 --- a/src/main/java/com/gg/server/global/log/domain/TraceId.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/domain/TraceId.java @@ -1,4 +1,4 @@ -package com.gg.server.global.log.domain; +package gg.pingpong.api.global.log.domain; import java.util.UUID; diff --git a/src/main/java/com/gg/server/global/log/domain/TraceStatus.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/domain/TraceStatus.java similarity index 87% rename from src/main/java/com/gg/server/global/log/domain/TraceStatus.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/domain/TraceStatus.java index 8ccf90140..99e180c88 100644 --- a/src/main/java/com/gg/server/global/log/domain/TraceStatus.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/domain/TraceStatus.java @@ -1,4 +1,4 @@ -package com.gg.server.global.log.domain; +package gg.pingpong.api.global.log.domain; import lombok.Getter; diff --git a/src/main/java/com/gg/server/global/log/pointcut/TracePointcut.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/pointcut/TracePointcut.java similarity index 76% rename from src/main/java/com/gg/server/global/log/pointcut/TracePointcut.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/pointcut/TracePointcut.java index 2033f77cb..082cc3bc7 100644 --- a/src/main/java/com/gg/server/global/log/pointcut/TracePointcut.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/pointcut/TracePointcut.java @@ -1,9 +1,9 @@ -package com.gg.server.global.log.pointcut; +package gg.pingpong.api.global.log.pointcut; import org.aspectj.lang.annotation.Pointcut; public class TracePointcut { - @Pointcut("execution(* com.gg.server.domain..*(..))") + @Pointcut("execution(* gg.pingpong.api.user..*(..))") public void allDomain() { } diff --git a/src/main/java/com/gg/server/global/log/service/LogTrace.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/service/LogTrace.java similarity index 60% rename from src/main/java/com/gg/server/global/log/service/LogTrace.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/service/LogTrace.java index 5c4a6436a..a7d70b478 100644 --- a/src/main/java/com/gg/server/global/log/service/LogTrace.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/service/LogTrace.java @@ -1,6 +1,6 @@ -package com.gg.server.global.log.service; +package gg.pingpong.api.global.log.service; -import com.gg.server.global.log.domain.TraceStatus; +import gg.pingpong.api.global.log.domain.TraceStatus; public interface LogTrace { TraceStatus begin(String message); diff --git a/src/main/java/com/gg/server/global/log/service/ThreadLocalLogTrace.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/service/ThreadLocalLogTrace.java similarity index 92% rename from src/main/java/com/gg/server/global/log/service/ThreadLocalLogTrace.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/service/ThreadLocalLogTrace.java index 712b72ae9..db9c037c1 100644 --- a/src/main/java/com/gg/server/global/log/service/ThreadLocalLogTrace.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/log/service/ThreadLocalLogTrace.java @@ -1,10 +1,9 @@ -package com.gg.server.global.log.service; +package gg.pingpong.api.global.log.service; import org.springframework.stereotype.Component; -import com.gg.server.global.log.domain.TraceId; -import com.gg.server.global.log.domain.TraceStatus; - +import gg.pingpong.api.global.log.domain.TraceId; +import gg.pingpong.api.global.log.domain.TraceStatus; import lombok.extern.slf4j.Slf4j; @Slf4j @@ -30,6 +29,7 @@ public void end(TraceStatus status) { complete(status, null); } + @Override public void exception(TraceStatus status, Exception exception) { if (status != null) { complete(status, exception); diff --git a/src/main/java/com/gg/server/global/scheduler/AbstractScheduler.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/scheduler/AbstractScheduler.java similarity index 95% rename from src/main/java/com/gg/server/global/scheduler/AbstractScheduler.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/scheduler/AbstractScheduler.java index 2d8cc0073..8dd5c1598 100644 --- a/src/main/java/com/gg/server/global/scheduler/AbstractScheduler.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/scheduler/AbstractScheduler.java @@ -1,4 +1,4 @@ -package com.gg.server.global.scheduler; +package gg.pingpong.api.global.scheduler; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; diff --git a/src/main/java/com/gg/server/global/scheduler/GameStatusScheduler.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/scheduler/GameStatusScheduler.java similarity index 86% rename from src/main/java/com/gg/server/global/scheduler/GameStatusScheduler.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/scheduler/GameStatusScheduler.java index 04204674d..ce06d61ee 100644 --- a/src/main/java/com/gg/server/global/scheduler/GameStatusScheduler.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/scheduler/GameStatusScheduler.java @@ -1,9 +1,8 @@ -package com.gg.server.global.scheduler; +package gg.pingpong.api.global.scheduler; import org.springframework.stereotype.Component; -import com.gg.server.domain.game.service.GameStatusService; - +import gg.pingpong.api.user.game.service.GameStatusService; import lombok.extern.slf4j.Slf4j; @Component diff --git a/src/main/java/com/gg/server/global/scheduler/MegaphoneScheduler.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/scheduler/MegaphoneScheduler.java similarity index 83% rename from src/main/java/com/gg/server/global/scheduler/MegaphoneScheduler.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/scheduler/MegaphoneScheduler.java index ed98c5548..c14b1961e 100644 --- a/src/main/java/com/gg/server/global/scheduler/MegaphoneScheduler.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/scheduler/MegaphoneScheduler.java @@ -1,11 +1,10 @@ -package com.gg.server.global.scheduler; +package gg.pingpong.api.global.scheduler; import java.time.LocalDate; import org.springframework.stereotype.Component; -import com.gg.server.domain.megaphone.service.MegaphoneService; - +import gg.pingpong.api.user.store.service.MegaphoneService; import lombok.extern.slf4j.Slf4j; @Component diff --git a/src/main/java/com/gg/server/global/scheduler/TournamentScheduler.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/scheduler/TournamentScheduler.java similarity index 81% rename from src/main/java/com/gg/server/global/scheduler/TournamentScheduler.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/scheduler/TournamentScheduler.java index d6a9ed249..2929d3b92 100644 --- a/src/main/java/com/gg/server/global/scheduler/TournamentScheduler.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/scheduler/TournamentScheduler.java @@ -1,10 +1,9 @@ -package com.gg.server.global.scheduler; +package gg.pingpong.api.global.scheduler; import org.springframework.stereotype.Component; -import com.gg.server.domain.tournament.service.TournamentService; -import com.gg.server.global.config.ConstantConfig; - +import gg.pingpong.api.global.config.ConstantConfig; +import gg.pingpong.api.user.tournament.service.TournamentService; import lombok.extern.slf4j.Slf4j; @Component diff --git a/src/main/java/com/gg/server/global/security/UserPrincipal.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/UserPrincipal.java similarity index 94% rename from src/main/java/com/gg/server/global/security/UserPrincipal.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/UserPrincipal.java index e71f15a74..64d2a86b0 100644 --- a/src/main/java/com/gg/server/global/security/UserPrincipal.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/UserPrincipal.java @@ -1,4 +1,4 @@ -package com.gg.server.global.security; +package gg.pingpong.api.global.security; import java.util.ArrayList; import java.util.Collection; @@ -10,9 +10,8 @@ import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.oauth2.core.user.OAuth2User; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RoleType; - +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RoleType; import lombok.Getter; @Getter diff --git a/src/main/java/com/gg/server/global/security/config/RestAuthenticationEntryPoint.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/config/RestAuthenticationEntryPoint.java similarity index 94% rename from src/main/java/com/gg/server/global/security/config/RestAuthenticationEntryPoint.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/config/RestAuthenticationEntryPoint.java index 6d5f37d26..2aa870794 100644 --- a/src/main/java/com/gg/server/global/security/config/RestAuthenticationEntryPoint.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/config/RestAuthenticationEntryPoint.java @@ -1,4 +1,4 @@ -package com.gg.server.global.security.config; +package gg.pingpong.api.global.security.config; import java.io.IOException; diff --git a/src/main/java/com/gg/server/global/security/config/SecurityConfig.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/config/SecurityConfig.java similarity index 89% rename from src/main/java/com/gg/server/global/security/config/SecurityConfig.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/config/SecurityConfig.java index 6b9bb0710..d753dc531 100644 --- a/src/main/java/com/gg/server/global/security/config/SecurityConfig.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/config/SecurityConfig.java @@ -1,4 +1,4 @@ -package com.gg.server.global.security.config; +package gg.pingpong.api.global.security.config; import java.util.Arrays; @@ -14,12 +14,11 @@ import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; -import com.gg.server.global.security.config.properties.CorsProperties; -import com.gg.server.global.security.handler.OAuthAuthenticationSuccessHandler; -import com.gg.server.global.security.jwt.utils.TokenAuthenticationFilter; -import com.gg.server.global.security.repository.OAuthAuthorizationRequestBasedOnCookieRepository; -import com.gg.server.global.security.service.CustomUserDetailsService; - +import gg.pingpong.api.global.security.config.properties.CorsProperties; +import gg.pingpong.api.global.security.handler.OAuthAuthenticationSuccessHandler; +import gg.pingpong.api.global.security.jwt.utils.TokenAuthenticationFilter; +import gg.pingpong.api.global.security.repository.OAuthAuthorizationRequestBasedOnCookieRepository; +import gg.pingpong.api.global.security.service.CustomUserDetailsService; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/main/java/com/gg/server/global/security/config/properties/AppProperties.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/config/properties/AppProperties.java similarity index 94% rename from src/main/java/com/gg/server/global/security/config/properties/AppProperties.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/config/properties/AppProperties.java index 4b38ee69b..7d3a828ae 100644 --- a/src/main/java/com/gg/server/global/security/config/properties/AppProperties.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/config/properties/AppProperties.java @@ -1,4 +1,4 @@ -package com.gg.server.global.security.config.properties; +package gg.pingpong.api.global.security.config.properties; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/gg/server/global/security/config/properties/CorsProperties.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/config/properties/CorsProperties.java similarity index 87% rename from src/main/java/com/gg/server/global/security/config/properties/CorsProperties.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/config/properties/CorsProperties.java index 4efc120f1..34adeda16 100644 --- a/src/main/java/com/gg/server/global/security/config/properties/CorsProperties.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/config/properties/CorsProperties.java @@ -1,4 +1,4 @@ -package com.gg.server.global.security.config.properties; +package gg.pingpong.api.global.security.config.properties; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; diff --git a/src/main/java/com/gg/server/global/security/cookie/CookieUtil.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/cookie/CookieUtil.java similarity index 95% rename from src/main/java/com/gg/server/global/security/cookie/CookieUtil.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/cookie/CookieUtil.java index db23b1ce3..a7e4663ff 100644 --- a/src/main/java/com/gg/server/global/security/cookie/CookieUtil.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/cookie/CookieUtil.java @@ -1,4 +1,4 @@ -package com.gg.server.global.security.cookie; +package gg.pingpong.api.global.security.cookie; import java.util.Base64; import java.util.Optional; @@ -12,8 +12,7 @@ import org.springframework.stereotype.Component; import org.springframework.util.SerializationUtils; -import com.gg.server.global.utils.ApplicationYmlRead; - +import gg.pingpong.api.global.utils.ApplicationYmlRead; import lombok.RequiredArgsConstructor; @Component diff --git a/src/main/java/com/gg/server/global/security/handler/OAuthAuthenticationSuccessHandler.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/handler/OAuthAuthenticationSuccessHandler.java similarity index 87% rename from src/main/java/com/gg/server/global/security/handler/OAuthAuthenticationSuccessHandler.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/handler/OAuthAuthenticationSuccessHandler.java index 97b890b27..7d7068de6 100644 --- a/src/main/java/com/gg/server/global/security/handler/OAuthAuthenticationSuccessHandler.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/handler/OAuthAuthenticationSuccessHandler.java @@ -1,4 +1,4 @@ -package com.gg.server.global.security.handler; +package gg.pingpong.api.global.security.handler; import java.io.IOException; @@ -12,18 +12,17 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.util.UriComponentsBuilder; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.global.security.UserPrincipal; -import com.gg.server.global.security.config.properties.AppProperties; -import com.gg.server.global.security.cookie.CookieUtil; -import com.gg.server.global.security.jwt.repository.JwtRedisRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.global.security.jwt.utils.TokenHeaders; -import com.gg.server.global.utils.ApplicationYmlRead; - +import gg.pingpong.api.global.security.UserPrincipal; +import gg.pingpong.api.global.security.config.properties.AppProperties; +import gg.pingpong.api.global.security.cookie.CookieUtil; +import gg.pingpong.api.global.security.jwt.repository.JwtRedisRepository; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.global.security.jwt.utils.TokenHeaders; +import gg.pingpong.api.global.utils.ApplicationYmlRead; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Component diff --git a/src/main/java/com/gg/server/global/security/info/OAuthUserInfo.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/OAuthUserInfo.java similarity index 83% rename from src/main/java/com/gg/server/global/security/info/OAuthUserInfo.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/OAuthUserInfo.java index 004e1133c..18abacd1c 100644 --- a/src/main/java/com/gg/server/global/security/info/OAuthUserInfo.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/OAuthUserInfo.java @@ -1,8 +1,8 @@ -package com.gg.server.global.security.info; +package gg.pingpong.api.global.security.info; import java.util.Map; -import com.gg.server.data.user.type.RoleType; +import gg.pingpong.data.user.type.RoleType; public abstract class OAuthUserInfo { protected Map attributes; diff --git a/src/main/java/com/gg/server/global/security/info/OAuthUserInfoFactory.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/OAuthUserInfoFactory.java similarity index 71% rename from src/main/java/com/gg/server/global/security/info/OAuthUserInfoFactory.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/OAuthUserInfoFactory.java index 77fa88fb7..02ecec4a2 100644 --- a/src/main/java/com/gg/server/global/security/info/OAuthUserInfoFactory.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/OAuthUserInfoFactory.java @@ -1,9 +1,9 @@ -package com.gg.server.global.security.info; +package gg.pingpong.api.global.security.info; import java.util.Map; -import com.gg.server.global.security.info.impl.FortyTwoOAuthUserInfo; -import com.gg.server.global.security.info.impl.KakaoOAuthUserInfo; +import gg.pingpong.api.global.security.info.impl.FortyTwoOAuthUserInfo; +import gg.pingpong.api.global.security.info.impl.KakaoOAuthUserInfo; public class OAuthUserInfoFactory { public static OAuthUserInfo getOAuth2UserInfo(ProviderType providerType, Map attributes) { diff --git a/src/main/java/com/gg/server/global/security/info/ProviderType.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/ProviderType.java similarity index 89% rename from src/main/java/com/gg/server/global/security/info/ProviderType.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/ProviderType.java index 8e11f8644..8571cf250 100644 --- a/src/main/java/com/gg/server/global/security/info/ProviderType.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/ProviderType.java @@ -1,4 +1,4 @@ -package com.gg.server.global.security.info; +package gg.pingpong.api.global.security.info; import lombok.Getter; diff --git a/src/main/java/com/gg/server/global/security/info/impl/FortyTwoOAuthUserInfo.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/impl/FortyTwoOAuthUserInfo.java similarity index 84% rename from src/main/java/com/gg/server/global/security/info/impl/FortyTwoOAuthUserInfo.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/impl/FortyTwoOAuthUserInfo.java index 43ae02a5c..2c2336730 100644 --- a/src/main/java/com/gg/server/global/security/info/impl/FortyTwoOAuthUserInfo.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/impl/FortyTwoOAuthUserInfo.java @@ -1,11 +1,11 @@ -package com.gg.server.global.security.info.impl; +package gg.pingpong.api.global.security.info.impl; import java.util.Map; import org.springframework.beans.factory.annotation.Value; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.global.security.info.OAuthUserInfo; +import gg.pingpong.api.global.security.info.OAuthUserInfo; +import gg.pingpong.data.user.type.RoleType; public class FortyTwoOAuthUserInfo extends OAuthUserInfo { diff --git a/src/main/java/com/gg/server/global/security/info/impl/KakaoOAuthUserInfo.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/impl/KakaoOAuthUserInfo.java similarity index 86% rename from src/main/java/com/gg/server/global/security/info/impl/KakaoOAuthUserInfo.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/impl/KakaoOAuthUserInfo.java index 488500a85..517f0c225 100644 --- a/src/main/java/com/gg/server/global/security/info/impl/KakaoOAuthUserInfo.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/impl/KakaoOAuthUserInfo.java @@ -1,11 +1,11 @@ -package com.gg.server.global.security.info.impl; +package gg.pingpong.api.global.security.info.impl; import java.util.Map; import org.springframework.beans.factory.annotation.Value; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.global.security.info.OAuthUserInfo; +import gg.pingpong.api.global.security.info.OAuthUserInfo; +import gg.pingpong.data.user.type.RoleType; public class KakaoOAuthUserInfo extends OAuthUserInfo { @Value("${info.image.defaultUrl}") diff --git a/src/main/java/com/gg/server/global/security/jwt/repository/JwtRedisRepository.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/jwt/repository/JwtRedisRepository.java similarity index 93% rename from src/main/java/com/gg/server/global/security/jwt/repository/JwtRedisRepository.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/jwt/repository/JwtRedisRepository.java index bb1e9a260..f98b6141b 100644 --- a/src/main/java/com/gg/server/global/security/jwt/repository/JwtRedisRepository.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/jwt/repository/JwtRedisRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.global.security.jwt.repository; +package gg.pingpong.api.global.security.jwt.repository; import java.util.concurrent.TimeUnit; diff --git a/src/main/java/com/gg/server/global/security/jwt/utils/AuthTokenProvider.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/jwt/utils/AuthTokenProvider.java similarity index 94% rename from src/main/java/com/gg/server/global/security/jwt/utils/AuthTokenProvider.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/jwt/utils/AuthTokenProvider.java index 4a2c75c7c..afbfe1192 100644 --- a/src/main/java/com/gg/server/global/security/jwt/utils/AuthTokenProvider.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/jwt/utils/AuthTokenProvider.java @@ -1,12 +1,11 @@ -package com.gg.server.global.security.jwt.utils; +package gg.pingpong.api.global.security.jwt.utils; import java.security.Key; import java.util.Date; import org.springframework.stereotype.Component; -import com.gg.server.global.security.config.properties.AppProperties; - +import gg.pingpong.api.global.security.config.properties.AppProperties; import io.jsonwebtoken.Claims; import io.jsonwebtoken.ExpiredJwtException; import io.jsonwebtoken.Jwts; diff --git a/src/main/java/com/gg/server/global/security/jwt/utils/TokenAuthenticationFilter.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/jwt/utils/TokenAuthenticationFilter.java similarity index 93% rename from src/main/java/com/gg/server/global/security/jwt/utils/TokenAuthenticationFilter.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/jwt/utils/TokenAuthenticationFilter.java index 06b3f9ae9..f9beda9b5 100644 --- a/src/main/java/com/gg/server/global/security/jwt/utils/TokenAuthenticationFilter.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/jwt/utils/TokenAuthenticationFilter.java @@ -1,4 +1,4 @@ -package com.gg.server.global.security.jwt.utils; +package gg.pingpong.api.global.security.jwt.utils; import static org.apache.commons.lang3.StringUtils.*; @@ -18,9 +18,8 @@ import org.springframework.stereotype.Component; import org.springframework.web.filter.OncePerRequestFilter; -import com.gg.server.global.security.service.CustomUserDetailsService; -import com.gg.server.global.utils.HeaderUtil; - +import gg.pingpong.api.global.security.service.CustomUserDetailsService; +import gg.pingpong.api.global.utils.HeaderUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/gg/server/global/security/jwt/utils/TokenHeaders.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/jwt/utils/TokenHeaders.java similarity index 74% rename from src/main/java/com/gg/server/global/security/jwt/utils/TokenHeaders.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/jwt/utils/TokenHeaders.java index 1165fdee8..139c30e09 100644 --- a/src/main/java/com/gg/server/global/security/jwt/utils/TokenHeaders.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/jwt/utils/TokenHeaders.java @@ -1,4 +1,4 @@ -package com.gg.server.global.security.jwt.utils; +package gg.pingpong.api.global.security.jwt.utils; public class TokenHeaders { public static final String REFRESH_TOKEN = "refresh_token"; diff --git a/src/main/java/com/gg/server/global/security/repository/OAuthAuthorizationRequestBasedOnCookieRepository.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/repository/OAuthAuthorizationRequestBasedOnCookieRepository.java similarity index 94% rename from src/main/java/com/gg/server/global/security/repository/OAuthAuthorizationRequestBasedOnCookieRepository.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/repository/OAuthAuthorizationRequestBasedOnCookieRepository.java index 6e30c2f51..574f0474c 100644 --- a/src/main/java/com/gg/server/global/security/repository/OAuthAuthorizationRequestBasedOnCookieRepository.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/repository/OAuthAuthorizationRequestBasedOnCookieRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.global.security.repository; +package gg.pingpong.api.global.security.repository; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -7,9 +7,9 @@ import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest; import org.springframework.stereotype.Repository; -import com.gg.server.global.security.cookie.CookieUtil; import com.nimbusds.oauth2.sdk.util.StringUtils; +import gg.pingpong.api.global.security.cookie.CookieUtil; import lombok.RequiredArgsConstructor; @Repository diff --git a/src/main/java/com/gg/server/global/security/service/CustomOAuth2UserService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/service/CustomOAuth2UserService.java similarity index 74% rename from src/main/java/com/gg/server/global/security/service/CustomOAuth2UserService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/service/CustomOAuth2UserService.java index dce1ea7f7..bf6f25272 100644 --- a/src/main/java/com/gg/server/global/security/service/CustomOAuth2UserService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/service/CustomOAuth2UserService.java @@ -1,4 +1,4 @@ -package com.gg.server.global.security.service; +package gg.pingpong.api.global.security.service; import java.time.LocalDateTime; @@ -12,26 +12,24 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Rank; -import com.gg.server.data.game.Tier; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.UserPrincipal; -import com.gg.server.global.security.info.OAuthUserInfo; -import com.gg.server.global.security.info.OAuthUserInfoFactory; -import com.gg.server.global.security.info.ProviderType; -import com.gg.server.global.utils.aws.AsyncNewUserImageUploader; - +import gg.pingpong.api.global.security.UserPrincipal; +import gg.pingpong.api.global.security.info.OAuthUserInfo; +import gg.pingpong.api.global.security.info.OAuthUserInfoFactory; +import gg.pingpong.api.global.security.info.ProviderType; +import gg.pingpong.api.global.utils.aws.AsyncNewUserImageUploader; +import gg.pingpong.data.rank.Rank; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.TierRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.season.SeasonRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.exception.tier.TierNotFoundException; import lombok.RequiredArgsConstructor; @Service @@ -92,7 +90,8 @@ private void createUserRank(User savedUser) { season -> { Rank userRank = Rank.from(savedUser, season, season.getStartPpp(), tier); rankRepository.save(userRank); - RankRedis rankRedis = RankRedis.from(UserDto.from(savedUser), season.getStartPpp(), tier.getImageUri()); + RankRedis rankRedis = RankRedis.from(savedUser.getId(), savedUser.getIntraId(), + savedUser.getTextColor(), season.getStartPpp(), tier.getImageUri()); String hashKey = RedisKeyManager.getHashKey(season.getId()); rankRedisRepository.addRankData(hashKey, savedUser.getId(), rankRedis); } diff --git a/src/main/java/com/gg/server/global/security/service/CustomUserDetailsService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/service/CustomUserDetailsService.java similarity index 75% rename from src/main/java/com/gg/server/global/security/service/CustomUserDetailsService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/service/CustomUserDetailsService.java index 047f0d048..d297ba73d 100644 --- a/src/main/java/com/gg/server/global/security/service/CustomUserDetailsService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/service/CustomUserDetailsService.java @@ -1,15 +1,14 @@ -package com.gg.server.global.security.service; +package gg.pingpong.api.global.security.service; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.user.User; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.service.UserFindService; -import com.gg.server.global.security.UserPrincipal; - +import gg.pingpong.api.global.security.UserPrincipal; +import gg.pingpong.api.user.user.service.UserFindService; +import gg.pingpong.data.user.User; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/global/utils/ApplicationYmlRead.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ApplicationYmlRead.java similarity index 93% rename from src/main/java/com/gg/server/global/utils/ApplicationYmlRead.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ApplicationYmlRead.java index f0838c623..b675bbc22 100644 --- a/src/main/java/com/gg/server/global/utils/ApplicationYmlRead.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ApplicationYmlRead.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils; +package gg.pingpong.api.global.utils; import java.util.Map; diff --git a/src/main/java/com/gg/server/global/utils/AsyncMailSender.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/AsyncMailSender.java similarity index 93% rename from src/main/java/com/gg/server/global/utils/AsyncMailSender.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/AsyncMailSender.java index 9a06d1553..0eba18d45 100644 --- a/src/main/java/com/gg/server/global/utils/AsyncMailSender.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/AsyncMailSender.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils; +package gg.pingpong.api.global.utils; import javax.mail.internet.MimeMessage; diff --git a/src/main/java/com/gg/server/global/utils/EloRating.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/EloRating.java similarity index 91% rename from src/main/java/com/gg/server/global/utils/EloRating.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/EloRating.java index d21dc57ed..95745738f 100644 --- a/src/main/java/com/gg/server/global/utils/EloRating.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/EloRating.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils; +package gg.pingpong.api.global.utils; public class EloRating { public static Integer pppChange(Integer myPPP, Integer opponentPPP, Boolean isWin, Boolean isOneSide) { diff --git a/src/main/java/com/gg/server/global/utils/ExpLevelCalculator.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ExpLevelCalculator.java similarity index 97% rename from src/main/java/com/gg/server/global/utils/ExpLevelCalculator.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ExpLevelCalculator.java index a6a355c49..a0b64e6d5 100644 --- a/src/main/java/com/gg/server/global/utils/ExpLevelCalculator.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ExpLevelCalculator.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils; +package gg.pingpong.api.global.utils; public class ExpLevelCalculator { private static Integer expPerGame = 100; diff --git a/src/main/java/com/gg/server/global/utils/FileDownloader.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/FileDownloader.java similarity index 97% rename from src/main/java/com/gg/server/global/utils/FileDownloader.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/FileDownloader.java index aa8746195..b7a080041 100644 --- a/src/main/java/com/gg/server/global/utils/FileDownloader.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/FileDownloader.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils; +package gg.pingpong.api.global.utils; import org.apache.http.client.HttpClient; import org.apache.http.impl.client.HttpClientBuilder; diff --git a/src/main/java/com/gg/server/global/utils/HeaderUtil.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/HeaderUtil.java similarity index 93% rename from src/main/java/com/gg/server/global/utils/HeaderUtil.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/HeaderUtil.java index d114e3d6a..7bc680609 100644 --- a/src/main/java/com/gg/server/global/utils/HeaderUtil.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/HeaderUtil.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils; +package gg.pingpong.api.global.utils; import javax.servlet.http.HttpServletRequest; diff --git a/src/main/java/com/gg/server/global/utils/ImageResizingUtil.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ImageResizingUtil.java similarity index 94% rename from src/main/java/com/gg/server/global/utils/ImageResizingUtil.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ImageResizingUtil.java index c340af35d..f6e586987 100644 --- a/src/main/java/com/gg/server/global/utils/ImageResizingUtil.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ImageResizingUtil.java @@ -1,6 +1,6 @@ -package com.gg.server.global.utils; +package gg.pingpong.api.global.utils; -import java.awt.Image; +import java.awt.*; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/src/main/java/com/gg/server/global/utils/ItemImageHandler.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ItemImageHandler.java similarity index 95% rename from src/main/java/com/gg/server/global/utils/ItemImageHandler.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ItemImageHandler.java index 62f3d7524..290ae29fe 100644 --- a/src/main/java/com/gg/server/global/utils/ItemImageHandler.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ItemImageHandler.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils; +package gg.pingpong.api.global.utils; import java.io.IOException; import java.io.InputStream; @@ -12,7 +12,8 @@ import com.amazonaws.services.s3.model.CannedAccessControlList; import com.amazonaws.services.s3.model.ObjectMetadata; import com.amazonaws.services.s3.model.PutObjectRequest; -import com.gg.server.data.store.Item; + +import gg.pingpong.data.store.Item; @Component public class ItemImageHandler { diff --git a/src/main/java/com/gg/server/global/utils/JpegMultipartFile.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/JpegMultipartFile.java similarity index 96% rename from src/main/java/com/gg/server/global/utils/JpegMultipartFile.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/JpegMultipartFile.java index f7836f4b2..3426c5906 100644 --- a/src/main/java/com/gg/server/global/utils/JpegMultipartFile.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/JpegMultipartFile.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils; +package gg.pingpong.api.global.utils; import java.io.ByteArrayInputStream; import java.io.File; diff --git a/src/main/java/com/gg/server/global/utils/UserImageHandler.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/UserImageHandler.java similarity index 95% rename from src/main/java/com/gg/server/global/utils/UserImageHandler.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/UserImageHandler.java index 136e2e6d0..66f5e441d 100644 --- a/src/main/java/com/gg/server/global/utils/UserImageHandler.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/UserImageHandler.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils; +package gg.pingpong.api.global.utils; import java.io.IOException; import java.io.InputStream; @@ -12,8 +12,9 @@ import com.amazonaws.services.s3.model.CannedAccessControlList; import com.amazonaws.services.s3.model.ObjectMetadata; import com.amazonaws.services.s3.model.PutObjectRequest; -import com.gg.server.data.user.User; -import com.gg.server.domain.user.data.UserImageRepository; + +import gg.pingpong.data.user.User; +import gg.pingpong.repo.user.UserImageRepository; @Component public class UserImageHandler { diff --git a/src/main/java/com/gg/server/global/utils/argumentresolver/Login.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/argumentresolver/Login.java similarity index 82% rename from src/main/java/com/gg/server/global/utils/argumentresolver/Login.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/argumentresolver/Login.java index a12a91b00..a2721766f 100644 --- a/src/main/java/com/gg/server/global/utils/argumentresolver/Login.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/argumentresolver/Login.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils.argumentresolver; +package gg.pingpong.api.global.utils.argumentresolver; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/com/gg/server/global/utils/argumentresolver/LoginMemberArgumentResolver.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/argumentresolver/LoginMemberArgumentResolver.java similarity index 82% rename from src/main/java/com/gg/server/global/utils/argumentresolver/LoginMemberArgumentResolver.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/argumentresolver/LoginMemberArgumentResolver.java index e06721a83..5e0e8a0c9 100644 --- a/src/main/java/com/gg/server/global/utils/argumentresolver/LoginMemberArgumentResolver.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/argumentresolver/LoginMemberArgumentResolver.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils.argumentresolver; +package gg.pingpong.api.global.utils.argumentresolver; import javax.servlet.http.HttpServletRequest; @@ -8,12 +8,11 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.ModelAndViewContainer; -import com.gg.server.data.user.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.global.utils.HeaderUtil; - +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.global.utils.HeaderUtil; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.user.UserRepository; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/main/java/com/gg/server/global/utils/aws/AsyncNewItemImageUploader.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/aws/AsyncNewItemImageUploader.java similarity index 86% rename from src/main/java/com/gg/server/global/utils/aws/AsyncNewItemImageUploader.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/aws/AsyncNewItemImageUploader.java index 245737fd5..62ad1b2a8 100644 --- a/src/main/java/com/gg/server/global/utils/aws/AsyncNewItemImageUploader.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/aws/AsyncNewItemImageUploader.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils.aws; +package gg.pingpong.api.global.utils.aws; import java.io.IOException; @@ -7,8 +7,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import com.gg.server.data.store.Item; -import com.gg.server.global.utils.ItemImageHandler; +import gg.pingpong.api.global.utils.ItemImageHandler; +import gg.pingpong.data.store.Item; @Component public class AsyncNewItemImageUploader { diff --git a/src/main/java/com/gg/server/global/utils/aws/AsyncNewUserImageUploader.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/aws/AsyncNewUserImageUploader.java similarity index 88% rename from src/main/java/com/gg/server/global/utils/aws/AsyncNewUserImageUploader.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/aws/AsyncNewUserImageUploader.java index 35c429afb..8813f039a 100644 --- a/src/main/java/com/gg/server/global/utils/aws/AsyncNewUserImageUploader.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/aws/AsyncNewUserImageUploader.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils.aws; +package gg.pingpong.api.global.utils.aws; import java.io.IOException; import java.time.LocalDateTime; @@ -12,12 +12,11 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import com.gg.server.data.user.User; -import com.gg.server.data.user.UserImage; -import com.gg.server.domain.user.data.UserImageRepository; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.utils.UserImageHandler; - +import gg.pingpong.api.global.utils.UserImageHandler; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.UserImage; +import gg.pingpong.repo.user.UserImageRepository; +import gg.pingpong.repo.user.UserRepository; import lombok.extern.slf4j.Slf4j; @Slf4j diff --git a/src/main/java/com/gg/server/global/utils/external/ApiUtil.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/external/ApiUtil.java similarity index 97% rename from src/main/java/com/gg/server/global/utils/external/ApiUtil.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/external/ApiUtil.java index 1df10fd0d..ef30fb58d 100644 --- a/src/main/java/com/gg/server/global/utils/external/ApiUtil.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/external/ApiUtil.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils.external; +package gg.pingpong.api.global.utils.external; import java.util.Map; diff --git a/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryCounter.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/ApiQueryCounter.java similarity index 84% rename from src/main/java/com/gg/server/global/utils/querytracker/ApiQueryCounter.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/ApiQueryCounter.java index 78f73ab30..96692962f 100644 --- a/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryCounter.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/ApiQueryCounter.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils.querytracker; +package gg.pingpong.api.global.utils.querytracker; import org.springframework.stereotype.Component; import org.springframework.web.context.annotation.RequestScope; diff --git a/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryCounterAop.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/ApiQueryCounterAop.java similarity index 94% rename from src/main/java/com/gg/server/global/utils/querytracker/ApiQueryCounterAop.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/ApiQueryCounterAop.java index bd484d4e2..ecddc15a6 100644 --- a/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryCounterAop.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/ApiQueryCounterAop.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils.querytracker; +package gg.pingpong.api.global.utils.querytracker; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; diff --git a/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryInspector.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/ApiQueryInspector.java similarity index 93% rename from src/main/java/com/gg/server/global/utils/querytracker/ApiQueryInspector.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/ApiQueryInspector.java index be39ce8e2..6e6935d55 100644 --- a/src/main/java/com/gg/server/global/utils/querytracker/ApiQueryInspector.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/ApiQueryInspector.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils.querytracker; +package gg.pingpong.api.global.utils.querytracker; import java.util.Objects; diff --git a/src/main/java/com/gg/server/global/utils/querytracker/ConnectionProxyHandler.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/ConnectionProxyHandler.java similarity index 94% rename from src/main/java/com/gg/server/global/utils/querytracker/ConnectionProxyHandler.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/ConnectionProxyHandler.java index 6fc63dee1..2a38f5fd8 100644 --- a/src/main/java/com/gg/server/global/utils/querytracker/ConnectionProxyHandler.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/ConnectionProxyHandler.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils.querytracker; +package gg.pingpong.api.global.utils.querytracker; import java.lang.reflect.Method; diff --git a/src/main/java/com/gg/server/global/utils/querytracker/LoggingInterceptor.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/LoggingInterceptor.java similarity index 94% rename from src/main/java/com/gg/server/global/utils/querytracker/LoggingInterceptor.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/LoggingInterceptor.java index 73ac677c5..828bf0beb 100644 --- a/src/main/java/com/gg/server/global/utils/querytracker/LoggingInterceptor.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/LoggingInterceptor.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils.querytracker; +package gg.pingpong.api.global.utils.querytracker; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; diff --git a/src/main/java/com/gg/server/global/utils/querytracker/PreparedStatementProxyHandler.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/PreparedStatementProxyHandler.java similarity index 95% rename from src/main/java/com/gg/server/global/utils/querytracker/PreparedStatementProxyHandler.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/PreparedStatementProxyHandler.java index 069771343..9f36a40ed 100644 --- a/src/main/java/com/gg/server/global/utils/querytracker/PreparedStatementProxyHandler.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/querytracker/PreparedStatementProxyHandler.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils.querytracker; +package gg.pingpong.api.global.utils.querytracker; import java.lang.reflect.Method; import java.util.Objects; diff --git a/src/main/java/com/gg/server/domain/game/GameController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/GameController.java similarity index 82% rename from src/main/java/com/gg/server/domain/game/GameController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/GameController.java index c4b53d163..2c2529d77 100644 --- a/src/main/java/com/gg/server/domain/game/GameController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/GameController.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game; +package gg.pingpong.api.user.game.controller; import javax.validation.Valid; @@ -16,26 +16,25 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.data.game.type.Mode; -import com.gg.server.domain.game.dto.GameListResDto; -import com.gg.server.domain.game.dto.GamePChangeResultResDto; -import com.gg.server.domain.game.dto.GameTeamInfo; -import com.gg.server.domain.game.dto.request.GameListReqDto; -import com.gg.server.domain.game.dto.request.NormalGameListReqDto; -import com.gg.server.domain.game.dto.request.NormalResultReqDto; -import com.gg.server.domain.game.dto.request.RankGameListReqDto; -import com.gg.server.domain.game.dto.request.RankResultReqDto; -import com.gg.server.domain.game.dto.request.TournamentResultReqDto; -import com.gg.server.domain.game.exception.ScoreNotMatchedException; -import com.gg.server.domain.game.service.GameFindService; -import com.gg.server.domain.game.service.GameService; -import com.gg.server.domain.rank.redis.RankRedisService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; -import com.gg.server.global.exception.custom.InvalidParameterException; -import com.gg.server.global.utils.argumentresolver.Login; - +import gg.pingpong.api.global.utils.argumentresolver.Login; +import gg.pingpong.api.user.game.controller.request.GameListReqDto; +import gg.pingpong.api.user.game.controller.request.NormalGameListReqDto; +import gg.pingpong.api.user.game.controller.request.NormalResultReqDto; +import gg.pingpong.api.user.game.controller.request.RankGameListReqDto; +import gg.pingpong.api.user.game.controller.request.RankResultReqDto; +import gg.pingpong.api.user.game.controller.request.TournamentResultReqDto; +import gg.pingpong.api.user.game.controller.response.GameListResDto; +import gg.pingpong.api.user.game.controller.response.GamePChangeResultResDto; +import gg.pingpong.api.user.game.dto.GameTeamInfo; +import gg.pingpong.api.user.game.service.GameFindService; +import gg.pingpong.api.user.game.service.GameService; +import gg.pingpong.api.user.rank.redis.RankRedisService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; +import gg.pingpong.utils.exception.custom.InvalidParameterException; +import gg.pingpong.utils.exception.game.ScoreNotMatchedException; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/game/dto/request/GameListReqDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/GameListReqDto.java similarity index 73% rename from src/main/java/com/gg/server/domain/game/dto/request/GameListReqDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/GameListReqDto.java index 330981327..5092d81b3 100644 --- a/src/main/java/com/gg/server/domain/game/dto/request/GameListReqDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/GameListReqDto.java @@ -1,7 +1,6 @@ -package com.gg.server.domain.game.dto.request; - -import com.gg.server.data.game.type.StatusType; +package gg.pingpong.api.user.game.controller.request; +import gg.pingpong.data.game.type.StatusType; import lombok.Getter; @Getter diff --git a/src/main/java/com/gg/server/domain/game/dto/request/NormalGameListReqDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/NormalGameListReqDto.java similarity index 72% rename from src/main/java/com/gg/server/domain/game/dto/request/NormalGameListReqDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/NormalGameListReqDto.java index 6da929827..98c4380ea 100644 --- a/src/main/java/com/gg/server/domain/game/dto/request/NormalGameListReqDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/NormalGameListReqDto.java @@ -1,7 +1,6 @@ -package com.gg.server.domain.game.dto.request; - -import com.gg.server.global.dto.PageRequestDto; +package gg.pingpong.api.user.game.controller.request; +import gg.pingpong.api.global.dto.PageRequestDto; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/gg/server/domain/game/dto/request/NormalResultReqDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/NormalResultReqDto.java similarity index 85% rename from src/main/java/com/gg/server/domain/game/dto/request/NormalResultReqDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/NormalResultReqDto.java index 0911f66b4..7c4578424 100644 --- a/src/main/java/com/gg/server/domain/game/dto/request/NormalResultReqDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/NormalResultReqDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game.dto.request; +package gg.pingpong.api.user.game.controller.request; import javax.validation.constraints.NotNull; import javax.validation.constraints.Positive; diff --git a/src/main/java/com/gg/server/domain/game/dto/request/RankGameListReqDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/RankGameListReqDto.java similarity index 89% rename from src/main/java/com/gg/server/domain/game/dto/request/RankGameListReqDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/RankGameListReqDto.java index 41d03b243..34bb9d52e 100644 --- a/src/main/java/com/gg/server/domain/game/dto/request/RankGameListReqDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/RankGameListReqDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game.dto.request; +package gg.pingpong.api.user.game.controller.request; import javax.validation.constraints.NotNull; import javax.validation.constraints.Positive; diff --git a/src/main/java/com/gg/server/domain/game/dto/request/RankResultReqDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/RankResultReqDto.java similarity index 94% rename from src/main/java/com/gg/server/domain/game/dto/request/RankResultReqDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/RankResultReqDto.java index 3741d997a..9a1eb4420 100644 --- a/src/main/java/com/gg/server/domain/game/dto/request/RankResultReqDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/RankResultReqDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game.dto.request; +package gg.pingpong.api.user.game.controller.request; import javax.validation.constraints.Max; import javax.validation.constraints.NotNull; diff --git a/src/main/java/com/gg/server/domain/game/dto/request/TournamentResultReqDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/TournamentResultReqDto.java similarity index 86% rename from src/main/java/com/gg/server/domain/game/dto/request/TournamentResultReqDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/TournamentResultReqDto.java index 95e881c8d..a95b70b44 100644 --- a/src/main/java/com/gg/server/domain/game/dto/request/TournamentResultReqDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/TournamentResultReqDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game.dto.request; +package gg.pingpong.api.user.game.controller.request; import javax.validation.constraints.Max; import javax.validation.constraints.NotNull; @@ -17,14 +17,14 @@ public class TournamentResultReqDto { @NotNull(message = "gameId 는 필수 값입니다.") private Long gameId; @NotNull(message = "myTeamId 는 필수 값입니다.") - @javax.validation.constraints.Positive + @Positive private Long myTeamId; @NotNull(message = "myTeamScore 는 필수 값입니다.") @PositiveOrZero @Max(2) private int myTeamScore; @NotNull(message = "enemyTeamId 는 필수 값입니다.") - @javax.validation.constraints.Positive + @Positive private Long enemyTeamId; @NotNull(message = "enemyTeamScore 는 필수 값입니다.") @PositiveOrZero diff --git a/src/main/java/com/gg/server/domain/game/dto/GameListResDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GameListResDto.java similarity index 93% rename from src/main/java/com/gg/server/domain/game/dto/GameListResDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GameListResDto.java index 24ad5b3cb..ae2b3e29a 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GameListResDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GameListResDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game.dto; +package gg.pingpong.api.user.game.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/domain/game/dto/GamePChangeResultResDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GamePChangeResultResDto.java similarity index 91% rename from src/main/java/com/gg/server/domain/game/dto/GamePChangeResultResDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GamePChangeResultResDto.java index b5f0ae6ec..b47b26e7b 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GamePChangeResultResDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GamePChangeResultResDto.java @@ -1,10 +1,10 @@ -package com.gg.server.domain.game.dto; +package gg.pingpong.api.user.game.controller.response; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.gg.server.domain.coin.dto.UserGameCoinResultDto; -import com.gg.server.global.utils.ExpLevelCalculator; +import gg.pingpong.api.global.utils.ExpLevelCalculator; +import gg.pingpong.api.user.store.dto.UserGameCoinResultDto; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/game/dto/GamePPPChangeResultResDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GamePPPChangeResultResDto.java similarity index 88% rename from src/main/java/com/gg/server/domain/game/dto/GamePPPChangeResultResDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GamePPPChangeResultResDto.java index f314919bf..08b285a29 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GamePPPChangeResultResDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GamePPPChangeResultResDto.java @@ -1,7 +1,6 @@ -package com.gg.server.domain.game.dto; - -import com.gg.server.domain.coin.dto.UserGameCoinResultDto; +package gg.pingpong.api.user.game.controller.response; +import gg.pingpong.api.user.store.dto.UserGameCoinResultDto; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/game/dto/GameResultResDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GameResultResDto.java similarity index 92% rename from src/main/java/com/gg/server/domain/game/dto/GameResultResDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GameResultResDto.java index 0e6286273..95c45c018 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GameResultResDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GameResultResDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game.dto; +package gg.pingpong.api.user.game.controller.response; import java.time.LocalDateTime; import java.util.Arrays; @@ -7,10 +7,11 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import com.gg.server.data.game.type.Mode; -import com.gg.server.domain.team.dto.TeamUserInfoDto; -import com.gg.server.domain.team.dto.TeamUserListDto; +import gg.pingpong.api.user.game.dto.TeamUserInfoDto; +import gg.pingpong.api.user.game.dto.TeamUserListDto; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.repo.game.out.GameTeamUser; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/game/dto/GameTeamInfo.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/GameTeamInfo.java similarity index 87% rename from src/main/java/com/gg/server/domain/game/dto/GameTeamInfo.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/GameTeamInfo.java index 05aa98c35..f90d830b0 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GameTeamInfo.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/GameTeamInfo.java @@ -1,13 +1,12 @@ -package com.gg.server.domain.game.dto; +package gg.pingpong.api.user.game.dto; import java.time.LocalDateTime; import java.util.List; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.domain.game.exception.GameDataConsistencyException; -import com.gg.server.domain.team.dto.MatchTeamsInfoDto; - +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.repo.game.out.GameTeamUserInfo; +import gg.pingpong.utils.exception.game.GameDataConsistencyException; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; diff --git a/src/main/java/com/gg/server/domain/team/dto/MatchTeamsInfoDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/MatchTeamsInfoDto.java similarity index 91% rename from src/main/java/com/gg/server/domain/team/dto/MatchTeamsInfoDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/MatchTeamsInfoDto.java index 212beaa03..7d22926cb 100644 --- a/src/main/java/com/gg/server/domain/team/dto/MatchTeamsInfoDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/MatchTeamsInfoDto.java @@ -1,9 +1,8 @@ -package com.gg.server.domain.team.dto; +package gg.pingpong.api.user.game.dto; import java.util.List; -import com.gg.server.domain.game.dto.GameTeamUserInfo; - +import gg.pingpong.repo.game.out.GameTeamUserInfo; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; diff --git a/src/main/java/com/gg/server/domain/team/dto/TeamInfo.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamInfo.java similarity index 90% rename from src/main/java/com/gg/server/domain/team/dto/TeamInfo.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamInfo.java index 0f12f64b5..bfbccba74 100644 --- a/src/main/java/com/gg/server/domain/team/dto/TeamInfo.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamInfo.java @@ -1,10 +1,9 @@ -package com.gg.server.domain.team.dto; +package gg.pingpong.api.user.game.dto; import java.util.ArrayList; import java.util.List; -import com.gg.server.domain.game.dto.GameTeamUserInfo; - +import gg.pingpong.repo.game.out.GameTeamUserInfo; import lombok.Getter; import lombok.ToString; diff --git a/src/main/java/com/gg/server/domain/team/dto/TeamReqDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamReqDto.java similarity index 94% rename from src/main/java/com/gg/server/domain/team/dto/TeamReqDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamReqDto.java index ae2bbf06e..848f3dae2 100644 --- a/src/main/java/com/gg/server/domain/team/dto/TeamReqDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamReqDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.team.dto; +package gg.pingpong.api.user.game.dto; import javax.validation.constraints.Max; import javax.validation.constraints.Min; diff --git a/src/main/java/com/gg/server/domain/team/dto/TeamUserInfoDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamUserInfoDto.java similarity index 93% rename from src/main/java/com/gg/server/domain/team/dto/TeamUserInfoDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamUserInfoDto.java index 1e22b72b4..71fddf0ae 100644 --- a/src/main/java/com/gg/server/domain/team/dto/TeamUserInfoDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamUserInfoDto.java @@ -1,8 +1,8 @@ -package com.gg.server.domain.team.dto; +package gg.pingpong.api.user.game.dto; import com.fasterxml.jackson.annotation.JsonInclude; -import com.gg.server.global.utils.ExpLevelCalculator; +import gg.pingpong.api.global.utils.ExpLevelCalculator; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/team/dto/TeamUserListDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamUserListDto.java similarity index 97% rename from src/main/java/com/gg/server/domain/team/dto/TeamUserListDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamUserListDto.java index 23c2590eb..86d28ef1c 100644 --- a/src/main/java/com/gg/server/domain/team/dto/TeamUserListDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamUserListDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.team.dto; +package gg.pingpong.api.user.game.dto; import java.util.List; diff --git a/src/main/java/com/gg/server/domain/game/service/GameFindService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameFindService.java similarity index 91% rename from src/main/java/com/gg/server/domain/game/service/GameFindService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameFindService.java index 6ff9c538a..09e68ce9c 100644 --- a/src/main/java/com/gg/server/domain/game/service/GameFindService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameFindService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game.service; +package gg.pingpong.api.user.game.service; import java.util.Arrays; import java.util.List; @@ -10,15 +10,14 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.GameListResDto; -import com.gg.server.domain.game.dto.GameResultResDto; -import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.game.exception.GameNotExistException; - +import gg.pingpong.api.user.game.controller.response.GameListResDto; +import gg.pingpong.api.user.game.controller.response.GameResultResDto; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.game.out.GameTeamUser; +import gg.pingpong.utils.exception.game.GameNotExistException; import lombok.RequiredArgsConstructor; @Service @@ -122,8 +121,7 @@ public GameListResDto allGameList(Pageable pageable, String status) { * @throws GameNotExistException - intraId로 조회한 게임이 없을 경우 */ @Transactional(readOnly = true) - @Cacheable(value = "allGameListByUser", - cacheManager = "gameCacheManager", + @Cacheable(value = "allGameListByUser", cacheManager = "gameCacheManager", key = "#pageable.pageNumber + #pageable.pageSize + #pageable.sort.toString() + #status + #intra") public GameListResDto allGameListUser(Pageable pageable, String intra, String status) { List statusTypes = Arrays.asList(StatusType.END.name()); diff --git a/src/main/java/com/gg/server/domain/game/service/GameService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameService.java similarity index 83% rename from src/main/java/com/gg/server/domain/game/service/GameService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameService.java index 1286fee4f..48bb4059b 100644 --- a/src/main/java/com/gg/server/domain/game/service/GameService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game.service; +package gg.pingpong.api.user.game.service; import java.time.LocalDateTime; import java.util.List; @@ -8,42 +8,40 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.PChange; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.type.RoundNumber; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.match.type.TournamentMatchStatus; -import com.gg.server.domain.coin.dto.UserGameCoinResultDto; -import com.gg.server.domain.coin.service.UserCoinChangeService; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.GamePChangeResultResDto; -import com.gg.server.domain.game.dto.GamePPPChangeResultResDto; -import com.gg.server.domain.game.dto.GameTeamInfo; -import com.gg.server.domain.game.dto.GameTeamUserInfo; -import com.gg.server.domain.game.dto.request.NormalResultReqDto; -import com.gg.server.domain.game.dto.request.RankResultReqDto; -import com.gg.server.domain.game.dto.request.TournamentResultReqDto; -import com.gg.server.domain.game.exception.GameNotExistException; -import com.gg.server.domain.game.exception.GameStatusNotMatchedException; -import com.gg.server.domain.game.exception.ScoreAlreadyEnteredException; -import com.gg.server.domain.match.service.MatchTournamentService; -import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.pchange.exception.PChangeNotExistException; -import com.gg.server.domain.pchange.service.PChangeService; -import com.gg.server.domain.rank.redis.RankRedisService; -import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.team.exception.TeamIdNotMatchException; -import com.gg.server.domain.tier.service.TierService; -import com.gg.server.domain.tournament.data.TournamentGameRepository; -import com.gg.server.domain.tournament.exception.TournamentGameNotFoundException; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.InvalidParameterException; -import com.gg.server.global.utils.ExpLevelCalculator; - +import gg.pingpong.api.global.utils.ExpLevelCalculator; +import gg.pingpong.api.user.game.controller.request.NormalResultReqDto; +import gg.pingpong.api.user.game.controller.request.RankResultReqDto; +import gg.pingpong.api.user.game.controller.request.TournamentResultReqDto; +import gg.pingpong.api.user.game.controller.response.GamePChangeResultResDto; +import gg.pingpong.api.user.game.controller.response.GamePPPChangeResultResDto; +import gg.pingpong.api.user.game.dto.GameTeamInfo; +import gg.pingpong.api.user.match.service.MatchTournamentService; +import gg.pingpong.api.user.rank.redis.RankRedisService; +import gg.pingpong.api.user.rank.service.TierService; +import gg.pingpong.api.user.store.dto.UserGameCoinResultDto; +import gg.pingpong.api.user.store.service.UserCoinChangeService; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.PChange; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.match.type.TournamentMatchStatus; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.type.RoundNumber; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.game.PChangeRepository; +import gg.pingpong.repo.game.TeamUserRepository; +import gg.pingpong.repo.game.out.GameTeamUserInfo; +import gg.pingpong.repo.tournarment.TournamentGameRepository; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.InvalidParameterException; +import gg.pingpong.utils.exception.game.GameNotExistException; +import gg.pingpong.utils.exception.game.GameStatusNotMatchedException; +import gg.pingpong.utils.exception.game.ScoreAlreadyEnteredException; +import gg.pingpong.utils.exception.pchange.PChangeNotExistException; +import gg.pingpong.utils.exception.team.TeamIdNotMatchException; +import gg.pingpong.utils.exception.tournament.TournamentGameNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/game/service/GameStatusService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameStatusService.java similarity index 78% rename from src/main/java/com/gg/server/domain/game/service/GameStatusService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameStatusService.java index 588d5360c..f33630821 100644 --- a/src/main/java/com/gg/server/domain/game/service/GameStatusService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameStatusService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game.service; +package gg.pingpong.api.user.game.service; import java.time.LocalDateTime; import java.util.List; @@ -8,21 +8,20 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.noti.type.NotiType; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.exception.GameDataConsistencyException; -import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.noti.dto.UserNotiDto; -import com.gg.server.domain.noti.service.NotiService; -import com.gg.server.domain.noti.service.SnsNotiService; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.dto.GameUser; -import com.gg.server.domain.user.service.UserService; - +import gg.pingpong.api.user.noti.dto.UserNotiDto; +import gg.pingpong.api.user.noti.service.NotiService; +import gg.pingpong.api.user.noti.service.SnsNotiService; +import gg.pingpong.api.user.user.service.UserService; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.noti.type.NotiType; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.game.out.GameUser; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.utils.exception.game.GameDataConsistencyException; +import gg.pingpong.utils.exception.match.SlotNotFoundException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/gg/server/domain/pchange/service/PChangeService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/PChangeService.java similarity index 83% rename from src/main/java/com/gg/server/domain/pchange/service/PChangeService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/PChangeService.java index 0bd9ca4e4..351b2e9d5 100644 --- a/src/main/java/com/gg/server/domain/pchange/service/PChangeService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/PChangeService.java @@ -1,16 +1,15 @@ -package com.gg.server.domain.pchange.service; +package gg.pingpong.api.user.game.service; import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.PChange; -import com.gg.server.data.user.User; -import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.pchange.exception.PChangeNotExistException; - +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.PChange; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.PChangeRepository; +import gg.pingpong.utils.exception.pchange.PChangeNotExistException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/announcement/controller/AnnouncementController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/AnnouncementController.java similarity index 75% rename from src/main/java/com/gg/server/domain/announcement/controller/AnnouncementController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/AnnouncementController.java index a25094f4b..00d4ff9d2 100644 --- a/src/main/java/com/gg/server/domain/announcement/controller/AnnouncementController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/AnnouncementController.java @@ -1,12 +1,11 @@ -package com.gg.server.domain.announcement.controller; +package gg.pingpong.api.user.manage.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.domain.announcement.dto.AnnouncementResponseDto; -import com.gg.server.domain.announcement.service.AnnouncementService; - +import gg.pingpong.api.user.manage.controller.response.AnnouncementResponseDto; +import gg.pingpong.api.user.manage.service.AnnouncementService; import lombok.RequiredArgsConstructor; @RestController diff --git a/src/main/java/com/gg/server/domain/feedback/controller/FeedbackController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/FeedbackController.java similarity index 74% rename from src/main/java/com/gg/server/domain/feedback/controller/FeedbackController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/FeedbackController.java index 6bec79846..10e6ff14f 100644 --- a/src/main/java/com/gg/server/domain/feedback/controller/FeedbackController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/FeedbackController.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.feedback.controller; +package gg.pingpong.api.user.manage.controller; import javax.validation.Valid; @@ -9,12 +9,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.domain.feedback.dto.FeedbackRequestDto; -import com.gg.server.domain.feedback.service.FeedbackService; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.utils.argumentresolver.Login; - +import gg.pingpong.api.global.utils.argumentresolver.Login; +import gg.pingpong.api.user.manage.controller.request.FeedbackRequestDto; +import gg.pingpong.api.user.manage.service.FeedbackService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.repo.user.UserRepository; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/feedback/dto/FeedbackRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/request/FeedbackRequestDto.java similarity index 84% rename from src/main/java/com/gg/server/domain/feedback/dto/FeedbackRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/request/FeedbackRequestDto.java index 8dfa1ec7a..230f8aa8a 100644 --- a/src/main/java/com/gg/server/domain/feedback/dto/FeedbackRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/request/FeedbackRequestDto.java @@ -1,11 +1,10 @@ -package com.gg.server.domain.feedback.dto; +package gg.pingpong.api.user.manage.controller.request; import javax.validation.constraints.NotNull; import org.hibernate.validator.constraints.Length; -import com.gg.server.data.manage.type.FeedbackType; - +import gg.pingpong.data.manage.type.FeedbackType; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/response/AnnouncementResponseDto.java similarity index 72% rename from src/main/java/com/gg/server/domain/announcement/dto/AnnouncementResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/response/AnnouncementResponseDto.java index 9d6f9dfc2..9db74d402 100644 --- a/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/response/AnnouncementResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.announcement.dto; +package gg.pingpong.api.user.manage.controller.response; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/dto/AnnouncementDto.java similarity index 77% rename from src/main/java/com/gg/server/domain/announcement/dto/AnnouncementDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/dto/AnnouncementDto.java index f635584fe..5cd6e952e 100644 --- a/src/main/java/com/gg/server/domain/announcement/dto/AnnouncementDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/dto/AnnouncementDto.java @@ -1,7 +1,6 @@ -package com.gg.server.domain.announcement.dto; - -import com.gg.server.data.manage.Announcement; +package gg.pingpong.api.user.manage.dto; +import gg.pingpong.data.manage.Announcement; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/penalty/redis/PenaltyUserRedisRepository.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/redis/PenaltyUserRedisRepository.java similarity index 86% rename from src/main/java/com/gg/server/domain/penalty/redis/PenaltyUserRedisRepository.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/redis/PenaltyUserRedisRepository.java index 4054d6edb..eda02c9ae 100644 --- a/src/main/java/com/gg/server/domain/penalty/redis/PenaltyUserRedisRepository.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/redis/PenaltyUserRedisRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.penalty.redis; +package gg.pingpong.api.user.manage.redis; import java.time.Duration; import java.time.LocalDateTime; @@ -8,9 +8,8 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; -import com.gg.server.admin.penalty.type.PenaltyKey; -import com.gg.server.data.manage.redis.RedisPenaltyUser; - +import gg.pingpong.data.manage.redis.RedisPenaltyUser; +import gg.pingpong.data.manage.type.PenaltyKey; import lombok.RequiredArgsConstructor; @Repository diff --git a/src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/AnnouncementService.java similarity index 74% rename from src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/AnnouncementService.java index 6a10ddaa0..92d8bcb6b 100644 --- a/src/main/java/com/gg/server/domain/announcement/service/AnnouncementService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/AnnouncementService.java @@ -1,13 +1,12 @@ -package com.gg.server.domain.announcement.service; +package gg.pingpong.api.user.manage.service; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.manage.Announcement; -import com.gg.server.domain.announcement.data.AnnouncementRepository; -import com.gg.server.domain.announcement.dto.AnnouncementDto; -import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; - +import gg.pingpong.api.user.manage.dto.AnnouncementDto; +import gg.pingpong.data.manage.Announcement; +import gg.pingpong.repo.manage.AnnouncementRepository; +import gg.pingpong.utils.exception.announcement.AnnounceNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/feedback/service/FeedbackService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/FeedbackService.java similarity index 63% rename from src/main/java/com/gg/server/domain/feedback/service/FeedbackService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/FeedbackService.java index 6797ab8eb..b35b22feb 100644 --- a/src/main/java/com/gg/server/domain/feedback/service/FeedbackService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/FeedbackService.java @@ -1,15 +1,14 @@ -package com.gg.server.domain.feedback.service; +package gg.pingpong.api.user.manage.service; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.manage.Feedback; -import com.gg.server.data.user.User; -import com.gg.server.domain.feedback.data.FeedbackRepository; -import com.gg.server.domain.feedback.dto.FeedbackRequestDto; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.exception.UserNotFoundException; - +import gg.pingpong.api.user.manage.controller.request.FeedbackRequestDto; +import gg.pingpong.data.manage.Feedback; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.manage.FeedbackRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/penalty/service/PenaltyService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/PenaltyService.java similarity index 78% rename from src/main/java/com/gg/server/domain/penalty/service/PenaltyService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/PenaltyService.java index a8f293b64..35ee13157 100644 --- a/src/main/java/com/gg/server/domain/penalty/service/PenaltyService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/PenaltyService.java @@ -1,19 +1,18 @@ -package com.gg.server.domain.penalty.service; +package gg.pingpong.api.user.manage.service; import java.time.LocalDateTime; import java.util.Optional; import org.springframework.stereotype.Service; -import com.gg.server.data.manage.Penalty; -import com.gg.server.data.manage.redis.RedisPenaltyUser; -import com.gg.server.data.user.User; -import com.gg.server.domain.penalty.data.PenaltyRepository; -import com.gg.server.domain.penalty.redis.PenaltyUserRedisRepository; -import com.gg.server.domain.penalty.type.PenaltyType; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.service.UserFindService; - +import gg.pingpong.api.user.manage.redis.PenaltyUserRedisRepository; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.api.user.user.service.UserFindService; +import gg.pingpong.data.manage.Penalty; +import gg.pingpong.data.manage.redis.RedisPenaltyUser; +import gg.pingpong.data.manage.type.PenaltyType; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.manage.PenaltyRepository; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/match/controller/MatchController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/MatchController.java similarity index 80% rename from src/main/java/com/gg/server/domain/match/controller/MatchController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/MatchController.java index 6955b4494..e2f128fd6 100644 --- a/src/main/java/com/gg/server/domain/match/controller/MatchController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/MatchController.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.controller; +package gg.pingpong.api.user.match.controller; import java.time.LocalDateTime; @@ -15,15 +15,14 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.data.match.type.Option; -import com.gg.server.domain.match.dto.MatchRequestDto; -import com.gg.server.domain.match.dto.MatchStatusResponseListDto; -import com.gg.server.domain.match.dto.SlotStatusResponseListDto; -import com.gg.server.domain.match.service.MatchFindService; -import com.gg.server.domain.match.service.MatchService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.utils.argumentresolver.Login; - +import gg.pingpong.api.global.utils.argumentresolver.Login; +import gg.pingpong.api.user.match.controller.request.MatchRequestDto; +import gg.pingpong.api.user.match.controller.response.MatchStatusResponseListDto; +import gg.pingpong.api.user.match.controller.response.SlotStatusResponseListDto; +import gg.pingpong.api.user.match.service.MatchFindService; +import gg.pingpong.api.user.match.service.MatchService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.match.type.Option; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/match/dto/MatchRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/request/MatchRequestDto.java similarity index 86% rename from src/main/java/com/gg/server/domain/match/dto/MatchRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/request/MatchRequestDto.java index ccb88fa40..0d0915f95 100644 --- a/src/main/java/com/gg/server/domain/match/dto/MatchRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/request/MatchRequestDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.dto; +package gg.pingpong.api.user.match.controller.request; import java.time.LocalDateTime; @@ -7,8 +7,8 @@ import org.springframework.format.annotation.DateTimeFormat; import com.fasterxml.jackson.annotation.JsonProperty; -import com.gg.server.data.match.type.Option; +import gg.pingpong.data.match.type.Option; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/match/dto/MatchStatusResponseListDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/response/MatchStatusResponseListDto.java similarity index 80% rename from src/main/java/com/gg/server/domain/match/dto/MatchStatusResponseListDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/response/MatchStatusResponseListDto.java index 3249e2269..3d15d5c3a 100644 --- a/src/main/java/com/gg/server/domain/match/dto/MatchStatusResponseListDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/response/MatchStatusResponseListDto.java @@ -1,7 +1,8 @@ -package com.gg.server.domain.match.dto; +package gg.pingpong.api.user.match.controller.response; import java.util.List; +import gg.pingpong.api.user.match.dto.MatchStatusDto; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/match/dto/SlotStatusResponseListDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/response/SlotStatusResponseListDto.java similarity index 82% rename from src/main/java/com/gg/server/domain/match/dto/SlotStatusResponseListDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/response/SlotStatusResponseListDto.java index f489825d4..ef65c4cf5 100644 --- a/src/main/java/com/gg/server/domain/match/dto/SlotStatusResponseListDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/response/SlotStatusResponseListDto.java @@ -1,7 +1,8 @@ -package com.gg.server.domain.match.dto; +package gg.pingpong.api.user.match.controller.response; import java.util.List; +import gg.pingpong.api.user.match.dto.SlotStatusDto; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/GameAddDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/GameAddDto.java new file mode 100644 index 000000000..e228a358f --- /dev/null +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/GameAddDto.java @@ -0,0 +1,44 @@ +package gg.pingpong.api.user.match.dto; + +import java.time.LocalDateTime; +import java.util.List; + +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.match.RedisMatchUser; +import gg.pingpong.data.match.type.Option; +import gg.pingpong.data.season.Season; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class GameAddDto { + private LocalDateTime startTime; + private Season season; + private Long playerId; + private Long enemyId; + private Mode mode; + + public GameAddDto(LocalDateTime startTime, Season season, RedisMatchUser player, + RedisMatchUser enemy) { + this.startTime = startTime; + this.season = season; + this.playerId = player.getUserId(); + this.enemyId = enemy.getUserId(); + this.mode = ofPlayers(List.of(player, enemy), season.getPppGap()); + } + + public Mode ofPlayers(List players, Integer pppGap) { + if (players.stream().allMatch(player -> player.getOption().equals(Option.BOTH))) { + if (Math.abs(players.get(0).getPpp() - players.get(1).getPpp()) <= pppGap) { + return Mode.RANK; + } + return Mode.NORMAL; + } + if (!players.get(0).getOption().equals(Option.BOTH)) { + return Mode.getEnumValue(players.get(0).getOption().getCode()); + } + return Mode.getEnumValue(players.get(1).getOption().getCode()); + } +} diff --git a/src/main/java/com/gg/server/domain/match/dto/MatchStatusDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/MatchStatusDto.java similarity index 88% rename from src/main/java/com/gg/server/domain/match/dto/MatchStatusDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/MatchStatusDto.java index f7b9b4e39..419d73711 100644 --- a/src/main/java/com/gg/server/domain/match/dto/MatchStatusDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/MatchStatusDto.java @@ -1,14 +1,14 @@ -package com.gg.server.domain.match.dto; +package gg.pingpong.api.user.match.dto; import java.time.LocalDateTime; import java.util.List; import com.fasterxml.jackson.annotation.JsonFormat; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.match.RedisMatchTime; -import com.gg.server.domain.slotmanagement.SlotManagement; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.match.RedisMatchTime; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/match/dto/SlotStatusDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/SlotStatusDto.java similarity index 92% rename from src/main/java/com/gg/server/domain/match/dto/SlotStatusDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/SlotStatusDto.java index 73ac51cb2..4523fc95d 100644 --- a/src/main/java/com/gg/server/domain/match/dto/SlotStatusDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/SlotStatusDto.java @@ -1,10 +1,10 @@ -package com.gg.server.domain.match.dto; +package gg.pingpong.api.user.match.dto; import java.time.LocalDateTime; import com.fasterxml.jackson.annotation.JsonFormat; -import com.gg.server.data.match.type.SlotStatus; +import gg.pingpong.data.match.type.SlotStatus; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/match/service/GameUpdateService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/GameUpdateService.java similarity index 71% rename from src/main/java/com/gg/server/domain/match/service/GameUpdateService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/GameUpdateService.java index 1a737f55e..5b2cc5da0 100644 --- a/src/main/java/com/gg/server/domain/match/service/GameUpdateService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/GameUpdateService.java @@ -1,28 +1,27 @@ -package com.gg.server.domain.match.service; +package gg.pingpong.api.user.match.service; import java.time.LocalDateTime; import java.util.List; import org.springframework.stereotype.Service; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Team; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.match.dto.GameAddDto; -import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.noti.service.NotiService; -import com.gg.server.domain.noti.service.SnsNotiService; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; - +import gg.pingpong.api.user.match.dto.GameAddDto; +import gg.pingpong.api.user.noti.service.NotiService; +import gg.pingpong.api.user.noti.service.SnsNotiService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.game.TeamRepository; +import gg.pingpong.repo.game.TeamUserRepository; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.exception.match.SlotNotFoundException; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service @@ -45,7 +44,8 @@ public class GameUpdateService { public void make(GameAddDto addDto, Long recoveredUserId) { SlotManagement slotManagement = slotManagementRepository.findCurrent(LocalDateTime.now()) .orElseThrow(SlotNotFoundException::new); - Game game = new Game(addDto, slotManagement.getGameInterval()); + Game game = new Game(addDto.getSeason(), addDto.getMode(), addDto.getStartTime(), + slotManagement.getGameInterval()); gameRepository.save(game); Team enemyTeam = new Team(game, -1, false); Team myTeam = new Team(game, -1, false); diff --git a/src/main/java/com/gg/server/domain/match/service/MatchFindService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchFindService.java similarity index 74% rename from src/main/java/com/gg/server/domain/match/service/MatchFindService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchFindService.java index 8e5e4d0c7..a52d747da 100644 --- a/src/main/java/com/gg/server/domain/match/service/MatchFindService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchFindService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.service; +package gg.pingpong.api.user.match.service; import java.time.LocalDateTime; import java.util.Comparator; @@ -10,34 +10,33 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Tier; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.match.RedisMatchTime; -import com.gg.server.data.match.RedisMatchUser; -import com.gg.server.data.match.type.Option; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.match.data.RedisMatchTimeRepository; -import com.gg.server.domain.match.data.RedisMatchUserRepository; -import com.gg.server.domain.match.dto.MatchStatusDto; -import com.gg.server.domain.match.dto.MatchStatusResponseListDto; -import com.gg.server.domain.match.dto.SlotStatusResponseListDto; -import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.match.utils.SlotGenerator; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; - +import gg.pingpong.api.user.match.controller.response.MatchStatusResponseListDto; +import gg.pingpong.api.user.match.controller.response.SlotStatusResponseListDto; +import gg.pingpong.api.user.match.dto.MatchStatusDto; +import gg.pingpong.api.user.match.utils.SlotGenerator; +import gg.pingpong.api.user.season.service.SeasonFindService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.match.RedisMatchTime; +import gg.pingpong.data.match.RedisMatchUser; +import gg.pingpong.data.match.type.Option; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.repo.match.RedisMatchTimeRepository; +import gg.pingpong.repo.match.RedisMatchUserRepository; +import gg.pingpong.repo.rank.TierRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.exception.match.SlotNotFoundException; +import gg.pingpong.utils.exception.tier.TierNotFoundException; import lombok.RequiredArgsConstructor; @Service @@ -79,7 +78,8 @@ public SlotStatusResponseListDto getAllMatchStatus(UserDto userDto, Option optio Tier tier = tierRepository.findStartTier().orElseThrow(TierNotFoundException::new); RankRedis user; if (userDto.getRoleType().equals(RoleType.GUEST)) { - user = RankRedis.from(userDto, season.getStartPpp(), tier.getImageUri()); + user = RankRedis.from(userDto.getId(), userDto.getIntraId(), userDto.getTextColor(), + season.getStartPpp(), tier.getImageUri()); } else { user = rankRedisRepository .findRankByUserId(RedisKeyManager.getHashKey(season.getId()), userDto.getId()); diff --git a/src/main/java/com/gg/server/domain/match/service/MatchService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchService.java similarity index 82% rename from src/main/java/com/gg/server/domain/match/service/MatchService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchService.java index 08cb83ed6..1860f25c3 100644 --- a/src/main/java/com/gg/server/domain/match/service/MatchService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.service; +package gg.pingpong.api.user.match.service; import java.time.LocalDateTime; import java.util.List; @@ -9,40 +9,39 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.match.RedisMatchTime; -import com.gg.server.data.match.RedisMatchUser; -import com.gg.server.data.match.type.Option; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.exception.GameAlreadyExistException; -import com.gg.server.domain.match.data.RedisMatchTimeRepository; -import com.gg.server.domain.match.data.RedisMatchUserRepository; -import com.gg.server.domain.match.dto.GameAddDto; -import com.gg.server.domain.match.exception.EnrolledSlotException; -import com.gg.server.domain.match.exception.PenaltyUserSlotException; -import com.gg.server.domain.match.exception.SlotCountException; -import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.match.utils.MatchCalculator; -import com.gg.server.domain.penalty.service.PenaltyService; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.exception.TournamentConflictException; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; - +import gg.pingpong.api.user.manage.service.PenaltyService; +import gg.pingpong.api.user.match.dto.GameAddDto; +import gg.pingpong.api.user.match.utils.MatchCalculator; +import gg.pingpong.api.user.season.service.SeasonFindService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.match.RedisMatchTime; +import gg.pingpong.data.match.RedisMatchUser; +import gg.pingpong.data.match.type.Option; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.repo.match.RedisMatchTimeRepository; +import gg.pingpong.repo.match.RedisMatchUserRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.tournarment.TournamentRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; +import gg.pingpong.utils.exception.game.GameAlreadyExistException; +import gg.pingpong.utils.exception.match.EnrolledSlotException; +import gg.pingpong.utils.exception.match.PenaltyUserSlotException; +import gg.pingpong.utils.exception.match.SlotCountException; +import gg.pingpong.utils.exception.match.SlotNotFoundException; +import gg.pingpong.utils.exception.tournament.TournamentConflictException; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchTournamentService.java similarity index 86% rename from src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchTournamentService.java index f06526ed0..eeb4a6edf 100644 --- a/src/main/java/com/gg/server/domain/match/service/MatchTournamentService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchTournamentService.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.match.service; +package gg.pingpong.api.user.match.service; -import static com.gg.server.data.game.type.RoundNumber.*; -import static com.gg.server.data.match.type.TournamentMatchStatus.*; +import static gg.pingpong.data.match.type.TournamentMatchStatus.*; +import static gg.pingpong.data.tournament.type.RoundNumber.*; import java.time.LocalDateTime; import java.util.ArrayList; @@ -16,34 +16,33 @@ import org.springframework.stereotype.Service; -import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; -import com.gg.server.admin.noti.service.NotiAdminService; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Team; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.TournamentUser; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.RoundNumber; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.match.type.TournamentMatchStatus; -import com.gg.server.data.noti.type.NotiType; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.match.exception.EnrolledSlotException; -import com.gg.server.domain.match.exception.LosingTeamNotFoundException; -import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.match.exception.WinningTeamNotFoundException; -import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tournament.data.TournamentGameRepository; -import com.gg.server.domain.tournament.exception.TournamentGameNotFoundException; - +import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; +import gg.pingpong.api.admin.noti.service.NotiAdminService; +import gg.pingpong.api.user.season.service.SeasonFindService; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.match.type.TournamentMatchStatus; +import gg.pingpong.data.noti.type.NotiType; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.TournamentUser; +import gg.pingpong.data.tournament.type.RoundNumber; +import gg.pingpong.data.tournament.type.TournamentRound; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.repo.tournarment.TournamentGameRepository; +import gg.pingpong.utils.exception.match.EnrolledSlotException; +import gg.pingpong.utils.exception.match.LosingTeamNotFoundException; +import gg.pingpong.utils.exception.match.SlotNotFoundException; +import gg.pingpong.utils.exception.match.WinningTeamNotFoundException; +import gg.pingpong.utils.exception.tournament.TournamentGameNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/match/utils/MatchCalculator.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/utils/MatchCalculator.java similarity index 94% rename from src/main/java/com/gg/server/domain/match/utils/MatchCalculator.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/utils/MatchCalculator.java index 0c100f3da..02b53b698 100644 --- a/src/main/java/com/gg/server/domain/match/utils/MatchCalculator.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/utils/MatchCalculator.java @@ -1,11 +1,11 @@ -package com.gg.server.domain.match.utils; +package gg.pingpong.api.user.match.utils; import java.util.List; import java.util.Optional; -import com.gg.server.data.match.RedisMatchUser; -import com.gg.server.data.match.type.Option; -import com.gg.server.data.match.type.SlotStatus; +import gg.pingpong.data.match.RedisMatchUser; +import gg.pingpong.data.match.type.Option; +import gg.pingpong.data.match.type.SlotStatus; public class MatchCalculator { private final Integer pppGap; diff --git a/src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/utils/SlotGenerator.java similarity index 86% rename from src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/utils/SlotGenerator.java index a30fd96fe..c67ab411d 100644 --- a/src/main/java/com/gg/server/domain/match/utils/SlotGenerator.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/utils/SlotGenerator.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.utils; +package gg.pingpong.api.user.match.utils; import java.time.LocalDateTime; import java.util.ArrayList; @@ -6,18 +6,17 @@ import java.util.List; import java.util.Set; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.match.RedisMatchTime; -import com.gg.server.data.match.RedisMatchUser; -import com.gg.server.data.match.type.Option; -import com.gg.server.data.match.type.SlotStatus; -import com.gg.server.domain.match.dto.SlotStatusDto; -import com.gg.server.domain.match.dto.SlotStatusResponseListDto; -import com.gg.server.domain.slotmanagement.SlotManagement; - +import gg.pingpong.api.user.match.controller.response.SlotStatusResponseListDto; +import gg.pingpong.api.user.match.dto.SlotStatusDto; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.match.RedisMatchTime; +import gg.pingpong.data.match.RedisMatchUser; +import gg.pingpong.data.match.type.Option; +import gg.pingpong.data.match.type.SlotStatus; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; import lombok.Getter; @Getter diff --git a/src/main/java/com/gg/server/domain/noti/controller/NotiController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/NotiController.java similarity index 76% rename from src/main/java/com/gg/server/domain/noti/controller/NotiController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/NotiController.java index 859cbeb02..f964c11c6 100644 --- a/src/main/java/com/gg/server/domain/noti/controller/NotiController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/NotiController.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.noti.controller; +package gg.pingpong.api.user.noti.controller; import java.util.List; @@ -9,12 +9,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.domain.noti.dto.NotiListResponseDto; -import com.gg.server.domain.noti.dto.NotiResponseDto; -import com.gg.server.domain.noti.service.NotiService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.utils.argumentresolver.Login; - +import gg.pingpong.api.global.utils.argumentresolver.Login; +import gg.pingpong.api.user.noti.controller.response.NotiListResponseDto; +import gg.pingpong.api.user.noti.controller.response.NotiResponseDto; +import gg.pingpong.api.user.noti.service.NotiService; +import gg.pingpong.api.user.user.dto.UserDto; import lombok.AllArgsConstructor; @RestController diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/request/NotiFindByUserRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/request/NotiFindByUserRequestDto.java new file mode 100644 index 000000000..f63c6e490 --- /dev/null +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/request/NotiFindByUserRequestDto.java @@ -0,0 +1,4 @@ +package gg.pingpong.api.user.noti.controller.request; + +public class NotiFindByUserRequestDto { +} diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response/NotiFindByUserResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response/NotiFindByUserResponseDto.java new file mode 100644 index 000000000..143f7f6e9 --- /dev/null +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response/NotiFindByUserResponseDto.java @@ -0,0 +1,4 @@ +package gg.pingpong.api.user.noti.controller.response; + +public class NotiFindByUserResponseDto { +} diff --git a/src/main/java/com/gg/server/domain/noti/dto/NotiListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response/NotiListResponseDto.java similarity index 92% rename from src/main/java/com/gg/server/domain/noti/dto/NotiListResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response/NotiListResponseDto.java index 830e258d2..a0e76bc58 100644 --- a/src/main/java/com/gg/server/domain/noti/dto/NotiListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response/NotiListResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.noti.dto; +package gg.pingpong.api.user.noti.controller.response; import java.util.List; import java.util.Objects; diff --git a/src/main/java/com/gg/server/domain/noti/dto/NotiResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response/NotiResponseDto.java similarity index 91% rename from src/main/java/com/gg/server/domain/noti/dto/NotiResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response/NotiResponseDto.java index 3a64213be..a55c5b1bc 100644 --- a/src/main/java/com/gg/server/domain/noti/dto/NotiResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response/NotiResponseDto.java @@ -1,11 +1,10 @@ -package com.gg.server.domain.noti.dto; +package gg.pingpong.api.user.noti.controller.response; import java.time.LocalDateTime; import java.util.Objects; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.noti.type.NotiType; - +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.noti.type.NotiType; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/noti/dto/NotiDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/dto/NotiDto.java similarity index 88% rename from src/main/java/com/gg/server/domain/noti/dto/NotiDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/dto/NotiDto.java index 70ceddcdc..a4bcf460b 100644 --- a/src/main/java/com/gg/server/domain/noti/dto/NotiDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/dto/NotiDto.java @@ -1,12 +1,11 @@ -package com.gg.server.domain.noti.dto; +package gg.pingpong.api.user.noti.dto; import java.time.LocalDateTime; import java.util.Objects; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.noti.type.NotiType; -import com.gg.server.domain.user.dto.UserDto; - +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.noti.type.NotiType; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/noti/dto/UserNotiDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/dto/UserNotiDto.java similarity index 76% rename from src/main/java/com/gg/server/domain/noti/dto/UserNotiDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/dto/UserNotiDto.java index d7f004f4c..af2f6ca83 100644 --- a/src/main/java/com/gg/server/domain/noti/dto/UserNotiDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/dto/UserNotiDto.java @@ -1,8 +1,7 @@ -package com.gg.server.domain.noti.dto; - -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.team.dto.GameUser; +package gg.pingpong.api.user.noti.dto; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.game.out.GameUser; import lombok.Getter; @Getter diff --git a/src/main/java/com/gg/server/domain/noti/service/NotiService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/NotiService.java similarity index 90% rename from src/main/java/com/gg/server/domain/noti/service/NotiService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/NotiService.java index 6c82fdd9c..d3efd0d01 100644 --- a/src/main/java/com/gg/server/domain/noti/service/NotiService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/NotiService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.noti.service; +package gg.pingpong.api.user.noti.service; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -8,18 +8,17 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.noti.type.NotiType; -import com.gg.server.data.user.User; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.noti.dto.NotiDto; -import com.gg.server.domain.noti.dto.NotiResponseDto; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; - +import gg.pingpong.api.user.noti.controller.response.NotiResponseDto; +import gg.pingpong.api.user.noti.dto.NotiDto; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.noti.type.NotiType; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.noti.NotiRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.AllArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/SnsNotiService.java similarity index 84% rename from src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/SnsNotiService.java index b127cff83..eca601697 100644 --- a/src/main/java/com/gg/server/domain/noti/service/SnsNotiService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/SnsNotiService.java @@ -1,15 +1,14 @@ -package com.gg.server.domain.noti.service; +package gg.pingpong.api.user.noti.service; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.noti.dto.UserNotiDto; -import com.gg.server.domain.noti.service.sns.NotiMailSender; -import com.gg.server.domain.noti.service.sns.SlackbotService; -import com.gg.server.domain.user.dto.UserDto; - +import gg.pingpong.api.user.noti.dto.UserNotiDto; +import gg.pingpong.api.user.noti.service.sns.NotiMailSender; +import gg.pingpong.api.user.noti.service.sns.SlackbotService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.user.type.SnsType; import lombok.extern.slf4j.Slf4j; @Service diff --git a/src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/NotiMailSender.java similarity index 86% rename from src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/NotiMailSender.java index c743f938c..282e23c62 100644 --- a/src/main/java/com/gg/server/domain/noti/service/sns/NotiMailSender.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/NotiMailSender.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.noti.service.sns; +package gg.pingpong.api.user.noti.service.sns; import javax.mail.MessagingException; import javax.mail.internet.MimeMessage; @@ -7,12 +7,11 @@ import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.stereotype.Component; -import com.gg.server.data.noti.Noti; -import com.gg.server.domain.noti.dto.UserNotiDto; -import com.gg.server.domain.noti.service.NotiService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.utils.AsyncMailSender; - +import gg.pingpong.api.global.utils.AsyncMailSender; +import gg.pingpong.api.user.noti.dto.UserNotiDto; +import gg.pingpong.api.user.noti.service.NotiService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.noti.Noti; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/SlackbotService.java similarity index 88% rename from src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/SlackbotService.java index 085dc543e..04537d431 100644 --- a/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/SlackbotService.java @@ -1,6 +1,6 @@ -package com.gg.server.domain.noti.service.sns; +package gg.pingpong.api.user.noti.service.sns; -import static com.gg.server.domain.noti.service.sns.SlackbotUtils.*; +import static gg.pingpong.api.user.noti.service.sns.SlackbotUtils.*; import java.util.HashMap; import java.util.Map; @@ -14,13 +14,12 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; -import com.gg.server.data.noti.Noti; -import com.gg.server.domain.noti.dto.UserNotiDto; -import com.gg.server.domain.noti.exception.SlackSendException; -import com.gg.server.domain.noti.service.NotiService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.utils.external.ApiUtil; - +import gg.pingpong.api.global.utils.external.ApiUtil; +import gg.pingpong.api.user.noti.dto.UserNotiDto; +import gg.pingpong.api.user.noti.service.NotiService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.utils.exception.noti.SlackSendException; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotUtils.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/SlackbotUtils.java similarity index 89% rename from src/main/java/com/gg/server/domain/noti/service/sns/SlackbotUtils.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/SlackbotUtils.java index 5580a656d..2a271eac5 100644 --- a/src/main/java/com/gg/server/domain/noti/service/sns/SlackbotUtils.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/SlackbotUtils.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.noti.service.sns; +package gg.pingpong.api.user.noti.service.sns; public class SlackbotUtils { public static String conversationsUrl = "https://slack.com/api/conversations.open"; diff --git a/src/main/java/com/gg/server/domain/rank/controller/RankController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/controller/RankController.java similarity index 78% rename from src/main/java/com/gg/server/domain/rank/controller/RankController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/controller/RankController.java index 92cacd8c6..825c3b5e4 100644 --- a/src/main/java/com/gg/server/domain/rank/controller/RankController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/controller/RankController.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.controller; +package gg.pingpong.api.user.rank.controller; import javax.validation.Valid; @@ -8,13 +8,12 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; -import com.gg.server.domain.rank.dto.RankPageResponseDto; -import com.gg.server.domain.rank.service.RankService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.dto.PageRequestDto; -import com.gg.server.global.utils.argumentresolver.Login; - +import gg.pingpong.api.global.dto.PageRequestDto; +import gg.pingpong.api.global.utils.argumentresolver.Login; +import gg.pingpong.api.user.rank.controller.response.ExpRankPageResponseDto; +import gg.pingpong.api.user.rank.controller.response.RankPageResponseDto; +import gg.pingpong.api.user.rank.service.RankService; +import gg.pingpong.api.user.user.dto.UserDto; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/rank/controller/RankV2Controller.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/controller/RankV2Controller.java similarity index 80% rename from src/main/java/com/gg/server/domain/rank/controller/RankV2Controller.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/controller/RankV2Controller.java index 8839d09d7..c625edb4c 100644 --- a/src/main/java/com/gg/server/domain/rank/controller/RankV2Controller.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/controller/RankV2Controller.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.controller; +package gg.pingpong.api.user.rank.controller; import javax.validation.Valid; @@ -10,13 +10,12 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; -import com.gg.server.domain.rank.dto.RankPageResponseDto; -import com.gg.server.domain.rank.service.RankService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.dto.PageRequestDto; -import com.gg.server.global.utils.argumentresolver.Login; - +import gg.pingpong.api.global.dto.PageRequestDto; +import gg.pingpong.api.global.utils.argumentresolver.Login; +import gg.pingpong.api.user.rank.controller.response.ExpRankPageResponseDto; +import gg.pingpong.api.user.rank.controller.response.RankPageResponseDto; +import gg.pingpong.api.user.rank.service.RankService; +import gg.pingpong.api.user.user.dto.UserDto; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/rank/dto/ExpRankPageResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/controller/response/ExpRankPageResponseDto.java similarity index 77% rename from src/main/java/com/gg/server/domain/rank/dto/ExpRankPageResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/controller/response/ExpRankPageResponseDto.java index fe4e0e5a5..8920edb3d 100644 --- a/src/main/java/com/gg/server/domain/rank/dto/ExpRankPageResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/controller/response/ExpRankPageResponseDto.java @@ -1,7 +1,8 @@ -package com.gg.server.domain.rank.dto; +package gg.pingpong.api.user.rank.controller.response; import java.util.List; +import gg.pingpong.api.user.rank.dto.ExpRankDto; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/rank/dto/RankPageResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/controller/response/RankPageResponseDto.java similarity index 75% rename from src/main/java/com/gg/server/domain/rank/dto/RankPageResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/controller/response/RankPageResponseDto.java index 2be8d1b3d..cd5b7956e 100644 --- a/src/main/java/com/gg/server/domain/rank/dto/RankPageResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/controller/response/RankPageResponseDto.java @@ -1,7 +1,8 @@ -package com.gg.server.domain.rank.dto; +package gg.pingpong.api.user.rank.controller.response; import java.util.List; +import gg.pingpong.api.user.rank.dto.RankDto; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/rank/dto/ExpRankDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/dto/ExpRankDto.java similarity index 87% rename from src/main/java/com/gg/server/domain/rank/dto/ExpRankDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/dto/ExpRankDto.java index 711748bdc..f9e27390c 100644 --- a/src/main/java/com/gg/server/domain/rank/dto/ExpRankDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/dto/ExpRankDto.java @@ -1,8 +1,8 @@ -package com.gg.server.domain.rank.dto; - -import com.gg.server.data.user.User; -import com.gg.server.global.utils.ExpLevelCalculator; +package gg.pingpong.api.user.rank.dto; +import gg.pingpong.api.global.utils.ExpLevelCalculator; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.user.ExpRankV2Dto; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/com/gg/server/domain/rank/dto/RankDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/dto/RankDto.java similarity index 85% rename from src/main/java/com/gg/server/domain/rank/dto/RankDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/dto/RankDto.java index 095619da8..c088f936b 100644 --- a/src/main/java/com/gg/server/domain/rank/dto/RankDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/dto/RankDto.java @@ -1,8 +1,8 @@ -package com.gg.server.domain.rank.dto; - -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.user.User; +package gg.pingpong.api.user.rank.dto; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.rank.RankV2Dto; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis/RankRedisService.java similarity index 90% rename from src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis/RankRedisService.java index 71f490a72..15c2936de 100644 --- a/src/main/java/com/gg/server/domain/rank/redis/RankRedisService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis/RankRedisService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.redis; +package gg.pingpong.api.user.rank.redis; import java.util.List; @@ -8,21 +8,22 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Rank; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.game.Tier; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.domain.pchange.service.PChangeService; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.exception.RankNotFoundException; -import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; -import com.gg.server.global.utils.EloRating; - +import gg.pingpong.api.global.utils.EloRating; +import gg.pingpong.api.user.game.service.PChangeService; +import gg.pingpong.api.user.season.service.SeasonFindService; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.rank.Rank; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.TierRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; +import gg.pingpong.utils.exception.rank.RankNotFoundException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/gg/server/domain/rank/service/RedisUploadService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis/RedisUploadService.java similarity index 71% rename from src/main/java/com/gg/server/domain/rank/service/RedisUploadService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis/RedisUploadService.java index d5d2e3940..2799000c8 100644 --- a/src/main/java/com/gg/server/domain/rank/service/RedisUploadService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis/RedisUploadService.java @@ -1,6 +1,7 @@ -package com.gg.server.domain.rank.service; +package gg.pingpong.api.user.rank.redis; import java.time.LocalDateTime; +import java.util.Objects; import javax.annotation.PostConstruct; @@ -10,12 +11,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.SeasonRepository; - +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.season.SeasonRepository; +import gg.pingpong.utils.RedisKeyManager; import lombok.RequiredArgsConstructor; @Service @@ -45,12 +45,12 @@ private void upload() { String zSetKey = RedisKeyManager.getZSetKey(season.getId()); rankRepository.findAllBySeasonId(season.getId()).forEach(rank -> { RankRedis rankRedis = RankRedis.from(rank); - connection.hSet(keySerializer().serialize(hashKey), - hashKeySerializer().serialize(rank.getUser().getId().toString()), - hashValueSerializer().serialize(rankRedis)); + connection.hSet(Objects.requireNonNull(keySerializer().serialize(hashKey)), + Objects.requireNonNull(hashKeySerializer().serialize(rank.getUser().getId().toString())), + Objects.requireNonNull(hashValueSerializer().serialize(rankRedis))); if (rank.getWins() + rankRedis.getLosses() != 0) { - connection.zAdd(keySerializer().serialize(zSetKey), rank.getPpp(), - valueSerializer().serialize(rank.getUser().getId().toString())); + connection.zAdd(Objects.requireNonNull(keySerializer().serialize(zSetKey)), rank.getPpp(), + Objects.requireNonNull(valueSerializer().serialize(rank.getUser().getId().toString()))); } }); }); diff --git a/src/main/java/com/gg/server/domain/rank/service/RankFindService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/RankFindService.java similarity index 57% rename from src/main/java/com/gg/server/domain/rank/service/RankFindService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/RankFindService.java index df217917d..f4fa770b7 100644 --- a/src/main/java/com/gg/server/domain/rank/service/RankFindService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/RankFindService.java @@ -1,11 +1,10 @@ -package com.gg.server.domain.rank.service; +package gg.pingpong.api.user.rank.service; import org.springframework.stereotype.Service; -import com.gg.server.data.game.Rank; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.exception.RankNotFoundException; - +import gg.pingpong.data.rank.Rank; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.utils.exception.rank.RankNotFoundException; import lombok.RequiredArgsConstructor; @Service @@ -14,6 +13,6 @@ public class RankFindService { private final RankRepository rankRepository; public Rank findByUserIdAndSeasonId(Long userId, Long seasonId) { - return rankRepository.findByUserIdAndSeasonId(userId, seasonId).orElseThrow(() -> new RankNotFoundException()); + return rankRepository.findByUserIdAndSeasonId(userId, seasonId).orElseThrow(RankNotFoundException::new); } } diff --git a/src/main/java/com/gg/server/domain/rank/service/RankService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/RankService.java similarity index 85% rename from src/main/java/com/gg/server/domain/rank/service/RankService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/RankService.java index ba32cdc54..f0d463e58 100644 --- a/src/main/java/com/gg/server/domain/rank/service/RankService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/RankService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.service; +package gg.pingpong.api.user.rank.service; import java.time.LocalDateTime; import java.util.ArrayList; @@ -11,25 +11,24 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.user.User; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.dto.ExpRankDto; -import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; -import com.gg.server.domain.rank.dto.ExpRankV2Dto; -import com.gg.server.domain.rank.dto.RankDto; -import com.gg.server.domain.rank.dto.RankPageResponseDto; -import com.gg.server.domain.rank.exception.RedisDataNotFoundException; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.PageNotFoundException; - +import gg.pingpong.api.user.rank.controller.response.ExpRankPageResponseDto; +import gg.pingpong.api.user.rank.controller.response.RankPageResponseDto; +import gg.pingpong.api.user.rank.dto.ExpRankDto; +import gg.pingpong.api.user.rank.dto.RankDto; +import gg.pingpong.api.user.season.service.SeasonFindService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.user.ExpRankV2Dto; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.PageNotFoundException; +import gg.pingpong.utils.exception.rank.RedisDataNotFoundException; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service @@ -201,10 +200,6 @@ private List createRankList(int startRank, int endRank, Season season) User user = userRepository.findById(userIds.get(i)).orElseThrow(UserNotFoundException::new); rankList.add(RankDto.from(user, userRanks.get(i), ++startRank)); } - // for (RankRedis userRank : userRanks) { - // rankList.add(RankDto.from()) - // rankList.add(RankDto.from(userRank, ++startRank)); - // } return rankList; } } diff --git a/src/main/java/com/gg/server/domain/tier/service/TierService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/TierService.java similarity index 88% rename from src/main/java/com/gg/server/domain/tier/service/TierService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/TierService.java index 5724ee592..643b2f12e 100644 --- a/src/main/java/com/gg/server/domain/tier/service/TierService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/TierService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tier.service; +package gg.pingpong.api.user.rank.service; import java.util.List; @@ -6,12 +6,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Rank; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Tier; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.tier.data.TierRepository; - +import gg.pingpong.data.rank.Rank; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.season.Season; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.TierRepository; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/season/SeasonController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/SeasonController.java similarity index 73% rename from src/main/java/com/gg/server/domain/season/SeasonController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/SeasonController.java index 4c02bdacc..083c154a4 100644 --- a/src/main/java/com/gg/server/domain/season/SeasonController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/SeasonController.java @@ -1,12 +1,11 @@ -package com.gg.server.domain.season; +package gg.pingpong.api.user.season.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.domain.season.dto.SeasonListResDto; -import com.gg.server.domain.season.service.SeasonService; - +import gg.pingpong.api.user.season.controller.response.SeasonListResDto; +import gg.pingpong.api.user.season.service.SeasonService; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/main/java/com/gg/server/domain/season/dto/SeasonListResDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/response/SeasonListResDto.java similarity index 82% rename from src/main/java/com/gg/server/domain/season/dto/SeasonListResDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/response/SeasonListResDto.java index 57dd8cb7a..6a7a84cb2 100644 --- a/src/main/java/com/gg/server/domain/season/dto/SeasonListResDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/response/SeasonListResDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.season.dto; +package gg.pingpong.api.user.season.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/domain/season/dto/SeasonResDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/response/SeasonResDto.java similarity index 82% rename from src/main/java/com/gg/server/domain/season/dto/SeasonResDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/response/SeasonResDto.java index a1f4d5352..fe4d7cd44 100644 --- a/src/main/java/com/gg/server/domain/season/dto/SeasonResDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/response/SeasonResDto.java @@ -1,7 +1,6 @@ -package com.gg.server.domain.season.dto; - -import com.gg.server.data.game.Season; +package gg.pingpong.api.user.season.controller.response; +import gg.pingpong.data.season.Season; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/season/dto/CurSeason.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/dto/CurSeason.java similarity index 86% rename from src/main/java/com/gg/server/domain/season/dto/CurSeason.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/dto/CurSeason.java index d47bc28a8..ac75ec2db 100644 --- a/src/main/java/com/gg/server/domain/season/dto/CurSeason.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/dto/CurSeason.java @@ -1,9 +1,8 @@ -package com.gg.server.domain.season.dto; +package gg.pingpong.api.user.season.dto; import java.time.LocalDateTime; -import com.gg.server.data.game.Season; - +import gg.pingpong.data.season.Season; import lombok.Getter; @Getter diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonFindService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonFindService.java new file mode 100644 index 000000000..f32a752b1 --- /dev/null +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonFindService.java @@ -0,0 +1,38 @@ +package gg.pingpong.api.user.season.service; + +import java.time.LocalDateTime; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import gg.pingpong.data.game.Game; +import gg.pingpong.data.season.Season; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.season.SeasonRepository; +import gg.pingpong.utils.exception.game.GameNotExistException; +import gg.pingpong.utils.exception.season.SeasonNotFoundException; +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor + +public class SeasonFindService { + private final SeasonRepository seasonRepository; + private final GameRepository gameRepository; + + @Transactional(readOnly = true) + public Season findCurrentSeason(LocalDateTime now) { + return seasonRepository.findCurrentSeason(now).orElseThrow(SeasonNotFoundException::new); + } + + @Transactional(readOnly = true) + public Season findSeasonById(Long seasonId) { + return seasonRepository.findById(seasonId).orElseThrow(SeasonNotFoundException::new); + } + + @Transactional(readOnly = true) + public Season findSeasonByGameId(Long gameId) { + Game game = gameRepository.findById(gameId).orElseThrow(GameNotExistException::new); + return game.getSeason(); + } +} diff --git a/src/main/java/com/gg/server/domain/season/service/SeasonService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonService.java similarity index 71% rename from src/main/java/com/gg/server/domain/season/service/SeasonService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonService.java index d16de8b41..2958b00d8 100644 --- a/src/main/java/com/gg/server/domain/season/service/SeasonService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.season.service; +package gg.pingpong.api.user.season.service; import java.time.LocalDateTime; import java.util.List; @@ -6,11 +6,10 @@ import org.springframework.stereotype.Service; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.season.dto.CurSeason; -import com.gg.server.domain.season.dto.SeasonResDto; -import com.gg.server.domain.season.exception.SeasonNotFoundException; - +import gg.pingpong.api.user.season.controller.response.SeasonResDto; +import gg.pingpong.api.user.season.dto.CurSeason; +import gg.pingpong.repo.season.SeasonRepository; +import gg.pingpong.utils.exception.season.SeasonNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/item/controller/ItemController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/ItemController.java similarity index 79% rename from src/main/java/com/gg/server/domain/item/controller/ItemController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/ItemController.java index c410e357e..194b4cbaa 100644 --- a/src/main/java/com/gg/server/domain/item/controller/ItemController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/ItemController.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.item.controller; +package gg.pingpong.api.user.store.controller; import javax.validation.Valid; @@ -15,14 +15,13 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.domain.item.dto.ItemGiftRequestDto; -import com.gg.server.domain.item.dto.ItemStoreListResponseDto; -import com.gg.server.domain.item.dto.UserItemListResponseDto; -import com.gg.server.domain.item.service.ItemService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.dto.PageRequestDto; -import com.gg.server.global.utils.argumentresolver.Login; - +import gg.pingpong.api.global.dto.PageRequestDto; +import gg.pingpong.api.global.utils.argumentresolver.Login; +import gg.pingpong.api.user.store.controller.request.ItemGiftRequestDto; +import gg.pingpong.api.user.store.controller.response.ItemStoreListResponseDto; +import gg.pingpong.api.user.store.controller.response.UserItemListResponseDto; +import gg.pingpong.api.user.store.service.ItemService; +import gg.pingpong.api.user.user.dto.UserDto; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/megaphone/controller/MegaphoneController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/MegaphoneController.java similarity index 81% rename from src/main/java/com/gg/server/domain/megaphone/controller/MegaphoneController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/MegaphoneController.java index 2d9bde346..b7ac85a83 100644 --- a/src/main/java/com/gg/server/domain/megaphone/controller/MegaphoneController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/MegaphoneController.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.megaphone.controller; +package gg.pingpong.api.user.store.controller; import java.time.LocalTime; import java.util.List; @@ -15,13 +15,12 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.domain.megaphone.dto.MegaphoneDetailResponseDto; -import com.gg.server.domain.megaphone.dto.MegaphoneTodayListResponseDto; -import com.gg.server.domain.megaphone.dto.MegaphoneUseRequestDto; -import com.gg.server.domain.megaphone.service.MegaphoneService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.utils.argumentresolver.Login; - +import gg.pingpong.api.global.utils.argumentresolver.Login; +import gg.pingpong.api.user.store.controller.request.MegaphoneUseRequestDto; +import gg.pingpong.api.user.store.controller.response.MegaphoneDetailResponseDto; +import gg.pingpong.api.user.store.controller.response.MegaphoneTodayListResponseDto; +import gg.pingpong.api.user.store.service.MegaphoneService; +import gg.pingpong.api.user.user.dto.UserDto; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/item/dto/ItemGiftRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/request/ItemGiftRequestDto.java similarity index 78% rename from src/main/java/com/gg/server/domain/item/dto/ItemGiftRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/request/ItemGiftRequestDto.java index 8a252d9ab..a2f093691 100644 --- a/src/main/java/com/gg/server/domain/item/dto/ItemGiftRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/request/ItemGiftRequestDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.item.dto; +package gg.pingpong.api.user.store.controller.request; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneUseRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/request/MegaphoneUseRequestDto.java similarity index 89% rename from src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneUseRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/request/MegaphoneUseRequestDto.java index 2d73e13b4..2a0839acd 100644 --- a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneUseRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/request/MegaphoneUseRequestDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.megaphone.dto; +package gg.pingpong.api.user.store.controller.request; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; diff --git a/src/main/java/com/gg/server/domain/item/dto/ItemStoreListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/ItemStoreListResponseDto.java similarity index 84% rename from src/main/java/com/gg/server/domain/item/dto/ItemStoreListResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/ItemStoreListResponseDto.java index 49802e579..048a11f51 100644 --- a/src/main/java/com/gg/server/domain/item/dto/ItemStoreListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/ItemStoreListResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.item.dto; +package gg.pingpong.api.user.store.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/domain/item/dto/ItemStoreResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/ItemStoreResponseDto.java similarity index 86% rename from src/main/java/com/gg/server/domain/item/dto/ItemStoreResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/ItemStoreResponseDto.java index fe7f60574..f874d825c 100644 --- a/src/main/java/com/gg/server/domain/item/dto/ItemStoreResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/ItemStoreResponseDto.java @@ -1,8 +1,7 @@ -package com.gg.server.domain.item.dto; - -import com.gg.server.data.store.Item; -import com.gg.server.data.store.type.ItemType; +package gg.pingpong.api.user.store.controller.response; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.store.type.ItemType; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneDetailResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/MegaphoneDetailResponseDto.java similarity index 80% rename from src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneDetailResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/MegaphoneDetailResponseDto.java index 5c2a227ef..af13f5c26 100644 --- a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneDetailResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/MegaphoneDetailResponseDto.java @@ -1,7 +1,6 @@ -package com.gg.server.domain.megaphone.dto; - -import com.gg.server.data.store.Megaphone; +package gg.pingpong.api.user.store.controller.response; +import gg.pingpong.data.store.Megaphone; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneTodayListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/MegaphoneTodayListResponseDto.java similarity index 79% rename from src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneTodayListResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/MegaphoneTodayListResponseDto.java index 7eff7d867..3b988d92d 100644 --- a/src/main/java/com/gg/server/domain/megaphone/dto/MegaphoneTodayListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/MegaphoneTodayListResponseDto.java @@ -1,7 +1,6 @@ -package com.gg.server.domain.megaphone.dto; - -import com.gg.server.data.store.redis.MegaphoneRedis; +package gg.pingpong.api.user.store.controller.response; +import gg.pingpong.data.store.redis.MegaphoneRedis; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/item/dto/UserItemListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/UserItemListResponseDto.java similarity index 87% rename from src/main/java/com/gg/server/domain/item/dto/UserItemListResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/UserItemListResponseDto.java index 9cfb4dc7b..c3d66e055 100644 --- a/src/main/java/com/gg/server/domain/item/dto/UserItemListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/UserItemListResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.item.dto; +package gg.pingpong.api.user.store.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/domain/item/dto/UserItemResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/UserItemResponseDto.java similarity index 74% rename from src/main/java/com/gg/server/domain/item/dto/UserItemResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/UserItemResponseDto.java index 2bd814427..1e51bd8e3 100644 --- a/src/main/java/com/gg/server/domain/item/dto/UserItemResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/UserItemResponseDto.java @@ -1,10 +1,9 @@ -package com.gg.server.domain.item.dto; - -import com.gg.server.data.store.Item; -import com.gg.server.data.store.Receipt; -import com.gg.server.data.store.type.ItemStatus; -import com.gg.server.data.store.type.ItemType; +package gg.pingpong.api.user.store.controller.response; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.store.Receipt; +import gg.pingpong.data.store.type.ItemStatus; +import gg.pingpong.data.store.type.ItemType; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/coin/dto/UserGameCoinResultDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/dto/UserGameCoinResultDto.java similarity index 90% rename from src/main/java/com/gg/server/domain/coin/dto/UserGameCoinResultDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/dto/UserGameCoinResultDto.java index 23f933cd4..49a0a9281 100644 --- a/src/main/java/com/gg/server/domain/coin/dto/UserGameCoinResultDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/dto/UserGameCoinResultDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.coin.dto; +package gg.pingpong.api.user.store.dto; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedisRepository.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/redis/MegaphoneRedisRepository.java similarity index 90% rename from src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedisRepository.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/redis/MegaphoneRedisRepository.java index 2c19c57aa..7a31281ed 100644 --- a/src/main/java/com/gg/server/domain/megaphone/redis/MegaphoneRedisRepository.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/redis/MegaphoneRedisRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.megaphone.redis; +package gg.pingpong.api.user.store.redis; import java.time.Duration; import java.util.List; @@ -6,8 +6,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; -import com.gg.server.data.store.redis.MegaphoneRedis; - +import gg.pingpong.data.store.redis.MegaphoneRedis; import lombok.RequiredArgsConstructor; @Repository diff --git a/src/main/java/com/gg/server/domain/coin/service/CoinHistoryService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/CoinHistoryService.java similarity index 85% rename from src/main/java/com/gg/server/domain/coin/service/CoinHistoryService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/CoinHistoryService.java index 50aad0a6d..27d4672f8 100644 --- a/src/main/java/com/gg/server/domain/coin/service/CoinHistoryService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/CoinHistoryService.java @@ -1,18 +1,17 @@ -package com.gg.server.domain.coin.service; +package gg.pingpong.api.user.store.service; import java.time.LocalDateTime; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.store.CoinHistory; -import com.gg.server.data.store.Item; -import com.gg.server.data.store.type.HistoryType; -import com.gg.server.data.user.User; -import com.gg.server.domain.coin.data.CoinHistoryRepository; -import com.gg.server.domain.coin.data.CoinPolicyRepository; -import com.gg.server.domain.coin.exception.CoinPolicyNotFoundException; - +import gg.pingpong.data.store.CoinHistory; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.store.type.HistoryType; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.store.CoinHistoryRepository; +import gg.pingpong.repo.store.CoinPolicyRepository; +import gg.pingpong.utils.exception.coin.CoinPolicyNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/item/service/ItemService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/ItemService.java similarity index 81% rename from src/main/java/com/gg/server/domain/item/service/ItemService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/ItemService.java index 1f7ec7407..8e80cb3ca 100644 --- a/src/main/java/com/gg/server/domain/item/service/ItemService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/ItemService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.item.service; +package gg.pingpong.api.user.store.service; import java.time.LocalDateTime; import java.util.List; @@ -9,32 +9,30 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.store.Item; -import com.gg.server.data.store.Receipt; -import com.gg.server.data.store.type.ItemStatus; -import com.gg.server.data.store.type.ItemType; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.domain.coin.service.UserCoinChangeService; -import com.gg.server.domain.item.data.ItemRepository; -import com.gg.server.domain.item.data.UserItemRepository; -import com.gg.server.domain.item.dto.ItemStoreListResponseDto; -import com.gg.server.domain.item.dto.ItemStoreResponseDto; -import com.gg.server.domain.item.dto.UserItemListResponseDto; -import com.gg.server.domain.item.dto.UserItemResponseDto; -import com.gg.server.domain.item.exception.ItemNotFoundException; -import com.gg.server.domain.item.exception.ItemNotPurchasableException; -import com.gg.server.domain.item.exception.ItemTypeException; -import com.gg.server.domain.item.exception.KakaoGiftException; -import com.gg.server.domain.item.exception.KakaoPurchaseException; -import com.gg.server.domain.noti.service.NotiService; -import com.gg.server.domain.receipt.data.ReceiptRepository; -import com.gg.server.domain.receipt.exception.ItemStatusException; -import com.gg.server.domain.receipt.exception.ReceiptNotOwnerException; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; - +import gg.pingpong.api.user.noti.service.NotiService; +import gg.pingpong.api.user.store.controller.response.ItemStoreListResponseDto; +import gg.pingpong.api.user.store.controller.response.ItemStoreResponseDto; +import gg.pingpong.api.user.store.controller.response.UserItemListResponseDto; +import gg.pingpong.api.user.store.controller.response.UserItemResponseDto; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.store.Receipt; +import gg.pingpong.data.store.type.ItemStatus; +import gg.pingpong.data.store.type.ItemType; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.repo.store.ItemRepository; +import gg.pingpong.repo.store.ReceiptRepository; +import gg.pingpong.repo.store.UserItemRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.exception.item.ItemNotFoundException; +import gg.pingpong.utils.exception.item.ItemNotPurchasableException; +import gg.pingpong.utils.exception.item.ItemTypeException; +import gg.pingpong.utils.exception.item.KakaoGiftException; +import gg.pingpong.utils.exception.item.KakaoPurchaseException; +import gg.pingpong.utils.exception.receipt.ItemStatusException; +import gg.pingpong.utils.exception.receipt.ReceiptNotOwnerException; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/MegaphoneService.java similarity index 79% rename from src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/MegaphoneService.java index 8180d2a5e..192909395 100644 --- a/src/main/java/com/gg/server/domain/megaphone/service/MegaphoneService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/MegaphoneService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.megaphone.service; +package gg.pingpong.api.user.store.service; import java.time.LocalDate; import java.time.LocalDateTime; @@ -9,31 +9,29 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.store.Megaphone; -import com.gg.server.data.store.Receipt; -import com.gg.server.data.store.redis.MegaphoneRedis; -import com.gg.server.data.store.type.ItemStatus; -import com.gg.server.data.store.type.ItemType; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.domain.item.exception.ItemTypeException; -import com.gg.server.domain.item.service.ItemService; -import com.gg.server.domain.megaphone.data.MegaphoneRepository; -import com.gg.server.domain.megaphone.dto.MegaphoneDetailResponseDto; -import com.gg.server.domain.megaphone.dto.MegaphoneTodayListResponseDto; -import com.gg.server.domain.megaphone.dto.MegaphoneUseRequestDto; -import com.gg.server.domain.megaphone.exception.MegaphoneContentException; -import com.gg.server.domain.megaphone.exception.MegaphoneNotFoundException; -import com.gg.server.domain.megaphone.exception.MegaphoneTimeException; -import com.gg.server.domain.megaphone.redis.MegaphoneRedisRepository; -import com.gg.server.domain.receipt.data.ReceiptRepository; -import com.gg.server.domain.receipt.exception.ItemStatusException; -import com.gg.server.domain.receipt.exception.ReceiptNotFoundException; -import com.gg.server.domain.receipt.exception.ReceiptNotOwnerException; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; - +import gg.pingpong.api.user.store.controller.request.MegaphoneUseRequestDto; +import gg.pingpong.api.user.store.controller.response.MegaphoneDetailResponseDto; +import gg.pingpong.api.user.store.controller.response.MegaphoneTodayListResponseDto; +import gg.pingpong.api.user.store.redis.MegaphoneRedisRepository; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.store.Megaphone; +import gg.pingpong.data.store.Receipt; +import gg.pingpong.data.store.redis.MegaphoneRedis; +import gg.pingpong.data.store.type.ItemStatus; +import gg.pingpong.data.store.type.ItemType; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.repo.store.MegaphoneRepository; +import gg.pingpong.repo.store.ReceiptRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.exception.item.ItemTypeException; +import gg.pingpong.utils.exception.megaphone.MegaphoneContentException; +import gg.pingpong.utils.exception.megaphone.MegaphoneNotFoundException; +import gg.pingpong.utils.exception.megaphone.MegaphoneTimeException; +import gg.pingpong.utils.exception.receipt.ItemStatusException; +import gg.pingpong.utils.exception.receipt.ReceiptNotFoundException; +import gg.pingpong.utils.exception.receipt.ReceiptNotOwnerException; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/coin/service/UserCoinChangeService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/UserCoinChangeService.java similarity index 81% rename from src/main/java/com/gg/server/domain/coin/service/UserCoinChangeService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/UserCoinChangeService.java index 81f6c77ee..87024279b 100644 --- a/src/main/java/com/gg/server/domain/coin/service/UserCoinChangeService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/UserCoinChangeService.java @@ -1,22 +1,21 @@ -package com.gg.server.domain.coin.service; +package gg.pingpong.api.user.store.service; import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Team; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.store.Item; -import com.gg.server.data.user.User; -import com.gg.server.domain.coin.data.CoinPolicyRepository; -import com.gg.server.domain.coin.dto.UserGameCoinResultDto; -import com.gg.server.domain.coin.exception.CoinPolicyNotFoundException; -import com.gg.server.domain.game.service.GameFindService; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.exception.UserAlreadyAttendanceException; -import com.gg.server.domain.user.exception.UserNotFoundException; - +import gg.pingpong.api.user.game.service.GameFindService; +import gg.pingpong.api.user.store.dto.UserGameCoinResultDto; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.store.CoinPolicyRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.exception.coin.CoinPolicyNotFoundException; +import gg.pingpong.utils.exception.user.UserAlreadyAttendanceException; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/tournament/controller/TournamentController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/TournamentController.java similarity index 85% rename from src/main/java/com/gg/server/domain/tournament/controller/TournamentController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/TournamentController.java index 58acfe25b..c2294aa7c 100644 --- a/src/main/java/com/gg/server/domain/tournament/controller/TournamentController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/TournamentController.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.controller; +package gg.pingpong.api.user.tournament.controller; import javax.validation.Valid; import javax.validation.constraints.Positive; @@ -17,15 +17,14 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.gg.server.domain.tournament.dto.TournamentFilterRequestDto; -import com.gg.server.domain.tournament.dto.TournamentGameListResponseDto; -import com.gg.server.domain.tournament.dto.TournamentListResponseDto; -import com.gg.server.domain.tournament.dto.TournamentResponseDto; -import com.gg.server.domain.tournament.dto.TournamentUserRegistrationResponseDto; -import com.gg.server.domain.tournament.service.TournamentService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.utils.argumentresolver.Login; - +import gg.pingpong.api.global.utils.argumentresolver.Login; +import gg.pingpong.api.user.tournament.controller.request.TournamentFilterRequestDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentGameListResponseDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentListResponseDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentResponseDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentUserRegistrationResponseDto; +import gg.pingpong.api.user.tournament.service.TournamentService; +import gg.pingpong.api.user.user.dto.UserDto; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentFilterRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/request/TournamentFilterRequestDto.java similarity index 60% rename from src/main/java/com/gg/server/domain/tournament/dto/TournamentFilterRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/request/TournamentFilterRequestDto.java index 545001e3c..a6aaed726 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentFilterRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/request/TournamentFilterRequestDto.java @@ -1,9 +1,8 @@ -package com.gg.server.domain.tournament.dto; - -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; -import com.gg.server.global.dto.PageRequestDto; +package gg.pingpong.api.user.tournament.controller.request; +import gg.pingpong.api.global.dto.PageRequestDto; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; import lombok.Getter; @Getter diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentGameListResponseDto.java similarity index 90% rename from src/main/java/com/gg/server/domain/tournament/dto/TournamentGameListResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentGameListResponseDto.java index 105df0017..f8b13428e 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentGameListResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.dto; +package gg.pingpong.api.user.tournament.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameResDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentGameResDto.java similarity index 77% rename from src/main/java/com/gg/server/domain/tournament/dto/TournamentGameResDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentGameResDto.java index bc3561330..4a0ae9409 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentGameResDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentGameResDto.java @@ -1,10 +1,9 @@ -package com.gg.server.domain.tournament.dto; - -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.domain.game.dto.GameResultResDto; -import com.gg.server.domain.game.dto.GameTeamUser; +package gg.pingpong.api.user.tournament.controller.response; +import gg.pingpong.api.user.game.controller.response.GameResultResDto; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.type.TournamentRound; +import gg.pingpong.repo.game.out.GameTeamUser; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentListResponseDto.java similarity index 89% rename from src/main/java/com/gg/server/domain/tournament/dto/TournamentListResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentListResponseDto.java index a6e3c66a8..85a616dda 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentListResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.dto; +package gg.pingpong.api.user.tournament.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentResponseDto.java similarity index 84% rename from src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentResponseDto.java index 74bd2c790..eb8d1b8da 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentResponseDto.java @@ -1,13 +1,12 @@ -package com.gg.server.domain.tournament.dto; +package gg.pingpong.api.user.tournament.controller.response; import java.time.LocalDateTime; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentUser; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; -import com.gg.server.domain.user.dto.UserImageDto; - +import gg.pingpong.api.user.user.dto.UserImageDto; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentUser; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserListResponseDto.java similarity index 85% rename from src/main/java/com/gg/server/domain/tournament/dto/TournamentUserListResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserListResponseDto.java index 52252302e..74317e828 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserListResponseDto.java @@ -1,11 +1,10 @@ -package com.gg.server.domain.tournament.dto; +package gg.pingpong.api.user.tournament.controller.response; import java.util.ArrayList; import java.util.Comparator; import java.util.List; -import com.gg.server.data.game.TournamentUser; - +import gg.pingpong.data.tournament.TournamentUser; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserRegistrationResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserRegistrationResponseDto.java similarity index 68% rename from src/main/java/com/gg/server/domain/tournament/dto/TournamentUserRegistrationResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserRegistrationResponseDto.java index aeef0ce04..49aec0c1b 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserRegistrationResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserRegistrationResponseDto.java @@ -1,7 +1,6 @@ -package com.gg.server.domain.tournament.dto; - -import com.gg.server.data.game.type.TournamentUserStatus; +package gg.pingpong.api.user.tournament.controller.response; +import gg.pingpong.data.tournament.type.TournamentUserStatus; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserResponseDto.java similarity index 85% rename from src/main/java/com/gg/server/domain/tournament/dto/TournamentUserResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserResponseDto.java index 25cc5a32e..d2156f75b 100644 --- a/src/main/java/com/gg/server/domain/tournament/dto/TournamentUserResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserResponseDto.java @@ -1,9 +1,8 @@ -package com.gg.server.domain.tournament.dto; +package gg.pingpong.api.user.tournament.controller.response; import java.time.LocalDateTime; -import com.gg.server.data.game.TournamentUser; - +import gg.pingpong.data.tournament.TournamentUser; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/service/TournamentService.java similarity index 84% rename from src/main/java/com/gg/server/domain/tournament/service/TournamentService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/service/TournamentService.java index 75ad90484..e8b2dc2bb 100644 --- a/src/main/java/com/gg/server/domain/tournament/service/TournamentService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/service/TournamentService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.service; +package gg.pingpong.api.user.tournament.service; import static java.util.Comparator.*; @@ -14,38 +14,37 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; -import com.gg.server.admin.noti.service.NotiAdminService; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.TournamentUser; -import com.gg.server.data.game.type.RoundNumber; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; -import com.gg.server.data.game.type.TournamentUserStatus; -import com.gg.server.data.noti.type.NotiType; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.match.service.MatchTournamentService; -import com.gg.server.domain.tournament.data.TournamentGameRepository; -import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.data.TournamentUserRepository; -import com.gg.server.domain.tournament.dto.TournamentGameListResponseDto; -import com.gg.server.domain.tournament.dto.TournamentGameResDto; -import com.gg.server.domain.tournament.dto.TournamentListResponseDto; -import com.gg.server.domain.tournament.dto.TournamentResponseDto; -import com.gg.server.domain.tournament.dto.TournamentUserRegistrationResponseDto; -import com.gg.server.domain.tournament.exception.TournamentConflictException; -import com.gg.server.domain.tournament.exception.TournamentNotFoundException; -import com.gg.server.domain.tournament.exception.TournamentUpdateException; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; - +import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; +import gg.pingpong.api.admin.noti.service.NotiAdminService; +import gg.pingpong.api.user.match.service.MatchTournamentService; +import gg.pingpong.api.user.tournament.controller.response.TournamentGameListResponseDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentGameResDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentListResponseDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentResponseDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentUserRegistrationResponseDto; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.noti.type.NotiType; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.TournamentUser; +import gg.pingpong.data.tournament.type.RoundNumber; +import gg.pingpong.data.tournament.type.TournamentRound; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; +import gg.pingpong.data.tournament.type.TournamentUserStatus; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.game.out.GameTeamUser; +import gg.pingpong.repo.tournarment.TournamentGameRepository; +import gg.pingpong.repo.tournarment.TournamentRepository; +import gg.pingpong.repo.tournarment.TournamentUserRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; +import gg.pingpong.utils.exception.tournament.TournamentConflictException; +import gg.pingpong.utils.exception.tournament.TournamentNotFoundException; +import gg.pingpong.utils.exception.tournament.TournamentUpdateException; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/user/controller/UserController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/UserController.java similarity index 77% rename from src/main/java/com/gg/server/domain/user/controller/UserController.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/UserController.java index 422026503..72251fd2f 100644 --- a/src/main/java/com/gg/server/domain/user/controller/UserController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/UserController.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.controller; +package gg.pingpong.api.user.user.controller; import java.io.IOException; import java.util.List; @@ -26,36 +26,35 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.user.type.OauthType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.domain.user.dto.UserAccessTokenDto; -import com.gg.server.domain.user.dto.UserAttendanceResponseDto; -import com.gg.server.domain.user.dto.UserBackgroundDto; -import com.gg.server.domain.user.dto.UserCoinHistoryListResponseDto; -import com.gg.server.domain.user.dto.UserCoinResponseDto; -import com.gg.server.domain.user.dto.UserDetailResponseDto; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.dto.UserEdgeDto; -import com.gg.server.domain.user.dto.UserHistoryResponseDto; -import com.gg.server.domain.user.dto.UserImageResponseDto; -import com.gg.server.domain.user.dto.UserLiveResponseDto; -import com.gg.server.domain.user.dto.UserModifyRequestDto; -import com.gg.server.domain.user.dto.UserNormalDetailResponseDto; -import com.gg.server.domain.user.dto.UserOauthDto; -import com.gg.server.domain.user.dto.UserProfileImageRequestDto; -import com.gg.server.domain.user.dto.UserRankResponseDto; -import com.gg.server.domain.user.dto.UserSearchResponseDto; -import com.gg.server.domain.user.dto.UserTextColorDto; -import com.gg.server.domain.user.exception.KakaoOauth2AlreadyExistException; -import com.gg.server.domain.user.service.UserAuthenticationService; -import com.gg.server.domain.user.service.UserCoinService; -import com.gg.server.domain.user.service.UserService; -import com.gg.server.global.dto.PageRequestDto; -import com.gg.server.global.security.cookie.CookieUtil; -import com.gg.server.global.security.jwt.utils.TokenHeaders; -import com.gg.server.global.utils.argumentresolver.Login; - +import gg.pingpong.api.global.dto.PageRequestDto; +import gg.pingpong.api.global.security.cookie.CookieUtil; +import gg.pingpong.api.global.security.jwt.utils.TokenHeaders; +import gg.pingpong.api.global.utils.argumentresolver.Login; +import gg.pingpong.api.user.user.controller.request.UserModifyRequestDto; +import gg.pingpong.api.user.user.controller.request.UserProfileImageRequestDto; +import gg.pingpong.api.user.user.controller.response.UserAttendanceResponseDto; +import gg.pingpong.api.user.user.controller.response.UserCoinHistoryListResponseDto; +import gg.pingpong.api.user.user.controller.response.UserCoinResponseDto; +import gg.pingpong.api.user.user.controller.response.UserDetailResponseDto; +import gg.pingpong.api.user.user.controller.response.UserHistoryResponseDto; +import gg.pingpong.api.user.user.controller.response.UserImageResponseDto; +import gg.pingpong.api.user.user.controller.response.UserLiveResponseDto; +import gg.pingpong.api.user.user.controller.response.UserNormalDetailResponseDto; +import gg.pingpong.api.user.user.controller.response.UserRankResponseDto; +import gg.pingpong.api.user.user.controller.response.UserSearchResponseDto; +import gg.pingpong.api.user.user.dto.UserAccessTokenDto; +import gg.pingpong.api.user.user.dto.UserBackgroundDto; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.api.user.user.dto.UserEdgeDto; +import gg.pingpong.api.user.user.dto.UserOauthDto; +import gg.pingpong.api.user.user.dto.UserTextColorDto; +import gg.pingpong.api.user.user.service.UserAuthenticationService; +import gg.pingpong.api.user.user.service.UserCoinService; +import gg.pingpong.api.user.user.service.UserService; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.user.type.OauthType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.utils.exception.user.KakaoOauth2AlreadyExistException; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserModifyRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/request/UserModifyRequestDto.java similarity index 69% rename from src/main/java/com/gg/server/domain/user/dto/UserModifyRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/request/UserModifyRequestDto.java index b7bc1e8d2..4323aef44 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserModifyRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/request/UserModifyRequestDto.java @@ -1,8 +1,7 @@ -package com.gg.server.domain.user.dto; - -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.SnsType; +package gg.pingpong.api.user.user.controller.request; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.SnsType; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserProfileImageRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/request/UserProfileImageRequestDto.java similarity index 82% rename from src/main/java/com/gg/server/domain/user/dto/UserProfileImageRequestDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/request/UserProfileImageRequestDto.java index 603d80690..ea25afffe 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserProfileImageRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/request/UserProfileImageRequestDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.controller.request; import javax.validation.constraints.NotNull; diff --git a/src/main/java/com/gg/server/domain/user/dto/CoinHistoryResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/CoinHistoryResponseDto.java similarity index 81% rename from src/main/java/com/gg/server/domain/user/dto/CoinHistoryResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/CoinHistoryResponseDto.java index a00ede8ed..9e33bbed3 100644 --- a/src/main/java/com/gg/server/domain/user/dto/CoinHistoryResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/CoinHistoryResponseDto.java @@ -1,9 +1,8 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.controller.response; import java.time.LocalDateTime; -import com.gg.server.data.store.CoinHistory; - +import gg.pingpong.data.store.CoinHistory; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserAttendanceResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserAttendanceResponseDto.java similarity index 82% rename from src/main/java/com/gg/server/domain/user/dto/UserAttendanceResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserAttendanceResponseDto.java index 878b7a0d5..88f6cdec6 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserAttendanceResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserAttendanceResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.controller.response; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserCoinHistoryListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserCoinHistoryListResponseDto.java similarity index 83% rename from src/main/java/com/gg/server/domain/user/dto/UserCoinHistoryListResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserCoinHistoryListResponseDto.java index 0cff36e9d..cd0229e0f 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserCoinHistoryListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserCoinHistoryListResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserCoinResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserCoinResponseDto.java similarity index 79% rename from src/main/java/com/gg/server/domain/user/dto/UserCoinResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserCoinResponseDto.java index 9ce90ec28..51190a42f 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserCoinResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserCoinResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.controller.response; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserDetailResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserDetailResponseDto.java similarity index 81% rename from src/main/java/com/gg/server/domain/user/dto/UserDetailResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserDetailResponseDto.java index 51f458561..dd971eb9b 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserDetailResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserDetailResponseDto.java @@ -1,12 +1,11 @@ -package com.gg.server.domain.user.dto; - -import com.gg.server.data.game.Tier; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.BackgroundType; -import com.gg.server.data.user.type.EdgeType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.global.utils.ExpLevelCalculator; +package gg.pingpong.api.user.user.controller.response; +import gg.pingpong.api.global.utils.ExpLevelCalculator; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.BackgroundType; +import gg.pingpong.data.user.type.EdgeType; +import gg.pingpong.data.user.type.SnsType; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserHistoryResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserHistoryResponseDto.java similarity index 69% rename from src/main/java/com/gg/server/domain/user/dto/UserHistoryResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserHistoryResponseDto.java index 792ec9e76..17e0bf3dd 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserHistoryResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserHistoryResponseDto.java @@ -1,7 +1,8 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.controller.response; import java.util.List; +import gg.pingpong.api.user.user.dto.UserHistoryData; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserImageResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserImageResponseDto.java similarity index 68% rename from src/main/java/com/gg/server/domain/user/dto/UserImageResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserImageResponseDto.java index f12164c40..151d19cac 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserImageResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserImageResponseDto.java @@ -1,7 +1,8 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.controller.response; import java.util.List; +import gg.pingpong.api.user.user.dto.UserImageDto; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserLiveResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserLiveResponseDto.java similarity index 77% rename from src/main/java/com/gg/server/domain/user/dto/UserLiveResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserLiveResponseDto.java index 5f239136c..8276412bd 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserLiveResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserLiveResponseDto.java @@ -1,7 +1,6 @@ -package com.gg.server.domain.user.dto; - -import com.gg.server.data.game.type.Mode; +package gg.pingpong.api.user.user.controller.response; +import gg.pingpong.data.game.type.Mode; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserNormalDetailResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserNormalDetailResponseDto.java similarity index 80% rename from src/main/java/com/gg/server/domain/user/dto/UserNormalDetailResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserNormalDetailResponseDto.java index 19d83ad16..752ed8888 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserNormalDetailResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserNormalDetailResponseDto.java @@ -1,7 +1,6 @@ -package com.gg.server.domain.user.dto; - -import com.gg.server.data.user.type.EdgeType; +package gg.pingpong.api.user.user.controller.response; +import gg.pingpong.data.user.type.EdgeType; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserRankResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserRankResponseDto.java similarity index 87% rename from src/main/java/com/gg/server/domain/user/dto/UserRankResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserRankResponseDto.java index 7e421e67a..4418123de 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserRankResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserRankResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.controller.response; import lombok.AccessLevel; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserSearchResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserSearchResponseDto.java similarity index 80% rename from src/main/java/com/gg/server/domain/user/dto/UserSearchResponseDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserSearchResponseDto.java index a6e1b31d3..71837c14b 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserSearchResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserSearchResponseDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.controller.response; import java.util.List; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserAccessTokenDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserAccessTokenDto.java similarity index 79% rename from src/main/java/com/gg/server/domain/user/dto/UserAccessTokenDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserAccessTokenDto.java index 44a9d837a..9774f80b8 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserAccessTokenDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserAccessTokenDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserBackgroundDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserBackgroundDto.java similarity index 86% rename from src/main/java/com/gg/server/domain/user/dto/UserBackgroundDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserBackgroundDto.java index 8420de4ea..a2aec636a 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserBackgroundDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserBackgroundDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.dto; import javax.validation.constraints.NotNull; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserDto.java similarity index 83% rename from src/main/java/com/gg/server/domain/user/dto/UserDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserDto.java index a1b9e0d8a..171b5aa88 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserDto.java @@ -1,10 +1,9 @@ -package com.gg.server.domain.user.dto; - -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; +package gg.pingpong.api.user.user.dto; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserEdgeDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserEdgeDto.java similarity index 86% rename from src/main/java/com/gg/server/domain/user/dto/UserEdgeDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserEdgeDto.java index be6be50be..c4c96e4af 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserEdgeDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserEdgeDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.dto; import javax.validation.constraints.NotNull; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserHistoryData.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserHistoryData.java similarity index 79% rename from src/main/java/com/gg/server/domain/user/dto/UserHistoryData.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserHistoryData.java index 39cc6edf9..9044f3aea 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserHistoryData.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserHistoryData.java @@ -1,9 +1,8 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.dto; import java.time.LocalDateTime; -import com.gg.server.data.game.PChange; - +import gg.pingpong.data.game.PChange; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserImageDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserImageDto.java similarity index 82% rename from src/main/java/com/gg/server/domain/user/dto/UserImageDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserImageDto.java index de372f7bb..49b7b3400 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserImageDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserImageDto.java @@ -1,8 +1,7 @@ -package com.gg.server.domain.user.dto; - -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.EdgeType; +package gg.pingpong.api.user.user.dto; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.EdgeType; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserOauthDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserOauthDto.java similarity index 78% rename from src/main/java/com/gg/server/domain/user/dto/UserOauthDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserOauthDto.java index a9c84dd98..0a595b409 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserOauthDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserOauthDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/user/dto/UserTextColorDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserTextColorDto.java similarity index 87% rename from src/main/java/com/gg/server/domain/user/dto/UserTextColorDto.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserTextColorDto.java index 32e93061f..4228807ad 100644 --- a/src/main/java/com/gg/server/domain/user/dto/UserTextColorDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserTextColorDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.dto; +package gg.pingpong.api.user.user.dto; import com.sun.istack.NotNull; diff --git a/src/main/java/com/gg/server/domain/user/service/UserAuthenticationService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserAuthenticationService.java similarity index 74% rename from src/main/java/com/gg/server/domain/user/service/UserAuthenticationService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserAuthenticationService.java index a5f1ab2af..c168938fd 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserAuthenticationService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserAuthenticationService.java @@ -1,11 +1,10 @@ -package com.gg.server.domain.user.service; +package gg.pingpong.api.user.user.service; import org.springframework.stereotype.Service; -import com.gg.server.domain.user.exception.TokenNotValidException; -import com.gg.server.global.security.jwt.repository.JwtRedisRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; - +import gg.pingpong.api.global.security.jwt.repository.JwtRedisRepository; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.utils.exception.user.TokenNotValidException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/user/service/UserCoinService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserCoinService.java similarity index 71% rename from src/main/java/com/gg/server/domain/user/service/UserCoinService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserCoinService.java index cf096f146..d683ccd15 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserCoinService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserCoinService.java @@ -1,19 +1,18 @@ -package com.gg.server.domain.user.service; +package gg.pingpong.api.user.user.service; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.store.CoinHistory; -import com.gg.server.data.user.User; -import com.gg.server.domain.coin.data.CoinHistoryRepository; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.CoinHistoryResponseDto; -import com.gg.server.domain.user.dto.UserCoinHistoryListResponseDto; -import com.gg.server.domain.user.dto.UserCoinResponseDto; -import com.gg.server.domain.user.exception.UserNotFoundException; - +import gg.pingpong.api.user.user.controller.response.CoinHistoryResponseDto; +import gg.pingpong.api.user.user.controller.response.UserCoinHistoryListResponseDto; +import gg.pingpong.api.user.user.controller.response.UserCoinResponseDto; +import gg.pingpong.data.store.CoinHistory; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.store.CoinHistoryRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/main/java/com/gg/server/domain/user/service/UserFindService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserFindService.java similarity index 68% rename from src/main/java/com/gg/server/domain/user/service/UserFindService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserFindService.java index ec67650db..84552b787 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserFindService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserFindService.java @@ -1,20 +1,19 @@ -package com.gg.server.domain.user.service; +package gg.pingpong.api.user.user.service; import java.time.LocalDateTime; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.user.User; -import com.gg.server.domain.rank.exception.RedisDataNotFoundException; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.exception.UserNotFoundException; - +import gg.pingpong.api.user.season.service.SeasonFindService; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.exception.rank.RedisDataNotFoundException; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/src/main/java/com/gg/server/domain/user/service/UserService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserService.java similarity index 80% rename from src/main/java/com/gg/server/domain/user/service/UserService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserService.java index 084c55e80..c94d92142 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.service; +package gg.pingpong.api.user.user.service; import java.io.IOException; import java.time.LocalDateTime; @@ -16,67 +16,66 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.PChange; -import com.gg.server.data.game.Rank; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Tier; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.store.Receipt; -import com.gg.server.data.store.type.ItemStatus; -import com.gg.server.data.store.type.ItemType; -import com.gg.server.data.user.User; -import com.gg.server.data.user.UserImage; -import com.gg.server.data.user.type.BackgroundType; -import com.gg.server.data.user.type.EdgeType; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.coin.service.CoinHistoryService; -import com.gg.server.domain.coin.service.UserCoinChangeService; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.item.service.ItemService; -import com.gg.server.domain.match.data.RedisMatchUserRepository; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.pchange.exception.PChangeNotExistException; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.dto.RankV2Dto; -import com.gg.server.domain.rank.exception.RankNotFoundException; -import com.gg.server.domain.rank.exception.RedisDataNotFoundException; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.rank.service.RankFindService; -import com.gg.server.domain.receipt.data.ReceiptRepository; -import com.gg.server.domain.receipt.exception.ReceiptNotFoundException; -import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.data.UserImageRepository; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserAttendanceResponseDto; -import com.gg.server.domain.user.dto.UserBackgroundDto; -import com.gg.server.domain.user.dto.UserDetailResponseDto; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.dto.UserEdgeDto; -import com.gg.server.domain.user.dto.UserHistoryData; -import com.gg.server.domain.user.dto.UserHistoryResponseDto; -import com.gg.server.domain.user.dto.UserImageDto; -import com.gg.server.domain.user.dto.UserImageResponseDto; -import com.gg.server.domain.user.dto.UserLiveResponseDto; -import com.gg.server.domain.user.dto.UserNormalDetailResponseDto; -import com.gg.server.domain.user.dto.UserProfileImageRequestDto; -import com.gg.server.domain.user.dto.UserRankResponseDto; -import com.gg.server.domain.user.dto.UserTextColorDto; -import com.gg.server.domain.user.exception.UserImageLargeException; -import com.gg.server.domain.user.exception.UserImageNullException; -import com.gg.server.domain.user.exception.UserImageTypeException; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.domain.user.exception.UserTextColorException; -import com.gg.server.global.utils.ExpLevelCalculator; -import com.gg.server.global.utils.aws.AsyncNewUserImageUploader; - +import gg.pingpong.api.global.utils.ExpLevelCalculator; +import gg.pingpong.api.global.utils.aws.AsyncNewUserImageUploader; +import gg.pingpong.api.user.rank.service.RankFindService; +import gg.pingpong.api.user.season.service.SeasonFindService; +import gg.pingpong.api.user.store.service.CoinHistoryService; +import gg.pingpong.api.user.store.service.ItemService; +import gg.pingpong.api.user.store.service.UserCoinChangeService; +import gg.pingpong.api.user.user.controller.request.UserProfileImageRequestDto; +import gg.pingpong.api.user.user.controller.response.UserAttendanceResponseDto; +import gg.pingpong.api.user.user.controller.response.UserDetailResponseDto; +import gg.pingpong.api.user.user.controller.response.UserHistoryResponseDto; +import gg.pingpong.api.user.user.controller.response.UserImageResponseDto; +import gg.pingpong.api.user.user.controller.response.UserLiveResponseDto; +import gg.pingpong.api.user.user.controller.response.UserNormalDetailResponseDto; +import gg.pingpong.api.user.user.controller.response.UserRankResponseDto; +import gg.pingpong.api.user.user.dto.UserBackgroundDto; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.api.user.user.dto.UserEdgeDto; +import gg.pingpong.api.user.user.dto.UserHistoryData; +import gg.pingpong.api.user.user.dto.UserImageDto; +import gg.pingpong.api.user.user.dto.UserTextColorDto; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.PChange; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.rank.Rank; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.store.Receipt; +import gg.pingpong.data.store.type.ItemStatus; +import gg.pingpong.data.store.type.ItemType; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.UserImage; +import gg.pingpong.data.user.type.BackgroundType; +import gg.pingpong.data.user.type.EdgeType; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.game.PChangeRepository; +import gg.pingpong.repo.match.RedisMatchUserRepository; +import gg.pingpong.repo.noti.NotiRepository; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.RankV2Dto; +import gg.pingpong.repo.rank.TierRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.store.ReceiptRepository; +import gg.pingpong.repo.user.UserImageRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.exception.pchange.PChangeNotExistException; +import gg.pingpong.utils.exception.rank.RankNotFoundException; +import gg.pingpong.utils.exception.rank.RedisDataNotFoundException; +import gg.pingpong.utils.exception.receipt.ReceiptNotFoundException; +import gg.pingpong.utils.exception.tier.TierNotFoundException; +import gg.pingpong.utils.exception.user.UserImageLargeException; +import gg.pingpong.utils.exception.user.UserImageNullException; +import gg.pingpong.utils.exception.user.UserImageTypeException; +import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.pingpong.utils.exception.user.UserTextColorException; import lombok.RequiredArgsConstructor; @Service @@ -109,7 +108,7 @@ public class UserService { public List findByPartOfIntraId(String intraId) { Pageable pageable = PageRequest.of(0, 5, Sort.by("intraId").ascending()); Page pageUsers = userRepository.findByIntraIdContains(pageable, intraId); - return pageUsers.getContent().stream().map(user -> user.getIntraId()) + return pageUsers.getContent().stream().map(User::getIntraId) .collect(Collectors.toList()); } diff --git a/src/main/java/com/gg/server/domain/user/service/UserTextColorCheckService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserTextColorCheckService.java similarity index 93% rename from src/main/java/com/gg/server/domain/user/service/UserTextColorCheckService.java rename to gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserTextColorCheckService.java index 1ebafe0d0..34614ca41 100644 --- a/src/main/java/com/gg/server/domain/user/service/UserTextColorCheckService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserTextColorCheckService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.service; +package gg.pingpong.api.user.user.service; import org.springframework.stereotype.Service; diff --git a/src/main/resources/db/migration/V1.1__migration_42gg_5th.sql b/gg-pingpong-api/src/main/resources/db/migration/V1.1__migration_42gg_5th.sql similarity index 100% rename from src/main/resources/db/migration/V1.1__migration_42gg_5th.sql rename to gg-pingpong-api/src/main/resources/db/migration/V1.1__migration_42gg_5th.sql diff --git a/src/main/resources/db/migration/V1.2__update_tournament_content_column.sql b/gg-pingpong-api/src/main/resources/db/migration/V1.2__update_tournament_content_column.sql similarity index 100% rename from src/main/resources/db/migration/V1.2__update_tournament_content_column.sql rename to gg-pingpong-api/src/main/resources/db/migration/V1.2__update_tournament_content_column.sql diff --git a/src/main/resources/db/migration/V1__init.sql b/gg-pingpong-api/src/main/resources/db/migration/V1__init.sql similarity index 100% rename from src/main/resources/db/migration/V1__init.sql rename to gg-pingpong-api/src/main/resources/db/migration/V1__init.sql diff --git a/src/main/resources/logback-spring.xml b/gg-pingpong-api/src/main/resources/logback-spring.xml similarity index 94% rename from src/main/resources/logback-spring.xml rename to gg-pingpong-api/src/main/resources/logback-spring.xml index 596304b67..9918591b4 100644 --- a/src/main/resources/logback-spring.xml +++ b/gg-pingpong-api/src/main/resources/logback-spring.xml @@ -1,7 +1,7 @@ - + @@ -81,15 +81,15 @@ - - + + - - + + - \ No newline at end of file + diff --git a/src/test/java/com/gg/server/ServerApplicationTests.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/ServerPingpongApiApplicationTests.java similarity index 76% rename from src/test/java/com/gg/server/ServerApplicationTests.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/ServerPingpongApiApplicationTests.java index 1e1a1b9e0..2c3659ec2 100644 --- a/src/test/java/com/gg/server/ServerApplicationTests.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/ServerPingpongApiApplicationTests.java @@ -1,4 +1,4 @@ -package com.gg.server; +package gg.pingpong.api; import java.util.TimeZone; @@ -6,10 +6,10 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.utils.annotation.IntegrationTest; @IntegrationTest -class ServerApplicationTests { +class ServerPingpongApiApplicationTests { @Test void contextLoads() { diff --git a/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerFailTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerFailTest.java similarity index 89% rename from src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerFailTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerFailTest.java index 925fb0ba0..6c15ec17a 100644 --- a/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerFailTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerFailTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.announcement.controller; +package gg.pingpong.api.admin.announcement.controller; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -12,11 +12,11 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.announcement.data.AnnouncementAdminRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.admin.repo.manage.AnnouncementAdminRepository; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerTest.java similarity index 90% rename from src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerTest.java index 6ad68339b..33e976b68 100644 --- a/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.announcement.controller; +package gg.pingpong.api.admin.announcement.controller; import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; @@ -14,15 +14,15 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.announcement.data.AnnouncementAdminRepository; -import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; -import com.gg.server.admin.announcement.dto.AnnouncementAdminListResponseDto; -import com.gg.server.data.manage.Announcement; -import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.admin.repo.manage.AnnouncementAdminRepository; +import gg.pingpong.api.admin.manage.controller.response.AnnouncementAdminListResponseDto; +import gg.pingpong.api.admin.manage.dto.AnnouncementAdminAddDto; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.data.manage.Announcement; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.exception.announcement.AnnounceNotFoundException; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java similarity index 76% rename from src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java index 949e555e9..16aafd1ce 100644 --- a/src/test/java/com/gg/server/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java @@ -1,8 +1,7 @@ -package com.gg.server.admin.announcement.controller; +package gg.pingpong.api.admin.announcement.controller; import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; -import static org.mockito.Mockito.*; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -13,11 +12,12 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.domain.Pageable; -import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; -import com.gg.server.admin.announcement.dto.AnnouncementAdminListResponseDto; -import com.gg.server.admin.announcement.service.AnnouncementAdminService; -import com.gg.server.global.dto.PageRequestDto; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.admin.manage.controller.AnnouncementAdminController; +import gg.pingpong.api.admin.manage.controller.response.AnnouncementAdminListResponseDto; +import gg.pingpong.api.admin.manage.dto.AnnouncementAdminAddDto; +import gg.pingpong.api.admin.manage.service.AnnouncementAdminService; +import gg.pingpong.api.global.dto.PageRequestDto; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/admin/announcement/service/AnnouncementAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/service/AnnouncementAdminServiceUnitTest.java similarity index 89% rename from src/test/java/com/gg/server/admin/announcement/service/AnnouncementAdminServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/service/AnnouncementAdminServiceUnitTest.java index b73d753bc..6156a8e22 100644 --- a/src/test/java/com/gg/server/admin/announcement/service/AnnouncementAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/service/AnnouncementAdminServiceUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.announcement.service; +package gg.pingpong.api.admin.announcement.service; import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; @@ -19,12 +19,13 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import com.gg.server.admin.announcement.data.AnnouncementAdminRepository; -import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; -import com.gg.server.data.manage.Announcement; -import com.gg.server.domain.announcement.exception.AnnounceDupException; -import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.admin.repo.manage.AnnouncementAdminRepository; +import gg.pingpong.api.admin.manage.dto.AnnouncementAdminAddDto; +import gg.pingpong.api.admin.manage.service.AnnouncementAdminService; +import gg.pingpong.data.manage.Announcement; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.announcement.AnnounceDupException; +import gg.pingpong.utils.exception.announcement.AnnounceNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/admin/coin/controller/CoinAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinAdminControllerTest.java similarity index 85% rename from src/test/java/com/gg/server/admin/coin/controller/CoinAdminControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinAdminControllerTest.java index f1c3d6113..2a17455d6 100644 --- a/src/test/java/com/gg/server/admin/coin/controller/CoinAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinAdminControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.coin.controller; +package gg.pingpong.api.admin.coin.controller; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -14,12 +14,12 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.coin.dto.CoinUpdateRequestDto; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.admin.store.controller.request.CoinUpdateRequestDto; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerFailTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinPolicyAdminControllerFailTest.java similarity index 84% rename from src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerFailTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinPolicyAdminControllerFailTest.java index e6e487c9b..23330d5c9 100644 --- a/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerFailTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinPolicyAdminControllerFailTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.coin.controller; +package gg.pingpong.api.admin.coin.controller; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -13,12 +13,12 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.coin.data.CoinPolicyAdminRepository; -import com.gg.server.admin.coin.dto.CoinPolicyAdminAddDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.admin.repo.store.CoinPolicyAdminRepository; +import gg.pingpong.api.admin.store.dto.CoinPolicyAdminAddDto; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinPolicyAdminControllerTest.java similarity index 85% rename from src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinPolicyAdminControllerTest.java index f42352706..e0a25e218 100644 --- a/src/test/java/com/gg/server/admin/coin/controller/CoinPolicyAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinPolicyAdminControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.coin.controller; +package gg.pingpong.api.admin.coin.controller; import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; @@ -16,16 +16,16 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.coin.data.CoinPolicyAdminRepository; -import com.gg.server.admin.coin.dto.CoinPolicyAdminAddDto; -import com.gg.server.admin.coin.dto.CoinPolicyAdminListResponseDto; -import com.gg.server.data.manage.CoinPolicy; -import com.gg.server.data.user.User; -import com.gg.server.domain.coin.exception.CoinPolicyNotFoundException; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.admin.repo.store.CoinPolicyAdminRepository; +import gg.pingpong.api.admin.store.controller.response.CoinPolicyAdminListResponseDto; +import gg.pingpong.api.admin.store.dto.CoinPolicyAdminAddDto; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.data.store.CoinPolicy; +import gg.pingpong.data.user.User; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.exception.coin.CoinPolicyNotFoundException; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @@ -97,7 +97,7 @@ void addCoinPolicy() throws Exception { .andReturn().getResponse().getContentAsString(); CoinPolicy result = coinPolicyAdminRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinPolicyNotFoundException()); + .orElseThrow(CoinPolicyNotFoundException::new); assertThat(result.getAttendance()).isEqualTo(addDto.getAttendance()); assertThat(result.getNormal()).isEqualTo(addDto.getNormal()); diff --git a/src/test/java/com/gg/server/admin/coin/service/CoinAdminServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/service/CoinAdminServiceTest.java similarity index 77% rename from src/test/java/com/gg/server/admin/coin/service/CoinAdminServiceTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/service/CoinAdminServiceTest.java index e73356a0b..b3ebecd1b 100644 --- a/src/test/java/com/gg/server/admin/coin/service/CoinAdminServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/service/CoinAdminServiceTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.coin.service; +package gg.pingpong.api.admin.coin.service; import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; @@ -14,13 +14,14 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.admin.coin.dto.CoinUpdateRequestDto; -import com.gg.server.data.store.CoinHistory; -import com.gg.server.data.user.User; -import com.gg.server.domain.coin.service.CoinHistoryService; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.admin.store.controller.request.CoinUpdateRequestDto; +import gg.pingpong.api.admin.store.service.CoinAdminService; +import gg.pingpong.api.user.store.service.CoinHistoryService; +import gg.pingpong.data.store.CoinHistory; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/controller/FeedbackAdminControllerTest.java similarity index 89% rename from src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/controller/FeedbackAdminControllerTest.java index f5b1e846e..938fc97ce 100644 --- a/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/controller/FeedbackAdminControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.feedback.controller; +package gg.pingpong.api.admin.feedback.controller; import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; @@ -13,16 +13,16 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.feedback.data.FeedbackAdminRepository; -import com.gg.server.admin.feedback.dto.FeedbackListAdminResponseDto; -import com.gg.server.data.manage.Feedback; -import com.gg.server.data.manage.type.FeedbackType; -import com.gg.server.data.user.User; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.admin.repo.manage.FeedbackAdminRepository; +import gg.pingpong.api.admin.manage.controller.response.FeedbackListAdminResponseDto; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.data.manage.Feedback; +import gg.pingpong.data.manage.type.FeedbackType; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/controller/FeedbackAdminControllerUnitTest.java similarity index 81% rename from src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/controller/FeedbackAdminControllerUnitTest.java index 4556d25bb..fc06b4084 100644 --- a/src/test/java/com/gg/server/admin/feedback/controller/FeedbackAdminControllerUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/controller/FeedbackAdminControllerUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.feedback.controller; +package gg.pingpong.api.admin.feedback.controller; import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; @@ -12,10 +12,11 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.domain.Pageable; -import com.gg.server.admin.feedback.dto.FeedbackAdminPageRequestDto; -import com.gg.server.admin.feedback.dto.FeedbackListAdminResponseDto; -import com.gg.server.admin.feedback.service.FeedbackAdminService; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.admin.manage.controller.FeedbackAdminController; +import gg.pingpong.api.admin.manage.controller.request.FeedbackAdminPageRequestDto; +import gg.pingpong.api.admin.manage.controller.response.FeedbackListAdminResponseDto; +import gg.pingpong.api.admin.manage.service.FeedbackAdminService; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/admin/feedback/service/FeedbackAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/service/FeedbackAdminServiceUnitTest.java similarity index 89% rename from src/test/java/com/gg/server/admin/feedback/service/FeedbackAdminServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/service/FeedbackAdminServiceUnitTest.java index ea49763bf..7e7130fab 100644 --- a/src/test/java/com/gg/server/admin/feedback/service/FeedbackAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/service/FeedbackAdminServiceUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.feedback.service; +package gg.pingpong.api.admin.feedback.service; import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; @@ -18,10 +18,11 @@ import org.springframework.data.domain.Pageable; import org.springframework.test.util.ReflectionTestUtils; -import com.gg.server.admin.feedback.data.FeedbackAdminRepository; -import com.gg.server.data.manage.Feedback; -import com.gg.server.domain.feedback.exception.FeedbackNotFoundException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.admin.repo.manage.FeedbackAdminRepository; +import gg.pingpong.api.admin.manage.service.FeedbackAdminService; +import gg.pingpong.data.manage.Feedback; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.feedback.FeedbackNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/game/controller/GameAdminControllerTest.java similarity index 90% rename from src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/game/controller/GameAdminControllerTest.java index 36e20171b..16c60334c 100644 --- a/src/test/java/com/gg/server/admin/game/controller/GameAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/game/controller/GameAdminControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.game.controller; +package gg.pingpong.api.admin.game.controller; import static java.lang.Thread.*; import static org.assertj.core.api.Assertions.*; @@ -24,26 +24,26 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.game.dto.GameLogListAdminResponseDto; -import com.gg.server.admin.game.dto.RankGamePPPModifyReqDto; -import com.gg.server.data.game.Rank; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Tier; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.game.dto.request.RankResultReqDto; -import com.gg.server.domain.game.service.GameService; -import com.gg.server.domain.match.service.GameUpdateService; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.user.controller.dto.GameInfoDto; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.admin.game.controller.response.GameLogListAdminResponseDto; +import gg.pingpong.api.admin.game.dto.RankGamePPPModifyReqDto; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.game.controller.request.RankResultReqDto; +import gg.pingpong.api.user.game.service.GameService; +import gg.pingpong.api.user.match.service.GameUpdateService; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.rank.Rank; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.game.out.GameTeamUser; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.dto.GameInfoDto; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/admin/item/controller/ItemAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/item/controller/ItemAdminControllerTest.java similarity index 87% rename from src/test/java/com/gg/server/admin/item/controller/ItemAdminControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/item/controller/ItemAdminControllerTest.java index e12f18574..d2aa62eda 100644 --- a/src/test/java/com/gg/server/admin/item/controller/ItemAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/item/controller/ItemAdminControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.item.controller; +package gg.pingpong.api.admin.item.controller; import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; @@ -23,18 +23,19 @@ import org.springframework.test.web.servlet.MockMvc; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.item.data.ItemAdminRepository; -import com.gg.server.admin.item.dto.ItemListResponseDto; -import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.admin.item.service.ItemAdminService; -import com.gg.server.data.store.Item; -import com.gg.server.data.store.type.ItemType; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.global.utils.ItemImageHandler; -import com.gg.server.utils.ItemTestUtils; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; + +import gg.pingpong.admin.repo.store.ItemAdminRepository; +import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; +import gg.pingpong.api.admin.store.controller.response.ItemListResponseDto; +import gg.pingpong.api.admin.store.service.ItemAdminService; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.global.utils.ItemImageHandler; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.store.type.ItemType; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.ItemTestUtils; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; @IntegrationTest @AutoConfigureMockMvc diff --git a/src/test/java/com/gg/server/admin/item/service/ItemAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/item/service/ItemAdminServiceUnitTest.java similarity index 81% rename from src/test/java/com/gg/server/admin/item/service/ItemAdminServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/item/service/ItemAdminServiceUnitTest.java index 6b49f9809..efb9d9bd2 100644 --- a/src/test/java/com/gg/server/admin/item/service/ItemAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/item/service/ItemAdminServiceUnitTest.java @@ -1,6 +1,6 @@ -package com.gg.server.admin.item.service; +package gg.pingpong.api.admin.item.service; -import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static gg.pingpong.api.utils.ReflectionUtilsForUnitTest.*; import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; @@ -20,18 +20,19 @@ import org.springframework.data.domain.Pageable; import org.springframework.web.multipart.MultipartFile; -import com.gg.server.admin.item.data.ItemAdminRepository; -import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.admin.item.exception.ItemNotFoundException; -import com.gg.server.data.store.Item; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.item.exception.ItemNotAvailableException; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.utils.aws.AsyncNewItemImageUploader; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.admin.repo.store.ItemAdminRepository; +import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; +import gg.pingpong.api.admin.store.service.ItemAdminService; +import gg.pingpong.api.global.utils.aws.AsyncNewItemImageUploader; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.item.ItemNotAvailableException; +import gg.pingpong.utils.exception.item.ItemNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) @@ -40,6 +41,7 @@ class ItemAdminServiceUnitTest { ItemAdminRepository itemAdminRepository; @Mock AsyncNewItemImageUploader asyncNewItemImageUploader; + @InjectMocks ItemAdminService itemAdminService; @@ -76,11 +78,15 @@ void success() throws Exception { // given given(itemAdminRepository.findById(any(Long.class))).willReturn(Optional.of(item)); given(itemAdminRepository.save(any(Item.class))).willReturn(mock(Item.class)); + ItemUpdateRequestDto mockRequest = mock(ItemUpdateRequestDto.class); + when(mockRequest.toItem(any(), any())).thenReturn(mock(Item.class)); + // when, then - itemAdminService.updateItem(1L, mock(ItemUpdateRequestDto.class), + itemAdminService.updateItem(1L, mockRequest, mock(MultipartFile.class), UserDto.from(user)); setFieldWithReflection(item, "isVisible", true); - itemAdminService.updateItem(1L, mock(ItemUpdateRequestDto.class), + + itemAdminService.updateItem(1L, mockRequest, null, UserDto.from(user)); verify(itemAdminRepository, times(2)).findById(any(Long.class)); verify(asyncNewItemImageUploader, times(1)).upload(any(), any()); @@ -124,8 +130,11 @@ void success() throws Exception { // given given(itemAdminRepository.findById(any(Long.class))).willReturn(Optional.of(item)); given(itemAdminRepository.save(any(Item.class))).willReturn(mock(Item.class)); + ItemUpdateRequestDto mockRequest = mock(ItemUpdateRequestDto.class); + when(mockRequest.toItem(any(), any())).thenReturn(mock(Item.class)); + // when, then - itemAdminService.updateItem(1L, mock(ItemUpdateRequestDto.class), UserDto.from(user)); + itemAdminService.updateItem(1L, mockRequest, UserDto.from(user)); assertThat(item.getDeleterIntraId()).isEqualTo(user.getIntraId()); verify(itemAdminRepository, times(1)).findById(any(Long.class)); verify(itemAdminRepository, times(1)).save(any(Item.class)); diff --git a/src/test/java/com/gg/server/admin/megaphone/controller/MegaphoneAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/megaphone/controller/MegaphoneAdminControllerTest.java similarity index 86% rename from src/test/java/com/gg/server/admin/megaphone/controller/MegaphoneAdminControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/megaphone/controller/MegaphoneAdminControllerTest.java index 43605f159..b87cbe20a 100644 --- a/src/test/java/com/gg/server/admin/megaphone/controller/MegaphoneAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/megaphone/controller/MegaphoneAdminControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.megaphone.controller; +package gg.pingpong.api.admin.megaphone.controller; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -12,10 +12,9 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.test.web.servlet.MockMvc; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; - +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java similarity index 88% rename from src/test/java/com/gg/server/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java index 3202aee61..b0c8a6ed7 100644 --- a/src/test/java/com/gg/server/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java @@ -1,8 +1,7 @@ -package com.gg.server.admin.megaphone.service; +package gg.pingpong.api.admin.megaphone.service; import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; -import static org.mockito.Mockito.*; import java.util.ArrayList; @@ -16,8 +15,9 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import com.gg.server.admin.megaphone.data.MegaphoneAdminRepository; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.admin.repo.store.MegaphoneAdminRepository; +import gg.pingpong.api.admin.store.service.MegaphoneAdminService; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/admin/noti/controller/NotiAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/noti/controller/NotiAdminControllerTest.java similarity index 88% rename from src/test/java/com/gg/server/admin/noti/controller/NotiAdminControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/noti/controller/NotiAdminControllerTest.java index 82e415c56..d56523fbe 100644 --- a/src/test/java/com/gg/server/admin/noti/controller/NotiAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/noti/controller/NotiAdminControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.noti.controller; +package gg.pingpong.api.admin.noti.controller; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; @@ -22,20 +22,20 @@ import org.springframework.test.web.servlet.MockMvc; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.noti.data.NotiAdminRepository; -import com.gg.server.admin.noti.dto.NotiAdminDto; -import com.gg.server.admin.noti.dto.NotiListAdminResponseDto; -import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; -import com.gg.server.admin.noti.service.NotiAdminService; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.noti.type.NotiType; -import com.gg.server.data.user.User; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.admin.repo.noti.NotiAdminRepository; +import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; +import gg.pingpong.api.admin.noti.controller.response.NotiListAdminResponseDto; +import gg.pingpong.api.admin.noti.dto.NotiAdminDto; +import gg.pingpong.api.admin.noti.service.NotiAdminService; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.noti.type.NotiType; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.noti.NotiRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/admin/noti/service/NotiAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/noti/service/NotiAdminServiceUnitTest.java similarity index 80% rename from src/test/java/com/gg/server/admin/noti/service/NotiAdminServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/noti/service/NotiAdminServiceUnitTest.java index 41fa58b77..19e499883 100644 --- a/src/test/java/com/gg/server/admin/noti/service/NotiAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/noti/service/NotiAdminServiceUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.noti.service; +package gg.pingpong.api.admin.noti.service; import static org.assertj.core.api.AssertionsForClassTypes.*; import static org.mockito.ArgumentMatchers.*; @@ -18,15 +18,15 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import com.gg.server.admin.noti.data.NotiAdminRepository; -import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; -import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.user.User; -import com.gg.server.domain.noti.service.SnsNotiService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.admin.repo.noti.NotiAdminRepository; +import gg.pingpong.admin.repo.user.UserAdminRepository; +import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; +import gg.pingpong.api.user.noti.service.SnsNotiService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.user.User; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) @@ -88,7 +88,7 @@ void success() { given(notiAdminRepository.findAll(any(Pageable.class))).willReturn(new PageImpl<>(Collections.emptyList())); //when - notiAdminService.getAllNoti(mock(org.springframework.data.domain.Pageable.class)); + notiAdminService.getAllNoti(mock(Pageable.class)); //then verify(notiAdminRepository, times(1)).findAll(any(Pageable.class)); @@ -102,7 +102,7 @@ class GetFilteredNotificationsTest { @DisplayName("성공") void success() { //given - given(notiAdminRepository.findNotisByUserIntraId(any(org.springframework.data.domain.Pageable.class), + given(notiAdminRepository.findNotisByUserIntraId(any(Pageable.class), any(String.class))) .willReturn(new PageImpl<>(Collections.emptyList())); @@ -111,7 +111,7 @@ void success() { //then verify(notiAdminRepository, times(1)).findNotisByUserIntraId( - any(org.springframework.data.domain.Pageable.class), any(String.class)); + any(Pageable.class), any(String.class)); } } } diff --git a/src/test/java/com/gg/server/admin/penalty/controller/PenaltyAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/penalty/controller/PenaltyAdminControllerTest.java similarity index 94% rename from src/test/java/com/gg/server/admin/penalty/controller/PenaltyAdminControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/penalty/controller/PenaltyAdminControllerTest.java index e693f0d33..637998d7a 100644 --- a/src/test/java/com/gg/server/admin/penalty/controller/PenaltyAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/penalty/controller/PenaltyAdminControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.penalty.controller; +package gg.pingpong.api.admin.penalty.controller; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; @@ -27,22 +27,23 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.penalty.data.PenaltyAdminRepository; -import com.gg.server.admin.penalty.data.PenaltyUserAdminRedisRepository; -import com.gg.server.admin.penalty.dto.PenaltyListResponseDto; -import com.gg.server.admin.penalty.dto.PenaltyRequestDto; -import com.gg.server.admin.penalty.service.PenaltyAdminService; -import com.gg.server.data.manage.Penalty; -import com.gg.server.data.manage.redis.RedisPenaltyUser; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.penalty.type.PenaltyType; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; + +import gg.pingpong.admin.repo.manage.PenaltyAdminRepository; +import gg.pingpong.admin.repo.manage.PenaltyUserAdminRedisRepository; +import gg.pingpong.api.admin.manage.controller.request.PenaltyRequestDto; +import gg.pingpong.api.admin.manage.controller.response.PenaltyListResponseDto; +import gg.pingpong.api.admin.manage.service.PenaltyAdminService; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.data.manage.Penalty; +import gg.pingpong.data.manage.redis.RedisPenaltyUser; +import gg.pingpong.data.manage.type.PenaltyType; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; @IntegrationTest @AutoConfigureMockMvc diff --git a/src/test/java/com/gg/server/admin/receipt/controller/ReceiptAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/receipt/controller/ReceiptAdminControllerTest.java similarity index 87% rename from src/test/java/com/gg/server/admin/receipt/controller/ReceiptAdminControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/receipt/controller/ReceiptAdminControllerTest.java index 8e975eb0d..0a3d7847c 100644 --- a/src/test/java/com/gg/server/admin/receipt/controller/ReceiptAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/receipt/controller/ReceiptAdminControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.receipt.controller; +package gg.pingpong.api.admin.receipt.controller; import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; @@ -17,17 +17,18 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.admin.receipt.data.ReceiptAdminRepository; -import com.gg.server.admin.receipt.dto.ReceiptListResponseDto; -import com.gg.server.admin.receipt.service.ReceiptAdminService; -import com.gg.server.data.store.Item; -import com.gg.server.data.store.type.ItemType; -import com.gg.server.data.user.User; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.ItemTestUtils; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; + +import gg.pingpong.admin.repo.store.ReceiptAdminRepository; +import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; +import gg.pingpong.api.admin.store.controller.response.ReceiptListResponseDto; +import gg.pingpong.api.admin.store.service.ReceiptAdminService; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.store.type.ItemType; +import gg.pingpong.data.user.User; +import gg.pingpong.utils.ItemTestUtils; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; @IntegrationTest @AutoConfigureMockMvc diff --git a/src/test/java/com/gg/server/admin/receipt/service/ReceiptAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/receipt/service/ReceiptAdminServiceUnitTest.java similarity index 85% rename from src/test/java/com/gg/server/admin/receipt/service/ReceiptAdminServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/receipt/service/ReceiptAdminServiceUnitTest.java index 3006aec28..b6a5cb51f 100644 --- a/src/test/java/com/gg/server/admin/receipt/service/ReceiptAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/receipt/service/ReceiptAdminServiceUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.receipt.service; +package gg.pingpong.api.admin.receipt.service; import static org.mockito.BDDMockito.*; @@ -14,9 +14,10 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import com.gg.server.admin.receipt.data.ReceiptAdminRepository; -import com.gg.server.data.store.Receipt; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.admin.repo.store.ReceiptAdminRepository; +import gg.pingpong.api.admin.store.service.ReceiptAdminService; +import gg.pingpong.data.store.Receipt; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/admin/season/SeasonAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/controller/SeasonAdminControllerTest.java similarity index 86% rename from src/test/java/com/gg/server/admin/season/SeasonAdminControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/controller/SeasonAdminControllerTest.java index 876158f3d..fad13af5f 100644 --- a/src/test/java/com/gg/server/admin/season/SeasonAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/controller/SeasonAdminControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.season; +package gg.pingpong.api.admin.season.controller; import static org.assertj.core.api.Assertions.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -17,27 +17,27 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.rank.service.RankAdminService; -import com.gg.server.admin.rank.service.RankRedisAdminService; -import com.gg.server.admin.season.data.SeasonAdminRepository; -import com.gg.server.admin.season.dto.SeasonAdminDto; -import com.gg.server.admin.season.dto.SeasonCreateRequestDto; -import com.gg.server.admin.season.dto.SeasonListAdminResponseDto; -import com.gg.server.admin.season.dto.SeasonUpdateRequestDto; -import com.gg.server.admin.season.service.SeasonAdminService; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Tier; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.exception.RedisDataNotFoundException; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.exception.SeasonForbiddenException; -import com.gg.server.domain.season.exception.SeasonNotFoundException; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; import com.google.common.net.HttpHeaders; +import gg.pingpong.admin.repo.season.SeasonAdminRepository; +import gg.pingpong.api.admin.rank.service.RankAdminService; +import gg.pingpong.api.admin.rank.service.RankRedisAdminService; +import gg.pingpong.api.admin.season.controller.request.SeasonCreateRequestDto; +import gg.pingpong.api.admin.season.controller.request.SeasonUpdateRequestDto; +import gg.pingpong.api.admin.season.controller.response.SeasonListAdminResponseDto; +import gg.pingpong.api.admin.season.dto.SeasonAdminDto; +import gg.pingpong.api.admin.season.service.SeasonAdminService; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.season.Season; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.exception.rank.RedisDataNotFoundException; +import gg.pingpong.utils.exception.season.SeasonForbiddenException; +import gg.pingpong.utils.exception.season.SeasonNotFoundException; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/service/SeasonAdminServiceUnitTest.java similarity index 93% rename from src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/service/SeasonAdminServiceUnitTest.java index 1e6b197ac..daf55c386 100644 --- a/src/test/java/com/gg/server/admin/season/service/SeasonAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/service/SeasonAdminServiceUnitTest.java @@ -1,6 +1,6 @@ -package com.gg.server.admin.season.service; +package gg.pingpong.api.admin.season.service; -import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static gg.pingpong.api.utils.ReflectionUtilsForUnitTest.*; import static org.assertj.core.api.Assertions.*; import static org.mockito.BDDMockito.*; @@ -19,16 +19,16 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.admin.rank.service.RankAdminService; -import com.gg.server.admin.rank.service.RankRedisAdminService; -import com.gg.server.admin.season.data.SeasonAdminRepository; -import com.gg.server.admin.season.dto.SeasonCreateRequestDto; -import com.gg.server.admin.season.dto.SeasonUpdateRequestDto; -import com.gg.server.data.game.Season; -import com.gg.server.domain.season.exception.SeasonForbiddenException; -import com.gg.server.domain.season.exception.SeasonNotFoundException; -import com.gg.server.domain.season.exception.SeasonTimeBeforeException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.admin.repo.season.SeasonAdminRepository; +import gg.pingpong.api.admin.rank.service.RankAdminService; +import gg.pingpong.api.admin.rank.service.RankRedisAdminService; +import gg.pingpong.api.admin.season.controller.request.SeasonCreateRequestDto; +import gg.pingpong.api.admin.season.controller.request.SeasonUpdateRequestDto; +import gg.pingpong.data.season.Season; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.season.SeasonForbiddenException; +import gg.pingpong.utils.exception.season.SeasonNotFoundException; +import gg.pingpong.utils.exception.season.SeasonTimeBeforeException; @UnitTest @ExtendWith(MockitoExtension.class) @@ -87,7 +87,13 @@ class CreateSeason { void beforeEach() { requestDto = new SeasonCreateRequestDto("season", LocalDateTime.now().plusDays(1).plusSeconds(1), 1000, 200); - season = new Season(requestDto); + season = Season.builder() + .seasonName(requestDto.getSeasonName()) + .startTime(requestDto.getStartTime()) + .startPpp(requestDto.getStartPpp()) + .pppGap(requestDto.getPppGap()) + .build(); + setFieldWithReflection(beforeSeasons.get(0), "id", 2L); beforeSeasonsAsc = new ArrayList<>(beforeSeasons); Collections.reverse(beforeSeasonsAsc); diff --git a/src/test/java/com/gg/server/admin/slotmanagement/controller/SlotAdminControllerFailTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/controller/SlotAdminControllerFailTest.java similarity index 91% rename from src/test/java/com/gg/server/admin/slotmanagement/controller/SlotAdminControllerFailTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/controller/SlotAdminControllerFailTest.java index 1741e2f64..1d791935f 100644 --- a/src/test/java/com/gg/server/admin/slotmanagement/controller/SlotAdminControllerFailTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/controller/SlotAdminControllerFailTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.slotmanagement.controller; +package gg.pingpong.api.admin.slotmanagement.controller; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -16,14 +16,14 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.slotmanagement.data.AdminSlotManagementsRepository; -import com.gg.server.admin.slotmanagement.dto.SlotCreateRequestDto; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.admin.repo.manage.AdminSlotManagementsRepository; +import gg.pingpong.api.admin.manage.controller.request.SlotCreateRequestDto; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/admin/slotmanagement/controller/SlotAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/controller/SlotAdminControllerTest.java similarity index 91% rename from src/test/java/com/gg/server/admin/slotmanagement/controller/SlotAdminControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/controller/SlotAdminControllerTest.java index ad722e176..8b9b0afee 100644 --- a/src/test/java/com/gg/server/admin/slotmanagement/controller/SlotAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/controller/SlotAdminControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.slotmanagement.controller; +package gg.pingpong.api.admin.slotmanagement.controller; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -17,16 +17,16 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.slotmanagement.data.AdminSlotManagementsRepository; -import com.gg.server.admin.slotmanagement.dto.SlotAdminDto; -import com.gg.server.admin.slotmanagement.dto.SlotCreateRequestDto; -import com.gg.server.admin.slotmanagement.dto.SlotListAdminResponseDto; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.admin.repo.manage.AdminSlotManagementsRepository; +import gg.pingpong.api.admin.manage.controller.request.SlotCreateRequestDto; +import gg.pingpong.api.admin.manage.controller.response.SlotListAdminResponseDto; +import gg.pingpong.api.admin.manage.dto.SlotAdminDto; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/admin/slotmanagement/service/SlotAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/service/SlotAdminServiceUnitTest.java similarity index 90% rename from src/test/java/com/gg/server/admin/slotmanagement/service/SlotAdminServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/service/SlotAdminServiceUnitTest.java index 60daac251..c4919577b 100644 --- a/src/test/java/com/gg/server/admin/slotmanagement/service/SlotAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/service/SlotAdminServiceUnitTest.java @@ -1,6 +1,6 @@ -package com.gg.server.admin.slotmanagement.service; +package gg.pingpong.api.admin.slotmanagement.service; -import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static gg.pingpong.api.utils.ReflectionUtilsForUnitTest.*; import static org.assertj.core.api.Assertions.*; import static org.mockito.BDDMockito.*; @@ -18,11 +18,12 @@ import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -import com.gg.server.admin.slotmanagement.data.AdminSlotManagementsRepository; -import com.gg.server.admin.slotmanagement.dto.SlotCreateRequestDto; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.exception.SlotManagementForbiddenException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.admin.repo.manage.AdminSlotManagementsRepository; +import gg.pingpong.api.admin.manage.controller.request.SlotCreateRequestDto; +import gg.pingpong.api.admin.manage.service.SlotAdminService; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.slotmanagement.SlotManagementForbiddenException; @UnitTest class SlotAdminServiceUnitTest { diff --git a/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminControllerTest.java similarity index 95% rename from src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminControllerTest.java index 1d113eb35..fdf7d6384 100644 --- a/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.tournament.controller; +package gg.pingpong.api.admin.tournament.controller; import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; @@ -20,33 +20,33 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.tournament.dto.TournamentAdminAddUserRequestDto; -import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; -import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; -import com.gg.server.admin.tournament.dto.TournamentGameUpdateRequestDto; -import com.gg.server.admin.tournament.service.TournamentAdminService; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.TournamentUser; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; -import com.gg.server.data.user.User; -import com.gg.server.domain.match.utils.MatchIntegrationTestUtils; -import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.team.dto.TeamReqDto; -import com.gg.server.domain.tournament.data.TournamentGameRepository; -import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.data.TournamentUserRepository; -import com.gg.server.domain.user.controller.dto.GameInfoDto; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.CustomRuntimeException; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminAddUserRequestDto; +import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminCreateRequestDto; +import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminUpdateRequestDto; +import gg.pingpong.api.admin.tournament.controller.request.TournamentGameUpdateRequestDto; +import gg.pingpong.api.admin.tournament.service.TournamentAdminService; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.game.dto.TeamReqDto; +import gg.pingpong.api.user.match.utils.MatchIntegrationTestUtils; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.TournamentUser; +import gg.pingpong.data.tournament.type.TournamentRound; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.PChangeRepository; +import gg.pingpong.repo.tournarment.TournamentGameRepository; +import gg.pingpong.repo.tournarment.TournamentRepository; +import gg.pingpong.repo.tournarment.TournamentUserRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.dto.GameInfoDto; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.CustomRuntimeException; import lombok.RequiredArgsConstructor; @IntegrationTest diff --git a/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminUserControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminUserControllerTest.java similarity index 86% rename from src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminUserControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminUserControllerTest.java index 336dc3401..10d3e18ec 100644 --- a/src/test/java/com/gg/server/admin/tournament/controller/TournamentAdminUserControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminUserControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.tournament.controller; +package gg.pingpong.api.admin.tournament.controller; import static org.assertj.core.api.AssertionsForClassTypes.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; @@ -15,16 +15,16 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.tournament.dto.TournamentUserListResponseDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.tournament.controller.response.TournamentUserListResponseDto; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.extern.slf4j.Slf4j; @IntegrationTest diff --git a/src/test/java/com/gg/server/admin/tournament/service/TournamentAdminServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/service/TournamentAdminServiceTest.java similarity index 93% rename from src/test/java/com/gg/server/admin/tournament/service/TournamentAdminServiceTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/service/TournamentAdminServiceTest.java index 5c1099e82..3a1534492 100644 --- a/src/test/java/com/gg/server/admin/tournament/service/TournamentAdminServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/service/TournamentAdminServiceTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.tournament.service; +package gg.pingpong.api.admin.tournament.service; import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; @@ -17,34 +17,34 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.admin.tournament.dto.TournamentAdminAddUserRequestDto; -import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; -import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.TournamentUser; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tournament.data.TournamentGameRepository; -import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.data.TournamentUserRepository; -import com.gg.server.domain.tournament.exception.TournamentConflictException; -import com.gg.server.domain.tournament.exception.TournamentNotFoundException; -import com.gg.server.domain.tournament.exception.TournamentUpdateException; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.global.config.ConstantConfig; -import com.gg.server.utils.ReflectionUtilsForUnitTest; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminAddUserRequestDto; +import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminCreateRequestDto; +import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminUpdateRequestDto; +import gg.pingpong.api.global.config.ConstantConfig; +import gg.pingpong.api.utils.ReflectionUtilsForUnitTest; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.TournamentUser; +import gg.pingpong.data.tournament.type.TournamentRound; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.repo.tournarment.TournamentGameRepository; +import gg.pingpong.repo.tournarment.TournamentRepository; +import gg.pingpong.repo.tournarment.TournamentUserRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.tournament.TournamentConflictException; +import gg.pingpong.utils.exception.tournament.TournamentNotFoundException; +import gg.pingpong.utils.exception.tournament.TournamentUpdateException; +import gg.pingpong.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/admin/user/controller/UserAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/user/controller/UserAdminControllerTest.java similarity index 91% rename from src/test/java/com/gg/server/admin/user/controller/UserAdminControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/admin/user/controller/UserAdminControllerTest.java index 7131e984c..b5e31f7cc 100644 --- a/src/test/java/com/gg/server/admin/user/controller/UserAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/user/controller/UserAdminControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.user.controller; +package gg.pingpong.api.admin.user.controller; import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; @@ -21,22 +21,22 @@ import org.springframework.test.web.servlet.MockMvc; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.user.data.UserAdminRepository; -import com.gg.server.admin.user.data.UserImageAdminRepository; -import com.gg.server.admin.user.dto.UserDetailAdminResponseDto; -import com.gg.server.admin.user.dto.UserImageAdminDto; -import com.gg.server.admin.user.dto.UserImageListAdminResponseDto; -import com.gg.server.admin.user.dto.UserSearchAdminDto; -import com.gg.server.admin.user.dto.UserSearchAdminResponseDto; -import com.gg.server.admin.user.service.UserAdminService; -import com.gg.server.data.user.User; -import com.gg.server.data.user.UserImage; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.admin.repo.user.UserAdminRepository; +import gg.pingpong.admin.repo.user.UserImageAdminRepository; +import gg.pingpong.api.admin.user.controller.response.UserDetailAdminResponseDto; +import gg.pingpong.api.admin.user.controller.response.UserImageListAdminResponseDto; +import gg.pingpong.api.admin.user.controller.response.UserSearchAdminResponseDto; +import gg.pingpong.api.admin.user.dto.UserImageAdminDto; +import gg.pingpong.api.admin.user.dto.UserSearchAdminDto; +import gg.pingpong.api.admin.user.service.UserAdminService; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.UserImage; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/data/game/GameUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/GameUnitTest.java similarity index 91% rename from src/test/java/com/gg/server/data/game/GameUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/GameUnitTest.java index e7dfb810b..d214e1ef1 100644 --- a/src/test/java/com/gg/server/data/game/GameUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/GameUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game; +package gg.pingpong.api.data.game; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; @@ -13,9 +13,11 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.Team; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; @UnitTest @DisplayName("GameUnitTest") diff --git a/src/test/java/com/gg/server/data/game/PChangeDataTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/PChangeDataTest.java similarity index 85% rename from src/test/java/com/gg/server/data/game/PChangeDataTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/PChangeDataTest.java index df4294887..28a1b7c31 100644 --- a/src/test/java/com/gg/server/data/game/PChangeDataTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/PChangeDataTest.java @@ -1,11 +1,12 @@ -package com.gg.server.data.game; +package gg.pingpong.api.data.game; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.data.game.PChange; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/data/game/TeamUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TeamUnitTest.java similarity index 92% rename from src/test/java/com/gg/server/data/game/TeamUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TeamUnitTest.java index aa07492a7..0222884b6 100644 --- a/src/test/java/com/gg/server/data/game/TeamUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TeamUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game; +package gg.pingpong.api.data.game; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; @@ -13,9 +13,11 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; @UnitTest @DisplayName("TeamUnitTest") diff --git a/src/test/java/com/gg/server/data/game/TournamentGameUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TournamentGameUnitTest.java similarity index 72% rename from src/test/java/com/gg/server/data/game/TournamentGameUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TournamentGameUnitTest.java index 0fda86517..18b495481 100644 --- a/src/test/java/com/gg/server/data/game/TournamentGameUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TournamentGameUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game; +package gg.pingpong.api.data.game; import java.time.LocalDateTime; @@ -8,9 +8,12 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @DisplayName("TournamentGameUnitTest") diff --git a/src/test/java/com/gg/server/data/game/TournamentUserUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TournamentUserUnitTest.java similarity index 81% rename from src/test/java/com/gg/server/data/game/TournamentUserUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TournamentUserUnitTest.java index 5af6b5a5d..0313d7235 100644 --- a/src/test/java/com/gg/server/data/game/TournamentUserUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TournamentUserUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game; +package gg.pingpong.api.data.game; import java.time.LocalDateTime; @@ -8,10 +8,12 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; -import com.gg.server.data.user.User; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentUser; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; +import gg.pingpong.data.user.User; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @DisplayName("TournamentUserUnitTest") diff --git a/src/test/java/com/gg/server/data/manage/AnnouncementUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/manage/AnnouncementUnitTest.java similarity index 82% rename from src/test/java/com/gg/server/data/manage/AnnouncementUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/data/manage/AnnouncementUnitTest.java index 9b29a98c2..1c73b54b0 100644 --- a/src/test/java/com/gg/server/data/manage/AnnouncementUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/manage/AnnouncementUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.data.manage; +package gg.pingpong.api.data.manage; import static org.assertj.core.api.Assertions.*; @@ -10,8 +10,9 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.admin.manage.dto.AnnouncementAdminAddDto; +import gg.pingpong.data.manage.Announcement; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) @@ -38,7 +39,7 @@ void updateTest() { @DisplayName("from_메서드_unitTest") void fromTest() { AnnouncementAdminAddDto dto = new AnnouncementAdminAddDto(content, intraId); - Announcement announcement = Announcement.from(dto); + Announcement announcement = Announcement.from(dto.getContent(), dto.getCreatorIntraId()); assertThat(announcement.getContent()).isEqualTo(dto.getContent()); assertThat(announcement.getCreatorIntraId()).isEqualTo(dto.getCreatorIntraId()); } diff --git a/src/test/java/com/gg/server/data/store/ItemUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/store/ItemUnitTest.java similarity index 84% rename from src/test/java/com/gg/server/data/store/ItemUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/data/store/ItemUnitTest.java index c324f4013..9a36ec7e8 100644 --- a/src/test/java/com/gg/server/data/store/ItemUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/store/ItemUnitTest.java @@ -1,6 +1,6 @@ -package com.gg.server.data.store; +package gg.pingpong.api.data.store; -import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static gg.pingpong.api.utils.ReflectionUtilsForUnitTest.*; import static org.assertj.core.api.Assertions.*; import org.junit.jupiter.api.DisplayName; @@ -9,7 +9,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.data.store.Item; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/controller/AnnouncementControllerTest.java similarity index 83% rename from src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/controller/AnnouncementControllerTest.java index f1162b682..36637e01b 100644 --- a/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/controller/AnnouncementControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.announcement.controller; +package gg.pingpong.api.user.announcement.controller; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -15,14 +15,14 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.data.manage.Announcement; -import com.gg.server.data.user.User; -import com.gg.server.domain.announcement.data.AnnouncementRepository; -import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.data.manage.Announcement; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.manage.AnnouncementRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.exception.announcement.AnnounceNotFoundException; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/controller/AnnouncementControllerUnitTest.java similarity index 75% rename from src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/controller/AnnouncementControllerUnitTest.java index 6555ff225..346450601 100644 --- a/src/test/java/com/gg/server/domain/announcement/controller/AnnouncementControllerUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/controller/AnnouncementControllerUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.announcement.controller; +package gg.pingpong.api.user.announcement.controller; import static org.assertj.core.api.Assertions.*; import static org.mockito.BDDMockito.*; @@ -11,10 +11,11 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.domain.announcement.dto.AnnouncementDto; -import com.gg.server.domain.announcement.dto.AnnouncementResponseDto; -import com.gg.server.domain.announcement.service.AnnouncementService; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.user.manage.controller.AnnouncementController; +import gg.pingpong.api.user.manage.controller.response.AnnouncementResponseDto; +import gg.pingpong.api.user.manage.dto.AnnouncementDto; +import gg.pingpong.api.user.manage.service.AnnouncementService; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/domain/announcement/service/AnnouncementServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/service/AnnouncementServiceUnitTest.java similarity index 86% rename from src/test/java/com/gg/server/domain/announcement/service/AnnouncementServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/service/AnnouncementServiceUnitTest.java index 2378ead57..311158454 100644 --- a/src/test/java/com/gg/server/domain/announcement/service/AnnouncementServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/service/AnnouncementServiceUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.announcement.service; +package gg.pingpong.api.user.announcement.service; import static org.assertj.core.api.Assertions.*; import static org.mockito.BDDMockito.*; @@ -14,10 +14,11 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.data.manage.Announcement; -import com.gg.server.domain.announcement.data.AnnouncementRepository; -import com.gg.server.domain.announcement.exception.AnnounceNotFoundException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.user.manage.service.AnnouncementService; +import gg.pingpong.data.manage.Announcement; +import gg.pingpong.repo.manage.AnnouncementRepository; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.announcement.AnnounceNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/domain/coin/service/CoinHistoryServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/coin/service/CoinHistoryServiceTest.java similarity index 90% rename from src/test/java/com/gg/server/domain/coin/service/CoinHistoryServiceTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/coin/service/CoinHistoryServiceTest.java index 6db5702dc..75e03958a 100644 --- a/src/test/java/com/gg/server/domain/coin/service/CoinHistoryServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/coin/service/CoinHistoryServiceTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.coin.service; +package gg.pingpong.api.user.coin.service; import static org.assertj.core.api.Assertions.*; @@ -10,16 +10,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.manage.CoinPolicy; -import com.gg.server.data.store.CoinHistory; -import com.gg.server.data.user.User; -import com.gg.server.domain.coin.data.CoinHistoryRepository; -import com.gg.server.domain.coin.data.CoinPolicyRepository; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; - +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.store.service.CoinHistoryService; +import gg.pingpong.data.store.CoinHistory; +import gg.pingpong.data.store.CoinPolicy; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.store.CoinHistoryRepository; +import gg.pingpong.repo.store.CoinPolicyRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @IntegrationTest diff --git a/src/test/java/com/gg/server/domain/coin/service/UserCoinChangeServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/coin/service/UserCoinChangeServiceTest.java similarity index 81% rename from src/test/java/com/gg/server/domain/coin/service/UserCoinChangeServiceTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/coin/service/UserCoinChangeServiceTest.java index 0c663e37e..bd4e8def1 100644 --- a/src/test/java/com/gg/server/domain/coin/service/UserCoinChangeServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/coin/service/UserCoinChangeServiceTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.coin.service; +package gg.pingpong.api.user.coin.service; import static org.assertj.core.api.Assertions.*; @@ -10,24 +10,25 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.manage.CoinPolicy; -import com.gg.server.data.store.Item; -import com.gg.server.data.store.type.ItemType; -import com.gg.server.data.user.User; -import com.gg.server.domain.coin.data.CoinHistoryRepository; -import com.gg.server.domain.coin.data.CoinPolicyRepository; -import com.gg.server.domain.coin.dto.UserGameCoinResultDto; -import com.gg.server.domain.coin.exception.CoinHistoryNotFoundException; -import com.gg.server.domain.coin.exception.CoinPolicyNotFoundException; -import com.gg.server.domain.item.data.ItemRepository; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; - +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.store.dto.UserGameCoinResultDto; +import gg.pingpong.api.user.store.service.CoinHistoryService; +import gg.pingpong.api.user.store.service.UserCoinChangeService; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.store.CoinPolicy; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.store.type.ItemType; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.store.CoinHistoryRepository; +import gg.pingpong.repo.store.CoinPolicyRepository; +import gg.pingpong.repo.store.ItemRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.exception.coin.CoinHistoryNotFoundException; +import gg.pingpong.utils.exception.coin.CoinPolicyNotFoundException; import lombok.RequiredArgsConstructor; @IntegrationTest @@ -81,9 +82,9 @@ void addAttendanceCoin() { assertThat(beforeCoin + coinIncrement).isEqualTo(user.getGgCoin()); assertThat(coinPolicyRepository.findTopByOrderByCreatedAtDesc() - .orElseThrow(() -> new CoinPolicyNotFoundException()).getAttendance()).isEqualTo(coinIncrement); + .orElseThrow(CoinPolicyNotFoundException::new).getAttendance()).isEqualTo(coinIncrement); System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); + .orElseThrow(CoinHistoryNotFoundException::new).getHistory()); try { coinIncrement = userCoinChangeService.addAttendanceCoin(user); @@ -140,11 +141,11 @@ void giftItemCoin() { assertThat(beforeCoin).isEqualTo(user.getGgCoin() + item.getPrice()); System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory() + .orElseThrow(CoinHistoryNotFoundException::new).getHistory() + coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getAmount()); + .orElseThrow(CoinHistoryNotFoundException::new).getAmount()); System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); + .orElseThrow(CoinHistoryNotFoundException::new).getHistory()); try { userCoinChangeService.giftItemCoin(item, item.getPrice(), user, user); @@ -193,10 +194,10 @@ void addRankWinGameService() { assertThat(user.getGgCoin()).isEqualTo(userGameCoinResultDto.getAfterCoin()); assertThat(coinPolicyRepository.findTopByOrderByCreatedAtDesc() - .orElseThrow(() -> new CoinPolicyNotFoundException()).getRankWin()) + .orElseThrow(CoinPolicyNotFoundException::new).getRankWin()) .isEqualTo(userGameCoinResultDto.getCoinIncrement()); System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); + .orElseThrow(CoinHistoryNotFoundException::new).getHistory()); } @Test @@ -219,9 +220,9 @@ void addRankLoseGameService() { assertThat(user.getGgCoin()).isEqualTo(userGameCoinResultDto.getAfterCoin()); assertThat(coinPolicyRepository.findTopByOrderByCreatedAtDesc() - .orElseThrow(() -> new CoinPolicyNotFoundException()).getRankLose()) + .orElseThrow(CoinPolicyNotFoundException::new).getRankLose()) .isEqualTo(userGameCoinResultDto.getCoinIncrement()); System.out.println(coinHistoryRepository.findFirstByOrderByIdDesc() - .orElseThrow(() -> new CoinHistoryNotFoundException()).getHistory()); + .orElseThrow(CoinHistoryNotFoundException::new).getHistory()); } } diff --git a/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/controller/FeedbackControllerTest.java similarity index 83% rename from src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/controller/FeedbackControllerTest.java index 262a2f062..d744a12c6 100644 --- a/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/controller/FeedbackControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.feedback.controller; +package gg.pingpong.api.user.feedback.controller; import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; @@ -14,14 +14,14 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.data.manage.Feedback; -import com.gg.server.data.manage.type.FeedbackType; -import com.gg.server.domain.feedback.data.FeedbackRepository; -import com.gg.server.domain.feedback.dto.FeedbackRequestDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.manage.controller.request.FeedbackRequestDto; +import gg.pingpong.data.manage.Feedback; +import gg.pingpong.data.manage.type.FeedbackType; +import gg.pingpong.repo.manage.FeedbackRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/controller/FeedbackControllerUnitTest.java similarity index 70% rename from src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/controller/FeedbackControllerUnitTest.java index 863297d42..f3a24fb80 100644 --- a/src/test/java/com/gg/server/domain/feedback/controller/FeedbackControllerUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/controller/FeedbackControllerUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.feedback.controller; +package gg.pingpong.api.user.feedback.controller; import static org.mockito.Mockito.*; @@ -10,10 +10,11 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.domain.feedback.dto.FeedbackRequestDto; -import com.gg.server.domain.feedback.service.FeedbackService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.user.manage.controller.FeedbackController; +import gg.pingpong.api.user.manage.controller.request.FeedbackRequestDto; +import gg.pingpong.api.user.manage.service.FeedbackService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/domain/feedback/service/FeedbackServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/service/FeedbackServiceUnitTest.java similarity index 77% rename from src/test/java/com/gg/server/domain/feedback/service/FeedbackServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/service/FeedbackServiceUnitTest.java index b33fc7489..7e23b8c13 100644 --- a/src/test/java/com/gg/server/domain/feedback/service/FeedbackServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/service/FeedbackServiceUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.feedback.service; +package gg.pingpong.api.user.feedback.service; import static org.mockito.BDDMockito.*; @@ -13,13 +13,14 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.data.manage.Feedback; -import com.gg.server.data.user.User; -import com.gg.server.domain.feedback.data.FeedbackRepository; -import com.gg.server.domain.feedback.dto.FeedbackRequestDto; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.user.manage.controller.request.FeedbackRequestDto; +import gg.pingpong.api.user.manage.service.FeedbackService; +import gg.pingpong.data.manage.Feedback; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.manage.FeedbackRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/domain/game/GameControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/GameControllerTest.java similarity index 93% rename from src/test/java/com/gg/server/domain/game/GameControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/GameControllerTest.java index 072814db9..44d117837 100644 --- a/src/test/java/com/gg/server/domain/game/GameControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/GameControllerTest.java @@ -1,6 +1,6 @@ -package com.gg.server.domain.game; +package gg.pingpong.api.user.game; -import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -24,44 +24,43 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.PChange; -import com.gg.server.data.game.Rank; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Team; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.game.Tier; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.GameListResDto; -import com.gg.server.domain.game.dto.GameTeamInfo; -import com.gg.server.domain.game.dto.request.RankResultReqDto; -import com.gg.server.domain.game.dto.request.TournamentResultReqDto; -import com.gg.server.domain.game.service.GameFindService; -import com.gg.server.domain.game.service.GameService; -import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RankRedisService; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.game.controller.request.RankResultReqDto; +import gg.pingpong.api.user.game.controller.request.TournamentResultReqDto; +import gg.pingpong.api.user.game.controller.response.GameListResDto; +import gg.pingpong.api.user.game.dto.GameTeamInfo; +import gg.pingpong.api.user.game.service.GameFindService; +import gg.pingpong.api.user.game.service.GameService; +import gg.pingpong.api.user.rank.redis.RankRedisService; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.PChange; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.rank.Rank; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.game.PChangeRepository; +import gg.pingpong.repo.game.TeamRepository; +import gg.pingpong.repo.game.TeamUserRepository; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.TierRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.season.SeasonRepository; +import gg.pingpong.repo.tournarment.TournamentRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @IntegrationTest @@ -124,10 +123,12 @@ void init() { Tier tier = tiers.get(0); rankRepository.save(Rank.from(user1, season, season.getStartPpp(), tier)); rankRepository.save(Rank.from(user2, season, season.getStartPpp(), tier)); - RankRedis userRank = RankRedis.from(UserDto.from(user1), season.getStartPpp(), tier.getImageUri()); + RankRedis userRank = RankRedis.from(user1.getId(), user1.getIntraId(), user1.getTextColor(), + season.getStartPpp(), tier.getImageUri()); String redisHashKey = RedisKeyManager.getHashKey(season.getId()); rankRedisRepository.addRankData(redisHashKey, user1.getId(), userRank); - userRank = RankRedis.from(UserDto.from(user2), season.getStartPpp(), tier.getImageUri()); + userRank = RankRedis.from(user2.getId(), user2.getIntraId(), user2.getTextColor(), season.getStartPpp(), + tier.getImageUri()); rankRedisRepository.addRankData(redisHashKey, user2.getId(), userRank); game1 = gameRepository.save( diff --git a/src/test/java/com/gg/server/domain/game/service/GameDBTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameDBTest.java similarity index 78% rename from src/test/java/com/gg/server/domain/game/service/GameDBTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameDBTest.java index 8c6af0ff8..a3b1b6f88 100644 --- a/src/test/java/com/gg/server/domain/game/service/GameDBTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameDBTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game.service; +package gg.pingpong.api.user.game.service; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -17,22 +17,21 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.game.service.GameAdminService; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Team; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; - +import gg.pingpong.api.admin.game.service.GameAdminService; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.game.PChangeRepository; +import gg.pingpong.repo.game.TeamRepository; +import gg.pingpong.repo.game.TeamUserRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/test/java/com/gg/server/domain/game/service/GameFindServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameFindServiceTest.java similarity index 71% rename from src/test/java/com/gg/server/domain/game/service/GameFindServiceTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameFindServiceTest.java index 0daa11303..bdb9adc7d 100644 --- a/src/test/java/com/gg/server/domain/game/service/GameFindServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameFindServiceTest.java @@ -1,6 +1,6 @@ -package com.gg.server.domain.game.service; +package gg.pingpong.api.user.game.service; -import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.assertj.core.api.Assertions.*; import java.time.LocalDateTime; import java.util.List; @@ -16,26 +16,24 @@ import org.springframework.data.domain.Sort; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Tier; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.GameListResDto; -import com.gg.server.domain.game.dto.GameResultResDto; -import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; - +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.game.controller.response.GameListResDto; +import gg.pingpong.api.user.game.controller.response.GameResultResDto; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.game.out.GameTeamUser; +import gg.pingpong.repo.rank.TierRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.exception.tier.TierNotFoundException; import lombok.RequiredArgsConstructor; @IntegrationTest @@ -80,7 +78,8 @@ void init() { testDataUtils.createMockMatch(newUser, season, startTime2, endTime2); testDataUtils.createUserRank(newUser, statusMsg, season); - RankRedis userRank = RankRedis.from(UserDto.from(newUser), season.getStartPpp(), tier.getImageUri()); + RankRedis userRank = RankRedis.from(newUser.getId(), newUser.getIntraId(), newUser.getTextColor(), + season.getStartPpp(), tier.getImageUri()); String redisHashKey = RedisKeyManager.getHashKey(season.getId()); rankRedisRepository.addRankData(redisHashKey, newUser.getId(), userRank); } diff --git a/src/test/java/com/gg/server/domain/game/service/GameServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameServiceTest.java similarity index 67% rename from src/test/java/com/gg/server/domain/game/service/GameServiceTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameServiceTest.java index a61fcf1b3..16bcbb9c0 100644 --- a/src/test/java/com/gg/server/domain/game/service/GameServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameServiceTest.java @@ -1,6 +1,6 @@ -package com.gg.server.domain.game.service; +package gg.pingpong.api.user.game.service; -import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.assertj.core.api.Assertions.*; import java.time.LocalDateTime; @@ -10,31 +10,29 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Rank; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Team; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.game.Tier; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.request.RankResultReqDto; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.exception.RankNotFoundException; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tier.exception.TierNotFoundException; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; - +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.game.controller.request.RankResultReqDto; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.rank.Rank; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.game.TeamRepository; +import gg.pingpong.repo.game.TeamUserRepository; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.TierRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.exception.rank.RankNotFoundException; +import gg.pingpong.utils.exception.tier.TierNotFoundException; import lombok.RequiredArgsConstructor; @IntegrationTest @@ -90,12 +88,14 @@ void init() { String statusMsg = "status message test1"; testDataUtils.createUserRank(user1, statusMsg, season); - RankRedis userRank = RankRedis.from(UserDto.from(user1), season.getStartPpp(), tier.getImageUri()); + RankRedis userRank = RankRedis.from(user1.getId(), user1.getIntraId(), user1.getTextColor(), + season.getStartPpp(), tier.getImageUri()); String redisHashKey = RedisKeyManager.getHashKey(season.getId()); rankRedisRepository.addRankData(redisHashKey, user1.getId(), userRank); statusMsg = "status message test2"; testDataUtils.createUserRank(user2, statusMsg, season); - RankRedis userRank2 = RankRedis.from(UserDto.from(user2), season.getStartPpp(), tier.getImageUri()); + RankRedis userRank2 = RankRedis.from(user2.getId(), user2.getIntraId(), user2.getTextColor(), + season.getStartPpp(), tier.getImageUri()); rankRedisRepository.addRankData(redisHashKey, user2.getId(), userRank2); } diff --git a/src/test/java/com/gg/server/domain/game/service/GameStatusServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameStatusServiceTest.java similarity index 73% rename from src/test/java/com/gg/server/domain/game/service/GameStatusServiceTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameStatusServiceTest.java index cd33bc9f1..89f47bb5d 100644 --- a/src/test/java/com/gg/server/domain/game/service/GameStatusServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameStatusServiceTest.java @@ -1,6 +1,6 @@ -package com.gg.server.domain.game.service; +package gg.pingpong.api.user.game.service; -import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.assertj.core.api.Assertions.*; import java.time.LocalDateTime; @@ -10,26 +10,25 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Team; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; - +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.game.TeamRepository; +import gg.pingpong.repo.game.TeamUserRepository; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.season.SeasonRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @IntegrationTest diff --git a/src/test/java/com/gg/server/domain/item/controller/ItemGiftControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemGiftControllerTest.java similarity index 83% rename from src/test/java/com/gg/server/domain/item/controller/ItemGiftControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemGiftControllerTest.java index 99a507d8d..40c529f97 100644 --- a/src/test/java/com/gg/server/domain/item/controller/ItemGiftControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemGiftControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.item.controller; +package gg.pingpong.api.user.item.controller; import static org.mockito.Mockito.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; @@ -16,13 +16,13 @@ import org.springframework.test.web.servlet.MockMvc; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.item.dto.ItemGiftRequestDto; -import com.gg.server.domain.item.service.ItemService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.store.controller.request.ItemGiftRequestDto; +import gg.pingpong.api.user.store.service.ItemService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/domain/item/controller/ItemPurchaseControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemPurchaseControllerTest.java similarity index 84% rename from src/test/java/com/gg/server/domain/item/controller/ItemPurchaseControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemPurchaseControllerTest.java index b666079bb..59e7f14c8 100644 --- a/src/test/java/com/gg/server/domain/item/controller/ItemPurchaseControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemPurchaseControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.item.controller; +package gg.pingpong.api.user.item.controller; import static org.mockito.Mockito.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; @@ -15,12 +15,12 @@ import org.springframework.test.web.servlet.MockMvc; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.item.service.ItemService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.store.service.ItemService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/domain/item/controller/ItemStoreListControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemStoreListControllerTest.java similarity index 87% rename from src/test/java/com/gg/server/domain/item/controller/ItemStoreListControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemStoreListControllerTest.java index 3ee0b3086..64b0a5659 100644 --- a/src/test/java/com/gg/server/domain/item/controller/ItemStoreListControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemStoreListControllerTest.java @@ -1,6 +1,6 @@ -package com.gg.server.domain.item.controller; +package gg.pingpong.api.user.item.controller; -import static com.gg.server.data.store.type.ItemType.*; +import static gg.pingpong.data.store.type.ItemType.*; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; @@ -20,14 +20,14 @@ import org.springframework.test.web.servlet.MockMvc; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.item.data.ItemRepository; -import com.gg.server.domain.item.dto.ItemStoreListResponseDto; -import com.gg.server.domain.item.dto.ItemStoreResponseDto; -import com.gg.server.domain.item.service.ItemService; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.store.controller.response.ItemStoreListResponseDto; +import gg.pingpong.api.user.store.controller.response.ItemStoreResponseDto; +import gg.pingpong.api.user.store.service.ItemService; +import gg.pingpong.repo.store.ItemRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/domain/item/controller/UserItemResponseControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/UserItemResponseControllerTest.java similarity index 87% rename from src/test/java/com/gg/server/domain/item/controller/UserItemResponseControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/UserItemResponseControllerTest.java index 711d02608..f367714c6 100644 --- a/src/test/java/com/gg/server/domain/item/controller/UserItemResponseControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/UserItemResponseControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.item.controller; +package gg.pingpong.api.user.item.controller; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -12,9 +12,10 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.domain.item.service.ItemService; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; + +import gg.pingpong.api.user.store.service.ItemService; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; @IntegrationTest @AutoConfigureMockMvc diff --git a/src/test/java/com/gg/server/domain/item/service/ItemServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/service/ItemServiceUnitTest.java similarity index 91% rename from src/test/java/com/gg/server/domain/item/service/ItemServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/service/ItemServiceUnitTest.java index 16b0a8877..9f88322e2 100644 --- a/src/test/java/com/gg/server/domain/item/service/ItemServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/service/ItemServiceUnitTest.java @@ -1,6 +1,6 @@ -package com.gg.server.domain.item.service; +package gg.pingpong.api.user.item.service; -import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static gg.pingpong.api.utils.ReflectionUtilsForUnitTest.*; import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; @@ -20,30 +20,31 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import com.gg.server.data.store.Item; -import com.gg.server.data.store.Receipt; -import com.gg.server.data.store.type.ItemStatus; -import com.gg.server.data.store.type.ItemType; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.coin.service.UserCoinChangeService; -import com.gg.server.domain.item.data.ItemRepository; -import com.gg.server.domain.item.data.UserItemRepository; -import com.gg.server.domain.item.exception.ItemNotFoundException; -import com.gg.server.domain.item.exception.ItemNotPurchasableException; -import com.gg.server.domain.item.exception.ItemTypeException; -import com.gg.server.domain.item.exception.KakaoGiftException; -import com.gg.server.domain.item.exception.KakaoPurchaseException; -import com.gg.server.domain.noti.service.NotiService; -import com.gg.server.domain.receipt.data.ReceiptRepository; -import com.gg.server.domain.receipt.exception.ItemStatusException; -import com.gg.server.domain.receipt.exception.ReceiptNotOwnerException; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.user.noti.service.NotiService; +import gg.pingpong.api.user.store.service.ItemService; +import gg.pingpong.api.user.store.service.UserCoinChangeService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.store.Receipt; +import gg.pingpong.data.store.type.ItemStatus; +import gg.pingpong.data.store.type.ItemType; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.store.ItemRepository; +import gg.pingpong.repo.store.ReceiptRepository; +import gg.pingpong.repo.store.UserItemRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.item.ItemNotFoundException; +import gg.pingpong.utils.exception.item.ItemNotPurchasableException; +import gg.pingpong.utils.exception.item.ItemTypeException; +import gg.pingpong.utils.exception.item.KakaoGiftException; +import gg.pingpong.utils.exception.item.KakaoPurchaseException; +import gg.pingpong.utils.exception.receipt.ItemStatusException; +import gg.pingpong.utils.exception.receipt.ReceiptNotOwnerException; +import gg.pingpong.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/domain/match/dto/MatchStatusDtoUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/dto/MatchStatusDtoUnitTest.java similarity index 93% rename from src/test/java/com/gg/server/domain/match/dto/MatchStatusDtoUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/dto/MatchStatusDtoUnitTest.java index a5218f933..888a63427 100644 --- a/src/test/java/com/gg/server/domain/match/dto/MatchStatusDtoUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/dto/MatchStatusDtoUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.dto; +package gg.pingpong.api.user.match.dto; import static org.mockito.Mockito.*; @@ -11,10 +11,10 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.type.Mode; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest class MatchStatusDtoUnitTest { diff --git a/src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchBothServiceTest.java similarity index 82% rename from src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchBothServiceTest.java index 47cf93aa9..c7bdc2d43 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchBothServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchBothServiceTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.service; +package gg.pingpong.api.user.match.service; import java.time.LocalDateTime; import java.util.ArrayList; @@ -18,26 +18,25 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.penalty.data.PenaltyAdminRepository; -import com.gg.server.admin.penalty.type.PenaltyKey; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.match.type.Option; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.match.data.RedisMatchTimeRepository; -import com.gg.server.domain.match.data.RedisMatchUserRepository; -import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.match.utils.MatchIntegrationTestUtils; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.penalty.redis.PenaltyUserRedisRepository; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; - +import gg.pingpong.admin.repo.manage.PenaltyAdminRepository; +import gg.pingpong.api.user.manage.redis.PenaltyUserRedisRepository; +import gg.pingpong.api.user.match.utils.MatchIntegrationTestUtils; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.manage.type.PenaltyKey; +import gg.pingpong.data.match.type.Option; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.repo.match.RedisMatchTimeRepository; +import gg.pingpong.repo.match.RedisMatchUserRepository; +import gg.pingpong.repo.noti.NotiRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.exception.match.SlotNotFoundException; import lombok.RequiredArgsConstructor; @IntegrationTest diff --git a/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchFindServiceUnitTest.java similarity index 84% rename from src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchFindServiceUnitTest.java index fbcfc03e1..cb43eb5ef 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchFindServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchFindServiceUnitTest.java @@ -1,8 +1,8 @@ -package com.gg.server.domain.match.service; +package gg.pingpong.api.user.match.service; -import static com.gg.server.domain.match.utils.GameTestUtils.*; -import static com.gg.server.domain.match.utils.UserTestUtils.*; -import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static gg.pingpong.api.user.match.utils.GameTestUtils.*; +import static gg.pingpong.api.user.match.utils.UserTestUtils.*; +import static gg.pingpong.api.utils.ReflectionUtilsForUnitTest.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; @@ -21,27 +21,27 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Tier; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.match.RedisMatchTime; -import com.gg.server.data.match.type.Option; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.match.data.RedisMatchTimeRepository; -import com.gg.server.domain.match.data.RedisMatchUserRepository; -import com.gg.server.domain.match.utils.SlotGenerator; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.user.match.utils.SlotGenerator; +import gg.pingpong.api.user.season.service.SeasonFindService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.match.RedisMatchTime; +import gg.pingpong.data.match.type.Option; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.repo.match.RedisMatchTimeRepository; +import gg.pingpong.repo.match.RedisMatchUserRepository; +import gg.pingpong.repo.rank.TierRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) @@ -170,7 +170,8 @@ void verifyEach() { void success() { // given UserDto userDto = UserDto.from(user); - RankRedis redisUser = RankRedis.from(userDto, season.getStartPpp(), tier.getImageUri()); + RankRedis redisUser = RankRedis.from(userDto.getId(), userDto.getIntraId(), userDto.getTextColor(), + season.getStartPpp(), tier.getImageUri()); String hashKey = RedisKeyManager.getHashKey(season.getId()); slotGenerator = new SlotGenerator(redisUser, slotManagement, season, Option.BOTH); given(rankRedisRepository.findRankByUserId(hashKey, user.getId())).willReturn( @@ -201,7 +202,8 @@ void success() { void successGuest() { // given User guest = createGuestUser(); - RankRedis redisUser = RankRedis.from(UserDto.from(guest), season.getStartPpp(), tier.getImageUri()); + RankRedis redisUser = RankRedis.from(guest.getId(), guest.getIntraId(), guest.getTextColor(), + season.getStartPpp(), tier.getImageUri()); slotGenerator = new SlotGenerator(redisUser, slotManagement, season, Option.BOTH); given(gameRepository.findByStatusTypeAndUserId(StatusType.BEFORE, UserDto.from(guest).getId())).willReturn( Optional.empty()); @@ -226,7 +228,8 @@ void successGuest() { void successWithMySlot() { // given UserDto userDto = UserDto.from(user); - RankRedis redisUser = RankRedis.from(userDto, season.getStartPpp(), tier.getImageUri()); + RankRedis redisUser = RankRedis.from(userDto.getId(), userDto.getIntraId(), userDto.getTextColor(), + season.getStartPpp(), tier.getImageUri()); String hashKey = RedisKeyManager.getHashKey(season.getId()); User enemy = createUser(); Game game = createNormalGame(user, enemy, season); diff --git a/src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchServiceTest.java similarity index 90% rename from src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchServiceTest.java index 2de6c6779..a45e3c785 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchServiceTest.java @@ -1,4 +1,7 @@ -package com.gg.server.domain.match.service; +package gg.pingpong.api.user.match.service; + +import static org.assertj.core.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; import java.time.LocalDateTime; import java.util.ArrayList; @@ -19,48 +22,47 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.penalty.data.PenaltyAdminRepository; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Tier; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; -import com.gg.server.data.manage.redis.RedisPenaltyUser; -import com.gg.server.data.match.RedisMatchUser; -import com.gg.server.data.match.type.MatchKey; -import com.gg.server.data.match.type.Option; -import com.gg.server.data.match.type.SlotStatus; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.noti.type.NotiType; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.match.data.RedisMatchTimeRepository; -import com.gg.server.domain.match.data.RedisMatchUserRepository; -import com.gg.server.domain.match.dto.MatchStatusDto; -import com.gg.server.domain.match.dto.MatchStatusResponseListDto; -import com.gg.server.domain.match.dto.SlotStatusDto; -import com.gg.server.domain.match.dto.SlotStatusResponseListDto; -import com.gg.server.domain.match.exception.EnrolledSlotException; -import com.gg.server.domain.match.exception.PenaltyUserSlotException; -import com.gg.server.domain.match.utils.MatchIntegrationTestUtils; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.penalty.redis.PenaltyUserRedisRepository; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.rank.service.RedisUploadService; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.exception.TournamentConflictException; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.exception.custom.BusinessException; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; - +import gg.pingpong.admin.repo.manage.PenaltyAdminRepository; +import gg.pingpong.api.user.manage.redis.PenaltyUserRedisRepository; +import gg.pingpong.api.user.match.controller.response.MatchStatusResponseListDto; +import gg.pingpong.api.user.match.controller.response.SlotStatusResponseListDto; +import gg.pingpong.api.user.match.dto.MatchStatusDto; +import gg.pingpong.api.user.match.dto.SlotStatusDto; +import gg.pingpong.api.user.match.utils.MatchIntegrationTestUtils; +import gg.pingpong.api.user.rank.redis.RedisUploadService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.manage.redis.RedisPenaltyUser; +import gg.pingpong.data.match.RedisMatchUser; +import gg.pingpong.data.match.type.MatchKey; +import gg.pingpong.data.match.type.Option; +import gg.pingpong.data.match.type.SlotStatus; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.noti.type.NotiType; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.repo.match.RedisMatchTimeRepository; +import gg.pingpong.repo.match.RedisMatchUserRepository; +import gg.pingpong.repo.noti.NotiRepository; +import gg.pingpong.repo.rank.TierRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.tournarment.TournamentRepository; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.exception.custom.BusinessException; +import gg.pingpong.utils.exception.match.EnrolledSlotException; +import gg.pingpong.utils.exception.match.PenaltyUserSlotException; +import gg.pingpong.utils.exception.tournament.TournamentConflictException; import lombok.RequiredArgsConstructor; @IntegrationTest @@ -295,7 +297,7 @@ void cancelMatchAfterMakingGameEntity() { matchService.makeMatch(UserDto.from(users.get(1)), Option.NORMAL, slotTimes.get(3)); //user2 다른 슬롯 등록 //첫번째 유저 경기 취소 - org.junit.jupiter.api.Assertions.assertThrows( + assertThrows( EnrolledSlotException.class, () -> matchService.makeMatch(UserDto.from(users.get(0)), Option.NORMAL, slotTimes.get(0)) ); @@ -322,8 +324,8 @@ void cancelMatchAfterMakingGameEntity() { users.get(0).getIntraId()); Assertions.assertThat(penaltyUser).isPresent(); // 패널티 시간은 하드 코딩 시 관리가 어려우니 Static이나 enum으로 관리하는게 좋을 듯 하다. - Assertions.assertThat(penaltyUser.get().getPenaltyTime()).isEqualTo(30); - org.junit.jupiter.api.Assertions.assertThrows(PenaltyUserSlotException.class, () -> { + assertThat(penaltyUser.get().getPenaltyTime()).isEqualTo(30); + assertThrows(PenaltyUserSlotException.class, () -> { matchService.makeMatch(UserDto.from(users.get(0)), Option.BOTH, slotTimes.get(10)); }); } diff --git a/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchTournamentServiceTest.java similarity index 91% rename from src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchTournamentServiceTest.java index f63218097..f282d681f 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchTournamentServiceTest.java @@ -1,6 +1,6 @@ -package com.gg.server.domain.match.service; +package gg.pingpong.api.user.match.service; -import static com.gg.server.data.game.type.RoundNumber.*; +import static gg.pingpong.data.tournament.type.RoundNumber.*; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; @@ -19,27 +19,27 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; -import com.gg.server.admin.noti.service.NotiAdminService; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Team; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.type.RoundNumber; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.match.type.TournamentMatchStatus; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.match.exception.EnrolledSlotException; -import com.gg.server.domain.match.exception.SlotNotFoundException; -import com.gg.server.domain.match.exception.WinningTeamNotFoundException; -import com.gg.server.domain.match.utils.MatchIntegrationTestUtils; -import com.gg.server.domain.match.utils.TournamentGameTestUtils; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; +import gg.pingpong.api.admin.noti.service.NotiAdminService; +import gg.pingpong.api.user.match.utils.MatchIntegrationTestUtils; +import gg.pingpong.api.user.match.utils.TournamentGameTestUtils; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.match.type.TournamentMatchStatus; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.type.RoundNumber; +import gg.pingpong.data.tournament.type.TournamentRound; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.exception.match.EnrolledSlotException; +import gg.pingpong.utils.exception.match.SlotNotFoundException; +import gg.pingpong.utils.exception.match.WinningTeamNotFoundException; @IntegrationTest @Transactional diff --git a/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchTournamentServiceUnitTest.java similarity index 88% rename from src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchTournamentServiceUnitTest.java index a82c84207..2f2985506 100644 --- a/src/test/java/com/gg/server/domain/match/service/MatchTournamentServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchTournamentServiceUnitTest.java @@ -1,8 +1,8 @@ -package com.gg.server.domain.match.service; +package gg.pingpong.api.user.match.service; -import static com.gg.server.data.game.type.RoundNumber.*; -import static com.gg.server.domain.match.utils.TournamentGameTestUtils.*; -import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static gg.pingpong.api.user.match.utils.TournamentGameTestUtils.*; +import static gg.pingpong.api.utils.ReflectionUtilsForUnitTest.*; +import static gg.pingpong.data.tournament.type.RoundNumber.*; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; import static org.mockito.BDDMockito.*; @@ -23,31 +23,31 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; -import com.gg.server.admin.noti.service.NotiAdminService; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Team; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.RoundNumber; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.match.type.TournamentMatchStatus; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.match.exception.EnrolledSlotException; -import com.gg.server.domain.match.exception.WinningTeamNotFoundException; -import com.gg.server.domain.match.utils.GameTestUtils; -import com.gg.server.domain.match.utils.TournamentTestUtils; -import com.gg.server.domain.match.utils.UserTestUtils; -import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tournament.data.TournamentGameRepository; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; +import gg.pingpong.api.admin.noti.service.NotiAdminService; +import gg.pingpong.api.user.match.utils.GameTestUtils; +import gg.pingpong.api.user.match.utils.TournamentTestUtils; +import gg.pingpong.api.user.match.utils.UserTestUtils; +import gg.pingpong.api.user.season.service.SeasonFindService; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.match.type.TournamentMatchStatus; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.type.RoundNumber; +import gg.pingpong.data.tournament.type.TournamentRound; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.repo.tournarment.TournamentGameRepository; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.match.EnrolledSlotException; +import gg.pingpong.utils.exception.match.WinningTeamNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/domain/match/utils/GameTestUtils.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/GameTestUtils.java similarity index 65% rename from src/test/java/com/gg/server/domain/match/utils/GameTestUtils.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/GameTestUtils.java index 6dd369a0b..d1530c93b 100644 --- a/src/test/java/com/gg/server/domain/match/utils/GameTestUtils.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/GameTestUtils.java @@ -1,14 +1,14 @@ -package com.gg.server.domain.match.utils; +package gg.pingpong.api.user.match.utils; import java.time.LocalDateTime; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Team; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.user.User; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; public class GameTestUtils { public static Game createGame(User user, User enemy, Season season, Mode mode) { diff --git a/src/test/java/com/gg/server/domain/match/utils/MatchIntegrationTestUtils.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/MatchIntegrationTestUtils.java similarity index 85% rename from src/test/java/com/gg/server/domain/match/utils/MatchIntegrationTestUtils.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/MatchIntegrationTestUtils.java index 33fd7dcfc..ee7cb3f7a 100644 --- a/src/test/java/com/gg/server/domain/match/utils/MatchIntegrationTestUtils.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/MatchIntegrationTestUtils.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.utils; +package gg.pingpong.api.user.match.utils; import java.time.LocalDateTime; import java.util.ArrayList; @@ -9,22 +9,21 @@ import org.springframework.stereotype.Component; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Team; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.data.user.User; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.user.data.UserRepository; - +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.type.TournamentRound; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.season.SeasonRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.RedisKeyManager; import lombok.RequiredArgsConstructor; @Component diff --git a/src/test/java/com/gg/server/domain/match/utils/TournamentGameTestUtils.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/TournamentGameTestUtils.java similarity index 86% rename from src/test/java/com/gg/server/domain/match/utils/TournamentGameTestUtils.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/TournamentGameTestUtils.java index df709fde3..c3cfa7337 100644 --- a/src/test/java/com/gg/server/domain/match/utils/TournamentGameTestUtils.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/TournamentGameTestUtils.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.utils; +package gg.pingpong.api.user.match.utils; import java.time.LocalDateTime; import java.util.ArrayList; @@ -7,18 +7,18 @@ import java.util.Optional; import java.util.stream.Collectors; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Team; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.RoundNumber; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.data.user.User; -import com.gg.server.domain.match.exception.WinningTeamNotFoundException; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.type.RoundNumber; +import gg.pingpong.data.tournament.type.TournamentRound; +import gg.pingpong.data.user.User; +import gg.pingpong.utils.exception.match.WinningTeamNotFoundException; public class TournamentGameTestUtils { diff --git a/src/test/java/com/gg/server/domain/match/utils/TournamentTestUtils.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/TournamentTestUtils.java similarity index 77% rename from src/test/java/com/gg/server/domain/match/utils/TournamentTestUtils.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/TournamentTestUtils.java index 6a480ea1f..01e003448 100644 --- a/src/test/java/com/gg/server/domain/match/utils/TournamentTestUtils.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/TournamentTestUtils.java @@ -1,13 +1,13 @@ -package com.gg.server.domain.match.utils; +package gg.pingpong.api.user.match.utils; import java.time.LocalDateTime; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.TournamentUser; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.TournamentUser; +import gg.pingpong.data.tournament.type.TournamentRound; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; public class TournamentTestUtils { /** diff --git a/src/test/java/com/gg/server/domain/match/utils/UserTestUtils.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/UserTestUtils.java similarity index 75% rename from src/test/java/com/gg/server/domain/match/utils/UserTestUtils.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/UserTestUtils.java index 4374e87f7..6863a6c9c 100644 --- a/src/test/java/com/gg/server/domain/match/utils/UserTestUtils.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/UserTestUtils.java @@ -1,11 +1,11 @@ -package com.gg.server.domain.match.utils; +package gg.pingpong.api.user.match.utils; import java.util.UUID; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; public class UserTestUtils { public static User createUser() { diff --git a/src/test/java/com/gg/server/domain/megaphone/controller/MegaphoneControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/megaphone/controller/MegaphoneControllerTest.java similarity index 83% rename from src/test/java/com/gg/server/domain/megaphone/controller/MegaphoneControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/megaphone/controller/MegaphoneControllerTest.java index 8a8e5fa8e..8e2965237 100644 --- a/src/test/java/com/gg/server/domain/megaphone/controller/MegaphoneControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/megaphone/controller/MegaphoneControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.megaphone.controller; +package gg.pingpong.api.user.megaphone.controller; import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; @@ -7,7 +7,6 @@ import java.time.LocalTime; import org.apache.http.HttpHeaders; -import org.assertj.core.api.AssertionsForClassTypes; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -17,24 +16,24 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.data.store.Item; -import com.gg.server.data.store.Megaphone; -import com.gg.server.data.store.Receipt; -import com.gg.server.data.store.type.ItemStatus; -import com.gg.server.data.store.type.ItemType; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.megaphone.data.MegaphoneRepository; -import com.gg.server.domain.megaphone.dto.MegaphoneUseRequestDto; -import com.gg.server.domain.receipt.data.ReceiptRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.ItemTestUtils; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.store.controller.request.MegaphoneUseRequestDto; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.store.Megaphone; +import gg.pingpong.data.store.Receipt; +import gg.pingpong.data.store.type.ItemStatus; +import gg.pingpong.data.store.type.ItemType; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.store.MegaphoneRepository; +import gg.pingpong.repo.store.ReceiptRepository; +import gg.pingpong.utils.ItemTestUtils; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @@ -121,7 +120,7 @@ public void deleteMegaphoneTest() throws Exception { .andReturn().getResponse(); //then - AssertionsForClassTypes.assertThat(receipt2.getStatus()).isEqualTo(ItemStatus.DELETED); + assertThat(receipt2.getStatus()).isEqualTo(ItemStatus.DELETED); } @Test diff --git a/src/test/java/com/gg/server/domain/megaphone/service/MegaphoneServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/megaphone/service/MegaphoneServiceUnitTest.java similarity index 90% rename from src/test/java/com/gg/server/domain/megaphone/service/MegaphoneServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/megaphone/service/MegaphoneServiceUnitTest.java index 4cebd0543..5aae4811d 100644 --- a/src/test/java/com/gg/server/domain/megaphone/service/MegaphoneServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/megaphone/service/MegaphoneServiceUnitTest.java @@ -1,6 +1,6 @@ -package com.gg.server.domain.megaphone.service; +package gg.pingpong.api.user.megaphone.service; -import static com.gg.server.utils.ReflectionUtilsForUnitTest.*; +import static gg.pingpong.api.utils.ReflectionUtilsForUnitTest.*; import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; @@ -22,29 +22,30 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.data.store.Item; -import com.gg.server.data.store.Megaphone; -import com.gg.server.data.store.Receipt; -import com.gg.server.data.store.type.ItemStatus; -import com.gg.server.data.store.type.ItemType; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.item.service.ItemService; -import com.gg.server.domain.megaphone.data.MegaphoneRepository; -import com.gg.server.domain.megaphone.dto.MegaphoneUseRequestDto; -import com.gg.server.domain.megaphone.exception.MegaphoneContentException; -import com.gg.server.domain.megaphone.exception.MegaphoneNotFoundException; -import com.gg.server.domain.megaphone.exception.MegaphoneTimeException; -import com.gg.server.domain.megaphone.redis.MegaphoneRedisRepository; -import com.gg.server.domain.receipt.data.ReceiptRepository; -import com.gg.server.domain.receipt.exception.ItemStatusException; -import com.gg.server.domain.receipt.exception.ReceiptNotFoundException; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.user.store.controller.request.MegaphoneUseRequestDto; +import gg.pingpong.api.user.store.redis.MegaphoneRedisRepository; +import gg.pingpong.api.user.store.service.ItemService; +import gg.pingpong.api.user.store.service.MegaphoneService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.store.Megaphone; +import gg.pingpong.data.store.Receipt; +import gg.pingpong.data.store.type.ItemStatus; +import gg.pingpong.data.store.type.ItemType; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.store.MegaphoneRepository; +import gg.pingpong.repo.store.ReceiptRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.megaphone.MegaphoneContentException; +import gg.pingpong.utils.exception.megaphone.MegaphoneNotFoundException; +import gg.pingpong.utils.exception.megaphone.MegaphoneTimeException; +import gg.pingpong.utils.exception.receipt.ItemStatusException; +import gg.pingpong.utils.exception.receipt.ReceiptNotFoundException; +import gg.pingpong.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/domain/noti/controller/NotiControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/controller/NotiControllerTest.java similarity index 85% rename from src/test/java/com/gg/server/domain/noti/controller/NotiControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/controller/NotiControllerTest.java index 0784ece3f..a18a0c6e9 100644 --- a/src/test/java/com/gg/server/domain/noti/controller/NotiControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/controller/NotiControllerTest.java @@ -1,33 +1,32 @@ -package com.gg.server.domain.noti.controller; +package gg.pingpong.api.user.noti.controller; -import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; import java.util.List; -import javax.transaction.Transactional; - import org.apache.http.HttpHeaders; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.noti.type.NotiType; -import com.gg.server.data.user.User; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.noti.dto.NotiListResponseDto; -import com.gg.server.domain.noti.service.NotiService; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.noti.controller.response.NotiListResponseDto; +import gg.pingpong.api.user.noti.service.NotiService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.noti.type.NotiType; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.noti.NotiRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/test/java/com/gg/server/domain/noti/service/NotiServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/NotiServiceTest.java similarity index 81% rename from src/test/java/com/gg/server/domain/noti/service/NotiServiceTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/NotiServiceTest.java index 0536dd740..023765197 100644 --- a/src/test/java/com/gg/server/domain/noti/service/NotiServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/NotiServiceTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.noti.service; +package gg.pingpong.api.user.noti.service; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -11,16 +11,15 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.noti.type.NotiType; -import com.gg.server.data.user.User; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; - +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.noti.type.NotiType; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.noti.NotiRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/test/java/com/gg/server/domain/noti/service/NotiServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/NotiServiceUnitTest.java similarity index 93% rename from src/test/java/com/gg/server/domain/noti/service/NotiServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/NotiServiceUnitTest.java index 588882a2f..aa297a034 100644 --- a/src/test/java/com/gg/server/domain/noti/service/NotiServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/NotiServiceUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.noti.service; +package gg.pingpong.api.user.noti.service; import static org.assertj.core.api.AssertionsForClassTypes.*; import static org.mockito.BDDMockito.*; @@ -16,18 +16,18 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.noti.type.NotiType; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.global.exception.custom.NotExistException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.noti.type.NotiType; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.noti.NotiRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.custom.NotExistException; +import gg.pingpong.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) @@ -50,8 +50,8 @@ void success() { Long userId = 1L; UserDto userDto = mock(UserDto.class); when(userDto.getId()).thenReturn(userId); - User user = new User("username", "email@example.com", "password", RacketType.NONE, RoleType.USER, - 0, SnsType.NONE, userId); + User user = new User("username", "email@example.com", "password", RacketType.NONE, + RoleType.USER, 0, SnsType.NONE, userId); when(userRepository.findById(userId)).thenReturn(Optional.of(user)); when(notiRepository.findAllByUserOrderByIdDesc(user)).thenReturn(List.of(new Noti())); //when @@ -140,8 +140,8 @@ void success() { Long userId = 1L; UserDto userDto = mock(UserDto.class); when(userDto.getId()).thenReturn(userId); - User user = new User("username", "email@example.com", "password", RacketType.NONE, RoleType.USER, - 0, SnsType.NONE, userId); + User user = new User("username", "email@example.com", "password", + RacketType.NONE, RoleType.USER, 0, SnsType.NONE, userId); List notis = List.of(new Noti()); given(userRepository.findById(any(Long.class))).willReturn(Optional.of(mock(User.class))); given(notiRepository.findAllByUser(any(User.class))).willReturn(notis); diff --git a/src/test/java/com/gg/server/domain/noti/service/SnsNotiServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/SnsNotiServiceUnitTest.java similarity index 87% rename from src/test/java/com/gg/server/domain/noti/service/SnsNotiServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/SnsNotiServiceUnitTest.java index 221bb707b..c1fced5a1 100644 --- a/src/test/java/com/gg/server/domain/noti/service/SnsNotiServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/SnsNotiServiceUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.noti.service; +package gg.pingpong.api.user.noti.service; import static org.mockito.Mockito.*; @@ -10,14 +10,14 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.noti.dto.UserNotiDto; -import com.gg.server.domain.noti.service.sns.NotiMailSender; -import com.gg.server.domain.noti.service.sns.SlackbotService; -import com.gg.server.domain.team.dto.GameUser; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.user.noti.dto.UserNotiDto; +import gg.pingpong.api.user.noti.service.sns.NotiMailSender; +import gg.pingpong.api.user.noti.service.sns.SlackbotService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.game.out.GameUser; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/domain/noti/service/sns/NotiMailSenderUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/sns/NotiMailSenderUnitTest.java similarity index 82% rename from src/test/java/com/gg/server/domain/noti/service/sns/NotiMailSenderUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/sns/NotiMailSenderUnitTest.java index ee33c67e3..41fbda784 100644 --- a/src/test/java/com/gg/server/domain/noti/service/sns/NotiMailSenderUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/sns/NotiMailSenderUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.noti.service.sns; +package gg.pingpong.api.user.noti.service.sns; import static org.mockito.Mockito.*; @@ -12,13 +12,13 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.mail.javamail.JavaMailSender; -import com.gg.server.data.noti.Noti; -import com.gg.server.domain.noti.dto.UserNotiDto; -import com.gg.server.domain.noti.service.NotiService; -import com.gg.server.domain.team.dto.GameUser; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.utils.AsyncMailSender; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.global.utils.AsyncMailSender; +import gg.pingpong.api.user.noti.dto.UserNotiDto; +import gg.pingpong.api.user.noti.service.NotiService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.repo.game.out.GameUser; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/domain/pchange/service/PChangeServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/pchange/service/PChangeServiceTest.java similarity index 85% rename from src/test/java/com/gg/server/domain/pchange/service/PChangeServiceTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/pchange/service/PChangeServiceTest.java index f492211e7..181dfc8a7 100644 --- a/src/test/java/com/gg/server/domain/pchange/service/PChangeServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/pchange/service/PChangeServiceTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.pchange.service; +package gg.pingpong.api.user.pchange.service; import static org.junit.Assert.*; import static org.mockito.BDDMockito.*; @@ -14,16 +14,17 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.PChange; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.pchange.exception.PChangeNotExistException; -import com.gg.server.utils.ReflectionUtilsForUnitTest; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.user.game.service.PChangeService; +import gg.pingpong.api.utils.ReflectionUtilsForUnitTest; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.PChange; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.game.PChangeRepository; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.pchange.PChangeNotExistException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/domain/rank/controller/RankControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/controller/RankControllerTest.java similarity index 88% rename from src/test/java/com/gg/server/domain/rank/controller/RankControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/controller/RankControllerTest.java index 089e6ee60..7c633a04c 100644 --- a/src/test/java/com/gg/server/domain/rank/controller/RankControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/controller/RankControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.controller; +package gg.pingpong.api.user.rank.controller; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -18,17 +18,18 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.data.game.Season; -import com.gg.server.data.user.User; -import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; -import com.gg.server.domain.rank.dto.RankDto; -import com.gg.server.domain.rank.dto.RankPageResponseDto; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.service.RedisUploadService; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; + +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.rank.controller.response.ExpRankPageResponseDto; +import gg.pingpong.api.user.rank.controller.response.RankPageResponseDto; +import gg.pingpong.api.user.rank.dto.RankDto; +import gg.pingpong.api.user.rank.redis.RedisUploadService; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.season.SeasonRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; @IntegrationTest @Transactional diff --git a/src/test/java/com/gg/server/domain/rank/controller/RankV2ControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/controller/RankV2ControllerTest.java similarity index 79% rename from src/test/java/com/gg/server/domain/rank/controller/RankV2ControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/controller/RankV2ControllerTest.java index 0676fb52a..5c6e29177 100644 --- a/src/test/java/com/gg/server/domain/rank/controller/RankV2ControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/controller/RankV2ControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.controller; +package gg.pingpong.api.user.rank.controller; import static org.mockito.BDDMockito.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; @@ -19,17 +19,17 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.servlet.MockMvc; -import com.gg.server.data.user.User; -import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; -import com.gg.server.domain.rank.dto.RankPageResponseDto; -import com.gg.server.domain.rank.service.RankService; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.config.WebConfig; -import com.gg.server.global.security.config.SecurityConfig; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.global.security.jwt.utils.TokenAuthenticationFilter; -import com.gg.server.global.utils.querytracker.LoggingInterceptor; +import gg.pingpong.api.global.config.WebConfig; +import gg.pingpong.api.global.security.config.SecurityConfig; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.global.security.jwt.utils.TokenAuthenticationFilter; +import gg.pingpong.api.global.utils.querytracker.LoggingInterceptor; +import gg.pingpong.api.user.rank.controller.response.ExpRankPageResponseDto; +import gg.pingpong.api.user.rank.controller.response.RankPageResponseDto; +import gg.pingpong.api.user.rank.service.RankService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.user.UserRepository; @WebMvcTest(value = RankV2Controller.class, excludeFilters = { diff --git a/src/test/java/com/gg/server/domain/rank/redis/RankRedisRepositoryTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RankRedisRepositoryTest.java similarity index 96% rename from src/test/java/com/gg/server/domain/rank/redis/RankRedisRepositoryTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RankRedisRepositoryTest.java index f932f235d..bdcc89f03 100644 --- a/src/test/java/com/gg/server/domain/rank/redis/RankRedisRepositoryTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RankRedisRepositoryTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.redis; +package gg.pingpong.api.user.rank.redis; import java.util.List; @@ -8,9 +8,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.domain.rank.exception.RedisDataNotFoundException; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.exception.rank.RedisDataNotFoundException; @IntegrationTest class RankRedisRepositoryTest { diff --git a/src/test/java/com/gg/server/domain/rank/redis/RedisTestService.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RedisTestService.java similarity index 94% rename from src/test/java/com/gg/server/domain/rank/redis/RedisTestService.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RedisTestService.java index ce12c0614..1341a67a3 100644 --- a/src/test/java/com/gg/server/domain/rank/redis/RedisTestService.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RedisTestService.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.redis; +package gg.pingpong.api.user.rank.redis; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; diff --git a/src/test/java/com/gg/server/domain/rank/redis/RedisTransactionTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RedisTransactionTest.java similarity index 94% rename from src/test/java/com/gg/server/domain/rank/redis/RedisTransactionTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RedisTransactionTest.java index e00e51059..25ac7382e 100644 --- a/src/test/java/com/gg/server/domain/rank/redis/RedisTransactionTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RedisTransactionTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.redis; +package gg.pingpong.api.user.rank.redis; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.DisplayName; @@ -7,7 +7,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.utils.annotation.IntegrationTestWithRedisTransaction; +import gg.pingpong.utils.annotation.IntegrationTestWithRedisTransaction; @IntegrationTestWithRedisTransaction public class RedisTransactionTest { diff --git a/src/test/java/com/gg/server/domain/rank/service/RankServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/service/RankServiceTest.java similarity index 86% rename from src/test/java/com/gg/server/domain/rank/service/RankServiceTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/service/RankServiceTest.java index 8366da1d8..9c7bde788 100644 --- a/src/test/java/com/gg/server/domain/rank/service/RankServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/service/RankServiceTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.service; +package gg.pingpong.api.user.rank.service; import static org.assertj.core.api.Assertions.*; import static org.mockito.BDDMockito.*; @@ -17,17 +17,17 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; -import com.gg.server.data.game.Season; -import com.gg.server.data.user.User; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.dto.ExpRankPageResponseDto; -import com.gg.server.domain.rank.dto.ExpRankV2Dto; -import com.gg.server.domain.rank.dto.RankPageResponseDto; -import com.gg.server.domain.rank.dto.RankV2Dto; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.season.service.SeasonFindService; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; +import gg.pingpong.api.user.rank.controller.response.ExpRankPageResponseDto; +import gg.pingpong.api.user.rank.controller.response.RankPageResponseDto; +import gg.pingpong.api.user.season.service.SeasonFindService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.RankV2Dto; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.user.ExpRankV2Dto; +import gg.pingpong.repo.user.UserRepository; @ExtendWith(MockitoExtension.class) class RankServiceTest { diff --git a/src/test/java/com/gg/server/domain/season/SeasonTestController.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/SeasonTestController.java similarity index 73% rename from src/test/java/com/gg/server/domain/season/SeasonTestController.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/SeasonTestController.java index 7b65f7e08..f30980dcf 100644 --- a/src/test/java/com/gg/server/domain/season/SeasonTestController.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/SeasonTestController.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.season; +package gg.pingpong.api.user.season; import static org.assertj.core.api.AssertionsForClassTypes.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -17,15 +17,15 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.data.game.Season; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.season.dto.SeasonListResDto; -import com.gg.server.domain.season.dto.SeasonResDto; -import com.gg.server.domain.season.service.SeasonService; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.season.controller.response.SeasonListResDto; +import gg.pingpong.api.user.season.controller.response.SeasonResDto; +import gg.pingpong.api.user.season.service.SeasonService; +import gg.pingpong.data.season.Season; +import gg.pingpong.repo.season.SeasonRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @@ -48,13 +48,16 @@ public class SeasonTestController { private SeasonRepository seasonRepository; @BeforeEach - @Transactional public void init() { System.out.println("before each"); - Season s1 = new Season("test1 시즌", LocalDateTime.now(), LocalDateTime.now().plusMinutes(15), 1000, 100); + Season s1 = new Season("test1 시즌", LocalDateTime.now().withNano(0).minusMinutes(5), + LocalDateTime.now().plusMinutes(15), 1000, + 100); seasonRepository.save(s1); seasonRepository.save( - new Season("test2 season", LocalDateTime.now(), LocalDateTime.now().plusMinutes(15), 1000, 100)); + new Season("test2 season", LocalDateTime.now().withNano(0).minusMinutes(5), + LocalDateTime.now().plusMinutes(15), 1000, + 100)); seasonRepository.flush(); System.out.println(seasonRepository.findAll()); } diff --git a/src/test/java/com/gg/server/domain/season/SeasonTriggerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/SeasonTriggerTest.java similarity index 86% rename from src/test/java/com/gg/server/domain/season/SeasonTriggerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/SeasonTriggerTest.java index ff21d4b19..c7f8d842f 100644 --- a/src/test/java/com/gg/server/domain/season/SeasonTriggerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/SeasonTriggerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.season; +package gg.pingpong.api.user.season; import java.time.LocalDateTime; @@ -15,13 +15,13 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.type.Mode; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.season.Season; +import gg.pingpong.repo.season.SeasonRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/test/java/com/gg/server/domain/season/service/SeasonServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/service/SeasonServiceUnitTest.java similarity index 85% rename from src/test/java/com/gg/server/domain/season/service/SeasonServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/service/SeasonServiceUnitTest.java index 5970e1674..1e4bcb9d7 100644 --- a/src/test/java/com/gg/server/domain/season/service/SeasonServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/service/SeasonServiceUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.season.service; +package gg.pingpong.api.user.season.service; import static org.mockito.BDDMockito.*; @@ -14,10 +14,10 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.data.game.Season; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.season.exception.SeasonNotFoundException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.data.season.Season; +import gg.pingpong.repo.season.SeasonRepository; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.season.SeasonNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/domain/tier/service/TierServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tier/service/TierServiceUnitTest.java similarity index 93% rename from src/test/java/com/gg/server/domain/tier/service/TierServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/tier/service/TierServiceUnitTest.java index e14086d62..f5d420213 100644 --- a/src/test/java/com/gg/server/domain/tier/service/TierServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tier/service/TierServiceUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tier.service; +package gg.pingpong.api.user.tier.service; import static org.mockito.Mockito.*; @@ -22,13 +22,14 @@ import org.mockito.quality.Strictness; import org.springframework.data.domain.Sort; -import com.gg.server.data.game.Rank; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Tier; -import com.gg.server.data.user.User; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.user.rank.service.TierService; +import gg.pingpong.data.rank.Rank; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.TierRepository; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/domain/tournament/controller/TournamentControllerMvcTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentControllerMvcTest.java similarity index 88% rename from src/test/java/com/gg/server/domain/tournament/controller/TournamentControllerMvcTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentControllerMvcTest.java index 5c25a0200..a5d40aebb 100644 --- a/src/test/java/com/gg/server/domain/tournament/controller/TournamentControllerMvcTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentControllerMvcTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.controller; +package gg.pingpong.api.user.tournament.controller; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; @@ -20,18 +20,18 @@ import org.springframework.http.ResponseEntity; import org.springframework.test.web.servlet.MockMvc; -import com.gg.server.domain.tournament.dto.TournamentFilterRequestDto; -import com.gg.server.domain.tournament.dto.TournamentGameListResponseDto; -import com.gg.server.domain.tournament.dto.TournamentListResponseDto; -import com.gg.server.domain.tournament.dto.TournamentResponseDto; -import com.gg.server.domain.tournament.dto.TournamentUserRegistrationResponseDto; -import com.gg.server.domain.tournament.service.TournamentService; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.global.config.WebConfig; -import com.gg.server.global.security.config.SecurityConfig; -import com.gg.server.global.security.jwt.utils.TokenAuthenticationFilter; -import com.gg.server.global.utils.querytracker.LoggingInterceptor; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.global.config.WebConfig; +import gg.pingpong.api.global.security.config.SecurityConfig; +import gg.pingpong.api.global.security.jwt.utils.TokenAuthenticationFilter; +import gg.pingpong.api.global.utils.querytracker.LoggingInterceptor; +import gg.pingpong.api.user.tournament.controller.request.TournamentFilterRequestDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentGameListResponseDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentListResponseDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentResponseDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentUserRegistrationResponseDto; +import gg.pingpong.api.user.tournament.service.TournamentService; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.utils.annotation.UnitTest; @UnitTest @WebMvcTest(controllers = TournamentController.class, excludeFilters = { diff --git a/src/test/java/com/gg/server/domain/tournament/controller/TournamentFindControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentFindControllerTest.java similarity index 95% rename from src/test/java/com/gg/server/domain/tournament/controller/TournamentFindControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentFindControllerTest.java index 339232baf..f56057e27 100644 --- a/src/test/java/com/gg/server/domain/tournament/controller/TournamentFindControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentFindControllerTest.java @@ -1,6 +1,6 @@ -package com.gg.server.domain.tournament.controller; +package gg.pingpong.api.user.tournament.controller; -import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -19,23 +19,23 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentUser; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.tournament.data.TournamentUserRepository; -import com.gg.server.domain.tournament.dto.TournamentListResponseDto; -import com.gg.server.domain.tournament.dto.TournamentResponseDto; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.CustomRuntimeException; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.tournament.controller.response.TournamentListResponseDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentResponseDto; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentUser; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.tournarment.TournamentUserRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.CustomRuntimeException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/test/java/com/gg/server/domain/tournament/controller/TournamentGameControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentGameControllerTest.java similarity index 77% rename from src/test/java/com/gg/server/domain/tournament/controller/TournamentGameControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentGameControllerTest.java index f5d745a1b..f2263e937 100644 --- a/src/test/java/com/gg/server/domain/tournament/controller/TournamentGameControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentGameControllerTest.java @@ -1,6 +1,6 @@ -package com.gg.server.domain.tournament.controller; +package gg.pingpong.api.user.tournament.controller; -import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -17,23 +17,23 @@ import org.springframework.transaction.annotation.Transactional; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.tournament.dto.TournamentGameListResponseDto; -import com.gg.server.domain.tournament.dto.TournamentGameResDto; -import com.gg.server.domain.user.controller.dto.GameInfoDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.tournament.controller.response.TournamentGameListResponseDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentGameResDto; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.type.TournamentRound; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.dto.GameInfoDto; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/test/java/com/gg/server/domain/tournament/controller/TournamentSchedulerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentSchedulerTest.java similarity index 82% rename from src/test/java/com/gg/server/domain/tournament/controller/TournamentSchedulerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentSchedulerTest.java index 64be308a0..d6e9e9994 100644 --- a/src/test/java/com/gg/server/domain/tournament/controller/TournamentSchedulerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentSchedulerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.controller; +package gg.pingpong.api.user.tournament.controller; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; @@ -15,17 +15,17 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.transaction.annotation.Transactional; -import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; -import com.gg.server.admin.noti.service.NotiAdminService; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.tournament.data.TournamentGameRepository; -import com.gg.server.domain.tournament.service.TournamentService; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; +import gg.pingpong.api.admin.noti.service.NotiAdminService; +import gg.pingpong.api.user.tournament.service.TournamentService; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.repo.tournarment.TournamentGameRepository; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; @IntegrationTest @Transactional diff --git a/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/service/TournamentServiceUnitTest.java similarity index 91% rename from src/test/java/com/gg/server/domain/tournament/service/TournamentServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/service/TournamentServiceUnitTest.java index 12676750b..02086589c 100644 --- a/src/test/java/com/gg/server/domain/tournament/service/TournamentServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/service/TournamentServiceUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.service; +package gg.pingpong.api.user.tournament.service; import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; @@ -24,37 +24,37 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import com.gg.server.admin.noti.dto.SendNotiAdminRequestDto; -import com.gg.server.admin.noti.service.NotiAdminService; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.TournamentUser; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; -import com.gg.server.data.game.type.TournamentUserStatus; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.match.service.MatchTournamentService; -import com.gg.server.domain.tournament.data.TournamentGameRepository; -import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.data.TournamentUserRepository; -import com.gg.server.domain.tournament.dto.TournamentGameListResponseDto; -import com.gg.server.domain.tournament.dto.TournamentResponseDto; -import com.gg.server.domain.tournament.dto.TournamentUserRegistrationResponseDto; -import com.gg.server.domain.tournament.exception.TournamentConflictException; -import com.gg.server.domain.tournament.exception.TournamentNotFoundException; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.utils.ReflectionUtilsForUnitTest; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; +import gg.pingpong.api.admin.noti.service.NotiAdminService; +import gg.pingpong.api.user.match.service.MatchTournamentService; +import gg.pingpong.api.user.tournament.controller.response.TournamentGameListResponseDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentResponseDto; +import gg.pingpong.api.user.tournament.controller.response.TournamentUserRegistrationResponseDto; +import gg.pingpong.api.user.user.dto.UserDto; +import gg.pingpong.api.utils.ReflectionUtilsForUnitTest; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.TournamentUser; +import gg.pingpong.data.tournament.type.TournamentRound; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; +import gg.pingpong.data.tournament.type.TournamentUserStatus; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.game.out.GameTeamUser; +import gg.pingpong.repo.tournarment.TournamentGameRepository; +import gg.pingpong.repo.tournarment.TournamentRepository; +import gg.pingpong.repo.tournarment.TournamentUserRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.tournament.TournamentConflictException; +import gg.pingpong.utils.exception.tournament.TournamentNotFoundException; +import gg.pingpong.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/src/test/java/com/gg/server/domain/user/controller/UserControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/controller/UserControllerTest.java similarity index 88% rename from src/test/java/com/gg/server/domain/user/controller/UserControllerTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/controller/UserControllerTest.java index f4086548e..4dcba5aa3 100644 --- a/src/test/java/com/gg/server/domain/user/controller/UserControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/controller/UserControllerTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.controller; +package gg.pingpong.api.user.user.controller; import static org.assertj.core.api.Assertions.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; @@ -26,57 +26,57 @@ import org.springframework.web.multipart.MultipartFile; import com.fasterxml.jackson.databind.ObjectMapper; -import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Rank; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Tier; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.store.Item; -import com.gg.server.data.store.Receipt; -import com.gg.server.data.store.type.ItemStatus; -import com.gg.server.data.store.type.ItemType; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.BackgroundType; -import com.gg.server.data.user.type.EdgeType; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.coin.data.CoinHistoryRepository; -import com.gg.server.domain.coin.data.CoinPolicyRepository; -import com.gg.server.domain.coin.service.CoinHistoryService; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.dto.request.RankResultReqDto; -import com.gg.server.domain.game.service.GameService; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.receipt.data.ReceiptRepository; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.user.controller.dto.GameInfoDto; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.CoinHistoryResponseDto; -import com.gg.server.domain.user.dto.UserAttendanceResponseDto; -import com.gg.server.domain.user.dto.UserCoinHistoryListResponseDto; -import com.gg.server.domain.user.dto.UserCoinResponseDto; -import com.gg.server.domain.user.dto.UserDetailResponseDto; -import com.gg.server.domain.user.dto.UserHistoryResponseDto; -import com.gg.server.domain.user.dto.UserLiveResponseDto; -import com.gg.server.domain.user.dto.UserModifyRequestDto; -import com.gg.server.domain.user.dto.UserNormalDetailResponseDto; -import com.gg.server.domain.user.dto.UserRankResponseDto; -import com.gg.server.domain.user.dto.UserSearchResponseDto; -import com.gg.server.domain.user.dto.UserTextColorDto; -import com.gg.server.domain.user.exception.UserNotFoundException; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.global.utils.UserImageHandler; -import com.gg.server.utils.ItemTestUtils; -import com.gg.server.utils.TestDataUtils; -import com.gg.server.utils.annotation.IntegrationTest; +import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.global.utils.UserImageHandler; +import gg.pingpong.api.user.game.controller.request.RankResultReqDto; +import gg.pingpong.api.user.game.service.GameService; +import gg.pingpong.api.user.store.service.CoinHistoryService; +import gg.pingpong.api.user.user.controller.request.UserModifyRequestDto; +import gg.pingpong.api.user.user.controller.response.CoinHistoryResponseDto; +import gg.pingpong.api.user.user.controller.response.UserAttendanceResponseDto; +import gg.pingpong.api.user.user.controller.response.UserCoinHistoryListResponseDto; +import gg.pingpong.api.user.user.controller.response.UserCoinResponseDto; +import gg.pingpong.api.user.user.controller.response.UserDetailResponseDto; +import gg.pingpong.api.user.user.controller.response.UserHistoryResponseDto; +import gg.pingpong.api.user.user.controller.response.UserLiveResponseDto; +import gg.pingpong.api.user.user.controller.response.UserNormalDetailResponseDto; +import gg.pingpong.api.user.user.controller.response.UserRankResponseDto; +import gg.pingpong.api.user.user.controller.response.UserSearchResponseDto; +import gg.pingpong.api.user.user.dto.UserTextColorDto; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.rank.Rank; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.store.Receipt; +import gg.pingpong.data.store.type.ItemStatus; +import gg.pingpong.data.store.type.ItemType; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.type.BackgroundType; +import gg.pingpong.data.user.type.EdgeType; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.TierRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.season.SeasonRepository; +import gg.pingpong.repo.store.CoinHistoryRepository; +import gg.pingpong.repo.store.CoinPolicyRepository; +import gg.pingpong.repo.store.ReceiptRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.ItemTestUtils; +import gg.pingpong.utils.RedisKeyManager; +import gg.pingpong.utils.TestDataUtils; +import gg.pingpong.utils.annotation.IntegrationTest; +import gg.pingpong.utils.dto.GameInfoDto; +import gg.pingpong.utils.exception.user.UserNotFoundException; import lombok.extern.slf4j.Slf4j; @IntegrationTest @@ -505,7 +505,7 @@ public void getUserCoin() throws Exception { .andReturn().getResponse().getContentAsString(); UserCoinResponseDto result = objectMapper.readValue(contentAsString, UserCoinResponseDto.class); - int userCoin = userRepository.findById(userId).orElseThrow(() -> new UserNotFoundException()).getGgCoin(); + int userCoin = userRepository.findById(userId).orElseThrow(UserNotFoundException::new).getGgCoin(); assertThat(result.getCoin()).isEqualTo(userCoin); System.out.println(userCoin); } diff --git a/src/test/java/com/gg/server/domain/user/service/UserAuthenticationServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserAuthenticationServiceUnitTest.java similarity index 84% rename from src/test/java/com/gg/server/domain/user/service/UserAuthenticationServiceUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserAuthenticationServiceUnitTest.java index 1b4b0ba6e..add8ec526 100644 --- a/src/test/java/com/gg/server/domain/user/service/UserAuthenticationServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserAuthenticationServiceUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.service; +package gg.pingpong.api.user.user.service; import static org.mockito.Mockito.*; @@ -11,10 +11,10 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import com.gg.server.domain.user.exception.TokenNotValidException; -import com.gg.server.global.security.jwt.repository.JwtRedisRepository; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.api.global.security.jwt.repository.JwtRedisRepository; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.user.TokenNotValidException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserFindServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserFindServiceUnitTest.java new file mode 100644 index 000000000..5121920d0 --- /dev/null +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserFindServiceUnitTest.java @@ -0,0 +1,8 @@ +package gg.pingpong.api.user.user.service; + +import gg.pingpong.utils.annotation.UnitTest; + +@UnitTest +class UserFindServiceUnitTest { + +} diff --git a/src/test/java/com/gg/server/utils/ReflectionUtilsForUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/utils/ReflectionUtilsForUnitTest.java similarity index 81% rename from src/test/java/com/gg/server/utils/ReflectionUtilsForUnitTest.java rename to gg-pingpong-api/src/test/java/gg/pingpong/api/utils/ReflectionUtilsForUnitTest.java index fc7f4cf0b..f6eef8431 100644 --- a/src/test/java/com/gg/server/utils/ReflectionUtilsForUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/utils/ReflectionUtilsForUnitTest.java @@ -1,9 +1,9 @@ -package com.gg.server.utils; +package gg.pingpong.api.utils; import java.lang.reflect.Field; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; /** * ReflectionUtilsForUnitTest. diff --git a/src/test/resources/application.yml b/gg-pingpong-api/src/test/resources/application.yml similarity index 100% rename from src/test/resources/application.yml rename to gg-pingpong-api/src/test/resources/application.yml diff --git a/gg-pingpong-data/build.gradle b/gg-pingpong-data/build.gradle new file mode 100644 index 000000000..78311ef9d --- /dev/null +++ b/gg-pingpong-data/build.gradle @@ -0,0 +1,20 @@ +plugins { + id 'java' +} + +group 'gg.pingpong.data' +version '42gg' + +repositories { + mavenCentral() +} + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' + testImplementation testFixtures(project(':gg-pingpong-utils')) +} + +test { + useJUnitPlatform() +} diff --git a/src/main/java/com/gg/server/global/utils/BaseTimeEntity.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/BaseTimeEntity.java similarity index 94% rename from src/main/java/com/gg/server/global/utils/BaseTimeEntity.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/BaseTimeEntity.java index 11ff94f14..7e8b59324 100644 --- a/src/main/java/com/gg/server/global/utils/BaseTimeEntity.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/BaseTimeEntity.java @@ -1,4 +1,4 @@ -package com.gg.server.global.utils; +package gg.pingpong.data; import java.time.LocalDateTime; diff --git a/src/main/java/com/gg/server/data/game/Game.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/game/Game.java similarity index 83% rename from src/main/java/com/gg/server/data/game/Game.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/game/Game.java index 828962177..5cdabf6ca 100644 --- a/src/main/java/com/gg/server/data/game/Game.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/game/Game.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game; +package gg.pingpong.data.game; import java.time.LocalDateTime; import java.util.ArrayList; @@ -20,12 +20,11 @@ import org.hibernate.annotations.DynamicUpdate; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.domain.match.dto.GameAddDto; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.utils.BusinessChecker; - +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.season.Season; +import gg.pingpong.utils.exception.BusinessChecker; +import gg.pingpong.utils.exception.ErrorCode; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -73,12 +72,12 @@ public Game(Season season, StatusType status, Mode mode, LocalDateTime startTime this.endTime = endTime; } - public Game(GameAddDto dto, Integer interval) { - this.season = dto.getSeason(); + public Game(Season season, Mode mode, LocalDateTime startTime, Integer interval) { + this.season = season; this.status = StatusType.BEFORE; - this.mode = dto.getMode(); - this.startTime = dto.getStartTime(); - this.endTime = dto.getStartTime().plusMinutes(interval); + this.mode = mode; + this.startTime = startTime; + this.endTime = startTime.plusMinutes(interval); } @Override diff --git a/src/main/java/com/gg/server/data/game/PChange.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/game/PChange.java similarity index 92% rename from src/main/java/com/gg/server/data/game/PChange.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/game/PChange.java index 662d9dc94..14950b420 100644 --- a/src/main/java/com/gg/server/data/game/PChange.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/game/PChange.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game; +package gg.pingpong.data.game; import javax.persistence.Column; import javax.persistence.Entity; @@ -10,9 +10,8 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.data.user.User; -import com.gg.server.global.utils.BaseTimeEntity; - +import gg.pingpong.data.BaseTimeEntity; +import gg.pingpong.data.user.User; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/data/game/Team.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/game/Team.java similarity index 92% rename from src/main/java/com/gg/server/data/game/Team.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/game/Team.java index 53e0ee928..04ffeb391 100644 --- a/src/main/java/com/gg/server/data/game/Team.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/game/Team.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game; +package gg.pingpong.data.game; import java.util.ArrayList; import java.util.List; @@ -17,9 +17,8 @@ import org.hibernate.annotations.DynamicUpdate; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.utils.BusinessChecker; - +import gg.pingpong.utils.exception.BusinessChecker; +import gg.pingpong.utils.exception.ErrorCode; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/data/game/TeamUser.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/game/TeamUser.java similarity index 86% rename from src/main/java/com/gg/server/data/game/TeamUser.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/game/TeamUser.java index ab44ccaec..a6144859a 100644 --- a/src/main/java/com/gg/server/data/game/TeamUser.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/game/TeamUser.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game; +package gg.pingpong.data.game; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -9,10 +9,9 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.data.user.User; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.utils.BusinessChecker; - +import gg.pingpong.data.user.User; +import gg.pingpong.utils.exception.BusinessChecker; +import gg.pingpong.utils.exception.ErrorCode; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/game/type/Mode.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/game/type/Mode.java new file mode 100644 index 000000000..40010f2ad --- /dev/null +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/game/type/Mode.java @@ -0,0 +1,27 @@ +package gg.pingpong.data.game.type; + +import java.util.Locale; + +import com.fasterxml.jackson.annotation.JsonCreator; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum Mode { + NORMAL("normal"), RANK("rank"), TOURNAMENT("tournament"); + private final String code; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static Mode getEnumValue(String code) { + for (Mode e : values()) { + if (e.code.equals(code)) { + return e; + } else if (e.code.toUpperCase(Locale.ROOT).equals(code.toUpperCase(Locale.ROOT))) { + return e; + } + } + return null; + } +} diff --git a/src/main/java/com/gg/server/data/game/type/StatusType.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/game/type/StatusType.java similarity index 95% rename from src/main/java/com/gg/server/data/game/type/StatusType.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/game/type/StatusType.java index f16dbe702..a6877703f 100644 --- a/src/main/java/com/gg/server/data/game/type/StatusType.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/game/type/StatusType.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game.type; +package gg.pingpong.data.game.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/data/manage/Announcement.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Announcement.java similarity index 79% rename from src/main/java/com/gg/server/data/manage/Announcement.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Announcement.java index 538f13350..0518942a9 100644 --- a/src/main/java/com/gg/server/data/manage/Announcement.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Announcement.java @@ -1,4 +1,4 @@ -package com.gg.server.data.manage; +package gg.pingpong.data.manage; import java.time.LocalDateTime; @@ -9,9 +9,7 @@ import javax.persistence.Id; import javax.validation.constraints.NotNull; -import com.gg.server.admin.announcement.dto.AnnouncementAdminAddDto; -import com.gg.server.global.utils.BaseTimeEntity; - +import gg.pingpong.data.BaseTimeEntity; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -47,10 +45,10 @@ public void update(String deleterIntraId, LocalDateTime deletedAt) { this.deletedAt = deletedAt; } - public static Announcement from(AnnouncementAdminAddDto addDto) { + public static Announcement from(String content, String creatorIntraId) { return Announcement.builder() - .content(addDto.getContent()) - .creatorIntraId(addDto.getCreatorIntraId()) + .content(content) + .creatorIntraId(creatorIntraId) .build(); } } diff --git a/src/main/java/com/gg/server/data/manage/Feedback.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Feedback.java similarity index 87% rename from src/main/java/com/gg/server/data/manage/Feedback.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Feedback.java index 4e31e3568..2da52cf37 100644 --- a/src/main/java/com/gg/server/data/manage/Feedback.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Feedback.java @@ -1,4 +1,4 @@ -package com.gg.server.data.manage; +package gg.pingpong.data.manage; import javax.persistence.Column; import javax.persistence.Entity; @@ -12,10 +12,9 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.data.manage.type.FeedbackType; -import com.gg.server.data.user.User; -import com.gg.server.global.utils.BaseTimeEntity; - +import gg.pingpong.data.BaseTimeEntity; +import gg.pingpong.data.manage.type.FeedbackType; +import gg.pingpong.data.user.User; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/data/manage/Penalty.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Penalty.java similarity index 89% rename from src/main/java/com/gg/server/data/manage/Penalty.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Penalty.java index 69582fcb9..d7b57f1f6 100644 --- a/src/main/java/com/gg/server/data/manage/Penalty.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Penalty.java @@ -1,4 +1,4 @@ -package com.gg.server.data.manage; +package gg.pingpong.data.manage; import java.time.LocalDateTime; @@ -14,10 +14,9 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.data.user.User; -import com.gg.server.domain.penalty.type.PenaltyType; -import com.gg.server.global.utils.BaseTimeEntity; - +import gg.pingpong.data.BaseTimeEntity; +import gg.pingpong.data.manage.type.PenaltyType; +import gg.pingpong.data.user.User; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/domain/slotmanagement/SlotManagement.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/SlotManagement.java similarity index 75% rename from src/main/java/com/gg/server/domain/slotmanagement/SlotManagement.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/manage/SlotManagement.java index 6192c4185..bf0abd874 100644 --- a/src/main/java/com/gg/server/domain/slotmanagement/SlotManagement.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/SlotManagement.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.slotmanagement; +package gg.pingpong.data.manage; import java.time.LocalDateTime; @@ -9,10 +9,8 @@ import javax.persistence.Id; import javax.validation.constraints.NotNull; -import com.gg.server.admin.slotmanagement.dto.SlotCreateRequestDto; -import com.gg.server.domain.slotmanagement.exception.SlotManagementForbiddenException; -import com.gg.server.global.utils.BaseTimeEntity; - +import gg.pingpong.data.BaseTimeEntity; +import gg.pingpong.utils.exception.slotmanagement.SlotManagementForbiddenException; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -62,12 +60,13 @@ public SlotManagement(Integer pastSlotTime, Integer futureSlotTime, Integer open } @Builder - public SlotManagement(SlotCreateRequestDto requestDto) { - this.pastSlotTime = requestDto.getPastSlotTime(); - this.futureSlotTime = requestDto.getFutureSlotTime(); - this.openMinute = requestDto.getOpenMinute(); - this.gameInterval = requestDto.getInterval(); - this.startTime = requestDto.getStartTime(); + public SlotManagement(Integer pastSlotTime, Integer futureSlotTime, Integer openMinute, Integer gameInterval, + LocalDateTime startTime) { + this.pastSlotTime = pastSlotTime; + this.futureSlotTime = futureSlotTime; + this.openMinute = openMinute; + this.gameInterval = gameInterval; + this.startTime = startTime; this.endTime = null; } diff --git a/src/main/java/com/gg/server/data/manage/redis/RedisPenaltyUser.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/redis/RedisPenaltyUser.java similarity index 96% rename from src/main/java/com/gg/server/data/manage/redis/RedisPenaltyUser.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/manage/redis/RedisPenaltyUser.java index 7fb8848b1..904b222cb 100644 --- a/src/main/java/com/gg/server/data/manage/redis/RedisPenaltyUser.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/redis/RedisPenaltyUser.java @@ -1,4 +1,4 @@ -package com.gg.server.data.manage.redis; +package gg.pingpong.data.manage.redis; import java.time.LocalDateTime; diff --git a/src/main/java/com/gg/server/data/manage/type/FeedbackType.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/FeedbackType.java similarity index 94% rename from src/main/java/com/gg/server/data/manage/type/FeedbackType.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/FeedbackType.java index 2a1437538..c5281c5e2 100644 --- a/src/main/java/com/gg/server/data/manage/type/FeedbackType.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/FeedbackType.java @@ -1,4 +1,4 @@ -package com.gg.server.data.manage.type; +package gg.pingpong.data.manage.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/admin/penalty/type/PenaltyKey.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/PenaltyKey.java similarity index 81% rename from src/main/java/com/gg/server/admin/penalty/type/PenaltyKey.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/PenaltyKey.java index 45b73d4e9..3f367a3c4 100644 --- a/src/main/java/com/gg/server/admin/penalty/type/PenaltyKey.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/PenaltyKey.java @@ -1,4 +1,4 @@ -package com.gg.server.admin.penalty.type; +package gg.pingpong.data.manage.type; public class PenaltyKey { public static final String ALL = "PENALTY:"; diff --git a/src/main/java/com/gg/server/domain/penalty/type/PenaltyType.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/PenaltyType.java similarity index 94% rename from src/main/java/com/gg/server/domain/penalty/type/PenaltyType.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/PenaltyType.java index b84d760a0..4b3a86e97 100644 --- a/src/main/java/com/gg/server/domain/penalty/type/PenaltyType.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/PenaltyType.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.penalty.type; +package gg.pingpong.data.manage.type; import java.util.Arrays; import java.util.Locale; diff --git a/src/main/java/com/gg/server/data/match/RedisMatchTime.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/match/RedisMatchTime.java similarity index 92% rename from src/main/java/com/gg/server/data/match/RedisMatchTime.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/match/RedisMatchTime.java index 35227c83d..b31096506 100644 --- a/src/main/java/com/gg/server/data/match/RedisMatchTime.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/match/RedisMatchTime.java @@ -1,4 +1,4 @@ -package com.gg.server.data.match; +package gg.pingpong.data.match; import java.io.Serializable; import java.time.LocalDateTime; @@ -11,8 +11,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import com.gg.server.data.match.type.Option; +import gg.pingpong.data.match.type.Option; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/data/match/RedisMatchUser.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/match/RedisMatchUser.java similarity index 87% rename from src/main/java/com/gg/server/data/match/RedisMatchUser.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/match/RedisMatchUser.java index ee4714587..191b21ab6 100644 --- a/src/main/java/com/gg/server/data/match/RedisMatchUser.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/match/RedisMatchUser.java @@ -1,4 +1,4 @@ -package com.gg.server.data.match; +package gg.pingpong.data.match; import java.io.Serializable; @@ -6,8 +6,7 @@ import org.springframework.data.redis.core.RedisHash; -import com.gg.server.data.match.type.Option; - +import gg.pingpong.data.match.type.Option; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/data/match/type/MatchKey.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/MatchKey.java similarity index 93% rename from src/main/java/com/gg/server/data/match/type/MatchKey.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/MatchKey.java index 786e219b2..33123f76b 100644 --- a/src/main/java/com/gg/server/data/match/type/MatchKey.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/MatchKey.java @@ -1,4 +1,4 @@ -package com.gg.server.data.match.type; +package gg.pingpong.data.match.type; import java.time.LocalDateTime; diff --git a/src/main/java/com/gg/server/data/match/type/Option.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/Option.java similarity index 87% rename from src/main/java/com/gg/server/data/match/type/Option.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/Option.java index 53134baaa..faad1359b 100644 --- a/src/main/java/com/gg/server/data/match/type/Option.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/Option.java @@ -1,10 +1,10 @@ -package com.gg.server.data.match.type; +package gg.pingpong.data.match.type; import java.util.Locale; import com.fasterxml.jackson.annotation.JsonCreator; -import com.gg.server.domain.match.exception.OptionInvalidException; +import gg.pingpong.utils.exception.match.OptionInvalidException; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/data/match/type/SlotStatus.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/SlotStatus.java similarity index 93% rename from src/main/java/com/gg/server/data/match/type/SlotStatus.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/SlotStatus.java index 6160212d1..6f3146822 100644 --- a/src/main/java/com/gg/server/data/match/type/SlotStatus.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/SlotStatus.java @@ -1,4 +1,4 @@ -package com.gg.server.data.match.type; +package gg.pingpong.data.match.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/data/match/type/TournamentMatchStatus.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/TournamentMatchStatus.java similarity index 91% rename from src/main/java/com/gg/server/data/match/type/TournamentMatchStatus.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/TournamentMatchStatus.java index 62e37d112..96faabeb5 100644 --- a/src/main/java/com/gg/server/data/match/type/TournamentMatchStatus.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/TournamentMatchStatus.java @@ -1,4 +1,4 @@ -package com.gg.server.data.match.type; +package gg.pingpong.data.match.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/data/noti/Noti.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/noti/Noti.java similarity index 89% rename from src/main/java/com/gg/server/data/noti/Noti.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/noti/Noti.java index ae37bad76..5e47ac52e 100644 --- a/src/main/java/com/gg/server/data/noti/Noti.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/noti/Noti.java @@ -1,4 +1,4 @@ -package com.gg.server.data.noti; +package gg.pingpong.data.noti; import javax.persistence.Column; import javax.persistence.Entity; @@ -12,10 +12,9 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.data.noti.type.NotiType; -import com.gg.server.data.user.User; -import com.gg.server.global.utils.BaseTimeEntity; - +import gg.pingpong.data.BaseTimeEntity; +import gg.pingpong.data.noti.type.NotiType; +import gg.pingpong.data.user.User; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/data/noti/type/NotiType.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/noti/type/NotiType.java similarity index 97% rename from src/main/java/com/gg/server/data/noti/type/NotiType.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/noti/type/NotiType.java index ee831b11e..3a98598ec 100644 --- a/src/main/java/com/gg/server/data/noti/type/NotiType.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/noti/type/NotiType.java @@ -1,4 +1,4 @@ -package com.gg.server.data.noti.type; +package gg.pingpong.data.noti.type; import java.util.Arrays; import java.util.Locale; diff --git a/src/main/java/com/gg/server/data/game/Rank.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/rank/Rank.java similarity index 83% rename from src/main/java/com/gg/server/data/game/Rank.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/rank/Rank.java index f593675de..2e97a383c 100644 --- a/src/main/java/com/gg/server/data/game/Rank.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/rank/Rank.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game; +package gg.pingpong.data.rank; import java.io.Serializable; @@ -15,10 +15,9 @@ import org.hibernate.annotations.DynamicUpdate; -import com.gg.server.admin.user.dto.UserUpdateAdminRequestDto; -import com.gg.server.data.user.User; -import com.gg.server.global.utils.BaseTimeEntity; - +import gg.pingpong.data.BaseTimeEntity; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.user.User; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -92,12 +91,6 @@ public void setStatusMessage(String statusMessage) { this.statusMessage = statusMessage; } - public void modifyUserRank(UserUpdateAdminRequestDto userUpdateAdminRequestDto) { - this.ppp = userUpdateAdminRequestDto.getPpp(); - this.wins = userUpdateAdminRequestDto.getWins(); - this.losses = userUpdateAdminRequestDto.getLosses(); - } - public void modifyUserRank(Integer ppp, int wins, int losses) { this.ppp = ppp; this.wins = wins; diff --git a/src/main/java/com/gg/server/data/game/Tier.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/rank/Tier.java similarity index 95% rename from src/main/java/com/gg/server/data/game/Tier.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/rank/Tier.java index 5b934c6da..996c40396 100644 --- a/src/main/java/com/gg/server/data/game/Tier.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/rank/Tier.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game; +package gg.pingpong.data.rank; import java.io.Serializable; diff --git a/src/main/java/com/gg/server/data/game/redis/RankRedis.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/rank/redis/RankRedis.java similarity index 86% rename from src/main/java/com/gg/server/data/game/redis/RankRedis.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/rank/redis/RankRedis.java index 43b53e62b..e56cf40b1 100644 --- a/src/main/java/com/gg/server/data/game/redis/RankRedis.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/rank/redis/RankRedis.java @@ -1,12 +1,10 @@ -package com.gg.server.data.game.redis; +package gg.pingpong.data.rank.redis; import java.io.Serializable; import org.springframework.data.redis.core.RedisHash; -import com.gg.server.data.game.Rank; -import com.gg.server.domain.user.dto.UserDto; - +import gg.pingpong.data.rank.Rank; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -48,16 +46,16 @@ public void setStatusMessage(String msg) { this.statusMessage = msg; } - public static RankRedis from(UserDto user, Integer ppp, String tierImageUri) { + public static RankRedis from(Long id, String intraId, String textColor, Integer ppp, String tierImageUri) { RankRedis rankRedis = RankRedis.builder() - .userId(user.getId()) - .intraId(user.getIntraId()) + .userId(id) + .intraId(intraId) .ppp(ppp) .wins(0) .losses(0) .statusMessage("") .tierImageUri(tierImageUri) - .textColor(user.getTextColor()) + .textColor(textColor) .build(); return rankRedis; } diff --git a/src/main/java/com/gg/server/data/game/Season.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/season/Season.java similarity index 78% rename from src/main/java/com/gg/server/data/game/Season.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/season/Season.java index 0b8beb164..2f3b528ad 100644 --- a/src/main/java/com/gg/server/data/game/Season.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/season/Season.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game; +package gg.pingpong.data.season; import java.time.LocalDateTime; @@ -9,8 +9,6 @@ import javax.persistence.Id; import javax.validation.constraints.NotNull; -import com.gg.server.admin.season.dto.SeasonCreateRequestDto; - import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -60,11 +58,4 @@ public Season(String seasonName, LocalDateTime startTime, LocalDateTime endTime, this.pppGap = pppGap; } - @Builder - public Season(SeasonCreateRequestDto createDto) { - this.seasonName = createDto.getSeasonName(); - this.startTime = createDto.getStartTime(); - this.startPpp = createDto.getStartPpp(); - this.pppGap = createDto.getPppGap(); - } } diff --git a/src/main/java/com/gg/server/data/store/CoinHistory.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/CoinHistory.java similarity index 93% rename from src/main/java/com/gg/server/data/store/CoinHistory.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/store/CoinHistory.java index b8ffa6c9b..b7eac63e7 100644 --- a/src/main/java/com/gg/server/data/store/CoinHistory.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/CoinHistory.java @@ -1,4 +1,4 @@ -package com.gg.server.data.store; +package gg.pingpong.data.store; import java.time.LocalDateTime; @@ -13,8 +13,7 @@ import org.springframework.data.annotation.CreatedDate; -import com.gg.server.data.user.User; - +import gg.pingpong.data.user.User; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/data/manage/CoinPolicy.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/CoinPolicy.java similarity index 80% rename from src/main/java/com/gg/server/data/manage/CoinPolicy.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/store/CoinPolicy.java index 74a745692..487572915 100644 --- a/src/main/java/com/gg/server/data/manage/CoinPolicy.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/CoinPolicy.java @@ -1,4 +1,4 @@ -package com.gg.server.data.manage; +package gg.pingpong.data.store; import java.time.LocalDateTime; @@ -13,9 +13,7 @@ import org.springframework.data.annotation.CreatedDate; -import com.gg.server.admin.coin.dto.CoinPolicyAdminAddDto; -import com.gg.server.data.user.User; - +import gg.pingpong.data.user.User; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -60,13 +58,13 @@ public CoinPolicy(User user, int attendance, int normal, int rankWin, int rankLo this.createdAt = LocalDateTime.now(); } - public static CoinPolicy from(User user, CoinPolicyAdminAddDto addDto) { + public static CoinPolicy from(User user, int attendance, int normal, int rankWin, int rankLose) { return CoinPolicy.builder() .user(user) - .attendance(addDto.getAttendance()) - .normal(addDto.getNormal()) - .rankWin(addDto.getRankWin()) - .rankLose(addDto.getRankLose()) + .attendance(attendance) + .normal(normal) + .rankWin(rankWin) + .rankLose(rankLose) .build(); } } diff --git a/src/main/java/com/gg/server/data/store/Item.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/Item.java similarity index 78% rename from src/main/java/com/gg/server/data/store/Item.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/store/Item.java index 6717955f9..16bea6da7 100644 --- a/src/main/java/com/gg/server/data/store/Item.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/Item.java @@ -1,4 +1,4 @@ -package com.gg.server.data.store; +package gg.pingpong.data.store; import java.time.LocalDateTime; @@ -11,9 +11,7 @@ import javax.persistence.Id; import javax.validation.constraints.NotNull; -import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.data.store.type.ItemType; - +import gg.pingpong.data.store.type.ItemType; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @@ -65,6 +63,7 @@ public class Item { @Column(name = "deleter_intra_id", length = 10) private String deleterIntraId; + @Builder public Item(String name, String mainContent, String subContent, String imageUri, Integer price, Boolean isVisible, Integer discount, ItemType type, LocalDateTime createdAt, String creatorIntraId) { this.name = name; @@ -79,20 +78,6 @@ public Item(String name, String mainContent, String subContent, String imageUri, this.creatorIntraId = creatorIntraId; } - @Builder - public Item(ItemUpdateRequestDto updateRequestDto, String creatorIntraId, String itemImageUri) { - this.name = updateRequestDto.getName(); - this.mainContent = updateRequestDto.getMainContent(); - this.subContent = updateRequestDto.getSubContent(); - this.imageUri = itemImageUri; - this.price = updateRequestDto.getPrice(); - this.discount = updateRequestDto.getDiscount(); - this.isVisible = true; - this.creatorIntraId = creatorIntraId; - this.createdAt = LocalDateTime.now(); - this.type = updateRequestDto.getItemType(); - } - public void imageUpdate(String imageUri) { this.imageUri = imageUri; } diff --git a/src/main/java/com/gg/server/data/store/Megaphone.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/Megaphone.java similarity index 94% rename from src/main/java/com/gg/server/data/store/Megaphone.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/store/Megaphone.java index 989cb7cd4..e648c8727 100644 --- a/src/main/java/com/gg/server/data/store/Megaphone.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/Megaphone.java @@ -1,4 +1,4 @@ -package com.gg.server.data.store; +package gg.pingpong.data.store; import java.time.LocalDate; @@ -12,8 +12,7 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.data.user.User; - +import gg.pingpong.data.user.User; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/data/store/Receipt.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/Receipt.java similarity index 95% rename from src/main/java/com/gg/server/data/store/Receipt.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/store/Receipt.java index b10e4bf9e..a41715200 100644 --- a/src/main/java/com/gg/server/data/store/Receipt.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/Receipt.java @@ -1,4 +1,4 @@ -package com.gg.server.data.store; +package gg.pingpong.data.store; import java.time.LocalDateTime; @@ -14,8 +14,7 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.data.store.type.ItemStatus; - +import gg.pingpong.data.store.type.ItemStatus; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/data/store/redis/MegaphoneRedis.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/redis/MegaphoneRedis.java similarity index 95% rename from src/main/java/com/gg/server/data/store/redis/MegaphoneRedis.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/store/redis/MegaphoneRedis.java index c498977cc..abe63aebb 100644 --- a/src/main/java/com/gg/server/data/store/redis/MegaphoneRedis.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/redis/MegaphoneRedis.java @@ -1,4 +1,4 @@ -package com.gg.server.data.store.redis; +package gg.pingpong.data.store.redis; import java.time.LocalDateTime; diff --git a/src/main/java/com/gg/server/data/store/type/HistoryType.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/HistoryType.java similarity index 87% rename from src/main/java/com/gg/server/data/store/type/HistoryType.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/HistoryType.java index 18305a2dd..af06808f8 100644 --- a/src/main/java/com/gg/server/data/store/type/HistoryType.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/HistoryType.java @@ -1,4 +1,4 @@ -package com.gg.server.data.store.type; +package gg.pingpong.data.store.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/data/store/type/ItemStatus.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/ItemStatus.java similarity index 87% rename from src/main/java/com/gg/server/data/store/type/ItemStatus.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/ItemStatus.java index a75506edb..384a2c6da 100644 --- a/src/main/java/com/gg/server/data/store/type/ItemStatus.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/ItemStatus.java @@ -1,4 +1,4 @@ -package com.gg.server.data.store.type; +package gg.pingpong.data.store.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/data/store/type/ItemType.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/ItemType.java similarity index 79% rename from src/main/java/com/gg/server/data/store/type/ItemType.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/ItemType.java index 51583e48d..dd75871f9 100644 --- a/src/main/java/com/gg/server/data/store/type/ItemType.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/ItemType.java @@ -1,4 +1,4 @@ -package com.gg.server.data.store.type; +package gg.pingpong.data.store.type; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/data/game/Tournament.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/Tournament.java similarity index 92% rename from src/main/java/com/gg/server/data/game/Tournament.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/Tournament.java index 0f46a52eb..bda096543 100644 --- a/src/main/java/com/gg/server/data/game/Tournament.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/Tournament.java @@ -1,7 +1,7 @@ -package com.gg.server.data.game; +package gg.pingpong.data.tournament; -import static com.gg.server.global.exception.ErrorCode.*; -import static com.gg.server.global.utils.BusinessChecker.*; +import static gg.pingpong.utils.exception.BusinessChecker.*; +import static gg.pingpong.utils.exception.ErrorCode.*; import java.time.LocalDateTime; import java.util.ArrayList; @@ -22,11 +22,10 @@ import javax.persistence.OneToOne; import javax.validation.constraints.NotNull; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; -import com.gg.server.data.user.User; -import com.gg.server.global.utils.BaseTimeEntity; - +import gg.pingpong.data.BaseTimeEntity; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; +import gg.pingpong.data.user.User; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/gg/server/data/game/TournamentGame.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/TournamentGame.java similarity index 90% rename from src/main/java/com/gg/server/data/game/TournamentGame.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/TournamentGame.java index 014c32744..b8693f31c 100644 --- a/src/main/java/com/gg/server/data/game/TournamentGame.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/TournamentGame.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game; +package gg.pingpong.data.tournament; import javax.persistence.Column; import javax.persistence.Entity; @@ -13,9 +13,9 @@ import javax.persistence.OneToOne; import javax.validation.constraints.NotNull; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.global.utils.BaseTimeEntity; - +import gg.pingpong.data.BaseTimeEntity; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.tournament.type.TournamentRound; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/gg/server/data/game/TournamentUser.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/TournamentUser.java similarity index 93% rename from src/main/java/com/gg/server/data/game/TournamentUser.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/TournamentUser.java index 6ec35100b..dcb29391b 100644 --- a/src/main/java/com/gg/server/data/game/TournamentUser.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/TournamentUser.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game; +package gg.pingpong.data.tournament; import java.time.LocalDateTime; @@ -12,9 +12,8 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.gg.server.data.user.User; -import com.gg.server.global.utils.BaseTimeEntity; - +import gg.pingpong.data.BaseTimeEntity; +import gg.pingpong.data.user.User; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/gg/server/data/game/type/RoundNumber.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/RoundNumber.java similarity index 85% rename from src/main/java/com/gg/server/data/game/type/RoundNumber.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/RoundNumber.java index f940fab96..177909f87 100644 --- a/src/main/java/com/gg/server/data/game/type/RoundNumber.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/RoundNumber.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game.type; +package gg.pingpong.data.tournament.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/data/game/type/TournamentRound.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentRound.java similarity index 93% rename from src/main/java/com/gg/server/data/game/type/TournamentRound.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentRound.java index 33a969f87..3fd46e156 100644 --- a/src/main/java/com/gg/server/data/game/type/TournamentRound.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentRound.java @@ -1,6 +1,6 @@ -package com.gg.server.data.game.type; +package gg.pingpong.data.tournament.type; -import static com.gg.server.data.game.type.RoundNumber.*; +import static gg.pingpong.data.tournament.type.RoundNumber.*; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/gg/server/data/game/type/TournamentStatus.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentStatus.java similarity index 94% rename from src/main/java/com/gg/server/data/game/type/TournamentStatus.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentStatus.java index 327310b06..ef7416125 100644 --- a/src/main/java/com/gg/server/data/game/type/TournamentStatus.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentStatus.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game.type; +package gg.pingpong.data.tournament.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/data/game/type/TournamentType.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentType.java similarity index 94% rename from src/main/java/com/gg/server/data/game/type/TournamentType.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentType.java index 17ed4a069..b424dbf22 100644 --- a/src/main/java/com/gg/server/data/game/type/TournamentType.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentType.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game.type; +package gg.pingpong.data.tournament.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/data/game/type/TournamentUserStatus.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentUserStatus.java similarity index 88% rename from src/main/java/com/gg/server/data/game/type/TournamentUserStatus.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentUserStatus.java index 95778ad02..8ab078e42 100644 --- a/src/main/java/com/gg/server/data/game/type/TournamentUserStatus.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentUserStatus.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game.type; +package gg.pingpong.data.tournament.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/gg/server/data/user/User.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/User.java similarity index 81% rename from src/main/java/com/gg/server/data/user/User.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/user/User.java index e05c91946..dd80e6962 100644 --- a/src/main/java/com/gg/server/data/user/User.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/User.java @@ -1,4 +1,4 @@ -package com.gg.server.data.user; +package gg.pingpong.data.user; import java.io.Serializable; @@ -13,15 +13,13 @@ import org.hibernate.annotations.DynamicUpdate; -import com.gg.server.admin.user.dto.UserUpdateAdminRequestDto; -import com.gg.server.data.user.type.BackgroundType; -import com.gg.server.data.user.type.EdgeType; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.item.exception.InsufficientGgcoinException; -import com.gg.server.global.utils.BaseTimeEntity; - +import gg.pingpong.data.BaseTimeEntity; +import gg.pingpong.data.user.type.BackgroundType; +import gg.pingpong.data.user.type.EdgeType; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.utils.exception.item.InsufficientGgcoinException; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -96,11 +94,11 @@ public User(String intraId, String eMail, String imageUri, RacketType racketType this.ggCoin = 0; } - public void modifyUserDetail(UserUpdateAdminRequestDto updateReq) { - this.eMail = updateReq.getEmail(); - this.racketType = updateReq.getRacketType(); - this.roleType = RoleType.of(updateReq.getRoleType()); - this.ggCoin = updateReq.getCoin(); + public void modifyUserDetail(String email, RacketType racketType, RoleType roleType, Integer coin) { + this.eMail = email; + this.racketType = racketType; + this.roleType = roleType; + this.ggCoin = coin; } public void updateImageUri(String imageUri) { diff --git a/src/main/java/com/gg/server/data/user/UserImage.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/UserImage.java similarity index 97% rename from src/main/java/com/gg/server/data/user/UserImage.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/user/UserImage.java index b798239ea..adb6f2ba7 100644 --- a/src/main/java/com/gg/server/data/user/UserImage.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/UserImage.java @@ -1,4 +1,4 @@ -package com.gg.server.data.user; +package gg.pingpong.data.user; import java.time.LocalDateTime; diff --git a/src/main/java/com/gg/server/data/user/type/BackgroundType.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/BackgroundType.java similarity index 96% rename from src/main/java/com/gg/server/data/user/type/BackgroundType.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/BackgroundType.java index 5b790d4ac..ef6c72b18 100644 --- a/src/main/java/com/gg/server/data/user/type/BackgroundType.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/BackgroundType.java @@ -1,4 +1,4 @@ -package com.gg.server.data.user.type; +package gg.pingpong.data.user.type; import java.util.Random; diff --git a/src/main/java/com/gg/server/data/user/type/EdgeType.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/EdgeType.java similarity index 96% rename from src/main/java/com/gg/server/data/user/type/EdgeType.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/EdgeType.java index 4db3159be..c09221e14 100644 --- a/src/main/java/com/gg/server/data/user/type/EdgeType.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/EdgeType.java @@ -1,4 +1,4 @@ -package com.gg.server.data.user.type; +package gg.pingpong.data.user.type; import java.util.Random; diff --git a/src/main/java/com/gg/server/data/user/type/OauthType.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/OauthType.java similarity index 95% rename from src/main/java/com/gg/server/data/user/type/OauthType.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/OauthType.java index 0bfda350b..103fa4311 100644 --- a/src/main/java/com/gg/server/data/user/type/OauthType.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/OauthType.java @@ -1,4 +1,4 @@ -package com.gg.server.data.user.type; +package gg.pingpong.data.user.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/data/user/type/RacketType.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/RacketType.java similarity index 93% rename from src/main/java/com/gg/server/data/user/type/RacketType.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/RacketType.java index 39ca89116..ec2785bc0 100644 --- a/src/main/java/com/gg/server/data/user/type/RacketType.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/RacketType.java @@ -1,4 +1,4 @@ -package com.gg.server.data.user.type; +package gg.pingpong.data.user.type; import java.util.Locale; diff --git a/src/main/java/com/gg/server/data/user/type/RoleType.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/RoleType.java similarity index 92% rename from src/main/java/com/gg/server/data/user/type/RoleType.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/RoleType.java index 81382949d..430056ffa 100644 --- a/src/main/java/com/gg/server/data/user/type/RoleType.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/RoleType.java @@ -1,4 +1,4 @@ -package com.gg.server.data.user.type; +package gg.pingpong.data.user.type; import java.util.Arrays; diff --git a/src/main/java/com/gg/server/data/user/type/SnsType.java b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/SnsType.java similarity index 92% rename from src/main/java/com/gg/server/data/user/type/SnsType.java rename to gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/SnsType.java index f04af49a7..52cccb283 100644 --- a/src/main/java/com/gg/server/data/user/type/SnsType.java +++ b/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/SnsType.java @@ -1,4 +1,4 @@ -package com.gg.server.data.user.type; +package gg.pingpong.data.user.type; import java.util.Arrays; diff --git a/src/test/java/com/gg/server/data/game/TournamentUnitTest.java b/gg-pingpong-data/src/test/java/gg/pingpong/data/tournament/TournamentUnitTest.java similarity index 97% rename from src/test/java/com/gg/server/data/game/TournamentUnitTest.java rename to gg-pingpong-data/src/test/java/gg/pingpong/data/tournament/TournamentUnitTest.java index 5034de6cc..5775af7a3 100644 --- a/src/test/java/com/gg/server/data/game/TournamentUnitTest.java +++ b/gg-pingpong-data/src/test/java/gg/pingpong/data/tournament/TournamentUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.data.game; +package gg.pingpong.data.tournament; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; @@ -16,12 +16,12 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; -import com.gg.server.data.user.User; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; -import com.gg.server.utils.annotation.UnitTest; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; +import gg.pingpong.data.user.User; +import gg.pingpong.utils.annotation.UnitTest; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; @UnitTest @DisplayName("TournamentUnitTest") diff --git a/gg-pingpong-repo/build.gradle b/gg-pingpong-repo/build.gradle new file mode 100644 index 000000000..839f760aa --- /dev/null +++ b/gg-pingpong-repo/build.gradle @@ -0,0 +1,25 @@ +plugins { + id 'java' +} + +group 'gg.pingpong.repo' +version '42gg' + +repositories { + mavenCentral() +} + +dependencies { + /* database */ + runtimeOnly 'mysql:mysql-connector-java' + /* flyway */ + implementation 'org.flywaydb:flyway-core' + + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' + testImplementation testFixtures(project(':gg-pingpong-utils')) +} + +test { + useJUnitPlatform() +} diff --git a/src/main/java/com/gg/server/domain/game/data/GameRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepository.java similarity index 95% rename from src/main/java/com/gg/server/domain/game/data/GameRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepository.java index 745aeea0e..d3251ea51 100644 --- a/src/main/java/com/gg/server/domain/game/data/GameRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.game.data; +package gg.pingpong.repo.game; import java.time.LocalDateTime; import java.util.List; @@ -14,12 +14,12 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.domain.game.dto.GameTeamUser; -import com.gg.server.domain.game.dto.GameTeamUserInfo; -import com.gg.server.domain.team.dto.GameUser; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.repo.game.out.GameTeamUser; +import gg.pingpong.repo.game.out.GameTeamUserInfo; +import gg.pingpong.repo.game.out.GameUser; public interface GameRepository extends JpaRepository, GameRepositoryCustom { Slice findAllByModeAndStatus(Mode mode, StatusType status, Pageable pageable); diff --git a/src/main/java/com/gg/server/domain/game/data/GameRepositoryCustom.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepositoryCustom.java similarity index 61% rename from src/main/java/com/gg/server/domain/game/data/GameRepositoryCustom.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepositoryCustom.java index d28668aa8..8ed108af6 100644 --- a/src/main/java/com/gg/server/domain/game/data/GameRepositoryCustom.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepositoryCustom.java @@ -1,8 +1,8 @@ -package com.gg.server.domain.game.data; +package gg.pingpong.repo.game; import java.util.Optional; -import com.gg.server.data.game.Game; +import gg.pingpong.data.game.Game; public interface GameRepositoryCustom { Optional getLatestGameByUser(Long userId); diff --git a/src/main/java/com/gg/server/domain/game/data/GameRepositoryImpl.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepositoryImpl.java similarity index 87% rename from src/main/java/com/gg/server/domain/game/data/GameRepositoryImpl.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepositoryImpl.java index b85dbca0d..104aa8cbf 100644 --- a/src/main/java/com/gg/server/domain/game/data/GameRepositoryImpl.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepositoryImpl.java @@ -1,13 +1,12 @@ -package com.gg.server.domain.game.data; +package gg.pingpong.repo.game; import java.util.Optional; import javax.persistence.EntityManager; import javax.persistence.NoResultException; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.TeamUser; - +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.TeamUser; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepository.java similarity index 90% rename from src/main/java/com/gg/server/domain/pchange/data/PChangeRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepository.java index 6057f6a66..d92ee1a85 100644 --- a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.pchange.data; +package gg.pingpong.repo.game; import java.util.List; import java.util.Optional; @@ -7,8 +7,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.game.PChange; -import com.gg.server.data.game.type.Mode; +import gg.pingpong.data.game.PChange; +import gg.pingpong.data.game.type.Mode; public interface PChangeRepository extends JpaRepository, PChangeRepositoryCustom { diff --git a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryCustom.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepositoryCustom.java similarity index 76% rename from src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryCustom.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepositoryCustom.java index c3fd6bdb3..2b30d2c38 100644 --- a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryCustom.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepositoryCustom.java @@ -1,8 +1,8 @@ -package com.gg.server.domain.pchange.data; +package gg.pingpong.repo.game; import java.util.List; -import com.gg.server.data.game.PChange; +import gg.pingpong.data.game.PChange; public interface PChangeRepositoryCustom { List findPChangesHistory(String intraId, Long seasonId); diff --git a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryImpl.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepositoryImpl.java similarity index 95% rename from src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryImpl.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepositoryImpl.java index 2360120b0..709ae5961 100644 --- a/src/main/java/com/gg/server/domain/pchange/data/PChangeRepositoryImpl.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepositoryImpl.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.pchange.data; +package gg.pingpong.repo.game; import java.util.List; @@ -6,8 +6,7 @@ import org.springframework.stereotype.Repository; -import com.gg.server.data.game.PChange; - +import gg.pingpong.data.game.PChange; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/gg/server/domain/team/data/TeamRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/TeamRepository.java similarity index 83% rename from src/main/java/com/gg/server/domain/team/data/TeamRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/TeamRepository.java index 83e00226b..4027538a8 100644 --- a/src/main/java/com/gg/server/domain/team/data/TeamRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/TeamRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.team.data; +package gg.pingpong.repo.game; import java.util.List; @@ -6,7 +6,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.game.Team; +import gg.pingpong.data.game.Team; public interface TeamRepository extends JpaRepository { @Query("select t from Team t where t.game.id=:gameId") diff --git a/src/main/java/com/gg/server/domain/team/data/TeamUserRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/TeamUserRepository.java similarity index 91% rename from src/main/java/com/gg/server/domain/team/data/TeamUserRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/TeamUserRepository.java index bfa8a5dc7..599551394 100644 --- a/src/main/java/com/gg/server/domain/team/data/TeamUserRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/TeamUserRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.team.data; +package gg.pingpong.repo.game; import java.time.LocalDateTime; import java.util.List; @@ -7,7 +7,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.game.TeamUser; +import gg.pingpong.data.game.TeamUser; public interface TeamUserRepository extends JpaRepository { @Query(value = "select team_user.id, team_user.team_id, team_user.user_id from team, team_user " diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameTeamUser.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameTeamUser.java new file mode 100644 index 000000000..35c7916f2 --- /dev/null +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameTeamUser.java @@ -0,0 +1,50 @@ +package gg.pingpong.repo.game.out; + +import java.time.LocalDateTime; + +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; + +public interface GameTeamUser { + Long getGameId(); + + LocalDateTime getStartTime(); + + LocalDateTime getEndTime(); + + StatusType getStatus(); + + Mode getMode(); + + Long getT1TeamId(); + + Integer getT1Wins(); + + Integer getT1Losses(); + + String getT1IntraId(); + + String getT1Image(); + + Integer getT1Exp(); + + Integer getT1Score(); + + Boolean getT1IsWin(); + + Long getT2TeamId(); + + Integer getT2Wins(); + + Integer getT2Losses(); + + String getT2IntraId(); + + String getT2Image(); + + Integer getT2Exp(); + + Integer getT2Score(); + + Boolean getT2IsWin(); +} diff --git a/src/main/java/com/gg/server/domain/game/dto/GameTeamUserInfo.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameTeamUserInfo.java similarity index 69% rename from src/main/java/com/gg/server/domain/game/dto/GameTeamUserInfo.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameTeamUserInfo.java index bff4af5a0..d3b0e3bb4 100644 --- a/src/main/java/com/gg/server/domain/game/dto/GameTeamUserInfo.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameTeamUserInfo.java @@ -1,9 +1,9 @@ -package com.gg.server.domain.game.dto; +package gg.pingpong.repo.game.out; import java.time.LocalDateTime; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; public interface GameTeamUserInfo { Long getGameId(); diff --git a/src/main/java/com/gg/server/domain/team/dto/GameUser.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameUser.java similarity index 62% rename from src/main/java/com/gg/server/domain/team/dto/GameUser.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameUser.java index d432737b0..2adca75b8 100644 --- a/src/main/java/com/gg/server/domain/team/dto/GameUser.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameUser.java @@ -1,6 +1,6 @@ -package com.gg.server.domain.team.dto; +package gg.pingpong.repo.game.out; -import com.gg.server.data.user.type.SnsType; +import gg.pingpong.data.user.type.SnsType; public interface GameUser { Long getGameId(); diff --git a/src/main/java/com/gg/server/domain/announcement/data/AnnouncementRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/AnnouncementRepository.java similarity index 70% rename from src/main/java/com/gg/server/domain/announcement/data/AnnouncementRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/AnnouncementRepository.java index b992738ef..82946d97f 100644 --- a/src/main/java/com/gg/server/domain/announcement/data/AnnouncementRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/AnnouncementRepository.java @@ -1,10 +1,10 @@ -package com.gg.server.domain.announcement.data; +package gg.pingpong.repo.manage; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.manage.Announcement; +import gg.pingpong.data.manage.Announcement; public interface AnnouncementRepository extends JpaRepository { Optional findFirstByOrderByIdDesc(); diff --git a/src/main/java/com/gg/server/domain/feedback/data/FeedbackRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/FeedbackRepository.java similarity index 67% rename from src/main/java/com/gg/server/domain/feedback/data/FeedbackRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/FeedbackRepository.java index 0a8fbd658..9575e4ea3 100644 --- a/src/main/java/com/gg/server/domain/feedback/data/FeedbackRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/FeedbackRepository.java @@ -1,8 +1,8 @@ -package com.gg.server.domain.feedback.data; +package gg.pingpong.repo.manage; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.manage.Feedback; +import gg.pingpong.data.manage.Feedback; public interface FeedbackRepository extends JpaRepository { Feedback findFirstByOrderByIdDesc(); diff --git a/src/main/java/com/gg/server/domain/penalty/data/PenaltyRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/PenaltyRepository.java similarity index 62% rename from src/main/java/com/gg/server/domain/penalty/data/PenaltyRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/PenaltyRepository.java index 13940f9cf..d3b16e8a1 100644 --- a/src/main/java/com/gg/server/domain/penalty/data/PenaltyRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/PenaltyRepository.java @@ -1,8 +1,8 @@ -package com.gg.server.domain.penalty.data; +package gg.pingpong.repo.manage; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.manage.Penalty; +import gg.pingpong.data.manage.Penalty; public interface PenaltyRepository extends JpaRepository { diff --git a/src/main/java/com/gg/server/domain/slotmanagement/data/SlotManagementRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/SlotManagementRepository.java similarity index 87% rename from src/main/java/com/gg/server/domain/slotmanagement/data/SlotManagementRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/SlotManagementRepository.java index 947559edf..96c0e3f7e 100644 --- a/src/main/java/com/gg/server/domain/slotmanagement/data/SlotManagementRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/SlotManagementRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.slotmanagement.data; +package gg.pingpong.repo.manage; import java.time.LocalDateTime; import java.util.List; @@ -8,7 +8,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.domain.slotmanagement.SlotManagement; +import gg.pingpong.data.manage.SlotManagement; public interface SlotManagementRepository extends JpaRepository { diff --git a/src/main/java/com/gg/server/domain/match/data/RedisMatchTimeRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/match/RedisMatchTimeRepository.java similarity index 93% rename from src/main/java/com/gg/server/domain/match/data/RedisMatchTimeRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/match/RedisMatchTimeRepository.java index 1cc9e49ac..c32a2ed4b 100644 --- a/src/main/java/com/gg/server/domain/match/data/RedisMatchTimeRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/match/RedisMatchTimeRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.data; +package gg.pingpong.repo.match; import java.time.Duration; import java.time.LocalDateTime; @@ -11,9 +11,8 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; -import com.gg.server.data.match.RedisMatchUser; -import com.gg.server.data.match.type.MatchKey; - +import gg.pingpong.data.match.RedisMatchUser; +import gg.pingpong.data.match.type.MatchKey; import lombok.RequiredArgsConstructor; @Repository diff --git a/src/main/java/com/gg/server/domain/match/data/RedisMatchUserRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/match/RedisMatchUserRepository.java similarity index 88% rename from src/main/java/com/gg/server/domain/match/data/RedisMatchUserRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/match/RedisMatchUserRepository.java index a9797bab6..9f4ccc657 100644 --- a/src/main/java/com/gg/server/domain/match/data/RedisMatchUserRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/match/RedisMatchUserRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.match.data; +package gg.pingpong.repo.match; import java.time.Duration; import java.time.LocalDateTime; @@ -10,11 +10,10 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; -import com.gg.server.data.match.RedisMatchTime; -import com.gg.server.data.match.type.MatchKey; -import com.gg.server.data.match.type.Option; -import com.gg.server.domain.match.exception.PastSlotException; - +import gg.pingpong.data.match.RedisMatchTime; +import gg.pingpong.data.match.type.MatchKey; +import gg.pingpong.data.match.type.Option; +import gg.pingpong.utils.exception.match.PastSlotException; import lombok.RequiredArgsConstructor; @Repository diff --git a/src/main/java/com/gg/server/domain/noti/data/NotiRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepository.java similarity index 78% rename from src/main/java/com/gg/server/domain/noti/data/NotiRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepository.java index a104720e8..a1777e78c 100644 --- a/src/main/java/com/gg/server/domain/noti/data/NotiRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepository.java @@ -1,12 +1,12 @@ -package com.gg.server.domain.noti.data; +package gg.pingpong.repo.noti; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.user.User; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.user.User; public interface NotiRepository extends JpaRepository, NotiRepositoryCustom { List findByUser(User user); diff --git a/src/main/java/com/gg/server/domain/noti/data/NotiRepositoryCustom.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepositoryCustom.java similarity index 68% rename from src/main/java/com/gg/server/domain/noti/data/NotiRepositoryCustom.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepositoryCustom.java index 8d484d880..41b2f8e96 100644 --- a/src/main/java/com/gg/server/domain/noti/data/NotiRepositoryCustom.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepositoryCustom.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.noti.data; +package gg.pingpong.repo.noti; public interface NotiRepositoryCustom { int countNotCheckedNotiByUser(Long userId); diff --git a/src/main/java/com/gg/server/domain/noti/data/NotiRepositoryImpl.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepositoryImpl.java similarity index 92% rename from src/main/java/com/gg/server/domain/noti/data/NotiRepositoryImpl.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepositoryImpl.java index f29e107e6..986bea00b 100644 --- a/src/main/java/com/gg/server/domain/noti/data/NotiRepositoryImpl.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepositoryImpl.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.noti.data; +package gg.pingpong.repo.noti; import javax.persistence.EntityManager; diff --git a/src/main/java/com/gg/server/domain/rank/data/RankRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/RankRepository.java similarity index 96% rename from src/main/java/com/gg/server/domain/rank/data/RankRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/RankRepository.java index f698d1424..349129af4 100644 --- a/src/main/java/com/gg/server/domain/rank/data/RankRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/RankRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.data; +package gg.pingpong.repo.rank; import java.util.List; import java.util.Optional; @@ -10,8 +10,7 @@ import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; -import com.gg.server.data.game.Rank; -import com.gg.server.domain.rank.dto.RankV2Dto; +import gg.pingpong.data.rank.Rank; @Repository public interface RankRepository extends JpaRepository { diff --git a/src/main/java/com/gg/server/domain/rank/dto/RankV2Dto.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/RankV2Dto.java similarity index 82% rename from src/main/java/com/gg/server/domain/rank/dto/RankV2Dto.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/RankV2Dto.java index 463977f2f..a506e23f1 100644 --- a/src/main/java/com/gg/server/domain/rank/dto/RankV2Dto.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/RankV2Dto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.dto; +package gg.pingpong.repo.rank; public interface RankV2Dto { diff --git a/src/main/java/com/gg/server/domain/tier/data/TierRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/TierRepository.java similarity index 82% rename from src/main/java/com/gg/server/domain/tier/data/TierRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/TierRepository.java index f1583fdfe..1530aa4c2 100644 --- a/src/main/java/com/gg/server/domain/tier/data/TierRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/TierRepository.java @@ -1,11 +1,11 @@ -package com.gg.server.domain.tier.data; +package gg.pingpong.repo.rank; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import com.gg.server.data.game.Tier; +import gg.pingpong.data.rank.Tier; public interface TierRepository extends JpaRepository { diff --git a/src/main/java/com/gg/server/domain/rank/redis/RankRedisRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/redis/RankRedisRepository.java similarity index 97% rename from src/main/java/com/gg/server/domain/rank/redis/RankRedisRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/redis/RankRedisRepository.java index 29df5cb90..62f232d62 100644 --- a/src/main/java/com/gg/server/domain/rank/redis/RankRedisRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/redis/RankRedisRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.redis; +package gg.pingpong.repo.rank.redis; import java.util.Comparator; import java.util.List; @@ -10,8 +10,8 @@ import org.springframework.data.redis.core.ZSetOperations; import org.springframework.stereotype.Repository; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.domain.rank.exception.RedisDataNotFoundException; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.utils.exception.rank.RedisDataNotFoundException; @Repository public class RankRedisRepository { diff --git a/src/main/java/com/gg/server/domain/season/data/SeasonRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/season/SeasonRepository.java similarity index 92% rename from src/main/java/com/gg/server/domain/season/data/SeasonRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/season/SeasonRepository.java index 1ba8b10ff..f6bd1848c 100644 --- a/src/main/java/com/gg/server/domain/season/data/SeasonRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/season/SeasonRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.season.data; +package gg.pingpong.repo.season; import java.time.LocalDateTime; import java.util.List; @@ -8,7 +8,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.game.Season; +import gg.pingpong.data.season.Season; public interface SeasonRepository extends JpaRepository { @Query("select s from Season s where s.startTime <= :now and s.endTime >= :now") diff --git a/src/main/java/com/gg/server/domain/coin/data/CoinHistoryRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/CoinHistoryRepository.java similarity index 89% rename from src/main/java/com/gg/server/domain/coin/data/CoinHistoryRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/CoinHistoryRepository.java index d1cd63487..a2535c0f8 100644 --- a/src/main/java/com/gg/server/domain/coin/data/CoinHistoryRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/CoinHistoryRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.coin.data; +package gg.pingpong.repo.store; import java.time.LocalDateTime; import java.util.List; @@ -10,8 +10,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.store.CoinHistory; -import com.gg.server.data.user.User; +import gg.pingpong.data.store.CoinHistory; +import gg.pingpong.data.user.User; public interface CoinHistoryRepository extends JpaRepository { @Query("SELECT CASE WHEN COUNT(ch) > 0 THEN true ELSE false END FROM CoinHistory ch " diff --git a/src/main/java/com/gg/server/domain/coin/data/CoinPolicyRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/CoinPolicyRepository.java similarity index 73% rename from src/main/java/com/gg/server/domain/coin/data/CoinPolicyRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/CoinPolicyRepository.java index 0a08de823..fe7da9f0e 100644 --- a/src/main/java/com/gg/server/domain/coin/data/CoinPolicyRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/CoinPolicyRepository.java @@ -1,10 +1,10 @@ -package com.gg.server.domain.coin.data; +package gg.pingpong.repo.store; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.manage.CoinPolicy; +import gg.pingpong.data.store.CoinPolicy; public interface CoinPolicyRepository extends JpaRepository { Optional findTopByOrderByCreatedAtDesc(); diff --git a/src/main/java/com/gg/server/domain/item/data/ItemRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/ItemRepository.java similarity index 81% rename from src/main/java/com/gg/server/domain/item/data/ItemRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/ItemRepository.java index efcdaffe6..18e25abe8 100644 --- a/src/main/java/com/gg/server/domain/item/data/ItemRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/ItemRepository.java @@ -1,11 +1,11 @@ -package com.gg.server.domain.item.data; +package gg.pingpong.repo.store; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import com.gg.server.data.store.Item; +import gg.pingpong.data.store.Item; public interface ItemRepository extends JpaRepository { @Query("SELECT i FROM Item i WHERE i.isVisible = true ORDER BY i.createdAt DESC") diff --git a/src/main/java/com/gg/server/domain/megaphone/data/MegaphoneRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/MegaphoneRepository.java similarity index 69% rename from src/main/java/com/gg/server/domain/megaphone/data/MegaphoneRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/MegaphoneRepository.java index 04c2fe49b..62b305c5a 100644 --- a/src/main/java/com/gg/server/domain/megaphone/data/MegaphoneRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/MegaphoneRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.megaphone.data; +package gg.pingpong.repo.store; import java.time.LocalDate; import java.util.List; @@ -6,9 +6,9 @@ import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.store.Megaphone; -import com.gg.server.data.store.Receipt; -import com.gg.server.data.store.type.ItemStatus; +import gg.pingpong.data.store.Megaphone; +import gg.pingpong.data.store.Receipt; +import gg.pingpong.data.store.type.ItemStatus; public interface MegaphoneRepository extends JpaRepository { List findAllByUsedAtAndReceiptStatus(LocalDate date, ItemStatus itemStatus); diff --git a/src/main/java/com/gg/server/domain/receipt/data/ReceiptRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/ReceiptRepository.java similarity index 62% rename from src/main/java/com/gg/server/domain/receipt/data/ReceiptRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/ReceiptRepository.java index a21621f09..3a607e3f0 100644 --- a/src/main/java/com/gg/server/domain/receipt/data/ReceiptRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/ReceiptRepository.java @@ -1,8 +1,8 @@ -package com.gg.server.domain.receipt.data; +package gg.pingpong.repo.store; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.store.Receipt; +import gg.pingpong.data.store.Receipt; public interface ReceiptRepository extends JpaRepository { } diff --git a/src/main/java/com/gg/server/domain/item/data/UserItemRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/UserItemRepository.java similarity index 88% rename from src/main/java/com/gg/server/domain/item/data/UserItemRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/UserItemRepository.java index 2d5c232d4..087943908 100644 --- a/src/main/java/com/gg/server/domain/item/data/UserItemRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/UserItemRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.item.data; +package gg.pingpong.repo.store; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -6,7 +6,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.store.Receipt; +import gg.pingpong.data.store.Receipt; public interface UserItemRepository extends JpaRepository { diff --git a/src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentGameRepository.java similarity index 78% rename from src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentGameRepository.java index 1d205ca9e..042697ce4 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/TournamentGameRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentGameRepository.java @@ -1,12 +1,12 @@ -package com.gg.server.domain.tournament.data; +package gg.pingpong.repo.tournarment; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.type.TournamentRound; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.type.TournamentRound; public interface TournamentGameRepository extends JpaRepository { List findAllByTournamentId(Long tournamentId); diff --git a/src/main/java/com/gg/server/domain/tournament/data/TournamentRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentRepository.java similarity index 87% rename from src/main/java/com/gg/server/domain/tournament/data/TournamentRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentRepository.java index 839e20930..491ee7c79 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/TournamentRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.tournament.data; +package gg.pingpong.repo.tournarment; import java.time.LocalDateTime; import java.util.List; @@ -12,9 +12,9 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; public interface TournamentRepository extends JpaRepository { List findAllByStatusIsNot(TournamentStatus status); diff --git a/src/main/java/com/gg/server/domain/tournament/data/TournamentUserRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentUserRepository.java similarity index 78% rename from src/main/java/com/gg/server/domain/tournament/data/TournamentUserRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentUserRepository.java index 1fad69e44..6a7130da0 100644 --- a/src/main/java/com/gg/server/domain/tournament/data/TournamentUserRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentUserRepository.java @@ -1,13 +1,13 @@ -package com.gg.server.domain.tournament.data; +package gg.pingpong.repo.tournarment; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentUser; -import com.gg.server.data.user.User; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentUser; +import gg.pingpong.data.user.User; public interface TournamentUserRepository extends JpaRepository { diff --git a/src/main/java/com/gg/server/domain/rank/dto/ExpRankV2Dto.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/ExpRankV2Dto.java similarity index 82% rename from src/main/java/com/gg/server/domain/rank/dto/ExpRankV2Dto.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/ExpRankV2Dto.java index 299139f4e..641e03ef9 100644 --- a/src/main/java/com/gg/server/domain/rank/dto/ExpRankV2Dto.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/ExpRankV2Dto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.dto; +package gg.pingpong.repo.user; public interface ExpRankV2Dto { String getIntraId(); diff --git a/src/main/java/com/gg/server/domain/user/data/UserImageRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/UserImageRepository.java similarity index 67% rename from src/main/java/com/gg/server/domain/user/data/UserImageRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/UserImageRepository.java index 7e42ca75b..809a3a3b3 100644 --- a/src/main/java/com/gg/server/domain/user/data/UserImageRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/UserImageRepository.java @@ -1,11 +1,11 @@ -package com.gg.server.domain.user.data; +package gg.pingpong.repo.user; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import com.gg.server.data.user.User; -import com.gg.server.data.user.UserImage; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.UserImage; public interface UserImageRepository extends JpaRepository { Optional findTopByUserAndIsCurrentIsTrueOrderByIdDesc(User user); diff --git a/src/main/java/com/gg/server/domain/user/data/UserRepository.java b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/UserRepository.java similarity index 94% rename from src/main/java/com/gg/server/domain/user/data/UserRepository.java rename to gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/UserRepository.java index dc60db2ce..60855d497 100644 --- a/src/main/java/com/gg/server/domain/user/data/UserRepository.java +++ b/gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/UserRepository.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.data; +package gg.pingpong.repo.user; import java.util.List; import java.util.Optional; @@ -10,8 +10,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import com.gg.server.data.user.User; -import com.gg.server.domain.rank.dto.ExpRankV2Dto; +import gg.pingpong.data.user.User; public interface UserRepository extends JpaRepository { Optional findByIntraId(String intraId); diff --git a/gg-pingpong-utils/build.gradle b/gg-pingpong-utils/build.gradle new file mode 100644 index 000000000..856dbdf49 --- /dev/null +++ b/gg-pingpong-utils/build.gradle @@ -0,0 +1,103 @@ +plugins { + id 'java' + id 'java-test-fixtures' + id 'jacoco-report-aggregation' +} + +group 'gg.pingpong.utils' +version '42gg' + +repositories { + mavenCentral() +} + +reporting { + reports { + unitTestCoverageReport(JacocoCoverageReport) { + testType = TestSuiteType.UNIT_TEST + } + } +} + +reporting { + reports { + integrationTestCoverageReport(JacocoCoverageReport) { + testType = TestSuiteType.UNIT_TEST + } + } +} + +def jacocoExcludes = [ + '*Application*', + "**/config/*", + "**/security/*", + "**/dto/*", + "**/aws/*", + "*NotiMailSender*", + '*SlackbotService*', +] + + +integrationTestCoverageReport { + reports { + html.required = true + csv.required = false + xml.required = true + } + + getClassDirectories().setFrom(files( + [project(':gg-pingpong-data'), project(':gg-pingpong-admin-repo'), + project(':gg-pingpong-repo'), project(':gg-pingpong-api')].collect { + it.fileTree(dir: "${it.buildDir}/classes/java/main", exclude: jacocoExcludes) + } + )) +} + + +unitTestCoverageReport { + reports { + html.required = true + csv.required = false + xml.required = true + } + + getClassDirectories().setFrom(files( + [project(':gg-pingpong-data'), project(':gg-pingpong-admin-repo'), + project(':gg-pingpong-repo'), project(':gg-pingpong-api')].collect { + it.fileTree(dir: "${it.buildDir}/classes/java/main", exclude: jacocoExcludes) + } + )) +} + + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' + + testFixturesImplementation("org.junit.jupiter:junit-jupiter:5.8.1") + testFixturesImplementation('org.springframework.boot:spring-boot-starter-data-redis') + testFixturesImplementation('org.springframework.boot:spring-boot-starter-data-jpa') + testFixturesImplementation("org.springframework.boot:spring-boot-starter-test:2.5.5") + testFixturesImplementation("org.testcontainers:testcontainers:1.19.3") + testFixturesImplementation("org.testcontainers:junit-jupiter:1.19.3") + testFixturesImplementation("org.testcontainers:mysql:1.19.3") + testFixturesImplementation("com.redis:testcontainers-redis:2.0.1") + + testFixturesImplementation("org.projectlombok:lombok:1.18.26") + testFixturesCompileOnly("org.projectlombok:lombok") + testFixturesAnnotationProcessor("org.projectlombok:lombok") + + testFixturesImplementation project(":gg-pingpong-data") + testFixturesImplementation project(":gg-pingpong-repo") + testFixturesImplementation project(":gg-pingpong-admin-repo") + testFixturesImplementation project(":gg-pingpong-api") + + jacocoAggregation(project(':gg-pingpong-data')) + jacocoAggregation(project(':gg-pingpong-repo')) + jacocoAggregation(project(':gg-pingpong-admin-repo')) + jacocoAggregation(project(':gg-pingpong-api')) +} + +test { + useJUnitPlatform() +} diff --git a/src/main/java/com/gg/server/domain/rank/redis/RedisKeyManager.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/RedisKeyManager.java similarity index 92% rename from src/main/java/com/gg/server/domain/rank/redis/RedisKeyManager.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/RedisKeyManager.java index cb55ca29f..1ef247577 100644 --- a/src/main/java/com/gg/server/domain/rank/redis/RedisKeyManager.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/RedisKeyManager.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.rank.redis; +package gg.pingpong.utils; public class RedisKeyManager { private static final String ZSetKeyPrefix = "rank:ZSet:"; diff --git a/src/main/java/com/gg/server/global/utils/BusinessChecker.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/BusinessChecker.java similarity index 86% rename from src/main/java/com/gg/server/global/utils/BusinessChecker.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/BusinessChecker.java index 9702b0b2f..eb5de88fb 100644 --- a/src/main/java/com/gg/server/global/utils/BusinessChecker.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/BusinessChecker.java @@ -1,10 +1,8 @@ -package com.gg.server.global.utils; +package gg.pingpong.utils.exception; import java.util.Collection; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; - +import gg.pingpong.utils.exception.custom.BusinessException; import lombok.AccessLevel; import lombok.NoArgsConstructor; diff --git a/src/main/java/com/gg/server/global/exception/ErrorCode.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/ErrorCode.java similarity index 99% rename from src/main/java/com/gg/server/global/exception/ErrorCode.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/ErrorCode.java index 9134e58c5..268ed64e4 100644 --- a/src/main/java/com/gg/server/global/exception/ErrorCode.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/ErrorCode.java @@ -1,4 +1,4 @@ -package com.gg.server.global.exception; +package gg.pingpong.utils.exception; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/gg/server/global/exception/ErrorResponse.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/ErrorResponse.java similarity index 88% rename from src/main/java/com/gg/server/global/exception/ErrorResponse.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/ErrorResponse.java index 1caabe9b2..414d27265 100644 --- a/src/main/java/com/gg/server/global/exception/ErrorResponse.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/ErrorResponse.java @@ -1,4 +1,4 @@ -package com.gg.server.global.exception; +package gg.pingpong.utils.exception; import lombok.Getter; diff --git a/src/main/java/com/gg/server/domain/announcement/exception/AnnounceDupException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/announcement/AnnounceDupException.java similarity index 52% rename from src/main/java/com/gg/server/domain/announcement/exception/AnnounceDupException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/announcement/AnnounceDupException.java index f664afc36..177bfe184 100644 --- a/src/main/java/com/gg/server/domain/announcement/exception/AnnounceDupException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/announcement/AnnounceDupException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.announcement.exception; +package gg.pingpong.utils.exception.announcement; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.DuplicationException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.DuplicationException; public class AnnounceDupException extends DuplicationException { public AnnounceDupException() { diff --git a/src/main/java/com/gg/server/domain/announcement/exception/AnnounceNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/announcement/AnnounceNotFoundException.java similarity index 53% rename from src/main/java/com/gg/server/domain/announcement/exception/AnnounceNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/announcement/AnnounceNotFoundException.java index 8c835202f..10ebefdae 100644 --- a/src/main/java/com/gg/server/domain/announcement/exception/AnnounceNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/announcement/AnnounceNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.announcement.exception; +package gg.pingpong.utils.exception.announcement; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.CustomRuntimeException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.CustomRuntimeException; public class AnnounceNotFoundException extends CustomRuntimeException { public AnnounceNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/coin/exception/CoinHistoryNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/coin/CoinHistoryNotFoundException.java similarity index 56% rename from src/main/java/com/gg/server/domain/coin/exception/CoinHistoryNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/coin/CoinHistoryNotFoundException.java index 902c165f7..867cb8d22 100644 --- a/src/main/java/com/gg/server/domain/coin/exception/CoinHistoryNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/coin/CoinHistoryNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.coin.exception; +package gg.pingpong.utils.exception.coin; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.CustomRuntimeException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.CustomRuntimeException; public class CoinHistoryNotFoundException extends CustomRuntimeException { public CoinHistoryNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/coin/exception/CoinPolicyNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/coin/CoinPolicyNotFoundException.java similarity index 55% rename from src/main/java/com/gg/server/domain/coin/exception/CoinPolicyNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/coin/CoinPolicyNotFoundException.java index ca7050f03..f4f2f211a 100644 --- a/src/main/java/com/gg/server/domain/coin/exception/CoinPolicyNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/coin/CoinPolicyNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.coin.exception; +package gg.pingpong.utils.exception.coin; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.CustomRuntimeException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.CustomRuntimeException; public class CoinPolicyNotFoundException extends CustomRuntimeException { public CoinPolicyNotFoundException() { diff --git a/src/main/java/com/gg/server/global/exception/custom/AuthenticationException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/AuthenticationException.java similarity index 68% rename from src/main/java/com/gg/server/global/exception/custom/AuthenticationException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/AuthenticationException.java index 647cc71d8..2979703b5 100644 --- a/src/main/java/com/gg/server/global/exception/custom/AuthenticationException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/AuthenticationException.java @@ -1,6 +1,6 @@ -package com.gg.server.global.exception.custom; +package gg.pingpong.utils.exception.custom; -import com.gg.server.global.exception.ErrorCode; +import gg.pingpong.utils.exception.ErrorCode; public class AuthenticationException extends CustomRuntimeException { private ErrorCode errorCode; diff --git a/src/main/java/com/gg/server/global/exception/custom/BusinessException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/BusinessException.java similarity index 73% rename from src/main/java/com/gg/server/global/exception/custom/BusinessException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/BusinessException.java index 0a1387d5c..430120b68 100644 --- a/src/main/java/com/gg/server/global/exception/custom/BusinessException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/BusinessException.java @@ -1,6 +1,6 @@ -package com.gg.server.global.exception.custom; +package gg.pingpong.utils.exception.custom; -import com.gg.server.global.exception.ErrorCode; +import gg.pingpong.utils.exception.ErrorCode; public class BusinessException extends CustomRuntimeException { public BusinessException(String message, ErrorCode errorCode) { diff --git a/src/main/java/com/gg/server/global/exception/custom/CustomRuntimeException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/CustomRuntimeException.java similarity index 80% rename from src/main/java/com/gg/server/global/exception/custom/CustomRuntimeException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/CustomRuntimeException.java index 17b0f4b87..f83f4045b 100644 --- a/src/main/java/com/gg/server/global/exception/custom/CustomRuntimeException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/CustomRuntimeException.java @@ -1,7 +1,6 @@ -package com.gg.server.global.exception.custom; - -import com.gg.server.global.exception.ErrorCode; +package gg.pingpong.utils.exception.custom; +import gg.pingpong.utils.exception.ErrorCode; import lombok.Getter; @Getter diff --git a/src/main/java/com/gg/server/global/exception/custom/DBConsistencyException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/DBConsistencyException.java similarity index 67% rename from src/main/java/com/gg/server/global/exception/custom/DBConsistencyException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/DBConsistencyException.java index 96dfeaf01..0da170e7a 100644 --- a/src/main/java/com/gg/server/global/exception/custom/DBConsistencyException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/DBConsistencyException.java @@ -1,7 +1,6 @@ -package com.gg.server.global.exception.custom; - -import com.gg.server.global.exception.ErrorCode; +package gg.pingpong.utils.exception.custom; +import gg.pingpong.utils.exception.ErrorCode; import lombok.Getter; @Getter diff --git a/src/main/java/com/gg/server/global/exception/custom/DuplicationException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/DuplicationException.java similarity index 64% rename from src/main/java/com/gg/server/global/exception/custom/DuplicationException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/DuplicationException.java index 7e3495c0c..08f54d542 100644 --- a/src/main/java/com/gg/server/global/exception/custom/DuplicationException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/DuplicationException.java @@ -1,6 +1,6 @@ -package com.gg.server.global.exception.custom; +package gg.pingpong.utils.exception.custom; -import com.gg.server.global.exception.ErrorCode; +import gg.pingpong.utils.exception.ErrorCode; public class DuplicationException extends CustomRuntimeException { public DuplicationException(String message, ErrorCode errorCode) { diff --git a/src/main/java/com/gg/server/global/exception/custom/ExpiredException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ExpiredException.java similarity index 62% rename from src/main/java/com/gg/server/global/exception/custom/ExpiredException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ExpiredException.java index dbc5b137e..7fabeca5a 100644 --- a/src/main/java/com/gg/server/global/exception/custom/ExpiredException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ExpiredException.java @@ -1,6 +1,6 @@ -package com.gg.server.global.exception.custom; +package gg.pingpong.utils.exception.custom; -import com.gg.server.global.exception.ErrorCode; +import gg.pingpong.utils.exception.ErrorCode; public class ExpiredException extends CustomRuntimeException { public ExpiredException(String message, ErrorCode errorCode) { diff --git a/src/main/java/com/gg/server/global/exception/custom/FileException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/FileException.java similarity index 62% rename from src/main/java/com/gg/server/global/exception/custom/FileException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/FileException.java index f6c86f2be..889a06664 100644 --- a/src/main/java/com/gg/server/global/exception/custom/FileException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/FileException.java @@ -1,6 +1,6 @@ -package com.gg.server.global.exception.custom; +package gg.pingpong.utils.exception.custom; -import com.gg.server.global.exception.ErrorCode; +import gg.pingpong.utils.exception.ErrorCode; public class FileException extends CustomRuntimeException { diff --git a/src/main/java/com/gg/server/global/exception/custom/ForbiddenException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ForbiddenException.java similarity index 63% rename from src/main/java/com/gg/server/global/exception/custom/ForbiddenException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ForbiddenException.java index 326c34991..64dfc868b 100644 --- a/src/main/java/com/gg/server/global/exception/custom/ForbiddenException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ForbiddenException.java @@ -1,6 +1,6 @@ -package com.gg.server.global.exception.custom; +package gg.pingpong.utils.exception.custom; -import com.gg.server.global.exception.ErrorCode; +import gg.pingpong.utils.exception.ErrorCode; public class ForbiddenException extends CustomRuntimeException { public ForbiddenException(String message, ErrorCode errorCode) { diff --git a/src/main/java/com/gg/server/global/exception/custom/InvalidParameterException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/InvalidParameterException.java similarity index 65% rename from src/main/java/com/gg/server/global/exception/custom/InvalidParameterException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/InvalidParameterException.java index afd0ccfe0..77456ecc8 100644 --- a/src/main/java/com/gg/server/global/exception/custom/InvalidParameterException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/InvalidParameterException.java @@ -1,6 +1,6 @@ -package com.gg.server.global.exception.custom; +package gg.pingpong.utils.exception.custom; -import com.gg.server.global.exception.ErrorCode; +import gg.pingpong.utils.exception.ErrorCode; public class InvalidParameterException extends CustomRuntimeException { public InvalidParameterException(String message, ErrorCode errorCode) { diff --git a/src/main/java/com/gg/server/global/exception/custom/NotExistException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/NotExistException.java similarity index 67% rename from src/main/java/com/gg/server/global/exception/custom/NotExistException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/NotExistException.java index 845b1ae72..0ffacbfdd 100644 --- a/src/main/java/com/gg/server/global/exception/custom/NotExistException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/NotExistException.java @@ -1,6 +1,6 @@ -package com.gg.server.global.exception.custom; +package gg.pingpong.utils.exception.custom; -import com.gg.server.global.exception.ErrorCode; +import gg.pingpong.utils.exception.ErrorCode; public class NotExistException extends CustomRuntimeException { private ErrorCode errorCode; diff --git a/src/main/java/com/gg/server/global/exception/custom/PageNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/PageNotFoundException.java similarity index 74% rename from src/main/java/com/gg/server/global/exception/custom/PageNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/PageNotFoundException.java index 0682d7c60..3deef6dca 100644 --- a/src/main/java/com/gg/server/global/exception/custom/PageNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/PageNotFoundException.java @@ -1,6 +1,6 @@ -package com.gg.server.global.exception.custom; +package gg.pingpong.utils.exception.custom; -import com.gg.server.global.exception.ErrorCode; +import gg.pingpong.utils.exception.ErrorCode; public class PageNotFoundException extends CustomRuntimeException { public PageNotFoundException(String message, ErrorCode errorCode) { diff --git a/src/main/java/com/gg/server/global/exception/custom/ParseException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ParseException.java similarity index 62% rename from src/main/java/com/gg/server/global/exception/custom/ParseException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ParseException.java index 6edfba853..89c556db1 100644 --- a/src/main/java/com/gg/server/global/exception/custom/ParseException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ParseException.java @@ -1,6 +1,6 @@ -package com.gg.server.global.exception.custom; +package gg.pingpong.utils.exception.custom; -import com.gg.server.global.exception.ErrorCode; +import gg.pingpong.utils.exception.ErrorCode; public class ParseException extends CustomRuntimeException { public ParseException(String message, ErrorCode errorCode) { diff --git a/src/main/java/com/gg/server/global/exception/custom/SendException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/SendException.java similarity index 62% rename from src/main/java/com/gg/server/global/exception/custom/SendException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/SendException.java index 27ab5faf3..52d1fee40 100644 --- a/src/main/java/com/gg/server/global/exception/custom/SendException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/SendException.java @@ -1,6 +1,6 @@ -package com.gg.server.global.exception.custom; +package gg.pingpong.utils.exception.custom; -import com.gg.server.global.exception.ErrorCode; +import gg.pingpong.utils.exception.ErrorCode; public class SendException extends CustomRuntimeException { public SendException(String message, ErrorCode errorCode) { diff --git a/src/main/java/com/gg/server/domain/feedback/exception/FeedbackNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/feedback/FeedbackNotFoundException.java similarity index 54% rename from src/main/java/com/gg/server/domain/feedback/exception/FeedbackNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/feedback/FeedbackNotFoundException.java index 8aef19e0f..df7738dce 100644 --- a/src/main/java/com/gg/server/domain/feedback/exception/FeedbackNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/feedback/FeedbackNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.feedback.exception; +package gg.pingpong.utils.exception.feedback; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.CustomRuntimeException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.CustomRuntimeException; public class FeedbackNotFoundException extends CustomRuntimeException { public FeedbackNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/game/exception/GameAlreadyExistException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameAlreadyExistException.java similarity index 56% rename from src/main/java/com/gg/server/domain/game/exception/GameAlreadyExistException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameAlreadyExistException.java index 029767308..0ccfafe23 100644 --- a/src/main/java/com/gg/server/domain/game/exception/GameAlreadyExistException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameAlreadyExistException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.game.exception; +package gg.pingpong.utils.exception.game; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.DuplicationException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.DuplicationException; public class GameAlreadyExistException extends DuplicationException { public GameAlreadyExistException() { diff --git a/src/main/java/com/gg/server/domain/game/exception/GameDataConsistencyException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameDataConsistencyException.java similarity index 55% rename from src/main/java/com/gg/server/domain/game/exception/GameDataConsistencyException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameDataConsistencyException.java index ee9db4070..2089f17f3 100644 --- a/src/main/java/com/gg/server/domain/game/exception/GameDataConsistencyException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameDataConsistencyException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.game.exception; +package gg.pingpong.utils.exception.game; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.DBConsistencyException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.DBConsistencyException; public class GameDataConsistencyException extends DBConsistencyException { public GameDataConsistencyException() { diff --git a/src/main/java/com/gg/server/domain/game/exception/GameNotExistException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameNotExistException.java similarity index 52% rename from src/main/java/com/gg/server/domain/game/exception/GameNotExistException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameNotExistException.java index 94e51f9a7..05bdfcda6 100644 --- a/src/main/java/com/gg/server/domain/game/exception/GameNotExistException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameNotExistException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.game.exception; +package gg.pingpong.utils.exception.game; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class GameNotExistException extends NotExistException { public GameNotExistException() { diff --git a/src/main/java/com/gg/server/domain/game/exception/GameStatusNotMatchedException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameStatusNotMatchedException.java similarity index 55% rename from src/main/java/com/gg/server/domain/game/exception/GameStatusNotMatchedException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameStatusNotMatchedException.java index ce667e58d..9b910fe58 100644 --- a/src/main/java/com/gg/server/domain/game/exception/GameStatusNotMatchedException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameStatusNotMatchedException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.game.exception; +package gg.pingpong.utils.exception.game; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; public class GameStatusNotMatchedException extends BusinessException { public GameStatusNotMatchedException() { diff --git a/src/main/java/com/gg/server/admin/game/exception/NotRecentlyGameException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/NotRecentlyGameException.java similarity index 54% rename from src/main/java/com/gg/server/admin/game/exception/NotRecentlyGameException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/NotRecentlyGameException.java index f9028b6fd..e81f9082f 100644 --- a/src/main/java/com/gg/server/admin/game/exception/NotRecentlyGameException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/NotRecentlyGameException.java @@ -1,7 +1,7 @@ -package com.gg.server.admin.game.exception; +package gg.pingpong.utils.exception.game; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.InvalidParameterException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.InvalidParameterException; public class NotRecentlyGameException extends InvalidParameterException { public NotRecentlyGameException() { diff --git a/src/main/java/com/gg/server/domain/game/exception/ScoreAlreadyEnteredException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreAlreadyEnteredException.java similarity index 53% rename from src/main/java/com/gg/server/domain/game/exception/ScoreAlreadyEnteredException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreAlreadyEnteredException.java index 621845147..41904af25 100644 --- a/src/main/java/com/gg/server/domain/game/exception/ScoreAlreadyEnteredException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreAlreadyEnteredException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.game.exception; +package gg.pingpong.utils.exception.game; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.DuplicationException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.DuplicationException; public class ScoreAlreadyEnteredException extends DuplicationException { public ScoreAlreadyEnteredException(String message, ErrorCode errorCode) { diff --git a/src/main/java/com/gg/server/domain/game/exception/ScoreNotInvalidException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreNotInvalidException.java similarity index 54% rename from src/main/java/com/gg/server/domain/game/exception/ScoreNotInvalidException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreNotInvalidException.java index 232bbf0bd..9e61ac2cc 100644 --- a/src/main/java/com/gg/server/domain/game/exception/ScoreNotInvalidException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreNotInvalidException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.game.exception; +package gg.pingpong.utils.exception.game; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.InvalidParameterException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.InvalidParameterException; public class ScoreNotInvalidException extends InvalidParameterException { public ScoreNotInvalidException() { diff --git a/src/main/java/com/gg/server/domain/game/exception/ScoreNotMatchedException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreNotMatchedException.java similarity index 54% rename from src/main/java/com/gg/server/domain/game/exception/ScoreNotMatchedException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreNotMatchedException.java index be4a42d8e..edc77e6de 100644 --- a/src/main/java/com/gg/server/domain/game/exception/ScoreNotMatchedException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreNotMatchedException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.game.exception; +package gg.pingpong.utils.exception.game; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.DuplicationException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.DuplicationException; public class ScoreNotMatchedException extends DuplicationException { public ScoreNotMatchedException() { diff --git a/src/main/java/com/gg/server/domain/item/exception/InsufficientGgcoinException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/InsufficientGgcoinException.java similarity index 54% rename from src/main/java/com/gg/server/domain/item/exception/InsufficientGgcoinException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/InsufficientGgcoinException.java index 3cb20a373..99787c438 100644 --- a/src/main/java/com/gg/server/domain/item/exception/InsufficientGgcoinException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/InsufficientGgcoinException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.item.exception; +package gg.pingpong.utils.exception.item; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; public class InsufficientGgcoinException extends BusinessException { public InsufficientGgcoinException() { diff --git a/src/main/java/com/gg/server/domain/item/exception/ItemImageLargeException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemImageLargeException.java similarity index 53% rename from src/main/java/com/gg/server/domain/item/exception/ItemImageLargeException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemImageLargeException.java index f2e488e69..8432182d5 100644 --- a/src/main/java/com/gg/server/domain/item/exception/ItemImageLargeException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemImageLargeException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.item.exception; +package gg.pingpong.utils.exception.item; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.FileException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.FileException; public class ItemImageLargeException extends FileException { public ItemImageLargeException() { diff --git a/src/main/java/com/gg/server/domain/item/exception/ItemImageTypeException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemImageTypeException.java similarity index 55% rename from src/main/java/com/gg/server/domain/item/exception/ItemImageTypeException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemImageTypeException.java index dc2e5f3d0..43baf0acf 100644 --- a/src/main/java/com/gg/server/domain/item/exception/ItemImageTypeException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemImageTypeException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.item.exception; +package gg.pingpong.utils.exception.item; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.FileException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.FileException; public class ItemImageTypeException extends FileException { public ItemImageTypeException() { diff --git a/src/main/java/com/gg/server/domain/item/exception/ItemNotAvailableException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotAvailableException.java similarity index 54% rename from src/main/java/com/gg/server/domain/item/exception/ItemNotAvailableException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotAvailableException.java index 2f276a6f8..e0ca95ebb 100644 --- a/src/main/java/com/gg/server/domain/item/exception/ItemNotAvailableException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotAvailableException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.item.exception; +package gg.pingpong.utils.exception.item; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.FileException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.FileException; public class ItemNotAvailableException extends FileException { public ItemNotAvailableException() { diff --git a/src/main/java/com/gg/server/admin/item/exception/ItemNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotFoundException.java similarity index 51% rename from src/main/java/com/gg/server/admin/item/exception/ItemNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotFoundException.java index a18f68019..e46a34c2f 100644 --- a/src/main/java/com/gg/server/admin/item/exception/ItemNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.admin.item.exception; +package gg.pingpong.utils.exception.item; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class ItemNotFoundException extends NotExistException { public ItemNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/item/exception/ItemNotPurchasableException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotPurchasableException.java similarity index 57% rename from src/main/java/com/gg/server/domain/item/exception/ItemNotPurchasableException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotPurchasableException.java index 6b181ab5d..2375db6dc 100644 --- a/src/main/java/com/gg/server/domain/item/exception/ItemNotPurchasableException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotPurchasableException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.item.exception; +package gg.pingpong.utils.exception.item; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; public class ItemNotPurchasableException extends BusinessException { public ItemNotPurchasableException() { diff --git a/src/main/java/com/gg/server/domain/item/exception/ItemTypeException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemTypeException.java similarity index 52% rename from src/main/java/com/gg/server/domain/item/exception/ItemTypeException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemTypeException.java index 5e9320142..970beea37 100644 --- a/src/main/java/com/gg/server/domain/item/exception/ItemTypeException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemTypeException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.item.exception; +package gg.pingpong.utils.exception.item; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; public class ItemTypeException extends BusinessException { public ItemTypeException() { diff --git a/src/main/java/com/gg/server/domain/item/exception/KakaoGiftException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/KakaoGiftException.java similarity index 55% rename from src/main/java/com/gg/server/domain/item/exception/KakaoGiftException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/KakaoGiftException.java index 6aa0cf2f3..47e334a73 100644 --- a/src/main/java/com/gg/server/domain/item/exception/KakaoGiftException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/KakaoGiftException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.item.exception; +package gg.pingpong.utils.exception.item; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; public class KakaoGiftException extends BusinessException { public KakaoGiftException() { diff --git a/src/main/java/com/gg/server/domain/item/exception/KakaoPurchaseException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/KakaoPurchaseException.java similarity index 57% rename from src/main/java/com/gg/server/domain/item/exception/KakaoPurchaseException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/KakaoPurchaseException.java index 53541f2a1..214da95f1 100644 --- a/src/main/java/com/gg/server/domain/item/exception/KakaoPurchaseException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/KakaoPurchaseException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.item.exception; +package gg.pingpong.utils.exception.item; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; public class KakaoPurchaseException extends BusinessException { public KakaoPurchaseException() { diff --git a/src/main/java/com/gg/server/domain/match/exception/EnrolledSlotException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/EnrolledSlotException.java similarity index 52% rename from src/main/java/com/gg/server/domain/match/exception/EnrolledSlotException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/EnrolledSlotException.java index 0374ffa1f..4f0050ae5 100644 --- a/src/main/java/com/gg/server/domain/match/exception/EnrolledSlotException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/EnrolledSlotException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.match.exception; +package gg.pingpong.utils.exception.match; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.DuplicationException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.DuplicationException; public class EnrolledSlotException extends DuplicationException { public EnrolledSlotException() { diff --git a/src/main/java/com/gg/server/domain/match/exception/LosingTeamNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/LosingTeamNotFoundException.java similarity index 56% rename from src/main/java/com/gg/server/domain/match/exception/LosingTeamNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/LosingTeamNotFoundException.java index f42fc21e3..10aa0dfeb 100644 --- a/src/main/java/com/gg/server/domain/match/exception/LosingTeamNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/LosingTeamNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.match.exception; +package gg.pingpong.utils.exception.match; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class LosingTeamNotFoundException extends NotExistException { public LosingTeamNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/match/exception/OptionInvalidException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/OptionInvalidException.java similarity index 52% rename from src/main/java/com/gg/server/domain/match/exception/OptionInvalidException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/OptionInvalidException.java index 7405cf513..dfa3aa53e 100644 --- a/src/main/java/com/gg/server/domain/match/exception/OptionInvalidException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/OptionInvalidException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.match.exception; +package gg.pingpong.utils.exception.match; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.InvalidParameterException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.InvalidParameterException; public class OptionInvalidException extends InvalidParameterException { public OptionInvalidException() { diff --git a/src/main/java/com/gg/server/domain/match/exception/PastSlotException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/PastSlotException.java similarity index 54% rename from src/main/java/com/gg/server/domain/match/exception/PastSlotException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/PastSlotException.java index b495d92f6..73d827482 100644 --- a/src/main/java/com/gg/server/domain/match/exception/PastSlotException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/PastSlotException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.match.exception; +package gg.pingpong.utils.exception.match; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.ExpiredException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.ExpiredException; public class PastSlotException extends ExpiredException { public PastSlotException() { diff --git a/src/main/java/com/gg/server/domain/match/exception/PenaltyUserSlotException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/PenaltyUserSlotException.java similarity index 58% rename from src/main/java/com/gg/server/domain/match/exception/PenaltyUserSlotException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/PenaltyUserSlotException.java index 65467eadf..1d0ee9de5 100644 --- a/src/main/java/com/gg/server/domain/match/exception/PenaltyUserSlotException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/PenaltyUserSlotException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.match.exception; +package gg.pingpong.utils.exception.match; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; public class PenaltyUserSlotException extends BusinessException { public PenaltyUserSlotException() { diff --git a/src/main/java/com/gg/server/domain/match/exception/SlotCountException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/SlotCountException.java similarity index 54% rename from src/main/java/com/gg/server/domain/match/exception/SlotCountException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/SlotCountException.java index b8c7758b8..12ed515f9 100644 --- a/src/main/java/com/gg/server/domain/match/exception/SlotCountException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/SlotCountException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.match.exception; +package gg.pingpong.utils.exception.match; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; public class SlotCountException extends BusinessException { public SlotCountException() { diff --git a/src/main/java/com/gg/server/domain/match/exception/SlotNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/SlotNotFoundException.java similarity index 53% rename from src/main/java/com/gg/server/domain/match/exception/SlotNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/SlotNotFoundException.java index e881e3929..fa705a2b6 100644 --- a/src/main/java/com/gg/server/domain/match/exception/SlotNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/SlotNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.match.exception; +package gg.pingpong.utils.exception.match; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class SlotNotFoundException extends NotExistException { public SlotNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/match/exception/WinningTeamNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/WinningTeamNotFoundException.java similarity index 56% rename from src/main/java/com/gg/server/domain/match/exception/WinningTeamNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/WinningTeamNotFoundException.java index e5d2da068..e35987aa5 100644 --- a/src/main/java/com/gg/server/domain/match/exception/WinningTeamNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/WinningTeamNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.match.exception; +package gg.pingpong.utils.exception.match; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class WinningTeamNotFoundException extends NotExistException { public WinningTeamNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneContentException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneContentException.java similarity index 53% rename from src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneContentException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneContentException.java index 307573a2b..da432bc36 100644 --- a/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneContentException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneContentException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.megaphone.exception; +package gg.pingpong.utils.exception.megaphone; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; public class MegaphoneContentException extends BusinessException { public MegaphoneContentException() { diff --git a/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneNotFoundException.java similarity index 53% rename from src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneNotFoundException.java index 1ac2c29a2..0e9f20c37 100644 --- a/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.megaphone.exception; +package gg.pingpong.utils.exception.megaphone; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class MegaphoneNotFoundException extends NotExistException { public MegaphoneNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneTimeException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneTimeException.java similarity index 54% rename from src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneTimeException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneTimeException.java index e4bd72074..f11699a56 100644 --- a/src/main/java/com/gg/server/domain/megaphone/exception/MegaphoneTimeException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneTimeException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.megaphone.exception; +package gg.pingpong.utils.exception.megaphone; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; public class MegaphoneTimeException extends BusinessException { public MegaphoneTimeException() { diff --git a/src/main/java/com/gg/server/domain/noti/exception/SlackJsonParseException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackJsonParseException.java similarity index 54% rename from src/main/java/com/gg/server/domain/noti/exception/SlackJsonParseException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackJsonParseException.java index 108cdfc32..c7cdc857e 100644 --- a/src/main/java/com/gg/server/domain/noti/exception/SlackJsonParseException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackJsonParseException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.noti.exception; +package gg.pingpong.utils.exception.noti; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.ParseException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.ParseException; public class SlackJsonParseException extends ParseException { public SlackJsonParseException() { diff --git a/src/main/java/com/gg/server/domain/noti/exception/SlackSendException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackSendException.java similarity index 50% rename from src/main/java/com/gg/server/domain/noti/exception/SlackSendException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackSendException.java index b4e83e773..3ac4af3ce 100644 --- a/src/main/java/com/gg/server/domain/noti/exception/SlackSendException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackSendException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.noti.exception; +package gg.pingpong.utils.exception.noti; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.SendException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.SendException; public class SlackSendException extends SendException { public SlackSendException() { diff --git a/src/main/java/com/gg/server/domain/noti/exception/SlackUserGetFailedException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackUserGetFailedException.java similarity index 54% rename from src/main/java/com/gg/server/domain/noti/exception/SlackUserGetFailedException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackUserGetFailedException.java index a06e99b4a..dd74005e3 100644 --- a/src/main/java/com/gg/server/domain/noti/exception/SlackUserGetFailedException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackUserGetFailedException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.noti.exception; +package gg.pingpong.utils.exception.noti; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class SlackUserGetFailedException extends NotExistException { public SlackUserGetFailedException() { diff --git a/src/main/java/com/gg/server/admin/pchange/exception/PChangeNotExistException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/pchange/PChangeNotExistException.java similarity index 54% rename from src/main/java/com/gg/server/admin/pchange/exception/PChangeNotExistException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/pchange/PChangeNotExistException.java index 20999c559..8a2ce6b7d 100644 --- a/src/main/java/com/gg/server/admin/pchange/exception/PChangeNotExistException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/pchange/PChangeNotExistException.java @@ -1,7 +1,7 @@ -package com.gg.server.admin.pchange.exception; +package gg.pingpong.utils.exception.pchange; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class PChangeNotExistException extends NotExistException { public PChangeNotExistException() { diff --git a/src/main/java/com/gg/server/domain/penalty/exception/PenaltyExpiredException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/PenaltyExpiredException.java similarity index 53% rename from src/main/java/com/gg/server/domain/penalty/exception/PenaltyExpiredException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/PenaltyExpiredException.java index 5a909074d..684ebe71d 100644 --- a/src/main/java/com/gg/server/domain/penalty/exception/PenaltyExpiredException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/PenaltyExpiredException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.penalty.exception; +package gg.pingpong.utils.exception.penalty; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.ExpiredException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.ExpiredException; public class PenaltyExpiredException extends ExpiredException { public PenaltyExpiredException() { diff --git a/src/main/java/com/gg/server/domain/penalty/exception/PenaltyNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/PenaltyNotFoundException.java similarity index 53% rename from src/main/java/com/gg/server/domain/penalty/exception/PenaltyNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/PenaltyNotFoundException.java index 5e69d28cb..8948ed11d 100644 --- a/src/main/java/com/gg/server/domain/penalty/exception/PenaltyNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/PenaltyNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.penalty.exception; +package gg.pingpong.utils.exception.penalty; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class PenaltyNotFoundException extends NotExistException { public PenaltyNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/penalty/exception/RedisPenaltyUserNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/RedisPenaltyUserNotFoundException.java similarity index 58% rename from src/main/java/com/gg/server/domain/penalty/exception/RedisPenaltyUserNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/RedisPenaltyUserNotFoundException.java index cbc585251..f0a0fc167 100644 --- a/src/main/java/com/gg/server/domain/penalty/exception/RedisPenaltyUserNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/RedisPenaltyUserNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.penalty.exception; +package gg.pingpong.utils.exception.penalty; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class RedisPenaltyUserNotFoundException extends NotExistException { public RedisPenaltyUserNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/rank/exception/RankNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RankNotFoundException.java similarity index 54% rename from src/main/java/com/gg/server/domain/rank/exception/RankNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RankNotFoundException.java index cae345c39..22379fa05 100644 --- a/src/main/java/com/gg/server/domain/rank/exception/RankNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RankNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.rank.exception; +package gg.pingpong.utils.exception.rank; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class RankNotFoundException extends NotExistException { public RankNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/rank/exception/RankUpdateException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RankUpdateException.java similarity index 52% rename from src/main/java/com/gg/server/domain/rank/exception/RankUpdateException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RankUpdateException.java index 92206f740..98aa426e5 100644 --- a/src/main/java/com/gg/server/domain/rank/exception/RankUpdateException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RankUpdateException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.rank.exception; +package gg.pingpong.utils.exception.rank; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.InvalidParameterException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.InvalidParameterException; public class RankUpdateException extends InvalidParameterException { public RankUpdateException() { diff --git a/src/main/java/com/gg/server/domain/rank/exception/RedisDataNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RedisDataNotFoundException.java similarity index 55% rename from src/main/java/com/gg/server/domain/rank/exception/RedisDataNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RedisDataNotFoundException.java index a885d15ab..e8fbbcb24 100644 --- a/src/main/java/com/gg/server/domain/rank/exception/RedisDataNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RedisDataNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.rank.exception; +package gg.pingpong.utils.exception.rank; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class RedisDataNotFoundException extends NotExistException { public RedisDataNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/receipt/exception/ItemStatusException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ItemStatusException.java similarity index 53% rename from src/main/java/com/gg/server/domain/receipt/exception/ItemStatusException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ItemStatusException.java index 1dbace282..3a74447be 100644 --- a/src/main/java/com/gg/server/domain/receipt/exception/ItemStatusException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ItemStatusException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.receipt.exception; +package gg.pingpong.utils.exception.receipt; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.BusinessException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.BusinessException; public class ItemStatusException extends BusinessException { public ItemStatusException() { diff --git a/src/main/java/com/gg/server/domain/receipt/exception/ReceiptNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ReceiptNotFoundException.java similarity index 53% rename from src/main/java/com/gg/server/domain/receipt/exception/ReceiptNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ReceiptNotFoundException.java index 8e90fca5b..8c81014fa 100644 --- a/src/main/java/com/gg/server/domain/receipt/exception/ReceiptNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ReceiptNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.receipt.exception; +package gg.pingpong.utils.exception.receipt; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class ReceiptNotFoundException extends NotExistException { public ReceiptNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/receipt/exception/ReceiptNotOwnerException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ReceiptNotOwnerException.java similarity index 54% rename from src/main/java/com/gg/server/domain/receipt/exception/ReceiptNotOwnerException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ReceiptNotOwnerException.java index b758dbd01..59887658c 100644 --- a/src/main/java/com/gg/server/domain/receipt/exception/ReceiptNotOwnerException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ReceiptNotOwnerException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.receipt.exception; +package gg.pingpong.utils.exception.receipt; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.ForbiddenException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.ForbiddenException; public class ReceiptNotOwnerException extends ForbiddenException { public ReceiptNotOwnerException() { diff --git a/src/main/java/com/gg/server/domain/season/exception/SeasonForbiddenException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonForbiddenException.java similarity index 54% rename from src/main/java/com/gg/server/domain/season/exception/SeasonForbiddenException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonForbiddenException.java index 3152b6584..40c723806 100644 --- a/src/main/java/com/gg/server/domain/season/exception/SeasonForbiddenException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonForbiddenException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.season.exception; +package gg.pingpong.utils.exception.season; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.ForbiddenException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.ForbiddenException; public class SeasonForbiddenException extends ForbiddenException { public SeasonForbiddenException() { diff --git a/src/main/java/com/gg/server/domain/season/exception/SeasonNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonNotFoundException.java similarity index 62% rename from src/main/java/com/gg/server/domain/season/exception/SeasonNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonNotFoundException.java index 7275c06b5..5daab8a08 100644 --- a/src/main/java/com/gg/server/domain/season/exception/SeasonNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.season.exception; +package gg.pingpong.utils.exception.season; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class SeasonNotFoundException extends NotExistException { public SeasonNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/season/exception/SeasonTimeBeforeException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonTimeBeforeException.java similarity index 54% rename from src/main/java/com/gg/server/domain/season/exception/SeasonTimeBeforeException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonTimeBeforeException.java index 60e08cb4f..847525364 100644 --- a/src/main/java/com/gg/server/domain/season/exception/SeasonTimeBeforeException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonTimeBeforeException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.season.exception; +package gg.pingpong.utils.exception.season; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.ForbiddenException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.ForbiddenException; public class SeasonTimeBeforeException extends ForbiddenException { public SeasonTimeBeforeException() { diff --git a/src/main/java/com/gg/server/domain/slotmanagement/exception/SlotManagementForbiddenException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/slotmanagement/SlotManagementForbiddenException.java similarity index 56% rename from src/main/java/com/gg/server/domain/slotmanagement/exception/SlotManagementForbiddenException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/slotmanagement/SlotManagementForbiddenException.java index 9ecf487f6..e465f9857 100644 --- a/src/main/java/com/gg/server/domain/slotmanagement/exception/SlotManagementForbiddenException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/slotmanagement/SlotManagementForbiddenException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.slotmanagement.exception; +package gg.pingpong.utils.exception.slotmanagement; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.ForbiddenException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.ForbiddenException; public class SlotManagementForbiddenException extends ForbiddenException { public SlotManagementForbiddenException() { diff --git a/src/main/java/com/gg/server/domain/slotmanagement/exception/SlotManagementNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/slotmanagement/SlotManagementNotFoundException.java similarity index 56% rename from src/main/java/com/gg/server/domain/slotmanagement/exception/SlotManagementNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/slotmanagement/SlotManagementNotFoundException.java index 8b89318be..fc65300bb 100644 --- a/src/main/java/com/gg/server/domain/slotmanagement/exception/SlotManagementNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/slotmanagement/SlotManagementNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.slotmanagement.exception; +package gg.pingpong.utils.exception.slotmanagement; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class SlotManagementNotFoundException extends NotExistException { public SlotManagementNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/team/exception/TeamIdNotMatchException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/team/TeamIdNotMatchException.java similarity index 54% rename from src/main/java/com/gg/server/domain/team/exception/TeamIdNotMatchException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/team/TeamIdNotMatchException.java index 6b11160e7..a68007457 100644 --- a/src/main/java/com/gg/server/domain/team/exception/TeamIdNotMatchException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/team/TeamIdNotMatchException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.team.exception; +package gg.pingpong.utils.exception.team; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class TeamIdNotMatchException extends NotExistException { public TeamIdNotMatchException() { diff --git a/src/main/java/com/gg/server/domain/team/exception/TeamNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/team/TeamNotFoundException.java similarity index 53% rename from src/main/java/com/gg/server/domain/team/exception/TeamNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/team/TeamNotFoundException.java index 588095905..9cc24bc87 100644 --- a/src/main/java/com/gg/server/domain/team/exception/TeamNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/team/TeamNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.team.exception; +package gg.pingpong.utils.exception.team; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class TeamNotFoundException extends NotExistException { diff --git a/src/main/java/com/gg/server/domain/tier/exception/TierNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tier/TierNotFoundException.java similarity index 54% rename from src/main/java/com/gg/server/domain/tier/exception/TierNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tier/TierNotFoundException.java index 39a094aca..7681147ef 100644 --- a/src/main/java/com/gg/server/domain/tier/exception/TierNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tier/TierNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.tier.exception; +package gg.pingpong.utils.exception.tier; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class TierNotFoundException extends NotExistException { public TierNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/tournament/exception/TournamentConflictException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentConflictException.java similarity index 64% rename from src/main/java/com/gg/server/domain/tournament/exception/TournamentConflictException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentConflictException.java index e9bbd20c5..e7396a89c 100644 --- a/src/main/java/com/gg/server/domain/tournament/exception/TournamentConflictException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentConflictException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.tournament.exception; +package gg.pingpong.utils.exception.tournament; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.DuplicationException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.DuplicationException; public class TournamentConflictException extends DuplicationException { public TournamentConflictException() { diff --git a/src/main/java/com/gg/server/domain/tournament/exception/TournamentGameNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentGameNotFoundException.java similarity index 57% rename from src/main/java/com/gg/server/domain/tournament/exception/TournamentGameNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentGameNotFoundException.java index 6105469c2..1d55b8d4a 100644 --- a/src/main/java/com/gg/server/domain/tournament/exception/TournamentGameNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentGameNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.tournament.exception; +package gg.pingpong.utils.exception.tournament; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class TournamentGameNotFoundException extends NotExistException { public TournamentGameNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/tournament/exception/TournamentNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentNotFoundException.java similarity index 65% rename from src/main/java/com/gg/server/domain/tournament/exception/TournamentNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentNotFoundException.java index 6a5c1f8eb..3f5e305ce 100644 --- a/src/main/java/com/gg/server/domain/tournament/exception/TournamentNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.tournament.exception; +package gg.pingpong.utils.exception.tournament; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class TournamentNotFoundException extends NotExistException { public TournamentNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/tournament/exception/TournamentUpdateException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentUpdateException.java similarity index 65% rename from src/main/java/com/gg/server/domain/tournament/exception/TournamentUpdateException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentUpdateException.java index b0b30faee..d03cf9b84 100644 --- a/src/main/java/com/gg/server/domain/tournament/exception/TournamentUpdateException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentUpdateException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.tournament.exception; +package gg.pingpong.utils.exception.tournament; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.ForbiddenException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.ForbiddenException; public class TournamentUpdateException extends ForbiddenException { public TournamentUpdateException() { diff --git a/src/main/java/com/gg/server/domain/user/exception/KakaoOauth2AlreadyExistException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/KakaoOauth2AlreadyExistException.java similarity index 55% rename from src/main/java/com/gg/server/domain/user/exception/KakaoOauth2AlreadyExistException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/KakaoOauth2AlreadyExistException.java index 030bf0d1d..8b5daa0e8 100644 --- a/src/main/java/com/gg/server/domain/user/exception/KakaoOauth2AlreadyExistException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/KakaoOauth2AlreadyExistException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.user.exception; +package gg.pingpong.utils.exception.user; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.InvalidParameterException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.InvalidParameterException; public class KakaoOauth2AlreadyExistException extends InvalidParameterException { public KakaoOauth2AlreadyExistException() { diff --git a/src/main/java/com/gg/server/domain/user/exception/KakaoOauth2NotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/KakaoOauth2NotFoundException.java similarity index 54% rename from src/main/java/com/gg/server/domain/user/exception/KakaoOauth2NotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/KakaoOauth2NotFoundException.java index 7f838e05d..e6aec3653 100644 --- a/src/main/java/com/gg/server/domain/user/exception/KakaoOauth2NotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/KakaoOauth2NotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.user.exception; +package gg.pingpong.utils.exception.user; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class KakaoOauth2NotFoundException extends NotExistException { public KakaoOauth2NotFoundException() { diff --git a/src/main/java/com/gg/server/domain/user/exception/TokenNotValidException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/TokenNotValidException.java similarity index 50% rename from src/main/java/com/gg/server/domain/user/exception/TokenNotValidException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/TokenNotValidException.java index 680283d55..198ced017 100644 --- a/src/main/java/com/gg/server/domain/user/exception/TokenNotValidException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/TokenNotValidException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.user.exception; +package gg.pingpong.utils.exception.user; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.AuthenticationException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.AuthenticationException; public class TokenNotValidException extends AuthenticationException { public TokenNotValidException() { diff --git a/src/main/java/com/gg/server/domain/user/exception/UserAlreadyAttendanceException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserAlreadyAttendanceException.java similarity index 56% rename from src/main/java/com/gg/server/domain/user/exception/UserAlreadyAttendanceException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserAlreadyAttendanceException.java index 897187efd..8efbc4663 100644 --- a/src/main/java/com/gg/server/domain/user/exception/UserAlreadyAttendanceException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserAlreadyAttendanceException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.user.exception; +package gg.pingpong.utils.exception.user; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.DuplicationException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.DuplicationException; public class UserAlreadyAttendanceException extends DuplicationException { public UserAlreadyAttendanceException() { diff --git a/src/main/java/com/gg/server/domain/user/exception/UserImageLargeException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageLargeException.java similarity index 53% rename from src/main/java/com/gg/server/domain/user/exception/UserImageLargeException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageLargeException.java index 47549630b..49d935d9e 100644 --- a/src/main/java/com/gg/server/domain/user/exception/UserImageLargeException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageLargeException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.user.exception; +package gg.pingpong.utils.exception.user; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.FileException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.FileException; public class UserImageLargeException extends FileException { public UserImageLargeException() { diff --git a/src/main/java/com/gg/server/domain/user/exception/UserImageNullException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageNullException.java similarity index 53% rename from src/main/java/com/gg/server/domain/user/exception/UserImageNullException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageNullException.java index 3ee71b583..5c1fe681a 100644 --- a/src/main/java/com/gg/server/domain/user/exception/UserImageNullException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageNullException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.user.exception; +package gg.pingpong.utils.exception.user; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.FileException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.FileException; public class UserImageNullException extends FileException { public UserImageNullException() { diff --git a/src/main/java/com/gg/server/domain/user/exception/UserImageTypeException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageTypeException.java similarity index 55% rename from src/main/java/com/gg/server/domain/user/exception/UserImageTypeException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageTypeException.java index dc705942a..11950f70b 100644 --- a/src/main/java/com/gg/server/domain/user/exception/UserImageTypeException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageTypeException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.user.exception; +package gg.pingpong.utils.exception.user; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.FileException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.FileException; public class UserImageTypeException extends FileException { public UserImageTypeException() { diff --git a/src/main/java/com/gg/server/domain/user/exception/UserNotFoundException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserNotFoundException.java similarity index 52% rename from src/main/java/com/gg/server/domain/user/exception/UserNotFoundException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserNotFoundException.java index d66034161..12f980945 100644 --- a/src/main/java/com/gg/server/domain/user/exception/UserNotFoundException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserNotFoundException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.user.exception; +package gg.pingpong.utils.exception.user; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.NotExistException; public class UserNotFoundException extends NotExistException { public UserNotFoundException() { diff --git a/src/main/java/com/gg/server/domain/user/exception/UserTextColorException.java b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserTextColorException.java similarity index 54% rename from src/main/java/com/gg/server/domain/user/exception/UserTextColorException.java rename to gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserTextColorException.java index 49e846ed8..84a468bd1 100644 --- a/src/main/java/com/gg/server/domain/user/exception/UserTextColorException.java +++ b/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserTextColorException.java @@ -1,7 +1,7 @@ -package com.gg.server.domain.user.exception; +package gg.pingpong.utils.exception.user; -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.CustomRuntimeException; +import gg.pingpong.utils.exception.ErrorCode; +import gg.pingpong.utils.exception.custom.CustomRuntimeException; public class UserTextColorException extends CustomRuntimeException { public UserTextColorException() { diff --git a/src/test/java/com/gg/server/utils/ItemTestUtils.java b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/ItemTestUtils.java similarity index 67% rename from src/test/java/com/gg/server/utils/ItemTestUtils.java rename to gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/ItemTestUtils.java index 3990c63e8..bd8ca0eb1 100644 --- a/src/test/java/com/gg/server/utils/ItemTestUtils.java +++ b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/ItemTestUtils.java @@ -1,20 +1,19 @@ -package com.gg.server.utils; +package gg.pingpong.utils; import java.time.LocalDate; import java.time.LocalDateTime; import org.springframework.stereotype.Component; -import com.gg.server.admin.item.dto.ItemUpdateRequestDto; -import com.gg.server.data.store.Item; -import com.gg.server.data.store.Megaphone; -import com.gg.server.data.store.Receipt; -import com.gg.server.data.store.type.ItemStatus; -import com.gg.server.data.user.User; -import com.gg.server.domain.item.data.ItemRepository; -import com.gg.server.domain.megaphone.data.MegaphoneRepository; -import com.gg.server.domain.receipt.data.ReceiptRepository; - +import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; +import gg.pingpong.data.store.Item; +import gg.pingpong.data.store.Megaphone; +import gg.pingpong.data.store.Receipt; +import gg.pingpong.data.store.type.ItemStatus; +import gg.pingpong.data.user.User; +import gg.pingpong.repo.store.ItemRepository; +import gg.pingpong.repo.store.MegaphoneRepository; +import gg.pingpong.repo.store.ReceiptRepository; import lombok.AllArgsConstructor; /** @@ -50,11 +49,7 @@ public Receipt purchaseItem(User purchaser, User owner, Item item) { * 아이템을 생성한다. */ public Item createItem(User creator, ItemUpdateRequestDto updateRequestDto) { - Item item = Item.builder() - .creatorIntraId(creator.getIntraId()) - .itemImageUri("42gg-s3") - .updateRequestDto(updateRequestDto) - .build(); + Item item = updateRequestDto.toItem("42gg-s3", creator.getIntraId()); itemRepository.save(item); return item; } diff --git a/src/test/java/com/gg/server/utils/TestDataUtils.java b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/TestDataUtils.java similarity index 89% rename from src/test/java/com/gg/server/utils/TestDataUtils.java rename to gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/TestDataUtils.java index 66ad35023..96813f625 100644 --- a/src/test/java/com/gg/server/utils/TestDataUtils.java +++ b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/TestDataUtils.java @@ -1,4 +1,4 @@ -package com.gg.server.utils; +package gg.pingpong.utils; import java.time.LocalDateTime; import java.util.ArrayList; @@ -9,58 +9,56 @@ import org.springframework.stereotype.Component; -import com.gg.server.admin.tournament.dto.TournamentAdminCreateRequestDto; -import com.gg.server.admin.tournament.dto.TournamentAdminUpdateRequestDto; -import com.gg.server.data.game.Game; -import com.gg.server.data.game.PChange; -import com.gg.server.data.game.Rank; -import com.gg.server.data.game.Season; -import com.gg.server.data.game.Team; -import com.gg.server.data.game.TeamUser; -import com.gg.server.data.game.Tier; -import com.gg.server.data.game.Tournament; -import com.gg.server.data.game.TournamentGame; -import com.gg.server.data.game.TournamentUser; -import com.gg.server.data.game.redis.RankRedis; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.game.type.StatusType; -import com.gg.server.data.game.type.TournamentRound; -import com.gg.server.data.game.type.TournamentStatus; -import com.gg.server.data.game.type.TournamentType; -import com.gg.server.data.manage.Announcement; -import com.gg.server.data.manage.CoinPolicy; -import com.gg.server.data.noti.Noti; -import com.gg.server.data.noti.type.NotiType; -import com.gg.server.data.user.User; -import com.gg.server.data.user.UserImage; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.announcement.data.AnnouncementRepository; -import com.gg.server.domain.coin.data.CoinPolicyRepository; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.exception.GameNotExistException; -import com.gg.server.domain.noti.data.NotiRepository; -import com.gg.server.domain.pchange.data.PChangeRepository; -import com.gg.server.domain.rank.data.RankRepository; -import com.gg.server.domain.rank.redis.RankRedisRepository; -import com.gg.server.domain.rank.redis.RedisKeyManager; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.slotmanagement.SlotManagement; -import com.gg.server.domain.slotmanagement.data.SlotManagementRepository; -import com.gg.server.domain.team.data.TeamRepository; -import com.gg.server.domain.team.data.TeamUserRepository; -import com.gg.server.domain.tier.data.TierRepository; -import com.gg.server.domain.tournament.data.TournamentGameRepository; -import com.gg.server.domain.tournament.data.TournamentRepository; -import com.gg.server.domain.tournament.data.TournamentUserRepository; -import com.gg.server.domain.tournament.dto.TournamentResponseDto; -import com.gg.server.domain.user.controller.dto.GameInfoDto; -import com.gg.server.domain.user.data.UserImageRepository; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.dto.UserImageDto; -import com.gg.server.global.security.jwt.utils.AuthTokenProvider; - +import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminCreateRequestDto; +import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminUpdateRequestDto; +import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; +import gg.pingpong.api.user.tournament.controller.response.TournamentResponseDto; +import gg.pingpong.api.user.user.dto.UserImageDto; +import gg.pingpong.data.game.Game; +import gg.pingpong.data.game.PChange; +import gg.pingpong.data.game.Team; +import gg.pingpong.data.game.TeamUser; +import gg.pingpong.data.game.type.Mode; +import gg.pingpong.data.game.type.StatusType; +import gg.pingpong.data.manage.Announcement; +import gg.pingpong.data.manage.SlotManagement; +import gg.pingpong.data.noti.Noti; +import gg.pingpong.data.noti.type.NotiType; +import gg.pingpong.data.rank.Rank; +import gg.pingpong.data.rank.Tier; +import gg.pingpong.data.rank.redis.RankRedis; +import gg.pingpong.data.season.Season; +import gg.pingpong.data.store.CoinPolicy; +import gg.pingpong.data.tournament.Tournament; +import gg.pingpong.data.tournament.TournamentGame; +import gg.pingpong.data.tournament.TournamentUser; +import gg.pingpong.data.tournament.type.TournamentRound; +import gg.pingpong.data.tournament.type.TournamentStatus; +import gg.pingpong.data.tournament.type.TournamentType; +import gg.pingpong.data.user.User; +import gg.pingpong.data.user.UserImage; +import gg.pingpong.data.user.type.RacketType; +import gg.pingpong.data.user.type.RoleType; +import gg.pingpong.data.user.type.SnsType; +import gg.pingpong.repo.game.GameRepository; +import gg.pingpong.repo.game.PChangeRepository; +import gg.pingpong.repo.game.TeamRepository; +import gg.pingpong.repo.game.TeamUserRepository; +import gg.pingpong.repo.manage.AnnouncementRepository; +import gg.pingpong.repo.manage.SlotManagementRepository; +import gg.pingpong.repo.noti.NotiRepository; +import gg.pingpong.repo.rank.RankRepository; +import gg.pingpong.repo.rank.TierRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.pingpong.repo.season.SeasonRepository; +import gg.pingpong.repo.store.CoinPolicyRepository; +import gg.pingpong.repo.tournarment.TournamentGameRepository; +import gg.pingpong.repo.tournarment.TournamentRepository; +import gg.pingpong.repo.tournarment.TournamentUserRepository; +import gg.pingpong.repo.user.UserImageRepository; +import gg.pingpong.repo.user.UserRepository; +import gg.pingpong.utils.dto.GameInfoDto; +import gg.pingpong.utils.exception.game.GameNotExistException; import lombok.RequiredArgsConstructor; @Component diff --git a/src/test/java/com/gg/server/utils/annotation/DataJpaUnitTest.java b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/DataJpaUnitTest.java similarity index 92% rename from src/test/java/com/gg/server/utils/annotation/DataJpaUnitTest.java rename to gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/DataJpaUnitTest.java index da53f256a..7f3b6f615 100644 --- a/src/test/java/com/gg/server/utils/annotation/DataJpaUnitTest.java +++ b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/DataJpaUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.utils.annotation; +package gg.pingpong.utils.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/test/java/com/gg/server/utils/annotation/IntegrationTest.java b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTest.java similarity index 81% rename from src/test/java/com/gg/server/utils/annotation/IntegrationTest.java rename to gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTest.java index 487b79276..d64a35597 100644 --- a/src/test/java/com/gg/server/utils/annotation/IntegrationTest.java +++ b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTest.java @@ -1,4 +1,4 @@ -package com.gg.server.utils.annotation; +package gg.pingpong.utils.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -10,9 +10,9 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; -import com.gg.server.utils.config.MySQLInitializer; -import com.gg.server.utils.config.RedisInitializer; -import com.gg.server.utils.config.TestRedisConfig; +import gg.pingpong.utils.config.MySQLInitializer; +import gg.pingpong.utils.config.RedisInitializer; +import gg.pingpong.utils.config.TestRedisConfig; /** * 통합테스트 환경의 의존성 관리를 위한 어노테이션. diff --git a/src/test/java/com/gg/server/utils/annotation/IntegrationTestAspect.java b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTestAspect.java similarity index 85% rename from src/test/java/com/gg/server/utils/annotation/IntegrationTestAspect.java rename to gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTestAspect.java index 88c4cbdfd..1951c667d 100644 --- a/src/test/java/com/gg/server/utils/annotation/IntegrationTestAspect.java +++ b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTestAspect.java @@ -1,4 +1,4 @@ -package com.gg.server.utils.annotation; +package gg.pingpong.utils.annotation; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.After; @@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import com.gg.server.domain.rank.redis.RankRedisRepository; +import gg.pingpong.repo.rank.redis.RankRedisRepository; @Aspect @Component diff --git a/src/test/java/com/gg/server/utils/annotation/IntegrationTestWithRedisTransaction.java b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTestWithRedisTransaction.java similarity index 84% rename from src/test/java/com/gg/server/utils/annotation/IntegrationTestWithRedisTransaction.java rename to gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTestWithRedisTransaction.java index 73d41e34b..1f5e76f30 100644 --- a/src/test/java/com/gg/server/utils/annotation/IntegrationTestWithRedisTransaction.java +++ b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTestWithRedisTransaction.java @@ -1,4 +1,4 @@ -package com.gg.server.utils.annotation; +package gg.pingpong.utils.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -9,8 +9,8 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ContextConfiguration; -import com.gg.server.utils.config.MySQLInitializer; -import com.gg.server.utils.config.RedisInitializer; +import gg.pingpong.utils.config.MySQLInitializer; +import gg.pingpong.utils.config.RedisInitializer; /** * 통합테스트 환경의 의존성 관리를 위한 어노테이션. diff --git a/src/test/java/com/gg/server/utils/annotation/TestTypeConstant.java b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/TestTypeConstant.java similarity index 89% rename from src/test/java/com/gg/server/utils/annotation/TestTypeConstant.java rename to gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/TestTypeConstant.java index b9ad8ebc3..4ef1bcba2 100644 --- a/src/test/java/com/gg/server/utils/annotation/TestTypeConstant.java +++ b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/TestTypeConstant.java @@ -1,4 +1,4 @@ -package com.gg.server.utils.annotation; +package gg.pingpong.utils.annotation; import lombok.AccessLevel; import lombok.NoArgsConstructor; diff --git a/src/test/java/com/gg/server/utils/annotation/UnitTest.java b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/UnitTest.java similarity index 92% rename from src/test/java/com/gg/server/utils/annotation/UnitTest.java rename to gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/UnitTest.java index 37d01fc5e..a470c40e5 100644 --- a/src/test/java/com/gg/server/utils/annotation/UnitTest.java +++ b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/UnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.utils.annotation; +package gg.pingpong.utils.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/test/java/com/gg/server/utils/annotation/WebMvcUnitTest.java b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/WebMvcUnitTest.java similarity index 92% rename from src/test/java/com/gg/server/utils/annotation/WebMvcUnitTest.java rename to gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/WebMvcUnitTest.java index 4ed284c7c..fdeec94ef 100644 --- a/src/test/java/com/gg/server/utils/annotation/WebMvcUnitTest.java +++ b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/WebMvcUnitTest.java @@ -1,4 +1,4 @@ -package com.gg.server.utils.annotation; +package gg.pingpong.utils.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/test/java/com/gg/server/utils/config/MySQLInitializer.java b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/MySQLInitializer.java similarity index 97% rename from src/test/java/com/gg/server/utils/config/MySQLInitializer.java rename to gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/MySQLInitializer.java index 127211a94..1af0f4bfc 100644 --- a/src/test/java/com/gg/server/utils/config/MySQLInitializer.java +++ b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/MySQLInitializer.java @@ -1,4 +1,4 @@ -package com.gg.server.utils.config; +package gg.pingpong.utils.config; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.context.ApplicationContextInitializer; diff --git a/src/test/java/com/gg/server/utils/config/RedisInitializer.java b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/RedisInitializer.java similarity index 96% rename from src/test/java/com/gg/server/utils/config/RedisInitializer.java rename to gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/RedisInitializer.java index 508741dc5..1fe3a5e6d 100644 --- a/src/test/java/com/gg/server/utils/config/RedisInitializer.java +++ b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/RedisInitializer.java @@ -1,4 +1,4 @@ -package com.gg.server.utils.config; +package gg.pingpong.utils.config; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.context.ApplicationContextInitializer; diff --git a/src/test/java/com/gg/server/utils/config/TestRedisConfig.java b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/TestRedisConfig.java similarity index 97% rename from src/test/java/com/gg/server/utils/config/TestRedisConfig.java rename to gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/TestRedisConfig.java index 73edb0c44..f8d4c63a9 100644 --- a/src/test/java/com/gg/server/utils/config/TestRedisConfig.java +++ b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/TestRedisConfig.java @@ -1,4 +1,4 @@ -package com.gg.server.utils.config; +package gg.pingpong.utils.config; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; diff --git a/src/test/java/com/gg/server/domain/user/controller/dto/GameInfoDto.java b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/dto/GameInfoDto.java similarity index 82% rename from src/test/java/com/gg/server/domain/user/controller/dto/GameInfoDto.java rename to gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/dto/GameInfoDto.java index e466976e3..05ba208b4 100644 --- a/src/test/java/com/gg/server/domain/user/controller/dto/GameInfoDto.java +++ b/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/dto/GameInfoDto.java @@ -1,4 +1,4 @@ -package com.gg.server.domain.user.controller.dto; +package gg.pingpong.utils.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/gradlew.bat b/gradlew.bat index 53a6b238d..f127cfd49 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,91 +1,91 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/naver-checkstyle-rules.xml b/naver-checkstyle-rules.xml index a022f4485..a6e5eb3cf 100644 --- a/naver-checkstyle-rules.xml +++ b/naver-checkstyle-rules.xml @@ -116,6 +116,7 @@ The following rules in the Naver coding convention cannot be checked by this con + diff --git a/settings.gradle b/settings.gradle index 096502d21..4d65fe63e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,7 @@ rootProject.name = 'server' +include 'gg-pingpong-data' +include 'gg-pingpong-admin-repo' +include 'gg-pingpong-repo' +include 'gg-pingpong-api' +include 'gg-pingpong-utils' + diff --git a/src/main/java/com/gg/server/Application.java b/src/main/java/com/gg/server/Application.java deleted file mode 100644 index ae01225eb..000000000 --- a/src/main/java/com/gg/server/Application.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.gg.server; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} diff --git a/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java b/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java deleted file mode 100644 index 6af21dae7..000000000 --- a/src/main/java/com/gg/server/admin/coin/service/CoinAdminService.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.gg.server.admin.coin.service; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.gg.server.admin.coin.dto.CoinUpdateRequestDto; -import com.gg.server.data.store.CoinHistory; -import com.gg.server.data.user.User; -import com.gg.server.domain.coin.service.CoinHistoryService; -import com.gg.server.domain.user.data.UserRepository; -import com.gg.server.domain.user.exception.UserNotFoundException; - -import lombok.RequiredArgsConstructor; - -@Service -@RequiredArgsConstructor -public class CoinAdminService { - private final UserRepository userRepository; - private final CoinHistoryService coinHistoryService; - - /*** - * 유저의 코인 정보를 업데이트합니다. - * @param coinUpdateRequestDto 코인 업데이트에 필요한 Dto - * @throws UserNotFoundException 유저가 존재하지 않을 경우 - */ - @Transactional - public void updateUserCoin(CoinUpdateRequestDto coinUpdateRequestDto) { - User user = userRepository.findByIntraId(coinUpdateRequestDto.getIntraId()) - .orElseThrow(UserNotFoundException::new); - user.addGgCoin(coinUpdateRequestDto.getChange()); - coinHistoryService.addCoinHistory( - new CoinHistory(user, coinUpdateRequestDto.getContent(), coinUpdateRequestDto.getChange())); - } -} diff --git a/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java b/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java deleted file mode 100644 index 5575352e7..000000000 --- a/src/main/java/com/gg/server/admin/receipt/service/ReceiptAdminService.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.gg.server.admin.receipt.service; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.gg.server.admin.receipt.data.ReceiptAdminRepository; -import com.gg.server.admin.receipt.dto.ReceiptListResponseDto; -import com.gg.server.admin.receipt.dto.ReceiptResponseDto; -import com.gg.server.data.store.Receipt; - -import lombok.RequiredArgsConstructor; - -@Service -@RequiredArgsConstructor -public class ReceiptAdminService { - private final ReceiptAdminRepository receiptAdminRepository; - - /** - *

모든 영수증 데이터를 가져옵니다.

- * @param pageable - * @return - */ - @Transactional(readOnly = true) - public ReceiptListResponseDto getAllReceipt(Pageable pageable) { - Page responseDto = receiptAdminRepository.findAll(pageable).map(ReceiptResponseDto::new); - return new ReceiptListResponseDto(responseDto.getContent(), responseDto.getTotalPages()); - } - - /** - *

특정 유저가 사용한 영수증 내역을 가져옵니다.

- * @param intraId - * @param pageable - * @return - */ - @Transactional(readOnly = true) - public ReceiptListResponseDto findByIntraId(String intraId, Pageable pageable) { - Page receipts = receiptAdminRepository.findReceiptByIntraId(intraId, pageable); - Page responseDto = receipts.map(ReceiptResponseDto::new); - return new ReceiptListResponseDto(responseDto.getContent(), responseDto.getTotalPages()); - } -} diff --git a/src/main/java/com/gg/server/data/game/type/Mode.java b/src/main/java/com/gg/server/data/game/type/Mode.java deleted file mode 100644 index d6893b381..000000000 --- a/src/main/java/com/gg/server/data/game/type/Mode.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.gg.server.data.game.type; - -import java.util.List; -import java.util.Locale; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.gg.server.data.match.RedisMatchUser; -import com.gg.server.data.match.type.Option; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor -public enum Mode { - NORMAL("normal"), RANK("rank"), TOURNAMENT("tournament"); - private final String code; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static Mode getEnumValue(String code) { - for (Mode e : values()) { - if (e.code.equals(code)) { - return e; - } else if (e.code.toUpperCase(Locale.ROOT).equals(code.toUpperCase(Locale.ROOT))) { - return e; - } - } - return null; - } - - public static Mode ofPlayers(List players, Integer pppGap) { - if (players.stream().allMatch(player -> player.getOption().equals(Option.BOTH))) { - if (Math.abs(players.get(0).getPpp() - players.get(1).getPpp()) <= pppGap) { - return Mode.RANK; - } - return Mode.NORMAL; - } - if (!players.get(0).getOption().equals(Option.BOTH)) { - return Mode.getEnumValue(players.get(0).getOption().getCode()); - } - return Mode.getEnumValue(players.get(1).getOption().getCode()); - } -} diff --git a/src/main/java/com/gg/server/domain/item/exception/ItemNotFoundException.java b/src/main/java/com/gg/server/domain/item/exception/ItemNotFoundException.java deleted file mode 100644 index 2e5fc703c..000000000 --- a/src/main/java/com/gg/server/domain/item/exception/ItemNotFoundException.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.gg.server.domain.item.exception; - -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; - -public class ItemNotFoundException extends NotExistException { - public ItemNotFoundException() { - super("해당 아이템이 없습니다.", ErrorCode.ITEM_NOT_FOUND); - } -} diff --git a/src/main/java/com/gg/server/domain/match/dto/GameAddDto.java b/src/main/java/com/gg/server/domain/match/dto/GameAddDto.java deleted file mode 100644 index 87053451a..000000000 --- a/src/main/java/com/gg/server/domain/match/dto/GameAddDto.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.gg.server.domain.match.dto; - -import java.time.LocalDateTime; -import java.util.List; - -import com.gg.server.data.game.Season; -import com.gg.server.data.game.type.Mode; -import com.gg.server.data.match.RedisMatchUser; - -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class GameAddDto { - private LocalDateTime startTime; - private Season season; - private Long playerId; - private Long enemyId; - private Mode mode; - - public GameAddDto(LocalDateTime startTime, Season season, RedisMatchUser player, - RedisMatchUser enemy) { - this.startTime = startTime; - this.season = season; - this.playerId = player.getUserId(); - this.enemyId = enemy.getUserId(); - this.mode = Mode.ofPlayers(List.of(player, enemy), season.getPppGap()); - } - -} diff --git a/src/main/java/com/gg/server/domain/noti/dto/NotiFindByUserRequestDto.java b/src/main/java/com/gg/server/domain/noti/dto/NotiFindByUserRequestDto.java deleted file mode 100644 index 550652e94..000000000 --- a/src/main/java/com/gg/server/domain/noti/dto/NotiFindByUserRequestDto.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.gg.server.domain.noti.dto; - -public class NotiFindByUserRequestDto { -} diff --git a/src/main/java/com/gg/server/domain/noti/dto/NotiFindByUserResponseDto.java b/src/main/java/com/gg/server/domain/noti/dto/NotiFindByUserResponseDto.java deleted file mode 100644 index 02b1f52cb..000000000 --- a/src/main/java/com/gg/server/domain/noti/dto/NotiFindByUserResponseDto.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.gg.server.domain.noti.dto; - -public class NotiFindByUserResponseDto { -} diff --git a/src/main/java/com/gg/server/domain/pchange/exception/PChangeNotExistException.java b/src/main/java/com/gg/server/domain/pchange/exception/PChangeNotExistException.java deleted file mode 100644 index c3d036011..000000000 --- a/src/main/java/com/gg/server/domain/pchange/exception/PChangeNotExistException.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.gg.server.domain.pchange.exception; - -import com.gg.server.global.exception.ErrorCode; -import com.gg.server.global.exception.custom.NotExistException; - -public class PChangeNotExistException extends NotExistException { - public PChangeNotExistException() { - super("이전 exp 히스토리가 존재하지 않습니다.", ErrorCode.PCHANGE_NOT_FOUND); - } -} diff --git a/src/main/java/com/gg/server/domain/season/service/SeasonFindService.java b/src/main/java/com/gg/server/domain/season/service/SeasonFindService.java deleted file mode 100644 index 3e67f0c2a..000000000 --- a/src/main/java/com/gg/server/domain/season/service/SeasonFindService.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.gg.server.domain.season.service; - -import java.time.LocalDateTime; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.gg.server.data.game.Game; -import com.gg.server.data.game.Season; -import com.gg.server.domain.game.data.GameRepository; -import com.gg.server.domain.game.exception.GameNotExistException; -import com.gg.server.domain.season.data.SeasonRepository; -import com.gg.server.domain.season.exception.SeasonNotFoundException; - -import lombok.RequiredArgsConstructor; - -@Service -@RequiredArgsConstructor - -public class SeasonFindService { - private final SeasonRepository seasonRepository; - private final GameRepository gameRepository; - - @Transactional(readOnly = true) - public Season findCurrentSeason(LocalDateTime now) { - return seasonRepository.findCurrentSeason(now).orElseThrow(() -> new SeasonNotFoundException()); - } - - @Transactional(readOnly = true) - public Season findSeasonById(Long seasonId) { - return seasonRepository.findById(seasonId).orElseThrow(() -> new SeasonNotFoundException()); - } - - @Transactional(readOnly = true) - public Season findSeasonByGameId(Long gameId) { - Game game = gameRepository.findById(gameId).orElseThrow(() -> new GameNotExistException()); - return game.getSeason(); - } -} diff --git a/src/test/java/com/gg/server/admin/penalty/service/PenaltyAdminServiceTest.java b/src/test/java/com/gg/server/admin/penalty/service/PenaltyAdminServiceTest.java deleted file mode 100644 index 35ea869e8..000000000 --- a/src/test/java/com/gg/server/admin/penalty/service/PenaltyAdminServiceTest.java +++ /dev/null @@ -1,215 +0,0 @@ -package com.gg.server.admin.penalty.service; - -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.BDDMockito.*; - -import java.time.LocalDateTime; -import java.util.Optional; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; - -import com.gg.server.admin.penalty.data.PenaltyAdminRepository; -import com.gg.server.admin.penalty.data.PenaltyUserAdminRedisRepository; -import com.gg.server.data.manage.Penalty; -import com.gg.server.data.manage.redis.RedisPenaltyUser; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.penalty.exception.PenaltyExpiredException; -import com.gg.server.domain.penalty.exception.PenaltyNotFoundException; -import com.gg.server.domain.penalty.exception.RedisPenaltyUserNotFoundException; -import com.gg.server.domain.penalty.type.PenaltyType; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.service.UserFindService; -import com.gg.server.utils.ReflectionUtilsForUnitTest; -import com.gg.server.utils.annotation.UnitTest; - -@UnitTest -@ExtendWith(MockitoExtension.class) -class PenaltyAdminServiceTest { - - @Mock - PenaltyUserAdminRedisRepository penaltyUserAdminRedisRepository; - @Mock - UserFindService userFindService; - @Mock - PenaltyAdminRepository penaltyRepository; - @InjectMocks - PenaltyAdminService penaltyAdminService; - - @Nested - @DisplayName("givePenalty - 유저에게 penalty 부여 한다") - class GivePenaltyTest { - User user; - UserDto userDto; - int penaltyTime; - - @BeforeEach - void beforeEach() { - user = new User("intra", "email", "image", RacketType.PENHOLDER, - RoleType.USER, 1000, SnsType.NONE, 4242L); - userDto = UserDto.from(user); - penaltyTime = 1; - given(userFindService.findByIntraId(userDto.getIntraId())).willReturn(user); - doNothing().when(penaltyUserAdminRedisRepository) - .addPenaltyUser(any(RedisPenaltyUser.class), any(LocalDateTime.class)); - } - - @Test - @DisplayName("Success - redis 에 PenaltyUser 가 있을 때") - void success1() { - RedisPenaltyUser redisPenaltyUser = new RedisPenaltyUser(); - redisPenaltyUser.updateReleaseTime(LocalDateTime.now(), penaltyTime); - Optional optional = Optional.of(redisPenaltyUser); - Penalty penalty = new Penalty(user, PenaltyType.CANCEL, "[AUTO] 매칭 취소", redisPenaltyUser.getReleaseTime(), - penaltyTime); - - given(penaltyUserAdminRedisRepository.findByIntraId(userDto.getIntraId())).willReturn( - optional); // redis 에 PenaltyUser 가 있을때 - given(penaltyRepository.save(any(Penalty.class))).willReturn(penalty); - - // when, then - penaltyAdminService.givePenalty(user.getIntraId(), penaltyTime, "reason"); - } - - @Test - @DisplayName("Success - redis 에 PenaltyUser 가 없을 때") - void success2() { - // given - Penalty penalty = new Penalty(user, PenaltyType.CANCEL, "[AUTO] 매칭 취소", LocalDateTime.now(), penaltyTime); - - given(penaltyUserAdminRedisRepository.findByIntraId(user.getIntraId())).willReturn( - Optional.empty()); // redis 에 PenaltyUser 가 없을때 - given(penaltyRepository.save(any(Penalty.class))).willReturn(penalty); - - // when, then - penaltyAdminService.givePenalty(user.getIntraId(), penaltyTime, "reason"); - } - } - - @Nested - @DisplayName("getAllPenalties - 모든 penalty 를 가져온다") - class GetAllPenaltiesTest { - - @Test - @DisplayName("Success - 현재 penalty 를 가져온다, Boolean current = true") - void success1() { - //given - given(penaltyRepository.findAllCurrent(any(Pageable.class), any(LocalDateTime.class))).willReturn( - Page.empty()); - //when, then - penaltyAdminService.getAllPenalties(Pageable.unpaged(), true); - } - - @Test - @DisplayName("Success - 모든 penalty 를 가져온다, Boolean current = false") - void success2() { - //given - given(penaltyRepository.findAll(any(Pageable.class))).willReturn(Page.empty()); - //when, then - penaltyAdminService.getAllPenalties(Pageable.unpaged(), false); - } - } - - @Nested - @DisplayName("deletePenalty 테스트 - redis에 있는 penalty 삭제, 뒤 시간 penalty 시간 당기고 penalty 삭제, ") - class DeletePenaltyTest { - Penalty penalty; - - @BeforeEach - void beforeEach() { - User user = new User("intra", "email", "image", RacketType.PENHOLDER, - RoleType.USER, 1000, SnsType.NONE, 4242L); - penalty = new Penalty(user, PenaltyType.NOSHOW, "noshow 패널티", LocalDateTime.now(), 10); - ReflectionUtilsForUnitTest.setFieldWithReflection(penalty, "id", 1L); - } - - @Test - @DisplayName("Success - penalty 삭제") - void success() { - //given - given(penaltyRepository.findById(1L)).willReturn(Optional.of(penalty)); - given(penaltyUserAdminRedisRepository.findByIntraId(anyString())) - .willReturn(Optional.of(new RedisPenaltyUser())); - doNothing() - .when(penaltyUserAdminRedisRepository).deletePenaltyInUser(any(RedisPenaltyUser.class), anyInt()); - doNothing() - .when(penaltyRepository).delete(any(Penalty.class)); - //when, then - penaltyAdminService.deletePenalty(1L); - } - - @Test - @DisplayName("Fail - penalty 삭제, penalty 시간이 지났을 경우") - void fail() { - ReflectionUtilsForUnitTest.setFieldWithReflection(penalty, "startTime", - LocalDateTime.now().minusMinutes(20)); - //given - given(penaltyRepository.findById(1L)).willReturn(Optional.of(penalty)); - //when, then - Assertions.assertThrows(PenaltyExpiredException.class, () -> { - penaltyAdminService.deletePenalty(1L); - }); - } - - @Test - @DisplayName("Fail - penalty 삭제, penalty 가 없을 경우") - void fail2() { - //given - given(penaltyRepository.findById(1L)).willReturn(Optional.empty()); - //when, then - Assertions.assertThrows(PenaltyNotFoundException.class, () -> { - penaltyAdminService.deletePenalty(1L); - }); - } - - @Test - @DisplayName("Fail - penalty 삭제, redis 에 penalty 가 없을 경우") - void fail3() { - //given - given(penaltyRepository.findById(1L)).willReturn(Optional.of(penalty)); - given(penaltyUserAdminRedisRepository.findByIntraId(anyString())) - .willReturn(Optional.empty()); - //when, then - Assertions.assertThrows(RedisPenaltyUserNotFoundException.class, () -> { - penaltyAdminService.deletePenalty(1L); - }); - } - } - - @Nested - @DisplayName("getAllPenaltiesByIntraId - intraId 로 패널티 리스트 조회") - class GetAllPenaltiesByIntraIdTest { - - @Test - @DisplayName("Success - 현재 penalty 들을 가져온다, Boolean current = true") - void success1() { - //given - given(penaltyRepository.findAllCurrentByIntraId(any(Pageable.class), any(LocalDateTime.class), anyString())) - .willReturn(Page.empty()); - //when, then - penaltyAdminService.getAllPenaltiesByIntraId(Pageable.unpaged(), "intra", true); - } - - @Test - @DisplayName("Success - 모든 penalty 를 가져 온다, Boolean current = false") - void success2() { - //given - given(penaltyRepository.findAllByIntraId(any(Pageable.class), anyString())) - .willReturn(Page.empty()); - //when, then - penaltyAdminService.getAllPenaltiesByIntraId(Pageable.unpaged(), "intra", false); - } - } -} diff --git a/src/test/java/com/gg/server/data/manage/PenaltyTest.java b/src/test/java/com/gg/server/data/manage/PenaltyTest.java deleted file mode 100644 index cb22a9a92..000000000 --- a/src/test/java/com/gg/server/data/manage/PenaltyTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.gg.server.data.manage; - -import static org.junit.jupiter.api.Assertions.*; - -import java.time.LocalDateTime; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import com.gg.server.utils.annotation.UnitTest; - -@UnitTest -@ExtendWith(MockitoExtension.class) -class PenaltyTest { - - @Test - void updateStartTime() { - // given - Penalty penalty = new Penalty(); - // when - penalty.updateStartTime(LocalDateTime.now()); - // then - assertNotNull(penalty.getStartTime()); - } -} diff --git a/src/test/java/com/gg/server/domain/penalty/service/PenaltyServiceTest.java b/src/test/java/com/gg/server/domain/penalty/service/PenaltyServiceTest.java deleted file mode 100644 index f07ceee01..000000000 --- a/src/test/java/com/gg/server/domain/penalty/service/PenaltyServiceTest.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.gg.server.domain.penalty.service; - -import static org.mockito.BDDMockito.*; - -import java.time.LocalDateTime; -import java.util.Optional; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import com.gg.server.data.manage.Penalty; -import com.gg.server.data.manage.redis.RedisPenaltyUser; -import com.gg.server.data.user.User; -import com.gg.server.data.user.type.RacketType; -import com.gg.server.data.user.type.RoleType; -import com.gg.server.data.user.type.SnsType; -import com.gg.server.domain.penalty.data.PenaltyRepository; -import com.gg.server.domain.penalty.redis.PenaltyUserRedisRepository; -import com.gg.server.domain.penalty.type.PenaltyType; -import com.gg.server.domain.user.dto.UserDto; -import com.gg.server.domain.user.service.UserFindService; -import com.gg.server.utils.annotation.UnitTest; - -@UnitTest -@ExtendWith(MockitoExtension.class) -class PenaltyServiceTest { - @Mock - PenaltyRepository penaltyRepository; - @Mock - PenaltyUserRedisRepository penaltyUserRedisRepository; - @Mock - UserFindService userFindService; - @InjectMocks - PenaltyService penaltyService; - - @Nested - @DisplayName("givePenalty - User에게 penalty 부여 한다") - class GivePenaltyTest { - - User user; - UserDto userDto; - int penaltyTime; - - @BeforeEach - void beforeEach() { - user = new User("intra", "email", "image", RacketType.PENHOLDER, - RoleType.USER, 1000, SnsType.NONE, 4242L); - userDto = UserDto.from(user); - penaltyTime = 1; - given(userFindService.findUserById(userDto.getId())).willReturn(user); - doNothing().when(penaltyUserRedisRepository) - .addPenaltyUser(any(RedisPenaltyUser.class), any(LocalDateTime.class)); - } - - @Test - @DisplayName("Success : redis 에 PenaltyUser 가 있을때") - void success1() { - RedisPenaltyUser redisPenaltyUser = new RedisPenaltyUser(); - redisPenaltyUser.updateReleaseTime(LocalDateTime.now(), penaltyTime); - Optional optional = Optional.of(redisPenaltyUser); - Penalty penalty = new Penalty(user, PenaltyType.CANCEL, "[AUTO] 매칭 취소", redisPenaltyUser.getReleaseTime(), - penaltyTime); - - given(penaltyUserRedisRepository.findByIntraId(userDto.getIntraId())).willReturn( - optional); // redis 에 PenaltyUser 가 있을때 - given(penaltyRepository.save(any(Penalty.class))).willReturn(penalty); - - // when, then - penaltyService.givePenalty(userDto, penaltyTime); - } - - @Test - @DisplayName("Success : redis 에 PenaltyUser 가 없을때") - void success2() { - // given - Penalty penalty = new Penalty(user, PenaltyType.CANCEL, "[AUTO] 매칭 취소", LocalDateTime.now(), penaltyTime); - - given(penaltyUserRedisRepository.findByIntraId(userDto.getIntraId())).willReturn( - Optional.empty()); // redis 에 PenaltyUser 가 없을때 - given(penaltyRepository.save(any(Penalty.class))).willReturn(penalty); - - // when, then - penaltyService.givePenalty(userDto, penaltyTime); - } - } - - @Test - @DisplayName("isPenaltyUser - Redis 에 PenaltyUser 가 존재 하는지 확인 한다") - void isPenaltyUser() { - //given - given(penaltyUserRedisRepository.findByIntraId("intraId")).willReturn(Optional.of(new RedisPenaltyUser())); - - //when then - penaltyService.isPenaltyUser("intraId"); - } -} diff --git a/src/test/java/com/gg/server/domain/user/service/UserFindServiceUnitTest.java b/src/test/java/com/gg/server/domain/user/service/UserFindServiceUnitTest.java deleted file mode 100644 index 4abe49cb6..000000000 --- a/src/test/java/com/gg/server/domain/user/service/UserFindServiceUnitTest.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.gg.server.domain.user.service; - -import com.gg.server.utils.annotation.UnitTest; - -@UnitTest -class UserFindServiceUnitTest { - -} From 066ae00c06fd6f4711f64b5443d39c377b4566b7 Mon Sep 17 00:00:00 2001 From: Hyunkyu Lee <88573971+wken5577@users.noreply.github.com> Date: Fri, 23 Feb 2024 18:37:32 +0900 Subject: [PATCH 30/32] =?UTF-8?q?[BUG]=20#625=20test,=20main=20deploy?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#626)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main-deploy.yml | 4 ++-- .github/workflows/test-deploy.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main-deploy.yml b/.github/workflows/main-deploy.yml index b8ba31051..ba3edda91 100644 --- a/.github/workflows/main-deploy.yml +++ b/.github/workflows/main-deploy.yml @@ -14,7 +14,7 @@ env: DOCKER_USER: ${{ secrets.DOCKER_USER }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} IMAGE_NAME: wken5577/42gg-server - VERSION_TAG : ${{ secrets.VERSION_TAG }} + VERSION_TAG: ${{ secrets.VERSION_TAG }} permissions: contents: read @@ -36,7 +36,7 @@ jobs: - name: Make application ymls run: | - cd ./src/main/resources + cd ./gg-pingpong-api/src/main/resources echo "${{ secrets.APPLICATION_YML }}" | base64 -d > application.yml shell: bash diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml index 3ddb998d3..9867ee258 100644 --- a/.github/workflows/test-deploy.yml +++ b/.github/workflows/test-deploy.yml @@ -37,7 +37,7 @@ jobs: - name: Make application ymls run: | - cd ./src/main/resources + cd ./gg-pingpong-api/src/main/resources echo "${{ secrets.MIGRATE_APPLICATION_YML }}" | base64 -d > application.yml shell: bash From 0ff20497571ce46463b2158f7f2a79774f56f229 Mon Sep 17 00:00:00 2001 From: wken5577 Date: Fri, 23 Feb 2024 18:46:15 +0900 Subject: [PATCH 31/32] [FIX] dockerfile fix --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c3ec4961c..aeaf705f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ ARG JAR_FILE=gg-pingpong-api/build/libs/gg-pingpong-api-42gg.jar COPY ${JAR_FILE} . EXPOSE 8080 -ENTRYPOINT ["java","-jar","server-42gg.jar", \ +ENTRYPOINT ["java","-jar","gg-pingpong-api-42gg.jar", \ "--spring.profiles.active=${PROFILE}", \ "--spring.security.oauth2.client.registration.42.client-id=${SPRING_42_CLIENT_ID}", \ "--spring.security.oauth2.client.registration.42.client-secret=${SPRING_42_CLIENT_SECRET}"] From da7fe730017e3573413898521907e49ffd0b206c Mon Sep 17 00:00:00 2001 From: Hyunkyu Lee <88573971+wken5577@users.noreply.github.com> Date: Wed, 28 Feb 2024 21:04:31 +0900 Subject: [PATCH 32/32] =?UTF-8?q?[FEAT]=20module=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20(#659)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test-code-validation.yml | 4 +- build.gradle | 26 +++--- .../build.gradle | 2 +- .../admin/repo/game/GameAdminRepository.java | 12 +-- .../repo/game/PChangeAdminRepository.java | 4 +- .../game/PChangeAdminRepositoryCustom.java | 4 +- .../PChangeAdminRepositoryCustomImpl.java | 4 +- .../admin/repo/game/TeamAdminRepository.java | 6 +- .../repo/game/TeamUserAdminRepository.java | 6 +- .../gg/admin}/repo/game/out/GameTeamUser.java | 6 +- .../AdminSlotManagementsRepository.java | 4 +- .../manage/AnnouncementAdminRepository.java | 4 +- .../repo/manage/FeedbackAdminRepository.java | 4 +- .../repo/manage/PenaltyAdminRepository.java | 4 +- .../manage/PenaltyAdminRepositoryCustom.java | 4 +- .../PenaltyAdminRepositoryCustomImpl.java | 4 +- .../PenaltyUserAdminRedisRepository.java | 6 +- .../admin/repo/noti/NotiAdminRepository.java | 4 +- .../repo/noti/NotiAdminRepositoryCustom.java | 4 +- .../noti/NotiAdminRepositoryCustomImpl.java | 4 +- .../repo/season/SeasonAdminRepository.java | 4 +- .../repo/store/CoinPolicyAdminRepository.java | 4 +- .../admin/repo/store/ItemAdminRepository.java | 4 +- .../repo/store/MegaphoneAdminRepository.java | 4 +- .../repo/store/ReceiptAdminRepository.java | 4 +- .../store/ReceiptAdminRepositorySearch.java | 4 +- .../admin/repo/user/UserAdminRepository.java | 4 +- .../repo/user/UserImageAdminRepository.java | 6 +- {gg-pingpong-data => gg-data}/build.gradle | 2 +- .../main/java/gg}/data/BaseTimeEntity.java | 2 +- .../src/main/java/gg}/data/game/Game.java | 12 +-- .../src/main/java/gg}/data/game/PChange.java | 6 +- .../src/main/java/gg}/data/game/Team.java | 6 +- .../src/main/java/gg}/data/game/TeamUser.java | 8 +- .../main/java/gg}/data/game/type/Mode.java | 2 +- .../java/gg}/data/game/type/StatusType.java | 2 +- .../java/gg}/data/manage/Announcement.java | 4 +- .../main/java/gg}/data/manage/Feedback.java | 8 +- .../main/java/gg}/data/manage/Penalty.java | 8 +- .../java/gg}/data/manage/SlotManagement.java | 6 +- .../data/manage/redis/RedisPenaltyUser.java | 2 +- .../gg}/data/manage/type/FeedbackType.java | 2 +- .../java/gg}/data/manage/type/PenaltyKey.java | 2 +- .../gg}/data/manage/type/PenaltyType.java | 2 +- .../java/gg}/data/match/RedisMatchTime.java | 4 +- .../java/gg}/data/match/RedisMatchUser.java | 4 +- .../java/gg}/data/match/type/MatchKey.java | 2 +- .../main/java/gg}/data/match/type/Option.java | 4 +- .../java/gg}/data/match/type/SlotStatus.java | 2 +- .../match/type/TournamentMatchStatus.java | 2 +- .../src/main/java/gg}/data/noti/Noti.java | 8 +- .../java/gg}/data/noti/type/NotiType.java | 2 +- .../src/main/java/gg}/data/rank/Rank.java | 8 +- .../src/main/java/gg}/data/rank/Tier.java | 2 +- .../java/gg}/data/rank/redis/RankRedis.java | 4 +- .../src/main/java/gg}/data/season/Season.java | 2 +- .../main/java/gg}/data/store/CoinHistory.java | 4 +- .../main/java/gg}/data/store/CoinPolicy.java | 4 +- .../src/main/java/gg}/data/store/Item.java | 4 +- .../main/java/gg}/data/store/Megaphone.java | 4 +- .../src/main/java/gg}/data/store/Receipt.java | 4 +- .../gg}/data/store/redis/MegaphoneRedis.java | 2 +- .../java/gg}/data/store/type/HistoryType.java | 2 +- .../java/gg}/data/store/type/ItemStatus.java | 2 +- .../java/gg}/data/store/type/ItemType.java | 2 +- .../java/gg}/data/tournament/Tournament.java | 14 +-- .../gg}/data/tournament/TournamentGame.java | 8 +- .../gg}/data/tournament/TournamentUser.java | 6 +- .../gg}/data/tournament/type/RoundNumber.java | 2 +- .../data/tournament/type/TournamentRound.java | 4 +- .../tournament/type/TournamentStatus.java | 2 +- .../data/tournament/type/TournamentType.java | 2 +- .../tournament/type/TournamentUserStatus.java | 2 +- .../src/main/java/gg}/data/user/User.java | 16 ++-- .../main/java/gg}/data/user/UserImage.java | 2 +- .../gg}/data/user/type/BackgroundType.java | 2 +- .../java/gg}/data/user/type/EdgeType.java | 2 +- .../java/gg}/data/user/type/OauthType.java | 2 +- .../java/gg}/data/user/type/RacketType.java | 2 +- .../java/gg}/data/user/type/RoleType.java | 2 +- .../main/java/gg}/data/user/type/SnsType.java | 2 +- .../data/tournament/TournamentUnitTest.java | 14 +-- gg-pingpong-api/build.gradle | 4 +- .../pingpong/api/PingpongApiApplication.java | 4 +- .../game/controller/GameAdminController.java | 4 +- .../api/admin/game/dto/GameLogAdminDto.java | 4 +- .../admin/game/service/GameAdminService.java | 42 ++++----- .../AnnouncementAdminResponseDto.java | 2 +- .../response/FeedbackAdminResponseDto.java | 4 +- .../response/PenaltyUserResponseDto.java | 4 +- .../api/admin/manage/dto/SlotAdminDto.java | 2 +- .../service/AnnouncementAdminService.java | 8 +- .../manage/service/FeedbackAdminService.java | 6 +- .../manage/service/PenaltyAdminService.java | 18 ++-- .../manage/service/SlotAdminService.java | 8 +- .../api/admin/noti/dto/NotiAdminDto.java | 4 +- .../admin/noti/service/NotiAdminService.java | 12 +-- .../admin/rank/service/RankAdminService.java | 24 ++--- .../rank/service/RankRedisAdminService.java | 18 ++-- .../request/SeasonCreateRequestDto.java | 2 +- .../api/admin/season/dto/SeasonAdminDto.java | 2 +- .../season/service/SeasonAdminService.java | 10 +- .../store/controller/ItemAdminController.java | 4 +- .../request/ItemUpdateRequestDto.java | 4 +- .../response/CoinPolicyAdminResponseDto.java | 2 +- .../response/ItemHistoryResponseDto.java | 2 +- .../response/MegaphoneAdminResponseDto.java | 2 +- .../response/ReceiptResponseDto.java | 6 +- .../admin/store/service/CoinAdminService.java | 8 +- .../store/service/CoinPolicyAdminService.java | 10 +- .../admin/store/service/ItemAdminService.java | 8 +- .../store/service/MegaphoneAdminService.java | 2 +- .../store/service/ReceiptAdminService.java | 4 +- .../TournamentAdminCreateRequestDto.java | 2 +- .../TournamentAdminUpdateRequestDto.java | 2 +- .../service/TournamentAdminService.java | 56 +++++------ .../user/controller/UserAdminController.java | 4 +- .../request/UserUpdateAdminRequestDto.java | 2 +- .../response/UserDetailAdminResponseDto.java | 4 +- .../api/admin/user/dto/UserAdminDto.java | 10 +- .../api/admin/user/dto/UserImageAdminDto.java | 2 +- .../admin/user/dto/UserSearchAdminDto.java | 4 +- .../admin/user/service/UserAdminService.java | 32 +++---- .../pingpong/api/global/config/JpaConfig.java | 4 +- .../pingpong/api/global/config/WebConfig.java | 2 +- .../exception/GlobalExceptionHandler.java | 18 ++-- .../api/global/security/UserPrincipal.java | 4 +- .../OAuthAuthenticationSuccessHandler.java | 8 +- .../global/security/info/OAuthUserInfo.java | 2 +- .../info/impl/FortyTwoOAuthUserInfo.java | 2 +- .../info/impl/KakaoOAuthUserInfo.java | 3 +- .../service/CustomOAuth2UserService.java | 26 +++--- .../service/CustomUserDetailsService.java | 4 +- .../api/global/utils/ItemImageHandler.java | 2 +- .../api/global/utils/UserImageHandler.java | 4 +- .../LoginMemberArgumentResolver.java | 4 +- .../utils/aws/AsyncNewItemImageUploader.java | 3 +- .../utils/aws/AsyncNewUserImageUploader.java | 8 +- .../user/game/controller/GameController.java | 10 +- .../controller/request/GameListReqDto.java | 2 +- .../controller/response/GameResultResDto.java | 4 +- .../api/user/game/dto/GameTeamInfo.java | 8 +- .../api/user/game/dto/MatchTeamsInfoDto.java | 2 +- .../pingpong/api/user/game/dto/TeamInfo.java | 2 +- .../user/game/service/GameFindService.java | 12 +-- .../api/user/game/service/GameService.java | 44 ++++----- .../user/game/service/GameStatusService.java | 20 ++-- .../api/user/game/service/PChangeService.java | 10 +- .../manage/controller/FeedbackController.java | 2 +- .../request/FeedbackRequestDto.java | 2 +- .../api/user/manage/dto/AnnouncementDto.java | 2 +- .../redis/PenaltyUserRedisRepository.java | 4 +- .../manage/service/AnnouncementService.java | 6 +- .../user/manage/service/FeedbackService.java | 10 +- .../user/manage/service/PenaltyService.java | 10 +- .../match/controller/MatchController.java | 2 +- .../controller/request/MatchRequestDto.java | 2 +- .../api/user/match/dto/GameAddDto.java | 8 +- .../api/user/match/dto/MatchStatusDto.java | 8 +- .../api/user/match/dto/SlotStatusDto.java | 2 +- .../user/match/service/GameUpdateService.java | 26 +++--- .../user/match/service/MatchFindService.java | 42 ++++----- .../api/user/match/service/MatchService.java | 56 +++++------ .../match/service/MatchTournamentService.java | 52 +++++------ .../api/user/match/utils/MatchCalculator.java | 6 +- .../api/user/match/utils/SlotGenerator.java | 18 ++-- .../controller/response/NotiResponseDto.java | 4 +- .../pingpong/api/user/noti/dto/NotiDto.java | 4 +- .../api/user/noti/dto/UserNotiDto.java | 4 +- .../api/user/noti/service/NotiService.java | 16 ++-- .../api/user/noti/service/SnsNotiService.java | 4 +- .../user/noti/service/sns/NotiMailSender.java | 2 +- .../noti/service/sns/SlackbotService.java | 4 +- .../api/user/rank/dto/ExpRankDto.java | 4 +- .../pingpong/api/user/rank/dto/RankDto.java | 6 +- .../api/user/rank/redis/RankRedisService.java | 26 +++--- .../user/rank/redis/RedisUploadService.java | 10 +- .../user/rank/service/RankFindService.java | 6 +- .../api/user/rank/service/RankService.java | 24 ++--- .../api/user/rank/service/TierService.java | 10 +- .../controller/response/SeasonResDto.java | 2 +- .../api/user/season/dto/CurSeason.java | 2 +- .../season/service/SeasonFindService.java | 12 +-- .../user/season/service/SeasonService.java | 4 +- .../response/ItemStoreResponseDto.java | 4 +- .../response/MegaphoneDetailResponseDto.java | 2 +- .../MegaphoneTodayListResponseDto.java | 2 +- .../response/UserItemResponseDto.java | 8 +- .../store/redis/MegaphoneRedisRepository.java | 2 +- .../store/service/CoinHistoryService.java | 14 +-- .../api/user/store/service/ItemService.java | 36 ++++---- .../user/store/service/MegaphoneService.java | 36 ++++---- .../store/service/UserCoinChangeService.java | 18 ++-- .../request/TournamentFilterRequestDto.java | 4 +- .../response/TournamentGameResDto.java | 6 +- .../response/TournamentResponseDto.java | 8 +- .../TournamentUserListResponseDto.java | 2 +- ...TournamentUserRegistrationResponseDto.java | 2 +- .../response/TournamentUserResponseDto.java | 2 +- .../tournament/service/TournamentService.java | 44 ++++----- .../user/user/controller/UserController.java | 8 +- .../request/UserModifyRequestDto.java | 4 +- .../response/CoinHistoryResponseDto.java | 2 +- .../response/UserDetailResponseDto.java | 10 +- .../response/UserLiveResponseDto.java | 2 +- .../response/UserNormalDetailResponseDto.java | 2 +- .../pingpong/api/user/user/dto/UserDto.java | 8 +- .../api/user/user/dto/UserHistoryData.java | 2 +- .../api/user/user/dto/UserImageDto.java | 4 +- .../service/UserAuthenticationService.java | 2 +- .../user/user/service/UserCoinService.java | 10 +- .../user/user/service/UserFindService.java | 16 ++-- .../api/user/user/service/UserService.java | 78 ++++++++-------- .../ServerPingpongApiApplicationTests.java | 2 +- .../AnnouncementAdminControllerFailTest.java | 6 +- .../AnnouncementAdminControllerTest.java | 10 +- .../AnnouncementAdminControllerUnitTest.java | 2 +- .../AnnouncementAdminServiceUnitTest.java | 10 +- .../controller/CoinAdminControllerTest.java | 6 +- .../CoinPolicyAdminControllerFailTest.java | 6 +- .../CoinPolicyAdminControllerTest.java | 12 +-- .../coin/service/CoinAdminServiceTest.java | 10 +- .../FeedbackAdminControllerTest.java | 14 +-- .../FeedbackAdminControllerUnitTest.java | 2 +- .../service/FeedbackAdminServiceUnitTest.java | 9 +- .../controller/GameAdminControllerTest.java | 26 +++--- .../controller/ItemAdminControllerTest.java | 14 +-- .../service/ItemAdminServiceUnitTest.java | 18 ++-- .../MegaphoneAdminControllerTest.java | 4 +- .../MegaphoneAdminServiceUnitTest.java | 4 +- .../controller/NotiAdminControllerTest.java | 16 ++-- .../service/NotiAdminServiceUnitTest.java | 12 +-- .../PenaltyAdminControllerTest.java | 24 ++--- .../ReceiptAdminControllerTest.java | 14 +-- .../service/ReceiptAdminServiceUnitTest.java | 6 +- .../controller/SeasonAdminControllerTest.java | 22 ++--- .../service/SeasonAdminServiceUnitTest.java | 12 +-- .../SlotAdminControllerFailTest.java | 10 +- .../controller/SlotAdminControllerTest.java | 10 +- .../service/SlotAdminServiceUnitTest.java | 8 +- .../TournamentAdminControllerTest.java | 36 ++++---- .../TournamentAdminUserControllerTest.java | 14 +-- .../service/TournamentAdminServiceTest.java | 46 +++++----- .../controller/UserAdminControllerTest.java | 16 ++-- .../pingpong/api/data/game/GameUnitTest.java | 10 +- .../api/data/game/PChangeDataTest.java | 4 +- .../pingpong/api/data/game/TeamUnitTest.java | 10 +- .../api/data/game/TournamentGameUnitTest.java | 12 +-- .../api/data/game/TournamentUserUnitTest.java | 12 +-- .../api/data/manage/AnnouncementUnitTest.java | 4 +- .../pingpong/api/data/store/ItemUnitTest.java | 4 +- .../AnnouncementControllerTest.java | 12 +-- .../AnnouncementControllerUnitTest.java | 2 +- .../service/AnnouncementServiceUnitTest.java | 8 +- .../coin/service/CoinHistoryServiceTest.java | 16 ++-- .../service/UserCoinChangeServiceTest.java | 30 +++--- .../controller/FeedbackControllerTest.java | 10 +- .../FeedbackControllerUnitTest.java | 2 +- .../service/FeedbackServiceUnitTest.java | 12 +-- .../api/user/game/GameControllerTest.java | 56 +++++------ .../api/user/game/service/GameDBTest.java | 26 +++--- .../game/service/GameFindServiceTest.java | 30 +++--- .../user/game/service/GameServiceTest.java | 42 ++++----- .../game/service/GameStatusServiceTest.java | 38 ++++---- .../controller/ItemGiftControllerTest.java | 4 +- .../ItemPurchaseControllerTest.java | 4 +- .../ItemStoreListControllerTest.java | 8 +- .../UserItemResponseControllerTest.java | 4 +- .../item/service/ItemServiceUnitTest.java | 42 ++++----- .../match/dto/MatchStatusDtoUnitTest.java | 8 +- .../match/service/MatchBothServiceTest.java | 32 +++---- .../service/MatchFindServiceUnitTest.java | 36 ++++---- .../user/match/service/MatchServiceTest.java | 66 ++++++------- .../service/MatchTournamentServiceTest.java | 39 ++++---- .../MatchTournamentServiceUnitTest.java | 40 ++++---- .../api/user/match/utils/GameTestUtils.java | 14 +-- .../utils/MatchIntegrationTestUtils.java | 30 +++--- .../match/utils/TournamentGameTestUtils.java | 24 ++--- .../user/match/utils/TournamentTestUtils.java | 12 +-- .../api/user/match/utils/UserTestUtils.java | 8 +- .../controller/MegaphoneControllerTest.java | 28 +++--- .../service/MegaphoneServiceUnitTest.java | 38 ++++---- .../noti/controller/NotiControllerTest.java | 14 +-- .../user/noti/service/NotiServiceTest.java | 14 +-- .../noti/service/NotiServiceUnitTest.java | 22 ++--- .../noti/service/SnsNotiServiceUnitTest.java | 8 +- .../service/sns/NotiMailSenderUnitTest.java | 6 +- .../pchange/service/PChangeServiceTest.java | 18 ++-- .../rank/controller/RankControllerTest.java | 12 +-- .../rank/controller/RankV2ControllerTest.java | 4 +- .../rank/redis/RankRedisRepositoryTest.java | 8 +- .../user/rank/redis/RedisTransactionTest.java | 2 +- .../user/rank/service/RankServiceTest.java | 14 +-- .../api/user/season/SeasonTestController.java | 8 +- .../api/user/season/SeasonTriggerTest.java | 10 +- .../season/service/SeasonServiceUnitTest.java | 8 +- .../tier/service/TierServiceUnitTest.java | 14 +-- .../TournamentControllerMvcTest.java | 2 +- .../TournamentFindControllerTest.java | 26 +++--- .../TournamentGameControllerTest.java | 26 +++--- .../controller/TournamentSchedulerTest.java | 16 ++-- .../service/TournamentServiceUnitTest.java | 46 +++++----- .../user/controller/UserControllerTest.java | 64 ++++++------- .../UserAuthenticationServiceUnitTest.java | 4 +- .../user/service/UserFindServiceUnitTest.java | 2 +- .../api/utils/ReflectionUtilsForUnitTest.java | 4 +- {gg-pingpong-repo => gg-repo}/build.gradle | 2 +- .../java/gg}/repo/game/GameRepository.java | 14 +-- .../gg}/repo/game/GameRepositoryCustom.java | 4 +- .../gg}/repo/game/GameRepositoryImpl.java | 6 +- .../java/gg}/repo/game/PChangeRepository.java | 6 +- .../repo/game/PChangeRepositoryCustom.java | 4 +- .../gg}/repo/game/PChangeRepositoryImpl.java | 4 +- .../java/gg}/repo/game/TeamRepository.java | 4 +- .../gg}/repo/game/TeamUserRepository.java | 4 +- .../java/gg}/repo/game/out/GameTeamUser.java | 6 +- .../gg}/repo/game/out/GameTeamUserInfo.java | 6 +- .../main/java/gg}/repo/game/out/GameUser.java | 4 +- .../repo/manage/AnnouncementRepository.java | 4 +- .../gg}/repo/manage/FeedbackRepository.java | 4 +- .../gg}/repo/manage/PenaltyRepository.java | 4 +- .../repo/manage/SlotManagementRepository.java | 4 +- .../repo/match/RedisMatchTimeRepository.java | 6 +- .../repo/match/RedisMatchUserRepository.java | 10 +- .../java/gg}/repo/noti/NotiRepository.java | 6 +- .../gg}/repo/noti/NotiRepositoryCustom.java | 2 +- .../gg}/repo/noti/NotiRepositoryImpl.java | 2 +- .../java/gg}/repo/rank/RankRepository.java | 4 +- .../main/java/gg}/repo/rank/RankV2Dto.java | 2 +- .../java/gg}/repo/rank/TierRepository.java | 4 +- .../repo/rank/redis/RankRedisRepository.java | 6 +- .../gg}/repo/season/SeasonRepository.java | 4 +- .../gg}/repo/store/CoinHistoryRepository.java | 6 +- .../gg}/repo/store/CoinPolicyRepository.java | 4 +- .../java/gg}/repo/store/ItemRepository.java | 4 +- .../gg}/repo/store/MegaphoneRepository.java | 8 +- .../gg}/repo/store/ReceiptRepository.java | 4 +- .../gg}/repo/store/UserItemRepository.java | 4 +- .../tournarment/TournamentGameRepository.java | 6 +- .../tournarment/TournamentRepository.java | 8 +- .../tournarment/TournamentUserRepository.java | 8 +- .../main/java/gg}/repo/user/ExpRankV2Dto.java | 2 +- .../gg}/repo/user/UserImageRepository.java | 6 +- .../java/gg}/repo/user/UserRepository.java | 4 +- {gg-pingpong-utils => gg-utils}/build.gradle | 20 ++-- .../main/java/gg}/utils/RedisKeyManager.java | 2 +- .../gg}/utils/exception/BusinessChecker.java | 4 +- .../java/gg}/utils/exception/ErrorCode.java | 2 +- .../gg}/utils/exception/ErrorResponse.java | 2 +- .../announcement/AnnounceDupException.java | 6 +- .../AnnounceNotFoundException.java | 6 +- .../coin/CoinHistoryNotFoundException.java | 6 +- .../coin/CoinPolicyNotFoundException.java | 6 +- .../custom/AuthenticationException.java | 4 +- .../exception/custom/BusinessException.java | 4 +- .../custom/CustomRuntimeException.java | 4 +- .../custom/DBConsistencyException.java | 4 +- .../custom/DuplicationException.java | 4 +- .../exception/custom/ExpiredException.java | 4 +- .../utils/exception/custom/FileException.java | 4 +- .../exception/custom/ForbiddenException.java | 4 +- .../custom/InvalidParameterException.java | 4 +- .../exception/custom/NotExistException.java | 4 +- .../custom/PageNotFoundException.java | 4 +- .../exception/custom/ParseException.java | 4 +- .../utils/exception/custom/SendException.java | 4 +- .../feedback/FeedbackNotFoundException.java | 6 +- .../game/GameAlreadyExistException.java | 6 +- .../game/GameDataConsistencyException.java | 6 +- .../exception/game/GameNotExistException.java | 6 +- .../game/GameStatusNotMatchedException.java | 6 +- .../game/NotRecentlyGameException.java | 6 +- .../game/ScoreAlreadyEnteredException.java | 6 +- .../game/ScoreNotInvalidException.java | 6 +- .../game/ScoreNotMatchedException.java | 6 +- .../item/InsufficientGgcoinException.java | 6 +- .../item/ItemImageLargeException.java | 6 +- .../item/ItemImageTypeException.java | 6 +- .../item/ItemNotAvailableException.java | 6 +- .../exception/item/ItemNotFoundException.java | 6 +- .../item/ItemNotPurchasableException.java | 6 +- .../exception/item/ItemTypeException.java | 6 +- .../exception/item/KakaoGiftException.java | 6 +- .../item/KakaoPurchaseException.java | 6 +- .../match/EnrolledSlotException.java | 6 +- .../match/LosingTeamNotFoundException.java | 6 +- .../match/OptionInvalidException.java | 6 +- .../exception/match/PastSlotException.java | 6 +- .../match/PenaltyUserSlotException.java | 6 +- .../exception/match/SlotCountException.java | 6 +- .../match/SlotNotFoundException.java | 6 +- .../match/WinningTeamNotFoundException.java | 6 +- .../megaphone/MegaphoneContentException.java | 6 +- .../megaphone/MegaphoneNotFoundException.java | 6 +- .../megaphone/MegaphoneTimeException.java | 6 +- .../noti/SlackJsonParseException.java | 6 +- .../exception/noti/SlackSendException.java | 6 +- .../noti/SlackUserGetFailedException.java | 6 +- .../pchange/PChangeNotExistException.java | 6 +- .../penalty/PenaltyExpiredException.java | 6 +- .../penalty/PenaltyNotFoundException.java | 6 +- .../RedisPenaltyUserNotFoundException.java | 6 +- .../exception/rank/RankNotFoundException.java | 6 +- .../exception/rank/RankUpdateException.java | 6 +- .../rank/RedisDataNotFoundException.java | 6 +- .../receipt/ItemStatusException.java | 6 +- .../receipt/ReceiptNotFoundException.java | 6 +- .../receipt/ReceiptNotOwnerException.java | 6 +- .../season/SeasonForbiddenException.java | 6 +- .../season/SeasonNotFoundException.java | 6 +- .../season/SeasonTimeBeforeException.java | 6 +- .../SlotManagementForbiddenException.java | 6 +- .../SlotManagementNotFoundException.java | 6 +- .../team/TeamIdNotMatchException.java | 6 +- .../exception/team/TeamNotFoundException.java | 6 +- .../exception/tier/TierNotFoundException.java | 6 +- .../TournamentConflictException.java | 6 +- .../TournamentGameNotFoundException.java | 6 +- .../TournamentNotFoundException.java | 6 +- .../tournament/TournamentUpdateException.java | 6 +- .../KakaoOauth2AlreadyExistException.java | 6 +- .../user/KakaoOauth2NotFoundException.java | 6 +- .../user/TokenNotValidException.java | 6 +- .../user/UserAlreadyAttendanceException.java | 6 +- .../user/UserImageLargeException.java | 6 +- .../user/UserImageNullException.java | 6 +- .../user/UserImageTypeException.java | 6 +- .../exception/user/UserNotFoundException.java | 6 +- .../user/UserTextColorException.java | 6 +- .../java/gg}/utils/ItemTestUtils.java | 18 ++-- .../java/gg}/utils/TestDataUtils.java | 92 +++++++++---------- .../gg}/utils/annotation/DataJpaUnitTest.java | 2 +- .../gg}/utils/annotation/IntegrationTest.java | 8 +- .../annotation/IntegrationTestAspect.java | 4 +- .../IntegrationTestWithRedisTransaction.java | 6 +- .../utils/annotation/TestTypeConstant.java | 2 +- .../java/gg}/utils/annotation/UnitTest.java | 2 +- .../gg}/utils/annotation/WebMvcUnitTest.java | 2 +- .../gg}/utils/config/MySQLInitializer.java | 2 +- .../gg}/utils/config/RedisInitializer.java | 2 +- .../gg}/utils/config/TestRedisConfig.java | 2 +- .../java/gg}/utils/dto/GameInfoDto.java | 2 +- settings.gradle | 8 +- 443 files changed, 2019 insertions(+), 2017 deletions(-) rename {gg-pingpong-admin-repo => gg-admin-repo}/build.gradle (86%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/game/GameAdminRepository.java (87%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/game/PChangeAdminRepository.java (70%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/game/PChangeAdminRepositoryCustom.java (61%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/game/PChangeAdminRepositoryCustomImpl.java (89%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/game/TeamAdminRepository.java (65%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/game/TeamUserAdminRepository.java (84%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg/admin}/repo/game/out/GameTeamUser.java (82%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/manage/AdminSlotManagementsRepository.java (89%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/manage/AnnouncementAdminRepository.java (73%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/manage/FeedbackAdminRepository.java (86%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/manage/PenaltyAdminRepository.java (90%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/manage/PenaltyAdminRepositoryCustom.java (84%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/manage/PenaltyAdminRepositoryCustomImpl.java (97%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/manage/PenaltyUserAdminRedisRepository.java (94%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/noti/NotiAdminRepository.java (85%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/noti/NotiAdminRepositoryCustom.java (80%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/noti/NotiAdminRepositoryCustomImpl.java (94%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/season/SeasonAdminRepository.java (95%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/store/CoinPolicyAdminRepository.java (74%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/store/ItemAdminRepository.java (78%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/store/MegaphoneAdminRepository.java (80%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/store/ReceiptAdminRepository.java (80%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/store/ReceiptAdminRepositorySearch.java (85%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/user/UserAdminRepository.java (87%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong => gg-admin-repo/src/main/java/gg}/admin/repo/user/UserImageAdminRepository.java (94%) rename {gg-pingpong-data => gg-data}/build.gradle (81%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/BaseTimeEntity.java (96%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/game/Game.java (91%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/game/PChange.java (93%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/game/Team.java (92%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/game/TeamUser.java (86%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/game/type/Mode.java (94%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/game/type/StatusType.java (95%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/manage/Announcement.java (94%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/manage/Feedback.java (88%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/manage/Penalty.java (90%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/manage/SlotManagement.java (92%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/manage/redis/RedisPenaltyUser.java (97%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/manage/type/FeedbackType.java (94%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/manage/type/PenaltyKey.java (83%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/manage/type/PenaltyType.java (95%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/match/RedisMatchTime.java (92%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/match/RedisMatchUser.java (87%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/match/type/MatchKey.java (94%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/match/type/Option.java (88%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/match/type/SlotStatus.java (94%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/match/type/TournamentMatchStatus.java (91%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/noti/Noti.java (90%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/noti/type/NotiType.java (97%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/rank/Rank.java (93%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/rank/Tier.java (95%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/rank/redis/RankRedis.java (96%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/season/Season.java (97%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/store/CoinHistory.java (94%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/store/CoinPolicy.java (95%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/store/Item.java (96%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/store/Megaphone.java (94%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/store/Receipt.java (95%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/store/redis/MegaphoneRedis.java (95%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/store/type/HistoryType.java (88%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/store/type/ItemStatus.java (88%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/store/type/ItemType.java (80%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/tournament/Tournament.java (92%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/tournament/TournamentGame.java (90%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/tournament/TournamentUser.java (93%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/tournament/type/RoundNumber.java (85%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/tournament/type/TournamentRound.java (93%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/tournament/type/TournamentStatus.java (94%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/tournament/type/TournamentType.java (94%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/tournament/type/TournamentUserStatus.java (88%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/user/User.java (90%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/user/UserImage.java (97%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/user/type/BackgroundType.java (96%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/user/type/EdgeType.java (96%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/user/type/OauthType.java (95%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/user/type/RacketType.java (94%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/user/type/RoleType.java (93%) rename {gg-pingpong-data/src/main/java/gg/pingpong => gg-data/src/main/java/gg}/data/user/type/SnsType.java (92%) rename {gg-pingpong-data/src/test/java/gg/pingpong => gg-data/src/test/java/gg}/data/tournament/TournamentUnitTest.java (97%) rename {gg-pingpong-repo => gg-repo}/build.gradle (86%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/game/GameRepository.java (95%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/game/GameRepositoryCustom.java (64%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/game/GameRepositoryImpl.java (88%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/game/PChangeRepository.java (91%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/game/PChangeRepositoryCustom.java (79%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/game/PChangeRepositoryImpl.java (96%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/game/TeamRepository.java (85%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/game/TeamUserRepository.java (92%) rename {gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin => gg-repo/src/main/java/gg}/repo/game/out/GameTeamUser.java (81%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/game/out/GameTeamUserInfo.java (70%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/game/out/GameUser.java (64%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/manage/AnnouncementRepository.java (74%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/manage/FeedbackRepository.java (70%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/manage/PenaltyRepository.java (66%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/manage/SlotManagementRepository.java (90%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/match/RedisMatchTimeRepository.java (93%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/match/RedisMatchUserRepository.java (89%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/noti/NotiRepository.java (80%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/noti/NotiRepositoryCustom.java (73%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/noti/NotiRepositoryImpl.java (94%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/rank/RankRepository.java (97%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/rank/RankV2Dto.java (85%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/rank/TierRepository.java (84%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/rank/redis/RankRedisRepository.java (97%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/season/SeasonRepository.java (92%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/store/CoinHistoryRepository.java (90%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/store/CoinPolicyRepository.java (75%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/store/ItemRepository.java (83%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/store/MegaphoneRepository.java (71%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/store/ReceiptRepository.java (66%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/store/UserItemRepository.java (89%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/tournarment/TournamentGameRepository.java (78%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/tournarment/TournamentRepository.java (87%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/tournarment/TournamentUserRepository.java (79%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/user/ExpRankV2Dto.java (85%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/user/UserImageRepository.java (70%) rename {gg-pingpong-repo/src/main/java/gg/pingpong => gg-repo/src/main/java/gg}/repo/user/UserRepository.java (96%) rename {gg-pingpong-utils => gg-utils}/build.gradle (77%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/RedisKeyManager.java (94%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/BusinessChecker.java (90%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/ErrorCode.java (99%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/ErrorResponse.java (88%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/announcement/AnnounceDupException.java (53%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/announcement/AnnounceNotFoundException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/coin/CoinHistoryNotFoundException.java (58%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/coin/CoinPolicyNotFoundException.java (57%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/custom/AuthenticationException.java (69%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/custom/BusinessException.java (74%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/custom/CustomRuntimeException.java (81%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/custom/DBConsistencyException.java (69%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/custom/DuplicationException.java (65%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/custom/ExpiredException.java (64%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/custom/FileException.java (63%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/custom/ForbiddenException.java (64%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/custom/InvalidParameterException.java (66%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/custom/NotExistException.java (68%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/custom/PageNotFoundException.java (76%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/custom/ParseException.java (63%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/custom/SendException.java (63%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/feedback/FeedbackNotFoundException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/game/GameAlreadyExistException.java (57%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/game/GameDataConsistencyException.java (56%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/game/GameNotExistException.java (54%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/game/GameStatusNotMatchedException.java (57%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/game/NotRecentlyGameException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/game/ScoreAlreadyEnteredException.java (54%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/game/ScoreNotInvalidException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/game/ScoreNotMatchedException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/item/InsufficientGgcoinException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/item/ItemImageLargeException.java (54%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/item/ItemImageTypeException.java (57%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/item/ItemNotAvailableException.java (56%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/item/ItemNotFoundException.java (53%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/item/ItemNotPurchasableException.java (58%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/item/ItemTypeException.java (54%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/item/KakaoGiftException.java (57%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/item/KakaoPurchaseException.java (58%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/match/EnrolledSlotException.java (53%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/match/LosingTeamNotFoundException.java (57%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/match/OptionInvalidException.java (53%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/match/PastSlotException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/match/PenaltyUserSlotException.java (59%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/match/SlotCountException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/match/SlotNotFoundException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/match/WinningTeamNotFoundException.java (58%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/megaphone/MegaphoneContentException.java (54%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/megaphone/MegaphoneNotFoundException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/megaphone/MegaphoneTimeException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/noti/SlackJsonParseException.java (56%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/noti/SlackSendException.java (52%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/noti/SlackUserGetFailedException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/pchange/PChangeNotExistException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/penalty/PenaltyExpiredException.java (54%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/penalty/PenaltyNotFoundException.java (54%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/penalty/RedisPenaltyUserNotFoundException.java (60%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/rank/RankNotFoundException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/rank/RankUpdateException.java (53%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/rank/RedisDataNotFoundException.java (56%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/receipt/ItemStatusException.java (54%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/receipt/ReceiptNotFoundException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/receipt/ReceiptNotOwnerException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/season/SeasonForbiddenException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/season/SeasonNotFoundException.java (64%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/season/SeasonTimeBeforeException.java (56%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/slotmanagement/SlotManagementForbiddenException.java (58%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/slotmanagement/SlotManagementNotFoundException.java (57%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/team/TeamIdNotMatchException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/team/TeamNotFoundException.java (54%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/tier/TierNotFoundException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/tournament/TournamentConflictException.java (66%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/tournament/TournamentGameNotFoundException.java (58%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/tournament/TournamentNotFoundException.java (66%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/tournament/TournamentUpdateException.java (66%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/user/KakaoOauth2AlreadyExistException.java (56%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/user/KakaoOauth2NotFoundException.java (56%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/user/TokenNotValidException.java (52%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/user/UserAlreadyAttendanceException.java (57%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/user/UserImageLargeException.java (54%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/user/UserImageNullException.java (55%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/user/UserImageTypeException.java (57%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/user/UserNotFoundException.java (53%) rename {gg-pingpong-utils/src/main/java/gg/pingpong => gg-utils/src/main/java/gg}/utils/exception/user/UserTextColorException.java (55%) rename {gg-pingpong-utils/src/testFixtures/java/gg/pingpong => gg-utils/src/testFixtures/java/gg}/utils/ItemTestUtils.java (79%) rename {gg-pingpong-utils/src/testFixtures/java/gg/pingpong => gg-utils/src/testFixtures/java/gg}/utils/TestDataUtils.java (92%) rename {gg-pingpong-utils/src/testFixtures/java/gg/pingpong => gg-utils/src/testFixtures/java/gg}/utils/annotation/DataJpaUnitTest.java (92%) rename {gg-pingpong-utils/src/testFixtures/java/gg/pingpong => gg-utils/src/testFixtures/java/gg}/utils/annotation/IntegrationTest.java (81%) rename {gg-pingpong-utils/src/testFixtures/java/gg/pingpong => gg-utils/src/testFixtures/java/gg}/utils/annotation/IntegrationTestAspect.java (86%) rename {gg-pingpong-utils/src/testFixtures/java/gg/pingpong => gg-utils/src/testFixtures/java/gg}/utils/annotation/IntegrationTestWithRedisTransaction.java (84%) rename {gg-pingpong-utils/src/testFixtures/java/gg/pingpong => gg-utils/src/testFixtures/java/gg}/utils/annotation/TestTypeConstant.java (90%) rename {gg-pingpong-utils/src/testFixtures/java/gg/pingpong => gg-utils/src/testFixtures/java/gg}/utils/annotation/UnitTest.java (93%) rename {gg-pingpong-utils/src/testFixtures/java/gg/pingpong => gg-utils/src/testFixtures/java/gg}/utils/annotation/WebMvcUnitTest.java (92%) rename {gg-pingpong-utils/src/testFixtures/java/gg/pingpong => gg-utils/src/testFixtures/java/gg}/utils/config/MySQLInitializer.java (97%) rename {gg-pingpong-utils/src/testFixtures/java/gg/pingpong => gg-utils/src/testFixtures/java/gg}/utils/config/RedisInitializer.java (96%) rename {gg-pingpong-utils/src/testFixtures/java/gg/pingpong => gg-utils/src/testFixtures/java/gg}/utils/config/TestRedisConfig.java (97%) rename {gg-pingpong-utils/src/testFixtures/java/gg/pingpong => gg-utils/src/testFixtures/java/gg}/utils/dto/GameInfoDto.java (88%) diff --git a/.github/workflows/test-code-validation.yml b/.github/workflows/test-code-validation.yml index 36fb0c0fb..2d4b0468d 100644 --- a/.github/workflows/test-code-validation.yml +++ b/.github/workflows/test-code-validation.yml @@ -30,7 +30,7 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true - files: ./gg-pingpong-utils/build/reports/jacoco/unitTestCoverageReport/unitTestCoverageReport.xml + files: ./gg-utils/build/reports/jacoco/unitTestCoverageReport/unitTestCoverageReport.xml flags: unitTest name: codecov-unit verbose: true @@ -43,7 +43,7 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true - files: ./gg-pingpong-utils/build/reports/jacoco/integrationTestCoverageReport/integrationTestCoverageReport.xml + files: ./gg-utils/build/reports/jacoco/integrationTestCoverageReport/integrationTestCoverageReport.xml flags: integrationTest name: codecov-integration verbose: true diff --git a/build.gradle b/build.gradle index 6991e8f20..fdb0fa7f7 100644 --- a/build.gradle +++ b/build.gradle @@ -239,40 +239,40 @@ project(':gg-pingpong-api') { bootJar { enabled = true } jar { enabled = true } dependencies { - implementation project(':gg-pingpong-data') - implementation project(':gg-pingpong-repo') - implementation project(':gg-pingpong-admin-repo') - implementation project(':gg-pingpong-utils') + implementation project(':gg-data') + implementation project(':gg-repo') + implementation project(':gg-admin-repo') + implementation project(':gg-utils') } } -project(':gg-pingpong-repo') { +project(':gg-repo') { bootJar { enabled = false } jar { enabled = true } dependencies { - implementation project(':gg-pingpong-data') - implementation project(':gg-pingpong-utils') + implementation project(':gg-data') + implementation project(':gg-utils') } } -project(':gg-pingpong-admin-repo') { +project(':gg-admin-repo') { bootJar { enabled = false } jar { enabled = true } dependencies { - implementation project(':gg-pingpong-data') - implementation project(':gg-pingpong-utils') + implementation project(':gg-data') + implementation project(':gg-utils') } } -project(':gg-pingpong-data') { +project(':gg-data') { bootJar { enabled = false } jar { enabled = true } dependencies { - implementation project(':gg-pingpong-utils') + implementation project(':gg-utils') } } -project(':gg-pingpong-utils') { +project(':gg-utils') { bootJar { enabled = false } jar { enabled = true } dependencies { diff --git a/gg-pingpong-admin-repo/build.gradle b/gg-admin-repo/build.gradle similarity index 86% rename from gg-pingpong-admin-repo/build.gradle rename to gg-admin-repo/build.gradle index 1674e3932..e8bceb7da 100644 --- a/gg-pingpong-admin-repo/build.gradle +++ b/gg-admin-repo/build.gradle @@ -17,7 +17,7 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' - testImplementation testFixtures(project(':gg-pingpong-utils')) + testImplementation testFixtures(project(':gg-utils')) } test { diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/GameAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/game/GameAdminRepository.java similarity index 87% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/GameAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/game/GameAdminRepository.java index 76fbd6b28..18efb7a17 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/GameAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/game/GameAdminRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.admin.repo.game; +package gg.admin.repo.game; import java.util.List; import java.util.Optional; @@ -9,11 +9,11 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.admin.repo.game.out.GameTeamUser; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.season.Season; +import gg.admin.repo.game.out.GameTeamUser; +import gg.data.game.Game; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.data.season.Season; public interface GameAdminRepository extends JpaRepository { diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/game/PChangeAdminRepository.java similarity index 70% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/game/PChangeAdminRepository.java index e9a68edb4..fb7e4b362 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/game/PChangeAdminRepository.java @@ -1,8 +1,8 @@ -package gg.pingpong.admin.repo.game; +package gg.admin.repo.game; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.game.PChange; +import gg.data.game.PChange; public interface PChangeAdminRepository extends JpaRepository, PChangeAdminRepositoryCustom { } diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepositoryCustom.java b/gg-admin-repo/src/main/java/gg/admin/repo/game/PChangeAdminRepositoryCustom.java similarity index 61% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepositoryCustom.java rename to gg-admin-repo/src/main/java/gg/admin/repo/game/PChangeAdminRepositoryCustom.java index ac3e7e9c1..afaed7f3b 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepositoryCustom.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/game/PChangeAdminRepositoryCustom.java @@ -1,8 +1,8 @@ -package gg.pingpong.admin.repo.game; +package gg.admin.repo.game; import java.util.List; -import gg.pingpong.data.game.PChange; +import gg.data.game.PChange; public interface PChangeAdminRepositoryCustom { List findByTeamUser(Long userId); diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepositoryCustomImpl.java b/gg-admin-repo/src/main/java/gg/admin/repo/game/PChangeAdminRepositoryCustomImpl.java similarity index 89% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepositoryCustomImpl.java rename to gg-admin-repo/src/main/java/gg/admin/repo/game/PChangeAdminRepositoryCustomImpl.java index 1de405780..a9702a353 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/PChangeAdminRepositoryCustomImpl.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/game/PChangeAdminRepositoryCustomImpl.java @@ -1,11 +1,11 @@ -package gg.pingpong.admin.repo.game; +package gg.admin.repo.game; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.LockModeType; -import gg.pingpong.data.game.PChange; +import gg.data.game.PChange; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/TeamAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/game/TeamAdminRepository.java similarity index 65% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/TeamAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/game/TeamAdminRepository.java index d4b7d97e7..da465572f 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/TeamAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/game/TeamAdminRepository.java @@ -1,11 +1,11 @@ -package gg.pingpong.admin.repo.game; +package gg.admin.repo.game; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.Team; +import gg.data.game.Game; +import gg.data.game.Team; public interface TeamAdminRepository extends JpaRepository { List findAllByGame(Game game); diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/TeamUserAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/game/TeamUserAdminRepository.java similarity index 84% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/TeamUserAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/game/TeamUserAdminRepository.java index def7afa33..7b4750dda 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/TeamUserAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/game/TeamUserAdminRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.admin.repo.game; +package gg.admin.repo.game; import java.util.List; @@ -6,8 +6,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.user.User; +import gg.data.game.TeamUser; +import gg.data.user.User; public interface TeamUserAdminRepository extends JpaRepository { @Query("SELECT tu.user FROM TeamUser tu WHERE tu.team.id = :teamId") diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameTeamUser.java b/gg-admin-repo/src/main/java/gg/admin/repo/game/out/GameTeamUser.java similarity index 82% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameTeamUser.java rename to gg-admin-repo/src/main/java/gg/admin/repo/game/out/GameTeamUser.java index 35c7916f2..60cb599f2 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameTeamUser.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/game/out/GameTeamUser.java @@ -1,9 +1,9 @@ -package gg.pingpong.repo.game.out; +package gg.admin.repo.game.out; import java.time.LocalDateTime; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; public interface GameTeamUser { Long getGameId(); diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/AdminSlotManagementsRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/manage/AdminSlotManagementsRepository.java similarity index 89% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/AdminSlotManagementsRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/manage/AdminSlotManagementsRepository.java index 0666ea175..ebcf52842 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/AdminSlotManagementsRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/manage/AdminSlotManagementsRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.admin.repo.manage; +package gg.admin.repo.manage; import java.time.LocalDateTime; import java.util.List; @@ -8,7 +8,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.manage.SlotManagement; +import gg.data.manage.SlotManagement; public interface AdminSlotManagementsRepository extends JpaRepository { @Query("select slot from SlotManagement slot " diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/AnnouncementAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/manage/AnnouncementAdminRepository.java similarity index 73% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/AnnouncementAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/manage/AnnouncementAdminRepository.java index 19b94298f..4a0419c5d 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/AnnouncementAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/manage/AnnouncementAdminRepository.java @@ -1,10 +1,10 @@ -package gg.pingpong.admin.repo.manage; +package gg.admin.repo.manage; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.manage.Announcement; +import gg.data.manage.Announcement; public interface AnnouncementAdminRepository extends JpaRepository { diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/FeedbackAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/manage/FeedbackAdminRepository.java similarity index 86% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/FeedbackAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/manage/FeedbackAdminRepository.java index a10ba2b63..971298b64 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/FeedbackAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/manage/FeedbackAdminRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.admin.repo.manage; +package gg.admin.repo.manage; import java.util.List; @@ -6,7 +6,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.manage.Feedback; +import gg.data.manage.Feedback; public interface FeedbackAdminRepository extends JpaRepository { @Query(value = "select f from Feedback f join fetch f.user " diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/manage/PenaltyAdminRepository.java similarity index 90% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/manage/PenaltyAdminRepository.java index 7699c3666..442f6c753 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/manage/PenaltyAdminRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.admin.repo.manage; +package gg.admin.repo.manage; import java.time.LocalDateTime; import java.util.List; @@ -10,7 +10,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.manage.Penalty; +import gg.data.manage.Penalty; public interface PenaltyAdminRepository extends JpaRepository, PenaltyAdminRepositoryCustom { @EntityGraph(attributePaths = {"user"}) diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepositoryCustom.java b/gg-admin-repo/src/main/java/gg/admin/repo/manage/PenaltyAdminRepositoryCustom.java similarity index 84% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepositoryCustom.java rename to gg-admin-repo/src/main/java/gg/admin/repo/manage/PenaltyAdminRepositoryCustom.java index 4fb32696c..41a680df3 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepositoryCustom.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/manage/PenaltyAdminRepositoryCustom.java @@ -1,11 +1,11 @@ -package gg.pingpong.admin.repo.manage; +package gg.admin.repo.manage; import java.time.LocalDateTime; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import gg.pingpong.data.manage.Penalty; +import gg.data.manage.Penalty; public interface PenaltyAdminRepositoryCustom { Page findAllCurrent(Pageable pageable, LocalDateTime targetTime); diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepositoryCustomImpl.java b/gg-admin-repo/src/main/java/gg/admin/repo/manage/PenaltyAdminRepositoryCustomImpl.java similarity index 97% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepositoryCustomImpl.java rename to gg-admin-repo/src/main/java/gg/admin/repo/manage/PenaltyAdminRepositoryCustomImpl.java index 1056928fa..c8b934e5e 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyAdminRepositoryCustomImpl.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/manage/PenaltyAdminRepositoryCustomImpl.java @@ -1,4 +1,4 @@ -package gg.pingpong.admin.repo.manage; +package gg.admin.repo.manage; import java.time.LocalDateTime; import java.util.List; @@ -9,7 +9,7 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import gg.pingpong.data.manage.Penalty; +import gg.data.manage.Penalty; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyUserAdminRedisRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/manage/PenaltyUserAdminRedisRepository.java similarity index 94% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyUserAdminRedisRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/manage/PenaltyUserAdminRedisRepository.java index 1edc3f96d..ac0a351f7 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/manage/PenaltyUserAdminRedisRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/manage/PenaltyUserAdminRedisRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.admin.repo.manage; +package gg.admin.repo.manage; import java.time.Duration; import java.time.LocalDateTime; @@ -11,8 +11,8 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; -import gg.pingpong.data.manage.redis.RedisPenaltyUser; -import gg.pingpong.data.manage.type.PenaltyKey; +import gg.data.manage.redis.RedisPenaltyUser; +import gg.data.manage.type.PenaltyKey; import lombok.RequiredArgsConstructor; @Repository diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/noti/NotiAdminRepository.java similarity index 85% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/noti/NotiAdminRepository.java index b6581f917..6e4aec4ba 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/noti/NotiAdminRepository.java @@ -1,11 +1,11 @@ -package gg.pingpong.admin.repo.noti; +package gg.admin.repo.noti; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.noti.Noti; +import gg.data.noti.Noti; public interface NotiAdminRepository extends JpaRepository, NotiAdminRepositoryCustom { diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepositoryCustom.java b/gg-admin-repo/src/main/java/gg/admin/repo/noti/NotiAdminRepositoryCustom.java similarity index 80% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepositoryCustom.java rename to gg-admin-repo/src/main/java/gg/admin/repo/noti/NotiAdminRepositoryCustom.java index bfb54b43f..fbc90aee0 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepositoryCustom.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/noti/NotiAdminRepositoryCustom.java @@ -1,10 +1,10 @@ -package gg.pingpong.admin.repo.noti; +package gg.admin.repo.noti; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.noti.Noti; +import gg.data.noti.Noti; public interface NotiAdminRepositoryCustom { diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepositoryCustomImpl.java b/gg-admin-repo/src/main/java/gg/admin/repo/noti/NotiAdminRepositoryCustomImpl.java similarity index 94% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepositoryCustomImpl.java rename to gg-admin-repo/src/main/java/gg/admin/repo/noti/NotiAdminRepositoryCustomImpl.java index ce01adb85..a41922069 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/noti/NotiAdminRepositoryCustomImpl.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/noti/NotiAdminRepositoryCustomImpl.java @@ -1,4 +1,4 @@ -package gg.pingpong.admin.repo.noti; +package gg.admin.repo.noti; import java.util.List; @@ -8,7 +8,7 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import gg.pingpong.data.noti.Noti; +import gg.data.noti.Noti; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/season/SeasonAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/season/SeasonAdminRepository.java similarity index 95% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/season/SeasonAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/season/SeasonAdminRepository.java index b60655855..7c7a61365 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/season/SeasonAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/season/SeasonAdminRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.admin.repo.season; +package gg.admin.repo.season; import java.time.LocalDateTime; import java.util.List; @@ -9,7 +9,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.season.Season; +import gg.data.season.Season; public interface SeasonAdminRepository extends JpaRepository { /* 입력시간과 모드로 입력시간 이후 가장 가까운 시즌 가져오기 */ diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/CoinPolicyAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/store/CoinPolicyAdminRepository.java similarity index 74% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/CoinPolicyAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/store/CoinPolicyAdminRepository.java index 8374052d4..72fd33f20 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/CoinPolicyAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/store/CoinPolicyAdminRepository.java @@ -1,10 +1,10 @@ -package gg.pingpong.admin.repo.store; +package gg.admin.repo.store; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.store.CoinPolicy; +import gg.data.store.CoinPolicy; public interface CoinPolicyAdminRepository extends JpaRepository { Optional findFirstByOrderByIdDesc(); diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ItemAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/store/ItemAdminRepository.java similarity index 78% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ItemAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/store/ItemAdminRepository.java index b937fb23a..007cf8f02 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ItemAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/store/ItemAdminRepository.java @@ -1,10 +1,10 @@ -package gg.pingpong.admin.repo.store; +package gg.admin.repo.store; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.store.Item; +import gg.data.store.Item; public interface ItemAdminRepository extends JpaRepository { Page findAll(Pageable pageable); diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/MegaphoneAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/store/MegaphoneAdminRepository.java similarity index 80% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/MegaphoneAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/store/MegaphoneAdminRepository.java index 1123e4991..133b024b0 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/MegaphoneAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/store/MegaphoneAdminRepository.java @@ -1,10 +1,10 @@ -package gg.pingpong.admin.repo.store; +package gg.admin.repo.store; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.store.Megaphone; +import gg.data.store.Megaphone; public interface MegaphoneAdminRepository extends JpaRepository { Page findMegaphonesByUserIntraId(String intraId, Pageable pageable); diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ReceiptAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/store/ReceiptAdminRepository.java similarity index 80% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ReceiptAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/store/ReceiptAdminRepository.java index 02c73cc7b..d121c17ae 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ReceiptAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/store/ReceiptAdminRepository.java @@ -1,10 +1,10 @@ -package gg.pingpong.admin.repo.store; +package gg.admin.repo.store; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.store.Receipt; +import gg.data.store.Receipt; public interface ReceiptAdminRepository extends JpaRepository, ReceiptAdminRepositorySearch { Page findAll(Pageable pageable); diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ReceiptAdminRepositorySearch.java b/gg-admin-repo/src/main/java/gg/admin/repo/store/ReceiptAdminRepositorySearch.java similarity index 85% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ReceiptAdminRepositorySearch.java rename to gg-admin-repo/src/main/java/gg/admin/repo/store/ReceiptAdminRepositorySearch.java index 552ca349d..7d24f901e 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/store/ReceiptAdminRepositorySearch.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/store/ReceiptAdminRepositorySearch.java @@ -1,11 +1,11 @@ -package gg.pingpong.admin.repo.store; +package gg.admin.repo.store; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.store.Receipt; +import gg.data.store.Receipt; public interface ReceiptAdminRepositorySearch { @Query(value = "select re from Receipt re where re.purchaserIntraId = :intraId or re.ownerIntraId = :intraId") diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/user/UserAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/user/UserAdminRepository.java similarity index 87% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/user/UserAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/user/UserAdminRepository.java index 601d910cb..b16de379c 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/user/UserAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/user/UserAdminRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.admin.repo.user; +package gg.admin.repo.user; import java.util.Optional; @@ -6,7 +6,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.user.User; +import gg.data.user.User; public interface UserAdminRepository extends JpaRepository { Optional findByIntraId(String intraId); diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/user/UserImageAdminRepository.java b/gg-admin-repo/src/main/java/gg/admin/repo/user/UserImageAdminRepository.java similarity index 94% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/user/UserImageAdminRepository.java rename to gg-admin-repo/src/main/java/gg/admin/repo/user/UserImageAdminRepository.java index 34f17e6c3..9f9162810 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/user/UserImageAdminRepository.java +++ b/gg-admin-repo/src/main/java/gg/admin/repo/user/UserImageAdminRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.admin.repo.user; +package gg.admin.repo.user; import java.util.Optional; @@ -8,8 +8,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.UserImage; +import gg.data.user.User; +import gg.data.user.UserImage; public interface UserImageAdminRepository extends JpaRepository { Optional findTopByUserAndIsCurrentIsTrueOrderByCreatedAtDesc(User user); diff --git a/gg-pingpong-data/build.gradle b/gg-data/build.gradle similarity index 81% rename from gg-pingpong-data/build.gradle rename to gg-data/build.gradle index 78311ef9d..bf38c2767 100644 --- a/gg-pingpong-data/build.gradle +++ b/gg-data/build.gradle @@ -12,7 +12,7 @@ repositories { dependencies { testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' - testImplementation testFixtures(project(':gg-pingpong-utils')) + testImplementation testFixtures(project(':gg-utils')) } test { diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/BaseTimeEntity.java b/gg-data/src/main/java/gg/data/BaseTimeEntity.java similarity index 96% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/BaseTimeEntity.java rename to gg-data/src/main/java/gg/data/BaseTimeEntity.java index 7e8b59324..ab03615d0 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/BaseTimeEntity.java +++ b/gg-data/src/main/java/gg/data/BaseTimeEntity.java @@ -1,4 +1,4 @@ -package gg.pingpong.data; +package gg.data; import java.time.LocalDateTime; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/game/Game.java b/gg-data/src/main/java/gg/data/game/Game.java similarity index 91% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/game/Game.java rename to gg-data/src/main/java/gg/data/game/Game.java index 5cdabf6ca..2799d9d40 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/game/Game.java +++ b/gg-data/src/main/java/gg/data/game/Game.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.game; +package gg.data.game; import java.time.LocalDateTime; import java.util.ArrayList; @@ -20,11 +20,11 @@ import org.hibernate.annotations.DynamicUpdate; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.season.Season; -import gg.pingpong.utils.exception.BusinessChecker; -import gg.pingpong.utils.exception.ErrorCode; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.data.season.Season; +import gg.utils.exception.BusinessChecker; +import gg.utils.exception.ErrorCode; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/game/PChange.java b/gg-data/src/main/java/gg/data/game/PChange.java similarity index 93% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/game/PChange.java rename to gg-data/src/main/java/gg/data/game/PChange.java index 14950b420..e1de0dda3 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/game/PChange.java +++ b/gg-data/src/main/java/gg/data/game/PChange.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.game; +package gg.data.game; import javax.persistence.Column; import javax.persistence.Entity; @@ -10,8 +10,8 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import gg.pingpong.data.BaseTimeEntity; -import gg.pingpong.data.user.User; +import gg.data.BaseTimeEntity; +import gg.data.user.User; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/game/Team.java b/gg-data/src/main/java/gg/data/game/Team.java similarity index 92% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/game/Team.java rename to gg-data/src/main/java/gg/data/game/Team.java index 04ffeb391..454f0ade7 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/game/Team.java +++ b/gg-data/src/main/java/gg/data/game/Team.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.game; +package gg.data.game; import java.util.ArrayList; import java.util.List; @@ -17,8 +17,8 @@ import org.hibernate.annotations.DynamicUpdate; -import gg.pingpong.utils.exception.BusinessChecker; -import gg.pingpong.utils.exception.ErrorCode; +import gg.utils.exception.BusinessChecker; +import gg.utils.exception.ErrorCode; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/game/TeamUser.java b/gg-data/src/main/java/gg/data/game/TeamUser.java similarity index 86% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/game/TeamUser.java rename to gg-data/src/main/java/gg/data/game/TeamUser.java index a6144859a..525e39351 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/game/TeamUser.java +++ b/gg-data/src/main/java/gg/data/game/TeamUser.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.game; +package gg.data.game; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -9,9 +9,9 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import gg.pingpong.data.user.User; -import gg.pingpong.utils.exception.BusinessChecker; -import gg.pingpong.utils.exception.ErrorCode; +import gg.data.user.User; +import gg.utils.exception.BusinessChecker; +import gg.utils.exception.ErrorCode; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/game/type/Mode.java b/gg-data/src/main/java/gg/data/game/type/Mode.java similarity index 94% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/game/type/Mode.java rename to gg-data/src/main/java/gg/data/game/type/Mode.java index 40010f2ad..bd0b05954 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/game/type/Mode.java +++ b/gg-data/src/main/java/gg/data/game/type/Mode.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.game.type; +package gg.data.game.type; import java.util.Locale; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/game/type/StatusType.java b/gg-data/src/main/java/gg/data/game/type/StatusType.java similarity index 95% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/game/type/StatusType.java rename to gg-data/src/main/java/gg/data/game/type/StatusType.java index a6877703f..78bef3fd9 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/game/type/StatusType.java +++ b/gg-data/src/main/java/gg/data/game/type/StatusType.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.game.type; +package gg.data.game.type; import java.util.Locale; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Announcement.java b/gg-data/src/main/java/gg/data/manage/Announcement.java similarity index 94% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Announcement.java rename to gg-data/src/main/java/gg/data/manage/Announcement.java index 0518942a9..976819c15 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Announcement.java +++ b/gg-data/src/main/java/gg/data/manage/Announcement.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.manage; +package gg.data.manage; import java.time.LocalDateTime; @@ -9,7 +9,7 @@ import javax.persistence.Id; import javax.validation.constraints.NotNull; -import gg.pingpong.data.BaseTimeEntity; +import gg.data.BaseTimeEntity; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Feedback.java b/gg-data/src/main/java/gg/data/manage/Feedback.java similarity index 88% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Feedback.java rename to gg-data/src/main/java/gg/data/manage/Feedback.java index 2da52cf37..5dd721dc1 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Feedback.java +++ b/gg-data/src/main/java/gg/data/manage/Feedback.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.manage; +package gg.data.manage; import javax.persistence.Column; import javax.persistence.Entity; @@ -12,9 +12,9 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import gg.pingpong.data.BaseTimeEntity; -import gg.pingpong.data.manage.type.FeedbackType; -import gg.pingpong.data.user.User; +import gg.data.BaseTimeEntity; +import gg.data.manage.type.FeedbackType; +import gg.data.user.User; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Penalty.java b/gg-data/src/main/java/gg/data/manage/Penalty.java similarity index 90% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Penalty.java rename to gg-data/src/main/java/gg/data/manage/Penalty.java index d7b57f1f6..17f4baf58 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/Penalty.java +++ b/gg-data/src/main/java/gg/data/manage/Penalty.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.manage; +package gg.data.manage; import java.time.LocalDateTime; @@ -14,9 +14,9 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import gg.pingpong.data.BaseTimeEntity; -import gg.pingpong.data.manage.type.PenaltyType; -import gg.pingpong.data.user.User; +import gg.data.BaseTimeEntity; +import gg.data.manage.type.PenaltyType; +import gg.data.user.User; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/SlotManagement.java b/gg-data/src/main/java/gg/data/manage/SlotManagement.java similarity index 92% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/manage/SlotManagement.java rename to gg-data/src/main/java/gg/data/manage/SlotManagement.java index bf0abd874..2ac1382ff 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/SlotManagement.java +++ b/gg-data/src/main/java/gg/data/manage/SlotManagement.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.manage; +package gg.data.manage; import java.time.LocalDateTime; @@ -9,8 +9,8 @@ import javax.persistence.Id; import javax.validation.constraints.NotNull; -import gg.pingpong.data.BaseTimeEntity; -import gg.pingpong.utils.exception.slotmanagement.SlotManagementForbiddenException; +import gg.data.BaseTimeEntity; +import gg.utils.exception.slotmanagement.SlotManagementForbiddenException; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/redis/RedisPenaltyUser.java b/gg-data/src/main/java/gg/data/manage/redis/RedisPenaltyUser.java similarity index 97% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/manage/redis/RedisPenaltyUser.java rename to gg-data/src/main/java/gg/data/manage/redis/RedisPenaltyUser.java index 904b222cb..fbbe906cd 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/redis/RedisPenaltyUser.java +++ b/gg-data/src/main/java/gg/data/manage/redis/RedisPenaltyUser.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.manage.redis; +package gg.data.manage.redis; import java.time.LocalDateTime; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/FeedbackType.java b/gg-data/src/main/java/gg/data/manage/type/FeedbackType.java similarity index 94% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/FeedbackType.java rename to gg-data/src/main/java/gg/data/manage/type/FeedbackType.java index c5281c5e2..5a3292bc9 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/FeedbackType.java +++ b/gg-data/src/main/java/gg/data/manage/type/FeedbackType.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.manage.type; +package gg.data.manage.type; import java.util.Locale; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/PenaltyKey.java b/gg-data/src/main/java/gg/data/manage/type/PenaltyKey.java similarity index 83% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/PenaltyKey.java rename to gg-data/src/main/java/gg/data/manage/type/PenaltyKey.java index 3f367a3c4..5a9368832 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/PenaltyKey.java +++ b/gg-data/src/main/java/gg/data/manage/type/PenaltyKey.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.manage.type; +package gg.data.manage.type; public class PenaltyKey { public static final String ALL = "PENALTY:"; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/PenaltyType.java b/gg-data/src/main/java/gg/data/manage/type/PenaltyType.java similarity index 95% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/PenaltyType.java rename to gg-data/src/main/java/gg/data/manage/type/PenaltyType.java index 4b3a86e97..037632693 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/manage/type/PenaltyType.java +++ b/gg-data/src/main/java/gg/data/manage/type/PenaltyType.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.manage.type; +package gg.data.manage.type; import java.util.Arrays; import java.util.Locale; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/match/RedisMatchTime.java b/gg-data/src/main/java/gg/data/match/RedisMatchTime.java similarity index 92% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/match/RedisMatchTime.java rename to gg-data/src/main/java/gg/data/match/RedisMatchTime.java index b31096506..10e8a5a03 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/match/RedisMatchTime.java +++ b/gg-data/src/main/java/gg/data/match/RedisMatchTime.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.match; +package gg.data.match; import java.io.Serializable; import java.time.LocalDateTime; @@ -12,7 +12,7 @@ import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import gg.pingpong.data.match.type.Option; +import gg.data.match.type.Option; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/match/RedisMatchUser.java b/gg-data/src/main/java/gg/data/match/RedisMatchUser.java similarity index 87% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/match/RedisMatchUser.java rename to gg-data/src/main/java/gg/data/match/RedisMatchUser.java index 191b21ab6..b76350975 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/match/RedisMatchUser.java +++ b/gg-data/src/main/java/gg/data/match/RedisMatchUser.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.match; +package gg.data.match; import java.io.Serializable; @@ -6,7 +6,7 @@ import org.springframework.data.redis.core.RedisHash; -import gg.pingpong.data.match.type.Option; +import gg.data.match.type.Option; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/MatchKey.java b/gg-data/src/main/java/gg/data/match/type/MatchKey.java similarity index 94% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/MatchKey.java rename to gg-data/src/main/java/gg/data/match/type/MatchKey.java index 33123f76b..78f3fbd0f 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/MatchKey.java +++ b/gg-data/src/main/java/gg/data/match/type/MatchKey.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.match.type; +package gg.data.match.type; import java.time.LocalDateTime; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/Option.java b/gg-data/src/main/java/gg/data/match/type/Option.java similarity index 88% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/Option.java rename to gg-data/src/main/java/gg/data/match/type/Option.java index faad1359b..a5f6225f0 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/Option.java +++ b/gg-data/src/main/java/gg/data/match/type/Option.java @@ -1,10 +1,10 @@ -package gg.pingpong.data.match.type; +package gg.data.match.type; import java.util.Locale; import com.fasterxml.jackson.annotation.JsonCreator; -import gg.pingpong.utils.exception.match.OptionInvalidException; +import gg.utils.exception.match.OptionInvalidException; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/SlotStatus.java b/gg-data/src/main/java/gg/data/match/type/SlotStatus.java similarity index 94% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/SlotStatus.java rename to gg-data/src/main/java/gg/data/match/type/SlotStatus.java index 6f3146822..e2aca1604 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/SlotStatus.java +++ b/gg-data/src/main/java/gg/data/match/type/SlotStatus.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.match.type; +package gg.data.match.type; import java.util.Locale; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/TournamentMatchStatus.java b/gg-data/src/main/java/gg/data/match/type/TournamentMatchStatus.java similarity index 91% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/TournamentMatchStatus.java rename to gg-data/src/main/java/gg/data/match/type/TournamentMatchStatus.java index 96faabeb5..24602a660 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/match/type/TournamentMatchStatus.java +++ b/gg-data/src/main/java/gg/data/match/type/TournamentMatchStatus.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.match.type; +package gg.data.match.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/noti/Noti.java b/gg-data/src/main/java/gg/data/noti/Noti.java similarity index 90% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/noti/Noti.java rename to gg-data/src/main/java/gg/data/noti/Noti.java index 5e47ac52e..043f353ae 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/noti/Noti.java +++ b/gg-data/src/main/java/gg/data/noti/Noti.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.noti; +package gg.data.noti; import javax.persistence.Column; import javax.persistence.Entity; @@ -12,9 +12,9 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import gg.pingpong.data.BaseTimeEntity; -import gg.pingpong.data.noti.type.NotiType; -import gg.pingpong.data.user.User; +import gg.data.BaseTimeEntity; +import gg.data.noti.type.NotiType; +import gg.data.user.User; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/noti/type/NotiType.java b/gg-data/src/main/java/gg/data/noti/type/NotiType.java similarity index 97% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/noti/type/NotiType.java rename to gg-data/src/main/java/gg/data/noti/type/NotiType.java index 3a98598ec..5c83e8390 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/noti/type/NotiType.java +++ b/gg-data/src/main/java/gg/data/noti/type/NotiType.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.noti.type; +package gg.data.noti.type; import java.util.Arrays; import java.util.Locale; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/rank/Rank.java b/gg-data/src/main/java/gg/data/rank/Rank.java similarity index 93% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/rank/Rank.java rename to gg-data/src/main/java/gg/data/rank/Rank.java index 2e97a383c..6dc0ed4a4 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/rank/Rank.java +++ b/gg-data/src/main/java/gg/data/rank/Rank.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.rank; +package gg.data.rank; import java.io.Serializable; @@ -15,9 +15,9 @@ import org.hibernate.annotations.DynamicUpdate; -import gg.pingpong.data.BaseTimeEntity; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; +import gg.data.BaseTimeEntity; +import gg.data.season.Season; +import gg.data.user.User; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/rank/Tier.java b/gg-data/src/main/java/gg/data/rank/Tier.java similarity index 95% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/rank/Tier.java rename to gg-data/src/main/java/gg/data/rank/Tier.java index 996c40396..ea26be3b9 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/rank/Tier.java +++ b/gg-data/src/main/java/gg/data/rank/Tier.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.rank; +package gg.data.rank; import java.io.Serializable; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/rank/redis/RankRedis.java b/gg-data/src/main/java/gg/data/rank/redis/RankRedis.java similarity index 96% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/rank/redis/RankRedis.java rename to gg-data/src/main/java/gg/data/rank/redis/RankRedis.java index e56cf40b1..29fbfb5fa 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/rank/redis/RankRedis.java +++ b/gg-data/src/main/java/gg/data/rank/redis/RankRedis.java @@ -1,10 +1,10 @@ -package gg.pingpong.data.rank.redis; +package gg.data.rank.redis; import java.io.Serializable; import org.springframework.data.redis.core.RedisHash; -import gg.pingpong.data.rank.Rank; +import gg.data.rank.Rank; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/season/Season.java b/gg-data/src/main/java/gg/data/season/Season.java similarity index 97% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/season/Season.java rename to gg-data/src/main/java/gg/data/season/Season.java index 2f3b528ad..ceffb0d78 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/season/Season.java +++ b/gg-data/src/main/java/gg/data/season/Season.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.season; +package gg.data.season; import java.time.LocalDateTime; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/CoinHistory.java b/gg-data/src/main/java/gg/data/store/CoinHistory.java similarity index 94% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/store/CoinHistory.java rename to gg-data/src/main/java/gg/data/store/CoinHistory.java index b7eac63e7..b1e3b731c 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/CoinHistory.java +++ b/gg-data/src/main/java/gg/data/store/CoinHistory.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.store; +package gg.data.store; import java.time.LocalDateTime; @@ -13,7 +13,7 @@ import org.springframework.data.annotation.CreatedDate; -import gg.pingpong.data.user.User; +import gg.data.user.User; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/CoinPolicy.java b/gg-data/src/main/java/gg/data/store/CoinPolicy.java similarity index 95% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/store/CoinPolicy.java rename to gg-data/src/main/java/gg/data/store/CoinPolicy.java index 487572915..57bb6a20d 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/CoinPolicy.java +++ b/gg-data/src/main/java/gg/data/store/CoinPolicy.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.store; +package gg.data.store; import java.time.LocalDateTime; @@ -13,7 +13,7 @@ import org.springframework.data.annotation.CreatedDate; -import gg.pingpong.data.user.User; +import gg.data.user.User; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/Item.java b/gg-data/src/main/java/gg/data/store/Item.java similarity index 96% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/store/Item.java rename to gg-data/src/main/java/gg/data/store/Item.java index 16bea6da7..4220eefa7 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/Item.java +++ b/gg-data/src/main/java/gg/data/store/Item.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.store; +package gg.data.store; import java.time.LocalDateTime; @@ -11,7 +11,7 @@ import javax.persistence.Id; import javax.validation.constraints.NotNull; -import gg.pingpong.data.store.type.ItemType; +import gg.data.store.type.ItemType; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/Megaphone.java b/gg-data/src/main/java/gg/data/store/Megaphone.java similarity index 94% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/store/Megaphone.java rename to gg-data/src/main/java/gg/data/store/Megaphone.java index e648c8727..6d2a82de3 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/Megaphone.java +++ b/gg-data/src/main/java/gg/data/store/Megaphone.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.store; +package gg.data.store; import java.time.LocalDate; @@ -12,7 +12,7 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import gg.pingpong.data.user.User; +import gg.data.user.User; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/Receipt.java b/gg-data/src/main/java/gg/data/store/Receipt.java similarity index 95% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/store/Receipt.java rename to gg-data/src/main/java/gg/data/store/Receipt.java index a41715200..d5d40cdad 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/Receipt.java +++ b/gg-data/src/main/java/gg/data/store/Receipt.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.store; +package gg.data.store; import java.time.LocalDateTime; @@ -14,7 +14,7 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import gg.pingpong.data.store.type.ItemStatus; +import gg.data.store.type.ItemStatus; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/redis/MegaphoneRedis.java b/gg-data/src/main/java/gg/data/store/redis/MegaphoneRedis.java similarity index 95% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/store/redis/MegaphoneRedis.java rename to gg-data/src/main/java/gg/data/store/redis/MegaphoneRedis.java index abe63aebb..36c922012 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/redis/MegaphoneRedis.java +++ b/gg-data/src/main/java/gg/data/store/redis/MegaphoneRedis.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.store.redis; +package gg.data.store.redis; import java.time.LocalDateTime; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/HistoryType.java b/gg-data/src/main/java/gg/data/store/type/HistoryType.java similarity index 88% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/HistoryType.java rename to gg-data/src/main/java/gg/data/store/type/HistoryType.java index af06808f8..9a1ba6c83 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/HistoryType.java +++ b/gg-data/src/main/java/gg/data/store/type/HistoryType.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.store.type; +package gg.data.store.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/ItemStatus.java b/gg-data/src/main/java/gg/data/store/type/ItemStatus.java similarity index 88% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/ItemStatus.java rename to gg-data/src/main/java/gg/data/store/type/ItemStatus.java index 384a2c6da..31c47a1b7 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/ItemStatus.java +++ b/gg-data/src/main/java/gg/data/store/type/ItemStatus.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.store.type; +package gg.data.store.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/ItemType.java b/gg-data/src/main/java/gg/data/store/type/ItemType.java similarity index 80% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/ItemType.java rename to gg-data/src/main/java/gg/data/store/type/ItemType.java index dd75871f9..920ab5d3a 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/store/type/ItemType.java +++ b/gg-data/src/main/java/gg/data/store/type/ItemType.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.store.type; +package gg.data.store.type; import lombok.RequiredArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/Tournament.java b/gg-data/src/main/java/gg/data/tournament/Tournament.java similarity index 92% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/Tournament.java rename to gg-data/src/main/java/gg/data/tournament/Tournament.java index bda096543..38b976fdb 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/Tournament.java +++ b/gg-data/src/main/java/gg/data/tournament/Tournament.java @@ -1,7 +1,7 @@ -package gg.pingpong.data.tournament; +package gg.data.tournament; -import static gg.pingpong.utils.exception.BusinessChecker.*; -import static gg.pingpong.utils.exception.ErrorCode.*; +import static gg.utils.exception.BusinessChecker.*; +import static gg.utils.exception.ErrorCode.*; import java.time.LocalDateTime; import java.util.ArrayList; @@ -22,10 +22,10 @@ import javax.persistence.OneToOne; import javax.validation.constraints.NotNull; -import gg.pingpong.data.BaseTimeEntity; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; -import gg.pingpong.data.user.User; +import gg.data.BaseTimeEntity; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; +import gg.data.user.User; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/TournamentGame.java b/gg-data/src/main/java/gg/data/tournament/TournamentGame.java similarity index 90% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/TournamentGame.java rename to gg-data/src/main/java/gg/data/tournament/TournamentGame.java index b8693f31c..c2d2166e5 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/TournamentGame.java +++ b/gg-data/src/main/java/gg/data/tournament/TournamentGame.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.tournament; +package gg.data.tournament; import javax.persistence.Column; import javax.persistence.Entity; @@ -13,9 +13,9 @@ import javax.persistence.OneToOne; import javax.validation.constraints.NotNull; -import gg.pingpong.data.BaseTimeEntity; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.tournament.type.TournamentRound; +import gg.data.BaseTimeEntity; +import gg.data.game.Game; +import gg.data.tournament.type.TournamentRound; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/TournamentUser.java b/gg-data/src/main/java/gg/data/tournament/TournamentUser.java similarity index 93% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/TournamentUser.java rename to gg-data/src/main/java/gg/data/tournament/TournamentUser.java index dcb29391b..2e7a7ef27 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/TournamentUser.java +++ b/gg-data/src/main/java/gg/data/tournament/TournamentUser.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.tournament; +package gg.data.tournament; import java.time.LocalDateTime; @@ -12,8 +12,8 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import gg.pingpong.data.BaseTimeEntity; -import gg.pingpong.data.user.User; +import gg.data.BaseTimeEntity; +import gg.data.user.User; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/RoundNumber.java b/gg-data/src/main/java/gg/data/tournament/type/RoundNumber.java similarity index 85% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/RoundNumber.java rename to gg-data/src/main/java/gg/data/tournament/type/RoundNumber.java index 177909f87..ecbd44897 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/RoundNumber.java +++ b/gg-data/src/main/java/gg/data/tournament/type/RoundNumber.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.tournament.type; +package gg.data.tournament.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentRound.java b/gg-data/src/main/java/gg/data/tournament/type/TournamentRound.java similarity index 93% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentRound.java rename to gg-data/src/main/java/gg/data/tournament/type/TournamentRound.java index 3fd46e156..8b868cb00 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentRound.java +++ b/gg-data/src/main/java/gg/data/tournament/type/TournamentRound.java @@ -1,6 +1,6 @@ -package gg.pingpong.data.tournament.type; +package gg.data.tournament.type; -import static gg.pingpong.data.tournament.type.RoundNumber.*; +import static gg.data.tournament.type.RoundNumber.*; import java.util.ArrayList; import java.util.List; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentStatus.java b/gg-data/src/main/java/gg/data/tournament/type/TournamentStatus.java similarity index 94% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentStatus.java rename to gg-data/src/main/java/gg/data/tournament/type/TournamentStatus.java index ef7416125..02ba48893 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentStatus.java +++ b/gg-data/src/main/java/gg/data/tournament/type/TournamentStatus.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.tournament.type; +package gg.data.tournament.type; import java.util.Locale; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentType.java b/gg-data/src/main/java/gg/data/tournament/type/TournamentType.java similarity index 94% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentType.java rename to gg-data/src/main/java/gg/data/tournament/type/TournamentType.java index b424dbf22..276830c5d 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentType.java +++ b/gg-data/src/main/java/gg/data/tournament/type/TournamentType.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.tournament.type; +package gg.data.tournament.type; import java.util.Locale; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentUserStatus.java b/gg-data/src/main/java/gg/data/tournament/type/TournamentUserStatus.java similarity index 88% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentUserStatus.java rename to gg-data/src/main/java/gg/data/tournament/type/TournamentUserStatus.java index 8ab078e42..2ef930740 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/tournament/type/TournamentUserStatus.java +++ b/gg-data/src/main/java/gg/data/tournament/type/TournamentUserStatus.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.tournament.type; +package gg.data.tournament.type; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/User.java b/gg-data/src/main/java/gg/data/user/User.java similarity index 90% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/user/User.java rename to gg-data/src/main/java/gg/data/user/User.java index dd80e6962..b1a71662c 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/User.java +++ b/gg-data/src/main/java/gg/data/user/User.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.user; +package gg.data.user; import java.io.Serializable; @@ -13,13 +13,13 @@ import org.hibernate.annotations.DynamicUpdate; -import gg.pingpong.data.BaseTimeEntity; -import gg.pingpong.data.user.type.BackgroundType; -import gg.pingpong.data.user.type.EdgeType; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.utils.exception.item.InsufficientGgcoinException; +import gg.data.BaseTimeEntity; +import gg.data.user.type.BackgroundType; +import gg.data.user.type.EdgeType; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; +import gg.utils.exception.item.InsufficientGgcoinException; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/UserImage.java b/gg-data/src/main/java/gg/data/user/UserImage.java similarity index 97% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/user/UserImage.java rename to gg-data/src/main/java/gg/data/user/UserImage.java index adb6f2ba7..ad4b2675a 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/UserImage.java +++ b/gg-data/src/main/java/gg/data/user/UserImage.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.user; +package gg.data.user; import java.time.LocalDateTime; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/BackgroundType.java b/gg-data/src/main/java/gg/data/user/type/BackgroundType.java similarity index 96% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/BackgroundType.java rename to gg-data/src/main/java/gg/data/user/type/BackgroundType.java index ef6c72b18..135c53626 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/BackgroundType.java +++ b/gg-data/src/main/java/gg/data/user/type/BackgroundType.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.user.type; +package gg.data.user.type; import java.util.Random; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/EdgeType.java b/gg-data/src/main/java/gg/data/user/type/EdgeType.java similarity index 96% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/EdgeType.java rename to gg-data/src/main/java/gg/data/user/type/EdgeType.java index c09221e14..6a6283875 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/EdgeType.java +++ b/gg-data/src/main/java/gg/data/user/type/EdgeType.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.user.type; +package gg.data.user.type; import java.util.Random; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/OauthType.java b/gg-data/src/main/java/gg/data/user/type/OauthType.java similarity index 95% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/OauthType.java rename to gg-data/src/main/java/gg/data/user/type/OauthType.java index 103fa4311..a41d16c5a 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/OauthType.java +++ b/gg-data/src/main/java/gg/data/user/type/OauthType.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.user.type; +package gg.data.user.type; import java.util.Locale; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/RacketType.java b/gg-data/src/main/java/gg/data/user/type/RacketType.java similarity index 94% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/RacketType.java rename to gg-data/src/main/java/gg/data/user/type/RacketType.java index ec2785bc0..baae5e934 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/RacketType.java +++ b/gg-data/src/main/java/gg/data/user/type/RacketType.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.user.type; +package gg.data.user.type; import java.util.Locale; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/RoleType.java b/gg-data/src/main/java/gg/data/user/type/RoleType.java similarity index 93% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/RoleType.java rename to gg-data/src/main/java/gg/data/user/type/RoleType.java index 430056ffa..f4a5e11c5 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/RoleType.java +++ b/gg-data/src/main/java/gg/data/user/type/RoleType.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.user.type; +package gg.data.user.type; import java.util.Arrays; diff --git a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/SnsType.java b/gg-data/src/main/java/gg/data/user/type/SnsType.java similarity index 92% rename from gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/SnsType.java rename to gg-data/src/main/java/gg/data/user/type/SnsType.java index 52cccb283..e5c7fb036 100644 --- a/gg-pingpong-data/src/main/java/gg/pingpong/data/user/type/SnsType.java +++ b/gg-data/src/main/java/gg/data/user/type/SnsType.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.user.type; +package gg.data.user.type; import java.util.Arrays; diff --git a/gg-pingpong-data/src/test/java/gg/pingpong/data/tournament/TournamentUnitTest.java b/gg-data/src/test/java/gg/data/tournament/TournamentUnitTest.java similarity index 97% rename from gg-pingpong-data/src/test/java/gg/pingpong/data/tournament/TournamentUnitTest.java rename to gg-data/src/test/java/gg/data/tournament/TournamentUnitTest.java index 5775af7a3..555bc1bde 100644 --- a/gg-pingpong-data/src/test/java/gg/pingpong/data/tournament/TournamentUnitTest.java +++ b/gg-data/src/test/java/gg/data/tournament/TournamentUnitTest.java @@ -1,4 +1,4 @@ -package gg.pingpong.data.tournament; +package gg.data.tournament; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; @@ -16,12 +16,12 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; -import gg.pingpong.data.user.User; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; +import gg.data.user.User; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; @UnitTest @DisplayName("TournamentUnitTest") diff --git a/gg-pingpong-api/build.gradle b/gg-pingpong-api/build.gradle index d926ad787..9edc92c20 100644 --- a/gg-pingpong-api/build.gradle +++ b/gg-pingpong-api/build.gradle @@ -2,7 +2,7 @@ plugins { id 'java' } -group 'gg.pingpong.api' +group 'gg.api' version '42gg' repositories { @@ -45,7 +45,7 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' - testImplementation testFixtures(project(':gg-pingpong-utils')) + testImplementation testFixtures(project(':gg-utils')) } test { diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/PingpongApiApplication.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/PingpongApiApplication.java index 5ed8ac248..468f1ac8b 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/PingpongApiApplication.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/PingpongApiApplication.java @@ -3,8 +3,8 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication(scanBasePackages = {"gg.pingpong.admin.repo", "gg.pingpong.data", "gg.pingpong.repo", - "gg.pingpong.api", "gg.pingpong.utils"}) +@SpringBootApplication(scanBasePackages = {"gg.admin.repo", "gg.data", "gg.repo", + "gg.pingpong.api", "gg.utils"}) public class PingpongApiApplication { public static void main(String[] args) { diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/controller/GameAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/controller/GameAdminController.java index 0beadf359..3391d8cb1 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/controller/GameAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/controller/GameAdminController.java @@ -22,8 +22,8 @@ import gg.pingpong.api.admin.game.service.GameAdminService; import gg.pingpong.api.global.dto.PageRequestDto; import gg.pingpong.api.user.rank.redis.RankRedisService; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.InvalidParameterException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.InvalidParameterException; import lombok.RequiredArgsConstructor; @RestController diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/GameLogAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/GameLogAdminDto.java index b5615e6fb..52f622d4c 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/GameLogAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/dto/GameLogAdminDto.java @@ -3,8 +3,8 @@ import java.time.Duration; import java.time.LocalDateTime; -import gg.pingpong.admin.repo.game.out.GameTeamUser; -import gg.pingpong.data.game.type.StatusType; +import gg.admin.repo.game.out.GameTeamUser; +import gg.data.game.type.StatusType; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/service/GameAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/service/GameAdminService.java index 0bc773a13..26e581a1d 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/service/GameAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/game/service/GameAdminService.java @@ -14,12 +14,20 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.admin.repo.game.GameAdminRepository; -import gg.pingpong.admin.repo.game.PChangeAdminRepository; -import gg.pingpong.admin.repo.game.TeamUserAdminRepository; -import gg.pingpong.admin.repo.game.out.GameTeamUser; -import gg.pingpong.admin.repo.season.SeasonAdminRepository; -import gg.pingpong.admin.repo.user.UserAdminRepository; +import gg.admin.repo.game.GameAdminRepository; +import gg.admin.repo.game.PChangeAdminRepository; +import gg.admin.repo.game.TeamUserAdminRepository; +import gg.admin.repo.game.out.GameTeamUser; +import gg.admin.repo.season.SeasonAdminRepository; +import gg.admin.repo.user.UserAdminRepository; +import gg.data.game.Game; +import gg.data.game.PChange; +import gg.data.game.TeamUser; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.user.User; import gg.pingpong.api.admin.game.controller.response.GameLogListAdminResponseDto; import gg.pingpong.api.admin.game.dto.GameLogAdminDto; import gg.pingpong.api.admin.game.dto.RankGamePPPModifyReqDto; @@ -27,21 +35,13 @@ import gg.pingpong.api.user.rank.service.TierService; import gg.pingpong.api.user.season.dto.CurSeason; import gg.pingpong.api.user.season.service.SeasonService; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.PChange; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.PChangeRepository; -import gg.pingpong.repo.match.RedisMatchUserRepository; -import gg.pingpong.utils.exception.game.GameNotExistException; -import gg.pingpong.utils.exception.game.NotRecentlyGameException; -import gg.pingpong.utils.exception.pchange.PChangeNotExistException; -import gg.pingpong.utils.exception.season.SeasonNotFoundException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.game.PChangeRepository; +import gg.repo.match.RedisMatchUserRepository; +import gg.utils.exception.game.GameNotExistException; +import gg.utils.exception.game.NotRecentlyGameException; +import gg.utils.exception.pchange.PChangeNotExistException; +import gg.utils.exception.season.SeasonNotFoundException; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/AnnouncementAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/AnnouncementAdminResponseDto.java index 20395bd6f..4b71bffb3 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/AnnouncementAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/AnnouncementAdminResponseDto.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import gg.pingpong.data.manage.Announcement; +import gg.data.manage.Announcement; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/FeedbackAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/FeedbackAdminResponseDto.java index f0cf5059b..1065e13c6 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/FeedbackAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/FeedbackAdminResponseDto.java @@ -2,8 +2,8 @@ import java.time.LocalDateTime; -import gg.pingpong.data.manage.Feedback; -import gg.pingpong.data.manage.type.FeedbackType; +import gg.data.manage.Feedback; +import gg.data.manage.type.FeedbackType; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/PenaltyUserResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/PenaltyUserResponseDto.java index 97e6d2e81..155620215 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/PenaltyUserResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/controller/response/PenaltyUserResponseDto.java @@ -2,8 +2,8 @@ import java.time.LocalDateTime; -import gg.pingpong.data.manage.Penalty; -import gg.pingpong.data.manage.redis.RedisPenaltyUser; +import gg.data.manage.Penalty; +import gg.data.manage.redis.RedisPenaltyUser; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/dto/SlotAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/dto/SlotAdminDto.java index 346662b89..2fbc5ad5b 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/dto/SlotAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/dto/SlotAdminDto.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import gg.pingpong.data.manage.SlotManagement; +import gg.data.manage.SlotManagement; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/AnnouncementAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/AnnouncementAdminService.java index 5b689d054..7df2a2a4c 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/AnnouncementAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/AnnouncementAdminService.java @@ -7,13 +7,13 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.admin.repo.manage.AnnouncementAdminRepository; +import gg.admin.repo.manage.AnnouncementAdminRepository; +import gg.data.manage.Announcement; import gg.pingpong.api.admin.manage.controller.response.AnnouncementAdminListResponseDto; import gg.pingpong.api.admin.manage.controller.response.AnnouncementAdminResponseDto; import gg.pingpong.api.admin.manage.dto.AnnouncementAdminAddDto; -import gg.pingpong.data.manage.Announcement; -import gg.pingpong.utils.exception.announcement.AnnounceDupException; -import gg.pingpong.utils.exception.announcement.AnnounceNotFoundException; +import gg.utils.exception.announcement.AnnounceDupException; +import gg.utils.exception.announcement.AnnounceNotFoundException; import lombok.AllArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/FeedbackAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/FeedbackAdminService.java index 727593e2a..e2004c3da 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/FeedbackAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/FeedbackAdminService.java @@ -8,11 +8,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.admin.repo.manage.FeedbackAdminRepository; +import gg.admin.repo.manage.FeedbackAdminRepository; +import gg.data.manage.Feedback; import gg.pingpong.api.admin.manage.controller.response.FeedbackAdminResponseDto; import gg.pingpong.api.admin.manage.controller.response.FeedbackListAdminResponseDto; -import gg.pingpong.data.manage.Feedback; -import gg.pingpong.utils.exception.feedback.FeedbackNotFoundException; +import gg.utils.exception.feedback.FeedbackNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/PenaltyAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/PenaltyAdminService.java index 16c3607f1..b98cb933f 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/PenaltyAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/PenaltyAdminService.java @@ -9,18 +9,18 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.admin.repo.manage.PenaltyAdminRepository; -import gg.pingpong.admin.repo.manage.PenaltyUserAdminRedisRepository; +import gg.admin.repo.manage.PenaltyAdminRepository; +import gg.admin.repo.manage.PenaltyUserAdminRedisRepository; +import gg.data.manage.Penalty; +import gg.data.manage.redis.RedisPenaltyUser; +import gg.data.manage.type.PenaltyType; +import gg.data.user.User; import gg.pingpong.api.admin.manage.controller.response.PenaltyListResponseDto; import gg.pingpong.api.admin.manage.controller.response.PenaltyUserResponseDto; import gg.pingpong.api.user.user.service.UserFindService; -import gg.pingpong.data.manage.Penalty; -import gg.pingpong.data.manage.redis.RedisPenaltyUser; -import gg.pingpong.data.manage.type.PenaltyType; -import gg.pingpong.data.user.User; -import gg.pingpong.utils.exception.penalty.PenaltyExpiredException; -import gg.pingpong.utils.exception.penalty.PenaltyNotFoundException; -import gg.pingpong.utils.exception.penalty.RedisPenaltyUserNotFoundException; +import gg.utils.exception.penalty.PenaltyExpiredException; +import gg.utils.exception.penalty.PenaltyNotFoundException; +import gg.utils.exception.penalty.RedisPenaltyUserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/SlotAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/SlotAdminService.java index 267260d1c..fbb735a00 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/SlotAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/manage/service/SlotAdminService.java @@ -7,13 +7,13 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.admin.repo.manage.AdminSlotManagementsRepository; +import gg.admin.repo.manage.AdminSlotManagementsRepository; +import gg.data.manage.SlotManagement; import gg.pingpong.api.admin.manage.controller.request.SlotCreateRequestDto; import gg.pingpong.api.admin.manage.controller.response.SlotListAdminResponseDto; import gg.pingpong.api.admin.manage.dto.SlotAdminDto; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.utils.exception.slotmanagement.SlotManagementForbiddenException; -import gg.pingpong.utils.exception.slotmanagement.SlotManagementNotFoundException; +import gg.utils.exception.slotmanagement.SlotManagementForbiddenException; +import gg.utils.exception.slotmanagement.SlotManagementNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/dto/NotiAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/dto/NotiAdminDto.java index ab153e291..d55960ed4 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/dto/NotiAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/dto/NotiAdminDto.java @@ -3,8 +3,8 @@ import java.time.LocalDateTime; import java.util.Objects; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.noti.type.NotiType; +import gg.data.noti.Noti; +import gg.data.noti.type.NotiType; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/service/NotiAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/service/NotiAdminService.java index 02102ec22..1982e1bc1 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/service/NotiAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/noti/service/NotiAdminService.java @@ -5,17 +5,17 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.admin.repo.noti.NotiAdminRepository; -import gg.pingpong.admin.repo.user.UserAdminRepository; +import gg.admin.repo.noti.NotiAdminRepository; +import gg.admin.repo.user.UserAdminRepository; +import gg.data.noti.Noti; +import gg.data.noti.type.NotiType; +import gg.data.user.User; import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; import gg.pingpong.api.admin.noti.controller.response.NotiListAdminResponseDto; import gg.pingpong.api.admin.noti.dto.NotiAdminDto; import gg.pingpong.api.user.noti.service.SnsNotiService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.noti.type.NotiType; -import gg.pingpong.data.user.User; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.utils.exception.user.UserNotFoundException; import lombok.AllArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/rank/service/RankAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/rank/service/RankAdminService.java index 4b507141c..eef02cdc5 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/rank/service/RankAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/rank/service/RankAdminService.java @@ -1,6 +1,6 @@ package gg.pingpong.api.admin.rank.service; -import static gg.pingpong.data.user.type.RoleType.*; +import static gg.data.user.type.RoleType.*; import java.time.LocalDateTime; import java.util.ArrayList; @@ -9,18 +9,18 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.admin.repo.user.UserAdminRepository; +import gg.admin.repo.user.UserAdminRepository; +import gg.data.rank.Rank; +import gg.data.rank.Tier; +import gg.data.season.Season; +import gg.data.user.User; import gg.pingpong.api.admin.season.dto.SeasonAdminDto; -import gg.pingpong.data.rank.Rank; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.TierRepository; -import gg.pingpong.repo.season.SeasonRepository; -import gg.pingpong.utils.exception.season.SeasonForbiddenException; -import gg.pingpong.utils.exception.season.SeasonTimeBeforeException; -import gg.pingpong.utils.exception.tier.TierNotFoundException; +import gg.repo.rank.RankRepository; +import gg.repo.rank.TierRepository; +import gg.repo.season.SeasonRepository; +import gg.utils.exception.season.SeasonForbiddenException; +import gg.utils.exception.season.SeasonTimeBeforeException; +import gg.utils.exception.tier.TierNotFoundException; import lombok.AllArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/rank/service/RankRedisAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/rank/service/RankRedisAdminService.java index e12e46aa4..1c903d6ad 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/rank/service/RankRedisAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/rank/service/RankRedisAdminService.java @@ -1,21 +1,21 @@ package gg.pingpong.api.admin.rank.service; -import static gg.pingpong.data.user.type.RoleType.*; +import static gg.data.user.type.RoleType.*; import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.rank.Tier; +import gg.data.rank.redis.RankRedis; +import gg.data.user.User; import gg.pingpong.api.admin.season.dto.SeasonAdminDto; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.rank.TierRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.exception.tier.TierNotFoundException; +import gg.repo.rank.TierRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.user.UserRepository; +import gg.utils.RedisKeyManager; +import gg.utils.exception.tier.TierNotFoundException; import lombok.AllArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/request/SeasonCreateRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/request/SeasonCreateRequestDto.java index fbfee0765..484f5a65d 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/request/SeasonCreateRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/controller/request/SeasonCreateRequestDto.java @@ -7,7 +7,7 @@ import org.springframework.format.annotation.DateTimeFormat; -import gg.pingpong.data.season.Season; +import gg.data.season.Season; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/dto/SeasonAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/dto/SeasonAdminDto.java index 3da375a6f..b65c3070d 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/dto/SeasonAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/dto/SeasonAdminDto.java @@ -2,8 +2,8 @@ import java.time.LocalDateTime; +import gg.data.season.Season; import gg.pingpong.api.admin.season.type.SeasonStatus; -import gg.pingpong.data.season.Season; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/service/SeasonAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/service/SeasonAdminService.java index 89e05eeac..639439fe2 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/service/SeasonAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/season/service/SeasonAdminService.java @@ -7,16 +7,16 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.admin.repo.season.SeasonAdminRepository; +import gg.admin.repo.season.SeasonAdminRepository; +import gg.data.season.Season; import gg.pingpong.api.admin.rank.service.RankAdminService; import gg.pingpong.api.admin.rank.service.RankRedisAdminService; import gg.pingpong.api.admin.season.controller.request.SeasonCreateRequestDto; import gg.pingpong.api.admin.season.controller.request.SeasonUpdateRequestDto; import gg.pingpong.api.admin.season.dto.SeasonAdminDto; -import gg.pingpong.data.season.Season; -import gg.pingpong.utils.exception.season.SeasonForbiddenException; -import gg.pingpong.utils.exception.season.SeasonNotFoundException; -import gg.pingpong.utils.exception.season.SeasonTimeBeforeException; +import gg.utils.exception.season.SeasonForbiddenException; +import gg.utils.exception.season.SeasonNotFoundException; +import gg.utils.exception.season.SeasonTimeBeforeException; import lombok.AllArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/ItemAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/ItemAdminController.java index e6a8a1aad..8fa6a208e 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/ItemAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/ItemAdminController.java @@ -26,8 +26,8 @@ import gg.pingpong.api.global.dto.PageRequestDto; import gg.pingpong.api.global.utils.argumentresolver.Login; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.utils.exception.item.ItemImageLargeException; -import gg.pingpong.utils.exception.item.ItemImageTypeException; +import gg.utils.exception.item.ItemImageLargeException; +import gg.utils.exception.item.ItemImageTypeException; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request/ItemUpdateRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request/ItemUpdateRequestDto.java index f899e3d7b..8b48862db 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request/ItemUpdateRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/request/ItemUpdateRequestDto.java @@ -4,8 +4,8 @@ import javax.validation.constraints.NotNull; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.store.type.ItemType; +import gg.data.store.Item; +import gg.data.store.type.ItemType; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/CoinPolicyAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/CoinPolicyAdminResponseDto.java index 295db5445..c6370a3b2 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/CoinPolicyAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/CoinPolicyAdminResponseDto.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import gg.pingpong.data.store.CoinPolicy; +import gg.data.store.CoinPolicy; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ItemHistoryResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ItemHistoryResponseDto.java index e756f39b7..5855e6766 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ItemHistoryResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ItemHistoryResponseDto.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import gg.pingpong.data.store.Item; +import gg.data.store.Item; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/MegaphoneAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/MegaphoneAdminResponseDto.java index 8d7d7ec93..e09f2633a 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/MegaphoneAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/MegaphoneAdminResponseDto.java @@ -1,6 +1,6 @@ package gg.pingpong.api.admin.store.controller.response; -import gg.pingpong.data.store.Megaphone; +import gg.data.store.Megaphone; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ReceiptResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ReceiptResponseDto.java index 0a257d8d8..026f4f448 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ReceiptResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/controller/response/ReceiptResponseDto.java @@ -2,9 +2,9 @@ import java.time.LocalDateTime; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.store.Receipt; -import gg.pingpong.data.store.type.ItemStatus; +import gg.data.store.Item; +import gg.data.store.Receipt; +import gg.data.store.type.ItemStatus; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinAdminService.java index d25c3339f..6a52d9781 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinAdminService.java @@ -3,12 +3,12 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.store.CoinHistory; +import gg.data.user.User; import gg.pingpong.api.admin.store.controller.request.CoinUpdateRequestDto; import gg.pingpong.api.user.store.service.CoinHistoryService; -import gg.pingpong.data.store.CoinHistory; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.user.UserRepository; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinPolicyAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinPolicyAdminService.java index 57157b48a..b0644ae52 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinPolicyAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/CoinPolicyAdminService.java @@ -5,15 +5,15 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.admin.repo.store.CoinPolicyAdminRepository; -import gg.pingpong.admin.repo.user.UserAdminRepository; +import gg.admin.repo.store.CoinPolicyAdminRepository; +import gg.admin.repo.user.UserAdminRepository; +import gg.data.store.CoinPolicy; +import gg.data.user.User; import gg.pingpong.api.admin.store.controller.response.CoinPolicyAdminListResponseDto; import gg.pingpong.api.admin.store.controller.response.CoinPolicyAdminResponseDto; import gg.pingpong.api.admin.store.dto.CoinPolicyAdminAddDto; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.store.CoinPolicy; -import gg.pingpong.data.user.User; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.utils.exception.user.UserNotFoundException; import lombok.AllArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ItemAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ItemAdminService.java index 77df9f02e..363aded6b 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ItemAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ItemAdminService.java @@ -8,15 +8,15 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import gg.pingpong.admin.repo.store.ItemAdminRepository; +import gg.admin.repo.store.ItemAdminRepository; +import gg.data.store.Item; import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; import gg.pingpong.api.admin.store.controller.response.ItemHistoryResponseDto; import gg.pingpong.api.admin.store.controller.response.ItemListResponseDto; import gg.pingpong.api.global.utils.aws.AsyncNewItemImageUploader; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.store.Item; -import gg.pingpong.utils.exception.item.ItemNotAvailableException; -import gg.pingpong.utils.exception.item.ItemNotFoundException; +import gg.utils.exception.item.ItemNotAvailableException; +import gg.utils.exception.item.ItemNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/MegaphoneAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/MegaphoneAdminService.java index e4eea3c0b..e83d5d507 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/MegaphoneAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/MegaphoneAdminService.java @@ -4,7 +4,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; -import gg.pingpong.admin.repo.store.MegaphoneAdminRepository; +import gg.admin.repo.store.MegaphoneAdminRepository; import gg.pingpong.api.admin.store.controller.response.MegaphoneAdminResponseDto; import gg.pingpong.api.admin.store.controller.response.MegaphoneHistoryResponseDto; import lombok.RequiredArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ReceiptAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ReceiptAdminService.java index 05fadc1d1..560a3510c 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ReceiptAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/store/service/ReceiptAdminService.java @@ -5,10 +5,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.admin.repo.store.ReceiptAdminRepository; +import gg.admin.repo.store.ReceiptAdminRepository; +import gg.data.store.Receipt; import gg.pingpong.api.admin.store.controller.response.ReceiptListResponseDto; import gg.pingpong.api.admin.store.controller.response.ReceiptResponseDto; -import gg.pingpong.data.store.Receipt; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminCreateRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminCreateRequestDto.java index 294e0b78f..f31951cbc 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminCreateRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminCreateRequestDto.java @@ -7,7 +7,7 @@ import org.hibernate.validator.constraints.Length; import org.springframework.format.annotation.DateTimeFormat; -import gg.pingpong.data.tournament.type.TournamentType; +import gg.data.tournament.type.TournamentType; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminUpdateRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminUpdateRequestDto.java index 9dbfd00a1..6121e4722 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminUpdateRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/controller/request/TournamentAdminUpdateRequestDto.java @@ -8,7 +8,7 @@ import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat.ISO; -import gg.pingpong.data.tournament.type.TournamentType; +import gg.data.tournament.type.TournamentType; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/service/TournamentAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/service/TournamentAdminService.java index 4dfeac73b..09385a366 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/service/TournamentAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/tournament/service/TournamentAdminService.java @@ -1,6 +1,6 @@ package gg.pingpong.api.admin.tournament.service; -import static gg.pingpong.data.match.type.TournamentMatchStatus.*; +import static gg.data.match.type.TournamentMatchStatus.*; import java.time.LocalDate; import java.time.LocalDateTime; @@ -10,6 +10,18 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.game.Game; +import gg.data.game.Team; +import gg.data.game.TeamUser; +import gg.data.game.type.StatusType; +import gg.data.manage.SlotManagement; +import gg.data.match.type.TournamentMatchStatus; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.TournamentUser; +import gg.data.tournament.type.TournamentRound; +import gg.data.tournament.type.TournamentStatus; +import gg.data.user.User; import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminAddUserRequestDto; import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminCreateRequestDto; import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminUpdateRequestDto; @@ -19,33 +31,21 @@ import gg.pingpong.api.user.game.service.GameService; import gg.pingpong.api.user.match.service.MatchTournamentService; import gg.pingpong.api.user.tournament.controller.response.TournamentUserListResponseDto; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.match.type.TournamentMatchStatus; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.TournamentUser; -import gg.pingpong.data.tournament.type.TournamentRound; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.repo.tournarment.TournamentGameRepository; -import gg.pingpong.repo.tournarment.TournamentRepository; -import gg.pingpong.repo.tournarment.TournamentUserRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.InvalidParameterException; -import gg.pingpong.utils.exception.game.ScoreNotInvalidException; -import gg.pingpong.utils.exception.match.SlotNotFoundException; -import gg.pingpong.utils.exception.tournament.TournamentConflictException; -import gg.pingpong.utils.exception.tournament.TournamentGameNotFoundException; -import gg.pingpong.utils.exception.tournament.TournamentNotFoundException; -import gg.pingpong.utils.exception.tournament.TournamentUpdateException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.manage.SlotManagementRepository; +import gg.repo.tournarment.TournamentGameRepository; +import gg.repo.tournarment.TournamentRepository; +import gg.repo.tournarment.TournamentUserRepository; +import gg.repo.user.UserRepository; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.InvalidParameterException; +import gg.utils.exception.game.ScoreNotInvalidException; +import gg.utils.exception.match.SlotNotFoundException; +import gg.utils.exception.tournament.TournamentConflictException; +import gg.utils.exception.tournament.TournamentGameNotFoundException; +import gg.utils.exception.tournament.TournamentNotFoundException; +import gg.utils.exception.tournament.TournamentUpdateException; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/UserAdminController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/UserAdminController.java index e9185d4d1..ebffae2c6 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/UserAdminController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/UserAdminController.java @@ -25,8 +25,8 @@ import gg.pingpong.api.admin.user.controller.response.UserSearchAdminResponseDto; import gg.pingpong.api.admin.user.service.UserAdminService; import gg.pingpong.api.global.dto.PageRequestDto; -import gg.pingpong.utils.exception.user.UserImageLargeException; -import gg.pingpong.utils.exception.user.UserImageTypeException; +import gg.utils.exception.user.UserImageLargeException; +import gg.utils.exception.user.UserImageTypeException; import lombok.AllArgsConstructor; @RestController diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/request/UserUpdateAdminRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/request/UserUpdateAdminRequestDto.java index 25e3f0c44..780ec00f1 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/request/UserUpdateAdminRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/request/UserUpdateAdminRequestDto.java @@ -1,6 +1,6 @@ package gg.pingpong.api.admin.user.controller.request; -import gg.pingpong.data.user.type.RacketType; +import gg.data.user.type.RacketType; import lombok.Builder; import lombok.Getter; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response/UserDetailAdminResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response/UserDetailAdminResponseDto.java index 8440e0f2f..09a1ead42 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response/UserDetailAdminResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/controller/response/UserDetailAdminResponseDto.java @@ -1,7 +1,7 @@ package gg.pingpong.api.admin.user.controller.response; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.user.User; +import gg.data.rank.redis.RankRedis; +import gg.data.user.User; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserAdminDto.java index e2f6ff4e4..fbf43045e 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserAdminDto.java @@ -1,10 +1,10 @@ package gg.pingpong.api.admin.user.dto; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.UserImage; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; +import gg.data.user.User; +import gg.data.user.UserImage; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import lombok.Builder; import lombok.Getter; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserImageAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserImageAdminDto.java index 29bcdfe22..4031d8213 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserImageAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserImageAdminDto.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import gg.pingpong.data.user.UserImage; +import gg.data.user.UserImage; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserSearchAdminDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserSearchAdminDto.java index 7d2766c6a..9a40f8e80 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserSearchAdminDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/dto/UserSearchAdminDto.java @@ -1,7 +1,7 @@ package gg.pingpong.api.admin.user.dto; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RoleType; +import gg.data.user.User; +import gg.data.user.type.RoleType; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/service/UserAdminService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/service/UserAdminService.java index 7b5052fb4..f56d50271 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/service/UserAdminService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/admin/user/service/UserAdminService.java @@ -11,9 +11,15 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import gg.pingpong.admin.repo.season.SeasonAdminRepository; -import gg.pingpong.admin.repo.user.UserAdminRepository; -import gg.pingpong.admin.repo.user.UserImageAdminRepository; +import gg.admin.repo.season.SeasonAdminRepository; +import gg.admin.repo.user.UserAdminRepository; +import gg.admin.repo.user.UserImageAdminRepository; +import gg.data.rank.Rank; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.user.User; +import gg.data.user.UserImage; +import gg.data.user.type.RoleType; import gg.pingpong.api.admin.rank.service.RankRedisAdminService; import gg.pingpong.api.admin.user.controller.request.UserUpdateAdminRequestDto; import gg.pingpong.api.admin.user.controller.response.UserDetailAdminResponseDto; @@ -23,19 +29,13 @@ import gg.pingpong.api.admin.user.dto.UserSearchAdminDto; import gg.pingpong.api.global.utils.aws.AsyncNewUserImageUploader; import gg.pingpong.api.user.user.service.UserFindService; -import gg.pingpong.data.rank.Rank; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.UserImage; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.exception.rank.RankNotFoundException; -import gg.pingpong.utils.exception.rank.RedisDataNotFoundException; -import gg.pingpong.utils.exception.season.SeasonNotFoundException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.rank.RankRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.utils.RedisKeyManager; +import gg.utils.exception.rank.RankNotFoundException; +import gg.utils.exception.rank.RedisDataNotFoundException; +import gg.utils.exception.season.SeasonNotFoundException; +import gg.utils.exception.user.UserNotFoundException; import lombok.AllArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/JpaConfig.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/JpaConfig.java index eb18297a6..6bb8e11f9 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/JpaConfig.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/JpaConfig.java @@ -5,7 +5,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @Configuration -@EnableJpaRepositories(basePackages = {"gg.pingpong.repo", "gg.pingpong.admin.repo"}) -@EntityScan(basePackages = "gg.pingpong.data") +@EnableJpaRepositories(basePackages = {"gg.repo", "gg.admin.repo"}) +@EntityScan(basePackages = "gg.data") public class JpaConfig { } diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/WebConfig.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/WebConfig.java index 623654413..9b8e1c539 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/WebConfig.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/config/WebConfig.java @@ -10,7 +10,7 @@ import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.global.utils.argumentresolver.LoginMemberArgumentResolver; import gg.pingpong.api.global.utils.querytracker.LoggingInterceptor; -import gg.pingpong.repo.user.UserRepository; +import gg.repo.user.UserRepository; import lombok.RequiredArgsConstructor; @Configuration diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/exception/GlobalExceptionHandler.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/exception/GlobalExceptionHandler.java index c400ac1de..697150080 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/exception/GlobalExceptionHandler.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/exception/GlobalExceptionHandler.java @@ -13,15 +13,15 @@ import com.amazonaws.AmazonServiceException; import com.amazonaws.SdkClientException; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.ErrorResponse; -import gg.pingpong.utils.exception.custom.AuthenticationException; -import gg.pingpong.utils.exception.custom.CustomRuntimeException; -import gg.pingpong.utils.exception.custom.DBConsistencyException; -import gg.pingpong.utils.exception.custom.DuplicationException; -import gg.pingpong.utils.exception.custom.ForbiddenException; -import gg.pingpong.utils.exception.custom.NotExistException; -import gg.pingpong.utils.exception.custom.PageNotFoundException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.ErrorResponse; +import gg.utils.exception.custom.AuthenticationException; +import gg.utils.exception.custom.CustomRuntimeException; +import gg.utils.exception.custom.DBConsistencyException; +import gg.utils.exception.custom.DuplicationException; +import gg.utils.exception.custom.ForbiddenException; +import gg.utils.exception.custom.NotExistException; +import gg.utils.exception.custom.PageNotFoundException; import lombok.extern.slf4j.Slf4j; @Slf4j diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/UserPrincipal.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/UserPrincipal.java index 64d2a86b0..2861aaab7 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/UserPrincipal.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/UserPrincipal.java @@ -10,8 +10,8 @@ import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.oauth2.core.user.OAuth2User; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RoleType; +import gg.data.user.User; +import gg.data.user.type.RoleType; import lombok.Getter; @Getter diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/handler/OAuthAuthenticationSuccessHandler.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/handler/OAuthAuthenticationSuccessHandler.java index 7d7068de6..85fd9754a 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/handler/OAuthAuthenticationSuccessHandler.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/handler/OAuthAuthenticationSuccessHandler.java @@ -12,6 +12,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.util.UriComponentsBuilder; +import gg.data.user.User; +import gg.data.user.type.RoleType; import gg.pingpong.api.global.security.UserPrincipal; import gg.pingpong.api.global.security.config.properties.AppProperties; import gg.pingpong.api.global.security.cookie.CookieUtil; @@ -19,10 +21,8 @@ import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.global.security.jwt.utils.TokenHeaders; import gg.pingpong.api.global.utils.ApplicationYmlRead; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.user.UserRepository; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Component diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/OAuthUserInfo.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/OAuthUserInfo.java index 18abacd1c..b1719d5f8 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/OAuthUserInfo.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/OAuthUserInfo.java @@ -2,7 +2,7 @@ import java.util.Map; -import gg.pingpong.data.user.type.RoleType; +import gg.data.user.type.RoleType; public abstract class OAuthUserInfo { protected Map attributes; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/impl/FortyTwoOAuthUserInfo.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/impl/FortyTwoOAuthUserInfo.java index 2c2336730..1e59b3de1 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/impl/FortyTwoOAuthUserInfo.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/impl/FortyTwoOAuthUserInfo.java @@ -4,8 +4,8 @@ import org.springframework.beans.factory.annotation.Value; +import gg.data.user.type.RoleType; import gg.pingpong.api.global.security.info.OAuthUserInfo; -import gg.pingpong.data.user.type.RoleType; public class FortyTwoOAuthUserInfo extends OAuthUserInfo { diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/impl/KakaoOAuthUserInfo.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/impl/KakaoOAuthUserInfo.java index 517f0c225..b28bea0cf 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/impl/KakaoOAuthUserInfo.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/info/impl/KakaoOAuthUserInfo.java @@ -4,11 +4,12 @@ import org.springframework.beans.factory.annotation.Value; +import gg.data.user.type.RoleType; import gg.pingpong.api.global.security.info.OAuthUserInfo; -import gg.pingpong.data.user.type.RoleType; public class KakaoOAuthUserInfo extends OAuthUserInfo { @Value("${info.image.defaultUrl}") + private String defaultImageUrl; public KakaoOAuthUserInfo(Map attributes) { diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/service/CustomOAuth2UserService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/service/CustomOAuth2UserService.java index bf6f25272..3976762b5 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/service/CustomOAuth2UserService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/service/CustomOAuth2UserService.java @@ -12,24 +12,24 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.rank.Rank; +import gg.data.rank.Tier; +import gg.data.rank.redis.RankRedis; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.SnsType; import gg.pingpong.api.global.security.UserPrincipal; import gg.pingpong.api.global.security.info.OAuthUserInfo; import gg.pingpong.api.global.security.info.OAuthUserInfoFactory; import gg.pingpong.api.global.security.info.ProviderType; import gg.pingpong.api.global.utils.aws.AsyncNewUserImageUploader; -import gg.pingpong.data.rank.Rank; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.TierRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.season.SeasonRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.exception.tier.TierNotFoundException; +import gg.repo.rank.RankRepository; +import gg.repo.rank.TierRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.season.SeasonRepository; +import gg.repo.user.UserRepository; +import gg.utils.RedisKeyManager; +import gg.utils.exception.tier.TierNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/service/CustomUserDetailsService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/service/CustomUserDetailsService.java index d297ba73d..ea0fd803d 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/service/CustomUserDetailsService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/security/service/CustomUserDetailsService.java @@ -5,10 +5,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.user.User; import gg.pingpong.api.global.security.UserPrincipal; import gg.pingpong.api.user.user.service.UserFindService; -import gg.pingpong.data.user.User; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ItemImageHandler.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ItemImageHandler.java index 290ae29fe..5b87aacc4 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ItemImageHandler.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/ItemImageHandler.java @@ -13,7 +13,7 @@ import com.amazonaws.services.s3.model.ObjectMetadata; import com.amazonaws.services.s3.model.PutObjectRequest; -import gg.pingpong.data.store.Item; +import gg.data.store.Item; @Component public class ItemImageHandler { diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/UserImageHandler.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/UserImageHandler.java index 66f5e441d..21d46a36e 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/UserImageHandler.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/UserImageHandler.java @@ -13,8 +13,8 @@ import com.amazonaws.services.s3.model.ObjectMetadata; import com.amazonaws.services.s3.model.PutObjectRequest; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.user.UserImageRepository; +import gg.data.user.User; +import gg.repo.user.UserImageRepository; @Component public class UserImageHandler { diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/argumentresolver/LoginMemberArgumentResolver.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/argumentresolver/LoginMemberArgumentResolver.java index 5e0e8a0c9..69a63945f 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/argumentresolver/LoginMemberArgumentResolver.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/argumentresolver/LoginMemberArgumentResolver.java @@ -8,11 +8,11 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.ModelAndViewContainer; +import gg.data.user.User; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.global.utils.HeaderUtil; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.user.UserRepository; +import gg.repo.user.UserRepository; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/aws/AsyncNewItemImageUploader.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/aws/AsyncNewItemImageUploader.java index 62ad1b2a8..fafc55d89 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/aws/AsyncNewItemImageUploader.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/aws/AsyncNewItemImageUploader.java @@ -7,11 +7,12 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import gg.data.store.Item; import gg.pingpong.api.global.utils.ItemImageHandler; -import gg.pingpong.data.store.Item; @Component public class AsyncNewItemImageUploader { + private final ItemImageHandler itemImageHandler; @Value("${info.image.itemNotFoundUrl}") diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/aws/AsyncNewUserImageUploader.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/aws/AsyncNewUserImageUploader.java index 8813f039a..5f8673d33 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/aws/AsyncNewUserImageUploader.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/global/utils/aws/AsyncNewUserImageUploader.java @@ -12,11 +12,11 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import gg.data.user.User; +import gg.data.user.UserImage; import gg.pingpong.api.global.utils.UserImageHandler; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.UserImage; -import gg.pingpong.repo.user.UserImageRepository; -import gg.pingpong.repo.user.UserRepository; +import gg.repo.user.UserImageRepository; +import gg.repo.user.UserRepository; import lombok.extern.slf4j.Slf4j; @Slf4j diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/GameController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/GameController.java index 2c2529d77..b8138959c 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/GameController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/GameController.java @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import gg.data.game.type.Mode; import gg.pingpong.api.global.utils.argumentresolver.Login; import gg.pingpong.api.user.game.controller.request.GameListReqDto; import gg.pingpong.api.user.game.controller.request.NormalGameListReqDto; @@ -30,11 +31,10 @@ import gg.pingpong.api.user.game.service.GameService; import gg.pingpong.api.user.rank.redis.RankRedisService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; -import gg.pingpong.utils.exception.custom.InvalidParameterException; -import gg.pingpong.utils.exception.game.ScoreNotMatchedException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; +import gg.utils.exception.custom.InvalidParameterException; +import gg.utils.exception.game.ScoreNotMatchedException; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/GameListReqDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/GameListReqDto.java index 5092d81b3..0ec4e79aa 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/GameListReqDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/request/GameListReqDto.java @@ -1,6 +1,6 @@ package gg.pingpong.api.user.game.controller.request; -import gg.pingpong.data.game.type.StatusType; +import gg.data.game.type.StatusType; import lombok.Getter; @Getter diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GameResultResDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GameResultResDto.java index 95c45c018..77e51ae73 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GameResultResDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/controller/response/GameResultResDto.java @@ -8,10 +8,10 @@ import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import gg.data.game.type.Mode; import gg.pingpong.api.user.game.dto.TeamUserInfoDto; import gg.pingpong.api.user.game.dto.TeamUserListDto; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.repo.game.out.GameTeamUser; +import gg.repo.game.out.GameTeamUser; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/GameTeamInfo.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/GameTeamInfo.java index f90d830b0..e0016a67d 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/GameTeamInfo.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/GameTeamInfo.java @@ -3,10 +3,10 @@ import java.time.LocalDateTime; import java.util.List; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.repo.game.out.GameTeamUserInfo; -import gg.pingpong.utils.exception.game.GameDataConsistencyException; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.repo.game.out.GameTeamUserInfo; +import gg.utils.exception.game.GameDataConsistencyException; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/MatchTeamsInfoDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/MatchTeamsInfoDto.java index 7d22926cb..7067bc15a 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/MatchTeamsInfoDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/MatchTeamsInfoDto.java @@ -2,7 +2,7 @@ import java.util.List; -import gg.pingpong.repo.game.out.GameTeamUserInfo; +import gg.repo.game.out.GameTeamUserInfo; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamInfo.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamInfo.java index bfbccba74..f55dfecb5 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamInfo.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/dto/TeamInfo.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; -import gg.pingpong.repo.game.out.GameTeamUserInfo; +import gg.repo.game.out.GameTeamUserInfo; import lombok.Getter; import lombok.ToString; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameFindService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameFindService.java index 09e68ce9c..caaf78c60 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameFindService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameFindService.java @@ -10,14 +10,14 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.game.Game; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; import gg.pingpong.api.user.game.controller.response.GameListResDto; import gg.pingpong.api.user.game.controller.response.GameResultResDto; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.game.out.GameTeamUser; -import gg.pingpong.utils.exception.game.GameNotExistException; +import gg.repo.game.GameRepository; +import gg.repo.game.out.GameTeamUser; +import gg.utils.exception.game.GameNotExistException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameService.java index 48bb4059b..9f9fba0ab 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameService.java @@ -8,6 +8,15 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.game.Game; +import gg.data.game.PChange; +import gg.data.game.TeamUser; +import gg.data.game.type.StatusType; +import gg.data.match.type.TournamentMatchStatus; +import gg.data.season.Season; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.type.RoundNumber; import gg.pingpong.api.global.utils.ExpLevelCalculator; import gg.pingpong.api.user.game.controller.request.NormalResultReqDto; import gg.pingpong.api.user.game.controller.request.RankResultReqDto; @@ -20,28 +29,19 @@ import gg.pingpong.api.user.rank.service.TierService; import gg.pingpong.api.user.store.dto.UserGameCoinResultDto; import gg.pingpong.api.user.store.service.UserCoinChangeService; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.PChange; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.match.type.TournamentMatchStatus; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.type.RoundNumber; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.game.PChangeRepository; -import gg.pingpong.repo.game.TeamUserRepository; -import gg.pingpong.repo.game.out.GameTeamUserInfo; -import gg.pingpong.repo.tournarment.TournamentGameRepository; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.InvalidParameterException; -import gg.pingpong.utils.exception.game.GameNotExistException; -import gg.pingpong.utils.exception.game.GameStatusNotMatchedException; -import gg.pingpong.utils.exception.game.ScoreAlreadyEnteredException; -import gg.pingpong.utils.exception.pchange.PChangeNotExistException; -import gg.pingpong.utils.exception.team.TeamIdNotMatchException; -import gg.pingpong.utils.exception.tournament.TournamentGameNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.game.PChangeRepository; +import gg.repo.game.TeamUserRepository; +import gg.repo.game.out.GameTeamUserInfo; +import gg.repo.tournarment.TournamentGameRepository; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.InvalidParameterException; +import gg.utils.exception.game.GameNotExistException; +import gg.utils.exception.game.GameStatusNotMatchedException; +import gg.utils.exception.game.ScoreAlreadyEnteredException; +import gg.utils.exception.pchange.PChangeNotExistException; +import gg.utils.exception.team.TeamIdNotMatchException; +import gg.utils.exception.tournament.TournamentGameNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameStatusService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameStatusService.java index f33630821..987541416 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameStatusService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/GameStatusService.java @@ -8,20 +8,20 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.game.Game; +import gg.data.game.type.StatusType; +import gg.data.manage.SlotManagement; +import gg.data.noti.Noti; +import gg.data.noti.type.NotiType; import gg.pingpong.api.user.noti.dto.UserNotiDto; import gg.pingpong.api.user.noti.service.NotiService; import gg.pingpong.api.user.noti.service.SnsNotiService; import gg.pingpong.api.user.user.service.UserService; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.noti.type.NotiType; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.game.out.GameUser; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.utils.exception.game.GameDataConsistencyException; -import gg.pingpong.utils.exception.match.SlotNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.game.out.GameUser; +import gg.repo.manage.SlotManagementRepository; +import gg.utils.exception.game.GameDataConsistencyException; +import gg.utils.exception.match.SlotNotFoundException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/PChangeService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/PChangeService.java index 351b2e9d5..53150d946 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/PChangeService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/game/service/PChangeService.java @@ -5,11 +5,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.PChange; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.PChangeRepository; -import gg.pingpong.utils.exception.pchange.PChangeNotExistException; +import gg.data.game.Game; +import gg.data.game.PChange; +import gg.data.user.User; +import gg.repo.game.PChangeRepository; +import gg.utils.exception.pchange.PChangeNotExistException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/FeedbackController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/FeedbackController.java index 10e6ff14f..d66bafeaf 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/FeedbackController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/FeedbackController.java @@ -13,7 +13,7 @@ import gg.pingpong.api.user.manage.controller.request.FeedbackRequestDto; import gg.pingpong.api.user.manage.service.FeedbackService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.repo.user.UserRepository; +import gg.repo.user.UserRepository; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/request/FeedbackRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/request/FeedbackRequestDto.java index 230f8aa8a..4a5066ce7 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/request/FeedbackRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/controller/request/FeedbackRequestDto.java @@ -4,7 +4,7 @@ import org.hibernate.validator.constraints.Length; -import gg.pingpong.data.manage.type.FeedbackType; +import gg.data.manage.type.FeedbackType; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/dto/AnnouncementDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/dto/AnnouncementDto.java index 5cd6e952e..7b0aa791f 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/dto/AnnouncementDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/dto/AnnouncementDto.java @@ -1,6 +1,6 @@ package gg.pingpong.api.user.manage.dto; -import gg.pingpong.data.manage.Announcement; +import gg.data.manage.Announcement; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/redis/PenaltyUserRedisRepository.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/redis/PenaltyUserRedisRepository.java index eda02c9ae..3194b11e5 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/redis/PenaltyUserRedisRepository.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/redis/PenaltyUserRedisRepository.java @@ -8,8 +8,8 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; -import gg.pingpong.data.manage.redis.RedisPenaltyUser; -import gg.pingpong.data.manage.type.PenaltyKey; +import gg.data.manage.redis.RedisPenaltyUser; +import gg.data.manage.type.PenaltyKey; import lombok.RequiredArgsConstructor; @Repository diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/AnnouncementService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/AnnouncementService.java index 92d8bcb6b..e1678b3ca 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/AnnouncementService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/AnnouncementService.java @@ -3,10 +3,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.manage.Announcement; import gg.pingpong.api.user.manage.dto.AnnouncementDto; -import gg.pingpong.data.manage.Announcement; -import gg.pingpong.repo.manage.AnnouncementRepository; -import gg.pingpong.utils.exception.announcement.AnnounceNotFoundException; +import gg.repo.manage.AnnouncementRepository; +import gg.utils.exception.announcement.AnnounceNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/FeedbackService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/FeedbackService.java index b35b22feb..3642277a3 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/FeedbackService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/FeedbackService.java @@ -3,12 +3,12 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.manage.Feedback; +import gg.data.user.User; import gg.pingpong.api.user.manage.controller.request.FeedbackRequestDto; -import gg.pingpong.data.manage.Feedback; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.manage.FeedbackRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.manage.FeedbackRepository; +import gg.repo.user.UserRepository; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/PenaltyService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/PenaltyService.java index 35ee13157..107eb584d 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/PenaltyService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/manage/service/PenaltyService.java @@ -5,14 +5,14 @@ import org.springframework.stereotype.Service; +import gg.data.manage.Penalty; +import gg.data.manage.redis.RedisPenaltyUser; +import gg.data.manage.type.PenaltyType; +import gg.data.user.User; import gg.pingpong.api.user.manage.redis.PenaltyUserRedisRepository; import gg.pingpong.api.user.user.dto.UserDto; import gg.pingpong.api.user.user.service.UserFindService; -import gg.pingpong.data.manage.Penalty; -import gg.pingpong.data.manage.redis.RedisPenaltyUser; -import gg.pingpong.data.manage.type.PenaltyType; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.manage.PenaltyRepository; +import gg.repo.manage.PenaltyRepository; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/MatchController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/MatchController.java index e2f128fd6..f515312ba 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/MatchController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/MatchController.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import gg.data.match.type.Option; import gg.pingpong.api.global.utils.argumentresolver.Login; import gg.pingpong.api.user.match.controller.request.MatchRequestDto; import gg.pingpong.api.user.match.controller.response.MatchStatusResponseListDto; @@ -22,7 +23,6 @@ import gg.pingpong.api.user.match.service.MatchFindService; import gg.pingpong.api.user.match.service.MatchService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.match.type.Option; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/request/MatchRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/request/MatchRequestDto.java index 0d0915f95..46f588629 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/request/MatchRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/controller/request/MatchRequestDto.java @@ -8,7 +8,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; -import gg.pingpong.data.match.type.Option; +import gg.data.match.type.Option; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/GameAddDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/GameAddDto.java index e228a358f..2938b7b14 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/GameAddDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/GameAddDto.java @@ -3,10 +3,10 @@ import java.time.LocalDateTime; import java.util.List; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.match.RedisMatchUser; -import gg.pingpong.data.match.type.Option; -import gg.pingpong.data.season.Season; +import gg.data.game.type.Mode; +import gg.data.match.RedisMatchUser; +import gg.data.match.type.Option; +import gg.data.season.Season; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/MatchStatusDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/MatchStatusDto.java index 419d73711..62f813079 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/MatchStatusDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/MatchStatusDto.java @@ -5,10 +5,10 @@ import com.fasterxml.jackson.annotation.JsonFormat; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.match.RedisMatchTime; +import gg.data.game.Game; +import gg.data.game.type.Mode; +import gg.data.manage.SlotManagement; +import gg.data.match.RedisMatchTime; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/SlotStatusDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/SlotStatusDto.java index 4523fc95d..dbab08775 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/SlotStatusDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/dto/SlotStatusDto.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; -import gg.pingpong.data.match.type.SlotStatus; +import gg.data.match.type.SlotStatus; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/GameUpdateService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/GameUpdateService.java index 5b2cc5da0..90753d0ab 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/GameUpdateService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/GameUpdateService.java @@ -5,23 +5,23 @@ import org.springframework.stereotype.Service; +import gg.data.game.Game; +import gg.data.game.Team; +import gg.data.game.TeamUser; +import gg.data.manage.SlotManagement; +import gg.data.noti.Noti; +import gg.data.user.User; import gg.pingpong.api.user.match.dto.GameAddDto; import gg.pingpong.api.user.noti.service.NotiService; import gg.pingpong.api.user.noti.service.SnsNotiService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.game.TeamRepository; -import gg.pingpong.repo.game.TeamUserRepository; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.exception.match.SlotNotFoundException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.game.TeamRepository; +import gg.repo.game.TeamUserRepository; +import gg.repo.manage.SlotManagementRepository; +import gg.repo.user.UserRepository; +import gg.utils.exception.match.SlotNotFoundException; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchFindService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchFindService.java index a52d747da..0b928053b 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchFindService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchFindService.java @@ -10,33 +10,33 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.game.Game; +import gg.data.game.type.StatusType; +import gg.data.manage.SlotManagement; +import gg.data.match.RedisMatchTime; +import gg.data.match.RedisMatchUser; +import gg.data.match.type.Option; +import gg.data.rank.Tier; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.user.User; +import gg.data.user.type.RoleType; import gg.pingpong.api.user.match.controller.response.MatchStatusResponseListDto; import gg.pingpong.api.user.match.controller.response.SlotStatusResponseListDto; import gg.pingpong.api.user.match.dto.MatchStatusDto; import gg.pingpong.api.user.match.utils.SlotGenerator; import gg.pingpong.api.user.season.service.SeasonFindService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.match.RedisMatchTime; -import gg.pingpong.data.match.RedisMatchUser; -import gg.pingpong.data.match.type.Option; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.repo.match.RedisMatchTimeRepository; -import gg.pingpong.repo.match.RedisMatchUserRepository; -import gg.pingpong.repo.rank.TierRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.exception.match.SlotNotFoundException; -import gg.pingpong.utils.exception.tier.TierNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.manage.SlotManagementRepository; +import gg.repo.match.RedisMatchTimeRepository; +import gg.repo.match.RedisMatchUserRepository; +import gg.repo.rank.TierRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.user.UserRepository; +import gg.utils.RedisKeyManager; +import gg.utils.exception.match.SlotNotFoundException; +import gg.utils.exception.tier.TierNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchService.java index 1860f25c3..42993ffcb 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchService.java @@ -9,39 +9,39 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.game.Game; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.data.match.RedisMatchTime; +import gg.data.match.RedisMatchUser; +import gg.data.match.type.Option; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.tournament.Tournament; +import gg.data.tournament.type.TournamentStatus; +import gg.data.user.User; import gg.pingpong.api.user.manage.service.PenaltyService; import gg.pingpong.api.user.match.dto.GameAddDto; import gg.pingpong.api.user.match.utils.MatchCalculator; import gg.pingpong.api.user.season.service.SeasonFindService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.match.RedisMatchTime; -import gg.pingpong.data.match.RedisMatchUser; -import gg.pingpong.data.match.type.Option; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.repo.match.RedisMatchTimeRepository; -import gg.pingpong.repo.match.RedisMatchUserRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.tournarment.TournamentRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; -import gg.pingpong.utils.exception.game.GameAlreadyExistException; -import gg.pingpong.utils.exception.match.EnrolledSlotException; -import gg.pingpong.utils.exception.match.PenaltyUserSlotException; -import gg.pingpong.utils.exception.match.SlotCountException; -import gg.pingpong.utils.exception.match.SlotNotFoundException; -import gg.pingpong.utils.exception.tournament.TournamentConflictException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.manage.SlotManagementRepository; +import gg.repo.match.RedisMatchTimeRepository; +import gg.repo.match.RedisMatchUserRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.tournarment.TournamentRepository; +import gg.repo.user.UserRepository; +import gg.utils.RedisKeyManager; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; +import gg.utils.exception.game.GameAlreadyExistException; +import gg.utils.exception.match.EnrolledSlotException; +import gg.utils.exception.match.PenaltyUserSlotException; +import gg.utils.exception.match.SlotCountException; +import gg.utils.exception.match.SlotNotFoundException; +import gg.utils.exception.tournament.TournamentConflictException; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchTournamentService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchTournamentService.java index eeb4a6edf..1b03f19b5 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchTournamentService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/service/MatchTournamentService.java @@ -1,7 +1,7 @@ package gg.pingpong.api.user.match.service; -import static gg.pingpong.data.match.type.TournamentMatchStatus.*; -import static gg.pingpong.data.tournament.type.RoundNumber.*; +import static gg.data.match.type.TournamentMatchStatus.*; +import static gg.data.tournament.type.RoundNumber.*; import java.time.LocalDateTime; import java.util.ArrayList; @@ -16,33 +16,33 @@ import org.springframework.stereotype.Service; +import gg.data.game.Game; +import gg.data.game.Team; +import gg.data.game.TeamUser; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.data.manage.SlotManagement; +import gg.data.match.type.TournamentMatchStatus; +import gg.data.noti.type.NotiType; +import gg.data.season.Season; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.TournamentUser; +import gg.data.tournament.type.RoundNumber; +import gg.data.tournament.type.TournamentRound; +import gg.data.tournament.type.TournamentStatus; +import gg.data.user.User; import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; import gg.pingpong.api.admin.noti.service.NotiAdminService; import gg.pingpong.api.user.season.service.SeasonFindService; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.match.type.TournamentMatchStatus; -import gg.pingpong.data.noti.type.NotiType; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.TournamentUser; -import gg.pingpong.data.tournament.type.RoundNumber; -import gg.pingpong.data.tournament.type.TournamentRound; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.repo.tournarment.TournamentGameRepository; -import gg.pingpong.utils.exception.match.EnrolledSlotException; -import gg.pingpong.utils.exception.match.LosingTeamNotFoundException; -import gg.pingpong.utils.exception.match.SlotNotFoundException; -import gg.pingpong.utils.exception.match.WinningTeamNotFoundException; -import gg.pingpong.utils.exception.tournament.TournamentGameNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.manage.SlotManagementRepository; +import gg.repo.tournarment.TournamentGameRepository; +import gg.utils.exception.match.EnrolledSlotException; +import gg.utils.exception.match.LosingTeamNotFoundException; +import gg.utils.exception.match.SlotNotFoundException; +import gg.utils.exception.match.WinningTeamNotFoundException; +import gg.utils.exception.tournament.TournamentGameNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/utils/MatchCalculator.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/utils/MatchCalculator.java index 02b53b698..413bb987e 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/utils/MatchCalculator.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/utils/MatchCalculator.java @@ -3,9 +3,9 @@ import java.util.List; import java.util.Optional; -import gg.pingpong.data.match.RedisMatchUser; -import gg.pingpong.data.match.type.Option; -import gg.pingpong.data.match.type.SlotStatus; +import gg.data.match.RedisMatchUser; +import gg.data.match.type.Option; +import gg.data.match.type.SlotStatus; public class MatchCalculator { private final Integer pppGap; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/utils/SlotGenerator.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/utils/SlotGenerator.java index c67ab411d..da68bcb16 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/utils/SlotGenerator.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/match/utils/SlotGenerator.java @@ -6,17 +6,17 @@ import java.util.List; import java.util.Set; +import gg.data.game.Game; +import gg.data.game.type.Mode; +import gg.data.manage.SlotManagement; +import gg.data.match.RedisMatchTime; +import gg.data.match.RedisMatchUser; +import gg.data.match.type.Option; +import gg.data.match.type.SlotStatus; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; import gg.pingpong.api.user.match.controller.response.SlotStatusResponseListDto; import gg.pingpong.api.user.match.dto.SlotStatusDto; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.match.RedisMatchTime; -import gg.pingpong.data.match.RedisMatchUser; -import gg.pingpong.data.match.type.Option; -import gg.pingpong.data.match.type.SlotStatus; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; import lombok.Getter; @Getter diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response/NotiResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response/NotiResponseDto.java index a55c5b1bc..2f4a2efa6 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response/NotiResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/controller/response/NotiResponseDto.java @@ -3,8 +3,8 @@ import java.time.LocalDateTime; import java.util.Objects; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.noti.type.NotiType; +import gg.data.noti.Noti; +import gg.data.noti.type.NotiType; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/dto/NotiDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/dto/NotiDto.java index a4bcf460b..9d38ca674 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/dto/NotiDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/dto/NotiDto.java @@ -3,9 +3,9 @@ import java.time.LocalDateTime; import java.util.Objects; +import gg.data.noti.Noti; +import gg.data.noti.type.NotiType; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.noti.type.NotiType; import lombok.Builder; import lombok.Getter; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/dto/UserNotiDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/dto/UserNotiDto.java index af2f6ca83..bddb971de 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/dto/UserNotiDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/dto/UserNotiDto.java @@ -1,7 +1,7 @@ package gg.pingpong.api.user.noti.dto; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.game.out.GameUser; +import gg.data.user.type.SnsType; +import gg.repo.game.out.GameUser; import lombok.Getter; @Getter diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/NotiService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/NotiService.java index d3efd0d01..94dce8928 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/NotiService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/NotiService.java @@ -8,17 +8,17 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.noti.Noti; +import gg.data.noti.type.NotiType; +import gg.data.user.User; import gg.pingpong.api.user.noti.controller.response.NotiResponseDto; import gg.pingpong.api.user.noti.dto.NotiDto; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.noti.type.NotiType; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.noti.NotiRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.noti.NotiRepository; +import gg.repo.user.UserRepository; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; +import gg.utils.exception.user.UserNotFoundException; import lombok.AllArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/SnsNotiService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/SnsNotiService.java index eca601697..656a9958f 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/SnsNotiService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/SnsNotiService.java @@ -3,12 +3,12 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.noti.Noti; +import gg.data.user.type.SnsType; import gg.pingpong.api.user.noti.dto.UserNotiDto; import gg.pingpong.api.user.noti.service.sns.NotiMailSender; import gg.pingpong.api.user.noti.service.sns.SlackbotService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.user.type.SnsType; import lombok.extern.slf4j.Slf4j; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/NotiMailSender.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/NotiMailSender.java index 282e23c62..970a1cff6 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/NotiMailSender.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/NotiMailSender.java @@ -7,11 +7,11 @@ import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.stereotype.Component; +import gg.data.noti.Noti; import gg.pingpong.api.global.utils.AsyncMailSender; import gg.pingpong.api.user.noti.dto.UserNotiDto; import gg.pingpong.api.user.noti.service.NotiService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.noti.Noti; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/SlackbotService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/SlackbotService.java index 04537d431..f645b9d4b 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/SlackbotService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/SlackbotService.java @@ -14,12 +14,12 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import gg.data.noti.Noti; import gg.pingpong.api.global.utils.external.ApiUtil; import gg.pingpong.api.user.noti.dto.UserNotiDto; import gg.pingpong.api.user.noti.service.NotiService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.utils.exception.noti.SlackSendException; +import gg.utils.exception.noti.SlackSendException; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/dto/ExpRankDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/dto/ExpRankDto.java index f9e27390c..9d3131860 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/dto/ExpRankDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/dto/ExpRankDto.java @@ -1,8 +1,8 @@ package gg.pingpong.api.user.rank.dto; +import gg.data.user.User; import gg.pingpong.api.global.utils.ExpLevelCalculator; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.user.ExpRankV2Dto; +import gg.repo.user.ExpRankV2Dto; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/dto/RankDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/dto/RankDto.java index c088f936b..ca045c620 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/dto/RankDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/dto/RankDto.java @@ -1,8 +1,8 @@ package gg.pingpong.api.user.rank.dto; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.rank.RankV2Dto; +import gg.data.rank.redis.RankRedis; +import gg.data.user.User; +import gg.repo.rank.RankV2Dto; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis/RankRedisService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis/RankRedisService.java index 15c2936de..945a9d3e4 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis/RankRedisService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis/RankRedisService.java @@ -8,22 +8,22 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.game.Game; +import gg.data.game.TeamUser; +import gg.data.rank.Rank; +import gg.data.rank.Tier; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; import gg.pingpong.api.global.utils.EloRating; import gg.pingpong.api.user.game.service.PChangeService; import gg.pingpong.api.user.season.service.SeasonFindService; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.rank.Rank; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.TierRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; -import gg.pingpong.utils.exception.rank.RankNotFoundException; +import gg.repo.rank.RankRepository; +import gg.repo.rank.TierRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.utils.RedisKeyManager; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; +import gg.utils.exception.rank.RankNotFoundException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis/RedisUploadService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis/RedisUploadService.java index 2799000c8..e494a6255 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis/RedisUploadService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/redis/RedisUploadService.java @@ -11,11 +11,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.season.SeasonRepository; -import gg.pingpong.utils.RedisKeyManager; +import gg.data.rank.redis.RankRedis; +import gg.repo.rank.RankRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.season.SeasonRepository; +import gg.utils.RedisKeyManager; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/RankFindService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/RankFindService.java index f4fa770b7..5ad1053dd 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/RankFindService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/RankFindService.java @@ -2,9 +2,9 @@ import org.springframework.stereotype.Service; -import gg.pingpong.data.rank.Rank; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.utils.exception.rank.RankNotFoundException; +import gg.data.rank.Rank; +import gg.repo.rank.RankRepository; +import gg.utils.exception.rank.RankNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/RankService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/RankService.java index f0d463e58..affb950d5 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/RankService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/RankService.java @@ -11,24 +11,24 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.user.User; import gg.pingpong.api.user.rank.controller.response.ExpRankPageResponseDto; import gg.pingpong.api.user.rank.controller.response.RankPageResponseDto; import gg.pingpong.api.user.rank.dto.ExpRankDto; import gg.pingpong.api.user.rank.dto.RankDto; import gg.pingpong.api.user.season.service.SeasonFindService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.user.ExpRankV2Dto; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.PageNotFoundException; -import gg.pingpong.utils.exception.rank.RedisDataNotFoundException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.rank.RankRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.user.ExpRankV2Dto; +import gg.repo.user.UserRepository; +import gg.utils.RedisKeyManager; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.PageNotFoundException; +import gg.utils.exception.rank.RedisDataNotFoundException; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/TierService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/TierService.java index 643b2f12e..f692dd0cb 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/TierService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/rank/service/TierService.java @@ -6,11 +6,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.data.rank.Rank; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.season.Season; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.TierRepository; +import gg.data.rank.Rank; +import gg.data.rank.Tier; +import gg.data.season.Season; +import gg.repo.rank.RankRepository; +import gg.repo.rank.TierRepository; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/response/SeasonResDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/response/SeasonResDto.java index fe4d7cd44..9b86af272 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/response/SeasonResDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/controller/response/SeasonResDto.java @@ -1,6 +1,6 @@ package gg.pingpong.api.user.season.controller.response; -import gg.pingpong.data.season.Season; +import gg.data.season.Season; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/dto/CurSeason.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/dto/CurSeason.java index ac75ec2db..e171e925b 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/dto/CurSeason.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/dto/CurSeason.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import gg.pingpong.data.season.Season; +import gg.data.season.Season; import lombok.Getter; @Getter diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonFindService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonFindService.java index f32a752b1..766376a37 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonFindService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonFindService.java @@ -5,12 +5,12 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.season.Season; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.season.SeasonRepository; -import gg.pingpong.utils.exception.game.GameNotExistException; -import gg.pingpong.utils.exception.season.SeasonNotFoundException; +import gg.data.game.Game; +import gg.data.season.Season; +import gg.repo.game.GameRepository; +import gg.repo.season.SeasonRepository; +import gg.utils.exception.game.GameNotExistException; +import gg.utils.exception.season.SeasonNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonService.java index 2958b00d8..0ebddfbdb 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/season/service/SeasonService.java @@ -8,8 +8,8 @@ import gg.pingpong.api.user.season.controller.response.SeasonResDto; import gg.pingpong.api.user.season.dto.CurSeason; -import gg.pingpong.repo.season.SeasonRepository; -import gg.pingpong.utils.exception.season.SeasonNotFoundException; +import gg.repo.season.SeasonRepository; +import gg.utils.exception.season.SeasonNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/ItemStoreResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/ItemStoreResponseDto.java index f874d825c..619125bc3 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/ItemStoreResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/ItemStoreResponseDto.java @@ -1,7 +1,7 @@ package gg.pingpong.api.user.store.controller.response; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.store.type.ItemType; +import gg.data.store.Item; +import gg.data.store.type.ItemType; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/MegaphoneDetailResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/MegaphoneDetailResponseDto.java index af13f5c26..4b9d4b0b9 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/MegaphoneDetailResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/MegaphoneDetailResponseDto.java @@ -1,6 +1,6 @@ package gg.pingpong.api.user.store.controller.response; -import gg.pingpong.data.store.Megaphone; +import gg.data.store.Megaphone; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/MegaphoneTodayListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/MegaphoneTodayListResponseDto.java index 3b988d92d..6cc63351a 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/MegaphoneTodayListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/MegaphoneTodayListResponseDto.java @@ -1,6 +1,6 @@ package gg.pingpong.api.user.store.controller.response; -import gg.pingpong.data.store.redis.MegaphoneRedis; +import gg.data.store.redis.MegaphoneRedis; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/UserItemResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/UserItemResponseDto.java index 1e51bd8e3..43a4a31ca 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/UserItemResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/controller/response/UserItemResponseDto.java @@ -1,9 +1,9 @@ package gg.pingpong.api.user.store.controller.response; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.store.Receipt; -import gg.pingpong.data.store.type.ItemStatus; -import gg.pingpong.data.store.type.ItemType; +import gg.data.store.Item; +import gg.data.store.Receipt; +import gg.data.store.type.ItemStatus; +import gg.data.store.type.ItemType; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/redis/MegaphoneRedisRepository.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/redis/MegaphoneRedisRepository.java index 7a31281ed..564cd7848 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/redis/MegaphoneRedisRepository.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/redis/MegaphoneRedisRepository.java @@ -6,7 +6,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; -import gg.pingpong.data.store.redis.MegaphoneRedis; +import gg.data.store.redis.MegaphoneRedis; import lombok.RequiredArgsConstructor; @Repository diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/CoinHistoryService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/CoinHistoryService.java index 27d4672f8..530ad372c 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/CoinHistoryService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/CoinHistoryService.java @@ -5,13 +5,13 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.data.store.CoinHistory; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.store.type.HistoryType; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.store.CoinHistoryRepository; -import gg.pingpong.repo.store.CoinPolicyRepository; -import gg.pingpong.utils.exception.coin.CoinPolicyNotFoundException; +import gg.data.store.CoinHistory; +import gg.data.store.Item; +import gg.data.store.type.HistoryType; +import gg.data.user.User; +import gg.repo.store.CoinHistoryRepository; +import gg.repo.store.CoinPolicyRepository; +import gg.utils.exception.coin.CoinPolicyNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/ItemService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/ItemService.java index 8e80cb3ca..6df2287e1 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/ItemService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/ItemService.java @@ -9,30 +9,30 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.store.Item; +import gg.data.store.Receipt; +import gg.data.store.type.ItemStatus; +import gg.data.store.type.ItemType; +import gg.data.user.User; +import gg.data.user.type.RoleType; import gg.pingpong.api.user.noti.service.NotiService; import gg.pingpong.api.user.store.controller.response.ItemStoreListResponseDto; import gg.pingpong.api.user.store.controller.response.ItemStoreResponseDto; import gg.pingpong.api.user.store.controller.response.UserItemListResponseDto; import gg.pingpong.api.user.store.controller.response.UserItemResponseDto; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.store.Receipt; -import gg.pingpong.data.store.type.ItemStatus; -import gg.pingpong.data.store.type.ItemType; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.repo.store.ItemRepository; -import gg.pingpong.repo.store.ReceiptRepository; -import gg.pingpong.repo.store.UserItemRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.exception.item.ItemNotFoundException; -import gg.pingpong.utils.exception.item.ItemNotPurchasableException; -import gg.pingpong.utils.exception.item.ItemTypeException; -import gg.pingpong.utils.exception.item.KakaoGiftException; -import gg.pingpong.utils.exception.item.KakaoPurchaseException; -import gg.pingpong.utils.exception.receipt.ItemStatusException; -import gg.pingpong.utils.exception.receipt.ReceiptNotOwnerException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.store.ItemRepository; +import gg.repo.store.ReceiptRepository; +import gg.repo.store.UserItemRepository; +import gg.repo.user.UserRepository; +import gg.utils.exception.item.ItemNotFoundException; +import gg.utils.exception.item.ItemNotPurchasableException; +import gg.utils.exception.item.ItemTypeException; +import gg.utils.exception.item.KakaoGiftException; +import gg.utils.exception.item.KakaoPurchaseException; +import gg.utils.exception.receipt.ItemStatusException; +import gg.utils.exception.receipt.ReceiptNotOwnerException; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/MegaphoneService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/MegaphoneService.java index 192909395..b478ed9dd 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/MegaphoneService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/MegaphoneService.java @@ -9,29 +9,29 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.store.Megaphone; +import gg.data.store.Receipt; +import gg.data.store.redis.MegaphoneRedis; +import gg.data.store.type.ItemStatus; +import gg.data.store.type.ItemType; +import gg.data.user.User; +import gg.data.user.type.RoleType; import gg.pingpong.api.user.store.controller.request.MegaphoneUseRequestDto; import gg.pingpong.api.user.store.controller.response.MegaphoneDetailResponseDto; import gg.pingpong.api.user.store.controller.response.MegaphoneTodayListResponseDto; import gg.pingpong.api.user.store.redis.MegaphoneRedisRepository; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.store.Megaphone; -import gg.pingpong.data.store.Receipt; -import gg.pingpong.data.store.redis.MegaphoneRedis; -import gg.pingpong.data.store.type.ItemStatus; -import gg.pingpong.data.store.type.ItemType; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.repo.store.MegaphoneRepository; -import gg.pingpong.repo.store.ReceiptRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.exception.item.ItemTypeException; -import gg.pingpong.utils.exception.megaphone.MegaphoneContentException; -import gg.pingpong.utils.exception.megaphone.MegaphoneNotFoundException; -import gg.pingpong.utils.exception.megaphone.MegaphoneTimeException; -import gg.pingpong.utils.exception.receipt.ItemStatusException; -import gg.pingpong.utils.exception.receipt.ReceiptNotFoundException; -import gg.pingpong.utils.exception.receipt.ReceiptNotOwnerException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.store.MegaphoneRepository; +import gg.repo.store.ReceiptRepository; +import gg.repo.user.UserRepository; +import gg.utils.exception.item.ItemTypeException; +import gg.utils.exception.megaphone.MegaphoneContentException; +import gg.utils.exception.megaphone.MegaphoneNotFoundException; +import gg.utils.exception.megaphone.MegaphoneTimeException; +import gg.utils.exception.receipt.ItemStatusException; +import gg.utils.exception.receipt.ReceiptNotFoundException; +import gg.utils.exception.receipt.ReceiptNotOwnerException; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/UserCoinChangeService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/UserCoinChangeService.java index 87024279b..e0bbe3ad6 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/UserCoinChangeService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/store/service/UserCoinChangeService.java @@ -5,17 +5,17 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.game.Team; +import gg.data.game.TeamUser; +import gg.data.store.Item; +import gg.data.user.User; import gg.pingpong.api.user.game.service.GameFindService; import gg.pingpong.api.user.store.dto.UserGameCoinResultDto; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.store.CoinPolicyRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.exception.coin.CoinPolicyNotFoundException; -import gg.pingpong.utils.exception.user.UserAlreadyAttendanceException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.store.CoinPolicyRepository; +import gg.repo.user.UserRepository; +import gg.utils.exception.coin.CoinPolicyNotFoundException; +import gg.utils.exception.user.UserAlreadyAttendanceException; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/request/TournamentFilterRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/request/TournamentFilterRequestDto.java index a6aaed726..a0f1d7621 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/request/TournamentFilterRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/request/TournamentFilterRequestDto.java @@ -1,8 +1,8 @@ package gg.pingpong.api.user.tournament.controller.request; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; import gg.pingpong.api.global.dto.PageRequestDto; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; import lombok.Getter; @Getter diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentGameResDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentGameResDto.java index 4a0ae9409..246488cc0 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentGameResDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentGameResDto.java @@ -1,9 +1,9 @@ package gg.pingpong.api.user.tournament.controller.response; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.type.TournamentRound; import gg.pingpong.api.user.game.controller.response.GameResultResDto; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.type.TournamentRound; -import gg.pingpong.repo.game.out.GameTeamUser; +import gg.repo.game.out.GameTeamUser; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentResponseDto.java index eb8d1b8da..2a10b819e 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentResponseDto.java @@ -2,11 +2,11 @@ import java.time.LocalDateTime; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentUser; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; import gg.pingpong.api.user.user.dto.UserImageDto; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentUser; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserListResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserListResponseDto.java index 74317e828..818afd763 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserListResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserListResponseDto.java @@ -4,7 +4,7 @@ import java.util.Comparator; import java.util.List; -import gg.pingpong.data.tournament.TournamentUser; +import gg.data.tournament.TournamentUser; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserRegistrationResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserRegistrationResponseDto.java index 49aec0c1b..5858017cb 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserRegistrationResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserRegistrationResponseDto.java @@ -1,6 +1,6 @@ package gg.pingpong.api.user.tournament.controller.response; -import gg.pingpong.data.tournament.type.TournamentUserStatus; +import gg.data.tournament.type.TournamentUserStatus; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserResponseDto.java index d2156f75b..acb5f83ae 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/controller/response/TournamentUserResponseDto.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import gg.pingpong.data.tournament.TournamentUser; +import gg.data.tournament.TournamentUser; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/service/TournamentService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/service/TournamentService.java index e8b2dc2bb..854e3b995 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/service/TournamentService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/tournament/service/TournamentService.java @@ -14,6 +14,16 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.noti.type.NotiType; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.TournamentUser; +import gg.data.tournament.type.RoundNumber; +import gg.data.tournament.type.TournamentRound; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; +import gg.data.tournament.type.TournamentUserStatus; +import gg.data.user.User; import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; import gg.pingpong.api.admin.noti.service.NotiAdminService; import gg.pingpong.api.user.match.service.MatchTournamentService; @@ -23,28 +33,18 @@ import gg.pingpong.api.user.tournament.controller.response.TournamentResponseDto; import gg.pingpong.api.user.tournament.controller.response.TournamentUserRegistrationResponseDto; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.noti.type.NotiType; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.TournamentUser; -import gg.pingpong.data.tournament.type.RoundNumber; -import gg.pingpong.data.tournament.type.TournamentRound; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; -import gg.pingpong.data.tournament.type.TournamentUserStatus; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.game.out.GameTeamUser; -import gg.pingpong.repo.tournarment.TournamentGameRepository; -import gg.pingpong.repo.tournarment.TournamentRepository; -import gg.pingpong.repo.tournarment.TournamentUserRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; -import gg.pingpong.utils.exception.tournament.TournamentConflictException; -import gg.pingpong.utils.exception.tournament.TournamentNotFoundException; -import gg.pingpong.utils.exception.tournament.TournamentUpdateException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.game.out.GameTeamUser; +import gg.repo.tournarment.TournamentGameRepository; +import gg.repo.tournarment.TournamentRepository; +import gg.repo.tournarment.TournamentUserRepository; +import gg.repo.user.UserRepository; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; +import gg.utils.exception.tournament.TournamentConflictException; +import gg.utils.exception.tournament.TournamentNotFoundException; +import gg.utils.exception.tournament.TournamentUpdateException; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/UserController.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/UserController.java index 72251fd2f..3afc31df1 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/UserController.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/UserController.java @@ -26,6 +26,9 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import gg.data.game.type.Mode; +import gg.data.user.type.OauthType; +import gg.data.user.type.RoleType; import gg.pingpong.api.global.dto.PageRequestDto; import gg.pingpong.api.global.security.cookie.CookieUtil; import gg.pingpong.api.global.security.jwt.utils.TokenHeaders; @@ -51,10 +54,7 @@ import gg.pingpong.api.user.user.service.UserAuthenticationService; import gg.pingpong.api.user.user.service.UserCoinService; import gg.pingpong.api.user.user.service.UserService; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.user.type.OauthType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.utils.exception.user.KakaoOauth2AlreadyExistException; +import gg.utils.exception.user.KakaoOauth2AlreadyExistException; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/request/UserModifyRequestDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/request/UserModifyRequestDto.java index 4323aef44..97df4e0bc 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/request/UserModifyRequestDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/request/UserModifyRequestDto.java @@ -1,7 +1,7 @@ package gg.pingpong.api.user.user.controller.request; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.SnsType; +import gg.data.user.type.RacketType; +import gg.data.user.type.SnsType; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/CoinHistoryResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/CoinHistoryResponseDto.java index 9e33bbed3..8fc5badb6 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/CoinHistoryResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/CoinHistoryResponseDto.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import gg.pingpong.data.store.CoinHistory; +import gg.data.store.CoinHistory; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserDetailResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserDetailResponseDto.java index dd971eb9b..9ed2874b5 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserDetailResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserDetailResponseDto.java @@ -1,11 +1,11 @@ package gg.pingpong.api.user.user.controller.response; +import gg.data.rank.Tier; +import gg.data.user.User; +import gg.data.user.type.BackgroundType; +import gg.data.user.type.EdgeType; +import gg.data.user.type.SnsType; import gg.pingpong.api.global.utils.ExpLevelCalculator; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.BackgroundType; -import gg.pingpong.data.user.type.EdgeType; -import gg.pingpong.data.user.type.SnsType; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserLiveResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserLiveResponseDto.java index 8276412bd..780d552f6 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserLiveResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserLiveResponseDto.java @@ -1,6 +1,6 @@ package gg.pingpong.api.user.user.controller.response; -import gg.pingpong.data.game.type.Mode; +import gg.data.game.type.Mode; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserNormalDetailResponseDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserNormalDetailResponseDto.java index 752ed8888..95cdb41ff 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserNormalDetailResponseDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/controller/response/UserNormalDetailResponseDto.java @@ -1,6 +1,6 @@ package gg.pingpong.api.user.user.controller.response; -import gg.pingpong.data.user.type.EdgeType; +import gg.data.user.type.EdgeType; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserDto.java index 171b5aa88..1d95daf26 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserDto.java @@ -1,9 +1,9 @@ package gg.pingpong.api.user.user.dto; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import lombok.Builder; import lombok.Getter; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserHistoryData.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserHistoryData.java index 9044f3aea..6648c9f6b 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserHistoryData.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserHistoryData.java @@ -2,7 +2,7 @@ import java.time.LocalDateTime; -import gg.pingpong.data.game.PChange; +import gg.data.game.PChange; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserImageDto.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserImageDto.java index 49b7b3400..02fbe549d 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserImageDto.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/dto/UserImageDto.java @@ -1,7 +1,7 @@ package gg.pingpong.api.user.user.dto; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.EdgeType; +import gg.data.user.User; +import gg.data.user.type.EdgeType; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserAuthenticationService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserAuthenticationService.java index c168938fd..cc79e0045 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserAuthenticationService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserAuthenticationService.java @@ -4,7 +4,7 @@ import gg.pingpong.api.global.security.jwt.repository.JwtRedisRepository; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.utils.exception.user.TokenNotValidException; +import gg.utils.exception.user.TokenNotValidException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserCoinService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserCoinService.java index d683ccd15..afa6c7408 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserCoinService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserCoinService.java @@ -5,14 +5,14 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.store.CoinHistory; +import gg.data.user.User; import gg.pingpong.api.user.user.controller.response.CoinHistoryResponseDto; import gg.pingpong.api.user.user.controller.response.UserCoinHistoryListResponseDto; import gg.pingpong.api.user.user.controller.response.UserCoinResponseDto; -import gg.pingpong.data.store.CoinHistory; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.store.CoinHistoryRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.store.CoinHistoryRepository; +import gg.repo.user.UserRepository; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserFindService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserFindService.java index 84552b787..0f6f6a7d6 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserFindService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserFindService.java @@ -5,15 +5,15 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.user.User; import gg.pingpong.api.user.season.service.SeasonFindService; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.exception.rank.RedisDataNotFoundException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.user.UserRepository; +import gg.utils.RedisKeyManager; +import gg.utils.exception.rank.RedisDataNotFoundException; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserService.java index c94d92142..eeae4bcdc 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/user/service/UserService.java @@ -16,6 +16,23 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import gg.data.game.Game; +import gg.data.game.PChange; +import gg.data.game.type.StatusType; +import gg.data.rank.Rank; +import gg.data.rank.Tier; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.store.Receipt; +import gg.data.store.type.ItemStatus; +import gg.data.store.type.ItemType; +import gg.data.user.User; +import gg.data.user.UserImage; +import gg.data.user.type.BackgroundType; +import gg.data.user.type.EdgeType; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.global.utils.ExpLevelCalculator; import gg.pingpong.api.global.utils.aws.AsyncNewUserImageUploader; import gg.pingpong.api.user.rank.service.RankFindService; @@ -37,45 +54,28 @@ import gg.pingpong.api.user.user.dto.UserHistoryData; import gg.pingpong.api.user.user.dto.UserImageDto; import gg.pingpong.api.user.user.dto.UserTextColorDto; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.PChange; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.rank.Rank; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.store.Receipt; -import gg.pingpong.data.store.type.ItemStatus; -import gg.pingpong.data.store.type.ItemType; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.UserImage; -import gg.pingpong.data.user.type.BackgroundType; -import gg.pingpong.data.user.type.EdgeType; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.game.PChangeRepository; -import gg.pingpong.repo.match.RedisMatchUserRepository; -import gg.pingpong.repo.noti.NotiRepository; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.RankV2Dto; -import gg.pingpong.repo.rank.TierRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.store.ReceiptRepository; -import gg.pingpong.repo.user.UserImageRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.exception.pchange.PChangeNotExistException; -import gg.pingpong.utils.exception.rank.RankNotFoundException; -import gg.pingpong.utils.exception.rank.RedisDataNotFoundException; -import gg.pingpong.utils.exception.receipt.ReceiptNotFoundException; -import gg.pingpong.utils.exception.tier.TierNotFoundException; -import gg.pingpong.utils.exception.user.UserImageLargeException; -import gg.pingpong.utils.exception.user.UserImageNullException; -import gg.pingpong.utils.exception.user.UserImageTypeException; -import gg.pingpong.utils.exception.user.UserNotFoundException; -import gg.pingpong.utils.exception.user.UserTextColorException; +import gg.repo.game.GameRepository; +import gg.repo.game.PChangeRepository; +import gg.repo.match.RedisMatchUserRepository; +import gg.repo.noti.NotiRepository; +import gg.repo.rank.RankRepository; +import gg.repo.rank.RankV2Dto; +import gg.repo.rank.TierRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.store.ReceiptRepository; +import gg.repo.user.UserImageRepository; +import gg.repo.user.UserRepository; +import gg.utils.RedisKeyManager; +import gg.utils.exception.pchange.PChangeNotExistException; +import gg.utils.exception.rank.RankNotFoundException; +import gg.utils.exception.rank.RedisDataNotFoundException; +import gg.utils.exception.receipt.ReceiptNotFoundException; +import gg.utils.exception.tier.TierNotFoundException; +import gg.utils.exception.user.UserImageLargeException; +import gg.utils.exception.user.UserImageNullException; +import gg.utils.exception.user.UserImageTypeException; +import gg.utils.exception.user.UserNotFoundException; +import gg.utils.exception.user.UserTextColorException; import lombok.RequiredArgsConstructor; @Service diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/ServerPingpongApiApplicationTests.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/ServerPingpongApiApplicationTests.java index 2c3659ec2..d6350dc89 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/ServerPingpongApiApplicationTests.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/ServerPingpongApiApplicationTests.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.utils.annotation.IntegrationTest; @IntegrationTest class ServerPingpongApiApplicationTests { diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerFailTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerFailTest.java index 6c15ec17a..f16fdb198 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerFailTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerFailTest.java @@ -13,10 +13,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import gg.pingpong.admin.repo.manage.AnnouncementAdminRepository; +import gg.admin.repo.manage.AnnouncementAdminRepository; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerTest.java index 33e976b68..bfa486b51 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerTest.java @@ -15,14 +15,14 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import gg.pingpong.admin.repo.manage.AnnouncementAdminRepository; +import gg.admin.repo.manage.AnnouncementAdminRepository; +import gg.data.manage.Announcement; import gg.pingpong.api.admin.manage.controller.response.AnnouncementAdminListResponseDto; import gg.pingpong.api.admin.manage.dto.AnnouncementAdminAddDto; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.data.manage.Announcement; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.exception.announcement.AnnounceNotFoundException; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.exception.announcement.AnnounceNotFoundException; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java index 16aafd1ce..bea390428 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/controller/AnnouncementAdminControllerUnitTest.java @@ -17,7 +17,7 @@ import gg.pingpong.api.admin.manage.dto.AnnouncementAdminAddDto; import gg.pingpong.api.admin.manage.service.AnnouncementAdminService; import gg.pingpong.api.global.dto.PageRequestDto; -import gg.pingpong.utils.annotation.UnitTest; +import gg.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/service/AnnouncementAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/service/AnnouncementAdminServiceUnitTest.java index 6156a8e22..c2c7c09de 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/service/AnnouncementAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/announcement/service/AnnouncementAdminServiceUnitTest.java @@ -19,13 +19,13 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import gg.pingpong.admin.repo.manage.AnnouncementAdminRepository; +import gg.admin.repo.manage.AnnouncementAdminRepository; +import gg.data.manage.Announcement; import gg.pingpong.api.admin.manage.dto.AnnouncementAdminAddDto; import gg.pingpong.api.admin.manage.service.AnnouncementAdminService; -import gg.pingpong.data.manage.Announcement; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.announcement.AnnounceDupException; -import gg.pingpong.utils.exception.announcement.AnnounceNotFoundException; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.announcement.AnnounceDupException; +import gg.utils.exception.announcement.AnnounceNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinAdminControllerTest.java index 2a17455d6..7c793e47c 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinAdminControllerTest.java @@ -17,9 +17,9 @@ import gg.pingpong.api.admin.store.controller.request.CoinUpdateRequestDto; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.user.UserRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinPolicyAdminControllerFailTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinPolicyAdminControllerFailTest.java index 23330d5c9..269e280fc 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinPolicyAdminControllerFailTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinPolicyAdminControllerFailTest.java @@ -14,11 +14,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import gg.pingpong.admin.repo.store.CoinPolicyAdminRepository; +import gg.admin.repo.store.CoinPolicyAdminRepository; import gg.pingpong.api.admin.store.dto.CoinPolicyAdminAddDto; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinPolicyAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinPolicyAdminControllerTest.java index e0a25e218..b31cc0581 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinPolicyAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/controller/CoinPolicyAdminControllerTest.java @@ -17,15 +17,15 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import gg.pingpong.admin.repo.store.CoinPolicyAdminRepository; +import gg.admin.repo.store.CoinPolicyAdminRepository; +import gg.data.store.CoinPolicy; +import gg.data.user.User; import gg.pingpong.api.admin.store.controller.response.CoinPolicyAdminListResponseDto; import gg.pingpong.api.admin.store.dto.CoinPolicyAdminAddDto; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.data.store.CoinPolicy; -import gg.pingpong.data.user.User; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.exception.coin.CoinPolicyNotFoundException; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.exception.coin.CoinPolicyNotFoundException; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/service/CoinAdminServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/service/CoinAdminServiceTest.java index b3ebecd1b..18e7d0916 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/service/CoinAdminServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/coin/service/CoinAdminServiceTest.java @@ -14,14 +14,14 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import gg.data.store.CoinHistory; +import gg.data.user.User; import gg.pingpong.api.admin.store.controller.request.CoinUpdateRequestDto; import gg.pingpong.api.admin.store.service.CoinAdminService; import gg.pingpong.api.user.store.service.CoinHistoryService; -import gg.pingpong.data.store.CoinHistory; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.user.UserRepository; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/controller/FeedbackAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/controller/FeedbackAdminControllerTest.java index 938fc97ce..4f3d7304e 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/controller/FeedbackAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/controller/FeedbackAdminControllerTest.java @@ -14,15 +14,15 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import gg.pingpong.admin.repo.manage.FeedbackAdminRepository; +import gg.admin.repo.manage.FeedbackAdminRepository; +import gg.data.manage.Feedback; +import gg.data.manage.type.FeedbackType; +import gg.data.user.User; import gg.pingpong.api.admin.manage.controller.response.FeedbackListAdminResponseDto; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.data.manage.Feedback; -import gg.pingpong.data.manage.type.FeedbackType; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.user.UserRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/controller/FeedbackAdminControllerUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/controller/FeedbackAdminControllerUnitTest.java index fc06b4084..be038724f 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/controller/FeedbackAdminControllerUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/controller/FeedbackAdminControllerUnitTest.java @@ -16,7 +16,7 @@ import gg.pingpong.api.admin.manage.controller.request.FeedbackAdminPageRequestDto; import gg.pingpong.api.admin.manage.controller.response.FeedbackListAdminResponseDto; import gg.pingpong.api.admin.manage.service.FeedbackAdminService; -import gg.pingpong.utils.annotation.UnitTest; +import gg.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/service/FeedbackAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/service/FeedbackAdminServiceUnitTest.java index 7e7130fab..868de05e8 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/service/FeedbackAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/feedback/service/FeedbackAdminServiceUnitTest.java @@ -18,13 +18,14 @@ import org.springframework.data.domain.Pageable; import org.springframework.test.util.ReflectionTestUtils; -import gg.pingpong.admin.repo.manage.FeedbackAdminRepository; +import gg.admin.repo.manage.FeedbackAdminRepository; +import gg.data.manage.Feedback; import gg.pingpong.api.admin.manage.service.FeedbackAdminService; -import gg.pingpong.data.manage.Feedback; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.feedback.FeedbackNotFoundException; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.feedback.FeedbackNotFoundException; @UnitTest + @ExtendWith(MockitoExtension.class) @DisplayName("FeedbackAdminServiceUnitTest") class FeedbackAdminServiceUnitTest { diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/game/controller/GameAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/game/controller/GameAdminControllerTest.java index 16c60334c..5c7f3b35c 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/game/controller/GameAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/game/controller/GameAdminControllerTest.java @@ -25,25 +25,25 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import gg.data.game.type.Mode; +import gg.data.rank.Rank; +import gg.data.rank.Tier; +import gg.data.season.Season; +import gg.data.user.User; import gg.pingpong.api.admin.game.controller.response.GameLogListAdminResponseDto; import gg.pingpong.api.admin.game.dto.RankGamePPPModifyReqDto; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.game.controller.request.RankResultReqDto; import gg.pingpong.api.user.game.service.GameService; import gg.pingpong.api.user.match.service.GameUpdateService; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.rank.Rank; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.game.out.GameTeamUser; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.dto.GameInfoDto; +import gg.repo.game.GameRepository; +import gg.repo.game.out.GameTeamUser; +import gg.repo.rank.RankRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.user.UserRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.dto.GameInfoDto; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/item/controller/ItemAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/item/controller/ItemAdminControllerTest.java index d2aa62eda..734c16218 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/item/controller/ItemAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/item/controller/ItemAdminControllerTest.java @@ -24,18 +24,18 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import gg.pingpong.admin.repo.store.ItemAdminRepository; +import gg.admin.repo.store.ItemAdminRepository; +import gg.data.store.Item; +import gg.data.store.type.ItemType; import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; import gg.pingpong.api.admin.store.controller.response.ItemListResponseDto; import gg.pingpong.api.admin.store.service.ItemAdminService; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.global.utils.ItemImageHandler; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.store.type.ItemType; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.ItemTestUtils; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.user.UserRepository; +import gg.utils.ItemTestUtils; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; @IntegrationTest @AutoConfigureMockMvc diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/item/service/ItemAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/item/service/ItemAdminServiceUnitTest.java index efb9d9bd2..18a30742d 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/item/service/ItemAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/item/service/ItemAdminServiceUnitTest.java @@ -20,19 +20,19 @@ import org.springframework.data.domain.Pageable; import org.springframework.web.multipart.MultipartFile; -import gg.pingpong.admin.repo.store.ItemAdminRepository; +import gg.admin.repo.store.ItemAdminRepository; +import gg.data.store.Item; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; import gg.pingpong.api.admin.store.service.ItemAdminService; import gg.pingpong.api.global.utils.aws.AsyncNewItemImageUploader; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.item.ItemNotAvailableException; -import gg.pingpong.utils.exception.item.ItemNotFoundException; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.item.ItemNotAvailableException; +import gg.utils.exception.item.ItemNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/megaphone/controller/MegaphoneAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/megaphone/controller/MegaphoneAdminControllerTest.java index b87cbe20a..7a8201a63 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/megaphone/controller/MegaphoneAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/megaphone/controller/MegaphoneAdminControllerTest.java @@ -13,8 +13,8 @@ import org.springframework.test.web.servlet.MockMvc; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java index b0c8a6ed7..fcbbe28b0 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/megaphone/service/MegaphoneAdminServiceUnitTest.java @@ -15,9 +15,9 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import gg.pingpong.admin.repo.store.MegaphoneAdminRepository; +import gg.admin.repo.store.MegaphoneAdminRepository; import gg.pingpong.api.admin.store.service.MegaphoneAdminService; -import gg.pingpong.utils.annotation.UnitTest; +import gg.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/noti/controller/NotiAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/noti/controller/NotiAdminControllerTest.java index d56523fbe..71343707a 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/noti/controller/NotiAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/noti/controller/NotiAdminControllerTest.java @@ -23,19 +23,19 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import gg.pingpong.admin.repo.noti.NotiAdminRepository; +import gg.admin.repo.noti.NotiAdminRepository; +import gg.data.noti.Noti; +import gg.data.noti.type.NotiType; +import gg.data.user.User; import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; import gg.pingpong.api.admin.noti.controller.response.NotiListAdminResponseDto; import gg.pingpong.api.admin.noti.dto.NotiAdminDto; import gg.pingpong.api.admin.noti.service.NotiAdminService; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.noti.type.NotiType; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.noti.NotiRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.noti.NotiRepository; +import gg.repo.user.UserRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/noti/service/NotiAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/noti/service/NotiAdminServiceUnitTest.java index 19e499883..62a19d4fa 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/noti/service/NotiAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/noti/service/NotiAdminServiceUnitTest.java @@ -18,15 +18,15 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import gg.pingpong.admin.repo.noti.NotiAdminRepository; -import gg.pingpong.admin.repo.user.UserAdminRepository; +import gg.admin.repo.noti.NotiAdminRepository; +import gg.admin.repo.user.UserAdminRepository; +import gg.data.noti.Noti; +import gg.data.user.User; import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; import gg.pingpong.api.user.noti.service.SnsNotiService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.user.User; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/penalty/controller/PenaltyAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/penalty/controller/PenaltyAdminControllerTest.java index 637998d7a..c67f02ef6 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/penalty/controller/PenaltyAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/penalty/controller/PenaltyAdminControllerTest.java @@ -28,22 +28,22 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import gg.pingpong.admin.repo.manage.PenaltyAdminRepository; -import gg.pingpong.admin.repo.manage.PenaltyUserAdminRedisRepository; +import gg.admin.repo.manage.PenaltyAdminRepository; +import gg.admin.repo.manage.PenaltyUserAdminRedisRepository; +import gg.data.manage.Penalty; +import gg.data.manage.redis.RedisPenaltyUser; +import gg.data.manage.type.PenaltyType; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.admin.manage.controller.request.PenaltyRequestDto; import gg.pingpong.api.admin.manage.controller.response.PenaltyListResponseDto; import gg.pingpong.api.admin.manage.service.PenaltyAdminService; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.data.manage.Penalty; -import gg.pingpong.data.manage.redis.RedisPenaltyUser; -import gg.pingpong.data.manage.type.PenaltyType; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.user.UserRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; @IntegrationTest @AutoConfigureMockMvc diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/receipt/controller/ReceiptAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/receipt/controller/ReceiptAdminControllerTest.java index 0a3d7847c..3a157f59e 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/receipt/controller/ReceiptAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/receipt/controller/ReceiptAdminControllerTest.java @@ -18,17 +18,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import gg.pingpong.admin.repo.store.ReceiptAdminRepository; +import gg.admin.repo.store.ReceiptAdminRepository; +import gg.data.store.Item; +import gg.data.store.type.ItemType; +import gg.data.user.User; import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; import gg.pingpong.api.admin.store.controller.response.ReceiptListResponseDto; import gg.pingpong.api.admin.store.service.ReceiptAdminService; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.store.type.ItemType; -import gg.pingpong.data.user.User; -import gg.pingpong.utils.ItemTestUtils; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.utils.ItemTestUtils; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; @IntegrationTest @AutoConfigureMockMvc diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/receipt/service/ReceiptAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/receipt/service/ReceiptAdminServiceUnitTest.java index b6a5cb51f..be06a7587 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/receipt/service/ReceiptAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/receipt/service/ReceiptAdminServiceUnitTest.java @@ -14,10 +14,10 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import gg.pingpong.admin.repo.store.ReceiptAdminRepository; +import gg.admin.repo.store.ReceiptAdminRepository; +import gg.data.store.Receipt; import gg.pingpong.api.admin.store.service.ReceiptAdminService; -import gg.pingpong.data.store.Receipt; -import gg.pingpong.utils.annotation.UnitTest; +import gg.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/controller/SeasonAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/controller/SeasonAdminControllerTest.java index fad13af5f..fdc758d2e 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/controller/SeasonAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/controller/SeasonAdminControllerTest.java @@ -19,7 +19,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.net.HttpHeaders; -import gg.pingpong.admin.repo.season.SeasonAdminRepository; +import gg.admin.repo.season.SeasonAdminRepository; +import gg.data.rank.Tier; +import gg.data.season.Season; import gg.pingpong.api.admin.rank.service.RankAdminService; import gg.pingpong.api.admin.rank.service.RankRedisAdminService; import gg.pingpong.api.admin.season.controller.request.SeasonCreateRequestDto; @@ -28,16 +30,14 @@ import gg.pingpong.api.admin.season.dto.SeasonAdminDto; import gg.pingpong.api.admin.season.service.SeasonAdminService; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.season.Season; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.exception.rank.RedisDataNotFoundException; -import gg.pingpong.utils.exception.season.SeasonForbiddenException; -import gg.pingpong.utils.exception.season.SeasonNotFoundException; +import gg.repo.rank.RankRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.utils.RedisKeyManager; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.exception.rank.RedisDataNotFoundException; +import gg.utils.exception.season.SeasonForbiddenException; +import gg.utils.exception.season.SeasonNotFoundException; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/service/SeasonAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/service/SeasonAdminServiceUnitTest.java index daf55c386..1022bcc8f 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/service/SeasonAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/season/service/SeasonAdminServiceUnitTest.java @@ -19,16 +19,16 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import gg.pingpong.admin.repo.season.SeasonAdminRepository; +import gg.admin.repo.season.SeasonAdminRepository; +import gg.data.season.Season; import gg.pingpong.api.admin.rank.service.RankAdminService; import gg.pingpong.api.admin.rank.service.RankRedisAdminService; import gg.pingpong.api.admin.season.controller.request.SeasonCreateRequestDto; import gg.pingpong.api.admin.season.controller.request.SeasonUpdateRequestDto; -import gg.pingpong.data.season.Season; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.season.SeasonForbiddenException; -import gg.pingpong.utils.exception.season.SeasonNotFoundException; -import gg.pingpong.utils.exception.season.SeasonTimeBeforeException; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.season.SeasonForbiddenException; +import gg.utils.exception.season.SeasonNotFoundException; +import gg.utils.exception.season.SeasonTimeBeforeException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/controller/SlotAdminControllerFailTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/controller/SlotAdminControllerFailTest.java index 1d791935f..2d6f207cd 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/controller/SlotAdminControllerFailTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/controller/SlotAdminControllerFailTest.java @@ -17,13 +17,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import gg.pingpong.admin.repo.manage.AdminSlotManagementsRepository; +import gg.admin.repo.manage.AdminSlotManagementsRepository; +import gg.data.manage.SlotManagement; import gg.pingpong.api.admin.manage.controller.request.SlotCreateRequestDto; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.manage.SlotManagementRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/controller/SlotAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/controller/SlotAdminControllerTest.java index 8b9b0afee..f41d37e56 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/controller/SlotAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/controller/SlotAdminControllerTest.java @@ -18,15 +18,15 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import gg.pingpong.admin.repo.manage.AdminSlotManagementsRepository; +import gg.admin.repo.manage.AdminSlotManagementsRepository; +import gg.data.manage.SlotManagement; import gg.pingpong.api.admin.manage.controller.request.SlotCreateRequestDto; import gg.pingpong.api.admin.manage.controller.response.SlotListAdminResponseDto; import gg.pingpong.api.admin.manage.dto.SlotAdminDto; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.manage.SlotManagementRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/service/SlotAdminServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/service/SlotAdminServiceUnitTest.java index c4919577b..63fe2d374 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/service/SlotAdminServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/slotmanagement/service/SlotAdminServiceUnitTest.java @@ -18,12 +18,12 @@ import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -import gg.pingpong.admin.repo.manage.AdminSlotManagementsRepository; +import gg.admin.repo.manage.AdminSlotManagementsRepository; +import gg.data.manage.SlotManagement; import gg.pingpong.api.admin.manage.controller.request.SlotCreateRequestDto; import gg.pingpong.api.admin.manage.service.SlotAdminService; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.slotmanagement.SlotManagementForbiddenException; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.slotmanagement.SlotManagementForbiddenException; @UnitTest class SlotAdminServiceUnitTest { diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminControllerTest.java index fdf7d6384..f5aa141e6 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminControllerTest.java @@ -21,6 +21,15 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import gg.data.game.type.Mode; +import gg.data.season.Season; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.TournamentUser; +import gg.data.tournament.type.TournamentRound; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; +import gg.data.user.User; import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminAddUserRequestDto; import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminCreateRequestDto; import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminUpdateRequestDto; @@ -29,24 +38,15 @@ import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.game.dto.TeamReqDto; import gg.pingpong.api.user.match.utils.MatchIntegrationTestUtils; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.TournamentUser; -import gg.pingpong.data.tournament.type.TournamentRound; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.PChangeRepository; -import gg.pingpong.repo.tournarment.TournamentGameRepository; -import gg.pingpong.repo.tournarment.TournamentRepository; -import gg.pingpong.repo.tournarment.TournamentUserRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.dto.GameInfoDto; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.CustomRuntimeException; +import gg.repo.game.PChangeRepository; +import gg.repo.tournarment.TournamentGameRepository; +import gg.repo.tournarment.TournamentRepository; +import gg.repo.tournarment.TournamentUserRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.dto.GameInfoDto; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.CustomRuntimeException; import lombok.RequiredArgsConstructor; @IntegrationTest diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminUserControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminUserControllerTest.java index 10d3e18ec..3ed665cae 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminUserControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/controller/TournamentAdminUserControllerTest.java @@ -16,15 +16,15 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import gg.data.tournament.Tournament; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.tournament.controller.response.TournamentUserListResponseDto; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.extern.slf4j.Slf4j; @IntegrationTest diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/service/TournamentAdminServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/service/TournamentAdminServiceTest.java index 3a1534492..e34413789 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/service/TournamentAdminServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/tournament/service/TournamentAdminServiceTest.java @@ -17,34 +17,34 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import gg.data.game.Game; +import gg.data.manage.SlotManagement; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.TournamentUser; +import gg.data.tournament.type.TournamentRound; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminAddUserRequestDto; import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminCreateRequestDto; import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminUpdateRequestDto; import gg.pingpong.api.global.config.ConstantConfig; import gg.pingpong.api.utils.ReflectionUtilsForUnitTest; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.TournamentUser; -import gg.pingpong.data.tournament.type.TournamentRound; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.repo.tournarment.TournamentGameRepository; -import gg.pingpong.repo.tournarment.TournamentRepository; -import gg.pingpong.repo.tournarment.TournamentUserRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.tournament.TournamentConflictException; -import gg.pingpong.utils.exception.tournament.TournamentNotFoundException; -import gg.pingpong.utils.exception.tournament.TournamentUpdateException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.manage.SlotManagementRepository; +import gg.repo.tournarment.TournamentGameRepository; +import gg.repo.tournarment.TournamentRepository; +import gg.repo.tournarment.TournamentUserRepository; +import gg.repo.user.UserRepository; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.tournament.TournamentConflictException; +import gg.utils.exception.tournament.TournamentNotFoundException; +import gg.utils.exception.tournament.TournamentUpdateException; +import gg.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/user/controller/UserAdminControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/user/controller/UserAdminControllerTest.java index b5e31f7cc..f07602ba8 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/user/controller/UserAdminControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/admin/user/controller/UserAdminControllerTest.java @@ -22,8 +22,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import gg.pingpong.admin.repo.user.UserAdminRepository; -import gg.pingpong.admin.repo.user.UserImageAdminRepository; +import gg.admin.repo.user.UserAdminRepository; +import gg.admin.repo.user.UserImageAdminRepository; +import gg.data.user.User; +import gg.data.user.UserImage; import gg.pingpong.api.admin.user.controller.response.UserDetailAdminResponseDto; import gg.pingpong.api.admin.user.controller.response.UserImageListAdminResponseDto; import gg.pingpong.api.admin.user.controller.response.UserSearchAdminResponseDto; @@ -31,12 +33,10 @@ import gg.pingpong.api.admin.user.dto.UserSearchAdminDto; import gg.pingpong.api.admin.user.service.UserAdminService; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.UserImage; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.user.UserRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/GameUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/GameUnitTest.java index d214e1ef1..ce67c4ca7 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/GameUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/GameUnitTest.java @@ -13,11 +13,11 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.Team; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.data.game.Game; +import gg.data.game.Team; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; @UnitTest @DisplayName("GameUnitTest") diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/PChangeDataTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/PChangeDataTest.java index 28a1b7c31..3db8c6c64 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/PChangeDataTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/PChangeDataTest.java @@ -5,8 +5,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; -import gg.pingpong.data.game.PChange; -import gg.pingpong.utils.annotation.UnitTest; +import gg.data.game.PChange; +import gg.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TeamUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TeamUnitTest.java index 0222884b6..1bb720d3a 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TeamUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TeamUnitTest.java @@ -13,11 +13,11 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.data.game.Team; +import gg.data.game.TeamUser; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; @UnitTest @DisplayName("TeamUnitTest") diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TournamentGameUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TournamentGameUnitTest.java index 18b495481..27519a10e 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TournamentGameUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TournamentGameUnitTest.java @@ -8,12 +8,12 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; -import gg.pingpong.utils.annotation.UnitTest; +import gg.data.game.Game; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; +import gg.utils.annotation.UnitTest; @UnitTest @DisplayName("TournamentGameUnitTest") diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TournamentUserUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TournamentUserUnitTest.java index 0313d7235..f96c9afc0 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TournamentUserUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/game/TournamentUserUnitTest.java @@ -8,12 +8,12 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentUser; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; -import gg.pingpong.data.user.User; -import gg.pingpong.utils.annotation.UnitTest; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentUser; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; +import gg.data.user.User; +import gg.utils.annotation.UnitTest; @UnitTest @DisplayName("TournamentUserUnitTest") diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/data/manage/AnnouncementUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/manage/AnnouncementUnitTest.java index 1c73b54b0..b813cbd68 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/data/manage/AnnouncementUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/manage/AnnouncementUnitTest.java @@ -10,9 +10,9 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; +import gg.data.manage.Announcement; import gg.pingpong.api.admin.manage.dto.AnnouncementAdminAddDto; -import gg.pingpong.data.manage.Announcement; -import gg.pingpong.utils.annotation.UnitTest; +import gg.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/data/store/ItemUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/store/ItemUnitTest.java index 9a36ec7e8..33da59006 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/data/store/ItemUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/data/store/ItemUnitTest.java @@ -9,8 +9,8 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; -import gg.pingpong.data.store.Item; -import gg.pingpong.utils.annotation.UnitTest; +import gg.data.store.Item; +import gg.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/controller/AnnouncementControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/controller/AnnouncementControllerTest.java index 36637e01b..f8c207877 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/controller/AnnouncementControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/controller/AnnouncementControllerTest.java @@ -16,13 +16,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import gg.data.manage.Announcement; +import gg.data.user.User; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.data.manage.Announcement; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.manage.AnnouncementRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.exception.announcement.AnnounceNotFoundException; +import gg.repo.manage.AnnouncementRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.exception.announcement.AnnounceNotFoundException; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/controller/AnnouncementControllerUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/controller/AnnouncementControllerUnitTest.java index 346450601..a6ac432bb 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/controller/AnnouncementControllerUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/controller/AnnouncementControllerUnitTest.java @@ -15,7 +15,7 @@ import gg.pingpong.api.user.manage.controller.response.AnnouncementResponseDto; import gg.pingpong.api.user.manage.dto.AnnouncementDto; import gg.pingpong.api.user.manage.service.AnnouncementService; -import gg.pingpong.utils.annotation.UnitTest; +import gg.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/service/AnnouncementServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/service/AnnouncementServiceUnitTest.java index 311158454..f30e86f5c 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/service/AnnouncementServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/announcement/service/AnnouncementServiceUnitTest.java @@ -14,11 +14,11 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import gg.data.manage.Announcement; import gg.pingpong.api.user.manage.service.AnnouncementService; -import gg.pingpong.data.manage.Announcement; -import gg.pingpong.repo.manage.AnnouncementRepository; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.announcement.AnnounceNotFoundException; +import gg.repo.manage.AnnouncementRepository; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.announcement.AnnounceNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/coin/service/CoinHistoryServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/coin/service/CoinHistoryServiceTest.java index 75e03958a..3b61b83ba 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/coin/service/CoinHistoryServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/coin/service/CoinHistoryServiceTest.java @@ -10,16 +10,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; +import gg.data.store.CoinHistory; +import gg.data.store.CoinPolicy; +import gg.data.user.User; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.store.service.CoinHistoryService; -import gg.pingpong.data.store.CoinHistory; -import gg.pingpong.data.store.CoinPolicy; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.store.CoinHistoryRepository; -import gg.pingpong.repo.store.CoinPolicyRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.store.CoinHistoryRepository; +import gg.repo.store.CoinPolicyRepository; +import gg.repo.user.UserRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @IntegrationTest diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/coin/service/UserCoinChangeServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/coin/service/UserCoinChangeServiceTest.java index bd4e8def1..afcf7a41b 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/coin/service/UserCoinChangeServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/coin/service/UserCoinChangeServiceTest.java @@ -10,25 +10,25 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; +import gg.data.game.Game; +import gg.data.game.type.Mode; +import gg.data.season.Season; +import gg.data.store.CoinPolicy; +import gg.data.store.Item; +import gg.data.store.type.ItemType; +import gg.data.user.User; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.store.dto.UserGameCoinResultDto; import gg.pingpong.api.user.store.service.CoinHistoryService; import gg.pingpong.api.user.store.service.UserCoinChangeService; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.store.CoinPolicy; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.store.type.ItemType; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.store.CoinHistoryRepository; -import gg.pingpong.repo.store.CoinPolicyRepository; -import gg.pingpong.repo.store.ItemRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.exception.coin.CoinHistoryNotFoundException; -import gg.pingpong.utils.exception.coin.CoinPolicyNotFoundException; +import gg.repo.store.CoinHistoryRepository; +import gg.repo.store.CoinPolicyRepository; +import gg.repo.store.ItemRepository; +import gg.repo.user.UserRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.exception.coin.CoinHistoryNotFoundException; +import gg.utils.exception.coin.CoinPolicyNotFoundException; import lombok.RequiredArgsConstructor; @IntegrationTest diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/controller/FeedbackControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/controller/FeedbackControllerTest.java index d744a12c6..ea796ed73 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/controller/FeedbackControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/controller/FeedbackControllerTest.java @@ -15,13 +15,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import gg.data.manage.Feedback; +import gg.data.manage.type.FeedbackType; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.manage.controller.request.FeedbackRequestDto; -import gg.pingpong.data.manage.Feedback; -import gg.pingpong.data.manage.type.FeedbackType; -import gg.pingpong.repo.manage.FeedbackRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.manage.FeedbackRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/controller/FeedbackControllerUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/controller/FeedbackControllerUnitTest.java index f3a24fb80..be96ba9ac 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/controller/FeedbackControllerUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/controller/FeedbackControllerUnitTest.java @@ -14,7 +14,7 @@ import gg.pingpong.api.user.manage.controller.request.FeedbackRequestDto; import gg.pingpong.api.user.manage.service.FeedbackService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.utils.annotation.UnitTest; +import gg.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/service/FeedbackServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/service/FeedbackServiceUnitTest.java index 7e23b8c13..452020e35 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/service/FeedbackServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/feedback/service/FeedbackServiceUnitTest.java @@ -13,14 +13,14 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import gg.data.manage.Feedback; +import gg.data.user.User; import gg.pingpong.api.user.manage.controller.request.FeedbackRequestDto; import gg.pingpong.api.user.manage.service.FeedbackService; -import gg.pingpong.data.manage.Feedback; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.manage.FeedbackRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.manage.FeedbackRepository; +import gg.repo.user.UserRepository; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/GameControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/GameControllerTest.java index 44d117837..ff71b42b0 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/GameControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/GameControllerTest.java @@ -25,6 +25,22 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import gg.data.game.Game; +import gg.data.game.PChange; +import gg.data.game.Team; +import gg.data.game.TeamUser; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.data.rank.Rank; +import gg.data.rank.Tier; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.game.controller.request.RankResultReqDto; import gg.pingpong.api.user.game.controller.request.TournamentResultReqDto; @@ -33,34 +49,18 @@ import gg.pingpong.api.user.game.service.GameFindService; import gg.pingpong.api.user.game.service.GameService; import gg.pingpong.api.user.rank.redis.RankRedisService; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.PChange; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.rank.Rank; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.game.PChangeRepository; -import gg.pingpong.repo.game.TeamRepository; -import gg.pingpong.repo.game.TeamUserRepository; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.TierRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.season.SeasonRepository; -import gg.pingpong.repo.tournarment.TournamentRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.game.GameRepository; +import gg.repo.game.PChangeRepository; +import gg.repo.game.TeamRepository; +import gg.repo.game.TeamUserRepository; +import gg.repo.rank.RankRepository; +import gg.repo.rank.TierRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.season.SeasonRepository; +import gg.repo.tournarment.TournamentRepository; +import gg.utils.RedisKeyManager; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @IntegrationTest diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameDBTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameDBTest.java index a3b1b6f88..dd1fad1e7 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameDBTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameDBTest.java @@ -17,21 +17,21 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.transaction.annotation.Transactional; +import gg.data.game.Game; +import gg.data.game.Team; +import gg.data.game.TeamUser; +import gg.data.game.type.Mode; +import gg.data.season.Season; +import gg.data.user.User; import gg.pingpong.api.admin.game.service.GameAdminService; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.game.PChangeRepository; -import gg.pingpong.repo.game.TeamRepository; -import gg.pingpong.repo.game.TeamUserRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.game.GameRepository; +import gg.repo.game.PChangeRepository; +import gg.repo.game.TeamRepository; +import gg.repo.game.TeamUserRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameFindServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameFindServiceTest.java index bdb9adc7d..deca8b8f5 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameFindServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameFindServiceTest.java @@ -16,24 +16,24 @@ import org.springframework.data.domain.Sort; import org.springframework.transaction.annotation.Transactional; +import gg.data.game.Game; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.data.rank.Tier; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.user.User; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.game.controller.response.GameListResDto; import gg.pingpong.api.user.game.controller.response.GameResultResDto; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.game.out.GameTeamUser; -import gg.pingpong.repo.rank.TierRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.exception.tier.TierNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.game.out.GameTeamUser; +import gg.repo.rank.TierRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.utils.RedisKeyManager; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.exception.tier.TierNotFoundException; import lombok.RequiredArgsConstructor; @IntegrationTest diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameServiceTest.java index 16bcbb9c0..e26469fe4 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameServiceTest.java @@ -10,29 +10,29 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; +import gg.data.game.Game; +import gg.data.game.Team; +import gg.data.game.TeamUser; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.data.rank.Rank; +import gg.data.rank.Tier; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.user.User; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.game.controller.request.RankResultReqDto; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.rank.Rank; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.game.TeamRepository; -import gg.pingpong.repo.game.TeamUserRepository; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.TierRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.exception.rank.RankNotFoundException; -import gg.pingpong.utils.exception.tier.TierNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.game.TeamRepository; +import gg.repo.game.TeamUserRepository; +import gg.repo.rank.RankRepository; +import gg.repo.rank.TierRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.utils.RedisKeyManager; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.exception.rank.RankNotFoundException; +import gg.utils.exception.tier.TierNotFoundException; import lombok.RequiredArgsConstructor; @IntegrationTest diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameStatusServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameStatusServiceTest.java index 89f47bb5d..383b15f97 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameStatusServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/game/service/GameStatusServiceTest.java @@ -10,25 +10,25 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.game.TeamRepository; -import gg.pingpong.repo.game.TeamUserRepository; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.season.SeasonRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.data.game.Game; +import gg.data.game.Team; +import gg.data.game.TeamUser; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.data.manage.SlotManagement; +import gg.data.season.Season; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; +import gg.repo.game.GameRepository; +import gg.repo.game.TeamRepository; +import gg.repo.game.TeamUserRepository; +import gg.repo.manage.SlotManagementRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.season.SeasonRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @IntegrationTest diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemGiftControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemGiftControllerTest.java index 40c529f97..822070f34 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemGiftControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemGiftControllerTest.java @@ -21,8 +21,8 @@ import gg.pingpong.api.user.store.controller.request.ItemGiftRequestDto; import gg.pingpong.api.user.store.service.ItemService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemPurchaseControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemPurchaseControllerTest.java index 59e7f14c8..c9f285c73 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemPurchaseControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemPurchaseControllerTest.java @@ -19,8 +19,8 @@ import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.store.service.ItemService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemStoreListControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemStoreListControllerTest.java index 64b0a5659..48fc990f5 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemStoreListControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/ItemStoreListControllerTest.java @@ -1,6 +1,6 @@ package gg.pingpong.api.user.item.controller; -import static gg.pingpong.data.store.type.ItemType.*; +import static gg.data.store.type.ItemType.*; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; @@ -25,9 +25,9 @@ import gg.pingpong.api.user.store.controller.response.ItemStoreListResponseDto; import gg.pingpong.api.user.store.controller.response.ItemStoreResponseDto; import gg.pingpong.api.user.store.service.ItemService; -import gg.pingpong.repo.store.ItemRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.store.ItemRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/UserItemResponseControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/UserItemResponseControllerTest.java index f367714c6..3cedff4b8 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/UserItemResponseControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/controller/UserItemResponseControllerTest.java @@ -14,8 +14,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import gg.pingpong.api.user.store.service.ItemService; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; @IntegrationTest @AutoConfigureMockMvc diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/service/ItemServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/service/ItemServiceUnitTest.java index 9f88322e2..45aeb4b29 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/service/ItemServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/item/service/ItemServiceUnitTest.java @@ -20,31 +20,31 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; +import gg.data.store.Item; +import gg.data.store.Receipt; +import gg.data.store.type.ItemStatus; +import gg.data.store.type.ItemType; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.user.noti.service.NotiService; import gg.pingpong.api.user.store.service.ItemService; import gg.pingpong.api.user.store.service.UserCoinChangeService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.store.Receipt; -import gg.pingpong.data.store.type.ItemStatus; -import gg.pingpong.data.store.type.ItemType; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.store.ItemRepository; -import gg.pingpong.repo.store.ReceiptRepository; -import gg.pingpong.repo.store.UserItemRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.item.ItemNotFoundException; -import gg.pingpong.utils.exception.item.ItemNotPurchasableException; -import gg.pingpong.utils.exception.item.ItemTypeException; -import gg.pingpong.utils.exception.item.KakaoGiftException; -import gg.pingpong.utils.exception.item.KakaoPurchaseException; -import gg.pingpong.utils.exception.receipt.ItemStatusException; -import gg.pingpong.utils.exception.receipt.ReceiptNotOwnerException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.store.ItemRepository; +import gg.repo.store.ReceiptRepository; +import gg.repo.store.UserItemRepository; +import gg.repo.user.UserRepository; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.item.ItemNotFoundException; +import gg.utils.exception.item.ItemNotPurchasableException; +import gg.utils.exception.item.ItemTypeException; +import gg.utils.exception.item.KakaoGiftException; +import gg.utils.exception.item.KakaoPurchaseException; +import gg.utils.exception.receipt.ItemStatusException; +import gg.utils.exception.receipt.ReceiptNotOwnerException; +import gg.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/dto/MatchStatusDtoUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/dto/MatchStatusDtoUnitTest.java index 888a63427..b0e726e53 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/dto/MatchStatusDtoUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/dto/MatchStatusDtoUnitTest.java @@ -11,10 +11,10 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.utils.annotation.UnitTest; +import gg.data.game.Game; +import gg.data.game.type.Mode; +import gg.data.manage.SlotManagement; +import gg.utils.annotation.UnitTest; @UnitTest class MatchStatusDtoUnitTest { diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchBothServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchBothServiceTest.java index c7bdc2d43..6cac860e4 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchBothServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchBothServiceTest.java @@ -18,25 +18,25 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.admin.repo.manage.PenaltyAdminRepository; +import gg.admin.repo.manage.PenaltyAdminRepository; +import gg.data.game.Game; +import gg.data.manage.SlotManagement; +import gg.data.manage.type.PenaltyKey; +import gg.data.match.type.Option; +import gg.data.season.Season; +import gg.data.user.User; import gg.pingpong.api.user.manage.redis.PenaltyUserRedisRepository; import gg.pingpong.api.user.match.utils.MatchIntegrationTestUtils; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.manage.type.PenaltyKey; -import gg.pingpong.data.match.type.Option; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.repo.match.RedisMatchTimeRepository; -import gg.pingpong.repo.match.RedisMatchUserRepository; -import gg.pingpong.repo.noti.NotiRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.exception.match.SlotNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.manage.SlotManagementRepository; +import gg.repo.match.RedisMatchTimeRepository; +import gg.repo.match.RedisMatchUserRepository; +import gg.repo.noti.NotiRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.exception.match.SlotNotFoundException; import lombok.RequiredArgsConstructor; @IntegrationTest diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchFindServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchFindServiceUnitTest.java index cb43eb5ef..e84103f51 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchFindServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchFindServiceUnitTest.java @@ -21,27 +21,27 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import gg.data.game.Game; +import gg.data.game.type.StatusType; +import gg.data.manage.SlotManagement; +import gg.data.match.RedisMatchTime; +import gg.data.match.type.Option; +import gg.data.rank.Tier; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.user.User; import gg.pingpong.api.user.match.utils.SlotGenerator; import gg.pingpong.api.user.season.service.SeasonFindService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.match.RedisMatchTime; -import gg.pingpong.data.match.type.Option; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.repo.match.RedisMatchTimeRepository; -import gg.pingpong.repo.match.RedisMatchUserRepository; -import gg.pingpong.repo.rank.TierRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.annotation.UnitTest; +import gg.repo.game.GameRepository; +import gg.repo.manage.SlotManagementRepository; +import gg.repo.match.RedisMatchTimeRepository; +import gg.repo.match.RedisMatchUserRepository; +import gg.repo.rank.TierRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.user.UserRepository; +import gg.utils.RedisKeyManager; +import gg.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchServiceTest.java index a45e3c785..e40f7f2dc 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchServiceTest.java @@ -22,7 +22,24 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.admin.repo.manage.PenaltyAdminRepository; +import gg.admin.repo.manage.PenaltyAdminRepository; +import gg.data.game.Game; +import gg.data.game.type.Mode; +import gg.data.manage.SlotManagement; +import gg.data.manage.redis.RedisPenaltyUser; +import gg.data.match.RedisMatchUser; +import gg.data.match.type.MatchKey; +import gg.data.match.type.Option; +import gg.data.match.type.SlotStatus; +import gg.data.noti.Noti; +import gg.data.noti.type.NotiType; +import gg.data.rank.Tier; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.tournament.Tournament; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; +import gg.data.user.User; import gg.pingpong.api.user.manage.redis.PenaltyUserRedisRepository; import gg.pingpong.api.user.match.controller.response.MatchStatusResponseListDto; import gg.pingpong.api.user.match.controller.response.SlotStatusResponseListDto; @@ -31,38 +48,21 @@ import gg.pingpong.api.user.match.utils.MatchIntegrationTestUtils; import gg.pingpong.api.user.rank.redis.RedisUploadService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.manage.redis.RedisPenaltyUser; -import gg.pingpong.data.match.RedisMatchUser; -import gg.pingpong.data.match.type.MatchKey; -import gg.pingpong.data.match.type.Option; -import gg.pingpong.data.match.type.SlotStatus; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.noti.type.NotiType; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.repo.match.RedisMatchTimeRepository; -import gg.pingpong.repo.match.RedisMatchUserRepository; -import gg.pingpong.repo.noti.NotiRepository; -import gg.pingpong.repo.rank.TierRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.tournarment.TournamentRepository; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.exception.custom.BusinessException; -import gg.pingpong.utils.exception.match.EnrolledSlotException; -import gg.pingpong.utils.exception.match.PenaltyUserSlotException; -import gg.pingpong.utils.exception.tournament.TournamentConflictException; +import gg.repo.game.GameRepository; +import gg.repo.manage.SlotManagementRepository; +import gg.repo.match.RedisMatchTimeRepository; +import gg.repo.match.RedisMatchUserRepository; +import gg.repo.noti.NotiRepository; +import gg.repo.rank.TierRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.tournarment.TournamentRepository; +import gg.utils.RedisKeyManager; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.exception.custom.BusinessException; +import gg.utils.exception.match.EnrolledSlotException; +import gg.utils.exception.match.PenaltyUserSlotException; +import gg.utils.exception.tournament.TournamentConflictException; import lombok.RequiredArgsConstructor; @IntegrationTest diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchTournamentServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchTournamentServiceTest.java index f282d681f..0b7aa2530 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchTournamentServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchTournamentServiceTest.java @@ -1,6 +1,6 @@ package gg.pingpong.api.user.match.service; -import static gg.pingpong.data.tournament.type.RoundNumber.*; +import static gg.data.tournament.type.RoundNumber.*; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; @@ -19,27 +19,26 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.transaction.annotation.Transactional; +import gg.data.game.Game; +import gg.data.game.Team; +import gg.data.game.type.StatusType; +import gg.data.match.type.TournamentMatchStatus; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.type.TournamentRound; +import gg.data.tournament.type.TournamentStatus; +import gg.data.user.User; import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; import gg.pingpong.api.admin.noti.service.NotiAdminService; import gg.pingpong.api.user.match.utils.MatchIntegrationTestUtils; import gg.pingpong.api.user.match.utils.TournamentGameTestUtils; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.match.type.TournamentMatchStatus; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.type.RoundNumber; -import gg.pingpong.data.tournament.type.TournamentRound; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.exception.match.EnrolledSlotException; -import gg.pingpong.utils.exception.match.SlotNotFoundException; -import gg.pingpong.utils.exception.match.WinningTeamNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.manage.SlotManagementRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.exception.match.EnrolledSlotException; +import gg.utils.exception.match.SlotNotFoundException; +import gg.utils.exception.match.WinningTeamNotFoundException; @IntegrationTest @Transactional @@ -75,10 +74,10 @@ class MatchTournament { @DisplayName("8강 경기 매칭 성공") public void quarterTest() { // when - matchTournamentService.matchGames(tournament, RoundNumber.QUARTER_FINAL); + matchTournamentService.matchGames(tournament, QUARTER_FINAL); // then - List quarterRounds = TournamentRound.getSameRounds(RoundNumber.QUARTER_FINAL); + List quarterRounds = TournamentRound.getSameRounds(QUARTER_FINAL); List quarterRoundGames = allTournamentGames.stream() .filter(o -> quarterRounds.contains(o.getTournamentRound())) .sorted(Comparator.comparing(TournamentGame::getTournamentRound)) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchTournamentServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchTournamentServiceUnitTest.java index 2f2985506..c0acdbb9e 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchTournamentServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/service/MatchTournamentServiceUnitTest.java @@ -1,8 +1,8 @@ package gg.pingpong.api.user.match.service; +import static gg.data.tournament.type.RoundNumber.*; import static gg.pingpong.api.user.match.utils.TournamentGameTestUtils.*; import static gg.pingpong.api.utils.ReflectionUtilsForUnitTest.*; -import static gg.pingpong.data.tournament.type.RoundNumber.*; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; import static org.mockito.BDDMockito.*; @@ -23,31 +23,31 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import gg.data.game.Game; +import gg.data.game.Team; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.data.manage.SlotManagement; +import gg.data.match.type.TournamentMatchStatus; +import gg.data.season.Season; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.type.RoundNumber; +import gg.data.tournament.type.TournamentRound; +import gg.data.tournament.type.TournamentStatus; +import gg.data.user.User; import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; import gg.pingpong.api.admin.noti.service.NotiAdminService; import gg.pingpong.api.user.match.utils.GameTestUtils; import gg.pingpong.api.user.match.utils.TournamentTestUtils; import gg.pingpong.api.user.match.utils.UserTestUtils; import gg.pingpong.api.user.season.service.SeasonFindService; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.match.type.TournamentMatchStatus; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.type.RoundNumber; -import gg.pingpong.data.tournament.type.TournamentRound; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.repo.tournarment.TournamentGameRepository; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.match.EnrolledSlotException; -import gg.pingpong.utils.exception.match.WinningTeamNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.manage.SlotManagementRepository; +import gg.repo.tournarment.TournamentGameRepository; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.match.EnrolledSlotException; +import gg.utils.exception.match.WinningTeamNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/GameTestUtils.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/GameTestUtils.java index d1530c93b..1b6b44346 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/GameTestUtils.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/GameTestUtils.java @@ -2,13 +2,13 @@ import java.time.LocalDateTime; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; +import gg.data.game.Game; +import gg.data.game.Team; +import gg.data.game.TeamUser; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.data.season.Season; +import gg.data.user.User; public class GameTestUtils { public static Game createGame(User user, User enemy, Season season, Mode mode) { diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/MatchIntegrationTestUtils.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/MatchIntegrationTestUtils.java index ee7cb3f7a..0bb2d3def 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/MatchIntegrationTestUtils.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/MatchIntegrationTestUtils.java @@ -9,21 +9,21 @@ import org.springframework.stereotype.Component; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.type.TournamentRound; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.season.SeasonRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.RedisKeyManager; +import gg.data.game.Game; +import gg.data.game.Team; +import gg.data.manage.SlotManagement; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.type.TournamentRound; +import gg.data.user.User; +import gg.repo.game.GameRepository; +import gg.repo.manage.SlotManagementRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.season.SeasonRepository; +import gg.repo.user.UserRepository; +import gg.utils.RedisKeyManager; import lombok.RequiredArgsConstructor; @Component diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/TournamentGameTestUtils.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/TournamentGameTestUtils.java index c3cfa7337..2bbd24485 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/TournamentGameTestUtils.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/TournamentGameTestUtils.java @@ -7,18 +7,18 @@ import java.util.Optional; import java.util.stream.Collectors; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.type.RoundNumber; -import gg.pingpong.data.tournament.type.TournamentRound; -import gg.pingpong.data.user.User; -import gg.pingpong.utils.exception.match.WinningTeamNotFoundException; +import gg.data.game.Game; +import gg.data.game.Team; +import gg.data.game.TeamUser; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.data.season.Season; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.type.RoundNumber; +import gg.data.tournament.type.TournamentRound; +import gg.data.user.User; +import gg.utils.exception.match.WinningTeamNotFoundException; public class TournamentGameTestUtils { diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/TournamentTestUtils.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/TournamentTestUtils.java index 01e003448..b39ac3b02 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/TournamentTestUtils.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/TournamentTestUtils.java @@ -2,12 +2,12 @@ import java.time.LocalDateTime; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.TournamentUser; -import gg.pingpong.data.tournament.type.TournamentRound; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.TournamentUser; +import gg.data.tournament.type.TournamentRound; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; public class TournamentTestUtils { /** diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/UserTestUtils.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/UserTestUtils.java index 6863a6c9c..28ae8de88 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/UserTestUtils.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/match/utils/UserTestUtils.java @@ -2,10 +2,10 @@ import java.util.UUID; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; public class UserTestUtils { public static User createUser() { diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/megaphone/controller/MegaphoneControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/megaphone/controller/MegaphoneControllerTest.java index 8e2965237..eb7ac45c5 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/megaphone/controller/MegaphoneControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/megaphone/controller/MegaphoneControllerTest.java @@ -17,23 +17,23 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import gg.data.store.Item; +import gg.data.store.Megaphone; +import gg.data.store.Receipt; +import gg.data.store.type.ItemStatus; +import gg.data.store.type.ItemType; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.store.controller.request.MegaphoneUseRequestDto; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.store.Megaphone; -import gg.pingpong.data.store.Receipt; -import gg.pingpong.data.store.type.ItemStatus; -import gg.pingpong.data.store.type.ItemType; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.store.MegaphoneRepository; -import gg.pingpong.repo.store.ReceiptRepository; -import gg.pingpong.utils.ItemTestUtils; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.store.MegaphoneRepository; +import gg.repo.store.ReceiptRepository; +import gg.utils.ItemTestUtils; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/megaphone/service/MegaphoneServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/megaphone/service/MegaphoneServiceUnitTest.java index 5aae4811d..1dd4dce0d 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/megaphone/service/MegaphoneServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/megaphone/service/MegaphoneServiceUnitTest.java @@ -22,30 +22,30 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import gg.data.store.Item; +import gg.data.store.Megaphone; +import gg.data.store.Receipt; +import gg.data.store.type.ItemStatus; +import gg.data.store.type.ItemType; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.user.store.controller.request.MegaphoneUseRequestDto; import gg.pingpong.api.user.store.redis.MegaphoneRedisRepository; import gg.pingpong.api.user.store.service.ItemService; import gg.pingpong.api.user.store.service.MegaphoneService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.store.Megaphone; -import gg.pingpong.data.store.Receipt; -import gg.pingpong.data.store.type.ItemStatus; -import gg.pingpong.data.store.type.ItemType; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.store.MegaphoneRepository; -import gg.pingpong.repo.store.ReceiptRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.megaphone.MegaphoneContentException; -import gg.pingpong.utils.exception.megaphone.MegaphoneNotFoundException; -import gg.pingpong.utils.exception.megaphone.MegaphoneTimeException; -import gg.pingpong.utils.exception.receipt.ItemStatusException; -import gg.pingpong.utils.exception.receipt.ReceiptNotFoundException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.store.MegaphoneRepository; +import gg.repo.store.ReceiptRepository; +import gg.repo.user.UserRepository; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.megaphone.MegaphoneContentException; +import gg.utils.exception.megaphone.MegaphoneNotFoundException; +import gg.utils.exception.megaphone.MegaphoneTimeException; +import gg.utils.exception.receipt.ItemStatusException; +import gg.utils.exception.receipt.ReceiptNotFoundException; +import gg.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/controller/NotiControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/controller/NotiControllerTest.java index a18a0c6e9..b6f3c805a 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/controller/NotiControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/controller/NotiControllerTest.java @@ -16,17 +16,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import gg.data.noti.Noti; +import gg.data.noti.type.NotiType; +import gg.data.user.User; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.noti.controller.response.NotiListResponseDto; import gg.pingpong.api.user.noti.service.NotiService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.noti.type.NotiType; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.noti.NotiRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.noti.NotiRepository; +import gg.repo.user.UserRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/NotiServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/NotiServiceTest.java index 023765197..0a4fbbeb8 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/NotiServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/NotiServiceTest.java @@ -11,15 +11,15 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import gg.data.noti.Noti; +import gg.data.noti.type.NotiType; +import gg.data.user.User; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.noti.type.NotiType; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.noti.NotiRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.noti.NotiRepository; +import gg.repo.user.UserRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/NotiServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/NotiServiceUnitTest.java index aa297a034..c498b707f 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/NotiServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/NotiServiceUnitTest.java @@ -16,18 +16,18 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import gg.data.noti.Noti; +import gg.data.noti.type.NotiType; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.noti.type.NotiType; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.noti.NotiRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.custom.NotExistException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.noti.NotiRepository; +import gg.repo.user.UserRepository; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.custom.NotExistException; +import gg.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/SnsNotiServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/SnsNotiServiceUnitTest.java index c1fced5a1..bb49f754d 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/SnsNotiServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/SnsNotiServiceUnitTest.java @@ -10,14 +10,14 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import gg.data.noti.Noti; +import gg.data.user.type.SnsType; import gg.pingpong.api.user.noti.dto.UserNotiDto; import gg.pingpong.api.user.noti.service.sns.NotiMailSender; import gg.pingpong.api.user.noti.service.sns.SlackbotService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.game.out.GameUser; -import gg.pingpong.utils.annotation.UnitTest; +import gg.repo.game.out.GameUser; +import gg.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/sns/NotiMailSenderUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/sns/NotiMailSenderUnitTest.java index 41fbda784..4161564b2 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/sns/NotiMailSenderUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/noti/service/sns/NotiMailSenderUnitTest.java @@ -12,13 +12,13 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.mail.javamail.JavaMailSender; +import gg.data.noti.Noti; import gg.pingpong.api.global.utils.AsyncMailSender; import gg.pingpong.api.user.noti.dto.UserNotiDto; import gg.pingpong.api.user.noti.service.NotiService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.repo.game.out.GameUser; -import gg.pingpong.utils.annotation.UnitTest; +import gg.repo.game.out.GameUser; +import gg.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/pchange/service/PChangeServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/pchange/service/PChangeServiceTest.java index 181dfc8a7..b396d297e 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/pchange/service/PChangeServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/pchange/service/PChangeServiceTest.java @@ -14,17 +14,17 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import gg.data.game.Game; +import gg.data.game.PChange; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.user.game.service.PChangeService; import gg.pingpong.api.utils.ReflectionUtilsForUnitTest; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.PChange; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.game.PChangeRepository; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.pchange.PChangeNotExistException; +import gg.repo.game.PChangeRepository; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.pchange.PChangeNotExistException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/controller/RankControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/controller/RankControllerTest.java index 7c633a04c..99e9e8e6d 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/controller/RankControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/controller/RankControllerTest.java @@ -19,17 +19,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import gg.data.season.Season; +import gg.data.user.User; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.rank.controller.response.ExpRankPageResponseDto; import gg.pingpong.api.user.rank.controller.response.RankPageResponseDto; import gg.pingpong.api.user.rank.dto.RankDto; import gg.pingpong.api.user.rank.redis.RedisUploadService; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.season.SeasonRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.season.SeasonRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; @IntegrationTest @Transactional diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/controller/RankV2ControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/controller/RankV2ControllerTest.java index 5c6e29177..01f676b0a 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/controller/RankV2ControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/controller/RankV2ControllerTest.java @@ -19,6 +19,7 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.servlet.MockMvc; +import gg.data.user.User; import gg.pingpong.api.global.config.WebConfig; import gg.pingpong.api.global.security.config.SecurityConfig; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; @@ -28,8 +29,7 @@ import gg.pingpong.api.user.rank.controller.response.RankPageResponseDto; import gg.pingpong.api.user.rank.service.RankService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.user.UserRepository; +import gg.repo.user.UserRepository; @WebMvcTest(value = RankV2Controller.class, excludeFilters = { diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RankRedisRepositoryTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RankRedisRepositoryTest.java index bdcc89f03..c048a5f26 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RankRedisRepositoryTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RankRedisRepositoryTest.java @@ -8,10 +8,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.exception.rank.RedisDataNotFoundException; +import gg.data.rank.redis.RankRedis; +import gg.repo.rank.redis.RankRedisRepository; +import gg.utils.annotation.IntegrationTest; +import gg.utils.exception.rank.RedisDataNotFoundException; @IntegrationTest class RankRedisRepositoryTest { diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RedisTransactionTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RedisTransactionTest.java index 25ac7382e..d1320a851 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RedisTransactionTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/redis/RedisTransactionTest.java @@ -7,7 +7,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.transaction.annotation.Transactional; -import gg.pingpong.utils.annotation.IntegrationTestWithRedisTransaction; +import gg.utils.annotation.IntegrationTestWithRedisTransaction; @IntegrationTestWithRedisTransaction public class RedisTransactionTest { diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/service/RankServiceTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/service/RankServiceTest.java index 9c7bde788..9e0afdb01 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/service/RankServiceTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/rank/service/RankServiceTest.java @@ -17,17 +17,17 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; +import gg.data.season.Season; +import gg.data.user.User; import gg.pingpong.api.user.rank.controller.response.ExpRankPageResponseDto; import gg.pingpong.api.user.rank.controller.response.RankPageResponseDto; import gg.pingpong.api.user.season.service.SeasonFindService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.RankV2Dto; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.user.ExpRankV2Dto; -import gg.pingpong.repo.user.UserRepository; +import gg.repo.rank.RankRepository; +import gg.repo.rank.RankV2Dto; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.user.ExpRankV2Dto; +import gg.repo.user.UserRepository; @ExtendWith(MockitoExtension.class) class RankServiceTest { diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/SeasonTestController.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/SeasonTestController.java index f30980dcf..8b20a431e 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/SeasonTestController.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/SeasonTestController.java @@ -18,14 +18,14 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import gg.data.season.Season; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.season.controller.response.SeasonListResDto; import gg.pingpong.api.user.season.controller.response.SeasonResDto; import gg.pingpong.api.user.season.service.SeasonService; -import gg.pingpong.data.season.Season; -import gg.pingpong.repo.season.SeasonRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.season.SeasonRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/SeasonTriggerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/SeasonTriggerTest.java index c7f8d842f..1728f970d 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/SeasonTriggerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/SeasonTriggerTest.java @@ -16,12 +16,12 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import gg.data.game.type.Mode; +import gg.data.season.Season; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.season.Season; -import gg.pingpong.repo.season.SeasonRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.season.SeasonRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/service/SeasonServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/service/SeasonServiceUnitTest.java index 1e4bcb9d7..0a8b083fa 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/service/SeasonServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/season/service/SeasonServiceUnitTest.java @@ -14,10 +14,10 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import gg.pingpong.data.season.Season; -import gg.pingpong.repo.season.SeasonRepository; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.season.SeasonNotFoundException; +import gg.data.season.Season; +import gg.repo.season.SeasonRepository; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.season.SeasonNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tier/service/TierServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tier/service/TierServiceUnitTest.java index f5d420213..46fa47aba 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tier/service/TierServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tier/service/TierServiceUnitTest.java @@ -22,14 +22,14 @@ import org.mockito.quality.Strictness; import org.springframework.data.domain.Sort; +import gg.data.rank.Rank; +import gg.data.rank.Tier; +import gg.data.season.Season; +import gg.data.user.User; import gg.pingpong.api.user.rank.service.TierService; -import gg.pingpong.data.rank.Rank; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.TierRepository; -import gg.pingpong.utils.annotation.UnitTest; +import gg.repo.rank.RankRepository; +import gg.repo.rank.TierRepository; +import gg.utils.annotation.UnitTest; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentControllerMvcTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentControllerMvcTest.java index a5d40aebb..33ffb76d7 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentControllerMvcTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentControllerMvcTest.java @@ -31,7 +31,7 @@ import gg.pingpong.api.user.tournament.controller.response.TournamentUserRegistrationResponseDto; import gg.pingpong.api.user.tournament.service.TournamentService; import gg.pingpong.api.user.user.dto.UserDto; -import gg.pingpong.utils.annotation.UnitTest; +import gg.utils.annotation.UnitTest; @UnitTest @WebMvcTest(controllers = TournamentController.class, excludeFilters = { diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentFindControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentFindControllerTest.java index f56057e27..aaade00a1 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentFindControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentFindControllerTest.java @@ -20,22 +20,22 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentUser; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.tournament.controller.response.TournamentListResponseDto; import gg.pingpong.api.user.tournament.controller.response.TournamentResponseDto; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentUser; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.tournarment.TournamentUserRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.CustomRuntimeException; +import gg.repo.tournarment.TournamentUserRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.CustomRuntimeException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentGameControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentGameControllerTest.java index f2263e937..b98c27d0e 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentGameControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentGameControllerTest.java @@ -18,22 +18,22 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import gg.data.game.type.Mode; +import gg.data.season.Season; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.type.TournamentRound; +import gg.data.tournament.type.TournamentStatus; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.tournament.controller.response.TournamentGameListResponseDto; import gg.pingpong.api.user.tournament.controller.response.TournamentGameResDto; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.type.TournamentRound; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.dto.GameInfoDto; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.dto.GameInfoDto; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentSchedulerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentSchedulerTest.java index d6e9e9994..7b8d45ccc 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentSchedulerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/controller/TournamentSchedulerTest.java @@ -15,17 +15,17 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.transaction.annotation.Transactional; +import gg.data.manage.SlotManagement; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.type.TournamentStatus; import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; import gg.pingpong.api.admin.noti.service.NotiAdminService; import gg.pingpong.api.user.tournament.service.TournamentService; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.repo.tournarment.TournamentGameRepository; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; +import gg.repo.manage.SlotManagementRepository; +import gg.repo.tournarment.TournamentGameRepository; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; @IntegrationTest @Transactional diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/service/TournamentServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/service/TournamentServiceUnitTest.java index 02086589c..f639df29f 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/service/TournamentServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/tournament/service/TournamentServiceUnitTest.java @@ -24,6 +24,19 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import gg.data.game.Game; +import gg.data.game.type.StatusType; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.TournamentUser; +import gg.data.tournament.type.TournamentRound; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; +import gg.data.tournament.type.TournamentUserStatus; +import gg.data.user.User; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto; import gg.pingpong.api.admin.noti.service.NotiAdminService; import gg.pingpong.api.user.match.service.MatchTournamentService; @@ -32,29 +45,16 @@ import gg.pingpong.api.user.tournament.controller.response.TournamentUserRegistrationResponseDto; import gg.pingpong.api.user.user.dto.UserDto; import gg.pingpong.api.utils.ReflectionUtilsForUnitTest; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.TournamentUser; -import gg.pingpong.data.tournament.type.TournamentRound; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; -import gg.pingpong.data.tournament.type.TournamentUserStatus; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.game.out.GameTeamUser; -import gg.pingpong.repo.tournarment.TournamentGameRepository; -import gg.pingpong.repo.tournarment.TournamentRepository; -import gg.pingpong.repo.tournarment.TournamentUserRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.tournament.TournamentConflictException; -import gg.pingpong.utils.exception.tournament.TournamentNotFoundException; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.game.out.GameTeamUser; +import gg.repo.tournarment.TournamentGameRepository; +import gg.repo.tournarment.TournamentRepository; +import gg.repo.tournarment.TournamentUserRepository; +import gg.repo.user.UserRepository; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.tournament.TournamentConflictException; +import gg.utils.exception.tournament.TournamentNotFoundException; +import gg.utils.exception.user.UserNotFoundException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/controller/UserControllerTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/controller/UserControllerTest.java index 4dcba5aa3..7553d1f94 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/controller/UserControllerTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/controller/UserControllerTest.java @@ -27,6 +27,23 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import gg.data.game.Game; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.data.rank.Rank; +import gg.data.rank.Tier; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.store.Item; +import gg.data.store.Receipt; +import gg.data.store.type.ItemStatus; +import gg.data.store.type.ItemType; +import gg.data.user.User; +import gg.data.user.type.BackgroundType; +import gg.data.user.type.EdgeType; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.global.utils.UserImageHandler; @@ -45,38 +62,21 @@ import gg.pingpong.api.user.user.controller.response.UserRankResponseDto; import gg.pingpong.api.user.user.controller.response.UserSearchResponseDto; import gg.pingpong.api.user.user.dto.UserTextColorDto; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.rank.Rank; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.store.Receipt; -import gg.pingpong.data.store.type.ItemStatus; -import gg.pingpong.data.store.type.ItemType; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.type.BackgroundType; -import gg.pingpong.data.user.type.EdgeType; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.TierRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.season.SeasonRepository; -import gg.pingpong.repo.store.CoinHistoryRepository; -import gg.pingpong.repo.store.CoinPolicyRepository; -import gg.pingpong.repo.store.ReceiptRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.ItemTestUtils; -import gg.pingpong.utils.RedisKeyManager; -import gg.pingpong.utils.TestDataUtils; -import gg.pingpong.utils.annotation.IntegrationTest; -import gg.pingpong.utils.dto.GameInfoDto; -import gg.pingpong.utils.exception.user.UserNotFoundException; +import gg.repo.game.GameRepository; +import gg.repo.rank.RankRepository; +import gg.repo.rank.TierRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.season.SeasonRepository; +import gg.repo.store.CoinHistoryRepository; +import gg.repo.store.CoinPolicyRepository; +import gg.repo.store.ReceiptRepository; +import gg.repo.user.UserRepository; +import gg.utils.ItemTestUtils; +import gg.utils.RedisKeyManager; +import gg.utils.TestDataUtils; +import gg.utils.annotation.IntegrationTest; +import gg.utils.dto.GameInfoDto; +import gg.utils.exception.user.UserNotFoundException; import lombok.extern.slf4j.Slf4j; @IntegrationTest diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserAuthenticationServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserAuthenticationServiceUnitTest.java index add8ec526..7a24f2f2c 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserAuthenticationServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserAuthenticationServiceUnitTest.java @@ -13,8 +13,8 @@ import gg.pingpong.api.global.security.jwt.repository.JwtRedisRepository; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; -import gg.pingpong.utils.annotation.UnitTest; -import gg.pingpong.utils.exception.user.TokenNotValidException; +import gg.utils.annotation.UnitTest; +import gg.utils.exception.user.TokenNotValidException; @UnitTest @ExtendWith(MockitoExtension.class) diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserFindServiceUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserFindServiceUnitTest.java index 5121920d0..470676fcd 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserFindServiceUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/user/user/service/UserFindServiceUnitTest.java @@ -1,6 +1,6 @@ package gg.pingpong.api.user.user.service; -import gg.pingpong.utils.annotation.UnitTest; +import gg.utils.annotation.UnitTest; @UnitTest class UserFindServiceUnitTest { diff --git a/gg-pingpong-api/src/test/java/gg/pingpong/api/utils/ReflectionUtilsForUnitTest.java b/gg-pingpong-api/src/test/java/gg/pingpong/api/utils/ReflectionUtilsForUnitTest.java index f6eef8431..2d1664ee9 100644 --- a/gg-pingpong-api/src/test/java/gg/pingpong/api/utils/ReflectionUtilsForUnitTest.java +++ b/gg-pingpong-api/src/test/java/gg/pingpong/api/utils/ReflectionUtilsForUnitTest.java @@ -2,8 +2,8 @@ import java.lang.reflect.Field; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; /** * ReflectionUtilsForUnitTest. diff --git a/gg-pingpong-repo/build.gradle b/gg-repo/build.gradle similarity index 86% rename from gg-pingpong-repo/build.gradle rename to gg-repo/build.gradle index 839f760aa..d268dd7ee 100644 --- a/gg-pingpong-repo/build.gradle +++ b/gg-repo/build.gradle @@ -17,7 +17,7 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' - testImplementation testFixtures(project(':gg-pingpong-utils')) + testImplementation testFixtures(project(':gg-utils')) } test { diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepository.java b/gg-repo/src/main/java/gg/repo/game/GameRepository.java similarity index 95% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepository.java rename to gg-repo/src/main/java/gg/repo/game/GameRepository.java index d3251ea51..f27d5bc27 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepository.java +++ b/gg-repo/src/main/java/gg/repo/game/GameRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.game; +package gg.repo.game; import java.time.LocalDateTime; import java.util.List; @@ -14,12 +14,12 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.repo.game.out.GameTeamUser; -import gg.pingpong.repo.game.out.GameTeamUserInfo; -import gg.pingpong.repo.game.out.GameUser; +import gg.data.game.Game; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.repo.game.out.GameTeamUser; +import gg.repo.game.out.GameTeamUserInfo; +import gg.repo.game.out.GameUser; public interface GameRepository extends JpaRepository, GameRepositoryCustom { Slice findAllByModeAndStatus(Mode mode, StatusType status, Pageable pageable); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepositoryCustom.java b/gg-repo/src/main/java/gg/repo/game/GameRepositoryCustom.java similarity index 64% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepositoryCustom.java rename to gg-repo/src/main/java/gg/repo/game/GameRepositoryCustom.java index 8ed108af6..1b8b7b7dc 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepositoryCustom.java +++ b/gg-repo/src/main/java/gg/repo/game/GameRepositoryCustom.java @@ -1,8 +1,8 @@ -package gg.pingpong.repo.game; +package gg.repo.game; import java.util.Optional; -import gg.pingpong.data.game.Game; +import gg.data.game.Game; public interface GameRepositoryCustom { Optional getLatestGameByUser(Long userId); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepositoryImpl.java b/gg-repo/src/main/java/gg/repo/game/GameRepositoryImpl.java similarity index 88% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepositoryImpl.java rename to gg-repo/src/main/java/gg/repo/game/GameRepositoryImpl.java index 104aa8cbf..d357d1600 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/GameRepositoryImpl.java +++ b/gg-repo/src/main/java/gg/repo/game/GameRepositoryImpl.java @@ -1,12 +1,12 @@ -package gg.pingpong.repo.game; +package gg.repo.game; import java.util.Optional; import javax.persistence.EntityManager; import javax.persistence.NoResultException; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.TeamUser; +import gg.data.game.Game; +import gg.data.game.TeamUser; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepository.java b/gg-repo/src/main/java/gg/repo/game/PChangeRepository.java similarity index 91% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepository.java rename to gg-repo/src/main/java/gg/repo/game/PChangeRepository.java index d92ee1a85..a31b85364 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepository.java +++ b/gg-repo/src/main/java/gg/repo/game/PChangeRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.game; +package gg.repo.game; import java.util.List; import java.util.Optional; @@ -7,8 +7,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.game.PChange; -import gg.pingpong.data.game.type.Mode; +import gg.data.game.PChange; +import gg.data.game.type.Mode; public interface PChangeRepository extends JpaRepository, PChangeRepositoryCustom { diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepositoryCustom.java b/gg-repo/src/main/java/gg/repo/game/PChangeRepositoryCustom.java similarity index 79% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepositoryCustom.java rename to gg-repo/src/main/java/gg/repo/game/PChangeRepositoryCustom.java index 2b30d2c38..a6bb3b1f6 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepositoryCustom.java +++ b/gg-repo/src/main/java/gg/repo/game/PChangeRepositoryCustom.java @@ -1,8 +1,8 @@ -package gg.pingpong.repo.game; +package gg.repo.game; import java.util.List; -import gg.pingpong.data.game.PChange; +import gg.data.game.PChange; public interface PChangeRepositoryCustom { List findPChangesHistory(String intraId, Long seasonId); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepositoryImpl.java b/gg-repo/src/main/java/gg/repo/game/PChangeRepositoryImpl.java similarity index 96% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepositoryImpl.java rename to gg-repo/src/main/java/gg/repo/game/PChangeRepositoryImpl.java index 709ae5961..21275f7b3 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/PChangeRepositoryImpl.java +++ b/gg-repo/src/main/java/gg/repo/game/PChangeRepositoryImpl.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.game; +package gg.repo.game; import java.util.List; @@ -6,7 +6,7 @@ import org.springframework.stereotype.Repository; -import gg.pingpong.data.game.PChange; +import gg.data.game.PChange; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/TeamRepository.java b/gg-repo/src/main/java/gg/repo/game/TeamRepository.java similarity index 85% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/TeamRepository.java rename to gg-repo/src/main/java/gg/repo/game/TeamRepository.java index 4027538a8..80e97a020 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/TeamRepository.java +++ b/gg-repo/src/main/java/gg/repo/game/TeamRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.game; +package gg.repo.game; import java.util.List; @@ -6,7 +6,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.game.Team; +import gg.data.game.Team; public interface TeamRepository extends JpaRepository { @Query("select t from Team t where t.game.id=:gameId") diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/TeamUserRepository.java b/gg-repo/src/main/java/gg/repo/game/TeamUserRepository.java similarity index 92% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/TeamUserRepository.java rename to gg-repo/src/main/java/gg/repo/game/TeamUserRepository.java index 599551394..ecb568782 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/TeamUserRepository.java +++ b/gg-repo/src/main/java/gg/repo/game/TeamUserRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.game; +package gg.repo.game; import java.time.LocalDateTime; import java.util.List; @@ -7,7 +7,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.game.TeamUser; +import gg.data.game.TeamUser; public interface TeamUserRepository extends JpaRepository { @Query(value = "select team_user.id, team_user.team_id, team_user.user_id from team, team_user " diff --git a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/out/GameTeamUser.java b/gg-repo/src/main/java/gg/repo/game/out/GameTeamUser.java similarity index 81% rename from gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/out/GameTeamUser.java rename to gg-repo/src/main/java/gg/repo/game/out/GameTeamUser.java index 719d25d95..0d4f1a010 100644 --- a/gg-pingpong-admin-repo/src/main/java/gg/pingpong/admin/repo/game/out/GameTeamUser.java +++ b/gg-repo/src/main/java/gg/repo/game/out/GameTeamUser.java @@ -1,9 +1,9 @@ -package gg.pingpong.admin.repo.game.out; +package gg.repo.game.out; import java.time.LocalDateTime; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; public interface GameTeamUser { Long getGameId(); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameTeamUserInfo.java b/gg-repo/src/main/java/gg/repo/game/out/GameTeamUserInfo.java similarity index 70% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameTeamUserInfo.java rename to gg-repo/src/main/java/gg/repo/game/out/GameTeamUserInfo.java index d3b0e3bb4..f12ff0c05 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameTeamUserInfo.java +++ b/gg-repo/src/main/java/gg/repo/game/out/GameTeamUserInfo.java @@ -1,9 +1,9 @@ -package gg.pingpong.repo.game.out; +package gg.repo.game.out; import java.time.LocalDateTime; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; public interface GameTeamUserInfo { Long getGameId(); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameUser.java b/gg-repo/src/main/java/gg/repo/game/out/GameUser.java similarity index 64% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameUser.java rename to gg-repo/src/main/java/gg/repo/game/out/GameUser.java index 2adca75b8..33f418b25 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/game/out/GameUser.java +++ b/gg-repo/src/main/java/gg/repo/game/out/GameUser.java @@ -1,6 +1,6 @@ -package gg.pingpong.repo.game.out; +package gg.repo.game.out; -import gg.pingpong.data.user.type.SnsType; +import gg.data.user.type.SnsType; public interface GameUser { Long getGameId(); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/AnnouncementRepository.java b/gg-repo/src/main/java/gg/repo/manage/AnnouncementRepository.java similarity index 74% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/AnnouncementRepository.java rename to gg-repo/src/main/java/gg/repo/manage/AnnouncementRepository.java index 82946d97f..be4cc237c 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/AnnouncementRepository.java +++ b/gg-repo/src/main/java/gg/repo/manage/AnnouncementRepository.java @@ -1,10 +1,10 @@ -package gg.pingpong.repo.manage; +package gg.repo.manage; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.manage.Announcement; +import gg.data.manage.Announcement; public interface AnnouncementRepository extends JpaRepository { Optional findFirstByOrderByIdDesc(); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/FeedbackRepository.java b/gg-repo/src/main/java/gg/repo/manage/FeedbackRepository.java similarity index 70% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/FeedbackRepository.java rename to gg-repo/src/main/java/gg/repo/manage/FeedbackRepository.java index 9575e4ea3..e01e01f8d 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/FeedbackRepository.java +++ b/gg-repo/src/main/java/gg/repo/manage/FeedbackRepository.java @@ -1,8 +1,8 @@ -package gg.pingpong.repo.manage; +package gg.repo.manage; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.manage.Feedback; +import gg.data.manage.Feedback; public interface FeedbackRepository extends JpaRepository { Feedback findFirstByOrderByIdDesc(); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/PenaltyRepository.java b/gg-repo/src/main/java/gg/repo/manage/PenaltyRepository.java similarity index 66% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/PenaltyRepository.java rename to gg-repo/src/main/java/gg/repo/manage/PenaltyRepository.java index d3b16e8a1..c0c9aebb9 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/PenaltyRepository.java +++ b/gg-repo/src/main/java/gg/repo/manage/PenaltyRepository.java @@ -1,8 +1,8 @@ -package gg.pingpong.repo.manage; +package gg.repo.manage; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.manage.Penalty; +import gg.data.manage.Penalty; public interface PenaltyRepository extends JpaRepository { diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/SlotManagementRepository.java b/gg-repo/src/main/java/gg/repo/manage/SlotManagementRepository.java similarity index 90% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/SlotManagementRepository.java rename to gg-repo/src/main/java/gg/repo/manage/SlotManagementRepository.java index 96c0e3f7e..56c72ee9a 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/manage/SlotManagementRepository.java +++ b/gg-repo/src/main/java/gg/repo/manage/SlotManagementRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.manage; +package gg.repo.manage; import java.time.LocalDateTime; import java.util.List; @@ -8,7 +8,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.manage.SlotManagement; +import gg.data.manage.SlotManagement; public interface SlotManagementRepository extends JpaRepository { diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/match/RedisMatchTimeRepository.java b/gg-repo/src/main/java/gg/repo/match/RedisMatchTimeRepository.java similarity index 93% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/match/RedisMatchTimeRepository.java rename to gg-repo/src/main/java/gg/repo/match/RedisMatchTimeRepository.java index c32a2ed4b..7a8d5d0e2 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/match/RedisMatchTimeRepository.java +++ b/gg-repo/src/main/java/gg/repo/match/RedisMatchTimeRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.match; +package gg.repo.match; import java.time.Duration; import java.time.LocalDateTime; @@ -11,8 +11,8 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; -import gg.pingpong.data.match.RedisMatchUser; -import gg.pingpong.data.match.type.MatchKey; +import gg.data.match.RedisMatchUser; +import gg.data.match.type.MatchKey; import lombok.RequiredArgsConstructor; @Repository diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/match/RedisMatchUserRepository.java b/gg-repo/src/main/java/gg/repo/match/RedisMatchUserRepository.java similarity index 89% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/match/RedisMatchUserRepository.java rename to gg-repo/src/main/java/gg/repo/match/RedisMatchUserRepository.java index 9f4ccc657..c877c6622 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/match/RedisMatchUserRepository.java +++ b/gg-repo/src/main/java/gg/repo/match/RedisMatchUserRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.match; +package gg.repo.match; import java.time.Duration; import java.time.LocalDateTime; @@ -10,10 +10,10 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; -import gg.pingpong.data.match.RedisMatchTime; -import gg.pingpong.data.match.type.MatchKey; -import gg.pingpong.data.match.type.Option; -import gg.pingpong.utils.exception.match.PastSlotException; +import gg.data.match.RedisMatchTime; +import gg.data.match.type.MatchKey; +import gg.data.match.type.Option; +import gg.utils.exception.match.PastSlotException; import lombok.RequiredArgsConstructor; @Repository diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepository.java b/gg-repo/src/main/java/gg/repo/noti/NotiRepository.java similarity index 80% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepository.java rename to gg-repo/src/main/java/gg/repo/noti/NotiRepository.java index a1777e78c..d5b78e5d3 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepository.java +++ b/gg-repo/src/main/java/gg/repo/noti/NotiRepository.java @@ -1,12 +1,12 @@ -package gg.pingpong.repo.noti; +package gg.repo.noti; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.user.User; +import gg.data.noti.Noti; +import gg.data.user.User; public interface NotiRepository extends JpaRepository, NotiRepositoryCustom { List findByUser(User user); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepositoryCustom.java b/gg-repo/src/main/java/gg/repo/noti/NotiRepositoryCustom.java similarity index 73% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepositoryCustom.java rename to gg-repo/src/main/java/gg/repo/noti/NotiRepositoryCustom.java index 41b2f8e96..4b7d2b663 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepositoryCustom.java +++ b/gg-repo/src/main/java/gg/repo/noti/NotiRepositoryCustom.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.noti; +package gg.repo.noti; public interface NotiRepositoryCustom { int countNotCheckedNotiByUser(Long userId); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepositoryImpl.java b/gg-repo/src/main/java/gg/repo/noti/NotiRepositoryImpl.java similarity index 94% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepositoryImpl.java rename to gg-repo/src/main/java/gg/repo/noti/NotiRepositoryImpl.java index 986bea00b..4d1ae7c25 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/noti/NotiRepositoryImpl.java +++ b/gg-repo/src/main/java/gg/repo/noti/NotiRepositoryImpl.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.noti; +package gg.repo.noti; import javax.persistence.EntityManager; diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/RankRepository.java b/gg-repo/src/main/java/gg/repo/rank/RankRepository.java similarity index 97% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/RankRepository.java rename to gg-repo/src/main/java/gg/repo/rank/RankRepository.java index 349129af4..03861c4fa 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/RankRepository.java +++ b/gg-repo/src/main/java/gg/repo/rank/RankRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.rank; +package gg.repo.rank; import java.util.List; import java.util.Optional; @@ -10,7 +10,7 @@ import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; -import gg.pingpong.data.rank.Rank; +import gg.data.rank.Rank; @Repository public interface RankRepository extends JpaRepository { diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/RankV2Dto.java b/gg-repo/src/main/java/gg/repo/rank/RankV2Dto.java similarity index 85% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/RankV2Dto.java rename to gg-repo/src/main/java/gg/repo/rank/RankV2Dto.java index a506e23f1..eb811eb57 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/RankV2Dto.java +++ b/gg-repo/src/main/java/gg/repo/rank/RankV2Dto.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.rank; +package gg.repo.rank; public interface RankV2Dto { diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/TierRepository.java b/gg-repo/src/main/java/gg/repo/rank/TierRepository.java similarity index 84% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/TierRepository.java rename to gg-repo/src/main/java/gg/repo/rank/TierRepository.java index 1530aa4c2..38ff04a7c 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/TierRepository.java +++ b/gg-repo/src/main/java/gg/repo/rank/TierRepository.java @@ -1,11 +1,11 @@ -package gg.pingpong.repo.rank; +package gg.repo.rank; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import gg.pingpong.data.rank.Tier; +import gg.data.rank.Tier; public interface TierRepository extends JpaRepository { diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/redis/RankRedisRepository.java b/gg-repo/src/main/java/gg/repo/rank/redis/RankRedisRepository.java similarity index 97% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/redis/RankRedisRepository.java rename to gg-repo/src/main/java/gg/repo/rank/redis/RankRedisRepository.java index 62f232d62..3ded2f8a9 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/rank/redis/RankRedisRepository.java +++ b/gg-repo/src/main/java/gg/repo/rank/redis/RankRedisRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.rank.redis; +package gg.repo.rank.redis; import java.util.Comparator; import java.util.List; @@ -10,8 +10,8 @@ import org.springframework.data.redis.core.ZSetOperations; import org.springframework.stereotype.Repository; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.utils.exception.rank.RedisDataNotFoundException; +import gg.data.rank.redis.RankRedis; +import gg.utils.exception.rank.RedisDataNotFoundException; @Repository public class RankRedisRepository { diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/season/SeasonRepository.java b/gg-repo/src/main/java/gg/repo/season/SeasonRepository.java similarity index 92% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/season/SeasonRepository.java rename to gg-repo/src/main/java/gg/repo/season/SeasonRepository.java index f6bd1848c..bae4dda42 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/season/SeasonRepository.java +++ b/gg-repo/src/main/java/gg/repo/season/SeasonRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.season; +package gg.repo.season; import java.time.LocalDateTime; import java.util.List; @@ -8,7 +8,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.season.Season; +import gg.data.season.Season; public interface SeasonRepository extends JpaRepository { @Query("select s from Season s where s.startTime <= :now and s.endTime >= :now") diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/CoinHistoryRepository.java b/gg-repo/src/main/java/gg/repo/store/CoinHistoryRepository.java similarity index 90% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/CoinHistoryRepository.java rename to gg-repo/src/main/java/gg/repo/store/CoinHistoryRepository.java index a2535c0f8..f287cf29e 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/CoinHistoryRepository.java +++ b/gg-repo/src/main/java/gg/repo/store/CoinHistoryRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.store; +package gg.repo.store; import java.time.LocalDateTime; import java.util.List; @@ -10,8 +10,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.store.CoinHistory; -import gg.pingpong.data.user.User; +import gg.data.store.CoinHistory; +import gg.data.user.User; public interface CoinHistoryRepository extends JpaRepository { @Query("SELECT CASE WHEN COUNT(ch) > 0 THEN true ELSE false END FROM CoinHistory ch " diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/CoinPolicyRepository.java b/gg-repo/src/main/java/gg/repo/store/CoinPolicyRepository.java similarity index 75% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/CoinPolicyRepository.java rename to gg-repo/src/main/java/gg/repo/store/CoinPolicyRepository.java index fe7da9f0e..217852559 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/CoinPolicyRepository.java +++ b/gg-repo/src/main/java/gg/repo/store/CoinPolicyRepository.java @@ -1,10 +1,10 @@ -package gg.pingpong.repo.store; +package gg.repo.store; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.store.CoinPolicy; +import gg.data.store.CoinPolicy; public interface CoinPolicyRepository extends JpaRepository { Optional findTopByOrderByCreatedAtDesc(); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/ItemRepository.java b/gg-repo/src/main/java/gg/repo/store/ItemRepository.java similarity index 83% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/ItemRepository.java rename to gg-repo/src/main/java/gg/repo/store/ItemRepository.java index 18e25abe8..74ace3772 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/ItemRepository.java +++ b/gg-repo/src/main/java/gg/repo/store/ItemRepository.java @@ -1,11 +1,11 @@ -package gg.pingpong.repo.store; +package gg.repo.store; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import gg.pingpong.data.store.Item; +import gg.data.store.Item; public interface ItemRepository extends JpaRepository { @Query("SELECT i FROM Item i WHERE i.isVisible = true ORDER BY i.createdAt DESC") diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/MegaphoneRepository.java b/gg-repo/src/main/java/gg/repo/store/MegaphoneRepository.java similarity index 71% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/MegaphoneRepository.java rename to gg-repo/src/main/java/gg/repo/store/MegaphoneRepository.java index 62b305c5a..d54128bcb 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/MegaphoneRepository.java +++ b/gg-repo/src/main/java/gg/repo/store/MegaphoneRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.store; +package gg.repo.store; import java.time.LocalDate; import java.util.List; @@ -6,9 +6,9 @@ import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.store.Megaphone; -import gg.pingpong.data.store.Receipt; -import gg.pingpong.data.store.type.ItemStatus; +import gg.data.store.Megaphone; +import gg.data.store.Receipt; +import gg.data.store.type.ItemStatus; public interface MegaphoneRepository extends JpaRepository { List findAllByUsedAtAndReceiptStatus(LocalDate date, ItemStatus itemStatus); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/ReceiptRepository.java b/gg-repo/src/main/java/gg/repo/store/ReceiptRepository.java similarity index 66% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/ReceiptRepository.java rename to gg-repo/src/main/java/gg/repo/store/ReceiptRepository.java index 3a607e3f0..87f43cd60 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/ReceiptRepository.java +++ b/gg-repo/src/main/java/gg/repo/store/ReceiptRepository.java @@ -1,8 +1,8 @@ -package gg.pingpong.repo.store; +package gg.repo.store; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.store.Receipt; +import gg.data.store.Receipt; public interface ReceiptRepository extends JpaRepository { } diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/UserItemRepository.java b/gg-repo/src/main/java/gg/repo/store/UserItemRepository.java similarity index 89% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/UserItemRepository.java rename to gg-repo/src/main/java/gg/repo/store/UserItemRepository.java index 087943908..2d5a9830b 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/store/UserItemRepository.java +++ b/gg-repo/src/main/java/gg/repo/store/UserItemRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.store; +package gg.repo.store; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -6,7 +6,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.store.Receipt; +import gg.data.store.Receipt; public interface UserItemRepository extends JpaRepository { diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentGameRepository.java b/gg-repo/src/main/java/gg/repo/tournarment/TournamentGameRepository.java similarity index 78% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentGameRepository.java rename to gg-repo/src/main/java/gg/repo/tournarment/TournamentGameRepository.java index 042697ce4..beb1da482 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentGameRepository.java +++ b/gg-repo/src/main/java/gg/repo/tournarment/TournamentGameRepository.java @@ -1,12 +1,12 @@ -package gg.pingpong.repo.tournarment; +package gg.repo.tournarment; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.type.TournamentRound; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.type.TournamentRound; public interface TournamentGameRepository extends JpaRepository { List findAllByTournamentId(Long tournamentId); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentRepository.java b/gg-repo/src/main/java/gg/repo/tournarment/TournamentRepository.java similarity index 87% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentRepository.java rename to gg-repo/src/main/java/gg/repo/tournarment/TournamentRepository.java index 491ee7c79..852d3d1bd 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentRepository.java +++ b/gg-repo/src/main/java/gg/repo/tournarment/TournamentRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.tournarment; +package gg.repo.tournarment; import java.time.LocalDateTime; import java.util.List; @@ -12,9 +12,9 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; +import gg.data.tournament.Tournament; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; public interface TournamentRepository extends JpaRepository { List findAllByStatusIsNot(TournamentStatus status); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentUserRepository.java b/gg-repo/src/main/java/gg/repo/tournarment/TournamentUserRepository.java similarity index 79% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentUserRepository.java rename to gg-repo/src/main/java/gg/repo/tournarment/TournamentUserRepository.java index 6a7130da0..5482c2279 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/tournarment/TournamentUserRepository.java +++ b/gg-repo/src/main/java/gg/repo/tournarment/TournamentUserRepository.java @@ -1,13 +1,13 @@ -package gg.pingpong.repo.tournarment; +package gg.repo.tournarment; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentUser; -import gg.pingpong.data.user.User; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentUser; +import gg.data.user.User; public interface TournamentUserRepository extends JpaRepository { diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/ExpRankV2Dto.java b/gg-repo/src/main/java/gg/repo/user/ExpRankV2Dto.java similarity index 85% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/ExpRankV2Dto.java rename to gg-repo/src/main/java/gg/repo/user/ExpRankV2Dto.java index 641e03ef9..ffe95bc83 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/ExpRankV2Dto.java +++ b/gg-repo/src/main/java/gg/repo/user/ExpRankV2Dto.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.user; +package gg.repo.user; public interface ExpRankV2Dto { String getIntraId(); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/UserImageRepository.java b/gg-repo/src/main/java/gg/repo/user/UserImageRepository.java similarity index 70% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/UserImageRepository.java rename to gg-repo/src/main/java/gg/repo/user/UserImageRepository.java index 809a3a3b3..e8bd67d87 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/UserImageRepository.java +++ b/gg-repo/src/main/java/gg/repo/user/UserImageRepository.java @@ -1,11 +1,11 @@ -package gg.pingpong.repo.user; +package gg.repo.user; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.UserImage; +import gg.data.user.User; +import gg.data.user.UserImage; public interface UserImageRepository extends JpaRepository { Optional findTopByUserAndIsCurrentIsTrueOrderByIdDesc(User user); diff --git a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/UserRepository.java b/gg-repo/src/main/java/gg/repo/user/UserRepository.java similarity index 96% rename from gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/UserRepository.java rename to gg-repo/src/main/java/gg/repo/user/UserRepository.java index 60855d497..446b14a9d 100644 --- a/gg-pingpong-repo/src/main/java/gg/pingpong/repo/user/UserRepository.java +++ b/gg-repo/src/main/java/gg/repo/user/UserRepository.java @@ -1,4 +1,4 @@ -package gg.pingpong.repo.user; +package gg.repo.user; import java.util.List; import java.util.Optional; @@ -10,7 +10,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import gg.pingpong.data.user.User; +import gg.data.user.User; public interface UserRepository extends JpaRepository { Optional findByIntraId(String intraId); diff --git a/gg-pingpong-utils/build.gradle b/gg-utils/build.gradle similarity index 77% rename from gg-pingpong-utils/build.gradle rename to gg-utils/build.gradle index 856dbdf49..5f95eb653 100644 --- a/gg-pingpong-utils/build.gradle +++ b/gg-utils/build.gradle @@ -46,8 +46,8 @@ integrationTestCoverageReport { } getClassDirectories().setFrom(files( - [project(':gg-pingpong-data'), project(':gg-pingpong-admin-repo'), - project(':gg-pingpong-repo'), project(':gg-pingpong-api')].collect { + [project(':gg-data'), project(':gg-admin-repo'), + project(':gg-repo'), project(':gg-pingpong-api')].collect { it.fileTree(dir: "${it.buildDir}/classes/java/main", exclude: jacocoExcludes) } )) @@ -62,8 +62,8 @@ unitTestCoverageReport { } getClassDirectories().setFrom(files( - [project(':gg-pingpong-data'), project(':gg-pingpong-admin-repo'), - project(':gg-pingpong-repo'), project(':gg-pingpong-api')].collect { + [project(':gg-data'), project(':gg-admin-repo'), + project(':gg-repo'), project(':gg-pingpong-api')].collect { it.fileTree(dir: "${it.buildDir}/classes/java/main", exclude: jacocoExcludes) } )) @@ -87,14 +87,14 @@ dependencies { testFixturesCompileOnly("org.projectlombok:lombok") testFixturesAnnotationProcessor("org.projectlombok:lombok") - testFixturesImplementation project(":gg-pingpong-data") - testFixturesImplementation project(":gg-pingpong-repo") - testFixturesImplementation project(":gg-pingpong-admin-repo") + testFixturesImplementation project(":gg-data") + testFixturesImplementation project(":gg-repo") + testFixturesImplementation project(":gg-admin-repo") testFixturesImplementation project(":gg-pingpong-api") - jacocoAggregation(project(':gg-pingpong-data')) - jacocoAggregation(project(':gg-pingpong-repo')) - jacocoAggregation(project(':gg-pingpong-admin-repo')) + jacocoAggregation(project(':gg-data')) + jacocoAggregation(project(':gg-repo')) + jacocoAggregation(project(':gg-admin-repo')) jacocoAggregation(project(':gg-pingpong-api')) } diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/RedisKeyManager.java b/gg-utils/src/main/java/gg/utils/RedisKeyManager.java similarity index 94% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/RedisKeyManager.java rename to gg-utils/src/main/java/gg/utils/RedisKeyManager.java index 1ef247577..d1b47aec2 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/RedisKeyManager.java +++ b/gg-utils/src/main/java/gg/utils/RedisKeyManager.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils; +package gg.utils; public class RedisKeyManager { private static final String ZSetKeyPrefix = "rank:ZSet:"; diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/BusinessChecker.java b/gg-utils/src/main/java/gg/utils/exception/BusinessChecker.java similarity index 90% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/BusinessChecker.java rename to gg-utils/src/main/java/gg/utils/exception/BusinessChecker.java index eb5de88fb..9b9ff8751 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/BusinessChecker.java +++ b/gg-utils/src/main/java/gg/utils/exception/BusinessChecker.java @@ -1,8 +1,8 @@ -package gg.pingpong.utils.exception; +package gg.utils.exception; import java.util.Collection; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.utils.exception.custom.BusinessException; import lombok.AccessLevel; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/ErrorCode.java b/gg-utils/src/main/java/gg/utils/exception/ErrorCode.java similarity index 99% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/ErrorCode.java rename to gg-utils/src/main/java/gg/utils/exception/ErrorCode.java index 268ed64e4..72b0fa6d3 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/ErrorCode.java +++ b/gg-utils/src/main/java/gg/utils/exception/ErrorCode.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils.exception; +package gg.utils.exception; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/ErrorResponse.java b/gg-utils/src/main/java/gg/utils/exception/ErrorResponse.java similarity index 88% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/ErrorResponse.java rename to gg-utils/src/main/java/gg/utils/exception/ErrorResponse.java index 414d27265..2bf551bb0 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/ErrorResponse.java +++ b/gg-utils/src/main/java/gg/utils/exception/ErrorResponse.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils.exception; +package gg.utils.exception; import lombok.Getter; diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/announcement/AnnounceDupException.java b/gg-utils/src/main/java/gg/utils/exception/announcement/AnnounceDupException.java similarity index 53% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/announcement/AnnounceDupException.java rename to gg-utils/src/main/java/gg/utils/exception/announcement/AnnounceDupException.java index 177bfe184..14abdc92e 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/announcement/AnnounceDupException.java +++ b/gg-utils/src/main/java/gg/utils/exception/announcement/AnnounceDupException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.announcement; +package gg.utils.exception.announcement; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.DuplicationException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.DuplicationException; public class AnnounceDupException extends DuplicationException { public AnnounceDupException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/announcement/AnnounceNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/announcement/AnnounceNotFoundException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/announcement/AnnounceNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/announcement/AnnounceNotFoundException.java index 10ebefdae..05b1dc2d8 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/announcement/AnnounceNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/announcement/AnnounceNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.announcement; +package gg.utils.exception.announcement; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.CustomRuntimeException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.CustomRuntimeException; public class AnnounceNotFoundException extends CustomRuntimeException { public AnnounceNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/coin/CoinHistoryNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/coin/CoinHistoryNotFoundException.java similarity index 58% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/coin/CoinHistoryNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/coin/CoinHistoryNotFoundException.java index 867cb8d22..5cf7d49c1 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/coin/CoinHistoryNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/coin/CoinHistoryNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.coin; +package gg.utils.exception.coin; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.CustomRuntimeException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.CustomRuntimeException; public class CoinHistoryNotFoundException extends CustomRuntimeException { public CoinHistoryNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/coin/CoinPolicyNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/coin/CoinPolicyNotFoundException.java similarity index 57% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/coin/CoinPolicyNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/coin/CoinPolicyNotFoundException.java index f4f2f211a..3e658f122 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/coin/CoinPolicyNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/coin/CoinPolicyNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.coin; +package gg.utils.exception.coin; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.CustomRuntimeException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.CustomRuntimeException; public class CoinPolicyNotFoundException extends CustomRuntimeException { public CoinPolicyNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/AuthenticationException.java b/gg-utils/src/main/java/gg/utils/exception/custom/AuthenticationException.java similarity index 69% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/AuthenticationException.java rename to gg-utils/src/main/java/gg/utils/exception/custom/AuthenticationException.java index 2979703b5..6fb9ac499 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/AuthenticationException.java +++ b/gg-utils/src/main/java/gg/utils/exception/custom/AuthenticationException.java @@ -1,6 +1,6 @@ -package gg.pingpong.utils.exception.custom; +package gg.utils.exception.custom; -import gg.pingpong.utils.exception.ErrorCode; +import gg.utils.exception.ErrorCode; public class AuthenticationException extends CustomRuntimeException { private ErrorCode errorCode; diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/BusinessException.java b/gg-utils/src/main/java/gg/utils/exception/custom/BusinessException.java similarity index 74% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/BusinessException.java rename to gg-utils/src/main/java/gg/utils/exception/custom/BusinessException.java index 430120b68..eafb5fa95 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/BusinessException.java +++ b/gg-utils/src/main/java/gg/utils/exception/custom/BusinessException.java @@ -1,6 +1,6 @@ -package gg.pingpong.utils.exception.custom; +package gg.utils.exception.custom; -import gg.pingpong.utils.exception.ErrorCode; +import gg.utils.exception.ErrorCode; public class BusinessException extends CustomRuntimeException { public BusinessException(String message, ErrorCode errorCode) { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/CustomRuntimeException.java b/gg-utils/src/main/java/gg/utils/exception/custom/CustomRuntimeException.java similarity index 81% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/CustomRuntimeException.java rename to gg-utils/src/main/java/gg/utils/exception/custom/CustomRuntimeException.java index f83f4045b..fab407b85 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/CustomRuntimeException.java +++ b/gg-utils/src/main/java/gg/utils/exception/custom/CustomRuntimeException.java @@ -1,6 +1,6 @@ -package gg.pingpong.utils.exception.custom; +package gg.utils.exception.custom; -import gg.pingpong.utils.exception.ErrorCode; +import gg.utils.exception.ErrorCode; import lombok.Getter; @Getter diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/DBConsistencyException.java b/gg-utils/src/main/java/gg/utils/exception/custom/DBConsistencyException.java similarity index 69% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/DBConsistencyException.java rename to gg-utils/src/main/java/gg/utils/exception/custom/DBConsistencyException.java index 0da170e7a..7e23c97f6 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/DBConsistencyException.java +++ b/gg-utils/src/main/java/gg/utils/exception/custom/DBConsistencyException.java @@ -1,6 +1,6 @@ -package gg.pingpong.utils.exception.custom; +package gg.utils.exception.custom; -import gg.pingpong.utils.exception.ErrorCode; +import gg.utils.exception.ErrorCode; import lombok.Getter; @Getter diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/DuplicationException.java b/gg-utils/src/main/java/gg/utils/exception/custom/DuplicationException.java similarity index 65% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/DuplicationException.java rename to gg-utils/src/main/java/gg/utils/exception/custom/DuplicationException.java index 08f54d542..7d3591af2 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/DuplicationException.java +++ b/gg-utils/src/main/java/gg/utils/exception/custom/DuplicationException.java @@ -1,6 +1,6 @@ -package gg.pingpong.utils.exception.custom; +package gg.utils.exception.custom; -import gg.pingpong.utils.exception.ErrorCode; +import gg.utils.exception.ErrorCode; public class DuplicationException extends CustomRuntimeException { public DuplicationException(String message, ErrorCode errorCode) { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ExpiredException.java b/gg-utils/src/main/java/gg/utils/exception/custom/ExpiredException.java similarity index 64% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ExpiredException.java rename to gg-utils/src/main/java/gg/utils/exception/custom/ExpiredException.java index 7fabeca5a..934c5ecc4 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ExpiredException.java +++ b/gg-utils/src/main/java/gg/utils/exception/custom/ExpiredException.java @@ -1,6 +1,6 @@ -package gg.pingpong.utils.exception.custom; +package gg.utils.exception.custom; -import gg.pingpong.utils.exception.ErrorCode; +import gg.utils.exception.ErrorCode; public class ExpiredException extends CustomRuntimeException { public ExpiredException(String message, ErrorCode errorCode) { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/FileException.java b/gg-utils/src/main/java/gg/utils/exception/custom/FileException.java similarity index 63% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/FileException.java rename to gg-utils/src/main/java/gg/utils/exception/custom/FileException.java index 889a06664..9d77bcffa 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/FileException.java +++ b/gg-utils/src/main/java/gg/utils/exception/custom/FileException.java @@ -1,6 +1,6 @@ -package gg.pingpong.utils.exception.custom; +package gg.utils.exception.custom; -import gg.pingpong.utils.exception.ErrorCode; +import gg.utils.exception.ErrorCode; public class FileException extends CustomRuntimeException { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ForbiddenException.java b/gg-utils/src/main/java/gg/utils/exception/custom/ForbiddenException.java similarity index 64% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ForbiddenException.java rename to gg-utils/src/main/java/gg/utils/exception/custom/ForbiddenException.java index 64dfc868b..b9ff7b742 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ForbiddenException.java +++ b/gg-utils/src/main/java/gg/utils/exception/custom/ForbiddenException.java @@ -1,6 +1,6 @@ -package gg.pingpong.utils.exception.custom; +package gg.utils.exception.custom; -import gg.pingpong.utils.exception.ErrorCode; +import gg.utils.exception.ErrorCode; public class ForbiddenException extends CustomRuntimeException { public ForbiddenException(String message, ErrorCode errorCode) { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/InvalidParameterException.java b/gg-utils/src/main/java/gg/utils/exception/custom/InvalidParameterException.java similarity index 66% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/InvalidParameterException.java rename to gg-utils/src/main/java/gg/utils/exception/custom/InvalidParameterException.java index 77456ecc8..d2f182ec5 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/InvalidParameterException.java +++ b/gg-utils/src/main/java/gg/utils/exception/custom/InvalidParameterException.java @@ -1,6 +1,6 @@ -package gg.pingpong.utils.exception.custom; +package gg.utils.exception.custom; -import gg.pingpong.utils.exception.ErrorCode; +import gg.utils.exception.ErrorCode; public class InvalidParameterException extends CustomRuntimeException { public InvalidParameterException(String message, ErrorCode errorCode) { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/NotExistException.java b/gg-utils/src/main/java/gg/utils/exception/custom/NotExistException.java similarity index 68% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/NotExistException.java rename to gg-utils/src/main/java/gg/utils/exception/custom/NotExistException.java index 0ffacbfdd..efbf33b5e 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/NotExistException.java +++ b/gg-utils/src/main/java/gg/utils/exception/custom/NotExistException.java @@ -1,6 +1,6 @@ -package gg.pingpong.utils.exception.custom; +package gg.utils.exception.custom; -import gg.pingpong.utils.exception.ErrorCode; +import gg.utils.exception.ErrorCode; public class NotExistException extends CustomRuntimeException { private ErrorCode errorCode; diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/PageNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/custom/PageNotFoundException.java similarity index 76% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/PageNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/custom/PageNotFoundException.java index 3deef6dca..8481e315f 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/PageNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/custom/PageNotFoundException.java @@ -1,6 +1,6 @@ -package gg.pingpong.utils.exception.custom; +package gg.utils.exception.custom; -import gg.pingpong.utils.exception.ErrorCode; +import gg.utils.exception.ErrorCode; public class PageNotFoundException extends CustomRuntimeException { public PageNotFoundException(String message, ErrorCode errorCode) { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ParseException.java b/gg-utils/src/main/java/gg/utils/exception/custom/ParseException.java similarity index 63% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ParseException.java rename to gg-utils/src/main/java/gg/utils/exception/custom/ParseException.java index 89c556db1..1924834ef 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/ParseException.java +++ b/gg-utils/src/main/java/gg/utils/exception/custom/ParseException.java @@ -1,6 +1,6 @@ -package gg.pingpong.utils.exception.custom; +package gg.utils.exception.custom; -import gg.pingpong.utils.exception.ErrorCode; +import gg.utils.exception.ErrorCode; public class ParseException extends CustomRuntimeException { public ParseException(String message, ErrorCode errorCode) { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/SendException.java b/gg-utils/src/main/java/gg/utils/exception/custom/SendException.java similarity index 63% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/SendException.java rename to gg-utils/src/main/java/gg/utils/exception/custom/SendException.java index 52d1fee40..e1580fb4d 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/custom/SendException.java +++ b/gg-utils/src/main/java/gg/utils/exception/custom/SendException.java @@ -1,6 +1,6 @@ -package gg.pingpong.utils.exception.custom; +package gg.utils.exception.custom; -import gg.pingpong.utils.exception.ErrorCode; +import gg.utils.exception.ErrorCode; public class SendException extends CustomRuntimeException { public SendException(String message, ErrorCode errorCode) { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/feedback/FeedbackNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/feedback/FeedbackNotFoundException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/feedback/FeedbackNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/feedback/FeedbackNotFoundException.java index df7738dce..1acdb2fb4 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/feedback/FeedbackNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/feedback/FeedbackNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.feedback; +package gg.utils.exception.feedback; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.CustomRuntimeException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.CustomRuntimeException; public class FeedbackNotFoundException extends CustomRuntimeException { public FeedbackNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameAlreadyExistException.java b/gg-utils/src/main/java/gg/utils/exception/game/GameAlreadyExistException.java similarity index 57% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameAlreadyExistException.java rename to gg-utils/src/main/java/gg/utils/exception/game/GameAlreadyExistException.java index 0ccfafe23..cf3b76564 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameAlreadyExistException.java +++ b/gg-utils/src/main/java/gg/utils/exception/game/GameAlreadyExistException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.game; +package gg.utils.exception.game; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.DuplicationException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.DuplicationException; public class GameAlreadyExistException extends DuplicationException { public GameAlreadyExistException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameDataConsistencyException.java b/gg-utils/src/main/java/gg/utils/exception/game/GameDataConsistencyException.java similarity index 56% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameDataConsistencyException.java rename to gg-utils/src/main/java/gg/utils/exception/game/GameDataConsistencyException.java index 2089f17f3..5e1f950ad 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameDataConsistencyException.java +++ b/gg-utils/src/main/java/gg/utils/exception/game/GameDataConsistencyException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.game; +package gg.utils.exception.game; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.DBConsistencyException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.DBConsistencyException; public class GameDataConsistencyException extends DBConsistencyException { public GameDataConsistencyException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameNotExistException.java b/gg-utils/src/main/java/gg/utils/exception/game/GameNotExistException.java similarity index 54% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameNotExistException.java rename to gg-utils/src/main/java/gg/utils/exception/game/GameNotExistException.java index 05bdfcda6..b15bbd8bb 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameNotExistException.java +++ b/gg-utils/src/main/java/gg/utils/exception/game/GameNotExistException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.game; +package gg.utils.exception.game; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class GameNotExistException extends NotExistException { public GameNotExistException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameStatusNotMatchedException.java b/gg-utils/src/main/java/gg/utils/exception/game/GameStatusNotMatchedException.java similarity index 57% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameStatusNotMatchedException.java rename to gg-utils/src/main/java/gg/utils/exception/game/GameStatusNotMatchedException.java index 9b910fe58..c78b11a22 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/GameStatusNotMatchedException.java +++ b/gg-utils/src/main/java/gg/utils/exception/game/GameStatusNotMatchedException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.game; +package gg.utils.exception.game; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; public class GameStatusNotMatchedException extends BusinessException { public GameStatusNotMatchedException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/NotRecentlyGameException.java b/gg-utils/src/main/java/gg/utils/exception/game/NotRecentlyGameException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/NotRecentlyGameException.java rename to gg-utils/src/main/java/gg/utils/exception/game/NotRecentlyGameException.java index e81f9082f..f4e7fabd8 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/NotRecentlyGameException.java +++ b/gg-utils/src/main/java/gg/utils/exception/game/NotRecentlyGameException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.game; +package gg.utils.exception.game; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.InvalidParameterException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.InvalidParameterException; public class NotRecentlyGameException extends InvalidParameterException { public NotRecentlyGameException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreAlreadyEnteredException.java b/gg-utils/src/main/java/gg/utils/exception/game/ScoreAlreadyEnteredException.java similarity index 54% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreAlreadyEnteredException.java rename to gg-utils/src/main/java/gg/utils/exception/game/ScoreAlreadyEnteredException.java index 41904af25..49020621b 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreAlreadyEnteredException.java +++ b/gg-utils/src/main/java/gg/utils/exception/game/ScoreAlreadyEnteredException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.game; +package gg.utils.exception.game; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.DuplicationException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.DuplicationException; public class ScoreAlreadyEnteredException extends DuplicationException { public ScoreAlreadyEnteredException(String message, ErrorCode errorCode) { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreNotInvalidException.java b/gg-utils/src/main/java/gg/utils/exception/game/ScoreNotInvalidException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreNotInvalidException.java rename to gg-utils/src/main/java/gg/utils/exception/game/ScoreNotInvalidException.java index 9e61ac2cc..a00805210 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreNotInvalidException.java +++ b/gg-utils/src/main/java/gg/utils/exception/game/ScoreNotInvalidException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.game; +package gg.utils.exception.game; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.InvalidParameterException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.InvalidParameterException; public class ScoreNotInvalidException extends InvalidParameterException { public ScoreNotInvalidException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreNotMatchedException.java b/gg-utils/src/main/java/gg/utils/exception/game/ScoreNotMatchedException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreNotMatchedException.java rename to gg-utils/src/main/java/gg/utils/exception/game/ScoreNotMatchedException.java index edc77e6de..4a14eb892 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/game/ScoreNotMatchedException.java +++ b/gg-utils/src/main/java/gg/utils/exception/game/ScoreNotMatchedException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.game; +package gg.utils.exception.game; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.DuplicationException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.DuplicationException; public class ScoreNotMatchedException extends DuplicationException { public ScoreNotMatchedException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/InsufficientGgcoinException.java b/gg-utils/src/main/java/gg/utils/exception/item/InsufficientGgcoinException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/InsufficientGgcoinException.java rename to gg-utils/src/main/java/gg/utils/exception/item/InsufficientGgcoinException.java index 99787c438..89114a1e2 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/InsufficientGgcoinException.java +++ b/gg-utils/src/main/java/gg/utils/exception/item/InsufficientGgcoinException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.item; +package gg.utils.exception.item; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; public class InsufficientGgcoinException extends BusinessException { public InsufficientGgcoinException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemImageLargeException.java b/gg-utils/src/main/java/gg/utils/exception/item/ItemImageLargeException.java similarity index 54% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemImageLargeException.java rename to gg-utils/src/main/java/gg/utils/exception/item/ItemImageLargeException.java index 8432182d5..2f40f7629 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemImageLargeException.java +++ b/gg-utils/src/main/java/gg/utils/exception/item/ItemImageLargeException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.item; +package gg.utils.exception.item; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.FileException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.FileException; public class ItemImageLargeException extends FileException { public ItemImageLargeException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemImageTypeException.java b/gg-utils/src/main/java/gg/utils/exception/item/ItemImageTypeException.java similarity index 57% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemImageTypeException.java rename to gg-utils/src/main/java/gg/utils/exception/item/ItemImageTypeException.java index 43baf0acf..e33ca349c 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemImageTypeException.java +++ b/gg-utils/src/main/java/gg/utils/exception/item/ItemImageTypeException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.item; +package gg.utils.exception.item; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.FileException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.FileException; public class ItemImageTypeException extends FileException { public ItemImageTypeException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotAvailableException.java b/gg-utils/src/main/java/gg/utils/exception/item/ItemNotAvailableException.java similarity index 56% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotAvailableException.java rename to gg-utils/src/main/java/gg/utils/exception/item/ItemNotAvailableException.java index e0ca95ebb..6f3215d29 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotAvailableException.java +++ b/gg-utils/src/main/java/gg/utils/exception/item/ItemNotAvailableException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.item; +package gg.utils.exception.item; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.FileException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.FileException; public class ItemNotAvailableException extends FileException { public ItemNotAvailableException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/item/ItemNotFoundException.java similarity index 53% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/item/ItemNotFoundException.java index e46a34c2f..169a7092e 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/item/ItemNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.item; +package gg.utils.exception.item; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class ItemNotFoundException extends NotExistException { public ItemNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotPurchasableException.java b/gg-utils/src/main/java/gg/utils/exception/item/ItemNotPurchasableException.java similarity index 58% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotPurchasableException.java rename to gg-utils/src/main/java/gg/utils/exception/item/ItemNotPurchasableException.java index 2375db6dc..35733742c 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemNotPurchasableException.java +++ b/gg-utils/src/main/java/gg/utils/exception/item/ItemNotPurchasableException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.item; +package gg.utils.exception.item; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; public class ItemNotPurchasableException extends BusinessException { public ItemNotPurchasableException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemTypeException.java b/gg-utils/src/main/java/gg/utils/exception/item/ItemTypeException.java similarity index 54% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemTypeException.java rename to gg-utils/src/main/java/gg/utils/exception/item/ItemTypeException.java index 970beea37..0b4b71ba6 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/ItemTypeException.java +++ b/gg-utils/src/main/java/gg/utils/exception/item/ItemTypeException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.item; +package gg.utils.exception.item; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; public class ItemTypeException extends BusinessException { public ItemTypeException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/KakaoGiftException.java b/gg-utils/src/main/java/gg/utils/exception/item/KakaoGiftException.java similarity index 57% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/KakaoGiftException.java rename to gg-utils/src/main/java/gg/utils/exception/item/KakaoGiftException.java index 47e334a73..dc9e3c848 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/KakaoGiftException.java +++ b/gg-utils/src/main/java/gg/utils/exception/item/KakaoGiftException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.item; +package gg.utils.exception.item; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; public class KakaoGiftException extends BusinessException { public KakaoGiftException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/KakaoPurchaseException.java b/gg-utils/src/main/java/gg/utils/exception/item/KakaoPurchaseException.java similarity index 58% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/KakaoPurchaseException.java rename to gg-utils/src/main/java/gg/utils/exception/item/KakaoPurchaseException.java index 214da95f1..ad95b4736 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/item/KakaoPurchaseException.java +++ b/gg-utils/src/main/java/gg/utils/exception/item/KakaoPurchaseException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.item; +package gg.utils.exception.item; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; public class KakaoPurchaseException extends BusinessException { public KakaoPurchaseException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/EnrolledSlotException.java b/gg-utils/src/main/java/gg/utils/exception/match/EnrolledSlotException.java similarity index 53% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/EnrolledSlotException.java rename to gg-utils/src/main/java/gg/utils/exception/match/EnrolledSlotException.java index 4f0050ae5..c742a4836 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/EnrolledSlotException.java +++ b/gg-utils/src/main/java/gg/utils/exception/match/EnrolledSlotException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.match; +package gg.utils.exception.match; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.DuplicationException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.DuplicationException; public class EnrolledSlotException extends DuplicationException { public EnrolledSlotException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/LosingTeamNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/match/LosingTeamNotFoundException.java similarity index 57% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/LosingTeamNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/match/LosingTeamNotFoundException.java index 10aa0dfeb..56d3694c7 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/LosingTeamNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/match/LosingTeamNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.match; +package gg.utils.exception.match; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class LosingTeamNotFoundException extends NotExistException { public LosingTeamNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/OptionInvalidException.java b/gg-utils/src/main/java/gg/utils/exception/match/OptionInvalidException.java similarity index 53% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/OptionInvalidException.java rename to gg-utils/src/main/java/gg/utils/exception/match/OptionInvalidException.java index dfa3aa53e..8be54a9ed 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/OptionInvalidException.java +++ b/gg-utils/src/main/java/gg/utils/exception/match/OptionInvalidException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.match; +package gg.utils.exception.match; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.InvalidParameterException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.InvalidParameterException; public class OptionInvalidException extends InvalidParameterException { public OptionInvalidException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/PastSlotException.java b/gg-utils/src/main/java/gg/utils/exception/match/PastSlotException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/PastSlotException.java rename to gg-utils/src/main/java/gg/utils/exception/match/PastSlotException.java index 73d827482..42cc5105d 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/PastSlotException.java +++ b/gg-utils/src/main/java/gg/utils/exception/match/PastSlotException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.match; +package gg.utils.exception.match; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.ExpiredException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.ExpiredException; public class PastSlotException extends ExpiredException { public PastSlotException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/PenaltyUserSlotException.java b/gg-utils/src/main/java/gg/utils/exception/match/PenaltyUserSlotException.java similarity index 59% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/PenaltyUserSlotException.java rename to gg-utils/src/main/java/gg/utils/exception/match/PenaltyUserSlotException.java index 1d0ee9de5..008b72545 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/PenaltyUserSlotException.java +++ b/gg-utils/src/main/java/gg/utils/exception/match/PenaltyUserSlotException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.match; +package gg.utils.exception.match; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; public class PenaltyUserSlotException extends BusinessException { public PenaltyUserSlotException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/SlotCountException.java b/gg-utils/src/main/java/gg/utils/exception/match/SlotCountException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/SlotCountException.java rename to gg-utils/src/main/java/gg/utils/exception/match/SlotCountException.java index 12ed515f9..44d51473d 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/SlotCountException.java +++ b/gg-utils/src/main/java/gg/utils/exception/match/SlotCountException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.match; +package gg.utils.exception.match; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; public class SlotCountException extends BusinessException { public SlotCountException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/SlotNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/match/SlotNotFoundException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/SlotNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/match/SlotNotFoundException.java index fa705a2b6..db6e3617f 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/SlotNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/match/SlotNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.match; +package gg.utils.exception.match; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class SlotNotFoundException extends NotExistException { public SlotNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/WinningTeamNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/match/WinningTeamNotFoundException.java similarity index 58% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/WinningTeamNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/match/WinningTeamNotFoundException.java index e35987aa5..cd018bb7d 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/match/WinningTeamNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/match/WinningTeamNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.match; +package gg.utils.exception.match; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class WinningTeamNotFoundException extends NotExistException { public WinningTeamNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneContentException.java b/gg-utils/src/main/java/gg/utils/exception/megaphone/MegaphoneContentException.java similarity index 54% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneContentException.java rename to gg-utils/src/main/java/gg/utils/exception/megaphone/MegaphoneContentException.java index da432bc36..e0a7fe332 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneContentException.java +++ b/gg-utils/src/main/java/gg/utils/exception/megaphone/MegaphoneContentException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.megaphone; +package gg.utils.exception.megaphone; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; public class MegaphoneContentException extends BusinessException { public MegaphoneContentException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/megaphone/MegaphoneNotFoundException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/megaphone/MegaphoneNotFoundException.java index 0e9f20c37..1cd7ebfd6 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/megaphone/MegaphoneNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.megaphone; +package gg.utils.exception.megaphone; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class MegaphoneNotFoundException extends NotExistException { public MegaphoneNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneTimeException.java b/gg-utils/src/main/java/gg/utils/exception/megaphone/MegaphoneTimeException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneTimeException.java rename to gg-utils/src/main/java/gg/utils/exception/megaphone/MegaphoneTimeException.java index f11699a56..29638bd25 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/megaphone/MegaphoneTimeException.java +++ b/gg-utils/src/main/java/gg/utils/exception/megaphone/MegaphoneTimeException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.megaphone; +package gg.utils.exception.megaphone; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; public class MegaphoneTimeException extends BusinessException { public MegaphoneTimeException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackJsonParseException.java b/gg-utils/src/main/java/gg/utils/exception/noti/SlackJsonParseException.java similarity index 56% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackJsonParseException.java rename to gg-utils/src/main/java/gg/utils/exception/noti/SlackJsonParseException.java index c7cdc857e..08e7ab4b8 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackJsonParseException.java +++ b/gg-utils/src/main/java/gg/utils/exception/noti/SlackJsonParseException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.noti; +package gg.utils.exception.noti; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.ParseException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.ParseException; public class SlackJsonParseException extends ParseException { public SlackJsonParseException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackSendException.java b/gg-utils/src/main/java/gg/utils/exception/noti/SlackSendException.java similarity index 52% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackSendException.java rename to gg-utils/src/main/java/gg/utils/exception/noti/SlackSendException.java index 3ac4af3ce..ecdedd880 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackSendException.java +++ b/gg-utils/src/main/java/gg/utils/exception/noti/SlackSendException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.noti; +package gg.utils.exception.noti; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.SendException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.SendException; public class SlackSendException extends SendException { public SlackSendException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackUserGetFailedException.java b/gg-utils/src/main/java/gg/utils/exception/noti/SlackUserGetFailedException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackUserGetFailedException.java rename to gg-utils/src/main/java/gg/utils/exception/noti/SlackUserGetFailedException.java index dd74005e3..ca437d365 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/noti/SlackUserGetFailedException.java +++ b/gg-utils/src/main/java/gg/utils/exception/noti/SlackUserGetFailedException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.noti; +package gg.utils.exception.noti; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class SlackUserGetFailedException extends NotExistException { public SlackUserGetFailedException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/pchange/PChangeNotExistException.java b/gg-utils/src/main/java/gg/utils/exception/pchange/PChangeNotExistException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/pchange/PChangeNotExistException.java rename to gg-utils/src/main/java/gg/utils/exception/pchange/PChangeNotExistException.java index 8a2ce6b7d..76803d01b 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/pchange/PChangeNotExistException.java +++ b/gg-utils/src/main/java/gg/utils/exception/pchange/PChangeNotExistException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.pchange; +package gg.utils.exception.pchange; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class PChangeNotExistException extends NotExistException { public PChangeNotExistException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/PenaltyExpiredException.java b/gg-utils/src/main/java/gg/utils/exception/penalty/PenaltyExpiredException.java similarity index 54% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/PenaltyExpiredException.java rename to gg-utils/src/main/java/gg/utils/exception/penalty/PenaltyExpiredException.java index 684ebe71d..612ed0f82 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/PenaltyExpiredException.java +++ b/gg-utils/src/main/java/gg/utils/exception/penalty/PenaltyExpiredException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.penalty; +package gg.utils.exception.penalty; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.ExpiredException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.ExpiredException; public class PenaltyExpiredException extends ExpiredException { public PenaltyExpiredException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/PenaltyNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/penalty/PenaltyNotFoundException.java similarity index 54% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/PenaltyNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/penalty/PenaltyNotFoundException.java index 8948ed11d..6ff0260f6 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/PenaltyNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/penalty/PenaltyNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.penalty; +package gg.utils.exception.penalty; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class PenaltyNotFoundException extends NotExistException { public PenaltyNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/RedisPenaltyUserNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/penalty/RedisPenaltyUserNotFoundException.java similarity index 60% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/RedisPenaltyUserNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/penalty/RedisPenaltyUserNotFoundException.java index f0a0fc167..efaab7bc4 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/penalty/RedisPenaltyUserNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/penalty/RedisPenaltyUserNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.penalty; +package gg.utils.exception.penalty; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class RedisPenaltyUserNotFoundException extends NotExistException { public RedisPenaltyUserNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RankNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/rank/RankNotFoundException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RankNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/rank/RankNotFoundException.java index 22379fa05..2d7889d27 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RankNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/rank/RankNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.rank; +package gg.utils.exception.rank; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class RankNotFoundException extends NotExistException { public RankNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RankUpdateException.java b/gg-utils/src/main/java/gg/utils/exception/rank/RankUpdateException.java similarity index 53% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RankUpdateException.java rename to gg-utils/src/main/java/gg/utils/exception/rank/RankUpdateException.java index 98aa426e5..af866cec9 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RankUpdateException.java +++ b/gg-utils/src/main/java/gg/utils/exception/rank/RankUpdateException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.rank; +package gg.utils.exception.rank; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.InvalidParameterException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.InvalidParameterException; public class RankUpdateException extends InvalidParameterException { public RankUpdateException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RedisDataNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/rank/RedisDataNotFoundException.java similarity index 56% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RedisDataNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/rank/RedisDataNotFoundException.java index e8fbbcb24..2795a5bf8 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/rank/RedisDataNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/rank/RedisDataNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.rank; +package gg.utils.exception.rank; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class RedisDataNotFoundException extends NotExistException { public RedisDataNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ItemStatusException.java b/gg-utils/src/main/java/gg/utils/exception/receipt/ItemStatusException.java similarity index 54% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ItemStatusException.java rename to gg-utils/src/main/java/gg/utils/exception/receipt/ItemStatusException.java index 3a74447be..f2c6195e3 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ItemStatusException.java +++ b/gg-utils/src/main/java/gg/utils/exception/receipt/ItemStatusException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.receipt; +package gg.utils.exception.receipt; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.BusinessException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.BusinessException; public class ItemStatusException extends BusinessException { public ItemStatusException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ReceiptNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/receipt/ReceiptNotFoundException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ReceiptNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/receipt/ReceiptNotFoundException.java index 8c81014fa..7bf1e361b 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ReceiptNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/receipt/ReceiptNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.receipt; +package gg.utils.exception.receipt; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class ReceiptNotFoundException extends NotExistException { public ReceiptNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ReceiptNotOwnerException.java b/gg-utils/src/main/java/gg/utils/exception/receipt/ReceiptNotOwnerException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ReceiptNotOwnerException.java rename to gg-utils/src/main/java/gg/utils/exception/receipt/ReceiptNotOwnerException.java index 59887658c..22fd37ccb 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/receipt/ReceiptNotOwnerException.java +++ b/gg-utils/src/main/java/gg/utils/exception/receipt/ReceiptNotOwnerException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.receipt; +package gg.utils.exception.receipt; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.ForbiddenException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.ForbiddenException; public class ReceiptNotOwnerException extends ForbiddenException { public ReceiptNotOwnerException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonForbiddenException.java b/gg-utils/src/main/java/gg/utils/exception/season/SeasonForbiddenException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonForbiddenException.java rename to gg-utils/src/main/java/gg/utils/exception/season/SeasonForbiddenException.java index 40c723806..75b38f409 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonForbiddenException.java +++ b/gg-utils/src/main/java/gg/utils/exception/season/SeasonForbiddenException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.season; +package gg.utils.exception.season; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.ForbiddenException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.ForbiddenException; public class SeasonForbiddenException extends ForbiddenException { public SeasonForbiddenException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/season/SeasonNotFoundException.java similarity index 64% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/season/SeasonNotFoundException.java index 5daab8a08..f2deb06b5 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/season/SeasonNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.season; +package gg.utils.exception.season; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class SeasonNotFoundException extends NotExistException { public SeasonNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonTimeBeforeException.java b/gg-utils/src/main/java/gg/utils/exception/season/SeasonTimeBeforeException.java similarity index 56% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonTimeBeforeException.java rename to gg-utils/src/main/java/gg/utils/exception/season/SeasonTimeBeforeException.java index 847525364..dae95b716 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/season/SeasonTimeBeforeException.java +++ b/gg-utils/src/main/java/gg/utils/exception/season/SeasonTimeBeforeException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.season; +package gg.utils.exception.season; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.ForbiddenException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.ForbiddenException; public class SeasonTimeBeforeException extends ForbiddenException { public SeasonTimeBeforeException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/slotmanagement/SlotManagementForbiddenException.java b/gg-utils/src/main/java/gg/utils/exception/slotmanagement/SlotManagementForbiddenException.java similarity index 58% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/slotmanagement/SlotManagementForbiddenException.java rename to gg-utils/src/main/java/gg/utils/exception/slotmanagement/SlotManagementForbiddenException.java index e465f9857..e6fd5b57b 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/slotmanagement/SlotManagementForbiddenException.java +++ b/gg-utils/src/main/java/gg/utils/exception/slotmanagement/SlotManagementForbiddenException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.slotmanagement; +package gg.utils.exception.slotmanagement; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.ForbiddenException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.ForbiddenException; public class SlotManagementForbiddenException extends ForbiddenException { public SlotManagementForbiddenException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/slotmanagement/SlotManagementNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/slotmanagement/SlotManagementNotFoundException.java similarity index 57% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/slotmanagement/SlotManagementNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/slotmanagement/SlotManagementNotFoundException.java index fc65300bb..46700252a 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/slotmanagement/SlotManagementNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/slotmanagement/SlotManagementNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.slotmanagement; +package gg.utils.exception.slotmanagement; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class SlotManagementNotFoundException extends NotExistException { public SlotManagementNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/team/TeamIdNotMatchException.java b/gg-utils/src/main/java/gg/utils/exception/team/TeamIdNotMatchException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/team/TeamIdNotMatchException.java rename to gg-utils/src/main/java/gg/utils/exception/team/TeamIdNotMatchException.java index a68007457..17b1247b7 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/team/TeamIdNotMatchException.java +++ b/gg-utils/src/main/java/gg/utils/exception/team/TeamIdNotMatchException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.team; +package gg.utils.exception.team; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class TeamIdNotMatchException extends NotExistException { public TeamIdNotMatchException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/team/TeamNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/team/TeamNotFoundException.java similarity index 54% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/team/TeamNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/team/TeamNotFoundException.java index 9cc24bc87..80c859c7d 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/team/TeamNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/team/TeamNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.team; +package gg.utils.exception.team; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class TeamNotFoundException extends NotExistException { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tier/TierNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/tier/TierNotFoundException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tier/TierNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/tier/TierNotFoundException.java index 7681147ef..4b75d4609 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tier/TierNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/tier/TierNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.tier; +package gg.utils.exception.tier; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class TierNotFoundException extends NotExistException { public TierNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentConflictException.java b/gg-utils/src/main/java/gg/utils/exception/tournament/TournamentConflictException.java similarity index 66% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentConflictException.java rename to gg-utils/src/main/java/gg/utils/exception/tournament/TournamentConflictException.java index e7396a89c..96f009d6b 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentConflictException.java +++ b/gg-utils/src/main/java/gg/utils/exception/tournament/TournamentConflictException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.tournament; +package gg.utils.exception.tournament; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.DuplicationException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.DuplicationException; public class TournamentConflictException extends DuplicationException { public TournamentConflictException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentGameNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/tournament/TournamentGameNotFoundException.java similarity index 58% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentGameNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/tournament/TournamentGameNotFoundException.java index 1d55b8d4a..547bfa3ed 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentGameNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/tournament/TournamentGameNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.tournament; +package gg.utils.exception.tournament; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class TournamentGameNotFoundException extends NotExistException { public TournamentGameNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/tournament/TournamentNotFoundException.java similarity index 66% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/tournament/TournamentNotFoundException.java index 3f5e305ce..0b6f2169e 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/tournament/TournamentNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.tournament; +package gg.utils.exception.tournament; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class TournamentNotFoundException extends NotExistException { public TournamentNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentUpdateException.java b/gg-utils/src/main/java/gg/utils/exception/tournament/TournamentUpdateException.java similarity index 66% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentUpdateException.java rename to gg-utils/src/main/java/gg/utils/exception/tournament/TournamentUpdateException.java index d03cf9b84..bb74f0bf2 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/tournament/TournamentUpdateException.java +++ b/gg-utils/src/main/java/gg/utils/exception/tournament/TournamentUpdateException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.tournament; +package gg.utils.exception.tournament; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.ForbiddenException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.ForbiddenException; public class TournamentUpdateException extends ForbiddenException { public TournamentUpdateException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/KakaoOauth2AlreadyExistException.java b/gg-utils/src/main/java/gg/utils/exception/user/KakaoOauth2AlreadyExistException.java similarity index 56% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/KakaoOauth2AlreadyExistException.java rename to gg-utils/src/main/java/gg/utils/exception/user/KakaoOauth2AlreadyExistException.java index 8b5daa0e8..df1fb40c9 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/KakaoOauth2AlreadyExistException.java +++ b/gg-utils/src/main/java/gg/utils/exception/user/KakaoOauth2AlreadyExistException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.user; +package gg.utils.exception.user; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.InvalidParameterException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.InvalidParameterException; public class KakaoOauth2AlreadyExistException extends InvalidParameterException { public KakaoOauth2AlreadyExistException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/KakaoOauth2NotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/user/KakaoOauth2NotFoundException.java similarity index 56% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/KakaoOauth2NotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/user/KakaoOauth2NotFoundException.java index e6aec3653..dc28347c4 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/KakaoOauth2NotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/user/KakaoOauth2NotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.user; +package gg.utils.exception.user; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class KakaoOauth2NotFoundException extends NotExistException { public KakaoOauth2NotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/TokenNotValidException.java b/gg-utils/src/main/java/gg/utils/exception/user/TokenNotValidException.java similarity index 52% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/TokenNotValidException.java rename to gg-utils/src/main/java/gg/utils/exception/user/TokenNotValidException.java index 198ced017..cbbfd9193 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/TokenNotValidException.java +++ b/gg-utils/src/main/java/gg/utils/exception/user/TokenNotValidException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.user; +package gg.utils.exception.user; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.AuthenticationException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.AuthenticationException; public class TokenNotValidException extends AuthenticationException { public TokenNotValidException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserAlreadyAttendanceException.java b/gg-utils/src/main/java/gg/utils/exception/user/UserAlreadyAttendanceException.java similarity index 57% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserAlreadyAttendanceException.java rename to gg-utils/src/main/java/gg/utils/exception/user/UserAlreadyAttendanceException.java index 8efbc4663..f74c197fa 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserAlreadyAttendanceException.java +++ b/gg-utils/src/main/java/gg/utils/exception/user/UserAlreadyAttendanceException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.user; +package gg.utils.exception.user; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.DuplicationException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.DuplicationException; public class UserAlreadyAttendanceException extends DuplicationException { public UserAlreadyAttendanceException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageLargeException.java b/gg-utils/src/main/java/gg/utils/exception/user/UserImageLargeException.java similarity index 54% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageLargeException.java rename to gg-utils/src/main/java/gg/utils/exception/user/UserImageLargeException.java index 49d935d9e..27ed0dd3c 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageLargeException.java +++ b/gg-utils/src/main/java/gg/utils/exception/user/UserImageLargeException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.user; +package gg.utils.exception.user; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.FileException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.FileException; public class UserImageLargeException extends FileException { public UserImageLargeException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageNullException.java b/gg-utils/src/main/java/gg/utils/exception/user/UserImageNullException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageNullException.java rename to gg-utils/src/main/java/gg/utils/exception/user/UserImageNullException.java index 5c1fe681a..9aec8e78f 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageNullException.java +++ b/gg-utils/src/main/java/gg/utils/exception/user/UserImageNullException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.user; +package gg.utils.exception.user; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.FileException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.FileException; public class UserImageNullException extends FileException { public UserImageNullException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageTypeException.java b/gg-utils/src/main/java/gg/utils/exception/user/UserImageTypeException.java similarity index 57% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageTypeException.java rename to gg-utils/src/main/java/gg/utils/exception/user/UserImageTypeException.java index 11950f70b..f91545dab 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserImageTypeException.java +++ b/gg-utils/src/main/java/gg/utils/exception/user/UserImageTypeException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.user; +package gg.utils.exception.user; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.FileException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.FileException; public class UserImageTypeException extends FileException { public UserImageTypeException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserNotFoundException.java b/gg-utils/src/main/java/gg/utils/exception/user/UserNotFoundException.java similarity index 53% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserNotFoundException.java rename to gg-utils/src/main/java/gg/utils/exception/user/UserNotFoundException.java index 12f980945..3144512f6 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserNotFoundException.java +++ b/gg-utils/src/main/java/gg/utils/exception/user/UserNotFoundException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.user; +package gg.utils.exception.user; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.NotExistException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.NotExistException; public class UserNotFoundException extends NotExistException { public UserNotFoundException() { diff --git a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserTextColorException.java b/gg-utils/src/main/java/gg/utils/exception/user/UserTextColorException.java similarity index 55% rename from gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserTextColorException.java rename to gg-utils/src/main/java/gg/utils/exception/user/UserTextColorException.java index 84a468bd1..1f9b1440b 100644 --- a/gg-pingpong-utils/src/main/java/gg/pingpong/utils/exception/user/UserTextColorException.java +++ b/gg-utils/src/main/java/gg/utils/exception/user/UserTextColorException.java @@ -1,7 +1,7 @@ -package gg.pingpong.utils.exception.user; +package gg.utils.exception.user; -import gg.pingpong.utils.exception.ErrorCode; -import gg.pingpong.utils.exception.custom.CustomRuntimeException; +import gg.utils.exception.ErrorCode; +import gg.utils.exception.custom.CustomRuntimeException; public class UserTextColorException extends CustomRuntimeException { public UserTextColorException() { diff --git a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/ItemTestUtils.java b/gg-utils/src/testFixtures/java/gg/utils/ItemTestUtils.java similarity index 79% rename from gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/ItemTestUtils.java rename to gg-utils/src/testFixtures/java/gg/utils/ItemTestUtils.java index bd8ca0eb1..68ea7dc0f 100644 --- a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/ItemTestUtils.java +++ b/gg-utils/src/testFixtures/java/gg/utils/ItemTestUtils.java @@ -1,19 +1,19 @@ -package gg.pingpong.utils; +package gg.utils; import java.time.LocalDate; import java.time.LocalDateTime; import org.springframework.stereotype.Component; +import gg.data.store.Item; +import gg.data.store.Megaphone; +import gg.data.store.Receipt; +import gg.data.store.type.ItemStatus; +import gg.data.user.User; import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto; -import gg.pingpong.data.store.Item; -import gg.pingpong.data.store.Megaphone; -import gg.pingpong.data.store.Receipt; -import gg.pingpong.data.store.type.ItemStatus; -import gg.pingpong.data.user.User; -import gg.pingpong.repo.store.ItemRepository; -import gg.pingpong.repo.store.MegaphoneRepository; -import gg.pingpong.repo.store.ReceiptRepository; +import gg.repo.store.ItemRepository; +import gg.repo.store.MegaphoneRepository; +import gg.repo.store.ReceiptRepository; import lombok.AllArgsConstructor; /** diff --git a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/TestDataUtils.java b/gg-utils/src/testFixtures/java/gg/utils/TestDataUtils.java similarity index 92% rename from gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/TestDataUtils.java rename to gg-utils/src/testFixtures/java/gg/utils/TestDataUtils.java index 96813f625..9de9768b6 100644 --- a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/TestDataUtils.java +++ b/gg-utils/src/testFixtures/java/gg/utils/TestDataUtils.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils; +package gg.utils; import java.time.LocalDateTime; import java.util.ArrayList; @@ -9,56 +9,56 @@ import org.springframework.stereotype.Component; +import gg.data.game.Game; +import gg.data.game.PChange; +import gg.data.game.Team; +import gg.data.game.TeamUser; +import gg.data.game.type.Mode; +import gg.data.game.type.StatusType; +import gg.data.manage.Announcement; +import gg.data.manage.SlotManagement; +import gg.data.noti.Noti; +import gg.data.noti.type.NotiType; +import gg.data.rank.Rank; +import gg.data.rank.Tier; +import gg.data.rank.redis.RankRedis; +import gg.data.season.Season; +import gg.data.store.CoinPolicy; +import gg.data.tournament.Tournament; +import gg.data.tournament.TournamentGame; +import gg.data.tournament.TournamentUser; +import gg.data.tournament.type.TournamentRound; +import gg.data.tournament.type.TournamentStatus; +import gg.data.tournament.type.TournamentType; +import gg.data.user.User; +import gg.data.user.UserImage; +import gg.data.user.type.RacketType; +import gg.data.user.type.RoleType; +import gg.data.user.type.SnsType; import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminCreateRequestDto; import gg.pingpong.api.admin.tournament.controller.request.TournamentAdminUpdateRequestDto; import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider; import gg.pingpong.api.user.tournament.controller.response.TournamentResponseDto; import gg.pingpong.api.user.user.dto.UserImageDto; -import gg.pingpong.data.game.Game; -import gg.pingpong.data.game.PChange; -import gg.pingpong.data.game.Team; -import gg.pingpong.data.game.TeamUser; -import gg.pingpong.data.game.type.Mode; -import gg.pingpong.data.game.type.StatusType; -import gg.pingpong.data.manage.Announcement; -import gg.pingpong.data.manage.SlotManagement; -import gg.pingpong.data.noti.Noti; -import gg.pingpong.data.noti.type.NotiType; -import gg.pingpong.data.rank.Rank; -import gg.pingpong.data.rank.Tier; -import gg.pingpong.data.rank.redis.RankRedis; -import gg.pingpong.data.season.Season; -import gg.pingpong.data.store.CoinPolicy; -import gg.pingpong.data.tournament.Tournament; -import gg.pingpong.data.tournament.TournamentGame; -import gg.pingpong.data.tournament.TournamentUser; -import gg.pingpong.data.tournament.type.TournamentRound; -import gg.pingpong.data.tournament.type.TournamentStatus; -import gg.pingpong.data.tournament.type.TournamentType; -import gg.pingpong.data.user.User; -import gg.pingpong.data.user.UserImage; -import gg.pingpong.data.user.type.RacketType; -import gg.pingpong.data.user.type.RoleType; -import gg.pingpong.data.user.type.SnsType; -import gg.pingpong.repo.game.GameRepository; -import gg.pingpong.repo.game.PChangeRepository; -import gg.pingpong.repo.game.TeamRepository; -import gg.pingpong.repo.game.TeamUserRepository; -import gg.pingpong.repo.manage.AnnouncementRepository; -import gg.pingpong.repo.manage.SlotManagementRepository; -import gg.pingpong.repo.noti.NotiRepository; -import gg.pingpong.repo.rank.RankRepository; -import gg.pingpong.repo.rank.TierRepository; -import gg.pingpong.repo.rank.redis.RankRedisRepository; -import gg.pingpong.repo.season.SeasonRepository; -import gg.pingpong.repo.store.CoinPolicyRepository; -import gg.pingpong.repo.tournarment.TournamentGameRepository; -import gg.pingpong.repo.tournarment.TournamentRepository; -import gg.pingpong.repo.tournarment.TournamentUserRepository; -import gg.pingpong.repo.user.UserImageRepository; -import gg.pingpong.repo.user.UserRepository; -import gg.pingpong.utils.dto.GameInfoDto; -import gg.pingpong.utils.exception.game.GameNotExistException; +import gg.repo.game.GameRepository; +import gg.repo.game.PChangeRepository; +import gg.repo.game.TeamRepository; +import gg.repo.game.TeamUserRepository; +import gg.repo.manage.AnnouncementRepository; +import gg.repo.manage.SlotManagementRepository; +import gg.repo.noti.NotiRepository; +import gg.repo.rank.RankRepository; +import gg.repo.rank.TierRepository; +import gg.repo.rank.redis.RankRedisRepository; +import gg.repo.season.SeasonRepository; +import gg.repo.store.CoinPolicyRepository; +import gg.repo.tournarment.TournamentGameRepository; +import gg.repo.tournarment.TournamentRepository; +import gg.repo.tournarment.TournamentUserRepository; +import gg.repo.user.UserImageRepository; +import gg.repo.user.UserRepository; +import gg.utils.dto.GameInfoDto; +import gg.utils.exception.game.GameNotExistException; import lombok.RequiredArgsConstructor; @Component diff --git a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/DataJpaUnitTest.java b/gg-utils/src/testFixtures/java/gg/utils/annotation/DataJpaUnitTest.java similarity index 92% rename from gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/DataJpaUnitTest.java rename to gg-utils/src/testFixtures/java/gg/utils/annotation/DataJpaUnitTest.java index 7f3b6f615..471db80b7 100644 --- a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/DataJpaUnitTest.java +++ b/gg-utils/src/testFixtures/java/gg/utils/annotation/DataJpaUnitTest.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils.annotation; +package gg.utils.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTest.java b/gg-utils/src/testFixtures/java/gg/utils/annotation/IntegrationTest.java similarity index 81% rename from gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTest.java rename to gg-utils/src/testFixtures/java/gg/utils/annotation/IntegrationTest.java index d64a35597..51f868fd6 100644 --- a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTest.java +++ b/gg-utils/src/testFixtures/java/gg/utils/annotation/IntegrationTest.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils.annotation; +package gg.utils.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -10,9 +10,9 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; -import gg.pingpong.utils.config.MySQLInitializer; -import gg.pingpong.utils.config.RedisInitializer; -import gg.pingpong.utils.config.TestRedisConfig; +import gg.utils.config.MySQLInitializer; +import gg.utils.config.RedisInitializer; +import gg.utils.config.TestRedisConfig; /** * 통합테스트 환경의 의존성 관리를 위한 어노테이션. diff --git a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTestAspect.java b/gg-utils/src/testFixtures/java/gg/utils/annotation/IntegrationTestAspect.java similarity index 86% rename from gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTestAspect.java rename to gg-utils/src/testFixtures/java/gg/utils/annotation/IntegrationTestAspect.java index 1951c667d..65a5caab1 100644 --- a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTestAspect.java +++ b/gg-utils/src/testFixtures/java/gg/utils/annotation/IntegrationTestAspect.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils.annotation; +package gg.utils.annotation; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.After; @@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import gg.pingpong.repo.rank.redis.RankRedisRepository; +import gg.repo.rank.redis.RankRedisRepository; @Aspect @Component diff --git a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTestWithRedisTransaction.java b/gg-utils/src/testFixtures/java/gg/utils/annotation/IntegrationTestWithRedisTransaction.java similarity index 84% rename from gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTestWithRedisTransaction.java rename to gg-utils/src/testFixtures/java/gg/utils/annotation/IntegrationTestWithRedisTransaction.java index 1f5e76f30..3d78f7aab 100644 --- a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/IntegrationTestWithRedisTransaction.java +++ b/gg-utils/src/testFixtures/java/gg/utils/annotation/IntegrationTestWithRedisTransaction.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils.annotation; +package gg.utils.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -9,8 +9,8 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ContextConfiguration; -import gg.pingpong.utils.config.MySQLInitializer; -import gg.pingpong.utils.config.RedisInitializer; +import gg.utils.config.MySQLInitializer; +import gg.utils.config.RedisInitializer; /** * 통합테스트 환경의 의존성 관리를 위한 어노테이션. diff --git a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/TestTypeConstant.java b/gg-utils/src/testFixtures/java/gg/utils/annotation/TestTypeConstant.java similarity index 90% rename from gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/TestTypeConstant.java rename to gg-utils/src/testFixtures/java/gg/utils/annotation/TestTypeConstant.java index 4ef1bcba2..ef86dd294 100644 --- a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/TestTypeConstant.java +++ b/gg-utils/src/testFixtures/java/gg/utils/annotation/TestTypeConstant.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils.annotation; +package gg.utils.annotation; import lombok.AccessLevel; import lombok.NoArgsConstructor; diff --git a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/UnitTest.java b/gg-utils/src/testFixtures/java/gg/utils/annotation/UnitTest.java similarity index 93% rename from gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/UnitTest.java rename to gg-utils/src/testFixtures/java/gg/utils/annotation/UnitTest.java index a470c40e5..25a9c5950 100644 --- a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/UnitTest.java +++ b/gg-utils/src/testFixtures/java/gg/utils/annotation/UnitTest.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils.annotation; +package gg.utils.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/WebMvcUnitTest.java b/gg-utils/src/testFixtures/java/gg/utils/annotation/WebMvcUnitTest.java similarity index 92% rename from gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/WebMvcUnitTest.java rename to gg-utils/src/testFixtures/java/gg/utils/annotation/WebMvcUnitTest.java index fdeec94ef..6b4e4f656 100644 --- a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/annotation/WebMvcUnitTest.java +++ b/gg-utils/src/testFixtures/java/gg/utils/annotation/WebMvcUnitTest.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils.annotation; +package gg.utils.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/MySQLInitializer.java b/gg-utils/src/testFixtures/java/gg/utils/config/MySQLInitializer.java similarity index 97% rename from gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/MySQLInitializer.java rename to gg-utils/src/testFixtures/java/gg/utils/config/MySQLInitializer.java index 1af0f4bfc..73ab9cf48 100644 --- a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/MySQLInitializer.java +++ b/gg-utils/src/testFixtures/java/gg/utils/config/MySQLInitializer.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils.config; +package gg.utils.config; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.context.ApplicationContextInitializer; diff --git a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/RedisInitializer.java b/gg-utils/src/testFixtures/java/gg/utils/config/RedisInitializer.java similarity index 96% rename from gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/RedisInitializer.java rename to gg-utils/src/testFixtures/java/gg/utils/config/RedisInitializer.java index 1fe3a5e6d..eaba9f188 100644 --- a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/RedisInitializer.java +++ b/gg-utils/src/testFixtures/java/gg/utils/config/RedisInitializer.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils.config; +package gg.utils.config; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.context.ApplicationContextInitializer; diff --git a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/TestRedisConfig.java b/gg-utils/src/testFixtures/java/gg/utils/config/TestRedisConfig.java similarity index 97% rename from gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/TestRedisConfig.java rename to gg-utils/src/testFixtures/java/gg/utils/config/TestRedisConfig.java index f8d4c63a9..fe0e85db7 100644 --- a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/config/TestRedisConfig.java +++ b/gg-utils/src/testFixtures/java/gg/utils/config/TestRedisConfig.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils.config; +package gg.utils.config; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; diff --git a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/dto/GameInfoDto.java b/gg-utils/src/testFixtures/java/gg/utils/dto/GameInfoDto.java similarity index 88% rename from gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/dto/GameInfoDto.java rename to gg-utils/src/testFixtures/java/gg/utils/dto/GameInfoDto.java index 05ba208b4..be50aa211 100644 --- a/gg-pingpong-utils/src/testFixtures/java/gg/pingpong/utils/dto/GameInfoDto.java +++ b/gg-utils/src/testFixtures/java/gg/utils/dto/GameInfoDto.java @@ -1,4 +1,4 @@ -package gg.pingpong.utils.dto; +package gg.utils.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/settings.gradle b/settings.gradle index 4d65fe63e..ae330bfed 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,7 @@ rootProject.name = 'server' -include 'gg-pingpong-data' -include 'gg-pingpong-admin-repo' -include 'gg-pingpong-repo' +include 'gg-data' +include 'gg-admin-repo' +include 'gg-repo' include 'gg-pingpong-api' -include 'gg-pingpong-utils' +include 'gg-utils'