This commit is contained in:
2025-12-09 10:54:56 +08:00
parent 46c975591b
commit e539acd414
20 changed files with 491 additions and 102 deletions

View File

@@ -41,13 +41,17 @@ public class ScoreRoomDetail extends BaseEntity
@Excel(name = "0 胜 1 负")
private Long detailType;
/** 目标玩家id 多人模式给分使用 */
@Excel(name = "目标玩家id 多人模式给分使用")
private Long getterId;
@Excel(name = "局次")
private Long gameTime;
public void setDetailId(Long detailId)
public void setGameTime(Long gameTime)
{
this.detailId = detailId;
this.gameTime = gameTime;
}
public Long getGameTime()
{
return gameTime;
}
public Long getDetailId()
@@ -104,17 +108,6 @@ public class ScoreRoomDetail extends BaseEntity
{
return detailType;
}
public void setGetterId(Long getterId)
{
this.getterId = getterId;
}
public Long getGetterId()
{
return getterId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -124,7 +117,6 @@ public class ScoreRoomDetail extends BaseEntity
.append("score", getScore())
.append("createdTime", getCreatedTime())
.append("detailType", getDetailType())
.append("getterId", getGetterId())
.toString();
}
}

View File

@@ -28,7 +28,7 @@ public class ScoreRoomUser extends BaseEntity
/** 得分 */
@Excel(name = "得分")
private Long score;
private Long allscore;
/** 三个值 {'user', 'boot', 'business'} */
@Excel(name = "三个值 {'user', 'boot', 'business'}")
@@ -42,6 +42,12 @@ public class ScoreRoomUser extends BaseEntity
@Excel(name = "玩家头像")
private String avatars;
@Excel(name="单局得分")
private Long score;
@Excel(name="局次")
private Long gameTime;
public void setRoomUserId(Long roomUserId)
{
this.roomUserId = roomUserId;
@@ -72,14 +78,14 @@ public class ScoreRoomUser extends BaseEntity
return userId;
}
public void setScore(Long score)
public void setAllscore(Long allscore)
{
this.score = score;
this.allscore = allscore;
}
public Long getScore()
public Long getAllscore()
{
return score;
return allscore;
}
public void setPlayerType(String playerType)
@@ -111,6 +117,28 @@ public class ScoreRoomUser extends BaseEntity
{
return avatars;
}
public void setScore(Long score)
{
this.score = score;
}
public Long getScore()
{
return score;
}
public void setGameTime(Long gameTime)
{
this.gameTime = gameTime;
}
public Long getGameTime()
{
return gameTime;
}
@Override
public String toString() {
@@ -118,10 +146,12 @@ public class ScoreRoomUser extends BaseEntity
.append("roomUserId", getRoomUserId())
.append("roomId", getRoomId())
.append("userId", getUserId())
.append("score", getScore())
.append("allscore", getAllscore())
.append("playerType", getPlayerType())
.append("nickName", getNickName())
.append("avatars", getAvatars())
.append("score", getScore())
.append("gameTime", getGameTime())
.toString();
}
}

View File

@@ -58,4 +58,12 @@ public interface ScoreRoomUserMapper
* @return 结果
*/
public int deleteScoreRoomUserByRoomUserIds(Long[] roomUserIds);
/**
* 查询所有【请填写功能名称】
*
* @param scoreRoomUser 【请填写功能名称】
* @return 【请填写功能名称】
*/
public List<ScoreRoomUser> selectAllScoreRoomUserList(ScoreRoomUser scoreRoomUser);
}

View File

@@ -27,6 +27,14 @@ public interface ScoreUserMapper
*/
public List<ScoreUser> selectScoreUserList(ScoreUser scoreUser);
/**
* 查询所有基础信息列表
*
* @param scoreUser 基础信息
* @return 基础信息集合
*/
public List<ScoreUser> selectAllScoreUserList(ScoreUser scoreUser);
/**
* 新增基础信息
*

View File

@@ -29,7 +29,7 @@ public interface IScoreRoomService
/**
* 新增房间信息
*
*
* @param scoreRoom 房间信息
* @return 结果
*/

View File

@@ -26,14 +26,21 @@ public interface IScoreRoomUserService
* @return 【请填写功能名称】集合
*/
public List<ScoreRoomUser> selectScoreRoomUserList(ScoreRoomUser scoreRoomUser);
/**
* 查询所有【请填写功能名称】
*
* @param scoreRoomUser 【请填写功能名称】
* @return 【请填写功能名称】
*/
public List<ScoreRoomUser> selectAllScoreRoomUserList(ScoreRoomUser scoreRoomUser);
/**
* 新增【请填写功能名称】
*
* @param scoreRoomUser 【请填写功能名称】
* @return 结果
* @return 【请填写功能名称】对象
*/
public int insertScoreRoomUser(ScoreRoomUser scoreRoomUser);
public ScoreRoomUser insertScoreRoomUser(ScoreRoomUser scoreRoomUser);
/**
* 修改【请填写功能名称】

View File

@@ -26,14 +26,21 @@ public interface IScoreUserService
* @return 基础信息集合
*/
public List<ScoreUser> selectScoreUserList(ScoreUser scoreUser);
/**
* 查询所有基础信息
*
* @param scoreUser 基础信息
* @return 基础信息集合
*/
public List<ScoreUser> selectAllScoreUserList(ScoreUser scoreUser);
/**
* 新增基础信息
*
*
* @param scoreUser 基础信息
* @return 结果
*/
public int insertScoreUser(ScoreUser scoreUser);
public ScoreUser insertScoreUser(ScoreUser scoreUser);
/**
* 修改基础信息
@@ -58,4 +65,5 @@ public interface IScoreUserService
* @return 结果
*/
public int deleteScoreUserByUserId(Long userId);
}

View File

@@ -4,7 +4,9 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ScoreRoomDetailMapper;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.ScoreRoomDetail;
import com.ruoyi.system.domain.ScoreUser;
import com.ruoyi.system.service.IScoreRoomDetailService;
/**

View File

@@ -4,6 +4,7 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ScoreRoomMapper;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.ScoreRoom;
import com.ruoyi.system.service.IScoreRoomService;
@@ -45,14 +46,25 @@ public class ScoreRoomServiceImpl implements IScoreRoomService
/**
* 新增房间信息
*
*
* @param scoreRoom 房间信息
* @return 结果
*/
@Override
public int insertScoreRoom(ScoreRoom scoreRoom)
{
return scoreRoomMapper.insertScoreRoom(scoreRoom);
// 设置创建时间
scoreRoom.setCreateTime(DateUtils.getNowDate());
// 插入房间信息MyBatis会自动将自增ID设置到scoreRoom对象的roomId属性中
int result = scoreRoomMapper.insertScoreRoom(scoreRoom);
if (result > 0) {
// 返回插入成功的行数
return result;
} else {
throw new RuntimeException("房间信息插入失败");
}
}
/**

View File

@@ -42,17 +42,29 @@ public class ScoreRoomUserServiceImpl implements IScoreRoomUserService
{
return scoreRoomUserMapper.selectScoreRoomUserList(scoreRoomUser);
}
/**
* 查询所有【请填写功能名称】
*
* @param scoreRoomUser 【请填写功能名称】
* @return 【请填写功能名称】
*/
@Override
public List<ScoreRoomUser> selectAllScoreRoomUserList(ScoreRoomUser scoreRoomUser)
{
return scoreRoomUserMapper.selectAllScoreRoomUserList(scoreRoomUser);
}
/**
* 新增【请填写功能名称】
*
* @param scoreRoomUser 【请填写功能名称】
* @return 结果
* @return 【请填写功能名称】对象
*/
@Override
public int insertScoreRoomUser(ScoreRoomUser scoreRoomUser)
public ScoreRoomUser insertScoreRoomUser(ScoreRoomUser scoreRoomUser)
{
return scoreRoomUserMapper.insertScoreRoomUser(scoreRoomUser);
scoreRoomUserMapper.insertScoreRoomUser(scoreRoomUser);
return scoreRoomUser;
}
/**

View File

@@ -17,6 +17,17 @@ import com.ruoyi.system.service.IScoreUserService;
@Service
public class ScoreUserServiceImpl implements IScoreUserService
{
/**
* 查询所有基础信息
*
* @param scoreUser 基础信息
* @return 基础信息集合
*/
@Override
public List<ScoreUser> selectAllScoreUserList(ScoreUser scoreUser)
{
return scoreUserMapper.selectAllScoreUserList(scoreUser);
}
@Autowired
private ScoreUserMapper scoreUserMapper;
@@ -46,15 +57,28 @@ public class ScoreUserServiceImpl implements IScoreUserService
/**
* 新增基础信息
*
*
* @param scoreUser 基础信息
* @return 结果
*/
@Override
public int insertScoreUser(ScoreUser scoreUser)
public ScoreUser insertScoreUser(ScoreUser scoreUser)
{
// 判断当前openId是否已经有值了
ScoreUser scoreUser1 = scoreUserMapper.selectScoreUserByUserId(scoreUser.getUserId());
if(scoreUser1 != null) {
throw new RuntimeException("当前openId是否已经有值");
}
scoreUser.setCreateTime(DateUtils.getNowDate());
return scoreUserMapper.insertScoreUser(scoreUser);
// 插入用户MyBatis会自动将自增ID设置到user对象的userId属性中
int result = scoreUserMapper.insertScoreUser(scoreUser);
if (result > 0) {
// 返回包含自增ID的用户对象
return scoreUser;
} else {
throw new RuntimeException("用户插入失败");
}
}
/**

View File

@@ -11,11 +11,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="score" column="score" />
<result property="createdTime" column="created_time" />
<result property="detailType" column="detail_type" />
<result property="getterId" column="getter_id" />
<result property="gameTime" column="game_time" />
</resultMap>
<sql id="selectScoreRoomDetailVo">
select detail_id, room_id, user_id, score, created_time, detail_type, getter_id from score_room_detail
select detail_id, room_id, user_id, score, created_time, detail_type, game_time from score_room_detail
</sql>
<select id="selectScoreRoomDetailList" parameterType="ScoreRoomDetail" resultMap="ScoreRoomDetailResult">
@@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="score != null "> and score = #{score}</if>
<if test="createdTime != null "> and created_time = #{createdTime}</if>
<if test="detailType != null "> and detail_type = #{detailType}</if>
<if test="getterId != null "> and getter_id = #{getterId}</if>
<if test="gameTime != null "> and game_time = #{gameTime}</if>
</where>
</select>
@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="score != null">score,</if>
<if test="createdTime != null">created_time,</if>
<if test="detailType != null">detail_type,</if>
<if test="getterId != null">getter_id,</if>
<if test="gameTime != null">game_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="roomId != null">#{roomId},</if>
@@ -51,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="score != null">#{score},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="detailType != null">#{detailType},</if>
<if test="getterId != null">#{getterId},</if>
<if test="gameTime != null">#{gameTime},</if>
</trim>
</insert>
@@ -63,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="score != null">score = #{score},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="detailType != null">detail_type = #{detailType},</if>
<if test="getterId != null">getter_id = #{getterId},</if>
<if test="gameTime != null">game_time = #{gameTime},</if>
</trim>
where detail_id = #{detailId}
</update>
@@ -80,10 +80,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<insert id="batchInsertScoreRoomDetail" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="detailId">
insert into score_room_detail (room_id, user_id, score, created_time, detail_type, getter_id)
insert into score_room_detail (room_id, user_id, score, created_time, detail_type, game_time)
values
<foreach item="detail" collection="list" separator=",">
(#{detail.roomId}, #{detail.userId}, #{detail.score}, #{detail.createdTime}, #{detail.detailType}, #{detail.getterId})
(#{detail.roomId}, #{detail.userId}, #{detail.score}, #{detail.createdTime}, #{detail.detailType}, #{detail.gameTime})
</foreach>
</insert>
</mapper>

View File

@@ -8,22 +8,64 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="roomUserId" column="room_user_id" />
<result property="roomId" column="room_id" />
<result property="userId" column="user_id" />
<result property="score" column="score" />
<result property="allscore" column="score" />
<result property="playerType" column="player_type" />
<result property="nickName" column="nick_name" />
<result property="avatars" column="avatars" />
</resultMap>
<resultMap type="ScoreRoomUser" id="ScoreRoomUserAllResult">
<result property="roomUserId" column="room_user_id" />
<result property="roomId" column="room_id" />
<result property="userId" column="user_id" />
<result property="allscore" column="allscore" />
<result property="score" column="detail_score" />
<result property="playerType" column="player_type" />
<result property="nickName" column="nick_name" />
<result property="avatars" column="avatars" />
<result property="gameTime" column="game_time" />
</resultMap>
<sql id="selectAllScoreRoomUserVo">
SELECT
ru.room_user_id,
ru.room_id,
ru.user_id,
ru.score AS allscore,
ru.player_type,
ru.nick_name,
ru.avatars,
rd.game_time,
rd.score AS detail_score,
rd.detail_id
FROM score_room_user ru
JOIN score_room_detail rd ON ru.user_id = rd.user_id
</sql>
<sql id="selectScoreRoomUserVo">
select room_user_id, room_id, user_id, score, player_type, nick_name, avatars from score_room_user
</sql>
<select id="selectAllScoreRoomUserList" parameterType="scoreRoomUser" resultMap="ScoreRoomUserAllResult">
<include refid="selectAllScoreRoomUserVo"/>
<where>
<!-- 条件指定表别名,避免字段歧义 -->
<if test="roomId != null "> and ru.room_id = #{roomId}</if>
<if test="userId != null "> and ru.user_id = #{userId}</if>
<if test="allscore != null "> and ru.score = #{allscore}</if>
<if test="playerType != null and playerType != ''"> and ru.player_type = #{playerType}</if>
<if test="nickName != null and nickName != ''"> and ru.nick_name like concat('%', #{nickName}, '%')</if>
<if test="avatars != null and avatars != ''"> and ru.avatars = #{avatars}</if>
<if test="gameTime != null "> and rd.game_time = #{gameTime}</if> <!-- 去掉!= ''int类型无空字符串 -->
<if test="score != null "> and rd.score = #{score}</if> <!-- 对应详情表的score -->
</where>
</select>
<select id="selectScoreRoomUserList" parameterType="ScoreRoomUser" resultMap="ScoreRoomUserResult">
<include refid="selectScoreRoomUserVo"/>
<where>
<if test="roomId != null "> and room_id = #{roomId}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="score != null "> and score = #{score}</if>
<if test="allscore != null "> and score = #{allscore}</if>
<if test="playerType != null and playerType != ''"> and player_type = #{playerType}</if>
<if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
<if test="avatars != null and avatars != ''"> and avatars = #{avatars}</if>
@@ -40,19 +82,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="roomId != null">room_id,</if>
<if test="userId != null">user_id,</if>
<if test="score != null">score,</if>
<if test="allscore != null">score,</if>
<if test="playerType != null">player_type,</if>
<if test="nickName != null">nick_name,</if>
<if test="avatars != null">avatars,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="roomId != null">#{roomId},</if>
<if test="userId != null">#{userId},</if>
<if test="score != null">#{score},</if>
<if test="allscore != null">#{allscore},</if>
<if test="playerType != null">#{playerType},</if>
<if test="nickName != null">#{nickName},</if>
<if test="avatars != null">#{avatars},</if>
</trim>
</trim>
</insert>
<update id="updateScoreRoomUser" parameterType="ScoreRoomUser">
@@ -60,7 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=",">
<if test="roomId != null">room_id = #{roomId},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="score != null">score = #{score},</if>
<if test="allscore != null">score = #{allscore},</if>
<if test="playerType != null">player_type = #{playerType},</if>
<if test="nickName != null">nick_name = #{nickName},</if>
<if test="avatars != null">avatars = #{avatars},</if>

View File

@@ -26,6 +26,15 @@
</where>
</select>
<select id="selectAllScoreUserList" parameterType="ScoreUser" resultMap="ScoreUserResult">
<include refid="selectScoreUserVo"/>
<where>
<if test="openId != null and openId != ''"> and open_id = #{openId}</if>
<if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
</where>
</select>
<select id="selectScoreUserByUserId" parameterType="Long" resultMap="ScoreUserResult">
<include refid="selectScoreUserVo"/>
where user_id = #{userId}