|
|
@ -40,7 +40,7 @@ public class MaterialLibraryManageServiceImpl implements MaterialLibraryManageSe
|
|
|
|
// 校验素材名是否已经存在
|
|
|
|
// 校验素材名是否已经存在
|
|
|
|
Assert.notEmpty(materialLibraryList, "素材列表不能为空");
|
|
|
|
Assert.notEmpty(materialLibraryList, "素材列表不能为空");
|
|
|
|
materialLibraryList.forEach(materialLibrary -> {
|
|
|
|
materialLibraryList.forEach(materialLibrary -> {
|
|
|
|
Assert.notEmpty(materialLibrary.getMaterialType(), "素材类型不能为空");
|
|
|
|
Assert.notNull(materialLibrary.getMaterialType(), "素材类型不能为空");
|
|
|
|
Assert.notEmpty(materialLibrary.getFileResourceId(), "文件资源id不能为空");
|
|
|
|
Assert.notEmpty(materialLibrary.getFileResourceId(), "文件资源id不能为空");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -94,9 +94,20 @@ public class MaterialLibraryManageServiceImpl implements MaterialLibraryManageSe
|
|
|
|
Assert.notEmpty(materialLibrary.getId(), "id不能为空");
|
|
|
|
Assert.notEmpty(materialLibrary.getId(), "id不能为空");
|
|
|
|
Assert.notEmpty(materialLibrary.getMaterialName(), "素材名不能为空");
|
|
|
|
Assert.notEmpty(materialLibrary.getMaterialName(), "素材名不能为空");
|
|
|
|
|
|
|
|
|
|
|
|
// 校验是否重名
|
|
|
|
MaterialLibrary material = materialLibraryService.getById(materialLibrary.getId());
|
|
|
|
Integer count = materialLibraryService.lambdaQuery().eq(MaterialLibrary::getMaterialName, materialLibrary.getMaterialName()).count();
|
|
|
|
Assert.notNull(material, "素材不存在");
|
|
|
|
Assert.isTrue(count == 0, "素材名已存在");
|
|
|
|
|
|
|
|
|
|
|
|
if (!material.getMaterialName().equals(materialLibrary.getMaterialName())){
|
|
|
|
|
|
|
|
// 如果素材名发生改变,需要校验素材名是否已经存在
|
|
|
|
|
|
|
|
Integer count = materialLibraryService.lambdaQuery().eq(MaterialLibrary::getMaterialName, materialLibrary.getMaterialName()).count();
|
|
|
|
|
|
|
|
Assert.isTrue(count == 0, "素材名已存在");
|
|
|
|
|
|
|
|
List<String> split = StrUtil.split(material.getMaterialName(), ".");
|
|
|
|
|
|
|
|
if (split.size() > 1){
|
|
|
|
|
|
|
|
//重新命名文件 添加后缀
|
|
|
|
|
|
|
|
materialLibrary.setMaterialName(materialLibrary.getMaterialName() + "." + split.get(split.size()-1));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return materialLibraryService.updateById(materialLibrary);
|
|
|
|
return materialLibraryService.updateById(materialLibrary);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|