BUGFIX: workspace删除校验;
This commit is contained in:
@@ -81,8 +81,8 @@ public class WorkspaceController {
|
|||||||
@DeleteMapping("/remove")
|
@DeleteMapping("/remove")
|
||||||
@ApiOperationSupport(order = 4)
|
@ApiOperationSupport(order = 4)
|
||||||
@ApiOperation(value = "删除", notes = "传入id")
|
@ApiOperation(value = "删除", notes = "传入id")
|
||||||
public Response remove(@Valid @RequestBody List<Workspace> workspaceList) {
|
public Response<List<Long>> remove(@Valid @RequestBody List<Workspace> workspaceList) {
|
||||||
return Response.success(workspaceService.removeBatchByIds(workspaceList));
|
return Response.success(workspaceService.delete(workspaceList));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/enumValues")
|
@GetMapping("/enumValues")
|
||||||
|
|||||||
@@ -45,4 +45,6 @@ public interface WorkspaceService extends IService<Workspace> {
|
|||||||
void moveFile();
|
void moveFile();
|
||||||
|
|
||||||
void maleDataInsert() throws FileNotFoundException;
|
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.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
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 {
|
// public static void main(String[] args) throws FileNotFoundException {
|
||||||
// String b = "C:\\workspace\\fileData\\aida_men_library\\top\\mens_test_9992.png";
|
// String b = "C:\\workspace\\fileData\\aida_men_library\\top\\mens_test_9992.png";
|
||||||
// File pngFile = new File(b);
|
// File pngFile = new File(b);
|
||||||
|
|||||||
Reference in New Issue
Block a user