Skip to content

Commit

Permalink
feat: Domain과 Repository에 조회, 업데이트 관련 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
Hchanghyeon committed Dec 2, 2023
1 parent a6b835a commit ae8c56a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/kr/pickple/back/game/domain/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ private Game(
updateGamePositions(positions);
}

public void updateGameStatus(final GameStatus gameStatus) {
this.status = gameStatus;
}

private void updateGamePositions(final List<Position> positions) {
gamePositions.updateGamePositions(this, positions);
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/kr/pickple/back/game/repository/GameRepository.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package kr.pickple.back.game.repository;

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 kr.pickple.back.address.domain.AddressDepth1;
import kr.pickple.back.address.domain.AddressDepth2;
import kr.pickple.back.chat.domain.ChatRoom;
import kr.pickple.back.game.domain.Game;
import kr.pickple.back.game.domain.GameStatus;

public interface GameRepository extends JpaRepository<Game, Long>, GameSearchRepository {

Expand All @@ -20,4 +24,10 @@ Page<Game> findByAddressDepth1AndAddressDepth2(
);

Optional<Game> findByChatRoom(final ChatRoom chatRoom);

@Query("SELECT g FROM Game g WHERE g.status = :status AND CONCAT(g.playDate, ' ', g.playStartTime) <= DATE_FORMAT(:nowDateTime, '%Y-%m-%d %H:%i:%s')")
List<Game> findGamesByStatusAndPlayDateStartTimeBeforeNow(final GameStatus status, final LocalDateTime nowDateTime);

@Query("SELECT g FROM Game g WHERE g.status = :status AND CONCAT(g.playDate, ' ', g.playEndTime) <= DATE_FORMAT(:nowDateTime, '%Y-%m-%d %H:%i:%s')")
List<Game> findGamesByStatusAndPlayDateEndTimeBeforeNow(final GameStatus status, final LocalDateTime nowDateTime);
}

0 comments on commit ae8c56a

Please sign in to comment.