|
@@ -1,7 +1,6 @@
|
|
package shop.alien.second.service.impl;
|
|
package shop.alien.second.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -9,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import shop.alien.entity.second.SecondGoods;
|
|
import shop.alien.entity.second.SecondGoods;
|
|
import shop.alien.entity.store.StoreImg;
|
|
import shop.alien.entity.store.StoreImg;
|
|
-import shop.alien.second.entity.SecondGoodsDTO;
|
|
|
|
|
|
+import shop.alien.entity.second.vo.SecondGoodsVo;
|
|
import shop.alien.second.mapper.SecondGoodsMapper;
|
|
import shop.alien.second.mapper.SecondGoodsMapper;
|
|
import shop.alien.second.service.SecondGoodsService;
|
|
import shop.alien.second.service.SecondGoodsService;
|
|
import shop.alien.util.common.netease.ImageCheckUtil;
|
|
import shop.alien.util.common.netease.ImageCheckUtil;
|
|
@@ -48,7 +47,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public boolean createBasicInfo(SecondGoodsDTO goodsDTO) {
|
|
|
|
|
|
+ public boolean createBasicInfo(SecondGoodsVo goodsDTO) {
|
|
// 实现基本信息保存逻辑
|
|
// 实现基本信息保存逻辑
|
|
SecondGoods goods = new SecondGoods();
|
|
SecondGoods goods = new SecondGoods();
|
|
BeanUtils.copyProperties(goods, goodsDTO);
|
|
BeanUtils.copyProperties(goods, goodsDTO);
|
|
@@ -89,7 +88,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
* @param goodsDTO 商品DTO信息
|
|
* @param goodsDTO 商品DTO信息
|
|
* @return 审核结果
|
|
* @return 审核结果
|
|
*/
|
|
*/
|
|
- private boolean performContentReviews(SecondGoods goods, SecondGoodsDTO goodsDTO) {
|
|
|
|
|
|
+ private boolean performContentReviews(SecondGoods goods, SecondGoodsVo goodsDTO) {
|
|
// 文本审核
|
|
// 文本审核
|
|
Map<String, String> textCheckResult = TextCheckUtil.check(goodsDTO.getDescribe());
|
|
Map<String, String> textCheckResult = TextCheckUtil.check(goodsDTO.getDescribe());
|
|
if (!"200".equals(textCheckResult.get("code"))) {
|
|
if (!"200".equals(textCheckResult.get("code"))) {
|
|
@@ -132,6 +131,11 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
return true; // 如果没有图片,则返回成功
|
|
return true; // 如果没有图片,则返回成功
|
|
}
|
|
}
|
|
for(int i = 0; i < imgUrl.size(); i++){
|
|
for(int i = 0; i < imgUrl.size(); i++){
|
|
|
|
+ // 判断如果第一个值为视频地址,获取视频第一帧作为商品封面图
|
|
|
|
+ if (i == 0 && imgUrl.get(i).endsWith(".mp4")) {
|
|
|
|
+// imgUrl.set(i, ImageCheckUtil.getFirstFrame(imgUrl.get(i)));
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
StoreImg storeImg = new StoreImg();
|
|
StoreImg storeImg = new StoreImg();
|
|
storeImg.setStoreId(savedGoodsId);
|
|
storeImg.setStoreId(savedGoodsId);
|
|
storeImg.setImgType(15);
|
|
storeImg.setImgType(15);
|
|
@@ -184,5 +188,51 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
|
|
|
return goodsPage;
|
|
return goodsPage;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 判断并获取商品封面图(若第一个链接是视频,则取第一帧)
|
|
|
|
+ * @param imgUrl 商品图片/视频链接列表
|
|
|
|
+ * @return 封面图URL或处理后的图像标识
|
|
|
|
+ */
|
|
|
|
+ public String getCoverImageFromVideoOrImage(List<String> imgUrl) {
|
|
|
|
+ if (imgUrl == null || imgUrl.isEmpty()) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String firstUrl = imgUrl.get(0);
|
|
|
|
+ if (isVideoUrl(firstUrl)) {
|
|
|
|
+ // 如果是视频,获取第一帧作为封面图
|
|
|
|
+ return extractFirstFrameAsCover(firstUrl);
|
|
|
|
+ } else {
|
|
|
|
+ // 否则直接返回第一个图片链接
|
|
|
|
+ return firstUrl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 判断URL是否为视频地址(支持常见格式)
|
|
|
|
+ * @param url 输入URL
|
|
|
|
+ * @return 是否为视频地址
|
|
|
|
+ */
|
|
|
|
+ private boolean isVideoUrl(String url) {
|
|
|
|
+ if (url == null) return false;
|
|
|
|
+ url = url.toLowerCase();
|
|
|
|
+ return url.endsWith(".mp4") ||
|
|
|
|
+ url.endsWith(".avi") ||
|
|
|
|
+ url.endsWith(".mov") ||
|
|
|
|
+ url.endsWith(".flv") ||
|
|
|
|
+ url.endsWith(".wmv") ||
|
|
|
|
+ url.endsWith(".mkv");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 提取视频第一帧作为封面图(需根据实际环境实现)
|
|
|
|
+ * @param videoUrl 视频地址
|
|
|
|
+ * @return 封面图URL或Base64编码字符串
|
|
|
|
+ */
|
|
|
|
+ private String extractFirstFrameAsCover(String videoUrl) {
|
|
|
|
+ // TODO: 实现视频首帧提取逻辑,可基于FFmpeg、JavaCV等
|
|
|
|
+ // 示例返回占位符
|
|
|
|
+ return "http://example.com/covers/" + System.currentTimeMillis() + ".jpg";
|
|
|
|
+ }
|
|
}
|
|
}
|