feat: 添加走棋记录和对局记录 Repository

This commit is contained in:
2026-06-23 11:01:40 +08:00
parent 05520a2b1d
commit e72fbff6e6
2 changed files with 48 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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);
}