111
This commit is contained in:
1
RuoYi-Vue/.github/FUNDING.yml
vendored
1
RuoYi-Vue/.github/FUNDING.yml
vendored
@@ -1 +0,0 @@
|
|||||||
custom: http://doc.ruoyi.vip/ruoyi-vue/other/donate.html
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.web.controller.scoring;
|
package com.ruoyi.web.controller.scoring;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@@ -60,15 +61,32 @@ public class ScoreRoomController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取【请填写功能名称】详细信息
|
* 获取【roomId】详细信息
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:room:query')")
|
@PreAuthorize("@ss.hasPermi('system:room:query')")
|
||||||
@GetMapping(value = "/{roomId}")
|
@GetMapping(value = "/id/{roomId}")
|
||||||
public AjaxResult getInfo(@PathVariable("roomId") Long roomId)
|
public AjaxResult getInfo(@PathVariable("roomId") Long roomId)
|
||||||
{
|
{
|
||||||
return success(scoreRoomService.selectScoreRoomByRoomId(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增【请填写功能名称】
|
* 新增【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -75,9 +75,9 @@ public class ScoreRoomDetailController extends BaseController
|
|||||||
@PreAuthorize("@ss.hasPermi('system:detail:add')")
|
@PreAuthorize("@ss.hasPermi('system:detail:add')")
|
||||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody ScoreRoomDetail scoreRoomDetail)
|
public AjaxResult add(@RequestBody List<ScoreRoomDetail> scoreRoomDetails)
|
||||||
{
|
{
|
||||||
return toAjax(scoreRoomDetailService.insertScoreRoomDetail(scoreRoomDetail));
|
return toAjax(scoreRoomDetailService.insertScoreRoomDetail(scoreRoomDetails));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -34,6 +34,20 @@ public class ScoreRoomUserController extends BaseController
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IScoreRoomUserService scoreRoomUserService;
|
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')")
|
@PreAuthorize("@ss.hasPermi('system:user:query1')")
|
||||||
@GetMapping(value = "/{roomUserId}")
|
@GetMapping(value = "/userid/{UserId}")
|
||||||
public AjaxResult getInfo(@PathVariable("roomUserId") Long roomUserId)
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增【请填写功能名称】
|
* 新增【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
@@ -83,12 +110,18 @@ public class ScoreRoomUserController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* 修改【请填写功能名称】
|
* 修改【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
@PreAuthorize("@ss.hasPermi('system:user:edit1')")
|
||||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
|
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody ScoreRoomUser scoreRoomUser)
|
public AjaxResult edit(@RequestBody List<ScoreRoomUser> scoreRoomUsers)
|
||||||
{
|
{
|
||||||
return toAjax(scoreRoomUserService.updateScoreRoomUser(scoreRoomUser));
|
try {
|
||||||
|
int result = scoreRoomUserService.updateScoreRoomUser(scoreRoomUsers);
|
||||||
|
return AjaxResult.success("得分提交成功!", result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("得分提交成功: {}", e.getMessage());
|
||||||
|
return AjaxResult.error("得分提交成功: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +129,7 @@ public class ScoreRoomUserController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:remove')")
|
@PreAuthorize("@ss.hasPermi('system:user:remove')")
|
||||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
|
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{roomUserIds}")
|
@DeleteMapping("/{roomUserIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] roomUserIds)
|
public AjaxResult remove(@PathVariable Long[] roomUserIds)
|
||||||
{
|
{
|
||||||
return toAjax(scoreRoomUserService.deleteScoreRoomUserByRoomUserIds(roomUserIds));
|
return toAjax(scoreRoomUserService.deleteScoreRoomUserByRoomUserIds(roomUserIds));
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.web.controller.scoring;
|
package com.ruoyi.web.controller.scoring;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.ruoyi.utils.SimpleResult;
|
import com.ruoyi.utils.SimpleResult;
|
||||||
@@ -66,7 +68,7 @@ public class ScoreUserController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
@PreAuthorize("@ss.hasPermi('system:user:query')")
|
||||||
@GetMapping(value = "/{userId}")
|
@GetMapping(value = "/{userId}")
|
||||||
public AjaxResult getInfo(@PathVariable("userId") Long userId)
|
public AjaxResult getInfo(@PathVariable("userId") String userId)
|
||||||
{
|
{
|
||||||
return success(scoreUserService.selectScoreUserByUserId(userId));
|
return success(scoreUserService.selectScoreUserByUserId(userId));
|
||||||
}
|
}
|
||||||
@@ -79,7 +81,19 @@ public class ScoreUserController extends BaseController
|
|||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody ScoreUser scoreUser)
|
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>
|
<artifactId>okhttp</artifactId>
|
||||||
<version>4.11.0</version>
|
<version>4.11.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-webmvc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ public class ScoreRoom extends BaseEntity
|
|||||||
|
|
||||||
/** 房主id */
|
/** 房主id */
|
||||||
@Excel(name = "房主id")
|
@Excel(name = "房主id")
|
||||||
private Long boosId;
|
private Long bossId;
|
||||||
|
|
||||||
|
@Excel(name = "房间名称")
|
||||||
|
private String roomName;
|
||||||
|
|
||||||
public void setRoomId(Long roomId)
|
public void setRoomId(Long roomId)
|
||||||
{
|
{
|
||||||
@@ -74,14 +77,22 @@ public class ScoreRoom extends BaseEntity
|
|||||||
return roomStatus;
|
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
|
@Override
|
||||||
@@ -91,7 +102,8 @@ public class ScoreRoom extends BaseEntity
|
|||||||
.append("createUser", getCreateUser())
|
.append("createUser", getCreateUser())
|
||||||
.append("odds", getOdds())
|
.append("odds", getOdds())
|
||||||
.append("roomStatus", getRoomStatus())
|
.append("roomStatus", getRoomStatus())
|
||||||
.append("boosId", getBoosId())
|
.append("roomName", getRoomName())
|
||||||
|
.append("bossId", getBossId())
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class ScoreRoomDetail extends BaseEntity
|
|||||||
|
|
||||||
/** 详情分数 */
|
/** 详情分数 */
|
||||||
@Excel(name = "详情分数")
|
@Excel(name = "详情分数")
|
||||||
private Long score;
|
private Long detailScore;
|
||||||
|
|
||||||
/** 触发时间 */
|
/** 触发时间 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@@ -41,9 +41,17 @@ public class ScoreRoomDetail extends BaseEntity
|
|||||||
@Excel(name = "0 胜 1 负")
|
@Excel(name = "0 胜 1 负")
|
||||||
private Long detailType;
|
private Long detailType;
|
||||||
|
|
||||||
/** 目标玩家id 多人模式给分使用 */
|
/** 局次 */
|
||||||
@Excel(name = "目标玩家id 多人模式给分使用")
|
@Excel(name = "局次")
|
||||||
private Long getterId;
|
private Long gameTime;
|
||||||
|
|
||||||
|
public Long getGameTime() {
|
||||||
|
return gameTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGameTime(Long gameTime) {
|
||||||
|
this.gameTime = gameTime;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDetailId(Long detailId)
|
public void setDetailId(Long detailId)
|
||||||
{
|
{
|
||||||
@@ -75,16 +83,6 @@ public class ScoreRoomDetail extends BaseEntity
|
|||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScore(Long score)
|
|
||||||
{
|
|
||||||
this.score = score;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getScore()
|
|
||||||
{
|
|
||||||
return score;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreatedTime(Date createdTime)
|
public void setCreatedTime(Date createdTime)
|
||||||
{
|
{
|
||||||
this.createdTime = createdTime;
|
this.createdTime = createdTime;
|
||||||
@@ -105,15 +103,6 @@ public class ScoreRoomDetail extends BaseEntity
|
|||||||
return detailType;
|
return detailType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGetterId(Long getterId)
|
|
||||||
{
|
|
||||||
this.getterId = getterId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getGetterId()
|
|
||||||
{
|
|
||||||
return getterId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@@ -121,10 +110,18 @@ public class ScoreRoomDetail extends BaseEntity
|
|||||||
.append("detailId", getDetailId())
|
.append("detailId", getDetailId())
|
||||||
.append("roomId", getRoomId())
|
.append("roomId", getRoomId())
|
||||||
.append("userId", getUserId())
|
.append("userId", getUserId())
|
||||||
.append("score", getScore())
|
.append("detailScore", getDetailScore())
|
||||||
.append("createdTime", getCreatedTime())
|
.append("createdTime", getCreatedTime())
|
||||||
.append("detailType", getDetailType())
|
.append("detailType", getDetailType())
|
||||||
.append("getterId", getGetterId())
|
.append("gameTime", getGameTime())
|
||||||
.toString();
|
.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.annotation.Excel;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【请填写功能名称】对象 score_room_user
|
* 【请填写功能名称】对象 score_room_user
|
||||||
*
|
*
|
||||||
@@ -28,7 +30,7 @@ public class ScoreRoomUser extends BaseEntity
|
|||||||
|
|
||||||
/** 得分 */
|
/** 得分 */
|
||||||
@Excel(name = "得分")
|
@Excel(name = "得分")
|
||||||
private Long score;
|
private Long totalScore;
|
||||||
|
|
||||||
/** 三个值 {'user', 'boot', 'business'} */
|
/** 三个值 {'user', 'boot', 'business'} */
|
||||||
@Excel(name = "三个值 {'user', 'boot', 'business'}")
|
@Excel(name = "三个值 {'user', 'boot', 'business'}")
|
||||||
@@ -42,6 +44,17 @@ public class ScoreRoomUser extends BaseEntity
|
|||||||
@Excel(name = "玩家头像")
|
@Excel(name = "玩家头像")
|
||||||
private String avatars;
|
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)
|
public void setRoomUserId(Long roomUserId)
|
||||||
{
|
{
|
||||||
this.roomUserId = roomUserId;
|
this.roomUserId = roomUserId;
|
||||||
@@ -72,16 +85,6 @@ public class ScoreRoomUser extends BaseEntity
|
|||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScore(Long score)
|
|
||||||
{
|
|
||||||
this.score = score;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getScore()
|
|
||||||
{
|
|
||||||
return score;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayerType(String playerType)
|
public void setPlayerType(String playerType)
|
||||||
{
|
{
|
||||||
this.playerType = playerType;
|
this.playerType = playerType;
|
||||||
@@ -118,10 +121,19 @@ public class ScoreRoomUser extends BaseEntity
|
|||||||
.append("roomUserId", getRoomUserId())
|
.append("roomUserId", getRoomUserId())
|
||||||
.append("roomId", getRoomId())
|
.append("roomId", getRoomId())
|
||||||
.append("userId", getUserId())
|
.append("userId", getUserId())
|
||||||
.append("score", getScore())
|
.append("totalScore", getTotalScore())
|
||||||
.append("playerType", getPlayerType())
|
.append("playerType", getPlayerType())
|
||||||
.append("nickName", getNickName())
|
.append("nickName", getNickName())
|
||||||
.append("avatars", getAvatars())
|
.append("avatars", getAvatars())
|
||||||
|
.append("details", getDetails())
|
||||||
.toString();
|
.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;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 用户id */
|
/** 用户id */
|
||||||
private Long userId;
|
private String userId;
|
||||||
|
|
||||||
/** 微信id */
|
/** 微信id */
|
||||||
@Excel(name = "微信id")
|
@Excel(name = "微信id")
|
||||||
@@ -30,12 +30,12 @@ public class ScoreUser extends BaseEntity
|
|||||||
@Excel(name = "用户头像")
|
@Excel(name = "用户头像")
|
||||||
private String avatars;
|
private String avatars;
|
||||||
|
|
||||||
public void setUserId(Long userId)
|
public void setUserId(String userId)
|
||||||
{
|
{
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getUserId()
|
public String getUserId()
|
||||||
{
|
{
|
||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.system.domain.ScoreRoomDetail;
|
import com.ruoyi.system.domain.ScoreRoomDetail;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【请填写功能名称】Mapper接口
|
* 【请填写功能名称】Mapper接口
|
||||||
@@ -30,10 +31,10 @@ public interface ScoreRoomDetailMapper
|
|||||||
/**
|
/**
|
||||||
* 新增【请填写功能名称】
|
* 新增【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param scoreRoomDetail 【请填写功能名称】
|
* @param scoreRoomDetails 【请填写功能名称】
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertScoreRoomDetail(ScoreRoomDetail scoreRoomDetail);
|
public int insertScoreRoomDetail(@Param("scoreRoomDetails") List<ScoreRoomDetail> scoreRoomDetails);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改【请填写功能名称】
|
* 修改【请填写功能名称】
|
||||||
|
|||||||
@@ -58,4 +58,8 @@ public interface ScoreRoomMapper
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteScoreRoomByRoomIds(Long[] roomIds);
|
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 java.util.List;
|
||||||
import com.ruoyi.system.domain.ScoreRoomUser;
|
import com.ruoyi.system.domain.ScoreRoomUser;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【请填写功能名称】Mapper接口
|
* 【请填写功能名称】Mapper接口
|
||||||
@@ -19,6 +20,20 @@ public interface ScoreRoomUserMapper
|
|||||||
*/
|
*/
|
||||||
public ScoreRoomUser selectScoreRoomUserByRoomUserId(Long roomUserId);
|
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);
|
public List<ScoreRoomUser> selectScoreRoomUserList(ScoreRoomUser scoreRoomUser);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增【请填写功能名称】
|
* 新增【请填写功能名称】
|
||||||
*
|
*
|
||||||
@@ -35,13 +51,7 @@ public interface ScoreRoomUserMapper
|
|||||||
*/
|
*/
|
||||||
public int insertScoreRoomUser(ScoreRoomUser scoreRoomUser);
|
public int insertScoreRoomUser(ScoreRoomUser scoreRoomUser);
|
||||||
|
|
||||||
/**
|
public int updateScoreRoomUser(@Param("scoreRoomUsers") List<ScoreRoomUser> scoreRoomUsers);
|
||||||
* 修改【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param scoreRoomUser 【请填写功能名称】
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int updateScoreRoomUser(ScoreRoomUser scoreRoomUser);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除【请填写功能名称】
|
* 删除【请填写功能名称】
|
||||||
@@ -58,4 +68,10 @@ public interface ScoreRoomUserMapper
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteScoreRoomUserByRoomUserIds(Long[] roomUserIds);
|
public int deleteScoreRoomUserByRoomUserIds(Long[] roomUserIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过JOIN查询获取房间内所有用户及其详细对局记录
|
||||||
|
*/
|
||||||
|
public List<ScoreRoomUser> selectUserScoresWithDetails(Long roomId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public interface ScoreUserMapper
|
|||||||
* @param userId 【请填写功能名称】主键
|
* @param userId 【请填写功能名称】主键
|
||||||
* @return 【请填写功能名称】
|
* @return 【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
public ScoreUser selectScoreUserByUserId(Long userId);
|
public ScoreUser selectScoreUserByUserId(String userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询【请填写功能名称】列表
|
* 查询【请填写功能名称】列表
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ public interface IScoreRoomDetailService
|
|||||||
/**
|
/**
|
||||||
* 新增【请填写功能名称】
|
* 新增【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param scoreRoomDetail 【请填写功能名称】
|
* @param scoreRoomDetails 【请填写功能名称】
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertScoreRoomDetail(ScoreRoomDetail scoreRoomDetail);
|
public int insertScoreRoomDetail(List<ScoreRoomDetail> scoreRoomDetails);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改【请填写功能名称】
|
* 修改【请填写功能名称】
|
||||||
|
|||||||
@@ -58,4 +58,5 @@ public interface IScoreRoomService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteScoreRoomByRoomId(Long roomId);
|
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 java.util.List;
|
||||||
import com.ruoyi.system.domain.ScoreRoomUser;
|
import com.ruoyi.system.domain.ScoreRoomUser;
|
||||||
|
import io.lettuce.core.dynamic.annotation.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【请填写功能名称】Service接口
|
* 【请填写功能名称】Service接口
|
||||||
@@ -19,6 +20,16 @@ public interface IScoreRoomUserService
|
|||||||
*/
|
*/
|
||||||
public ScoreRoomUser selectScoreRoomUserByRoomUserId(Long roomUserId);
|
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);
|
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);
|
public int insertScoreRoomUser(ScoreRoomUser scoreRoomUser);
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改【请填写功能名称】
|
public int updateScoreRoomUser(List<ScoreRoomUser> scoreRoomUsers);
|
||||||
*
|
|
||||||
* @param scoreRoomUser 【请填写功能名称】
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int updateScoreRoomUser(ScoreRoomUser scoreRoomUser);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除【请填写功能名称】
|
* 批量删除【请填写功能名称】
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public interface IScoreUserService
|
|||||||
* @param userId 【请填写功能名称】主键
|
* @param userId 【请填写功能名称】主键
|
||||||
* @return 【请填写功能名称】
|
* @return 【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
public ScoreUser selectScoreUserByUserId(Long userId);
|
public ScoreUser selectScoreUserByUserId(String userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询【请填写功能名称】列表
|
* 查询【请填写功能名称】列表
|
||||||
@@ -33,8 +33,7 @@ public interface IScoreUserService
|
|||||||
* @param scoreUser 【请填写功能名称】
|
* @param scoreUser 【请填写功能名称】
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertScoreUser(ScoreUser scoreUser);
|
public ScoreUser insertScoreUser(ScoreUser scoreUser);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改【请填写功能名称】
|
* 修改【请填写功能名称】
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -46,13 +46,13 @@ public class ScoreRoomDetailServiceImpl implements IScoreRoomDetailService
|
|||||||
/**
|
/**
|
||||||
* 新增【请填写功能名称】
|
* 新增【请填写功能名称】
|
||||||
*
|
*
|
||||||
* @param scoreRoomDetail 【请填写功能名称】
|
* @param scoreRoomDetails 【请填写功能名称】
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertScoreRoomDetail(ScoreRoomDetail scoreRoomDetail)
|
public int insertScoreRoomDetail(List<ScoreRoomDetail> scoreRoomDetails)
|
||||||
{
|
{
|
||||||
return scoreRoomDetailMapper.insertScoreRoomDetail(scoreRoomDetail);
|
return scoreRoomDetailMapper.insertScoreRoomDetail(scoreRoomDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,6 +31,18 @@ public class ScoreRoomServiceImpl implements IScoreRoomService
|
|||||||
return scoreRoomMapper.selectScoreRoomByRoomId(roomId);
|
return scoreRoomMapper.selectScoreRoomByRoomId(roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询【请填写功能名称】
|
||||||
|
*
|
||||||
|
* @param createUser 【请填写功能名称】主键
|
||||||
|
* @return 【请填写功能名称】
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ScoreRoom> selectScoreRoomBycreateUser(Long createUser)
|
||||||
|
{
|
||||||
|
return scoreRoomMapper.selectScoreRoomBycreateUser(createUser);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询【请填写功能名称】列表
|
* 查询【请填写功能名称】列表
|
||||||
*
|
*
|
||||||
@@ -52,6 +64,8 @@ public class ScoreRoomServiceImpl implements IScoreRoomService
|
|||||||
@Override
|
@Override
|
||||||
public int insertScoreRoom(ScoreRoom scoreRoom)
|
public int insertScoreRoom(ScoreRoom scoreRoom)
|
||||||
{
|
{
|
||||||
|
// List<ScoreRoom> newRoom = scoreRoomMapper.selectScoreRoomList(scoreRoom);
|
||||||
|
|
||||||
return scoreRoomMapper.insertScoreRoom(scoreRoom);
|
return scoreRoomMapper.insertScoreRoom(scoreRoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.lettuce.core.dynamic.annotation.Param;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.system.mapper.ScoreRoomUserMapper;
|
import com.ruoyi.system.mapper.ScoreRoomUserMapper;
|
||||||
@@ -31,6 +35,20 @@ public class ScoreRoomUserServiceImpl implements IScoreRoomUserService
|
|||||||
return scoreRoomUserMapper.selectScoreRoomUserByRoomUserId(roomUserId);
|
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);
|
return scoreRoomUserMapper.selectScoreRoomUserList(scoreRoomUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询【请填写功能名称】列表
|
||||||
|
*
|
||||||
|
* @param roomId 【请填写功能名称】
|
||||||
|
* @return 【请填写功能名称】
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ScoreRoomUser> getUserScoresWithDetails(Long roomId) {
|
||||||
|
return scoreRoomUserMapper.selectUserScoresWithDetails(roomId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增【请填写功能名称】
|
* 新增【请填写功能名称】
|
||||||
*
|
*
|
||||||
@@ -55,16 +84,53 @@ public class ScoreRoomUserServiceImpl implements IScoreRoomUserService
|
|||||||
return scoreRoomUserMapper.insertScoreRoomUser(scoreRoomUser);
|
return scoreRoomUserMapper.insertScoreRoomUser(scoreRoomUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改【请填写功能名称】
|
|
||||||
*
|
|
||||||
* @param scoreRoomUser 【请填写功能名称】
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int updateScoreRoomUser(ScoreRoomUser scoreRoomUser)
|
public int 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) {
|
||||||
|
// 1. 首先检查用户是否已在房间中
|
||||||
|
ScoreRoomUser existingUser = scoreRoomUserMapper.selectScoreRoomUserPrescore(newScore.getUserId(), newScore.getRoomId());
|
||||||
|
|
||||||
|
Long newTotalScore;
|
||||||
|
ScoreRoomUser userToUpdate;
|
||||||
|
|
||||||
|
if (existingUser == null) {
|
||||||
|
// 用户不在房间中,创建新记录
|
||||||
|
userToUpdate = new ScoreRoomUser();
|
||||||
|
userToUpdate.setRoomId(newScore.getRoomId());
|
||||||
|
userToUpdate.setUserId(newScore.getUserId());
|
||||||
|
userToUpdate.setPlayerType("user");
|
||||||
|
userToUpdate.setNickName(newScore.getNickName());
|
||||||
|
userToUpdate.setTotalScore(newScore.getTotalScore() != null ? newScore.getTotalScore() : 0L);
|
||||||
|
|
||||||
|
// 插入新记录
|
||||||
|
scoreRoomUserMapper.insertScoreRoomUser(userToUpdate);
|
||||||
|
return userToUpdate;
|
||||||
|
} else {
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
return userToUpdate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,4 +156,7 @@ public class ScoreRoomUserServiceImpl implements IScoreRoomUserService
|
|||||||
{
|
{
|
||||||
return scoreRoomUserMapper.deleteScoreRoomUserByRoomUserId(roomUserId);
|
return scoreRoomUserMapper.deleteScoreRoomUserByRoomUserId(roomUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class ScoreUserServiceImpl implements IScoreUserService
|
|||||||
* @return 【请填写功能名称】
|
* @return 【请填写功能名称】
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ScoreUser selectScoreUserByUserId(Long userId)
|
public ScoreUser selectScoreUserByUserId(String userId)
|
||||||
{
|
{
|
||||||
return scoreUserMapper.selectScoreUserByUserId(userId);
|
return scoreUserMapper.selectScoreUserByUserId(userId);
|
||||||
}
|
}
|
||||||
@@ -51,16 +51,23 @@ public class ScoreUserServiceImpl implements IScoreUserService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertScoreUser(ScoreUser scoreUser)
|
public ScoreUser insertScoreUser(ScoreUser scoreUser)
|
||||||
{
|
{
|
||||||
// 判断当前openId是否已经有值了
|
// 判断当前openId是否已经有值了
|
||||||
ScoreUser scoreUser1 = scoreUserMapper.selectScoreUserByOpenId(scoreUser.getOpenId());
|
ScoreUser scoreUser1 = scoreUserMapper.selectScoreUserByOpenId(scoreUser.getOpenId());
|
||||||
if(scoreUser1 != null) {
|
if(scoreUser1 != null) {
|
||||||
return 1;
|
throw new RuntimeException("当前openId是否已经有值");
|
||||||
}
|
}
|
||||||
|
|
||||||
scoreUser.setCreateTime(DateUtils.getNowDate());
|
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("用户插入失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -35,26 +35,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
where detail_id = #{detailId}
|
where detail_id = #{detailId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertScoreRoomDetail" parameterType="ScoreRoomDetail" useGeneratedKeys="true" keyProperty="detailId">
|
|
||||||
insert into score_room_detail
|
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<insert id="insertScoreRoomDetail" useGeneratedKeys="true" keyProperty="detailId">
|
||||||
<if test="roomId != null">room_id,</if>
|
INSERT INTO score_room_detail
|
||||||
<if test="userId != null">user_id,</if>
|
(room_id, user_id, detail_score, game_time, created_time, detail_type)
|
||||||
<if test="score != null">score,</if>
|
VALUES
|
||||||
<if test="createdTime != null">created_time,</if>
|
<foreach collection="scoreRoomDetails" item="item" separator=",">
|
||||||
<if test="detailType != null">detail_type,</if>
|
(
|
||||||
<if test="getterId != null">getter_id,</if>
|
#{item.roomId},
|
||||||
</trim>
|
#{item.userId},
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
#{item.detailScore},
|
||||||
<if test="roomId != null">#{roomId},</if>
|
#{item.gameTime},
|
||||||
<if test="userId != null">#{userId},</if>
|
NOW(),
|
||||||
<if test="score != null">#{score},</if>
|
0
|
||||||
<if test="createdTime != null">#{createdTime},</if>
|
)
|
||||||
<if test="detailType != null">#{detailType},</if>
|
</foreach>
|
||||||
<if test="getterId != null">#{getterId},</if>
|
|
||||||
</trim>
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
<update id="updateScoreRoomDetail" parameterType="ScoreRoomDetail">
|
<update id="updateScoreRoomDetail" parameterType="ScoreRoomDetail">
|
||||||
update score_room_detail
|
update score_room_detail
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="createUser" column="create_user" />
|
<result property="createUser" column="create_user" />
|
||||||
<result property="odds" column="odds" />
|
<result property="odds" column="odds" />
|
||||||
<result property="roomStatus" column="room_status" />
|
<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>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectScoreRoomVo">
|
<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>
|
</sql>
|
||||||
|
|
||||||
<select id="selectScoreRoomList" parameterType="ScoreRoom" resultMap="ScoreRoomResult">
|
<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="createUser != null "> and create_user = #{createUser}</if>
|
||||||
<if test="odds != null "> and odds = #{odds}</if>
|
<if test="odds != null "> and odds = #{odds}</if>
|
||||||
<if test="roomStatus != null "> and room_status = #{roomStatus}</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>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -31,19 +32,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
where room_id = #{roomId}
|
where room_id = #{roomId}
|
||||||
</select>
|
</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 id="insertScoreRoom" parameterType="ScoreRoom" useGeneratedKeys="true" keyProperty="roomId">
|
||||||
insert into score_room
|
insert into score_room
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="createUser != null">create_user,</if>
|
<if test="createUser != null">create_user,</if>
|
||||||
<if test="odds != null">odds,</if>
|
<if test="odds != null">odds,</if>
|
||||||
<if test="roomStatus != null">room_status,</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>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="createUser != null">#{createUser},</if>
|
<if test="createUser != null">#{createUser},</if>
|
||||||
<if test="odds != null">#{odds},</if>
|
<if test="odds != null">#{odds},</if>
|
||||||
<if test="roomStatus != null">#{roomStatus},</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>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -53,7 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="createUser != null">create_user = #{createUser},</if>
|
<if test="createUser != null">create_user = #{createUser},</if>
|
||||||
<if test="odds != null">odds = #{odds},</if>
|
<if test="odds != null">odds = #{odds},</if>
|
||||||
<if test="roomStatus != null">room_status = #{roomStatus},</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>
|
</trim>
|
||||||
where room_id = #{roomId}
|
where room_id = #{roomId}
|
||||||
</update>
|
</update>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="roomUserId" column="room_user_id" />
|
<result property="roomUserId" column="room_user_id" />
|
||||||
<result property="roomId" column="room_id" />
|
<result property="roomId" column="room_id" />
|
||||||
<result property="userId" column="user_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="playerType" column="player_type" />
|
||||||
<result property="nickName" column="nick_name" />
|
<result property="nickName" column="nick_name" />
|
||||||
<result property="avatars" column="avatars" />
|
<result property="avatars" column="avatars" />
|
||||||
@@ -23,49 +23,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<where>
|
<where>
|
||||||
<if test="roomId != null "> and room_id = #{roomId}</if>
|
<if test="roomId != null "> and room_id = #{roomId}</if>
|
||||||
<if test="userId != null "> and user_id = #{userId}</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="playerType != null and playerType != ''"> and player_type = #{playerType}</if>
|
||||||
<if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
|
<if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
|
||||||
<if test="avatars != null and avatars != ''"> and avatars = #{avatars}</if>
|
<if test="avatars != null and avatars != ''"> and avatars = #{avatars}</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectScoreRoomUserByRoomUserId" parameterType="Long" resultMap="ScoreRoomUserResult">
|
<select id="selectScoreRoomUserByRoomUserId" parameterType="Long" resultMap="ScoreRoomUserResult">
|
||||||
<include refid="selectScoreRoomUserVo"/>
|
<include refid="selectScoreRoomUserVo"/>
|
||||||
where room_user_id = #{roomUserId}
|
where room_user_id = #{roomUserId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectScoreRoomUserPrescore" resultMap="ScoreRoomUserResult">
|
||||||
|
select room_id, user_id, score from score_room_user
|
||||||
|
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 id="insertScoreRoomUser" parameterType="ScoreRoomUser" useGeneratedKeys="true" keyProperty="roomUserId">
|
||||||
insert into score_room_user
|
insert into score_room_user
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="roomId != null">room_id,</if>
|
<if test="roomId != null">room_id,</if>
|
||||||
<if test="userId != null">user_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="playerType != null">player_type,</if>
|
||||||
<if test="nickName != null">nick_name,</if>
|
<if test="nickName != null">nick_name,</if>
|
||||||
<if test="avatars != null">avatars,</if>
|
<if test="avatars != null">avatars,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="roomId != null">#{roomId},</if>
|
<if test="roomId != null">#{roomId},</if>
|
||||||
<if test="userId != null">#{userId},</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="playerType != null">#{playerType},</if>
|
||||||
<if test="nickName != null">#{nickName},</if>
|
<if test="nickName != null">#{nickName},</if>
|
||||||
<if test="avatars != null">#{avatars},</if>
|
<if test="avatars != null">#{avatars},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateScoreRoomUser" parameterType="ScoreRoomUser">
|
<update id="updateScoreRoomUser">
|
||||||
update score_room_user
|
UPDATE score_room_user
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
SET
|
||||||
<if test="roomId != null">room_id = #{roomId},</if>
|
score = CASE
|
||||||
<if test="userId != null">user_id = #{userId},</if>
|
<foreach collection="scoreRoomUsers" item="item">
|
||||||
<if test="score != null">score = #{score},</if>
|
WHEN room_id = #{item.roomId} AND user_id = #{item.userId} THEN #{item.totalScore}
|
||||||
<if test="playerType != null">player_type = #{playerType},</if>
|
</foreach>
|
||||||
<if test="nickName != null">nick_name = #{nickName},</if>
|
ELSE score
|
||||||
<if test="avatars != null">avatars = #{avatars},</if>
|
END
|
||||||
</trim>
|
<!-- 如果需要更新其他字段,可以继续添加类似的CASE WHEN结构 -->
|
||||||
where room_user_id = #{roomUserId}
|
WHERE (room_id, user_id) IN
|
||||||
|
<foreach collection="scoreRoomUsers" item="item" separator="," open="(" close=")">
|
||||||
|
(#{item.roomId}, #{item.userId})
|
||||||
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteScoreRoomUserByRoomUserId" parameterType="Long">
|
<delete id="deleteScoreRoomUserByRoomUserId" parameterType="Long">
|
||||||
@@ -78,4 +94,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
#{roomUserId}
|
#{roomUserId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</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>
|
</mapper>
|
||||||
@@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectScoreUserByUserId" parameterType="Long" resultMap="ScoreUserResult">
|
<select id="selectScoreUserByUserId" resultMap="ScoreUserResult">
|
||||||
<include refid="selectScoreUserVo"/>
|
<include refid="selectScoreUserVo"/>
|
||||||
where user_id = #{userId}
|
where user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -1,8 +1,55 @@
|
|||||||
import {GET} from '@/utils/request'
|
// api/room.js - 房间相关API
|
||||||
|
import { GET, POST, PUT, DELETE } from '@/utils/request'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 房间相关API
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
/**
|
||||||
|
* 根据房间ID查询房间
|
||||||
|
* @param {number} roomId 房间ID
|
||||||
|
*/
|
||||||
|
getRoomById(roomId) {
|
||||||
|
return GET(`/system/room/id/${roomId}`)
|
||||||
|
},
|
||||||
|
|
||||||
// 查询【请填写功能名称】详细
|
/**
|
||||||
export const getuser = (roomid) => {
|
* 根据创建者查询房间
|
||||||
return GET('/system/roomuser/list',roomid)
|
* @param {number} createUser 创建者ID
|
||||||
}
|
*/
|
||||||
|
getRoomsByCreateUser(createUser) {
|
||||||
|
return GET(`/system/room/createUser/${createUser}`)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询房间列表
|
||||||
|
* @param {Object} params 查询参数
|
||||||
|
*/
|
||||||
|
getRoomList(params) {
|
||||||
|
return GET('/system/room/list', params)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增房间
|
||||||
|
* @param {Object} roomData 房间数据
|
||||||
|
*/
|
||||||
|
addRoom(roomData) {
|
||||||
|
return POST('/system/room', roomData)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改房间
|
||||||
|
* @param {Object} roomData 房间数据
|
||||||
|
*/
|
||||||
|
updateRoom(roomData) {
|
||||||
|
return PUT('/system/room', roomData)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除房间
|
||||||
|
* @param {Array} roomIds 房间ID数组
|
||||||
|
*/
|
||||||
|
deleteRooms(roomIds) {
|
||||||
|
return DELETE(`/system/room/${roomIds}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
47
scoring/api/roomDetail.js
Normal file
47
scoring/api/roomDetail.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
// api/roomDetail.js - 房间详情相关API
|
||||||
|
import { GET, POST, PUT, DELETE } from '@/utils/request'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 房间详情相关API
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
/**
|
||||||
|
* 根据详情ID查询房间详情
|
||||||
|
* @param {number} detailId 详情ID
|
||||||
|
*/
|
||||||
|
getRoomDetailById(detailId) {
|
||||||
|
return GET(`/system/detail/${detailId}`)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询房间详情列表
|
||||||
|
* @param {Object} params 查询参数
|
||||||
|
*/
|
||||||
|
getRoomDetailList(params) {
|
||||||
|
return GET('/system/detail/list', params)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增房间详情
|
||||||
|
* @param {Array} roomDetails 房间详情数据数组
|
||||||
|
*/
|
||||||
|
addRoomDetails(roomDetails) {
|
||||||
|
return POST('/system/detail', roomDetails)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改房间详情
|
||||||
|
* @param {Object} roomDetail 房间详情数据
|
||||||
|
*/
|
||||||
|
updateRoomDetail(roomDetail) {
|
||||||
|
return PUT('/system/detail', roomDetail)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除房间详情
|
||||||
|
* @param {Array} detailIds 详情ID数组
|
||||||
|
*/
|
||||||
|
deleteRoomDetails(detailIds) {
|
||||||
|
return DELETE(`/system/detail/${detailIds}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
179
scoring/api/roomUser.js
Normal file
179
scoring/api/roomUser.js
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
// api/roomUser.js - 房间用户相关API
|
||||||
|
import { GET, POST, PUT, DELETE } from '@/utils/request'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 房间用户相关API
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
/**
|
||||||
|
* 获取房间内所有用户及其详细对局记录(已修复)
|
||||||
|
* @param {number} roomId 房间ID
|
||||||
|
*/
|
||||||
|
async getUserScoresWithDetails(roomId) {
|
||||||
|
try {
|
||||||
|
console.log('获取房间用户详情,房间ID:', roomId);
|
||||||
|
|
||||||
|
// 使用正确的API路径
|
||||||
|
const response = await GET(`/system/score/room/user/user-details/${roomId}`);
|
||||||
|
|
||||||
|
console.log('房间用户详情API响应:', response);
|
||||||
|
|
||||||
|
// 处理不同的响应格式
|
||||||
|
if (response.code === 200 || response.code === 0) {
|
||||||
|
return response.data;
|
||||||
|
} else if (response.success) {
|
||||||
|
return response.data;
|
||||||
|
} else {
|
||||||
|
// 如果接口返回错误,尝试使用列表接口
|
||||||
|
console.warn('主接口失败,尝试使用列表接口');
|
||||||
|
return await this.getRoomUserList({ roomId });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取房间用户详情失败:', error);
|
||||||
|
|
||||||
|
// 降级方案1:使用列表接口
|
||||||
|
try {
|
||||||
|
console.log('尝试使用列表接口作为降级方案');
|
||||||
|
const listResult = await this.getRoomUserList({ roomId });
|
||||||
|
if (listResult) {
|
||||||
|
return listResult;
|
||||||
|
}
|
||||||
|
} catch (listError) {
|
||||||
|
console.error('列表接口也失败:', listError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 降级方案2:返回空数据并提示
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据RoomUserId查询
|
||||||
|
* @param {number} roomUserId 房间用户ID
|
||||||
|
*/
|
||||||
|
async getRoomUserById(roomUserId) {
|
||||||
|
try {
|
||||||
|
const response = await GET(`/system/score/room/user/RoomUserId/${roomUserId}`);
|
||||||
|
return response.data || response;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取房间用户信息失败:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据UserId查询
|
||||||
|
* @param {number} userId 用户ID
|
||||||
|
*/
|
||||||
|
async getRoomUserByUserId(userId) {
|
||||||
|
try {
|
||||||
|
const response = await GET(`/system/score/room/user/userid/${userId}`);
|
||||||
|
return response.data || response;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('根据用户ID获取房间用户失败:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询房间用户列表
|
||||||
|
* @param {Object} params 查询参数
|
||||||
|
*/
|
||||||
|
async getRoomUserList(params) {
|
||||||
|
try {
|
||||||
|
console.log('获取房间用户列表,参数:', params);
|
||||||
|
const response = await GET('/system/score/room/user/list', params);
|
||||||
|
console.log('房间用户列表响应:', response);
|
||||||
|
return response.data || response;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取房间用户列表失败:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增房间用户
|
||||||
|
* @param {Object} roomUserData 房间用户数据
|
||||||
|
*/
|
||||||
|
async addRoomUser(roomUserData) {
|
||||||
|
try {
|
||||||
|
console.log('新增房间用户:', roomUserData);
|
||||||
|
const response = await POST('/system/score/room/user', roomUserData);
|
||||||
|
console.log('新增房间用户响应:', response);
|
||||||
|
return response.data || response;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('新增房间用户失败:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async updateRoomUsersSafe(roomUsers) {
|
||||||
|
try {
|
||||||
|
console.log('安全更新房间用户得分:', roomUsers);
|
||||||
|
|
||||||
|
// 过滤和转换数据
|
||||||
|
const safeUsers = roomUsers.map(user => {
|
||||||
|
let userId = user.userId;
|
||||||
|
|
||||||
|
// 确保userId在int范围内
|
||||||
|
if (userId > 2147483647 || userId < -2147483648) {
|
||||||
|
console.warn('用户ID超出范围,进行转换:', userId);
|
||||||
|
// 使用哈希值
|
||||||
|
const strId = userId.toString();
|
||||||
|
let hash = 0;
|
||||||
|
for (let i = 0; i < strId.length; i++) {
|
||||||
|
hash = ((hash << 5) - hash) + strId.charCodeAt(i);
|
||||||
|
hash = hash & hash;
|
||||||
|
}
|
||||||
|
userId = Math.abs(hash) % 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...user,
|
||||||
|
userId: userId
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await PUT('/system/score/room/user', safeUsers);
|
||||||
|
console.log('安全更新响应:', response);
|
||||||
|
return response.data || response;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('安全更新房间用户得分:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 批量更新用户得分
|
||||||
|
* @param {Array} roomUsers 房间用户数据数组
|
||||||
|
*/
|
||||||
|
async updateRoomUsers(roomUsers) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
console.log('更新房间用户得分:', roomUsers);
|
||||||
|
const response = await PUT('/system/score/room/user', roomUsers);
|
||||||
|
console.log('更新房间用户得分响应:', response);
|
||||||
|
return response.data || response;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('更新房间用户得分:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除房间用户
|
||||||
|
* @param {Array} roomUserIds 房间用户ID数组
|
||||||
|
*/
|
||||||
|
async deleteRoomUsers(roomUserIds) {
|
||||||
|
try {
|
||||||
|
const response = await DELETE(`/system/score/room/user/${roomUserIds}`);
|
||||||
|
return response.data || response;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('删除房间用户失败:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { GET, POST } from '@/utils/request.js'
|
import { GET, POST,PUT,DELETE } from '@/utils/request.js'
|
||||||
|
|
||||||
export const register = (userInfo) => {
|
export const register = (userInfo) => {
|
||||||
return POST('/system/score/user', userInfo);
|
return POST('/system/score/user', userInfo);
|
||||||
@@ -6,4 +6,60 @@ export const register = (userInfo) => {
|
|||||||
|
|
||||||
export const login = (userInfo) => {
|
export const login = (userInfo) => {
|
||||||
return POST('/system/score/user/login', userInfo);
|
return POST('/system/score/user/login', userInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户相关API
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询用户
|
||||||
|
* @param {string} userId 用户ID
|
||||||
|
*/
|
||||||
|
getUserById(userId) {
|
||||||
|
return GET(`/system/score/user/${userId}`)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户列表
|
||||||
|
* @param {Object} params 查询参数
|
||||||
|
*/
|
||||||
|
getUserList(params) {
|
||||||
|
return GET('/system/score/user/list', params)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户
|
||||||
|
* @param {Object} userData 用户数据
|
||||||
|
*/
|
||||||
|
addUser(userData) {
|
||||||
|
return POST('/system/score/user', userData)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户
|
||||||
|
* @param {Object} userData 用户数据
|
||||||
|
*/
|
||||||
|
updateUser(userData) {
|
||||||
|
return PUT('/system/score/user', userData)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除用户
|
||||||
|
* @param {Array} userIds 用户ID数组
|
||||||
|
*/
|
||||||
|
deleteUsers(userIds) {
|
||||||
|
return DELETE(`/system/score/user/${userIds}`)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户登录
|
||||||
|
* @param {Object} loginData 登录数据
|
||||||
|
*/
|
||||||
|
login(loginData) {
|
||||||
|
return POST('/system/score/user/login', loginData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"path": "pages/settle/index", // 结算页面(新增注册)
|
"path": "pages/settle/index",
|
||||||
"style": { "navigationBarTitleText": "房间结算" }
|
"style": { "navigationBarTitleText": "房间结算" }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,38 +11,80 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 玩家信息表头 -->
|
<!-- 玩家列表容器 - 添加滚动条功能 -->
|
||||||
<view class="player-header">
|
<view class="player-list-container">
|
||||||
<view class="header-row">
|
<!-- 水平滚动容器 -->
|
||||||
<view class="header-cell header-label">玩家 ({{ players.length }}位)</view>
|
<scroll-view
|
||||||
<view class="header-cell" v-for="player in players" :key="player.id">
|
class="player-scroll-view"
|
||||||
<view class="player-header-info">
|
scroll-x="true"
|
||||||
<image class="player-avatar" :src="player.avatar" mode="aspectFit"></image>
|
:scroll-left="scrollLeft"
|
||||||
<text class="player-name">{{ player.name }}</text>
|
@scroll="onScroll"
|
||||||
|
:show-scrollbar="false"
|
||||||
|
scroll-with-animation
|
||||||
|
>
|
||||||
|
<view class="player-list-content">
|
||||||
|
<!-- 玩家信息表头 -->
|
||||||
|
<view class="player-header">
|
||||||
|
<view class="header-row">
|
||||||
|
<view class="header-cell header-label">玩家 ({{ players.length }}位)</view>
|
||||||
|
<view class="player-columns">
|
||||||
|
<view class="player-column" v-for="player in players" :key="player.id">
|
||||||
|
<view class="player-header-info">
|
||||||
|
<!-- 统一头像容器样式 -->
|
||||||
|
<view class="avatar-container">
|
||||||
|
<image class="player-avatar" :src="player.avatar" mode="aspectFill"></image>
|
||||||
|
</view>
|
||||||
|
<text class="player-name">{{ player.name }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 对局详情表格 -->
|
||||||
|
<view class="detail-table">
|
||||||
|
<!-- 总分行 -->
|
||||||
|
<view class="table-row">
|
||||||
|
<view class="row-label">总分</view>
|
||||||
|
<view class="row-cells">
|
||||||
|
<view class="score-cell" v-for="player in players" :key="player.id">
|
||||||
|
{{ formatScore(player.totalScore) }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 每局得分行 -->
|
||||||
|
<view class="table-row" v-for="(round, roundIndex) in gameRounds" :key="roundIndex">
|
||||||
|
<view class="row-label">第{{ roundIndex + 1 }}局</view>
|
||||||
|
<view class="row-cells">
|
||||||
|
<view class="score-cell" v-for="player in players" :key="player.id">
|
||||||
|
{{ formatScore(getPlayerRoundScore(roundIndex, player.id)) }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</scroll-view>
|
||||||
</view>
|
|
||||||
|
<!-- 自定义可拖动滚动条 -->
|
||||||
<!-- 对局详情表格 -->
|
<view class="custom-scrollbar" v-if="showScrollIndicator">
|
||||||
<view class="detail-table">
|
<view
|
||||||
<!-- 总分行 -->
|
class="scroll-track"
|
||||||
<view class="table-row">
|
@touchstart="onTrackTouchStart"
|
||||||
<view class="row-label">总分</view>
|
@touchmove.prevent="onTrackTouchMove"
|
||||||
<view class="row-cells">
|
@touchend="onTrackTouchEnd"
|
||||||
<view class="score-cell" v-for="player in players" :key="player.id">
|
:id="trackId"
|
||||||
{{ formatScore(player.totalScore) }}
|
>
|
||||||
</view>
|
<view
|
||||||
</view>
|
class="scroll-thumb"
|
||||||
</view>
|
:style="{
|
||||||
|
left: thumbPosition + '%',
|
||||||
<!-- 每局得分行 -->
|
width: thumbWidth + '%'
|
||||||
<view class="table-row" v-for="(round, roundIndex) in gameRounds" :key="roundIndex">
|
}"
|
||||||
<view class="row-label">第{{ roundIndex + 1 }}局</view>
|
@touchstart="onThumbTouchStart"
|
||||||
<view class="row-cells">
|
@touchmove.prevent="onThumbTouchMove"
|
||||||
<view class="score-cell" v-for="player in players" :key="player.id">
|
@touchend="onThumbTouchEnd"
|
||||||
{{ formatScore(getPlayerRoundScore(roundIndex, player.id)) }}
|
></view>
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -55,13 +97,45 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted, computed, nextTick, watch } from 'vue'
|
||||||
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
|
|
||||||
// 玩家数据
|
// 玩家数据
|
||||||
const players = ref([])
|
const players = ref([])
|
||||||
// 对局记录
|
// 对局记录
|
||||||
const gameRounds = ref([])
|
const gameRounds = ref([])
|
||||||
|
|
||||||
|
// 滚动条相关数据
|
||||||
|
const scrollLeft = ref(0)
|
||||||
|
const scrollWidth = ref(0)
|
||||||
|
const scrollViewWidth = ref(0)
|
||||||
|
const trackId = ref('scroll-track-' + Date.now())
|
||||||
|
|
||||||
|
// 滚动条拖动状态
|
||||||
|
const isDragging = ref(false)
|
||||||
|
const dragStartX = ref(0)
|
||||||
|
const dragStartScrollLeft = ref(0)
|
||||||
|
const trackRect = ref({ left: 0, width: 0 })
|
||||||
|
|
||||||
|
// 计算属性:是否显示滚动条指示器
|
||||||
|
const showScrollIndicator = computed(() => {
|
||||||
|
return scrollWidth.value > scrollViewWidth.value
|
||||||
|
})
|
||||||
|
|
||||||
|
// 计算属性:滚动条滑块宽度
|
||||||
|
const thumbWidth = computed(() => {
|
||||||
|
if (scrollWidth.value === 0) return 100
|
||||||
|
const widthRatio = (scrollViewWidth.value / scrollWidth.value) * 100
|
||||||
|
return Math.max(20, Math.min(100, widthRatio)) // 最小宽度20%,最大100%
|
||||||
|
})
|
||||||
|
|
||||||
|
// 计算属性:滚动条滑块位置
|
||||||
|
const thumbPosition = computed(() => {
|
||||||
|
if (scrollWidth.value === 0 || scrollWidth.value <= scrollViewWidth.value) return 0
|
||||||
|
const maxScroll = scrollWidth.value - scrollViewWidth.value
|
||||||
|
return (scrollLeft.value / maxScroll) * (100 - thumbWidth.value)
|
||||||
|
})
|
||||||
|
|
||||||
// 格式化分数显示
|
// 格式化分数显示
|
||||||
const formatScore = (score) => {
|
const formatScore = (score) => {
|
||||||
if (score === 0) return '0'
|
if (score === 0) return '0'
|
||||||
@@ -128,9 +202,154 @@ onMounted(() => {
|
|||||||
]
|
]
|
||||||
calculateTotalScores()
|
calculateTotalScores()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 监听玩家数量变化
|
||||||
|
watch(() => players.value.length, () => {
|
||||||
|
setTimeout(() => {
|
||||||
|
updateScrollDimensions()
|
||||||
|
}, 300)
|
||||||
|
})
|
||||||
|
|
||||||
|
// 更新滚动区域尺寸
|
||||||
|
setTimeout(() => {
|
||||||
|
updateScrollDimensions()
|
||||||
|
}, 1000)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
// 更新滚动区域
|
||||||
|
setTimeout(() => {
|
||||||
|
updateScrollDimensions()
|
||||||
|
getTrackRect()
|
||||||
|
}, 300)
|
||||||
|
})
|
||||||
|
|
||||||
|
// 滚动事件处理
|
||||||
|
const onScroll = (e) => {
|
||||||
|
scrollLeft.value = e.detail.scrollLeft
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新滚动区域尺寸
|
||||||
|
const updateScrollDimensions = () => {
|
||||||
|
console.log('开始更新滚动区域尺寸...')
|
||||||
|
|
||||||
|
nextTick(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
const query = uni.createSelectorQuery()
|
||||||
|
query.select('.player-scroll-view').boundingClientRect()
|
||||||
|
query.select('.player-list-content').boundingClientRect()
|
||||||
|
query.exec((res) => {
|
||||||
|
if (res[0] && res[1]) {
|
||||||
|
scrollViewWidth.value = res[0].width
|
||||||
|
scrollWidth.value = res[1].width
|
||||||
|
|
||||||
|
console.log('滚动区域计算完成:', {
|
||||||
|
scrollViewWidth: scrollViewWidth.value,
|
||||||
|
scrollWidth: scrollWidth.value,
|
||||||
|
showScrollIndicator: scrollWidth.value > scrollViewWidth.value,
|
||||||
|
playersCount: players.value.length
|
||||||
|
})
|
||||||
|
|
||||||
|
// 强制更新显示状态
|
||||||
|
if (scrollWidth.value > scrollViewWidth.value) {
|
||||||
|
console.log('需要显示滚动条')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.error('获取滚动区域尺寸失败')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, 100)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取轨道位置信息
|
||||||
|
const getTrackRect = () => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
const query = uni.createSelectorQuery()
|
||||||
|
query.select('.custom-scrollbar .scroll-track').boundingClientRect()
|
||||||
|
query.exec((res) => {
|
||||||
|
if (res[0]) {
|
||||||
|
trackRect.value = {
|
||||||
|
left: res[0].left,
|
||||||
|
width: res[0].width
|
||||||
|
}
|
||||||
|
resolve(trackRect.value)
|
||||||
|
} else {
|
||||||
|
resolve(null)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, 100)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 滚动条滑块触摸开始
|
||||||
|
const onThumbTouchStart = async (e) => {
|
||||||
|
isDragging.value = true
|
||||||
|
dragStartX.value = e.touches[0].clientX
|
||||||
|
dragStartScrollLeft.value = scrollLeft.value
|
||||||
|
|
||||||
|
await getTrackRect()
|
||||||
|
|
||||||
|
e.stopPropagation()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 滚动条滑块触摸移动
|
||||||
|
const onThumbTouchMove = (e) => {
|
||||||
|
if (!isDragging.value) return
|
||||||
|
|
||||||
|
const deltaX = e.touches[0].clientX - dragStartX.value
|
||||||
|
const maxScroll = Math.max(0, scrollWidth.value - scrollViewWidth.value)
|
||||||
|
|
||||||
|
if (maxScroll > 0 && trackRect.value.width > 0) {
|
||||||
|
const scrollPercent = deltaX / trackRect.value.width
|
||||||
|
const newScrollLeft = dragStartScrollLeft.value + (scrollPercent * maxScroll)
|
||||||
|
scrollLeft.value = Math.max(0, Math.min(maxScroll, newScrollLeft))
|
||||||
|
}
|
||||||
|
|
||||||
|
e.stopPropagation()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 滚动条滑块触摸结束
|
||||||
|
const onThumbTouchEnd = (e) => {
|
||||||
|
isDragging.value = false
|
||||||
|
e.stopPropagation()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 滚动条轨道触摸开始
|
||||||
|
const onTrackTouchStart = async (e) => {
|
||||||
|
const rect = await getTrackRect()
|
||||||
|
if (!rect) return
|
||||||
|
|
||||||
|
const clickX = e.touches[0].clientX - rect.left
|
||||||
|
const thumbWidthPx = (thumbWidth.value / 100) * rect.width
|
||||||
|
const thumbCenter = (thumbPosition.value / 100) * rect.width + thumbWidthPx / 2
|
||||||
|
|
||||||
|
const maxScroll = Math.max(0, scrollWidth.value - scrollViewWidth.value)
|
||||||
|
|
||||||
|
if (maxScroll > 0) {
|
||||||
|
if (clickX < thumbCenter) {
|
||||||
|
scrollLeft.value = Math.max(0, scrollLeft.value - scrollViewWidth.value * 0.8)
|
||||||
|
} else {
|
||||||
|
scrollLeft.value = Math.min(maxScroll, scrollLeft.value + scrollViewWidth.value * 0.8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 滚动条轨道触摸移动
|
||||||
|
const onTrackTouchMove = (e) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 滚动条轨道触摸结束
|
||||||
|
const onTrackTouchEnd = (e) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回上一页
|
||||||
|
const goBack = () => {
|
||||||
|
uni.navigateBack()
|
||||||
|
}
|
||||||
|
|
||||||
// 分享对局详情
|
// 分享对局详情
|
||||||
const shareDetail = () => {
|
const shareDetail = () => {
|
||||||
@@ -145,6 +364,7 @@ const shareDetail = () => {
|
|||||||
.game-detail-page {
|
.game-detail-page {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
|
padding-bottom: 200rpx; /* 给底部按钮留出空间 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-bar {
|
.nav-bar {
|
||||||
@@ -169,27 +389,59 @@ const shareDetail = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 玩家列表容器 */
|
||||||
|
.player-list-container {
|
||||||
|
padding: 0 30rpx 30rpx;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 滚动视图样式 */
|
||||||
|
.player-scroll-view {
|
||||||
|
width: 100%;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
// 隐藏原生滚动条
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.player-list-content {
|
||||||
|
display: inline-block;
|
||||||
|
min-width: 100%;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
.player-header {
|
.player-header {
|
||||||
padding: 20rpx 30rpx;
|
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
border-bottom: 1rpx solid #eee;
|
border-bottom: 1rpx solid #eee;
|
||||||
|
|
||||||
.header-row {
|
.header-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
padding: 20rpx 0;
|
||||||
|
|
||||||
.header-cell {
|
.header-label {
|
||||||
flex: 1;
|
width: 200rpx;
|
||||||
|
flex: none;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #000;
|
||||||
|
font-weight: 500;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
align-items: center;
|
||||||
|
padding-left: 20rpx;
|
||||||
&.header-label {
|
}
|
||||||
width: 200rpx;
|
|
||||||
flex: none;
|
.player-columns {
|
||||||
font-size: 28rpx;
|
display: flex;
|
||||||
color: #000;
|
}
|
||||||
font-weight: 500;
|
|
||||||
}
|
.player-column {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
width: 140rpx;
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 0 10rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.player-header-info {
|
.player-header-info {
|
||||||
@@ -197,24 +449,41 @@ const shareDetail = () => {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
.player-avatar {
|
/* 统一头像容器样式 */
|
||||||
width: 60rpx;
|
.avatar-container {
|
||||||
height: 60rpx;
|
position: relative;
|
||||||
border-radius: 50%;
|
width: 110rpx;
|
||||||
|
height: 110rpx;
|
||||||
margin-bottom: 10rpx;
|
margin-bottom: 10rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
.player-avatar {
|
||||||
|
width: 100rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 5rpx solid #fff;
|
||||||
|
box-shadow: 0 6rpx 20rpx rgba(65, 71, 155, 0.3);
|
||||||
|
background: linear-gradient(135deg, #41479b 0%, #8b91e2 100%);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.player-name {
|
.player-name {
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
color: #000;
|
color: #000;
|
||||||
|
text-align: center;
|
||||||
|
word-break: break-all;
|
||||||
|
white-space: normal;
|
||||||
|
max-width: 120rpx;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail-table {
|
.detail-table {
|
||||||
padding: 0 30rpx;
|
|
||||||
|
|
||||||
.table-row {
|
.table-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 20rpx 0;
|
padding: 20rpx 0;
|
||||||
@@ -226,30 +495,70 @@ const shareDetail = () => {
|
|||||||
|
|
||||||
.row-label {
|
.row-label {
|
||||||
width: 200rpx;
|
width: 200rpx;
|
||||||
|
flex: none;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #000;
|
color: #000;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
padding-left: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row-cells {
|
.row-cells {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
|
||||||
|
|
||||||
.score-cell {
|
.score-cell {
|
||||||
flex: 1;
|
width: 140rpx;
|
||||||
|
flex-shrink: 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #333;
|
color: #333;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
padding: 0 10rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 自定义可拖动滚动条样式 - 完全复制单人房间的样式 */
|
||||||
|
.custom-scrollbar {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
|
||||||
|
.scroll-track {
|
||||||
|
height: 12rpx;
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
border-radius: 6rpx;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
// 添加点击区域扩展
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: -10rpx;
|
||||||
|
bottom: -10rpx;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.scroll-thumb {
|
||||||
|
position: absolute;
|
||||||
|
height: 100%;
|
||||||
|
background-color: #41479b;
|
||||||
|
border-radius: 6rpx;
|
||||||
|
transition: all 0.1s ease;
|
||||||
|
|
||||||
|
// 添加悬停效果
|
||||||
|
&:active {
|
||||||
|
background-color: #33367a;
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.action-buttons {
|
.action-buttons {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -23,8 +23,14 @@
|
|||||||
<!-- 动态渲染每个玩家的结算结果 -->
|
<!-- 动态渲染每个玩家的结算结果 -->
|
||||||
<view class="table-row" v-for="player in players" :key="player.id">
|
<view class="table-row" v-for="player in players" :key="player.id">
|
||||||
<view class="player-info">
|
<view class="player-info">
|
||||||
<image class="player-avatar" :src="player.avatar" mode="aspectFit"></image>
|
<!-- 修改头像容器,添加统一的大头像样式 -->
|
||||||
|
<view class="avatar-container">
|
||||||
|
<image class="player-avatar" :src="player.avatar" mode="aspectFill"></image>
|
||||||
|
<!-- 如果是玩家自己,添加标识 -->
|
||||||
|
<view v-if="player.isSelf" class="self-indicator"></view>
|
||||||
|
</view>
|
||||||
<text class="player-name">{{ player.name }}</text>
|
<text class="player-name">{{ player.name }}</text>
|
||||||
|
<view v-if="player.isSelf" class="self-tag">自己</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="win-lose">
|
<view class="win-lose">
|
||||||
<view class="win-tag" v-if="player.totalScore > 0">胜利!</view>
|
<view class="win-tag" v-if="player.totalScore > 0">胜利!</view>
|
||||||
@@ -68,6 +74,9 @@ onMounted(() => {
|
|||||||
// 获取倍率
|
// 获取倍率
|
||||||
rate.value = parseFloat(options.rate) || 1
|
rate.value = parseFloat(options.rate) || 1
|
||||||
|
|
||||||
|
// 获取当前用户信息
|
||||||
|
const currentUserInfo = uni.getStorageSync('userInfo')
|
||||||
|
|
||||||
// 从本地存储获取玩家数据和对局记录
|
// 从本地存储获取玩家数据和对局记录
|
||||||
const savedPlayers = uni.getStorageSync('players')
|
const savedPlayers = uni.getStorageSync('players')
|
||||||
const savedRounds = uni.getStorageSync('gameRounds')
|
const savedRounds = uni.getStorageSync('gameRounds')
|
||||||
@@ -75,6 +84,12 @@ onMounted(() => {
|
|||||||
if (savedPlayers && savedRounds) {
|
if (savedPlayers && savedRounds) {
|
||||||
// 计算每个玩家的总分和倍率分
|
// 计算每个玩家的总分和倍率分
|
||||||
players.value = savedPlayers.map(player => {
|
players.value = savedPlayers.map(player => {
|
||||||
|
// 检查是否是玩家自己
|
||||||
|
const isSelf = currentUserInfo &&
|
||||||
|
currentUserInfo.userId &&
|
||||||
|
player.userId &&
|
||||||
|
player.userId.toString() === currentUserInfo.userId.toString()
|
||||||
|
|
||||||
// 计算总分
|
// 计算总分
|
||||||
let totalScore = 0
|
let totalScore = 0
|
||||||
savedRounds.forEach(round => {
|
savedRounds.forEach(round => {
|
||||||
@@ -90,7 +105,8 @@ onMounted(() => {
|
|||||||
return {
|
return {
|
||||||
...player,
|
...player,
|
||||||
totalScore,
|
totalScore,
|
||||||
rateScore
|
rateScore,
|
||||||
|
isSelf: isSelf || false // 添加isSelf字段
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -101,7 +117,8 @@ onMounted(() => {
|
|||||||
name: '玩家80061',
|
name: '玩家80061',
|
||||||
avatar: 'https://ts1.tc.mm.bing.net/th/id/OIP-C.QQG4bvcAR3CJ0WeQULA9UQAAAA?w=275&h=211&c=8&rs=1&qlt=90&o=6&cb=ucfimgc1&dpr=1.5&pid=3.1&rm=2',
|
avatar: 'https://ts1.tc.mm.bing.net/th/id/OIP-C.QQG4bvcAR3CJ0WeQULA9UQAAAA?w=275&h=211&c=8&rs=1&qlt=90&o=6&cb=ucfimgc1&dpr=1.5&pid=3.1&rm=2',
|
||||||
totalScore: 0,
|
totalScore: 0,
|
||||||
rateScore: 0
|
rateScore: 0,
|
||||||
|
isSelf: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -181,13 +198,21 @@ const shareResult = () => {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
text-align: left;
|
||||||
|
flex: 1.5; /* 调整玩家信息列宽度 */
|
||||||
|
padding-left: 30rpx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-row {
|
.table-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 20rpx;
|
align-items: center;
|
||||||
|
padding: 25rpx 30rpx;
|
||||||
border-bottom: 1rpx solid #ddd;
|
border-bottom: 1rpx solid #ddd;
|
||||||
|
background-color: #fff;
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
@@ -196,18 +221,65 @@ const shareResult = () => {
|
|||||||
.player-info {
|
.player-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex: 1;
|
flex: 1.5; /* 与表头对齐 */
|
||||||
|
min-width: 200rpx;
|
||||||
|
|
||||||
.player-avatar {
|
.avatar-container {
|
||||||
width: 60rpx;
|
position: relative;
|
||||||
height: 60rpx;
|
width: 110rpx; /* 容器比头像稍大 */
|
||||||
border-radius: 50%;
|
height: 110rpx;
|
||||||
margin-right: 10rpx;
|
margin-right: 20rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
.player-avatar {
|
||||||
|
width: 100rpx; /* 增大头像尺寸 */
|
||||||
|
height: 100rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 5rpx solid #fff; /* 添加白色边框 */
|
||||||
|
box-shadow: 0 6rpx 20rpx rgba(65, 71, 155, 0.3); /* 添加阴影效果 */
|
||||||
|
background: linear-gradient(135deg, #41479b 0%, #8b91e2 100%); /* 添加渐变背景 */
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
|
/* 为虚拟玩家头像添加特殊样式 */
|
||||||
|
&:not([src*="OIP-C"]) {
|
||||||
|
/* 处理默认头像的特殊样式 */
|
||||||
|
border: 5rpx solid #f0f0f0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 玩家自己头像的特殊标识 */
|
||||||
|
.self-indicator {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
width: 24rpx;
|
||||||
|
height: 24rpx;
|
||||||
|
background-color: #4CAF50;
|
||||||
|
border: 3rpx solid #fff;
|
||||||
|
border-radius: 50%;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.player-name {
|
.player-name {
|
||||||
font-size: 28rpx;
|
font-size: 26rpx;
|
||||||
color: #000;
|
color: #000;
|
||||||
|
margin-right: 10rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
/* 允许换行 */
|
||||||
|
word-break: break-all;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.self-tag {
|
||||||
|
background-color: #007aff;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 20rpx;
|
||||||
|
padding: 2rpx 8rpx;
|
||||||
|
border-radius: 10rpx;
|
||||||
|
margin-left: 5rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,24 +293,27 @@ const shareResult = () => {
|
|||||||
background-color: #07c160;
|
background-color: #07c160;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
padding: 5rpx 15rpx;
|
padding: 6rpx 20rpx;
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lose-tag {
|
.lose-tag {
|
||||||
background-color: #fa5151;
|
background-color: #fa5151;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
padding: 5rpx 15rpx;
|
padding: 6rpx 20rpx;
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.draw-tag {
|
.draw-tag {
|
||||||
background-color: #10aeff;
|
background-color: #10aeff;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
padding: 5rpx 15rpx;
|
padding: 6rpx 20rpx;
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,20 +321,28 @@ const shareResult = () => {
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #666;
|
color: #333;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 优化虚拟玩家头像的默认样式 */
|
||||||
|
.player-avatar[src*="OIP-C"] {
|
||||||
|
/* 虚拟玩家的默认头像样式 */
|
||||||
|
border: 5rpx solid #e6e6ff !important;
|
||||||
|
box-shadow: 0 6rpx 20rpx rgba(139, 145, 226, 0.3) !important;
|
||||||
|
}
|
||||||
|
|
||||||
.detail-link {
|
.detail-link {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 20rpx 0;
|
margin: 20rpx 0;
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
|
|
||||||
text {
|
text {
|
||||||
font-size: 26rpx;
|
font-size: 28rpx;
|
||||||
color: #41479b;
|
color: #41479b;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
@@ -279,5 +362,12 @@ const shareResult = () => {
|
|||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
border-radius: 40rpx;
|
border-radius: 40rpx;
|
||||||
|
box-shadow: 0 4rpx 12rpx rgba(255, 193, 7, 0.3);
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
background-color: #e6ac00;
|
||||||
|
transform: translateY(2rpx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,4 @@
|
|||||||
|
// api/request.js
|
||||||
import { BASE_URL } from './CommonValues.js';
|
import { BASE_URL } from './CommonValues.js';
|
||||||
import { loginSystem } from '@/api/login.js';
|
import { loginSystem } from '@/api/login.js';
|
||||||
|
|
||||||
@@ -50,13 +51,50 @@ export async function SIMPLE(url, data, method) {
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: data,
|
data: data,
|
||||||
success: res => {
|
success: res => {
|
||||||
if(res.data.code == '200' || res.data.statusCode == '200') {
|
console.log(`API响应 ${url}:`, res);
|
||||||
|
|
||||||
|
// 更灵活的状态码判断
|
||||||
|
let isSuccess = false;
|
||||||
|
|
||||||
|
// 检查HTTP状态码
|
||||||
|
if (res.statusCode === 200) {
|
||||||
|
// 检查响应数据
|
||||||
|
if (res.data) {
|
||||||
|
// 如果data是数组,直接认为是成功的
|
||||||
|
if (Array.isArray(res.data)) {
|
||||||
|
isSuccess = true;
|
||||||
|
}
|
||||||
|
// 如果有code字段且为200
|
||||||
|
else if (res.data.code === 200 || res.data.code === '200') {
|
||||||
|
isSuccess = true;
|
||||||
|
}
|
||||||
|
// 如果有statusCode字段且为200
|
||||||
|
else if (res.data.statusCode === 200 || res.data.statusCode === '200') {
|
||||||
|
isSuccess = true;
|
||||||
|
}
|
||||||
|
// 如果没有code字段但有data字段
|
||||||
|
else if (res.data.data !== undefined) {
|
||||||
|
isSuccess = true;
|
||||||
|
}
|
||||||
|
// 如果data是对象但不是错误结构
|
||||||
|
else if (typeof res.data === 'object' && !res.data.errMsg) {
|
||||||
|
isSuccess = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 没有data字段但状态码是200
|
||||||
|
isSuccess = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSuccess) {
|
||||||
resolve(res.data)
|
resolve(res.data)
|
||||||
} else {
|
} else {
|
||||||
|
console.error('请求返回错误状态:', res.data);
|
||||||
reject(res)
|
reject(res)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: err => {
|
fail: err => {
|
||||||
|
console.error('请求失败:', err);
|
||||||
reject(err)
|
reject(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -75,13 +113,50 @@ export function SIMPLE_TOKEN(url, data, token, method) {
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: data,
|
data: data,
|
||||||
success: res => {
|
success: res => {
|
||||||
if(res.data.code == '200' || res.data.statusCode == '200') {
|
console.log(`API响应 ${url}:`, res);
|
||||||
|
|
||||||
|
// 更灵活的状态码判断
|
||||||
|
let isSuccess = false;
|
||||||
|
|
||||||
|
// 检查HTTP状态码
|
||||||
|
if (res.statusCode === 200) {
|
||||||
|
// 检查响应数据
|
||||||
|
if (res.data) {
|
||||||
|
// 如果data是数组,直接认为是成功的
|
||||||
|
if (Array.isArray(res.data)) {
|
||||||
|
isSuccess = true;
|
||||||
|
}
|
||||||
|
// 如果有code字段且为200
|
||||||
|
else if (res.data.code === 200 || res.data.code === '200') {
|
||||||
|
isSuccess = true;
|
||||||
|
}
|
||||||
|
// 如果有statusCode字段且为200
|
||||||
|
else if (res.data.statusCode === 200 || res.data.statusCode === '200') {
|
||||||
|
isSuccess = true;
|
||||||
|
}
|
||||||
|
// 如果没有code字段但有data字段
|
||||||
|
else if (res.data.data !== undefined) {
|
||||||
|
isSuccess = true;
|
||||||
|
}
|
||||||
|
// 如果data是对象但不是错误结构
|
||||||
|
else if (typeof res.data === 'object' && !res.data.errMsg) {
|
||||||
|
isSuccess = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 没有data字段但状态码是200
|
||||||
|
isSuccess = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSuccess) {
|
||||||
resolve(res.data)
|
resolve(res.data)
|
||||||
} else {
|
} else {
|
||||||
|
console.error('请求返回错误状态:', res.data);
|
||||||
reject(res)
|
reject(res)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: err => {
|
fail: err => {
|
||||||
|
console.error('请求失败:', err);
|
||||||
reject(err)
|
reject(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user