Skip to content

Commit

Permalink
fix: checkstyle rebase dev에 맞게 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
middlefitting committed Jan 27, 2024
1 parent cd881b7 commit 72f0b70
Show file tree
Hide file tree
Showing 18 changed files with 1,697 additions and 1,577 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Void>
* @throws InvalidParameterException 점수가 3점을 초과하거나, 두 팀의 점수가 같을 경우
*/
@PutMapping("/{gameId}")
public ResponseEntity<Void> 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<Void>(HttpStatus.NO_CONTENT);
}
/**
* 랭킹 점수 수정 API
* @param reqDto team1Id team1Score team2Id team2Score
* @param gameId 수정할 게임 id
* @return ResponseEntity<Void>
* @throws InvalidParameterException 점수가 3점을 초과하거나, 두 팀의 점수가 같을 경우
*/
@PutMapping("/{gameId}")
public ResponseEntity<Void> 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<Void>(HttpStatus.NO_CONTENT);
}
}
Original file line number Diff line number Diff line change
@@ -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<Game, Long> {

Page<Game> findBySeason(Pageable pageable, Season season);
Page<Game> findBySeason(Pageable pageable, Season season);

Page<Game> findBySeasonAndModeIn(Pageable pageable, Season season, List<Mode> modes);

Page<Game> findBySeasonAndModeIn(Pageable pageable, Season season, List<Mode> modes);
Page<Game> findAllByModeIn(Pageable pageable, List<Mode> modes);

Page<Game> findAllByModeIn(Pageable pageable, List<Mode> 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 <t2.teamId and t1.gameId=t2.gameId "
+ "order by t1.startTime desc;", nativeQuery = true)
List<GameTeamUser> findTeamsByGameIsIn(@Param("games") List<Long> 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 <t2.teamId and t1.gameId=t2.gameId order by t1.startTime desc;", nativeQuery = true)
List<GameTeamUser> findTeamsByGameIsIn(@Param("games") List<Long> 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<Game> 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<Game> 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<Game> findGameWithSeasonByGameId(@Param("gameId")Long gameId);
@Query(value = "SELECT g FROM Game g JOIN FETCH g.season WHERE g.id = :gameId")
Optional<Game> findGameWithSeasonByGameId(@Param("gameId") Long gameId);
}
Loading

0 comments on commit 72f0b70

Please sign in to comment.