完善新增报名人员校验

main
rong.liu 11 months ago
parent f00c4725c4
commit b55cd503bd
  1. 1
      common/src/main/java/com/huoran/common/utils/TokenUtils.java
  2. 34
      competition/src/main/java/com/huoran/competition/controller/CompetitionRegistrationController.java
  3. 2
      competition/src/main/java/com/huoran/competition/entity/CompetitionRegistration.java

@ -38,6 +38,7 @@ public class TokenUtils {
*/ */
public static String getIdByJwtToken(HttpServletRequest request) { public static String getIdByJwtToken(HttpServletRequest request) {
String jwtToken = request.getHeader("token"); String jwtToken = request.getHeader("token");
System.out.println("------------------------------->>>TOKEN-------------"+jwtToken);
if(StringUtils.isEmpty(jwtToken)) { if(StringUtils.isEmpty(jwtToken)) {
return ""; return "";
} }

@ -9,7 +9,9 @@ import com.huoran.competition.entity.CompetitionRegistration;
import com.huoran.competition.entity.req.PageRegistrationStaffReq; import com.huoran.competition.entity.req.PageRegistrationStaffReq;
import com.huoran.competition.entity.vo.RegistrationNewInformationBroughtOutVO; import com.huoran.competition.entity.vo.RegistrationNewInformationBroughtOutVO;
import com.huoran.competition.entity.vo.RegistrationVO; import com.huoran.competition.entity.vo.RegistrationVO;
import com.huoran.competition.mapper.CompetitionRegistrationMapper;
import com.huoran.competition.service.CompetitionRegistrationService; import com.huoran.competition.service.CompetitionRegistrationService;
import com.huoran.competition.service.impl.CompetitionRegistrationServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
@ -21,6 +23,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
@ -38,6 +41,9 @@ public class CompetitionRegistrationController {
@Autowired @Autowired
private CompetitionRegistrationService competitionRegistrationService; private CompetitionRegistrationService competitionRegistrationService;
@Autowired
private CompetitionRegistrationMapper competitionRegistrationMapper;
@NoRepeatSubmit @NoRepeatSubmit
@ApiOperation(value = "是否禁用报名人员") @ApiOperation(value = "是否禁用报名人员")
@PutMapping("/disableRegistration") @PutMapping("/disableRegistration")
@ -158,21 +164,39 @@ public class CompetitionRegistrationController {
if (ObjectUtils.isEmpty(info.getAccountId())) { if (ObjectUtils.isEmpty(info.getAccountId())) {
return R.error("账号id不能为空"); return R.error("账号id不能为空");
} }
//获取原报名信息
CompetitionRegistration registration = competitionRegistrationService.getById(info.getId());
//判断活动id不能为空 //判断活动id不能为空
if (ObjectUtils.isEmpty(info.getCompetitionId())) { if (ObjectUtils.isEmpty(info.getCompetitionId())) {
return R.error("活动id不能为空"); return R.error("活动id不能为空");
} }
//校验是否已经报名活动过 //校验是否已经报名活动过(用于防止该用户本来为个人账号报名了该活动,后认证企业账号后又报名活动,防止通过后台编辑更改当前所属组织架构为个人或组织时候就需判重)
if (isRegistered(info.getAccountId(), info.getCompetitionId())) { //当前处理方法为:如果当前活动下,用户多个角色下都已参加报名活动,通过后台不能做编辑更改组织的情况
return R.error("该账号已报名该活动"); //如果当前活动下,用户只有一个角色下都已参加报名活动,通过后台可以更改组织的情况
List<RegistrationNewInformationBroughtOutVO> role = competitionRegistrationMapper.getOrganizationalInformation(null, info.getAccountId());
if (!ObjectUtils.isEmpty(role)) {
QueryWrapper<CompetitionRegistration> queryWrapper = new QueryWrapper<>();
//查询role里面全部accountId
queryWrapper.in("account_id", role.stream().map(RegistrationNewInformationBroughtOutVO::getAccountId).collect(Collectors.toList()));
List<CompetitionRegistration> list = competitionRegistrationService.list(queryWrapper);
if (!ObjectUtils.isEmpty(list)){
return R.error("当前用户已在该角色下报名该活动,请勿重复操作报名!");
}
} }
boolean flag = true; boolean flag = true;
//获取原报名信息
CompetitionRegistration registration = competitionRegistrationService.getById(info.getId());
if (!ObjectUtils.isEmpty(registration)) { if (!ObjectUtils.isEmpty(registration)) {
//需求:如果时间被清空情况下,签到状态变更为未签到 //需求:如果时间被清空情况下,签到状态变更为未签到
if (ObjectUtils.isEmpty(info.getSignInTime())) { if (ObjectUtils.isEmpty(info.getSignInTime())) {
registration.setSignInStatus(String.valueOf(2)); registration.setSignInStatus(String.valueOf(2));
}else if (!ObjectUtils.isEmpty(registration.getSignInTime())){
registration.setSignInStatus(String.valueOf(1));//有签到时间设置签到状态
} }
//判断如果账号id不等于原登记的账户id,则账号id做更改 //判断如果账号id不等于原登记的账户id,则账号id做更改

@ -60,7 +60,7 @@ public class CompetitionRegistration implements Serializable {
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime; private Date updateTime;
@ApiModelProperty(value = "签到情况(签到状态(0待签到 1.已签到 2未签到:活动结束后没签到的))") @ApiModelProperty(value = "签到情况(签到状态(0待签到 1.已签到 2未签到))")
private String signInStatus; private String signInStatus;

Loading…
Cancel
Save