fix: 防止重复报名 - 个人项目和集体项目都添加重复检查
- 个人项目:检测到重复报名时返回错误而非更新 - 集体项目:添加重复报名检查 - 新增 /martial/athlete/registered API 用于查询已报名选手 Closes #3
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+23
@@ -1,5 +1,7 @@
|
||||
package org.springblade.modules.martial.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.qiniu.util.Auth;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -106,4 +108,25 @@ public class MartialAthleteController extends BladeController {
|
||||
return R.success("状态更新成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已报名选手列表(用于检查重复报名)
|
||||
*/
|
||||
@GetMapping("/registered")
|
||||
@Operation(summary = "获取已报名选手", description = "查询指定赛事和项目的已报名选手")
|
||||
public R<List<MartialAthlete>> getRegisteredAthletes(
|
||||
@RequestParam Long competitionId,
|
||||
@RequestParam(required = false) String projectIds) {
|
||||
LambdaQueryWrapper<MartialAthlete> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MartialAthlete::getCompetitionId, competitionId)
|
||||
.eq(MartialAthlete::getIsDeleted, 0)
|
||||
.eq(MartialAthlete::getRegistrationStatus, 1);
|
||||
|
||||
if (Func.isNotBlank(projectIds)) {
|
||||
wrapper.in(MartialAthlete::getProjectId, Func.toLongList(projectIds));
|
||||
}
|
||||
|
||||
List<MartialAthlete> list = athleteService.list(wrapper);
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+16
-7
@@ -329,6 +329,19 @@ public class MartialRegistrationOrderController extends BladeController {
|
||||
|
||||
// Create a record for each project
|
||||
for (Long projectId : projectIds) {
|
||||
// Check if team already registered for this project
|
||||
LambdaQueryWrapper<MartialAthlete> teamCheckWrapper = new LambdaQueryWrapper<>();
|
||||
teamCheckWrapper.eq(MartialAthlete::getCompetitionId, dto.getCompetitionId())
|
||||
.eq(MartialAthlete::getProjectId, projectId)
|
||||
.eq(MartialAthlete::getTeamName, team.getTeamName())
|
||||
.eq(MartialAthlete::getIsDeleted, 0);
|
||||
MartialAthlete existingTeamRecord = athleteService.getOne(teamCheckWrapper, false);
|
||||
|
||||
if (existingTeamRecord != null) {
|
||||
log.warn("集体重复报名: teamName={}, projectId={}", team.getTeamName(), projectId);
|
||||
return R.fail("集体 " + team.getTeamName() + " 已报名该项目,请勿重复报名");
|
||||
}
|
||||
|
||||
MartialAthlete teamAthlete = new MartialAthlete();
|
||||
teamAthlete.setOrderId(orderId);
|
||||
teamAthlete.setCompetitionId(dto.getCompetitionId());
|
||||
@@ -368,13 +381,9 @@ public class MartialRegistrationOrderController extends BladeController {
|
||||
MartialAthlete existingRecord = athleteService.getOne(checkWrapper, false);
|
||||
|
||||
if (existingRecord != null) {
|
||||
// Update existing record with order info
|
||||
existingRecord.setOrderId(orderId);
|
||||
existingRecord.setRegistrationStatus(1);
|
||||
existingRecord.setUpdateUser(AuthUtil.getUserId());
|
||||
existingRecord.setUpdateTime(new java.util.Date());
|
||||
athleteService.updateById(existingRecord);
|
||||
log.info("更新已存在的选手参赛记录: playerName={}, projectId={}", existingAthlete.getPlayerName(), projectId);
|
||||
// Reject duplicate registration
|
||||
log.warn("选手重复报名: playerName={}, projectId={}", existingAthlete.getPlayerName(), projectId);
|
||||
return R.fail("选手 " + existingAthlete.getPlayerName() + " 已报名该项目,请勿重复报名");
|
||||
} else {
|
||||
// Create new record
|
||||
MartialAthlete newRecord = new MartialAthlete();
|
||||
|
||||
Reference in New Issue
Block a user