|
@@ -26,10 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
@@ -67,7 +64,7 @@ public class BytedanceVideoSlogenInfoController {
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
HttpServletRequest req) {
|
|
|
Result<IPage<BytedanceVideoSlogenInfo>> result = new Result<>();
|
|
|
- slogenInfo.setStatus(1);
|
|
|
+// slogenInfo.setStatus(1); //默认不传为所有,传了1是正常,传0是已删除
|
|
|
QueryWrapper<BytedanceVideoSlogenInfo> queryWrapper = QueryGenerator.initQueryWrapper(slogenInfo, req.getParameterMap());
|
|
|
Page<BytedanceVideoSlogenInfo> page = new Page<>(pageNo, pageSize);
|
|
|
IPage<BytedanceVideoSlogenInfo> pageList = bytedanceVideoSlogenInfoService.page(page, queryWrapper);
|
|
@@ -84,7 +81,8 @@ public class BytedanceVideoSlogenInfoController {
|
|
|
@RequestParam(value = "startTime",defaultValue = "") String startTime,
|
|
|
@RequestParam(value = "endTime",defaultValue = "") String endTime,
|
|
|
@RequestParam(value = "pageNo", defaultValue="1") Integer pageNo,
|
|
|
- @RequestParam(value = "pageSize", defaultValue="10") Integer pageSize
|
|
|
+ @RequestParam(value = "pageSize", defaultValue="10") Integer pageSize,
|
|
|
+ @RequestParam(value = "status",required = false) Integer status
|
|
|
) {
|
|
|
try {
|
|
|
//查询用户角色
|
|
@@ -96,7 +94,7 @@ public class BytedanceVideoSlogenInfoController {
|
|
|
if ("admin".equals(roleCode) && Check.isNull(projectId)) {
|
|
|
projectId = "admin"; //传递projectId为admin
|
|
|
}
|
|
|
- return bytedanceVideoSlogenInfoService.getVideoSlogenReport(userId, projectId,keyWord, startTime,endTime,pageNo,pageSize);
|
|
|
+ return bytedanceVideoSlogenInfoService.getVideoSlogenReport(userId, projectId,keyWord,status, startTime,endTime,pageNo,pageSize);
|
|
|
}catch (Exception e){
|
|
|
log.error("指定文案-获取指定文案维度创意报表数据异常",e);
|
|
|
return Result.error("请求失败,请联系开发人员!");
|
|
@@ -208,18 +206,16 @@ public class BytedanceVideoSlogenInfoController {
|
|
|
public Result<BytedanceVideoSlogenInfo> edit(@RequestBody BytedanceVideoSlogenInfo slogenInfo) {
|
|
|
Result<BytedanceVideoSlogenInfo> result = new Result<>();
|
|
|
try{
|
|
|
- BytedanceVideoSlogenInfo bytedanceVideoSlogenInfoEntity = bytedanceVideoSlogenInfoService.getById(slogenInfo.getId());
|
|
|
- if(bytedanceVideoSlogenInfoEntity==null) {
|
|
|
- result.error500("未找到对应实体");
|
|
|
- return result;
|
|
|
+ List<BytedanceVideoSlogenInfo> videoSlogenInfoList = bytedanceVideoSlogenInfoService.getVideoSlogenBySlogenAndProjectId(slogenInfo.getSlogan(),slogenInfo.getProjectId());
|
|
|
+ if(videoSlogenInfoList==null) {
|
|
|
+ return result.error500("未找到对应实体");
|
|
|
}
|
|
|
- LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
- slogenInfo.setUpdateBy(user.getId());
|
|
|
- slogenInfo.setUpdateTime(new Date());
|
|
|
|
|
|
- String title = slogenInfo.getSlogan();
|
|
|
+
|
|
|
+ String title = slogenInfo.getNewSlogan();
|
|
|
title = title.trim().replaceAll("[\\{]{2,}", "{");
|
|
|
title = title.trim().replaceAll("[\\}]{2,}", "}");
|
|
|
+ slogenInfo.setNewSlogan(title);
|
|
|
|
|
|
String reg = "\\{[\\u4e00-\\u9fa5\\-]{2,6}\\}";
|
|
|
Pattern pattern = Pattern.compile(reg);
|
|
@@ -234,14 +230,14 @@ public class BytedanceVideoSlogenInfoController {
|
|
|
while (matcher.find()) { //此处find()每次被调用后,会偏移到下一个匹配
|
|
|
times++;
|
|
|
if (times >= 3) {
|
|
|
- return Result.errorMsg("动态词包不合法,词包数量超过2个");
|
|
|
+ return result.error500("动态词包不合法,词包数量超过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("动态词包不合法,词包不存在或者含有单独的非词包大括号");
|
|
|
+ return result.error500("动态词包不合法,词包不存在或者含有单独的非词包大括号");
|
|
|
}
|
|
|
creativeWordIdsArray.add(creativeWordPackage.getCreativeWordId());
|
|
|
len = len - (right - left) + creativeWordPackage.getMaxWordLen();
|
|
@@ -251,16 +247,26 @@ public class BytedanceVideoSlogenInfoController {
|
|
|
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);
|
|
|
- result.success("修改成功!");
|
|
|
- result.setCode(0);
|
|
|
+ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ for (BytedanceVideoSlogenInfo videoSlogenInfo:videoSlogenInfoList
|
|
|
+ ) {
|
|
|
+ videoSlogenInfo.setSlogan(slogenInfo.getNewSlogan());
|
|
|
+ videoSlogenInfo.setUpdateBy(user.getId());
|
|
|
+ videoSlogenInfo.setUpdateTime(new Date());
|
|
|
+ videoSlogenInfo.setCreativeWordIds(creativeWordIdsArray.toJSONString());
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean ok = bytedanceVideoSlogenInfoService.updateBatchById(videoSlogenInfoList);
|
|
|
+ if(ok) {
|
|
|
+ result.success("修改成功!");
|
|
|
+ result.setCode(0);
|
|
|
+ }
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(),e);
|
|
@@ -275,7 +281,7 @@ public class BytedanceVideoSlogenInfoController {
|
|
|
* @return
|
|
|
*/
|
|
|
@ApiOperation(value="头条视频文案信息-通过id删除", notes="头条视频文案信息-通过id删除")
|
|
|
- @PostMapping(value = "/delete")
|
|
|
+ @DeleteMapping(value = "/delete")
|
|
|
public Result<?> delete(@RequestParam(name="id") String id) {
|
|
|
try {
|
|
|
BytedanceVideoSlogenInfo slogenInfo = bytedanceVideoSlogenInfoService.getById(id);
|
|
@@ -293,6 +299,37 @@ public class BytedanceVideoSlogenInfoController {
|
|
|
return Result.error("删除失败!");
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 通过id删除
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value="头条视频文案信息-通过id删除", notes="头条视频文案信息-通过id删除")
|
|
|
+ @DeleteMapping(value = "/deleteBySlogenAndProjectId")
|
|
|
+ public Result<?> deleteBySlogenAndProjectId(@RequestParam(name="slogan") String slogan, @RequestParam(name="projectId") Long projectId) {
|
|
|
+ try {
|
|
|
+ Result result = new Result();
|
|
|
+ List<BytedanceVideoSlogenInfo> videoSlogenInfoList = bytedanceVideoSlogenInfoService.getVideoSlogenBySlogenAndProjectId(slogan,projectId);
|
|
|
+ if(Check.isNull(videoSlogenInfoList)) {
|
|
|
+ return result.ok("此文案不存在或者已经被删除");
|
|
|
+ }
|
|
|
+ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ videoSlogenInfoList.forEach(videoSlogenInfo->{
|
|
|
+ videoSlogenInfo.setStatus(0);
|
|
|
+ videoSlogenInfo.setUpdateTime(new Date());
|
|
|
+ videoSlogenInfo.setCreateBy(user.getId());});
|
|
|
+
|
|
|
+ boolean ok = bytedanceVideoSlogenInfoService.updateBatchById(videoSlogenInfoList);
|
|
|
+ if(ok) {
|
|
|
+ result.success("删除成功!");
|
|
|
+ result.setCode(0);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("删除失败",e.getMessage());
|
|
|
+ return Result.error("删除失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 通过id查询
|
|
@@ -312,4 +349,28 @@ public class BytedanceVideoSlogenInfoController {
|
|
|
result.setSuccess(true);
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过slogen和projectId查询
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value="头条视频文案信息-通过文案内容和项目id查询", notes="头条视频文案信息-通过文案内容和项目id查询")
|
|
|
+ @GetMapping(value = "/queryBySlogenAndProjectId")
|
|
|
+ public Result<BytedanceVideoSlogenInfo> queryBySlogenAndProjectId(@RequestParam(name="slogan") String slogan, @RequestParam(name="projectId") Long projectId) {
|
|
|
+
|
|
|
+ Result<BytedanceVideoSlogenInfo> result = new Result<>();
|
|
|
+ List<BytedanceVideoSlogenInfo> videoSlogenInfoList = bytedanceVideoSlogenInfoService.getVideoSlogenBySlogenAndProjectId(slogan,projectId);
|
|
|
+ if(Check.isNull(videoSlogenInfoList)) {
|
|
|
+ result.error500("未找到对应实体");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ List<String> materialNameArray = new ArrayList<>();
|
|
|
+ videoSlogenInfoList.forEach(videoSlogenInfo->materialNameArray.add(videoSlogenInfo.getMaterialName()));
|
|
|
+ BytedanceVideoSlogenInfo bytedanceVideoSlogenInfo = videoSlogenInfoList.get(0);
|
|
|
+ bytedanceVideoSlogenInfo.setMaterialNameArray(materialNameArray);
|
|
|
+ result.setResult(bytedanceVideoSlogenInfo);
|
|
|
+ result.setSuccess(true);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|