|
@@ -75,19 +75,7 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
|
|
|
public void add(TempLittleArtistTrainingCampDto dto) {
|
|
|
SysUser user = getUser();
|
|
|
Date now = DateUtil.toDate(LocalDate.now().toString());
|
|
|
- if (dto.getApplyEndDate().getTime() < now.getTime()) {
|
|
|
- throw new BizException("报名结束时间不能小于今天");
|
|
|
- }
|
|
|
- if (dto.getApplyStartDate().getTime() > dto.getApplyEndDate().getTime()) {
|
|
|
- throw new BizException("报名开始时间不能大于结束时间");
|
|
|
- }
|
|
|
- if (dto.getTrainStartDate().getTime() > dto.getTrainEndDate().getTime()) {
|
|
|
- throw new BizException("训练开始时间不能大于训练结束时间");
|
|
|
- }
|
|
|
- //报名结束时间必需小于训练开始时间
|
|
|
- if (dto.getTrainStartDate().getTime() < dto.getApplyEndDate().getTime()) {
|
|
|
- throw new BizException("报名结束时间必需小于训练开始时间");
|
|
|
- }
|
|
|
+ checkDateTime(dto, now);
|
|
|
TempLittleArtistTrainingCamp entity = new TempLittleArtistTrainingCamp();
|
|
|
BeanUtils.copyProperties(dto, entity);
|
|
|
entity.setState(TempLittleArtistTrainingCamp.NOT_START);
|
|
@@ -107,9 +95,16 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
|
|
|
@Override
|
|
|
public void update(TempLittleArtistTrainingCampDto dto) {
|
|
|
SysUser user = getUser();
|
|
|
+ Date now = DateUtil.toDate(LocalDate.now().toString());
|
|
|
+ checkDateTime(dto, now);
|
|
|
TempLittleArtistTrainingCamp entity = Optional.ofNullable(dto.getId())
|
|
|
.map(this::getById)
|
|
|
.orElseThrow(() -> new BizException("训练营不存在"));
|
|
|
+ int count = tempLittleArtistTrainingCampUserRelationService.count(Wrappers.<TempLittleArtistTrainingCampUserRelation>lambdaQuery()
|
|
|
+ .eq(TempLittleArtistTrainingCampUserRelation::getActivityId, entity.getId()));
|
|
|
+ if (count > 0) {
|
|
|
+ throw new BizException("训练营已有学生报名,无法删除");
|
|
|
+ }
|
|
|
entity.setName(dto.getName());
|
|
|
entity.setApplyStartDate(dto.getApplyStartDate());
|
|
|
entity.setApplyEndDate(dto.getApplyEndDate());
|
|
@@ -122,6 +117,25 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 校验时间
|
|
|
+ */
|
|
|
+ private void checkDateTime(TempLittleArtistTrainingCampDto dto, Date now) {
|
|
|
+ if (dto.getApplyEndDate().getTime() < now.getTime()) {
|
|
|
+ throw new BizException("报名结束时间不能小于今天");
|
|
|
+ }
|
|
|
+ if (dto.getApplyStartDate().getTime() > dto.getApplyEndDate().getTime()) {
|
|
|
+ throw new BizException("报名开始时间不能大于结束时间");
|
|
|
+ }
|
|
|
+ if (dto.getTrainStartDate().getTime() > dto.getTrainEndDate().getTime()) {
|
|
|
+ throw new BizException("训练开始时间不能大于训练结束时间");
|
|
|
+ }
|
|
|
+ //报名结束时间必需小于训练开始时间
|
|
|
+ if (dto.getTrainStartDate().getTime() < dto.getApplyEndDate().getTime()) {
|
|
|
+ throw new BizException("报名结束时间必需小于训练开始时间");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 删除训练营
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -130,6 +144,11 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
|
|
|
TempLittleArtistTrainingCamp entity = Optional.ofNullable(id)
|
|
|
.map(this::getById)
|
|
|
.orElseThrow(() -> new BizException("训练营不存在"));
|
|
|
+ int count = tempLittleArtistTrainingCampUserRelationService.count(Wrappers.<TempLittleArtistTrainingCampUserRelation>lambdaQuery()
|
|
|
+ .eq(TempLittleArtistTrainingCampUserRelation::getActivityId, entity.getId()));
|
|
|
+ if (count > 0) {
|
|
|
+ throw new BizException("训练营已有学生报名,无法删除");
|
|
|
+ }
|
|
|
entity.setDelFlag(1);
|
|
|
this.updateById(entity);
|
|
|
}
|
|
@@ -295,15 +314,14 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
result.put("user", userRelation);
|
|
|
if (CollectionUtils.isNotEmpty(campList)) {
|
|
|
- campList.sort(Comparator.comparing(TempLittleArtistTrainingCamp::getApplyStartDate));
|
|
|
- }
|
|
|
- if (CollectionUtils.isNotEmpty(campList)) {
|
|
|
- campList.forEach(a -> {
|
|
|
- int count = tempLittleArtistTrainingCampUserRelationService.count(Wrappers.<TempLittleArtistTrainingCampUserRelation>lambdaQuery()
|
|
|
- .eq(TempLittleArtistTrainingCampUserRelation::getActivityId, a.getId())
|
|
|
- );
|
|
|
- a.setUserCount(count);
|
|
|
- });
|
|
|
+ campList = campList.stream()
|
|
|
+ .peek(a -> {
|
|
|
+ int count = tempLittleArtistTrainingCampUserRelationService.count(Wrappers.<TempLittleArtistTrainingCampUserRelation>lambdaQuery()
|
|
|
+ .eq(TempLittleArtistTrainingCampUserRelation::getActivityId, a.getId()));
|
|
|
+ a.setUserCount(count);
|
|
|
+ })
|
|
|
+ .sorted(Comparator.comparing(TempLittleArtistTrainingCamp::getApplyStartDate))
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
result.put("campList", campList);
|
|
|
return result;
|
|
@@ -445,23 +463,26 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
|
|
|
SysUser user = getUser();
|
|
|
//查询训练营人员关系
|
|
|
TempLittleArtistTrainingCampUserRelation campUser = tempLittleArtistTrainingCampUserRelationService.getOne(Wrappers.<TempLittleArtistTrainingCampUserRelation>lambdaQuery()
|
|
|
- .eq(TempLittleArtistTrainingCampUserRelation::getUserId, user.getId()));
|
|
|
+ .eq(TempLittleArtistTrainingCampUserRelation::getUserId, user.getId())
|
|
|
+ .eq(TempLittleArtistTrainingCampUserRelation::getState, TempLittleArtistTrainingCampUserRelation.APPLY)
|
|
|
+ );
|
|
|
if (Objects.isNull(campUser)) {
|
|
|
return null;
|
|
|
}
|
|
|
- //查询训练营
|
|
|
+ //查询在训练中的训练营
|
|
|
TempLittleArtistTrainingCamp camp = this.getOne(Wrappers.<TempLittleArtistTrainingCamp>lambdaQuery()
|
|
|
.eq(TempLittleArtistTrainingCamp::getId, campUser.getActivityId())
|
|
|
+ .eq(TempLittleArtistTrainingCamp::getState, TempLittleArtistTrainingCamp.ING)
|
|
|
.eq(TempLittleArtistTrainingCamp::getDelFlag, 0));
|
|
|
if (Objects.isNull(camp)) {
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
TempCampUserTrainingPlayTimeVo vo = new TempCampUserTrainingPlayTimeVo();
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
param.put("userId", user.getId());
|
|
|
- param.put("startTime", DateUtil.dateToString(camp.getTrainStartDate()) + " 00:00:00");
|
|
|
- param.put("endTime", DateUtil.dateToString(camp.getTrainEndDate()) + " 23:59:59");
|
|
|
+ param.put("startTime", now + " 00:00:00");
|
|
|
+ param.put("endTime", now + " 23:59:59");
|
|
|
Integer playTime = baseMapper.queryUserTrainingPlayTime(param);
|
|
|
vo.setPlayTime(playTime);
|
|
|
vo.setTrainStartDate(camp.getTrainStartDate());
|