syh 5 лет назад
Родитель
Сommit
68e8eadf38

+ 17 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CreateInternalServiceImpl.java

@@ -207,6 +207,23 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         return resultMap;
     }
 
+    public Map<String, Object> bindAdByKuaishou() {
+        Map<String, Object> result = new HashMap<>();
+        String url = "https://ad.oceanengine.com/pages/login/index.html";
+        System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
+        ChromeOptions chromeOptions = new ChromeOptions();
+        chromeOptions.addArguments("--headless");
+        chromeOptions.addArguments("--incognito");
+        chromeOptions.addArguments("--disable-gpu");
+        chromeOptions.addArguments("--no-sandbox");
+        chromeOptions.addArguments("--window-size=1920,1080");
+        chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
+        chromeOptions.setAcceptInsecureCerts(true);
+        WebDriver webDriver = new ChromeDriver(chromeOptions);
+        WebElement element = webDriver.findElement(By.xpath(""));
+        return result;
+    }
+
     @Override
     public Map<String, Object> createInternal(JSONObject requestJson) {
         Map<String, Object> resultMap = new HashMap<>();

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialInfo.java

@@ -43,6 +43,8 @@ public class MaterialInfo {
     @Excel(name = "url", width = 15)
     @ApiModelProperty(value = "url")
     private String url;
+
+    private String type;
     /**
      * status
      */

+ 2 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialInfoService.java

@@ -3,6 +3,7 @@ package cn.com.ctop.common.module.service;
 import cn.com.ctop.common.module.entity.MaterialInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.io.IOException;
 import java.util.Map;
 
 /**
@@ -17,5 +18,5 @@ public interface IMaterialInfoService extends IService<MaterialInfo> {
 
     Map<String, Object> checkMaterialInfo(String code);
 
-    Map<String, Object> insert(String userId, String code, String url);
+    Map<String, Object> insert(String userId, String code, String url) throws IOException;
 }

+ 20 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -9,9 +9,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.io.IOException;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.regex.Pattern;
 
 /**
  * 素材信息
@@ -46,9 +48,21 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         }
     }
 
+    public boolean imgLocation(String fileName) throws IOException {
+        String reg = "(mp4|flv|avi|rm|rmvb|wmv)";
+        Pattern p = Pattern.compile(reg);
+        return p.matcher(fileName).find();
+    }
+
+    public static void main(String[] args) {
+        String reg = "(mp4|flv|avi|rm|rmvb|wmv)";
+        Pattern p = Pattern.compile(reg);
+        System.out.println(p.matcher("https://ctop-media.oss-cn-beijing.aliyuncs.com/video/2019-10-30/ios%E6%8E%A8%E5%B9%BF%E8%A7%86%E9%A2%91-1572437289724.mp4").find());
+    }
     @Override
-    public Map<String, Object> insert(String userId, String code, String url) {
+    public Map<String, Object> insert(String userId, String code, String url) throws IOException {
         Map<String, Object> resultMap = new HashMap<>();
+        Boolean isVideo = imgLocation(url);
         MaterialInfo info = new MaterialInfo();
         info.setId(code);
         info.setCode(code);
@@ -57,6 +71,11 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         info.setUserId(userId);
         info.setCreateTime(new Date());
         info.setUpdateTime(new Date());
+        if (isVideo) {
+            info.setType("VIDEO");
+        } else {
+            info.setType("IMAGE");
+        }
         this.save(info);
         ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
         return resultMap;