|
@@ -13,6 +13,7 @@ import com.backendsys.modules.material.service.MaterialService;
|
|
|
import com.backendsys.modules.upload.service.SysFileService;
|
|
|
import com.backendsys.modules.upload.utils.ObjectKey.ObjectKeyEntity;
|
|
|
import com.backendsys.modules.upload.utils.ObjectKey.ObjectKeyUtil;
|
|
|
+import com.backendsys.modules.upload.utils.UploadUtil;
|
|
|
import com.backendsys.utils.response.PageEntity;
|
|
|
import com.backendsys.utils.response.PageInfoResult;
|
|
|
import com.backendsys.utils.v2.PageUtils;
|
|
@@ -29,6 +30,9 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class MaterialServiceImpl implements MaterialService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ObjectKeyUtil objectKeyUtil;
|
|
|
+
|
|
|
@Autowired
|
|
|
private MaterialDao materialDao;
|
|
|
@Autowired
|
|
@@ -38,9 +42,6 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
@Autowired
|
|
|
private SysFileService sysFileService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ObjectKeyUtil objectKeyUtil;
|
|
|
-
|
|
|
private List<MaterialTag> getMaterialTagByIds(String tag_ids) {
|
|
|
if (StrUtil.isEmpty(tag_ids)) return null;
|
|
|
LambdaQueryWrapper<MaterialTag> wrapper = new LambdaQueryWrapper<>();
|
|
@@ -105,6 +106,13 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
MaterialCategory materialCategory = materialCategoryDao.selectById(material.getCategory_id());
|
|
|
if (materialCategory == null) throw new CustException("素材分类不存在");
|
|
|
|
|
|
+ // 生成缩略图,并填充缩略图地址
|
|
|
+ if (StrUtil.isNotEmpty(material.getImage_url())) {
|
|
|
+ ObjectKeyEntity objectKeyEntity = objectKeyUtil.urlToObjectKey(material.getImage_url());
|
|
|
+ String image_thumb_url = UploadUtil.getImageThumbUrl(material.getImage_url(), objectKeyEntity.getTarget(), 315, 180);
|
|
|
+ material.setImage_thumb_url(image_thumb_url);
|
|
|
+ }
|
|
|
+
|
|
|
materialDao.insertMaterial(material);
|
|
|
|
|
|
return Map.of("material_id", material.getMaterial_id());
|
|
@@ -127,6 +135,13 @@ public class MaterialServiceImpl implements MaterialService {
|
|
|
|
|
|
// 编辑的时候,如果素材图片有修改,需要删除之前的图片
|
|
|
|
|
|
+ // 生成缩略图,并填充缩略图地址
|
|
|
+ if (StrUtil.isNotEmpty(material.getImage_url())) {
|
|
|
+ ObjectKeyEntity objectKeyEntity = objectKeyUtil.urlToObjectKey(material.getImage_url());
|
|
|
+ String image_thumb_url = UploadUtil.getImageThumbUrl(material.getImage_url(), objectKeyEntity.getTarget(), 315, 180);
|
|
|
+ material.setImage_thumb_url(image_thumb_url);
|
|
|
+ }
|
|
|
+
|
|
|
materialDao.updateMaterial(material);
|
|
|
return Map.of("material_id", material.getMaterial_id());
|
|
|
};
|