|
@@ -85,13 +85,21 @@ public class SysFileCategoryServiceImpl implements SysFileCategoryService {
|
|
|
public Map<String, Object> updateFileCategoryBatch(List<SysFileCategory> sysFileCategoryList) {
|
|
|
|
|
|
// 手动校验参数
|
|
|
- if (sysFileCategoryList.size() > 20) throw new CustException("批量编辑数量不大于: 20");
|
|
|
- sysFileCategoryList.stream().forEach(item -> {
|
|
|
- if (item.getCategory_name() != null && item.getCategory_name().isEmpty()) throw new CustException("文件分类名称不能为空");
|
|
|
- if (item.getCategory_name() != null && item.getCategory_name().length() > 50) throw new CustException("文件分类名称长度不超过 50 字符");
|
|
|
- if (item.getSort() != null && (item.getSort() < 1 || item.getSort() > 9999)) throw new CustException("排序必须在 1 到 9999 之间");
|
|
|
- if (item.getStatus() != null && item.getStatus() != 1 && item.getStatus() != -1) throw new CustException("状态取值有误,范围应是(-1禁用, 1启用)");
|
|
|
- });
|
|
|
+ if (sysFileCategoryList.size() > 20) {
|
|
|
+ throw new CustException("批量编辑数量不大于: 20");
|
|
|
+ }
|
|
|
+ if (sysFileCategoryList.size() > 0) {
|
|
|
+ sysFileCategoryList.stream().forEach(item -> {
|
|
|
+ if (item.getCategory_name() != null && item.getCategory_name().isEmpty())
|
|
|
+ throw new CustException("文件分类名称不能为空");
|
|
|
+ if (item.getCategory_name() != null && item.getCategory_name().length() > 50)
|
|
|
+ throw new CustException("文件分类名称长度不超过 50 字符");
|
|
|
+ if (item.getSort() != null && (item.getSort() < 1 || item.getSort() > 9999))
|
|
|
+ throw new CustException("排序必须在 1 到 9999 之间");
|
|
|
+ if (item.getStatus() != null && item.getStatus() != 1 && item.getStatus() != -1)
|
|
|
+ throw new CustException("状态取值有误,范围应是(-1禁用, 1启用)");
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
// 获得当前用户ID
|
|
|
Long user_id = SecurityUtil.getUserId();
|
|
@@ -178,10 +186,12 @@ public class SysFileCategoryServiceImpl implements SysFileCategoryService {
|
|
|
|
|
|
|
|
|
// [DB] 批量更新
|
|
|
- System.out.println("updateByIdBatch: " + sysFileCategoryList);
|
|
|
- sysFileCategoryDao.updateByIdBatch(sysFileCategoryList);
|
|
|
- String updateIdSetStr = updateIdSetNoNull.stream().map(String::valueOf).collect(Collectors.joining(", "));
|
|
|
- message += "更新了 Id: " + updateIdSetStr;
|
|
|
+ if (sysFileCategoryList.size() > 0) {
|
|
|
+ System.out.println("updateByIdBatch: " + sysFileCategoryList);
|
|
|
+ sysFileCategoryDao.updateByIdBatch(sysFileCategoryList);
|
|
|
+ String updateIdSetStr = updateIdSetNoNull.stream().map(String::valueOf).collect(Collectors.joining(", "));
|
|
|
+ message += "更新了 Id: " + updateIdSetStr;
|
|
|
+ }
|
|
|
|
|
|
// 返回值
|
|
|
Map<String, Object> response = new LinkedHashMap<>();
|