one
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.web.controller.scoring;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -60,15 +61,33 @@ public class ScoreRoomController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取【请填写功能名称】详细信息
|
||||
* 获取【roomId】详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:room:query')")
|
||||
@GetMapping(value = "/{roomId}")
|
||||
@GetMapping(value = "/id/{roomId}")
|
||||
public AjaxResult getInfo(@PathVariable("roomId") Long roomId)
|
||||
{
|
||||
return success(scoreRoomService.selectScoreRoomByRoomId(roomId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取【createUser】详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:room:query1')")
|
||||
@GetMapping(value = "/createUser/{createUser}")
|
||||
public AjaxResult getByCreateUser(@PathVariable("createUser") Long createUser)
|
||||
{
|
||||
List<ScoreRoom> rooms = scoreRoomService.selectScoreRoomBycreateUser(createUser);
|
||||
if (rooms == null || rooms.isEmpty()) {
|
||||
return AjaxResult.success("无历史记录,创建新房间", Collections.emptyList());
|
||||
}
|
||||
|
||||
return AjaxResult.success(rooms);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*/
|
||||
|
||||
@@ -34,6 +34,20 @@ public class ScoreRoomUserController extends BaseController
|
||||
@Autowired
|
||||
private IScoreRoomUserService scoreRoomUserService;
|
||||
|
||||
/**
|
||||
* 获取房间内所有用户及其详细对局记录
|
||||
*/
|
||||
@GetMapping("/user-details/{roomId}")
|
||||
public AjaxResult getUserScoresWithDetails(@PathVariable("roomId") Long roomId) {
|
||||
try {
|
||||
List<ScoreRoomUser> result = scoreRoomUserService.getUserScoresWithDetails(roomId);
|
||||
return AjaxResult.success(result);
|
||||
} catch (Exception e) {
|
||||
logger.error("查询房间{}用户得分详情失败", roomId, e);
|
||||
return AjaxResult.error("查询失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*/
|
||||
@@ -62,13 +76,26 @@ public class ScoreRoomUserController extends BaseController
|
||||
/**
|
||||
* 获取【请填写功能名称】详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||
@GetMapping(value = "/{roomUserId}")
|
||||
public AjaxResult getInfo(@PathVariable("roomUserId") Long roomUserId)
|
||||
@PreAuthorize("@ss.hasPermi('system:user:query1')")
|
||||
@GetMapping(value = "/userid/{UserId}")
|
||||
public AjaxResult getInfo(@PathVariable("UserId") Long UserId)
|
||||
{
|
||||
return success(scoreRoomUserService.selectScoreRoomUserByRoomUserId(roomUserId));
|
||||
return success(scoreRoomUserService.selectScoreRoomUserByUserId(UserId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取【请填写功能名称】详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||
@GetMapping(value = "/RoomUserId/{RoomUserId}")
|
||||
public AjaxResult getInfo1(@PathVariable("RoomUserId") Long RoomUserId)
|
||||
{
|
||||
return success(scoreRoomUserService.selectScoreRoomUserByRoomUserId(RoomUserId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*/
|
||||
@@ -86,9 +113,15 @@ public class ScoreRoomUserController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ScoreRoomUser scoreRoomUser)
|
||||
public AjaxResult edit(@RequestBody List<ScoreRoomUser> scoreRoomUsers)
|
||||
{
|
||||
return toAjax(scoreRoomUserService.updateScoreRoomUser(scoreRoomUser));
|
||||
try {
|
||||
List<ScoreRoomUser> result = scoreRoomUserService.updateScoreRoomUser(scoreRoomUsers);
|
||||
return AjaxResult.success("得分提交成功!", result);
|
||||
} catch (Exception e) {
|
||||
logger.error("得分提交失败: {}", e.getMessage());
|
||||
return AjaxResult.error("得分提交失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.ruoyi.web.controller.scoring;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.utils.SimpleResult;
|
||||
@@ -66,7 +68,7 @@ public class ScoreUserController extends BaseController
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||
@GetMapping(value = "/{userId}")
|
||||
public AjaxResult getInfo(@PathVariable("userId") Long userId)
|
||||
public AjaxResult getInfo(@PathVariable("userId") String userId)
|
||||
{
|
||||
return success(scoreUserService.selectScoreUserByUserId(userId));
|
||||
}
|
||||
@@ -76,10 +78,22 @@ public class ScoreUserController extends BaseController
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:add')")
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody ScoreUser scoreUser)
|
||||
{
|
||||
return toAjax(scoreUserService.insertScoreUser(scoreUser));
|
||||
try {
|
||||
ScoreUser newUser = scoreUserService.insertScoreUser(scoreUser);
|
||||
// 构建返回数据
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("userId", newUser.getUserId());
|
||||
data.put("nickName", newUser.getNickName());
|
||||
data.put("avatars", newUser.getAvatars());
|
||||
data.put("openId", newUser.getOpenId());
|
||||
return AjaxResult.success("用户添加成功", data);
|
||||
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("用户添加失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.11.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-webmvc</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -32,7 +32,10 @@ public class ScoreRoom extends BaseEntity
|
||||
|
||||
/** 房主id */
|
||||
@Excel(name = "房主id")
|
||||
private Long boosId;
|
||||
private Long bossId;
|
||||
|
||||
@Excel(name = "房间名称")
|
||||
private String roomName;
|
||||
|
||||
public void setRoomId(Long roomId)
|
||||
{
|
||||
@@ -74,14 +77,22 @@ public class ScoreRoom extends BaseEntity
|
||||
return roomStatus;
|
||||
}
|
||||
|
||||
public void setBoosId(Long boosId)
|
||||
public void setBossId(Long bossId)
|
||||
{
|
||||
this.boosId = boosId;
|
||||
this.bossId = bossId;
|
||||
}
|
||||
|
||||
public Long getBoosId()
|
||||
public Long getBossId()
|
||||
{
|
||||
return boosId;
|
||||
return bossId;
|
||||
}
|
||||
|
||||
public String getRoomName() {
|
||||
return roomName;
|
||||
}
|
||||
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,7 +102,8 @@ public class ScoreRoom extends BaseEntity
|
||||
.append("createUser", getCreateUser())
|
||||
.append("odds", getOdds())
|
||||
.append("roomStatus", getRoomStatus())
|
||||
.append("boosId", getBoosId())
|
||||
.append("roomName", getRoomName())
|
||||
.append("bossId", getBossId())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ScoreRoomDetail extends BaseEntity
|
||||
|
||||
/** 详情分数 */
|
||||
@Excel(name = "详情分数")
|
||||
private Long score;
|
||||
private Long detailScore;
|
||||
|
||||
/** 触发时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@@ -41,9 +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 Long getGameTime() {
|
||||
return gameTime;
|
||||
}
|
||||
|
||||
public void setGameTime(Long gameTime) {
|
||||
this.gameTime = gameTime;
|
||||
}
|
||||
|
||||
public void setDetailId(Long detailId)
|
||||
{
|
||||
@@ -75,16 +83,6 @@ public class ScoreRoomDetail extends BaseEntity
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setScore(Long score)
|
||||
{
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public Long getScore()
|
||||
{
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setCreatedTime(Date createdTime)
|
||||
{
|
||||
this.createdTime = createdTime;
|
||||
@@ -105,15 +103,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() {
|
||||
@@ -121,10 +110,18 @@ public class ScoreRoomDetail extends BaseEntity
|
||||
.append("detailId", getDetailId())
|
||||
.append("roomId", getRoomId())
|
||||
.append("userId", getUserId())
|
||||
.append("score", getScore())
|
||||
.append("detailScore", getDetailScore())
|
||||
.append("createdTime", getCreatedTime())
|
||||
.append("detailType", getDetailType())
|
||||
.append("getterId", getGetterId())
|
||||
.append("gameTime", getGameTime())
|
||||
.toString();
|
||||
}
|
||||
|
||||
public Long getDetailScore() {
|
||||
return detailScore;
|
||||
}
|
||||
|
||||
public void setDetailScore(Long detailScore) {
|
||||
this.detailScore = detailScore;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】对象 score_room_user
|
||||
*
|
||||
@@ -28,7 +30,7 @@ public class ScoreRoomUser extends BaseEntity
|
||||
|
||||
/** 得分 */
|
||||
@Excel(name = "得分")
|
||||
private Long score;
|
||||
private Long totalScore;
|
||||
|
||||
/** 三个值 {'user', 'boot', 'business'} */
|
||||
@Excel(name = "三个值 {'user', 'boot', 'business'}")
|
||||
@@ -42,6 +44,17 @@ public class ScoreRoomUser extends BaseEntity
|
||||
@Excel(name = "玩家头像")
|
||||
private String avatars;
|
||||
|
||||
// 详细对局记录
|
||||
private List<ScoreRoomDetail> details;
|
||||
|
||||
public List<ScoreRoomDetail> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
public void setDetails(List<ScoreRoomDetail> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public void setRoomUserId(Long roomUserId)
|
||||
{
|
||||
this.roomUserId = roomUserId;
|
||||
@@ -72,16 +85,6 @@ public class ScoreRoomUser extends BaseEntity
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setScore(Long score)
|
||||
{
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public Long getScore()
|
||||
{
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setPlayerType(String playerType)
|
||||
{
|
||||
this.playerType = playerType;
|
||||
@@ -118,10 +121,19 @@ public class ScoreRoomUser extends BaseEntity
|
||||
.append("roomUserId", getRoomUserId())
|
||||
.append("roomId", getRoomId())
|
||||
.append("userId", getUserId())
|
||||
.append("score", getScore())
|
||||
.append("totalScore", getTotalScore())
|
||||
.append("playerType", getPlayerType())
|
||||
.append("nickName", getNickName())
|
||||
.append("avatars", getAvatars())
|
||||
.append("details", getDetails())
|
||||
.toString();
|
||||
}
|
||||
|
||||
public Long getTotalScore() {
|
||||
return totalScore;
|
||||
}
|
||||
|
||||
public void setTotalScore(Long totalScore) {
|
||||
this.totalScore = totalScore;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ScoreUser extends BaseEntity
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 用户id */
|
||||
private Long userId;
|
||||
private String userId;
|
||||
|
||||
/** 微信id */
|
||||
@Excel(name = "微信id")
|
||||
@@ -30,12 +30,12 @@ public class ScoreUser extends BaseEntity
|
||||
@Excel(name = "用户头像")
|
||||
private String avatars;
|
||||
|
||||
public void setUserId(Long userId)
|
||||
public void setUserId(String userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId()
|
||||
public String getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
|
||||
@@ -58,4 +58,8 @@ public interface ScoreRoomMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteScoreRoomByRoomIds(Long[] roomIds);
|
||||
|
||||
|
||||
|
||||
public List<ScoreRoom> selectScoreRoomBycreateUser(Long createUser);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.ScoreRoomUser;
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Mapper接口
|
||||
@@ -19,6 +20,20 @@ public interface ScoreRoomUserMapper
|
||||
*/
|
||||
public ScoreRoomUser selectScoreRoomUserByRoomUserId(Long roomUserId);
|
||||
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param UserId 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
public ScoreRoomUser selectScoreRoomUserByUserId(Long UserId);
|
||||
|
||||
|
||||
|
||||
public ScoreRoomUser selectScoreRoomUserPrescore(@Param("userId") Long UserId, @Param("roomId")Long RoomId);
|
||||
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
@@ -27,6 +42,7 @@ public interface ScoreRoomUserMapper
|
||||
*/
|
||||
public List<ScoreRoomUser> selectScoreRoomUserList(ScoreRoomUser scoreRoomUser);
|
||||
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
@@ -35,13 +51,7 @@ public interface ScoreRoomUserMapper
|
||||
*/
|
||||
public int insertScoreRoomUser(ScoreRoomUser scoreRoomUser);
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param scoreRoomUser 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateScoreRoomUser(ScoreRoomUser scoreRoomUser);
|
||||
public List<ScoreRoomUser> updateScoreRoomUser(@Param("list") List<ScoreRoomUser> scoreRoomUser);
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】
|
||||
@@ -58,4 +68,10 @@ public interface ScoreRoomUserMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteScoreRoomUserByRoomUserIds(Long[] roomUserIds);
|
||||
|
||||
/**
|
||||
* 通过JOIN查询获取房间内所有用户及其详细对局记录
|
||||
*/
|
||||
public List<ScoreRoomUser> selectUserScoresWithDetails(Long roomId);
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public interface ScoreUserMapper
|
||||
* @param userId 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
public ScoreUser selectScoreUserByUserId(Long userId);
|
||||
public ScoreUser selectScoreUserByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
|
||||
@@ -58,4 +58,5 @@ public interface IScoreRoomService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteScoreRoomByRoomId(Long roomId);
|
||||
public List<ScoreRoom> selectScoreRoomBycreateUser(Long createUser);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.ScoreRoomUser;
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Service接口
|
||||
@@ -19,6 +20,16 @@ public interface IScoreRoomUserService
|
||||
*/
|
||||
public ScoreRoomUser selectScoreRoomUserByRoomUserId(Long roomUserId);
|
||||
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param UserId 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
public ScoreRoomUser selectScoreRoomUserByUserId(Long UserId);
|
||||
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
@@ -27,6 +38,13 @@ public interface IScoreRoomUserService
|
||||
*/
|
||||
public List<ScoreRoomUser> selectScoreRoomUserList(ScoreRoomUser scoreRoomUser);
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
* @param roomId 【请填写功能名称】
|
||||
* @return 【请填写功能名称】集合
|
||||
*/
|
||||
public List<ScoreRoomUser> getUserScoresWithDetails(Long roomId);
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
@@ -35,13 +53,8 @@ public interface IScoreRoomUserService
|
||||
*/
|
||||
public int insertScoreRoomUser(ScoreRoomUser scoreRoomUser);
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param scoreRoomUser 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateScoreRoomUser(ScoreRoomUser scoreRoomUser);
|
||||
|
||||
public List<ScoreRoomUser> updateScoreRoomUser(List<ScoreRoomUser> scoreRoomUsers);
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
|
||||
@@ -17,7 +17,7 @@ public interface IScoreUserService
|
||||
* @param userId 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
public ScoreUser selectScoreUserByUserId(Long userId);
|
||||
public ScoreUser selectScoreUserByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
@@ -33,8 +33,7 @@ public interface IScoreUserService
|
||||
* @param scoreUser 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertScoreUser(ScoreUser scoreUser);
|
||||
|
||||
public ScoreUser insertScoreUser(ScoreUser scoreUser);
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
|
||||
@@ -31,6 +31,18 @@ public class ScoreRoomServiceImpl implements IScoreRoomService
|
||||
return scoreRoomMapper.selectScoreRoomByRoomId(roomId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param createUser 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public List<ScoreRoom> selectScoreRoomBycreateUser(Long createUser)
|
||||
{
|
||||
return scoreRoomMapper.selectScoreRoomBycreateUser(createUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.mapper.ScoreRoomUserMapper;
|
||||
@@ -31,6 +35,20 @@ public class ScoreRoomUserServiceImpl implements IScoreRoomUserService
|
||||
return scoreRoomUserMapper.selectScoreRoomUserByRoomUserId(roomUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param UserId 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public ScoreRoomUser selectScoreRoomUserByUserId(Long UserId)
|
||||
{
|
||||
return scoreRoomUserMapper.selectScoreRoomUserByUserId(UserId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
@@ -43,6 +61,17 @@ public class ScoreRoomUserServiceImpl implements IScoreRoomUserService
|
||||
return scoreRoomUserMapper.selectScoreRoomUserList(scoreRoomUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
* @param roomId 【请填写功能名称】
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public List<ScoreRoomUser> getUserScoresWithDetails(Long roomId) {
|
||||
return scoreRoomUserMapper.selectUserScoresWithDetails(roomId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
@@ -55,16 +84,39 @@ public class ScoreRoomUserServiceImpl implements IScoreRoomUserService
|
||||
return scoreRoomUserMapper.insertScoreRoomUser(scoreRoomUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param scoreRoomUser 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int updateScoreRoomUser(ScoreRoomUser scoreRoomUser)
|
||||
public List<ScoreRoomUser> updateScoreRoomUser(List<ScoreRoomUser> scoreRoomUsers)
|
||||
{
|
||||
return scoreRoomUserMapper.updateScoreRoomUser(scoreRoomUser);
|
||||
List<ScoreRoomUser> updatedUsers = new ArrayList<>();
|
||||
|
||||
for (ScoreRoomUser playerScore: scoreRoomUsers){
|
||||
// 处理单个用户的得分累加
|
||||
ScoreRoomUser updatedUser = processUserScoreUpdate(playerScore);
|
||||
updatedUsers.add(updatedUser);
|
||||
}
|
||||
|
||||
return scoreRoomUserMapper.updateScoreRoomUser(updatedUsers);
|
||||
}
|
||||
|
||||
private ScoreRoomUser processUserScoreUpdate(ScoreRoomUser newScore) {
|
||||
ScoreRoomUser existingUser = scoreRoomUserMapper.selectScoreRoomUserPrescore(newScore.getUserId(), newScore.getRoomId());
|
||||
|
||||
Long newTotalScore;
|
||||
ScoreRoomUser userToUpdate;
|
||||
|
||||
// 2. 存在记录:历史总分 + 本次得分
|
||||
Long currentScore = existingUser.getTotalScore() != null ? existingUser.getTotalScore() : 0L;
|
||||
Long additionalScore = newScore.getTotalScore() != null ? newScore.getTotalScore() : 0L;
|
||||
|
||||
newTotalScore = currentScore + additionalScore;
|
||||
|
||||
// 使用现有记录进行更新
|
||||
userToUpdate = existingUser;
|
||||
userToUpdate.setTotalScore(newTotalScore);
|
||||
userToUpdate.setUpdateTime(new Date());
|
||||
|
||||
return userToUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ScoreUserServiceImpl implements IScoreUserService
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public ScoreUser selectScoreUserByUserId(Long userId)
|
||||
public ScoreUser selectScoreUserByUserId(String userId)
|
||||
{
|
||||
return scoreUserMapper.selectScoreUserByUserId(userId);
|
||||
}
|
||||
@@ -51,16 +51,23 @@ public class ScoreUserServiceImpl implements IScoreUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertScoreUser(ScoreUser scoreUser)
|
||||
public ScoreUser insertScoreUser(ScoreUser scoreUser)
|
||||
{
|
||||
// 判断当前openId是否已经有值了
|
||||
ScoreUser scoreUser1 = scoreUserMapper.selectScoreUserByOpenId(scoreUser.getOpenId());
|
||||
if(scoreUser1 != null) {
|
||||
return 1;
|
||||
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("用户插入失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,11 +9,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="createUser" column="create_user" />
|
||||
<result property="odds" column="odds" />
|
||||
<result property="roomStatus" column="room_status" />
|
||||
<result property="boosId" column="boos_id" />
|
||||
<result property="bossId" column="boss_id" />
|
||||
<result property="roomName" column="room_name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectScoreRoomVo">
|
||||
select room_id, create_user, odds, room_status, boos_id from score_room
|
||||
select room_id, create_user, odds, room_status, boss_id from score_room
|
||||
</sql>
|
||||
|
||||
<select id="selectScoreRoomList" parameterType="ScoreRoom" resultMap="ScoreRoomResult">
|
||||
@@ -22,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createUser != null "> and create_user = #{createUser}</if>
|
||||
<if test="odds != null "> and odds = #{odds}</if>
|
||||
<if test="roomStatus != null "> and room_status = #{roomStatus}</if>
|
||||
<if test="boosId != null "> and boos_id = #{boosId}</if>
|
||||
<if test="bossId != null "> and boss_id = #{bossId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@@ -31,19 +32,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where room_id = #{roomId}
|
||||
</select>
|
||||
|
||||
<select id="selectScoreRoomBycreateUser" parameterType="Long" resultMap="ScoreRoomResult">
|
||||
<include refid="selectScoreRoomVo"/>
|
||||
WHERE room_status IN (0, 1)
|
||||
AND create_user = #{createUser}
|
||||
</select>
|
||||
|
||||
<insert id="insertScoreRoom" parameterType="ScoreRoom" useGeneratedKeys="true" keyProperty="roomId">
|
||||
insert into score_room
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="createUser != null">create_user,</if>
|
||||
<if test="odds != null">odds,</if>
|
||||
<if test="roomStatus != null">room_status,</if>
|
||||
<if test="boosId != null">boos_id,</if>
|
||||
<if test="bossId != null">boss_id,</if>
|
||||
<if test="roomName != null">room_name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="createUser != null">#{createUser},</if>
|
||||
<if test="odds != null">#{odds},</if>
|
||||
<if test="roomStatus != null">#{roomStatus},</if>
|
||||
<if test="boosId != null">#{boosId},</if>
|
||||
<if test="bossId != null">#{bossId},</if>
|
||||
<if test="roomName != null">#{roomName},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -53,7 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createUser != null">create_user = #{createUser},</if>
|
||||
<if test="odds != null">odds = #{odds},</if>
|
||||
<if test="roomStatus != null">room_status = #{roomStatus},</if>
|
||||
<if test="boosId != null">boos_id = #{boosId},</if>
|
||||
<if test="bossId != null">boss_id = #{bossId},</if>
|
||||
</trim>
|
||||
where room_id = #{roomId}
|
||||
</update>
|
||||
|
||||
@@ -8,7 +8,7 @@ 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="totalScore" column="score" />
|
||||
<result property="playerType" column="player_type" />
|
||||
<result property="nickName" column="nick_name" />
|
||||
<result property="avatars" column="avatars" />
|
||||
@@ -23,49 +23,62 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<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="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>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectScoreRoomUserByRoomUserId" parameterType="Long" resultMap="ScoreRoomUserResult">
|
||||
<include refid="selectScoreRoomUserVo"/>
|
||||
where room_user_id = #{roomUserId}
|
||||
</select>
|
||||
|
||||
<select id="selectScoreRoomUserPrescore" resultMap="ScoreRoomUserResult">
|
||||
<include refid="selectScoreRoomUserVo"/>
|
||||
where room_id = #{roomId} and user_id = #{userId}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectScoreRoomUserByUserId" parameterType="Long" resultMap="ScoreRoomUserResult">
|
||||
<include refid="selectScoreRoomUserVo"/>
|
||||
where user_id = #{UserId}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<insert id="insertScoreRoomUser" parameterType="ScoreRoomUser" useGeneratedKeys="true" keyProperty="roomUserId">
|
||||
insert into score_room_user
|
||||
<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="totalScore != 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="totalScore != null">#{totalScore},</if>
|
||||
<if test="playerType != null">#{playerType},</if>
|
||||
<if test="nickName != null">#{nickName},</if>
|
||||
<if test="avatars != null">#{avatars},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateScoreRoomUser" parameterType="ScoreRoomUser">
|
||||
update score_room_user
|
||||
<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="playerType != null">player_type = #{playerType},</if>
|
||||
<if test="nickName != null">nick_name = #{nickName},</if>
|
||||
<if test="avatars != null">avatars = #{avatars},</if>
|
||||
</trim>
|
||||
where room_user_id = #{roomUserId}
|
||||
<update id="updateScoreRoomUser">
|
||||
<foreach collection="list" item="item" index="index" separator=";">
|
||||
update score_room_user
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="item.totalScore != null">score = #{item.totalScore},</if>
|
||||
<if test="item.playerType != null">player_type = #{item.playerType},</if>
|
||||
<if test="item.nickName != null">nick_name = #{item.nickName},</if>
|
||||
<if test="item.avatars != null">avatars = #{item.avatars},</if>
|
||||
</trim>
|
||||
where room_id = #{item.roomId} AND user_id = #{item.userId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteScoreRoomUserByRoomUserId" parameterType="Long">
|
||||
@@ -78,4 +91,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{roomUserId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<resultMap id="UserScoreDetailResultMap" type="ScoreRoomUser">
|
||||
<!-- 主用户信息映射 -->
|
||||
<id property="userId" column="user_id"/>
|
||||
<result property="nickName" column="nick_name"/>
|
||||
<result property="avatars" column="avatars"/>
|
||||
<result property="totalScore" column="score"/>
|
||||
<result property="roomId" column="room_id" />
|
||||
<!-- 详细对局记录映射 -->
|
||||
<collection property="details" ofType="ScoreRoomDetail">
|
||||
<result property="gameTime" column="game_time"/>
|
||||
<result property="detailScore" column="detail_score"/>
|
||||
<result property="createdTime" column="created_time"/>
|
||||
<result property="roomId" column="room_id" />
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectUserScoresWithDetails" parameterType="Long" resultMap="UserScoreDetailResultMap">
|
||||
SELECT
|
||||
sru.user_id,
|
||||
sru.room_id,
|
||||
sru.nick_name,
|
||||
sru.avatars,
|
||||
sru.score,
|
||||
srd.game_time,
|
||||
srd.detail_score,
|
||||
srd.created_time
|
||||
FROM score_room_user sru
|
||||
LEFT JOIN score_room_detail srd ON sru.room_id = srd.room_id AND sru.user_id = srd.user_id
|
||||
WHERE sru.room_id = #{roomId}
|
||||
ORDER BY srd.game_time
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectScoreUserByUserId" parameterType="Long" resultMap="ScoreUserResult">
|
||||
<select id="selectScoreUserByUserId" resultMap="ScoreUserResult">
|
||||
<include refid="selectScoreUserVo"/>
|
||||
where user_id = #{userId}
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user