diff --git a/src/main/java/org/springblade/modules/martial/controller/MartialMiniController.java b/src/main/java/org/springblade/modules/martial/controller/MartialMiniController.java index b242c1c..39c4a2b 100644 --- a/src/main/java/org/springblade/modules/martial/controller/MartialMiniController.java +++ b/src/main/java/org/springblade/modules/martial/controller/MartialMiniController.java @@ -1,6 +1,8 @@ package org.springblade.modules.martial.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.v3.oas.annotations.Operation; @@ -165,7 +167,7 @@ public class MartialMiniController extends BladeController { } /** - * 获取选手列表 + * 获取选手列表(支持分页) * - 普通裁判:获取待评分的选手列表(该裁判还未评分的选手) * - 裁判长:获取已有评分的选手列表(至少有一个裁判已评分的选手) * @@ -173,15 +175,19 @@ public class MartialMiniController extends BladeController { * @param refereeType 裁判类型(1-裁判长, 2-普通裁判) * @param projectId 项目ID(可选,用于筛选特定项目的选手) * @param venueId 场地ID(可选,用于筛选特定场地的选手) - * @return 选手列表 + * @param current 当前页码(默认1) + * @param size 每页条数(默认10) + * @return 分页选手列表 */ @GetMapping("/score/athletes") - @Operation(summary = "获取选手列表", description = "根据裁判类型获取不同的选手列表") - public R> getAthletes( + @Operation(summary = "获取选手列表", description = "根据裁判类型获取不同的选手列表(支持分页)") + public R> getAthletes( @RequestParam Long judgeId, @RequestParam Integer refereeType, @RequestParam(required = false) Long projectId, - @RequestParam(required = false) Long venueId + @RequestParam(required = false) Long venueId, + @RequestParam(defaultValue = "1") Integer current, + @RequestParam(defaultValue = "10") Integer size ) { // 1. 构建选手查询条件 LambdaQueryWrapper athleteQuery = new LambdaQueryWrapper<>(); @@ -207,11 +213,11 @@ public class MartialMiniController extends BladeController { .collect(java.util.stream.Collectors.groupingBy(MartialScore::getAthleteId)); // 3. 根据裁判类型筛选选手 - List result; + List filteredList; if (refereeType == 1) { // 裁判长:返回已有评分的选手 - result = athletes.stream() + filteredList = athletes.stream() .filter(athlete -> { List scores = scoresByAthlete.get(athlete.getId()); return scores != null && !scores.isEmpty(); @@ -220,7 +226,7 @@ public class MartialMiniController extends BladeController { .collect(java.util.stream.Collectors.toList()); } else { // 普通裁判:返回该裁判还未评分的选手 - result = athletes.stream() + filteredList = athletes.stream() .filter(athlete -> { List scores = scoresByAthlete.get(athlete.getId()); if (scores == null) { @@ -233,7 +239,23 @@ public class MartialMiniController extends BladeController { .collect(java.util.stream.Collectors.toList()); } - return R.data(result); + // 4. 手动分页 + int total = filteredList.size(); + int fromIndex = (current - 1) * size; + int toIndex = Math.min(fromIndex + size, total); + + List pageRecords; + if (fromIndex >= total) { + pageRecords = new ArrayList<>(); + } else { + pageRecords = filteredList.subList(fromIndex, toIndex); + } + + // 5. 构建分页结果 + IPage page = new Page<>(current, size, total); + page.setRecords(pageRecords); + + return R.data(page); } /** @@ -298,6 +320,9 @@ public class MartialMiniController extends BladeController { org.springblade.modules.martial.pojo.vo.MiniAthleteListVO vo = new org.springblade.modules.martial.pojo.vo.MiniAthleteListVO(); vo.setAthleteId(athlete.getId()); vo.setName(athlete.getPlayerName()); + // 调试日志 + System.out.println("DEBUG: athlete.getId()=" + athlete.getId() + ", idCard=" + athlete.getIdCard() + ", playerNo=" + athlete.getPlayerNo()); + vo.setIdCard(athlete.getIdCard()); vo.setNumber(athlete.getPlayerNo()); vo.setTeam(athlete.getTeamName()); vo.setOrderNum(athlete.getOrderNum()); diff --git a/src/main/java/org/springblade/modules/martial/pojo/vo/MiniAthleteListVO.java b/src/main/java/org/springblade/modules/martial/pojo/vo/MiniAthleteListVO.java index 3d5e08f..2891245 100644 --- a/src/main/java/org/springblade/modules/martial/pojo/vo/MiniAthleteListVO.java +++ b/src/main/java/org/springblade/modules/martial/pojo/vo/MiniAthleteListVO.java @@ -1,5 +1,7 @@ package org.springblade.modules.martial.pojo.vo; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -13,34 +15,48 @@ import java.math.BigDecimal; */ @Data @Schema(description = "小程序选手列表") +@JsonInclude(JsonInclude.Include.ALWAYS) public class MiniAthleteListVO implements Serializable { private static final long serialVersionUID = 1L; @Schema(description = "选手ID") + @JsonProperty("athleteId") private Long athleteId; @Schema(description = "选手姓名") + @JsonProperty("name") private String name; + @Schema(description = "身份证号") + @JsonProperty("idCard") + private String idCard = ""; + @Schema(description = "参赛编号") + @JsonProperty("number") private String number; @Schema(description = "队伍名称") + @JsonProperty("team") private String team; @Schema(description = "项目名称") + @JsonProperty("projectName") private String projectName; @Schema(description = "出场顺序") + @JsonProperty("orderNum") private Integer orderNum; @Schema(description = "总分(裁判长可见)") + @JsonProperty("totalScore") private BigDecimal totalScore; @Schema(description = "已评分裁判数量(裁判长可见)") + @JsonProperty("scoredJudgeCount") private Integer scoredJudgeCount; @Schema(description = "比赛状态(0-待出场,1-进行中,2-已完成)") + @JsonProperty("competitionStatus") private Integer competitionStatus; }