|
|
@@ -50,7 +50,7 @@ public class ContestServiceImpl extends ServiceImpl<ContestMapper, Contest> impl
|
|
|
if (contest == null) {
|
|
|
return false;
|
|
|
}
|
|
|
- if (!"password".equals(contest.getType())) {
|
|
|
+ if (!Contest.TYPE_PASSWORD.equals(contest.getType())) {
|
|
|
return true;
|
|
|
}
|
|
|
return contest.getPassword() != null && contest.getPassword().equals(password);
|
|
|
@@ -112,7 +112,7 @@ public class ContestServiceImpl extends ServiceImpl<ContestMapper, Contest> impl
|
|
|
.eq(StringUtils.hasText(status), Contest::getStatus, status)
|
|
|
.orderByDesc(Contest::getId);
|
|
|
if (onlyPublic) {
|
|
|
- wrapper.eq(Contest::getType, "public");
|
|
|
+ wrapper.eq(Contest::getType, Contest.TYPE_PUBLIC);
|
|
|
}
|
|
|
Page<Contest> contestPage = page(page, wrapper);
|
|
|
Page<ContestVo> result = new Page<>(contestPage.getCurrent(), contestPage.getSize(), contestPage.getTotal());
|
|
|
@@ -126,7 +126,7 @@ public class ContestServiceImpl extends ServiceImpl<ContestMapper, Contest> impl
|
|
|
Contest contest = new Contest();
|
|
|
BeanUtils.copyProperties(dto, contest);
|
|
|
contest.setCreatedBy(createdBy);
|
|
|
- if (!"password".equals(contest.getType())) {
|
|
|
+ if (!Contest.TYPE_PASSWORD.equals(contest.getType())) {
|
|
|
contest.setPassword(null);
|
|
|
}
|
|
|
return save(contest);
|
|
|
@@ -142,7 +142,7 @@ public class ContestServiceImpl extends ServiceImpl<ContestMapper, Contest> impl
|
|
|
contest.setTitle(dto.getTitle());
|
|
|
contest.setDescription(dto.getDescription());
|
|
|
contest.setType(dto.getType());
|
|
|
- contest.setPassword("password".equals(dto.getType()) ? dto.getPassword() : null);
|
|
|
+ contest.setPassword(Contest.TYPE_PASSWORD.equals(dto.getType()) ? dto.getPassword() : null);
|
|
|
contest.setStartDatetime(dto.getStartDatetime());
|
|
|
contest.setEndDatetime(dto.getEndDatetime());
|
|
|
return updateById(contest);
|
|
|
@@ -205,7 +205,7 @@ public class ContestServiceImpl extends ServiceImpl<ContestMapper, Contest> impl
|
|
|
if (contest == null) {
|
|
|
throw new IllegalArgumentException("比赛不存在");
|
|
|
}
|
|
|
- if (!"pending".equals(contest.getStatus()) && !"running".equals(contest.getStatus())) {
|
|
|
+ if (!Contest.STATUS_PENDING.equals(contest.getStatus()) && !Contest.STATUS_RUNNING.equals(contest.getStatus())) {
|
|
|
throw new IllegalArgumentException("比赛未开始或已结束,无法报名");
|
|
|
}
|
|
|
Long count = contestRegistrationMapper.selectCount(new LambdaQueryWrapper<ContestRegistration>()
|
|
|
@@ -232,17 +232,17 @@ public class ContestServiceImpl extends ServiceImpl<ContestMapper, Contest> impl
|
|
|
public void refreshStatus() {
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
List<Contest> pendings = list(new LambdaQueryWrapper<Contest>()
|
|
|
- .eq(Contest::getStatus, "pending")
|
|
|
+ .eq(Contest::getStatus, Contest.STATUS_PENDING)
|
|
|
.le(Contest::getStartDatetime, now));
|
|
|
for (Contest contest : pendings) {
|
|
|
- contest.setStatus("running");
|
|
|
+ contest.setStatus(Contest.STATUS_RUNNING);
|
|
|
updateById(contest);
|
|
|
}
|
|
|
List<Contest> runnings = list(new LambdaQueryWrapper<Contest>()
|
|
|
- .eq(Contest::getStatus, "running")
|
|
|
+ .eq(Contest::getStatus, Contest.STATUS_RUNNING)
|
|
|
.le(Contest::getEndDatetime, now));
|
|
|
for (Contest contest : runnings) {
|
|
|
- contest.setStatus("ended");
|
|
|
+ contest.setStatus(Contest.STATUS_ENDED);
|
|
|
updateById(contest);
|
|
|
}
|
|
|
}
|