BUGFIX: workspace删除校验;
This commit is contained in:
@@ -45,4 +45,6 @@ public interface WorkspaceService extends IService<Workspace> {
|
||||
void moveFile();
|
||||
|
||||
void maleDataInsert() throws FileNotFoundException;
|
||||
|
||||
List<Long> delete(List<Workspace> workspaceList);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -443,6 +444,21 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> delete(List<Workspace> workspaceList) {
|
||||
// 校验不能删除最后选择的workspace
|
||||
List<Long> deleteIds = workspaceList.stream().map(Workspace::getId).collect(Collectors.toList());
|
||||
QueryWrapper<Workspace> qw = new QueryWrapper<>();
|
||||
qw.lambda().in(Workspace::getId, deleteIds);
|
||||
qw.lambda().eq(Workspace::getIsLastIndex, 1);
|
||||
List<Workspace> workspaces = workspaceMapper.selectList(qw);
|
||||
if (!CollectionUtils.isEmpty(workspaces)) {
|
||||
throw new BusinessException("Unable to delete the workspace you last used");
|
||||
}
|
||||
workspaceMapper.deleteBatchIds(deleteIds);
|
||||
return deleteIds;
|
||||
}
|
||||
|
||||
// public static void main(String[] args) throws FileNotFoundException {
|
||||
// String b = "C:\\workspace\\fileData\\aida_men_library\\top\\mens_test_9992.png";
|
||||
// File pngFile = new File(b);
|
||||
|
||||
Reference in New Issue
Block a user