|
@@ -29,7 +29,9 @@ import java.io.InputStream;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
/**
|
|
@@ -94,6 +96,7 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
|
|
|
|
|
|
@Override
|
|
|
public Result<Object> add(JSONObject data) throws IOException {
|
|
|
+ String result = "添加完成";
|
|
|
JSONArray list = data.getJSONArray("list");
|
|
|
if (Check.isNull(list) || list.size() == 0) {
|
|
|
return Result.error("缺少参数");
|
|
@@ -108,6 +111,7 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
|
|
|
String tradeName = trade.getString("tradeName");
|
|
|
String videoUrl = trade.getString("videoUrl");
|
|
|
String signature = trade.getString("signature");
|
|
|
+ String uploaderId = trade.getString("uploaderId");
|
|
|
QueryWrapper<ProductMaterial> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("product_id", entity.getProductId());
|
|
|
queryWrapper.eq("trade_name", tradeName).last("limit 1");
|
|
@@ -115,19 +119,20 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
|
|
|
if (!Check.isNull(one1)) {
|
|
|
entity.setStartMonth(one1.getStartMonth());
|
|
|
entity.setEndMonth(one1.getEndMonth());
|
|
|
+ result = "";
|
|
|
}
|
|
|
int count = 0;
|
|
|
- if (Check.isNull(videoUrl)) {
|
|
|
- queryWrapper.isNull("video_url");
|
|
|
- ProductMaterial one = this.getOne(queryWrapper);
|
|
|
- if (Check.isNull(one)) {
|
|
|
- entity.setTradeName(tradeName);
|
|
|
- lists.add(entity);
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (Check.isNull(signature)) {
|
|
|
- List<String> urls = Arrays.asList(videoUrl.split(","));
|
|
|
- for (String url : urls) {
|
|
|
+ queryWrapper.isNull("video_url");
|
|
|
+ ProductMaterial one = this.getOne(queryWrapper);
|
|
|
+ if (Check.isNull(one)) {
|
|
|
+ entity.setTradeName(tradeName);
|
|
|
+ lists.add(entity);
|
|
|
+ }
|
|
|
+ if (!Check.isNull(videoUrl)) {
|
|
|
+ if (Check.isNull(signature) && Check.isNull(uploaderId)) {
|
|
|
+ List<String >urls = Arrays.asList(videoUrl.split(","));
|
|
|
+ HashSet<String> set = new HashSet<>(urls);
|
|
|
+ for (String url : set) {
|
|
|
ProductMaterial material = new ProductMaterial();
|
|
|
count++;
|
|
|
//获取MD5
|
|
@@ -135,8 +140,13 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
|
|
|
String md5 = MD5Util.getMd5(localPath);
|
|
|
if (checkVideo(entity.getProductId(), tradeName, md5)) {
|
|
|
BeanUtils.copyProperties(entity, material);
|
|
|
- material.setUploaderId(entity.getUserId());
|
|
|
material.setTradeName(tradeName);
|
|
|
+ MaterialInfo info = materialInfoService.getMaterialInfoByCode(md5);
|
|
|
+ if (!Check.isNull(info)) {
|
|
|
+ material.setUploaderId(uploaderId);
|
|
|
+ } else {
|
|
|
+ material.setUploaderId(material.getUserId());
|
|
|
+ }
|
|
|
material.setSignature(md5);
|
|
|
String cosUrl = getCosUrl(url);
|
|
|
material.setVideoUrl(cosUrl);
|
|
@@ -157,7 +167,7 @@ public class ProductMaterialServiceImpl extends ServiceImpl<ProductMaterialMappe
|
|
|
material.setTradeName(tradeName);
|
|
|
material.setVideoUrl(videoUrl);
|
|
|
material.setSignature(signature);
|
|
|
- material.setUploaderId(entity.getUserId());
|
|
|
+ material.setUploaderId(uploaderId);
|
|
|
if (checkVideo(entity.getProductId(), tradeName, signature)) {
|
|
|
lists.add(material);
|
|
|
}
|