|
@@ -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);
|
|
|
}
|