|
@@ -12,20 +12,26 @@ import org.apache.shiro.SecurityUtils;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
|
+import org.jeecg.modules.bytedance.advertise.entity.ByteDanceCreativeWordPackage;
|
|
import org.jeecg.modules.bytedance.advertise.entity.BytedanceVideoSlogenInfo;
|
|
import org.jeecg.modules.bytedance.advertise.entity.BytedanceVideoSlogenInfo;
|
|
|
|
+import org.jeecg.modules.bytedance.advertise.service.IByteDanceGeneralCopywriterService;
|
|
import org.jeecg.modules.bytedance.advertise.service.IBytedanceVideoSlogenInfoService;
|
|
import org.jeecg.modules.bytedance.advertise.service.IBytedanceVideoSlogenInfoService;
|
|
import org.jeecg.modules.bytedance.advertise.service.impl.BytedanceVideoSlogenInfoServiceImpl;
|
|
import org.jeecg.modules.bytedance.advertise.service.impl.BytedanceVideoSlogenInfoServiceImpl;
|
|
import org.jeecg.modules.bytedance.common.entity.MaterialInfo;
|
|
import org.jeecg.modules.bytedance.common.entity.MaterialInfo;
|
|
import org.jeecg.modules.bytedance.common.service.IMaterialInfoService;
|
|
import org.jeecg.modules.bytedance.common.service.IMaterialInfoService;
|
|
import org.jeecg.modules.bytedance.common.utils.Check;
|
|
import org.jeecg.modules.bytedance.common.utils.Check;
|
|
|
|
+import org.jeecg.modules.bytedance.common.utils.StringUtils;
|
|
import org.jeecg.modules.system.service.ISysRoleService;
|
|
import org.jeecg.modules.system.service.ISysRoleService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 头条视频文案信息
|
|
* 头条视频文案信息
|
|
@@ -44,6 +50,8 @@ public class BytedanceVideoSlogenInfoController {
|
|
private IMaterialInfoService materialInfoService;
|
|
private IMaterialInfoService materialInfoService;
|
|
@Autowired
|
|
@Autowired
|
|
private ISysRoleService sysRoleService;
|
|
private ISysRoleService sysRoleService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IByteDanceGeneralCopywriterService byteDanceGeneralCopywriterService;
|
|
/**
|
|
/**
|
|
* 分页列表查询
|
|
* 分页列表查询
|
|
* @param slogenInfo
|
|
* @param slogenInfo
|
|
@@ -119,7 +127,7 @@ public class BytedanceVideoSlogenInfoController {
|
|
* 添加
|
|
* 添加
|
|
* @param
|
|
* @param
|
|
* @param
|
|
* @param
|
|
- * @param userId
|
|
|
|
|
|
+ * @param
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@ApiOperation(value="头条视频文案信息-批量添加", notes="头条视频文案信息-批量添加")
|
|
@ApiOperation(value="头条视频文案信息-批量添加", notes="头条视频文案信息-批量添加")
|
|
@@ -129,6 +137,50 @@ public class BytedanceVideoSlogenInfoController {
|
|
try {
|
|
try {
|
|
String userId = materialInfo.getUserId();
|
|
String userId = materialInfo.getUserId();
|
|
JSONArray slogenArray = materialInfo.getSlogans();
|
|
JSONArray slogenArray = materialInfo.getSlogans();
|
|
|
|
+ for (int i = 0;i<slogenArray.size();i++) {
|
|
|
|
+ JSONObject slogenInfo = slogenArray.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){
|
|
|
|
+ return Result.errorMsg("动态词包不合法,词包数量超过2个");
|
|
|
|
+ }
|
|
|
|
+ String matchStr = matcher.group();//获取当前匹配的值
|
|
|
|
+ title = title.replace(matchStr,"");
|
|
|
|
+
|
|
|
|
+ ByteDanceCreativeWordPackage creativeWordPackage = byteDanceGeneralCopywriterService.selectCreativeWordPackageByName(matchStr.substring(1,matchStr.length()-1));
|
|
|
|
+ if(Check.isNull(creativeWordPackage)){
|
|
|
|
+ return Result.errorMsg("动态词包不合法,词包不存在或者含有单独的非词包大括号");
|
|
|
|
+ }
|
|
|
|
+ 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){
|
|
|
|
+ return result.error500("文案长度不合法,小于5或大于30");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
JSONArray materialIds = materialInfo.getMaterialIds();
|
|
JSONArray materialIds = materialInfo.getMaterialIds();
|
|
for(int i=0;i<materialIds.size();i++){
|
|
for(int i=0;i<materialIds.size();i++){
|
|
MaterialInfo materialInfo2 = materialInfoService.getById(materialIds.get(i).toString());
|
|
MaterialInfo materialInfo2 = materialInfoService.getById(materialIds.get(i).toString());
|
|
@@ -155,6 +207,7 @@ public class BytedanceVideoSlogenInfoController {
|
|
@PostMapping(value = "/edit")
|
|
@PostMapping(value = "/edit")
|
|
public Result<BytedanceVideoSlogenInfo> edit(@RequestBody BytedanceVideoSlogenInfo slogenInfo) {
|
|
public Result<BytedanceVideoSlogenInfo> edit(@RequestBody BytedanceVideoSlogenInfo slogenInfo) {
|
|
Result<BytedanceVideoSlogenInfo> result = new Result<>();
|
|
Result<BytedanceVideoSlogenInfo> result = new Result<>();
|
|
|
|
+ try{
|
|
BytedanceVideoSlogenInfo bytedanceVideoSlogenInfoEntity = bytedanceVideoSlogenInfoService.getById(slogenInfo.getId());
|
|
BytedanceVideoSlogenInfo bytedanceVideoSlogenInfoEntity = bytedanceVideoSlogenInfoService.getById(slogenInfo.getId());
|
|
if(bytedanceVideoSlogenInfoEntity==null) {
|
|
if(bytedanceVideoSlogenInfoEntity==null) {
|
|
result.error500("未找到对应实体");
|
|
result.error500("未找到对应实体");
|
|
@@ -163,9 +216,57 @@ public class BytedanceVideoSlogenInfoController {
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
slogenInfo.setUpdateBy(user.getId());
|
|
slogenInfo.setUpdateBy(user.getId());
|
|
slogenInfo.setUpdateTime(new Date());
|
|
slogenInfo.setUpdateTime(new Date());
|
|
|
|
+
|
|
|
|
+ String title = slogenInfo.getSlogan();
|
|
|
|
+ title = title.trim().replaceAll("[\\{]{2,}", "{");
|
|
|
|
+ title = title.trim().replaceAll("[\\}]{2,}", "}");
|
|
|
|
+
|
|
|
|
+ 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) {
|
|
|
|
+ return Result.errorMsg("动态词包不合法,词包数量超过2个");
|
|
|
|
+ }
|
|
|
|
+ String matchStr = matcher.group();//获取当前匹配的值
|
|
|
|
+ title = title.replace(matchStr,"");
|
|
|
|
+
|
|
|
|
+ ByteDanceCreativeWordPackage creativeWordPackage = byteDanceGeneralCopywriterService.selectCreativeWordPackageByName(matchStr.substring(1, matchStr.length() - 1));
|
|
|
|
+ if (Check.isNull(creativeWordPackage)) {
|
|
|
|
+ return Result.errorMsg("动态词包不合法,词包不存在或者含有单独的非词包大括号");
|
|
|
|
+ }
|
|
|
|
+ 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.setCreativeWordIds(creativeWordIdsArray.toJSONString());
|
|
|
|
+ }
|
|
|
|
+ //校验标题长度,长度小于5和大于30的全部过滤
|
|
|
|
+ if (len < 5 || len > 30) {
|
|
|
|
+ return result.error500("文案长度不合法,小于5或大于30");
|
|
|
|
+ }
|
|
|
|
+
|
|
bytedanceVideoSlogenInfoService.updateById(slogenInfo);
|
|
bytedanceVideoSlogenInfoService.updateById(slogenInfo);
|
|
result.success("修改成功!");
|
|
result.success("修改成功!");
|
|
|
|
+ result.setCode(0);
|
|
return result;
|
|
return result;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
|
+ result.error500("操作失败");
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|