|
|
@ -1,17 +1,16 @@ |
|
|
package com.project.task.domain.service.impl; |
|
|
package com.project.task.domain.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import cn.hutool.core.date.DateUtil; |
|
|
import cn.hutool.core.date.DateUtil; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.project.base.domain.enums.StatusEnum; |
|
|
import com.project.base.domain.exception.BusinessErrorException; |
|
|
import com.project.base.domain.exception.BusinessErrorException; |
|
|
import com.project.base.domain.result.Result; |
|
|
import com.project.base.domain.result.Result; |
|
|
import com.project.task.domain.entity.TaskEntity; |
|
|
import com.project.task.domain.entity.TaskEntity; |
|
|
import com.project.task.domain.service.DeleteTaskDomainService; |
|
|
import com.project.task.domain.service.DeleteTaskDomainService; |
|
|
import com.project.task.domain.service.TaskBaseService; |
|
|
import com.project.task.domain.service.TaskBaseService; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
import java.util.Date; |
|
|
import java.util.Date; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
@ -20,19 +19,25 @@ public class DeleteTaskDomainServiceImpl implements DeleteTaskDomainService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private TaskBaseService taskBaseService; |
|
|
private TaskBaseService taskBaseService; |
|
|
@Override |
|
|
@Override |
|
|
public Result<String> batchDelete(String ids) throws Exception { |
|
|
public Result<String> batchDelete(List<Long> ids) throws Exception { |
|
|
if (StringUtils.isBlank(ids)) { |
|
|
if (CollUtil.isEmpty(ids)) { |
|
|
throw new BusinessErrorException("id不能为空"); |
|
|
throw new BusinessErrorException("id不能为空"); |
|
|
} |
|
|
} |
|
|
List<String> idList = Arrays.asList(ids.split(",")); |
|
|
|
|
|
long count = taskBaseService.lambdaQuery() |
|
|
long count = taskBaseService.lambdaQuery() |
|
|
.in(TaskEntity::getId, idList) |
|
|
.in(TaskEntity::getId, ids) |
|
|
.ge(TaskEntity::getStartTime, DateUtil.beginOfDay(new Date())) |
|
|
.ge(TaskEntity::getStartTime, DateUtil.beginOfDay(new Date())) |
|
|
.count(); |
|
|
.count(); |
|
|
if (count > 0) { |
|
|
if (count > 0) { |
|
|
throw new BusinessErrorException("已开考 、 已截止的考试任务不允许删除"); |
|
|
throw new BusinessErrorException("已开考 、 已截止的考试任务不允许删除"); |
|
|
} |
|
|
} |
|
|
taskBaseService.removeBatchByIds(idList); |
|
|
count = taskBaseService.lambdaQuery() |
|
|
|
|
|
.in(TaskEntity::getId, ids) |
|
|
|
|
|
.eq(TaskEntity::getDeleted , StatusEnum.Delete.getValue()) |
|
|
|
|
|
.count(); |
|
|
|
|
|
if (count > 0) { |
|
|
|
|
|
throw new BusinessErrorException("任务不存在或已被删除"); |
|
|
|
|
|
} |
|
|
|
|
|
taskBaseService.removeBatchByIds(ids); |
|
|
return Result.success("删除成功"); |
|
|
return Result.success("删除成功"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|