|
@@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.Optional;
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -106,18 +107,21 @@ public class MaterialServiceImpl implements MaterialService {
|
|
MaterialCategory materialCategory = materialCategoryDao.selectById(material.getCategory_id());
|
|
MaterialCategory materialCategory = materialCategoryDao.selectById(material.getCategory_id());
|
|
if (materialCategory == null) throw new CustException("素材分类不存在");
|
|
if (materialCategory == null) throw new CustException("素材分类不存在");
|
|
|
|
|
|
- ObjectKeyEntity objectKeyEntity = objectKeyUtil.urlToObjectKey(material.getImage_url());
|
|
|
|
-
|
|
|
|
-// // 错误做法:原图地址不能加参数,否则缩略图会重复加参数
|
|
|
|
-// if (StrUtil.isNotEmpty(material.getImage_url())) {
|
|
|
|
-// String image_url = UploadUtil.getImageThumbUrl(material.getImage_url(), objectKeyEntity.getTarget(), 315, null, null, true);
|
|
|
|
-// material.setImage_url(image_url);
|
|
|
|
-// }
|
|
|
|
|
|
+ // [Filter] tag_id 过滤掉空值和 0
|
|
|
|
+ String cleaned = Optional.ofNullable(material.getTag_ids())
|
|
|
|
+ .orElse("")
|
|
|
|
+ .replaceAll("\\b0\\b,?", "")
|
|
|
|
+ .replaceAll(",{2,}", ",")
|
|
|
|
+ .replaceAll("^,|,$", "");
|
|
|
|
+ material.setTag_ids(cleaned);
|
|
|
|
|
|
// 生成缩略图,并填充缩略图地址
|
|
// 生成缩略图,并填充缩略图地址
|
|
if (StrUtil.isNotEmpty(material.getImage_url())) {
|
|
if (StrUtil.isNotEmpty(material.getImage_url())) {
|
|
- String image_thumb_url = UploadUtil.getImageThumbUrl(material.getImage_url(), objectKeyEntity.getTarget(), 276, 155);
|
|
|
|
- material.setImage_thumb_url(image_thumb_url);
|
|
|
|
|
|
+ ObjectKeyEntity objectKeyEntity = objectKeyUtil.urlToObjectKey(material.getImage_url());
|
|
|
|
+ if (objectKeyEntity != null) {
|
|
|
|
+ String image_thumb_url = UploadUtil.getImageThumbUrl(material.getImage_url(), objectKeyEntity.getTarget(), 276, 155);
|
|
|
|
+ material.setImage_thumb_url(image_thumb_url);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
materialDao.insertMaterial(material);
|
|
materialDao.insertMaterial(material);
|
|
@@ -140,6 +144,14 @@ public class MaterialServiceImpl implements MaterialService {
|
|
if (materialCategory == null) throw new CustException("素材分类不存在");
|
|
if (materialCategory == null) throw new CustException("素材分类不存在");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // [Filter] tag_id 过滤掉空值和 0
|
|
|
|
+ String cleaned = Optional.ofNullable(material.getTag_ids())
|
|
|
|
+ .orElse("")
|
|
|
|
+ .replaceAll("\\b0\\b,?", "")
|
|
|
|
+ .replaceAll(",{2,}", ",")
|
|
|
|
+ .replaceAll("^,|,$", "");
|
|
|
|
+ material.setTag_ids(cleaned);
|
|
|
|
+
|
|
// 编辑的时候,如果素材图片有修改,需要删除之前的图片
|
|
// 编辑的时候,如果素材图片有修改,需要删除之前的图片
|
|
|
|
|
|
// 生成缩略图,并填充缩略图地址
|
|
// 生成缩略图,并填充缩略图地址
|