fix: 添加 @JsonProperty 注解确保 JSON 字段名正确序列化
Some checks failed
continuous-integration/drone/push Build is failing

- MiniAthleteListVO 添加 @JsonProperty 注解,确保字段名与前端一致
- 添加 @JsonInclude(ALWAYS) 确保所有字段都输出
- 添加 idCard 字段支持身份证号显示

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-18 23:08:16 +08:00
parent ab290d1aa2
commit 3ae441c044
2 changed files with 50 additions and 9 deletions

View File

@@ -1,6 +1,8 @@
package org.springblade.modules.martial.controller; package org.springblade.modules.martial.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.Operation; 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 refereeType 裁判类型1-裁判长, 2-普通裁判)
* @param projectId 项目ID可选用于筛选特定项目的选手 * @param projectId 项目ID可选用于筛选特定项目的选手
* @param venueId 场地ID可选用于筛选特定场地的选手 * @param venueId 场地ID可选用于筛选特定场地的选手
* @return 选手列表 * @param current 当前页码默认1
* @param size 每页条数默认10
* @return 分页选手列表
*/ */
@GetMapping("/score/athletes") @GetMapping("/score/athletes")
@Operation(summary = "获取选手列表", description = "根据裁判类型获取不同的选手列表") @Operation(summary = "获取选手列表", description = "根据裁判类型获取不同的选手列表(支持分页)")
public R<List<org.springblade.modules.martial.pojo.vo.MiniAthleteListVO>> getAthletes( public R<IPage<org.springblade.modules.martial.pojo.vo.MiniAthleteListVO>> getAthletes(
@RequestParam Long judgeId, @RequestParam Long judgeId,
@RequestParam Integer refereeType, @RequestParam Integer refereeType,
@RequestParam(required = false) Long projectId, @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. 构建选手查询条件 // 1. 构建选手查询条件
LambdaQueryWrapper<MartialAthlete> athleteQuery = new LambdaQueryWrapper<>(); LambdaQueryWrapper<MartialAthlete> athleteQuery = new LambdaQueryWrapper<>();
@@ -207,11 +213,11 @@ public class MartialMiniController extends BladeController {
.collect(java.util.stream.Collectors.groupingBy(MartialScore::getAthleteId)); .collect(java.util.stream.Collectors.groupingBy(MartialScore::getAthleteId));
// 3. 根据裁判类型筛选选手 // 3. 根据裁判类型筛选选手
List<org.springblade.modules.martial.pojo.vo.MiniAthleteListVO> result; List<org.springblade.modules.martial.pojo.vo.MiniAthleteListVO> filteredList;
if (refereeType == 1) { if (refereeType == 1) {
// 裁判长:返回已有评分的选手 // 裁判长:返回已有评分的选手
result = athletes.stream() filteredList = athletes.stream()
.filter(athlete -> { .filter(athlete -> {
List<MartialScore> scores = scoresByAthlete.get(athlete.getId()); List<MartialScore> scores = scoresByAthlete.get(athlete.getId());
return scores != null && !scores.isEmpty(); return scores != null && !scores.isEmpty();
@@ -220,7 +226,7 @@ public class MartialMiniController extends BladeController {
.collect(java.util.stream.Collectors.toList()); .collect(java.util.stream.Collectors.toList());
} else { } else {
// 普通裁判:返回该裁判还未评分的选手 // 普通裁判:返回该裁判还未评分的选手
result = athletes.stream() filteredList = athletes.stream()
.filter(athlete -> { .filter(athlete -> {
List<MartialScore> scores = scoresByAthlete.get(athlete.getId()); List<MartialScore> scores = scoresByAthlete.get(athlete.getId());
if (scores == null) { if (scores == null) {
@@ -233,7 +239,23 @@ public class MartialMiniController extends BladeController {
.collect(java.util.stream.Collectors.toList()); .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<org.springblade.modules.martial.pojo.vo.MiniAthleteListVO> pageRecords;
if (fromIndex >= total) {
pageRecords = new ArrayList<>();
} else {
pageRecords = filteredList.subList(fromIndex, toIndex);
}
// 5. 构建分页结果
IPage<org.springblade.modules.martial.pojo.vo.MiniAthleteListVO> 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(); org.springblade.modules.martial.pojo.vo.MiniAthleteListVO vo = new org.springblade.modules.martial.pojo.vo.MiniAthleteListVO();
vo.setAthleteId(athlete.getId()); vo.setAthleteId(athlete.getId());
vo.setName(athlete.getPlayerName()); 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.setNumber(athlete.getPlayerNo());
vo.setTeam(athlete.getTeamName()); vo.setTeam(athlete.getTeamName());
vo.setOrderNum(athlete.getOrderNum()); vo.setOrderNum(athlete.getOrderNum());

View File

@@ -1,5 +1,7 @@
package org.springblade.modules.martial.pojo.vo; 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 io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@@ -13,34 +15,48 @@ import java.math.BigDecimal;
*/ */
@Data @Data
@Schema(description = "小程序选手列表") @Schema(description = "小程序选手列表")
@JsonInclude(JsonInclude.Include.ALWAYS)
public class MiniAthleteListVO implements Serializable { public class MiniAthleteListVO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Schema(description = "选手ID") @Schema(description = "选手ID")
@JsonProperty("athleteId")
private Long athleteId; private Long athleteId;
@Schema(description = "选手姓名") @Schema(description = "选手姓名")
@JsonProperty("name")
private String name; private String name;
@Schema(description = "身份证号")
@JsonProperty("idCard")
private String idCard = "";
@Schema(description = "参赛编号") @Schema(description = "参赛编号")
@JsonProperty("number")
private String number; private String number;
@Schema(description = "队伍名称") @Schema(description = "队伍名称")
@JsonProperty("team")
private String team; private String team;
@Schema(description = "项目名称") @Schema(description = "项目名称")
@JsonProperty("projectName")
private String projectName; private String projectName;
@Schema(description = "出场顺序") @Schema(description = "出场顺序")
@JsonProperty("orderNum")
private Integer orderNum; private Integer orderNum;
@Schema(description = "总分(裁判长可见)") @Schema(description = "总分(裁判长可见)")
@JsonProperty("totalScore")
private BigDecimal totalScore; private BigDecimal totalScore;
@Schema(description = "已评分裁判数量(裁判长可见)") @Schema(description = "已评分裁判数量(裁判长可见)")
@JsonProperty("scoredJudgeCount")
private Integer scoredJudgeCount; private Integer scoredJudgeCount;
@Schema(description = "比赛状态0-待出场,1-进行中,2-已完成)") @Schema(description = "比赛状态0-待出场,1-进行中,2-已完成)")
@JsonProperty("competitionStatus")
private Integer competitionStatus; private Integer competitionStatus;
} }