diff --git a/competition/src/main/java/com/huoran/competition/controller/CompetitionController.java b/competition/src/main/java/com/huoran/competition/controller/CompetitionController.java index 3a8b09a..cce2e03 100644 --- a/competition/src/main/java/com/huoran/competition/controller/CompetitionController.java +++ b/competition/src/main/java/com/huoran/competition/controller/CompetitionController.java @@ -145,7 +145,7 @@ public class CompetitionController { return R.ok(); } - @ApiOperation(value = "根据id查询活动", response = Competition.class) + @ApiOperation(value = "活动详情", response = Competition.class) @PostMapping("/getCompetition") public R getCompetition(@ApiParam(name = "competitionId", value = "活动ID", required = true) @RequestParam("competitionId") String competitionId, HttpServletRequest request) { String accountId = TokenUtils.getIdByJwtToken(request); @@ -155,6 +155,11 @@ public class CompetitionController { wrapper.eq("competition_id", competitionId); wrapper.eq("account_id", accountId); CompetitionRegistration registration = competitionRegistrationService.getOne(wrapper); + competition.setApplicantNum(competitionRegistrationService.registrationPopulation(competitionId)); + + + + if (registration != null) { CompetitionTeam team = competitionTeamService.getById(registration.getTeamId()); if (team != null) { 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 28e2557..04a26ea 100644 --- a/competition/src/main/java/com/huoran/competition/controller/CompetitionRegistrationController.java +++ b/competition/src/main/java/com/huoran/competition/controller/CompetitionRegistrationController.java @@ -51,8 +51,8 @@ public class CompetitionRegistrationController { @NoRepeatSubmit @ApiOperation(value = "个人活动报名") - @PostMapping("/addCompetitionRegistration") - public R addCompetitionRegistration( + @PostMapping("/individualEventRegistration") + public R individualEventRegistration( @ApiParam(name = "competitionRegistration", value = "报名人员对象", required = true) @RequestBody CompetitionRegistration competitionRegistration, HttpServletRequest request) { if (competitionRegistration.getAccountId()==null){ diff --git a/competition/src/main/java/com/huoran/competition/entity/Competition.java b/competition/src/main/java/com/huoran/competition/entity/Competition.java index f97893b..c9c2eb4 100644 --- a/competition/src/main/java/com/huoran/competition/entity/Competition.java +++ b/competition/src/main/java/com/huoran/competition/entity/Competition.java @@ -124,7 +124,9 @@ public class Competition implements Serializable { - + @ApiModelProperty(value = "报名人数") + @TableField(exist = false) + private Integer applicantNum; @ApiModelProperty(value = "赛制") @TableField(exist = false) diff --git a/competition/src/main/java/com/huoran/competition/entity/CompetitionRegistration.java b/competition/src/main/java/com/huoran/competition/entity/CompetitionRegistration.java index 33800a9..263f605 100644 --- a/competition/src/main/java/com/huoran/competition/entity/CompetitionRegistration.java +++ b/competition/src/main/java/com/huoran/competition/entity/CompetitionRegistration.java @@ -34,9 +34,6 @@ public class CompetitionRegistration implements Serializable { @ApiModelProperty(value = "活动主键Id(c_competition表主键)") private Integer competitionId; - @ApiModelProperty(value = "用户主键Id") - private Integer userId; - @ApiModelProperty(value = "是否禁用(0未禁用,1禁用)") private Integer isDisable; @@ -44,32 +41,15 @@ public class CompetitionRegistration implements Serializable { @TableField(exist = false) private String registrationInvitationCode; - @ApiModelProperty("内部标识") + @ApiModelProperty("内部标识(默认为0,内部添加为1)") private Integer identification; - @ApiModelProperty(value = "用户名称") - private String username; - - @ApiModelProperty(value = "学校名称") - private String school; - - @ApiModelProperty(value = "账号") - private Integer account; - - @ApiModelProperty(value = "手机号") - private String phone; - @ApiModelProperty(value = "账号id") private Integer accountId; - @ApiModelProperty(value = "学号") - private Integer workNumber; - @ApiModelProperty(value = "团队id,默认为0无团队") private Integer teamId; - @TableField(exist = false) - private boolean join; @ApiModelProperty(value = "创建时间") @TableField(fill = FieldFill.INSERT) diff --git a/competition/src/main/java/com/huoran/competition/entity/vo/CompetitionVO.java b/competition/src/main/java/com/huoran/competition/entity/vo/CompetitionVO.java index dc1d715..9ecee45 100644 --- a/competition/src/main/java/com/huoran/competition/entity/vo/CompetitionVO.java +++ b/competition/src/main/java/com/huoran/competition/entity/vo/CompetitionVO.java @@ -147,5 +147,10 @@ public class CompetitionVO implements Serializable { @ApiModelProperty(value = "创建来源(0默认平台创建)") private String createSource; + @ApiModelProperty(value = "数量上限限制") + private Integer quantityLimit; + + @ApiModelProperty(value = "是否展示报名人员(0否,1是)") + private String whetherToShowApplicants; } diff --git a/competition/src/main/java/com/huoran/competition/entity/vo/RegistrationVO.java b/competition/src/main/java/com/huoran/competition/entity/vo/RegistrationVO.java index 205e08e..4bd0829 100644 --- a/competition/src/main/java/com/huoran/competition/entity/vo/RegistrationVO.java +++ b/competition/src/main/java/com/huoran/competition/entity/vo/RegistrationVO.java @@ -40,6 +40,9 @@ public class RegistrationVO { @Excel(name = "团队名称", orderNum = "7", mergeVertical = true, isImportField = "teamName", width = 30) private String teamName; + @ApiModelProperty(value = "头像") + private String userAvatars; + @ApiModelProperty(value = "团队id") private Integer teamId; diff --git a/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionMapper.xml b/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionMapper.xml index 89fd5d3..286ac62 100644 --- a/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionMapper.xml +++ b/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionMapper.xml @@ -649,6 +649,12 @@ c.publish_status, c.play_start_time, c.play_end_time, + c.sign_up_start_time, + c.sign_up_end_time, + c.is_need_code, + c.invitation_code, + c.quantity_limit, + c.whether_to_show_applicants, c.create_time, c.sponsor, IFNULL( @@ -657,7 +663,7 @@ ) AS applicant_num, c.is_open, create_source, - ( CASE create_source WHEN 0 THEN '平台创建' WHEN 1 THEN '组织创建' ELSE '无' end) as createSource, + ( CASE create_source WHEN 0 THEN '平台创建' WHEN 1 THEN '组织创建' ELSE '无' END ) AS createSource, IF ( ( SELECT r.id FROM c_competition_registration r WHERE r.competition_id = c.id AND r.account_id = #{req.accountId} ) IS NULL, @@ -705,6 +711,12 @@ c.publish_status, c.play_start_time, c.play_end_time, + c.sign_up_start_time, + c.sign_up_end_time, + c.is_need_code, + c.invitation_code, + c.quantity_limit, + c.whether_to_show_applicants, c.create_time, c.sponsor, IFNULL( diff --git a/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionRegistrationMapper.xml b/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionRegistrationMapper.xml index fd58202..dfe48b9 100644 --- a/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionRegistrationMapper.xml +++ b/competition/src/main/java/com/huoran/competition/mapper/xml/CompetitionRegistrationMapper.xml @@ -39,6 +39,7 @@ u.user_name AS username, u.user_id, qa.account_id, + u.user_avatars, qa.create_time, qa.identification,ct.team_name,ct.captain, CASE diff --git a/competition/src/main/java/com/huoran/competition/service/CompetitionRegistrationService.java b/competition/src/main/java/com/huoran/competition/service/CompetitionRegistrationService.java index 281a1b0..ebf66a2 100644 --- a/competition/src/main/java/com/huoran/competition/service/CompetitionRegistrationService.java +++ b/competition/src/main/java/com/huoran/competition/service/CompetitionRegistrationService.java @@ -36,4 +36,6 @@ public interface CompetitionRegistrationService extends IService setupQueryWrapper = new QueryWrapper<>(); + /*QueryWrapper setupQueryWrapper = new QueryWrapper<>(); setupQueryWrapper.eq("competition_id", contestId); CompleteCompetitionSetup setup = completeCompetitionSetupMapper.selectOne(setupQueryWrapper); //团队赛类型 @@ -113,7 +114,7 @@ public class CompetitionRegistrationServiceImpl extends ServiceImpl setupQueryWrapper = new QueryWrapper<>(); - setupQueryWrapper.eq("competition_id", competitionRegistration.getCompetitionId()); - CompleteCompetitionSetup setup = completeCompetitionSetupMapper.selectOne(setupQueryWrapper); - //团队赛限制验证 - if (setup.getCompetitionType() == 1) { - if (competitionRegistration.getTeamId() != null) { - //团队数量限制 - if (setup.getQuantityLimit() != null) { - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("competition_id", competitionRegistration.getCompetitionId()); - wrapper.groupBy("team_id"); - List competitionRegistrations = baseMapper.selectList(wrapper); - if (competitionRegistrations != null && competitionRegistration.isJoin() && competitionRegistrations.size() >= setup.getQuantityLimit()) { - throw new CustomException(ExceptionEnum.TEAM_LIMIT2); - } - } - //团队人数限制 - if (setup.getMaxTeamSize() != null) { - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("competition_id", competitionRegistration.getCompetitionId()); - wrapper.eq("team_id", competitionRegistration.getTeamId()); - List competitionRegistrations = baseMapper.selectList(wrapper); - if (competitionRegistrations != null && competitionRegistration.isJoin() && competitionRegistrations.size() >= setup.getMaxTeamSize()) { - throw new CustomException(ExceptionEnum.TEAM_LIMIT1); - } - } - } + Competition competition = competitionMapper.selectById(competitionRegistration.getCompetitionId()); + - } else { //个人赛人数限制 - if (setup.getQuantityLimit() != null) { + if (competition.getQuantityLimit() != null) { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq("competition_id", competitionRegistration.getCompetitionId()); List competitionRegistrations = baseMapper.selectList(wrapper); - if (competitionRegistrations != null && competitionRegistrations.size() >= setup.getQuantityLimit()) { + if (competitionRegistrations != null && competitionRegistrations.size() >= competition.getQuantityLimit()) { throw new CustomException(ExceptionEnum.TEAM_LIMIT3); } } - } //内部添加,一路绿灯 + QueryWrapper wrapper = getCompetitionRegistrationQueryWrapper(competitionRegistration, competition); + int count = baseMapper.selectCount(wrapper); + //添加前判断是否已报名 + if (count > 0) { + throw new CustomException(ExceptionEnum.HAVE_BEEN_REGISTERED); + } else { + int save = baseMapper.insert(competitionRegistration); + return save > 0 ? R.ok() : R.error(); + } + } + + @NotNull + private static QueryWrapper getCompetitionRegistrationQueryWrapper(CompetitionRegistration competitionRegistration, Competition competition) { if (competitionRegistration.getIdentification() == null || competitionRegistration.getIdentification() != 1) { //是否需要报名邀请码 - Integer code = setup.getIsNeedCode(); + Integer code = competition.getIsNeedCode(); if (code == 1) { //验证报名邀请码 - if (!setup.getInvitationCode().equals(competitionRegistration.getRegistrationInvitationCode())) { + if (!competition.getInvitationCode().equals(competitionRegistration.getRegistrationInvitationCode())) { throw new CustomException(ExceptionEnum.CODE); } } @@ -251,37 +237,7 @@ public class CompetitionRegistrationServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>(); wrapper.eq("account_id", accountId); wrapper.eq("competition_id", competitionId); - int count = baseMapper.selectCount(wrapper); - //添加前判断是否已报名 - if (count > 0) { - throw new CustomException(ExceptionEnum.HAVE_BEEN_REGISTERED); - } else { - Competition competition = competitionMapper.selectById(competitionId); - //活动范围(0:本校内 1:全平台 2:指定区域、院校) - /*if (competition.getCompetitionScope() == 2) { - Integer schoolId = userClient.getSchoolIdByAccountId(accountId.toString()); - //拿到当前用户所在学校省市信息 - School school = this.getSchool(schoolId); - if (school!=null){ - boolean check = competitionRangeService.checkWhetherToParticipate(school, competitionId); - if (check) { - throw new CustomException(ExceptionEnum.UNABLE_TO_REGISTER); - } - } - }*/ - //报名成功后每个阶段添加为默认参数人员 - List competitionStages = competitionStageMapper.selectCompetitionStageBySetupId(setup.getSetupId()); - for (CompetitionStage competitionStage : competitionStages) { - TeamParticipant teamParticipant = new TeamParticipant(); - teamParticipant.setTeamId(competitionRegistration.getTeamId()); - teamParticipant.setStageId(competitionStage.getStageId()); - teamParticipant.setCompetitionId(competitionRegistration.getCompetitionId()); - teamParticipant.setAccountId(accountId); - teamParticipantService.save(teamParticipant); - } - int save = baseMapper.insert(competitionRegistration); - return save > 0 ? R.ok() : R.error(); - } + return wrapper; } @Override @@ -292,4 +248,12 @@ public class CompetitionRegistrationServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("competition_id", competitionId); + List competitionRegistrations = baseMapper.selectList(queryWrapper); + return competitionRegistrations.size(); + } }