From f00c4725c4a294dac50b963783fc108fa8ac2fde Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Wed, 10 Jan 2024 17:57:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=96=B0=E5=A2=9E=E6=8A=A5?= =?UTF-8?q?=E5=90=8D=E4=BA=BA=E5=91=98=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompetitionRegistrationController.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/competition/src/main/java/com/huoran/competition/controller/CompetitionRegistrationController.java b/competition/src/main/java/com/huoran/competition/controller/CompetitionRegistrationController.java index b889b9e..aa5e47d 100644 --- a/competition/src/main/java/com/huoran/competition/controller/CompetitionRegistrationController.java +++ b/competition/src/main/java/com/huoran/competition/controller/CompetitionRegistrationController.java @@ -1,6 +1,7 @@ package com.huoran.competition.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.huoran.common.aop.annotation.NoRepeatSubmit; import com.huoran.common.response.R; import com.huoran.common.utils.TokenUtils; @@ -115,19 +116,35 @@ public class CompetitionRegistrationController { } + //校验是否已经报名活动 + public boolean isRegistered(Integer accountId, Integer competitionId) { + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("account_id", accountId); + queryWrapper.eq("competition_id", competitionId); + CompetitionRegistration competitionRegistration = competitionRegistrationService.getOne(queryWrapper); + return competitionRegistration != null; + } + + @ApiOperation(value = "后台-新增报名人员(这里的账号id必传,根据手机号带出的账号信息选中)") @PostMapping("/addNewApplicantsInTheBackground") public R addNewApplicantsInTheBackground(@ApiParam(name = "competitionRegistration", value = "报名人员对象", required = true) @RequestBody CompetitionRegistration competitionRegistration) { if (ObjectUtils.isEmpty(competitionRegistration.getAccountId())) { return R.error("账号id不能为空"); } + //校验是否已经报名活动过 + if (isRegistered(competitionRegistration.getAccountId(), competitionRegistration.getCompetitionId())) { + return R.error("该账号已报名该活动"); + } boolean flag = competitionRegistrationService.save(competitionRegistration); return flag ? R.ok() : R.error("新增失败"); } @ApiOperation(value = "后台-报名人员详情(必填,列表返回的账号id)", response = RegistrationNewInformationBroughtOutVO.class) @PostMapping("/detailsOfApplicants") - public R detailsOfApplicants(@ApiParam(name = "accountId", value = "账号id(列表返回的账号id)", required = true) @RequestParam("accountId") Integer accountId, @ApiParam(name = "competitionId", value = "活动id", required = true) @RequestParam("accountId") String competitionId) { + public R detailsOfApplicants(@ApiParam(name = "accountId", value = "账号id(列表返回的账号id)", required = true) @RequestParam("accountId") Integer accountId, + @ApiParam(name = "competitionId", value = "活动id", required = true) @RequestParam("competitionId") String competitionId) { if (ObjectUtils.isEmpty(accountId)) { return R.error("账号id不能为空"); } @@ -145,6 +162,10 @@ public class CompetitionRegistrationController { if (ObjectUtils.isEmpty(info.getCompetitionId())) { return R.error("活动id不能为空"); } + //校验是否已经报名活动过 + if (isRegistered(info.getAccountId(), info.getCompetitionId())) { + return R.error("该账号已报名该活动"); + } boolean flag = true; //获取原报名信息 CompetitionRegistration registration = competitionRegistrationService.getById(info.getId());