Selaa lähdekoodia

广告文案数量-可设置

yangzian 3 vuotta sitten
vanhempi
commit
cd95ab809c

+ 3 - 0
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/entity/AiBytedanceAdvertiserStrategy.java

@@ -350,4 +350,7 @@ public class AiBytedanceAdvertiserStrategy{
 	 */
 	private String componentId;
 
+	/**广告文案数量*/
+	private Integer copywritingNumber;
+
 }

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

@@ -20,7 +20,14 @@ public interface ByteDanceGeneralCopywriterMapper extends BaseMapper<ByteDanceGe
     ByteDanceCreativeWordPackage selectCreativeWordPackageByName(String name);
 
     List<ByteDanceGeneralCopywriter> getRandThree(@Param(value = "accountId") Long accountId);
-    List<ByteDanceGeneralCopywriter> getRandTen(@Param(value = "accountId") Long accountId);
+
+    /**
+     * 查询账户 通用文案 数量
+     * @param accountId 账户di
+     * @param copywritingNumber 文案数量
+     * @return
+     */
+    List<ByteDanceGeneralCopywriter> getRandTen(@Param(value = "accountId") Long accountId,@Param("copywritingNumber")Integer copywritingNumber);
 
     List<ByteDanceGeneralCopywriter> selectAllDataByTextCopywriter(@Param(value = "textCopywriter") String textCopywriter);
 }

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

@@ -49,7 +49,7 @@
 
     <select id="getRandTen"
             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 10
+        select * from ctop_bytedance_general_copywriter where status = 1 and account_id = #{accountId} order by rand() limit #{copywritingNumber}
     </select>
 
     <select id="selectAllDataByTextCopywriter" resultType="org.jeecg.modules.bytedance.advertise.entity.ByteDanceGeneralCopywriter">

+ 1 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/IBytedanceVideoSlogenInfoService.java

@@ -17,7 +17,7 @@ public interface IBytedanceVideoSlogenInfoService extends IService<BytedanceVide
 
     void insertSlogans(Long projectId, String videoCode, JSONArray slogans, String userId);
 
-    List<BytedanceVideoSlogenInfo> listByParams(String code, Integer status);
+    List<BytedanceVideoSlogenInfo> listByParams(String code, Integer status,Integer copywritingNumber);
 
     Result getVideoSlogenReport(String userId, String projectId,String keyWord,Integer status, String startTime, String endTime, Integer pageNum, Integer pageSize);
 

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

@@ -377,11 +377,12 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
         JSONObject creObj = new JSONObject();
 
         JSONArray titleArray = new JSONArray();
-        List<BytedanceVideoSlogenInfo> slogenInfos = slogenInfoService.listByParams(videoInfo.getSignature(),1);
+        //根据账户 和 文案数量 查询 指定文案
+        List<BytedanceVideoSlogenInfo> slogenInfos = slogenInfoService.listByParams(videoInfo.getSignature(),1,strategy.getCopywritingNumber());
         //使用指定文案
         if(!Check.isNull(slogenInfos)){
             for (BytedanceVideoSlogenInfo slogenInfo:slogenInfos) {
-                if(titleArray.size() >= 10){    //接口中是要求一个视频最多10个标题
+                if(titleArray.size() >= strategy.getCopywritingNumber()){    //接口中是要求一个视频最多10个标题
                     break;
                 }
                 JSONObject titleObject = new JSONObject();
@@ -407,7 +408,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             List<ByteDanceGeneralCopywriter> byteDanceGeneralCopywriter = byteDanceGeneralCopywriterMapper.getRandThree(strategy.getAccountId());
             if(!Check.isNull(byteDanceGeneralCopywriter)){
                 for(int i = 0; i < byteDanceGeneralCopywriter.size(); i++){
-                    if(titleArray.size() >= 10){
+                    if(titleArray.size() >= strategy.getCopywritingNumber()){
                         break;
                     }
                     JSONObject titleObject = new JSONObject();
@@ -433,7 +434,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
             }
             // 图片 使用通用文案 最多10条
         }else if ("image".equalsIgnoreCase(videoInfo.getMaterialType())){
-            List<ByteDanceGeneralCopywriter> byteDanceGeneralCopywriterList = byteDanceGeneralCopywriterMapper.getRandTen(strategy.getAccountId());
+            List<ByteDanceGeneralCopywriter> byteDanceGeneralCopywriterList = byteDanceGeneralCopywriterMapper.getRandTen(strategy.getAccountId(),strategy.getCopywritingNumber());
             if(!Check.isNull(byteDanceGeneralCopywriterList)){
                 for (ByteDanceGeneralCopywriter byteDanceGeneralCopywriter : byteDanceGeneralCopywriterList){
                     JSONObject titleObject = new JSONObject();

+ 13 - 1
jeecg-boot-bytedance/src/main/java/org/jeecg/modules/bytedance/advertise/service/impl/BytedanceVideoSlogenInfoServiceImpl.java

@@ -49,8 +49,15 @@ public class BytedanceVideoSlogenInfoServiceImpl extends ServiceImpl<BytedanceVi
         }
     }
 
+    /**
+     * 根据账户 和 文案数量 查询 指定文案
+     * @param code 素材code
+     * @param status 状态
+     * @param copywritingNumber 文案数量
+     * @return
+     */
     @Override
-    public List<BytedanceVideoSlogenInfo> listByParams(String code, Integer status) {
+    public List<BytedanceVideoSlogenInfo> listByParams(String code, Integer status,Integer copywritingNumber) {
         QueryWrapper<BytedanceVideoSlogenInfo>queryWrapper =new QueryWrapper<>();
         if(!Check.isNull(code)){
             queryWrapper.eq("video_code",code);
@@ -59,6 +66,11 @@ public class BytedanceVideoSlogenInfoServiceImpl extends ServiceImpl<BytedanceVi
             queryWrapper.eq("status",status);
         }
         queryWrapper.orderByDesc("id");
+
+        if (!Check.isNull(copywritingNumber)){
+            queryWrapper.last("limit "+copywritingNumber);
+        }
+
         return this.list(queryWrapper);
     }
     @Override