浏览代码

视频被驳回再保存时,标题先删除后保存。

huangxuechao 4 年之前
父节点
当前提交
2ee0dcda67

+ 3 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java

@@ -534,7 +534,7 @@ public class MaterialInfoController {
                     int len = StringUtils.lengthAsSlogan(title);
                     int left = title.indexOf("{");
                     int right = title.indexOf("}");
-                    if(left >= 0 && right >= 0){
+                    if(left >= 0 || right >= 0){
                         int times = 0;
                         while (matcher.find()) { //此处find()每次被调用后,会偏移到下一个匹配
                             times++;
@@ -570,7 +570,8 @@ public class MaterialInfoController {
                 }
 
                 LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-                slogenInfoService.insertSlogans(materialInfo.getProjectId(), materialInfoEntity.getCode(), slogans, user.getId());
+                slogenInfoService.deleteAllSlogens(Check.isNull(materialInfo.getProjectId()) ? materialInfoEntity.getProjectId() : materialInfo.getProjectId(),materialInfoEntity.getCode(),user.getId());
+                slogenInfoService.insertSlogans(Check.isNull(materialInfo.getProjectId()) ? materialInfoEntity.getProjectId() : materialInfo.getProjectId() , materialInfoEntity.getCode(), slogans, user.getId());
             }
         }
         boolean ok = materialInfoService.updateById(materialInfo);

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/BytedanceVideoSlogenInfoController.java

@@ -117,7 +117,7 @@ public class BytedanceVideoSlogenInfoController {
 			int len = StringUtils.lengthAsSlogan(title);
 			int left = title.indexOf("{");
 			int right = title.indexOf("}");
-			if (left >= 0 && right >= 0) {
+			if (left >= 0 || right >= 0) {
 				int times = 0;
 				while (matcher.find()) { //此处find()每次被调用后,会偏移到下一个匹配
 					times++;

+ 2 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/BytedanceVideoSlogenInfoMapper.java

@@ -2,6 +2,7 @@ package cn.com.ctop.toutiao.modules.material.mapper;
 
 import cn.com.ctop.toutiao.modules.material.entity.BytedanceVideoSlogenInfo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 头条视频文案信息
@@ -10,5 +11,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @version V1.0
  */
 public interface BytedanceVideoSlogenInfoMapper extends BaseMapper<BytedanceVideoSlogenInfo> {
-
+    void updateStatusToZero(@Param("projectId") Long projectId,@Param("videoCode") String videoCode,@Param("userId") String userId);
 }

+ 8 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/BytedanceVideoSlogenInfoMapper.xml

@@ -1,5 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.toutiao.modules.material.mapper.BytedanceVideoSlogenInfoMapper">
-
+    <update id="updateStatusToZero" >
+        update ctop_bytedance_video_slogen_info a set a.status = 0
+        where 1=1
+        and a.video_code = #{videoCode} and a.create_by = #{userId}
+        <if test="projectId != null">
+            and a.project_id = #{projectId}
+        </if>
+    </update>
 </mapper>

+ 2 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IBytedanceVideoSlogenInfoService.java

@@ -17,4 +17,6 @@ public interface IBytedanceVideoSlogenInfoService extends IService<BytedanceVide
     void insertSlogans(Long projectId, String videoCode, JSONArray slogans, String userId);
 
     List<BytedanceVideoSlogenInfo> listByParams(String code, Integer status);
+
+    void deleteAllSlogens(Long projectId, String videoCode, String userId);
 }

+ 10 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceVideoSlogenInfoServiceImpl.java

@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 /**
@@ -21,6 +22,9 @@ import java.util.List;
  */
 @Service
 public class BytedanceVideoSlogenInfoServiceImpl extends ServiceImpl<BytedanceVideoSlogenInfoMapper, BytedanceVideoSlogenInfo> implements IBytedanceVideoSlogenInfoService {
+    @Resource
+    BytedanceVideoSlogenInfoMapper bytedanceVideoSlogenInfoMapper;
+
     @Override
     public void insertSlogans(Long projectId, String videoCode, JSONArray slogans,String userId){
         if(null==slogans||slogans.isEmpty()){
@@ -36,6 +40,12 @@ public class BytedanceVideoSlogenInfoServiceImpl extends ServiceImpl<BytedanceVi
             this.save(slogenInfo);
         }
     }
+
+    @Override
+    public void deleteAllSlogens(Long projectId, String videoCode, String userId){
+        bytedanceVideoSlogenInfoMapper.updateStatusToZero(projectId, videoCode, userId);
+    }
+
     @Override
     public List<BytedanceVideoSlogenInfo> listByParams(String code, Integer status) {
         QueryWrapper<BytedanceVideoSlogenInfo>queryWrapper =new QueryWrapper<>();