瀏覽代碼

视频 指定文案不够的时候 使用通用文案 最多3条

yangzian 4 年之前
父節點
當前提交
a410847c92

+ 1 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/ByteDanceGeneralCopywriterMapper.java

@@ -19,7 +19,7 @@ public interface ByteDanceGeneralCopywriterMapper extends BaseMapper<ByteDanceGe
 
     ByteDanceCreativeWordPackage selectCreativeWordPackageByName(String name);
 
-    ByteDanceGeneralCopywriter getRandOne(@Param(value = "accountId") Long accountId);
+    List<ByteDanceGeneralCopywriter> getRandThree(@Param(value = "accountId") Long accountId);
     List<ByteDanceGeneralCopywriter> getRandTen(@Param(value = "accountId") Long accountId);
 
     List<ByteDanceGeneralCopywriter> selectAllDataByTextCopywriter(@Param(value = "textCopywriter") String textCopywriter);

+ 2 - 2
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/mapper/xml/ByteDanceGeneralCopywriterMapper.xml

@@ -42,9 +42,9 @@
     <select id="selectCreativeWordPackageByName" resultType="org.jeecg.modules.bytedance.advertise.entity.ByteDanceCreativeWordPackage">
         select * from ctop_bytedance_creative_word_package where name = #{name}
     </select>
-    <select id="getRandOne"
+    <select id="getRandThree"
             resultType="org.jeecg.modules.bytedance.advertise.entity.ByteDanceGeneralCopywriter">
-        select * from ctop_bytedance_general_copywriter where status = 1 and account_id = #{accountId} order by rand() limit 1
+        select * from ctop_bytedance_general_copywriter where status = 1 and account_id = #{accountId} order by rand() limit 3
     </select>
 
     <select id="getRandTen"

+ 9 - 8
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/AiBytedanceAdvertiserStrategyServiceImpl.java

@@ -395,17 +395,18 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
                 titleArray.add(titleObject);
             }
         }
+
         // 视频 指定文案不够的时候 使用通用文案 最多3条
         if ("video".equalsIgnoreCase(videoInfo.getMaterialType())){
-            for(int i = 0; i < 3; i++){
-                if(titleArray.size() >= 10){
-                    break;
-                }
-                ByteDanceGeneralCopywriter byteDanceGeneralCopywriter = byteDanceGeneralCopywriterMapper.getRandOne(strategy.getAccountId());
-                if(!Check.isNull(byteDanceGeneralCopywriter)){
+            List<ByteDanceGeneralCopywriter> byteDanceGeneralCopywriter = byteDanceGeneralCopywriterMapper.getRandThree(strategy.getAccountId());
+            if(!Check.isNull(byteDanceGeneralCopywriter)){
+                for(int i = 0; i < byteDanceGeneralCopywriter.size(); i++){
+                    if(titleArray.size() >= 10){
+                        break;
+                    }
                     JSONObject titleObject = new JSONObject();
-                    titleObject.put("title",byteDanceGeneralCopywriter.getTextCopywriter());
-                    String creativeWordsIds = byteDanceGeneralCopywriter.getCreativeWordIds();
+                    titleObject.put("title",byteDanceGeneralCopywriter.get(i).getTextCopywriter());
+                    String creativeWordsIds = byteDanceGeneralCopywriter.get(i).getCreativeWordIds();
                     if(null!=creativeWordsIds&&!creativeWordsIds.trim().equals("")){
                         JSONArray creativeWordsArray = JSON.parseArray(creativeWordsIds);
                         if(null!=creativeWordsArray&&!creativeWordsArray.isEmpty()){