|
@@ -6,7 +6,9 @@ import cn.com.ctop.common.module.entity.*;
|
|
import cn.com.ctop.common.module.enums.MaterialSupplierEnum;
|
|
import cn.com.ctop.common.module.enums.MaterialSupplierEnum;
|
|
import cn.com.ctop.common.module.service.*;
|
|
import cn.com.ctop.common.module.service.*;
|
|
import cn.com.ctop.common.module.utils.*;
|
|
import cn.com.ctop.common.module.utils.*;
|
|
|
|
+import cn.com.ctop.toutiao.modules.material.entity.ByteDanceCreativeWordPackage;
|
|
import cn.com.ctop.toutiao.modules.material.entity.BytedanceVideoSlogenInfo;
|
|
import cn.com.ctop.toutiao.modules.material.entity.BytedanceVideoSlogenInfo;
|
|
|
|
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeWordPackageService;
|
|
import cn.com.ctop.toutiao.modules.material.service.IBytedanceVideoSlogenInfoService;
|
|
import cn.com.ctop.toutiao.modules.material.service.IBytedanceVideoSlogenInfoService;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -31,6 +33,8 @@ import javax.servlet.http.HttpServletRequest;
|
|
import java.net.URLDecoder;
|
|
import java.net.URLDecoder;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 素材信息
|
|
* 素材信息
|
|
@@ -74,7 +78,8 @@ public class MaterialInfoController {
|
|
private IProductService productService;
|
|
private IProductService productService;
|
|
@Autowired
|
|
@Autowired
|
|
private IProjectService projectService;
|
|
private IProjectService projectService;
|
|
-
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IByteDanceCreativeWordPackageService byteDanceGeneralCopywriterService;
|
|
|
|
|
|
@GetMapping("/supplierWatermark")
|
|
@GetMapping("/supplierWatermark")
|
|
public Result<String> supplierWatermark(String id) {
|
|
public Result<String> supplierWatermark(String id) {
|
|
@@ -513,6 +518,57 @@ public class MaterialInfoController {
|
|
if (!Check.isNull(materialInfo.getSlogans())) {
|
|
if (!Check.isNull(materialInfo.getSlogans())) {
|
|
JSONArray slogans = materialInfo.getSlogans();
|
|
JSONArray slogans = materialInfo.getSlogans();
|
|
if (null != slogans && !slogans.isEmpty()) {
|
|
if (null != slogans && !slogans.isEmpty()) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for (int i = 0;i<slogans.size();i++) {
|
|
|
|
+ JSONObject slogenInfo = slogans.getJSONObject(i);
|
|
|
|
+ String title = slogenInfo.getString("title");
|
|
|
|
+ title = title.trim().replaceAll("[\\{]{2,}","{");
|
|
|
|
+ title = title.trim().replaceAll("[\\}]{2,}","}");
|
|
|
|
+ slogenInfo.put("title",title);
|
|
|
|
+ String reg = "\\{[\\u4e00-\\u9fa5\\-]{2,6}\\}";
|
|
|
|
+ Pattern pattern = Pattern.compile(reg);
|
|
|
|
+ Matcher matcher = pattern.matcher(title);
|
|
|
|
+ JSONArray creativeWordIdsArray = new JSONArray();
|
|
|
|
+
|
|
|
|
+ int len = StringUtils.lengthAsSlogan(title);
|
|
|
|
+ int left = title.indexOf("{");
|
|
|
|
+ int right = title.indexOf("}");
|
|
|
|
+ if(left >= 0 && right >= 0){
|
|
|
|
+ int times = 0;
|
|
|
|
+ while (matcher.find()) { //此处find()每次被调用后,会偏移到下一个匹配
|
|
|
|
+ times++;
|
|
|
|
+ if(times>=3){
|
|
|
|
+ result.setCode(500);
|
|
|
|
+ result.setMessage("动态词包不合法,词包数量超过2个");
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ String matchStr = matcher.group();//获取当前匹配的值
|
|
|
|
+ title = title.replace(matchStr,"");
|
|
|
|
+ ByteDanceCreativeWordPackage creativeWordPackage = byteDanceGeneralCopywriterService.selectCreativeWordPackageByName(matchStr.substring(1,matchStr.length()-1));
|
|
|
|
+ if(Check.isNull(creativeWordPackage)){
|
|
|
|
+ result.setCode(500);
|
|
|
|
+ result.setMessage("动态词包不合法,词包不存在或者含有单独的非词包大括号");
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ creativeWordIdsArray.add(creativeWordPackage.getCreativeWordId());
|
|
|
|
+ len = len - (right - left) + creativeWordPackage.getMaxWordLen();
|
|
|
|
+ left = title.indexOf("{");
|
|
|
|
+ right = title.indexOf("}");
|
|
|
|
+ }
|
|
|
|
+ if(title.contains("{") || title.contains("}")){
|
|
|
|
+ return result.error500("大括号单独出现或大括号中内容不合法");
|
|
|
|
+ }
|
|
|
|
+ slogenInfo.put("creative_word_ids",creativeWordIdsArray.toJSONString());
|
|
|
|
+ }
|
|
|
|
+ //校验标题长度,长度小于5和大于30的全部过滤
|
|
|
|
+ if(len<5 || len>30){
|
|
|
|
+ result.setCode(500);
|
|
|
|
+ result.setMessage("文案长度不合法,小于5或大于30");
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
slogenInfoService.insertSlogans(materialInfo.getProjectId(), materialInfoEntity.getCode(), slogans, user.getId());
|
|
slogenInfoService.insertSlogans(materialInfo.getProjectId(), materialInfoEntity.getCode(), slogans, user.getId());
|
|
}
|
|
}
|
|
@@ -545,6 +601,7 @@ public class MaterialInfoController {
|
|
sendMessageService.sendMessage(userId, text);
|
|
sendMessageService.sendMessage(userId, text);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ result.setCode(0);
|
|
return result;
|
|
return result;
|
|
|
|
|
|
}
|
|
}
|
|
@@ -567,7 +624,9 @@ public class MaterialInfoController {
|
|
successNum++;
|
|
successNum++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return result.success("批量修改成功" + successNum + "个");
|
|
|
|
|
|
+ result.setCode(0);
|
|
|
|
+ result.setMessage("批量修改成功" + successNum + "个");
|
|
|
|
+ return result;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|