| | |
| | | wrapper.orderByDesc(Competition::getInsertTime); |
| | | |
| | | Page<Competition> page = cttService.page(competitionPage, wrapper); |
| | | for (Competition record : page.getRecords()) { |
| | | |
| | | // 查询当前赛事有多少人报名了 |
| | | List<UserCompetition> competitionId = ucttService.list(new QueryWrapper<UserCompetition>() |
| | | .eq("competitionId", record.getId())); |
| | | // 报名数量 |
| | | int temp = competitionId.size(); |
| | | String value = String.valueOf(temp); |
| | | record.setCount(record.getApplicantsNumber()+"-"+value); |
| | | } |
| | | return page; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | @PostMapping("/base/competition/add") |
| | | public void add(@RequestBody Competition competition){ |
| | | try { |
| | | if (competition.getStartTime().after(new Date())){ |
| | | competition.setStatus(1); |
| | | } |
| | | if (competition.getStartTime().before(new Date())){ |
| | | if (competition.getEndTime().after(new Date())){ |
| | | competition.setStatus(2); |
| | | }else{ |
| | | competition.setStatus(3); |
| | | } |
| | | } |
| | | competition.setInsertTime(new Date()); |
| | | cttService.save(competition); |
| | | }catch (Exception e){ |
| | |
| | | @PostMapping("/base/competition/update") |
| | | public void update(@RequestBody Competition competition){ |
| | | try { |
| | | if (competition.getStartTime().after(new Date())){ |
| | | competition.setStatus(1); |
| | | } |
| | | if (competition.getStartTime().before(new Date())){ |
| | | if (competition.getEndTime().after(new Date())){ |
| | | competition.setStatus(2); |
| | | }else{ |
| | | competition.setStatus(3); |
| | | } |
| | | } |
| | | cttService.updateById(competition); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |