|
@@ -25,6 +25,8 @@ import com.backendsys.utils.response.PageEntity;
|
|
|
import com.backendsys.utils.response.PageInfoResult;
|
|
|
import com.backendsys.utils.v2.PageUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -412,19 +414,16 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileDao, SysFile> impleme
|
|
|
Long category_id = sysFile.getCategory_id();
|
|
|
|
|
|
// 判断 文件分类ID 是否存在
|
|
|
- Boolean isExist = sysFileCategoryDao.exists(new LambdaQueryWrapper<SysFileCategory>().eq(SysFileCategory::getId, category_id));
|
|
|
- if (!isExist) throw new CustException("文件分类不存在");
|
|
|
+ if (category_id != null) {
|
|
|
+ Boolean isExist = sysFileCategoryDao.exists(new LambdaQueryWrapper<SysFileCategory>().eq(SysFileCategory::getId, category_id));
|
|
|
+ if (!isExist) throw new CustException("文件分类不存在");
|
|
|
+ }
|
|
|
|
|
|
// [DB] 批量更新 分类ID
|
|
|
- SysFile entity = new SysFile();
|
|
|
- entity.setCategory_id(category_id);
|
|
|
-
|
|
|
- // 查询条件 (当前用户, ids)
|
|
|
- LambdaQueryWrapper<SysFile> wrapperFile = new LambdaQueryWrapper<>();
|
|
|
- wrapperFile.eq(SysFile::getUser_id, sysFile.getUser_id());
|
|
|
- wrapperFile.in(SysFile::getId, ids);
|
|
|
-
|
|
|
- sysFileDao.update(entity, wrapperFile);
|
|
|
+ LambdaUpdateWrapper<SysFile> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(SysFile::getUser_id, sysFile.getUser_id()).in(SysFile::getId, ids);
|
|
|
+ wrapper.set(SysFile::getCategory_id, category_id);
|
|
|
+ sysFileDao.update(null, wrapper);
|
|
|
|
|
|
return Map.of("ids", ids);
|
|
|
}
|