diff --git a/init-judge-project.sql b/init-judge-project.sql new file mode 100644 index 0000000..bc1e73a --- /dev/null +++ b/init-judge-project.sql @@ -0,0 +1,91 @@ +-- ============================================ +-- 初始化裁判-项目关联数据 +-- 用于解决"您没有权限给该项目打分"的问题 +-- ============================================ + +-- 说明: +-- 1. 这个脚本会为所有裁判分配所有项目的评分权限 +-- 2. 如果需要更精细的权限控制,请根据实际情况修改 +-- 3. 执行前请确保 martial_judge 和 martial_project 表中已有数据 + +-- 清空现有的裁判-项目关联(可选) +-- TRUNCATE TABLE martial_judge_project; + +-- 方案1:为所有裁判分配所有项目(适用于测试环境) +INSERT INTO martial_judge_project ( + competition_id, + judge_id, + project_id, + assign_time, + status, + is_deleted, + create_time, + update_time +) +SELECT + j.competition_id, + j.id AS judge_id, + p.id AS project_id, + NOW() AS assign_time, + 1 AS status, + 0 AS is_deleted, + NOW() AS create_time, + NOW() AS update_time +FROM martial_judge j +CROSS JOIN martial_project p +WHERE j.is_deleted = 0 + AND p.is_deleted = 0 + AND NOT EXISTS ( + SELECT 1 FROM martial_judge_project jp + WHERE jp.judge_id = j.id + AND jp.project_id = p.id + AND jp.is_deleted = 0 + ); + +-- 方案2:为特定裁判分配特定项目(适用于生产环境) +-- 示例:为裁判ID=456分配项目ID=5的权限 +/* +INSERT INTO martial_judge_project ( + competition_id, + judge_id, + project_id, + assign_time, + status, + is_deleted, + create_time, + update_time +) VALUES ( + 200, -- 比赛ID + 456, -- 裁判ID + 5, -- 项目ID + NOW(), + 1, + 0, + NOW(), + NOW() +); +*/ + +-- 验证数据 +SELECT + jp.id, + j.name AS judge_name, + p.project_name, + jp.status, + jp.assign_time +FROM martial_judge_project jp +LEFT JOIN martial_judge j ON jp.judge_id = j.id +LEFT JOIN martial_project p ON jp.project_id = p.id +WHERE jp.is_deleted = 0 +ORDER BY jp.judge_id, jp.project_id; + +-- 查看每个裁判分配的项目数量 +SELECT + j.id AS judge_id, + j.name AS judge_name, + COUNT(jp.id) AS project_count +FROM martial_judge j +LEFT JOIN martial_judge_project jp ON j.id = jp.judge_id AND jp.is_deleted = 0 +WHERE j.is_deleted = 0 +GROUP BY j.id, j.name +ORDER BY j.id; diff --git a/src/main/java/org/springblade/modules/martial/controller/MartialAthleteController.java b/src/main/java/org/springblade/modules/martial/controller/MartialAthleteController.java index 2ba0355..2fc794d 100644 --- a/src/main/java/org/springblade/modules/martial/controller/MartialAthleteController.java +++ b/src/main/java/org/springblade/modules/martial/controller/MartialAthleteController.java @@ -1,12 +1,14 @@ package org.springblade.modules.martial.controller; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.qiniu.util.Auth; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.modules.martial.pojo.entity.MartialAthlete; @@ -53,6 +55,8 @@ public class MartialAthleteController extends BladeController { @PostMapping("/submit") @Operation(summary = "新增或修改", description = "传入实体") public R submit(@RequestBody MartialAthlete athlete) { + athlete.setCreateUser(AuthUtil.getUserId()); + athlete.setUpdateUser(AuthUtil.getUserId()); return R.status(athleteService.saveOrUpdate(athlete)); } diff --git a/src/main/java/org/springblade/modules/martial/controller/MartialDeductionItemController.java b/src/main/java/org/springblade/modules/martial/controller/MartialDeductionItemController.java index 8199e9a..a96f5c6 100644 --- a/src/main/java/org/springblade/modules/martial/controller/MartialDeductionItemController.java +++ b/src/main/java/org/springblade/modules/martial/controller/MartialDeductionItemController.java @@ -10,9 +10,13 @@ import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.modules.martial.pojo.entity.MartialDeductionItem; +import org.springblade.modules.martial.pojo.entity.MartialProject; import org.springblade.modules.martial.service.IMartialDeductionItemService; +import org.springblade.modules.martial.service.IMartialProjectService; import org.springframework.web.bind.annotation.*; +import java.util.List; + /** * 扣分项配置 控制器 * @@ -26,6 +30,8 @@ public class MartialDeductionItemController extends BladeController { private final IMartialDeductionItemService deductionItemService; + private final IMartialProjectService martialProjectService; + /** * 详情 */ @@ -43,6 +49,11 @@ public class MartialDeductionItemController extends BladeController { @Operation(summary = "分页列表", description = "分页查询") public R> list(MartialDeductionItem deductionItem, Query query) { IPage pages = deductionItemService.page(Condition.getPage(query), Condition.getQueryWrapper(deductionItem)); + List deductionItems = pages.getRecords(); + for (MartialDeductionItem item : deductionItems) { + MartialProject project = martialProjectService.getById(item.getProjectId()); + item.setProjectName(project.getProjectName()); + } return R.data(pages); } 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 c9c15a8..b242c1c 100644 --- a/src/main/java/org/springblade/modules/martial/controller/MartialMiniController.java +++ b/src/main/java/org/springblade/modules/martial/controller/MartialMiniController.java @@ -17,6 +17,7 @@ import org.springblade.modules.martial.pojo.vo.MiniAthleteAdminVO; import org.springblade.modules.martial.pojo.vo.MiniAthleteScoreVO; import org.springblade.modules.martial.pojo.vo.MiniLoginVO; import org.springblade.modules.martial.pojo.vo.MiniScoreDetailVO; +import com.alibaba.fastjson.JSON; import org.springblade.modules.martial.service.*; import org.springframework.web.bind.annotation.*; @@ -124,42 +125,114 @@ public class MartialMiniController extends BladeController { } /** - * 获取我的选手列表(普通评委) + * 提交评分(评委) * - * @param judgeId 评委ID - * @param venueId 场地ID - * @param projectId 项目ID - * @return 选手列表(含评分状态) + * @param dto 评分信息 + * @return 提交结果 */ - @GetMapping("/athletes") - @Operation(summary = "选手列表(普通评委)", description = "获取分配的选手列表") - public R> getMyAthletes( - @RequestParam Long judgeId, - @RequestParam Long venueId, - @RequestParam Long projectId - ) { - List result = athleteService.getAthletesWithMyScore( - judgeId, venueId, projectId); - return R.data(result); + @PostMapping("/score/submit") + @Operation(summary = "提交评分", description = "评委提交对选手的评分") + public R submitScore(@RequestBody org.springblade.modules.martial.pojo.dto.MiniScoreSubmitDTO dto) { + + // 转换DTO为实体 + MartialScore score = new MartialScore(); + score.setAthleteId(dto.getAthleteId()); + score.setJudgeId(dto.getJudgeId()); + score.setScore(dto.getScore()); + score.setProjectId(dto.getProjectId()); + score.setCompetitionId(dto.getCompetitionId()); + score.setVenueId(dto.getVenueId()); + score.setScheduleId(dto.getScheduleId()); + score.setNote(dto.getNote()); + score.setScoreTime(LocalDateTime.now()); + + // 将扣分项列表转换为JSON字符串存储 + if (dto.getDeductions() != null && !dto.getDeductions().isEmpty()) { + score.setDeductionItems(com.alibaba.fastjson.JSON.toJSONString(dto.getDeductions())); + } + + // 获取评委姓名 + if (dto.getJudgeId() != null) { + var judge = judgeService.getById(dto.getJudgeId()); + if (judge != null) { + score.setJudgeName(judge.getName()); + } + } + + // 保存评分(会自动进行权限验证和分数范围验证) + boolean success = scoreService.save(score); + return success ? R.success("评分提交成功") : R.fail("评分提交失败"); } /** - * 获取选手列表(裁判长) + * 获取选手列表 + * - 普通裁判:获取待评分的选手列表(该裁判还未评分的选手) + * - 裁判长:获取已有评分的选手列表(至少有一个裁判已评分的选手) * - * @param competitionId 比赛ID - * @param venueId 场地ID - * @param projectId 项目ID - * @return 选手列表(含评分统计) + * @param judgeId 裁判ID + * @param refereeType 裁判类型(1-裁判长, 2-普通裁判) + * @param projectId 项目ID(可选,用于筛选特定项目的选手) + * @param venueId 场地ID(可选,用于筛选特定场地的选手) + * @return 选手列表 */ - @GetMapping("/athletes/admin") - @Operation(summary = "选手列表(裁判长)", description = "裁判长查看所有选手") - public R> getAthletesForAdmin( - @RequestParam Long competitionId, - @RequestParam Long venueId, - @RequestParam Long projectId + @GetMapping("/score/athletes") + @Operation(summary = "获取选手列表", description = "根据裁判类型获取不同的选手列表") + public R> getAthletes( + @RequestParam Long judgeId, + @RequestParam Integer refereeType, + @RequestParam(required = false) Long projectId, + @RequestParam(required = false) Long venueId ) { - List result = athleteService.getAthletesForAdmin( - competitionId, venueId, projectId); + // 1. 构建选手查询条件 + LambdaQueryWrapper athleteQuery = new LambdaQueryWrapper<>(); + athleteQuery.eq(MartialAthlete::getIsDeleted, 0); + + if (projectId != null) { + athleteQuery.eq(MartialAthlete::getProjectId, projectId); + } + // 注意:场地筛选需要通过评分记录的venueId来过滤,这里先查询所有选手 + + // 按出场顺序排序 + athleteQuery.orderByAsc(MartialAthlete::getOrderNum); + + List athletes = athleteService.list(athleteQuery); + + // 2. 获取所有评分记录 + LambdaQueryWrapper scoreQuery = new LambdaQueryWrapper<>(); + scoreQuery.eq(MartialScore::getIsDeleted, 0); + List allScores = scoreService.list(scoreQuery); + + // 按选手ID分组统计评分 + java.util.Map> scoresByAthlete = allScores.stream() + .collect(java.util.stream.Collectors.groupingBy(MartialScore::getAthleteId)); + + // 3. 根据裁判类型筛选选手 + List result; + + if (refereeType == 1) { + // 裁判长:返回已有评分的选手 + result = athletes.stream() + .filter(athlete -> { + List scores = scoresByAthlete.get(athlete.getId()); + return scores != null && !scores.isEmpty(); + }) + .map(athlete -> convertToAthleteListVO(athlete, scoresByAthlete.get(athlete.getId()))) + .collect(java.util.stream.Collectors.toList()); + } else { + // 普通裁判:返回该裁判还未评分的选手 + result = athletes.stream() + .filter(athlete -> { + List scores = scoresByAthlete.get(athlete.getId()); + if (scores == null) { + return true; // 没有任何评分,可以评 + } + // 检查该裁判是否已评分 + return scores.stream().noneMatch(s -> s.getJudgeId().equals(judgeId)); + }) + .map(athlete -> convertToAthleteListVO(athlete, null)) + .collect(java.util.stream.Collectors.toList()); + } + return R.data(result); } @@ -189,6 +262,64 @@ public class MartialMiniController extends BladeController { return success ? R.success("修改成功") : R.fail("修改失败"); } + /** + * 退出登录 + * + * @return 退出结果 + */ + @PostMapping("/logout") + @Operation(summary = "退出登录", description = "清除登录状态") + public R logout() { + // TODO: 实现真实的退出逻辑 + // 1. 清除token + // 2. 清除session + return R.success("退出成功"); + } + + /** + * Token验证 + * + * @return 验证结果 + */ + @GetMapping("/verify") + @Operation(summary = "Token验证", description = "验证当前token是否有效") + public R verify() { + // TODO: 实现真实的token验证逻辑 + // 1. 从请求头获取token + // 2. 验证token是否有效 + // 3. 返回验证结果 + return R.success("Token有效"); + } + + /** + * 转换选手实体为VO + */ + private org.springblade.modules.martial.pojo.vo.MiniAthleteListVO convertToAthleteListVO(MartialAthlete athlete, List scores) { + org.springblade.modules.martial.pojo.vo.MiniAthleteListVO vo = new org.springblade.modules.martial.pojo.vo.MiniAthleteListVO(); + vo.setAthleteId(athlete.getId()); + vo.setName(athlete.getPlayerName()); + vo.setNumber(athlete.getPlayerNo()); + vo.setTeam(athlete.getTeamName()); + vo.setOrderNum(athlete.getOrderNum()); + vo.setCompetitionStatus(athlete.getCompetitionStatus()); + vo.setTotalScore(athlete.getTotalScore()); + + // 设置项目名称 + if (athlete.getProjectId() != null) { + MartialProject project = projectService.getById(athlete.getProjectId()); + if (project != null) { + vo.setProjectName(project.getProjectName()); + } + } + + // 设置已评分裁判数量(仅裁判长可见) + if (scores != null) { + vo.setScoredJudgeCount(scores.size()); + } + + return vo; + } + /** * 解析项目JSON字符串 */ diff --git a/src/main/java/org/springblade/modules/martial/controller/MartialRegistrationOrderController.java b/src/main/java/org/springblade/modules/martial/controller/MartialRegistrationOrderController.java index 84bd0aa..25381b4 100644 --- a/src/main/java/org/springblade/modules/martial/controller/MartialRegistrationOrderController.java +++ b/src/main/java/org/springblade/modules/martial/controller/MartialRegistrationOrderController.java @@ -31,9 +31,9 @@ public class MartialRegistrationOrderController extends BladeController { */ @GetMapping("/detail") @Operation(summary = "详情", description = "传入ID") - public R detail(@RequestParam Long id) { - MartialRegistrationOrder detail = registrationOrderService.getById(id); - return R.data(detail); + public R detail(@RequestParam Long id) { + // 返回包含关联数据的完整详情 + return R.data(registrationOrderService.getDetailWithRelations(id)); } /** diff --git a/src/main/java/org/springblade/modules/martial/mapper/MartialAthleteMapper.xml b/src/main/java/org/springblade/modules/martial/mapper/MartialAthleteMapper.xml index 935c728..7168a93 100644 --- a/src/main/java/org/springblade/modules/martial/mapper/MartialAthleteMapper.xml +++ b/src/main/java/org/springblade/modules/martial/mapper/MartialAthleteMapper.xml @@ -39,6 +39,9 @@ AND a.competition_status = #{athlete.competitionStatus} + + AND a.create_user = #{athlete.createUser} + ORDER BY a.create_time DESC diff --git a/src/main/java/org/springblade/modules/martial/mapper/MartialJudgeInviteMapper.xml b/src/main/java/org/springblade/modules/martial/mapper/MartialJudgeInviteMapper.xml index 14dd7c3..538a8be 100644 --- a/src/main/java/org/springblade/modules/martial/mapper/MartialJudgeInviteMapper.xml +++ b/src/main/java/org/springblade/modules/martial/mapper/MartialJudgeInviteMapper.xml @@ -26,12 +26,7 @@ - - - - - @@ -73,6 +68,7 @@ ji.update_time, ji.status, ji.is_deleted, + ji.referee_type, j.name AS judge_name, j.level AS judge_level, c.competition_name @@ -80,20 +76,13 @@ martial_judge_invite ji LEFT JOIN martial_judge j ON ji.judge_id = j.id LEFT JOIN martial_competition c ON ji.competition_id = c.id - WHERE - ji.is_deleted = 0 - - AND ji.competition_id = #{judgeInvite.competitionId} - - - AND ji.invite_status = #{judgeInvite.inviteStatus} - - - AND j.name LIKE CONCAT('%', #{judgeInvite.judgeName}, '%') - - - AND j.level = #{judgeInvite.judgeLevel} - + WHERE ji.is_deleted = 0 + + AND ji.competition_id = #{judgeInvite.competitionId} + + + AND ji.invite_status = #{judgeInvite.inviteStatus} + ORDER BY ji.create_time DESC diff --git a/src/main/java/org/springblade/modules/martial/pojo/dto/MiniScoreSubmitDTO.java b/src/main/java/org/springblade/modules/martial/pojo/dto/MiniScoreSubmitDTO.java new file mode 100644 index 0000000..9a9f4a1 --- /dev/null +++ b/src/main/java/org/springblade/modules/martial/pojo/dto/MiniScoreSubmitDTO.java @@ -0,0 +1,47 @@ +package org.springblade.modules.martial.pojo.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * 小程序提交评分请求DTO + * + * @author BladeX + */ +@Data +@Schema(description = "小程序提交评分请求") +public class MiniScoreSubmitDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(description = "选手ID") + private Long athleteId; + + @Schema(description = "评委ID") + private Long judgeId; + + @Schema(description = "评分") + private BigDecimal score; + + @Schema(description = "扣分项ID列表") + private List deductions; + + @Schema(description = "备注") + private String note; + + @Schema(description = "项目ID") + private Long projectId; + + @Schema(description = "赛事ID") + private Long competitionId; + + @Schema(description = "场地ID") + private Long venueId; + + @Schema(description = "赛程ID") + private Long scheduleId; +} diff --git a/src/main/java/org/springblade/modules/martial/pojo/entity/MartialCompetition.java b/src/main/java/org/springblade/modules/martial/pojo/entity/MartialCompetition.java index 77dadfb..8eeea79 100644 --- a/src/main/java/org/springblade/modules/martial/pojo/entity/MartialCompetition.java +++ b/src/main/java/org/springblade/modules/martial/pojo/entity/MartialCompetition.java @@ -158,4 +158,9 @@ public class MartialCompetition extends TenantEntity { @Schema(description = "报名总金额") private BigDecimal totalAmount; + /** + * 是否精品:1 是,2 否 + */ + @Schema(description = "是否精品:1 是,2 否") + private Integer isCompeBoutique; } diff --git a/src/main/java/org/springblade/modules/martial/pojo/entity/MartialDeductionItem.java b/src/main/java/org/springblade/modules/martial/pojo/entity/MartialDeductionItem.java index b311ab6..f8df30b 100644 --- a/src/main/java/org/springblade/modules/martial/pojo/entity/MartialDeductionItem.java +++ b/src/main/java/org/springblade/modules/martial/pojo/entity/MartialDeductionItem.java @@ -16,6 +16,7 @@ */ package org.springblade.modules.martial.pojo.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -67,6 +68,12 @@ public class MartialDeductionItem extends TenantEntity { @Schema(description = "适用项目") private String applicableProjects; + /** + * 项目id + */ + @Schema(description = "项目id") + private Long projectId; + /** * 描述 */ @@ -79,4 +86,11 @@ public class MartialDeductionItem extends TenantEntity { @Schema(description = "排序") private Integer sortOrder; + /** + * 项目名称 + */ + @TableField(exist = false) + @Schema(description = "项目名称") + private String projectName; + } diff --git a/src/main/java/org/springblade/modules/martial/pojo/entity/MartialJudgeInvite.java b/src/main/java/org/springblade/modules/martial/pojo/entity/MartialJudgeInvite.java index ec26dfb..7626dda 100644 --- a/src/main/java/org/springblade/modules/martial/pojo/entity/MartialJudgeInvite.java +++ b/src/main/java/org/springblade/modules/martial/pojo/entity/MartialJudgeInvite.java @@ -163,4 +163,10 @@ public class MartialJudgeInvite extends TenantEntity { @Schema(description = "取消原因") private String cancelReason; + /** + * 裁判类型 + */ + @Schema(description = "裁判类型") + private Integer refereeType; + } diff --git a/src/main/java/org/springblade/modules/martial/pojo/vo/MartialRegistrationOrderVO.java b/src/main/java/org/springblade/modules/martial/pojo/vo/MartialRegistrationOrderVO.java new file mode 100644 index 0000000..25c3a6c --- /dev/null +++ b/src/main/java/org/springblade/modules/martial/pojo/vo/MartialRegistrationOrderVO.java @@ -0,0 +1,105 @@ +package org.springblade.modules.martial.pojo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.modules.martial.pojo.entity.MartialRegistrationOrder; + +import java.util.List; + +/** + * 报名订单视图对象 + * 包含关联的赛事、项目和选手信息 + * + * @author BladeX + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Schema(description = "报名订单视图对象") +public class MartialRegistrationOrderVO extends MartialRegistrationOrder { + + private static final long serialVersionUID = 1L; + + /** + * 赛事名称 + */ + @Schema(description = "赛事名称") + private String competitionName; + + /** + * 赛事地点 + */ + @Schema(description = "赛事地点") + private String location; + + /** + * 赛事开始时间 + */ + @Schema(description = "赛事开始时间") + private String startTime; + + /** + * 赛事结束时间 + */ + @Schema(description = "赛事结束时间") + private String endTime; + + /** + * 报名项目名称列表(逗号分隔) + */ + @Schema(description = "报名项目名称") + private String projectNames; + + /** + * 报名项目列表 + */ + @Schema(description = "报名项目列表") + private List projectList; + + /** + * 参赛选手名称列表(逗号分隔) + */ + @Schema(description = "参赛选手名称") + private String athleteNames; + + /** + * 参赛选手列表 + */ + @Schema(description = "参赛选手列表") + private List athleteList; + + /** + * 项目信息 + */ + @Data + @Schema(description = "项目信息") + public static class ProjectInfo { + @Schema(description = "项目ID") + private Long id; + + @Schema(description = "项目名称") + private String projectName; + + @Schema(description = "项目类型") + private String projectType; + } + + /** + * 选手信息 + */ + @Data + @Schema(description = "选手信息") + public static class AthleteInfo { + @Schema(description = "选手ID") + private Long id; + + @Schema(description = "选手姓名") + private String playerName; + + @Schema(description = "性别") + private Integer gender; + + @Schema(description = "身份证号") + private String idCard; + } +} 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 new file mode 100644 index 0000000..3d5e08f --- /dev/null +++ b/src/main/java/org/springblade/modules/martial/pojo/vo/MiniAthleteListVO.java @@ -0,0 +1,46 @@ +package org.springblade.modules.martial.pojo.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 小程序选手列表VO + * + * @author BladeX + */ +@Data +@Schema(description = "小程序选手列表") +public class MiniAthleteListVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(description = "选手ID") + private Long athleteId; + + @Schema(description = "选手姓名") + private String name; + + @Schema(description = "参赛编号") + private String number; + + @Schema(description = "队伍名称") + private String team; + + @Schema(description = "项目名称") + private String projectName; + + @Schema(description = "出场顺序") + private Integer orderNum; + + @Schema(description = "总分(裁判长可见)") + private BigDecimal totalScore; + + @Schema(description = "已评分裁判数量(裁判长可见)") + private Integer scoredJudgeCount; + + @Schema(description = "比赛状态(0-待出场,1-进行中,2-已完成)") + private Integer competitionStatus; +} diff --git a/src/main/java/org/springblade/modules/martial/service/IMartialRegistrationOrderService.java b/src/main/java/org/springblade/modules/martial/service/IMartialRegistrationOrderService.java index 713d8cc..4c6acd2 100644 --- a/src/main/java/org/springblade/modules/martial/service/IMartialRegistrationOrderService.java +++ b/src/main/java/org/springblade/modules/martial/service/IMartialRegistrationOrderService.java @@ -2,6 +2,7 @@ package org.springblade.modules.martial.service; import com.baomidou.mybatisplus.extension.service.IService; import org.springblade.modules.martial.pojo.entity.MartialRegistrationOrder; +import org.springblade.modules.martial.pojo.vo.MartialRegistrationOrderVO; /** * RegistrationOrder 服务类 @@ -10,4 +11,12 @@ import org.springblade.modules.martial.pojo.entity.MartialRegistrationOrder; */ public interface IMartialRegistrationOrderService extends IService { + /** + * 获取报名订单详情(包含关联数据) + * + * @param id 订单ID + * @return 订单详情VO + */ + MartialRegistrationOrderVO getDetailWithRelations(Long id); + } diff --git a/src/main/java/org/springblade/modules/martial/service/impl/MartialJudgeInviteServiceImpl.java b/src/main/java/org/springblade/modules/martial/service/impl/MartialJudgeInviteServiceImpl.java index cf6a90f..78dadf0 100644 --- a/src/main/java/org/springblade/modules/martial/service/impl/MartialJudgeInviteServiceImpl.java +++ b/src/main/java/org/springblade/modules/martial/service/impl/MartialJudgeInviteServiceImpl.java @@ -11,10 +11,13 @@ import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.modules.martial.pojo.dto.BatchGenerateInviteDTO; import org.springblade.modules.martial.pojo.dto.GenerateInviteDTO; +import org.springblade.modules.martial.pojo.entity.MartialJudge; import org.springblade.modules.martial.pojo.entity.MartialJudgeInvite; import org.springblade.modules.martial.mapper.MartialJudgeInviteMapper; import org.springblade.modules.martial.pojo.vo.MartialJudgeInviteVO; import org.springblade.modules.martial.service.IMartialJudgeInviteService; +import org.springblade.modules.martial.service.IMartialJudgeService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.time.LocalDateTime; @@ -33,6 +36,9 @@ import java.util.UUID; @Service public class MartialJudgeInviteServiceImpl extends ServiceImpl implements IMartialJudgeInviteService { + @Autowired + private IMartialJudgeService martialJudgeService; + @Override public IPage selectJudgeInvitePage(MartialJudgeInvite judgeInvite, Query query) { IPage page = Condition.getPage(query); @@ -93,6 +99,8 @@ public class MartialJudgeInviteServiceImpl extends ServiceImpl implements IMartialRegistrationOrderService { + private final IMartialCompetitionService competitionService; + private final IMartialAthleteService athleteService; + private final IMartialProjectService projectService; + + @Override + public MartialRegistrationOrderVO getDetailWithRelations(Long id) { + // 获取订单基本信息 + MartialRegistrationOrder order = this.getById(id); + if (order == null) { + return null; + } + + // 创建VO对象 + MartialRegistrationOrderVO vo = new MartialRegistrationOrderVO(); + BeanUtils.copyProperties(order, vo); + + // 获取赛事信息 + if (order.getCompetitionId() != null) { + MartialCompetition competition = competitionService.getById(order.getCompetitionId()); + if (competition != null) { + vo.setCompetitionName(competition.getCompetitionName()); + vo.setLocation(competition.getLocation()); + vo.setStartTime(competition.getCompetitionStartTime() != null ? competition.getCompetitionStartTime().toString() : null); + vo.setEndTime(competition.getCompetitionEndTime() != null ? competition.getCompetitionEndTime().toString() : null); + } + } + + // 获取该订单的所有选手 + LambdaQueryWrapper athleteWrapper = new LambdaQueryWrapper<>(); + athleteWrapper.eq(MartialAthlete::getOrderId, id); + List athletes = athleteService.list(athleteWrapper); + + if (!athletes.isEmpty()) { + // 设置选手名称列表 + String athleteNames = athletes.stream() + .map(MartialAthlete::getPlayerName) + .collect(Collectors.joining("、")); + vo.setAthleteNames(athleteNames); + + // 设置选手详细列表 + List athleteList = athletes.stream() + .map(athlete -> { + MartialRegistrationOrderVO.AthleteInfo info = new MartialRegistrationOrderVO.AthleteInfo(); + info.setId(athlete.getId()); + info.setPlayerName(athlete.getPlayerName()); + info.setGender(athlete.getGender()); + info.setIdCard(athlete.getIdCard()); + return info; + }) + .collect(Collectors.toList()); + vo.setAthleteList(athleteList); + + // 获取项目信息(从选手的项目ID中去重) + List projectIds = athletes.stream() + .map(MartialAthlete::getProjectId) + .filter(projectId -> projectId != null) + .distinct() + .collect(Collectors.toList()); + + if (!projectIds.isEmpty()) { + List projects = projectService.listByIds(projectIds); + + // 设置项目名称列表 + String projectNames = projects.stream() + .map(MartialProject::getProjectName) + .collect(Collectors.joining("、")); + vo.setProjectNames(projectNames); + + // 设置项目详细列表 + List projectList = projects.stream() + .map(project -> { + MartialRegistrationOrderVO.ProjectInfo info = new MartialRegistrationOrderVO.ProjectInfo(); + info.setId(project.getId()); + info.setProjectName(project.getProjectName()); + //类型(1-个人,2-双人,3-集体) + Integer type = project.getType(); + String strType = type == 1 ? "个人":"集体"; + info.setProjectType(strType); + return info; + }) + .collect(Collectors.toList()); + vo.setProjectList(projectList); + } + } + + return vo; + } + } diff --git a/src/main/java/org/springblade/modules/martial/service/impl/MartialScoreServiceImpl.java b/src/main/java/org/springblade/modules/martial/service/impl/MartialScoreServiceImpl.java index 651f46d..211cd8a 100644 --- a/src/main/java/org/springblade/modules/martial/service/impl/MartialScoreServiceImpl.java +++ b/src/main/java/org/springblade/modules/martial/service/impl/MartialScoreServiceImpl.java @@ -73,9 +73,14 @@ public class MartialScoreServiceImpl extends ServiceImpl