feat: 添加走棋记录和对局记录 Repository
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
package com.webgame.webgamebackend.repository;
|
||||||
|
|
||||||
|
import com.webgame.webgamebackend.entities.GameMoveEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 走棋记录 Repository
|
||||||
|
*/
|
||||||
|
public interface GameMoveRepository extends JpaRepository<GameMoveEntity, String> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按房间 ID 查询走棋记录,按步序号升序
|
||||||
|
*
|
||||||
|
* @param roomId 房间 ID
|
||||||
|
* @return 走棋记录列表
|
||||||
|
*/
|
||||||
|
List<GameMoveEntity> findByRoomIdOrderByMoveIndexAsc(String roomId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计房间走棋步数
|
||||||
|
*
|
||||||
|
* @param roomId 房间 ID
|
||||||
|
* @return 步数
|
||||||
|
*/
|
||||||
|
int countByRoomId(String roomId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.webgame.webgamebackend.repository;
|
||||||
|
|
||||||
|
import com.webgame.webgamebackend.entities.GameRecordEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对局记录 Repository
|
||||||
|
*/
|
||||||
|
public interface GameRecordRepository extends JpaRepository<GameRecordEntity, String> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按房间 ID 查询对局记录
|
||||||
|
*
|
||||||
|
* @param roomId 房间 ID
|
||||||
|
* @return 对局记录(可能为空)
|
||||||
|
*/
|
||||||
|
Optional<GameRecordEntity> findByRoomId(String roomId);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user