💩 改善代码, 通过 P3C 校验

This commit is contained in:
zhaojun1998
2019-12-21 12:08:24 +08:00
parent 0e6bcbfa11
commit 8e7d4432a3
58 changed files with 239 additions and 102 deletions

View File

@@ -29,6 +29,7 @@ import java.util.List;
/**
* 前台文件管理
* @author zhaojun
*/
@RequestMapping("/api")
@RestController
@@ -72,16 +73,16 @@ public class FileController {
fileItemList.sort(new FileComparator(sortBy, order));
filterFileList(fileItemList);
Integer total = fileItemList.size();
Integer totalPage = (total + PAGE_SIZE - 1) / PAGE_SIZE;
int total = fileItemList.size();
int totalPage = (total + PAGE_SIZE - 1) / PAGE_SIZE;
if (page > totalPage) {
return ResultBean.successData(new ArrayList<>());
}
Integer start = (page - 1) * PAGE_SIZE;
Integer end = page * PAGE_SIZE;
end = end > total ? total : end;
int start = (page - 1) * PAGE_SIZE;
int end = page * PAGE_SIZE;
end = Math.min(end, total);
List<FileItemDTO> fileSubItem = fileItemList.subList(start, end);
return ResultBean.successData(fileSubItem);
}