package org.jeecg; import cn.com.ctop.common.module.entity.BindAccountLogin; import cn.com.ctop.common.module.entity.CtopOauthToken; import cn.com.ctop.common.module.service.IBindAccountLoginService; import cn.com.ctop.common.module.service.ICtopOauthTokenService; import cn.com.ctop.common.module.utils.CtopAdConstant; import cn.com.ctop.common.module.utils.HttpUtils; import cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp; import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService; import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService; import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService; import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService; import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService; import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService; import cn.com.ctop.toutiao.modules.material.service.IByteDanceCampaignService; import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.util.DateUtils; import org.jeecg.modules.ctop.entity.KuaishouEffectVideoInfo; import org.jeecg.modules.ctop.service.IKuaishouEffectVideoInfoService; import org.jeecg.modules.ctop.service.IProjectMemberService; import org.jeecg.modules.ctop.service.IRuleEngineService; import org.junit.Test; import org.junit.runner.RunWith; import org.kie.api.runtime.KieSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @RunWith(SpringRunner.class) @SpringBootTest @Slf4j public class SampleTest { @Autowired private ICtopOauthTokenService oauthTokenService; @Autowired private IByteDanceAdvertiserDataService advertiserDataService; @Autowired private IByteDanceCreativeService creativeService; @Autowired private IKuaishouInterfaceService iKuaishouInterfaceService; @Test public void loadBytedanceCreativeData() { /** * */ CtopOauthToken token = oauthTokenService.getTokenByAccountId(23212L); iKuaishouInterfaceService.getCampaignList(token, null, null); // advertiserDataService.getMaterialList(token); } @Test public void test() { /** * */ // CtopOauthToken token = oauthTokenService.getTokenByAccountId(23212L); // iKuaishouInterfaceService.getCampaignList(token,null,null); // advertiserDataService.getMaterialList(token); // HttpUtils.httpPostRequest() Map paramsMap = new HashMap<>(); paramsMap.put("campaignType",2); String url = "https://ad.e.kuaishou.com/rest/dsp/control-panel/cover/list/actionBarText"; String s = HttpUtils.httpGet(url, paramsMap, null); System.err.println(s); } @Autowired private IBindAccountLoginService bindAccountLoginService; @Autowired private IKuaishouWebInterfaceService kuaishouWebInterfaceService; @Test public void kuaishouLogin() { Long start = System.currentTimeMillis(); List list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1); if (list != null && !list.isEmpty()) { for (BindAccountLogin login : list) { if (null == login.getCookie() || "".equals(login.getCookie().trim())) { kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login); } } } Long end = System.currentTimeMillis(); log.info("总用时:{}毫秒", end - start); } static ExecutorService executorService = Executors.newFixedThreadPool(10); ; static CountDownLatch countDownLatch = null; @Test public void kuaishouCommentDelete() { Long start = System.currentTimeMillis(); List list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1); if (list != null && !list.isEmpty()) { countDownLatch = new CountDownLatch(list.size()); list.forEach(login -> { executorService.submit(() -> { try { if (null != login.getCookie() && !"".equals(login.getCookie().trim())) { kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login); } } catch (Exception e) { } finally { countDownLatch.countDown(); } }); }); } try { countDownLatch.await(); } catch (InterruptedException e) { e.printStackTrace(); } Long end = System.currentTimeMillis(); log.info("总用时:{}毫秒", end - start); } @Autowired private PangolinLoginService pangolinLoginService; @Autowired private PangolinCrawlerService pangolinCrawlerService; @Autowired private PangolinAppService pangolinAppService; @Test public void testPangolinLogin() { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("login_type", "pangolin"); queryWrapper.eq("status", 1); List list = bindAccountLoginService.list(queryWrapper); if (list != null && !list.isEmpty()) { for (BindAccountLogin login : list) { if (null == login.getCookie() || "".equals(login.getCookie().trim())) { pangolinLoginService.pangolinLogin(login.getAccountName(), login.getPassword()); } } } } @Test public void testPangolinData() { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("login_type", "pangolin"); queryWrapper.eq("status", 1); queryWrapper.isNotNull("cookie"); List list = bindAccountLoginService.list(queryWrapper); if (list != null && !list.isEmpty()) { for (BindAccountLogin bindAccountLogin : list) { pangolinCrawlerService.getChannelList(bindAccountLogin); pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1); pangolinCrawlerService.getCheckList(bindAccountLogin); QueryWrapper queryWrapper1 = new QueryWrapper<>(); queryWrapper1.eq("account_name", bindAccountLogin.getAccountName()); List appList = pangolinAppService.list(queryWrapper1); if (appList != null && !appList.isEmpty()) { appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getAppId())); } } } } @Autowired private IByteDanceCampaignService campaignService; @Test public void testGetCampaign() { CtopOauthToken token = oauthTokenService.getOauthTokenByAccountId("1649600126891015"); campaignService.getAdvertiserCampaign(token, "1672261893872756", null); } @Autowired private IKuaishouEffectVideoInfoService effectVideoInfoService; @Test public void loadKuaishouEffectVideoInfo() { List videoInfos = effectVideoInfoService.list(); for (KuaishouEffectVideoInfo video : videoInfos) { if (null != video.getSignature() && !"".equals(video.getSignature())) { effectVideoInfoService.updateFinalCostDateBySignature(video.getSignature()); effectVideoInfoService.updateInitialCostDateBySignature(video.getSignature()); effectVideoInfoService.updateTotalCostBySignature(video.getSignature()); // effectVideoInfoService.updateTowWeekCostBySignature(video.getSignature()); } } } @Test public void getIndustryInfo() { String access_token = "cbdf6502c04978ae401cb92a64530fb73a8c7dbe"; // 请求地址 String url = "https://ad.oceanengine.com/open_api/2/tools/industry/get/"; JSONObject jsonObject = HttpUtils.bytedanceGetRequest(access_token, url, new JSONObject()); System.out.println(jsonObject.toJSONString()); } @Test public void loadImageInfo() throws Exception { List tokens = oauthTokenService.selectToutiaoToken(); for (CtopOauthToken token : tokens) { advertiserDataService.getImageByPage(token, null, 1); Thread.sleep(1000L); } } @Resource private KieSession kieSession; @Autowired private IRuleEngineService ruleEngineService; @Autowired private IProjectMemberService projectMemberService; @Test public void testLoadAccount() { String userId = "c3611c88d0c8414abd3d2ee2a5a0ee7a"; List> result = projectMemberService.getProjectAccountByUserId(userId); } }