瀏覽代碼

修改wps返回url encode问题

syh 4 年之前
父節點
當前提交
fa13d89ca8

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -75,6 +75,9 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/template/creative/words/get", "anon");
         filterChainDefinitionMap.put("template/bytedance/industry/list", "anon");
 
+        filterChainDefinitionMap.put("/bytedance/batch/creative/words/get", "anon");
+        filterChainDefinitionMap.put("/bytedance/batch/action/text", "anon");
+        filterChainDefinitionMap.put("/bytedance/batch/industry/list", "anon");
         filterChainDefinitionMap.put("/appium/crawler/*", "anon");
 
         filterChainDefinitionMap.put("/ctop/kuaishouChannelRegInfo/*", "anon");

+ 0 - 11
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ByteDanceTemplateController.java

@@ -128,15 +128,4 @@ public class ByteDanceTemplateController {
         return fileInfoService.getSiteList(accountId);
     }
 
-    /**
-     * 获取动态词包信息
-     *
-     * @param accountId
-     * @return
-     */
-    @GetMapping("creative/words/get")
-    public Map<String, Object> getCreativeWords(Long accountId) {
-        return fileInfoService.getCreativeWords(accountId);
-    }
-
 }

+ 4 - 6
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -169,12 +169,10 @@ public class SampleTest {
         List<KuaishouEffectVideoInfo>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());
-                if(null==video.getTwoWeekCost()){
-                    effectVideoInfoService.updateTowWeekCostBySignature(video.getSignature());
-                }
+                effectVideoInfoService.updateFinalCostDateBySignature(video.getSignature());
+                effectVideoInfoService.updateInitialCostDateBySignature(video.getSignature());
+                effectVideoInfoService.updateTotalCostBySignature(video.getSignature());
+//                effectVideoInfoService.updateTowWeekCostBySignature(video.getSignature());
             }
         }
     }

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IFileInfoService.java

@@ -29,4 +29,6 @@ public interface IFileInfoService extends IService<FileInfo> {
     JSONObject getCreativeWord(CtopOauthToken token, Long advertiserId);
 
     String downLoadByUrl(String fileUrl);
+
+    JSONObject getActionText(Long accountId, String landingType);
 }

+ 24 - 5
module-common/src/main/java/cn/com/ctop/common/module/service/impl/FileInfoServiceImpl.java

@@ -132,21 +132,40 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
         JSONArray creativeWords = resultObject.getJSONObject("data").getJSONArray("creative_word");
         resultObject.remove("data");
         JSONArray array = new JSONArray();
-        if (null != creativeWords && creativeWords.size() > 0) {
+        if (null != creativeWords && !creativeWords.isEmpty()) {
             creativeWords.forEach(word -> {
                 JSONObject getWord = (JSONObject) word;
-                getWord.remove("user_rate");
-                getWord.remove("content_type");
-                getWord.remove("default_word");
+                String name = getWord.getString("name");
+                getWord.remove("words");
+                getWord.put("name","{"+name+"}");
                 getWord.remove("words");
                 getWord.remove("max_word_len");
-                array.add(getWord);
+                String status = getWord.getString("status");
+                if(null!=status&&status.trim().equals("CREATIVE_WORD_STATUS_APPROVE")){
+                    array.add(getWord);
+                }
             });
         }
         resultObject.put("creative_word", array);
         return resultObject;
     }
 
+    /**
+     * 行动号召数据获取
+     * @return
+     */
+    @Override
+    public JSONObject getActionText(Long accountId,String landingType) {
+        CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId(accountId);
+        // 请求地址
+        String url = "https://ad.oceanengine.com/open_api/2/tools/action_text/get/";
+        // 请求参数
+        JSONObject data = new JSONObject();
+        data.put("advertiser_id", accountId);
+        data.put("landing_type",landingType);
+        return HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, data);
+    }
+
     private JSONObject imageUpload(CtopOauthToken token, String advertiserId, String imageUrl) {
         // 请求地址
         String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_file_image_ad");

+ 33 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/controller/ByteDanceBatchController.java

@@ -1,18 +1,18 @@
 package cn.com.ctop.toutiao.modules.batch.controller;
 
+import cn.com.ctop.common.module.service.IFileInfoService;
+import cn.com.ctop.toutiao.modules.batch.service.IBytedanceIndustryInfoService;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 
 @Slf4j
@@ -21,6 +21,35 @@ import java.util.List;
 public class ByteDanceBatchController {
     @Autowired
     IByteDanceAdvertisePlanService byteDanceAdvertisePlanService;
+    @Autowired
+    private IBytedanceIndustryInfoService bytedanceIndustryInfoService;
+    @Autowired
+    private IFileInfoService fileInfoService;
+    /**
+     * 获取动态词包信息
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping("creative/words/get")
+    public Map<String, Object> getCreativeWords(Long accountId) {
+        return fileInfoService.getCreativeWords(accountId);
+    }
+
+    @GetMapping("action/text")
+    public Map<String,Object>getActionText(Long accountId,String landType){
+        return fileInfoService.getActionText(accountId,landType);
+    }
+
+    @GetMapping("industry/list")
+    public Map<String,Object>getIndustryList(){
+        return bytedanceIndustryInfoService.getIndustryList();
+    }
+
+    @GetMapping("load/industry")
+    public Map<String,Object>loadIndustryList(Long accountId,Integer level){
+        return bytedanceIndustryInfoService.getBytedanceIndustryList(accountId,level);
+    }
 
     /**
      *  批量创建计划

+ 150 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/controller/BytedanceIndustryInfoController.java

@@ -0,0 +1,150 @@
+package cn.com.ctop.toutiao.modules.batch.controller;
+
+import cn.com.ctop.toutiao.modules.batch.entity.BytedanceIndustryInfo;
+import cn.com.ctop.toutiao.modules.batch.service.IBytedanceIndustryInfoService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
+
+ /**
+ * 头条行业类别
+ * @author jeecg-boot
+ * @date   2020-07-30
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="头条行业类别")
+@RestController
+@RequestMapping("/ctop/bytedanceIndustryInfo")
+public class BytedanceIndustryInfoController {
+	@Autowired
+	private IBytedanceIndustryInfoService bytedanceIndustryInfoService;
+
+	/**
+	  * 分页列表查询
+	 * @param bytedanceIndustryInfo
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@ApiOperation(value="头条行业类别-分页列表查询", notes="头条行业类别-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<BytedanceIndustryInfo>> queryPageList(BytedanceIndustryInfo bytedanceIndustryInfo,
+															  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+															  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+															  HttpServletRequest req) {
+		Result<IPage<BytedanceIndustryInfo>> result = new Result<>();
+		QueryWrapper<BytedanceIndustryInfo> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceIndustryInfo, req.getParameterMap());
+		Page<BytedanceIndustryInfo> page = new Page<BytedanceIndustryInfo>(pageNo, pageSize);
+		IPage<BytedanceIndustryInfo> pageList = bytedanceIndustryInfoService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param bytedanceIndustryInfo
+	 * @return
+	 */
+	@ApiOperation(value="头条行业类别-添加", notes="头条行业类别-添加")
+	@PostMapping(value = "/add")
+	public Result<BytedanceIndustryInfo> add(@RequestBody BytedanceIndustryInfo bytedanceIndustryInfo) {
+		Result<BytedanceIndustryInfo> result = new Result<>();
+		try {
+			bytedanceIndustryInfoService.save(bytedanceIndustryInfo);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param bytedanceIndustryInfo
+	 * @return
+	 */
+	@ApiOperation(value="头条行业类别-编辑", notes="头条行业类别-编辑")
+	@PutMapping(value = "/edit")
+	public Result<BytedanceIndustryInfo> edit(@RequestBody BytedanceIndustryInfo bytedanceIndustryInfo) {
+		Result<BytedanceIndustryInfo> result = new Result<BytedanceIndustryInfo>();
+		BytedanceIndustryInfo bytedanceIndustryInfoEntity = bytedanceIndustryInfoService.getById(bytedanceIndustryInfo.getId());
+		if(bytedanceIndustryInfoEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = bytedanceIndustryInfoService.updateById(bytedanceIndustryInfo);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	  *   通过id删除
+	 * @param id
+	 * @return
+	 */
+	@ApiOperation(value="头条行业类别-通过id删除", notes="头条行业类别-通过id删除")
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		try {
+			bytedanceIndustryInfoService.removeById(id);
+		} catch (Exception e) {
+			log.error("删除失败",e.getMessage());
+			return Result.error("删除失败!");
+		}
+		return Result.ok("删除成功!");
+	}
+
+	/**
+	  *  批量删除
+	 * @param ids
+	 * @return
+	 */
+	@ApiOperation(value="头条行业类别-批量删除", notes="头条行业类别-批量删除")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<BytedanceIndustryInfo> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<BytedanceIndustryInfo> result = new Result<>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.bytedanceIndustryInfoService.removeByIds(Arrays.asList(ids.split(",")));
+			result.success("删除成功!");
+		}
+		return result;
+	}
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@ApiOperation(value="头条行业类别-通过id查询", notes="头条行业类别-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<BytedanceIndustryInfo> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<BytedanceIndustryInfo> result = new Result<>();
+		BytedanceIndustryInfo bytedanceIndustryInfo = bytedanceIndustryInfoService.getById(id);
+		if(bytedanceIndustryInfo==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(bytedanceIndustryInfo);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+}

+ 53 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/entity/BytedanceIndustryInfo.java

@@ -0,0 +1,53 @@
+package cn.com.ctop.toutiao.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 头条行业类别
+ * @author jeecg-boot
+ * @date   2020-07-30
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_bytedance_industry_info")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_bytedance_industry_info对象", description="头条行业类别")
+public class BytedanceIndustryInfo {
+
+	/**id*/
+	@TableId
+    @ApiModelProperty(value = "id")
+	private Long id;
+	/**name*/
+	@Excel(name = "name", width = 15)
+    @ApiModelProperty(value = "name")
+	private String name;
+	/**code*/
+	@Excel(name = "code", width = 15)
+    @ApiModelProperty(value = "code")
+	private String code;
+	/**parentCode*/
+	@Excel(name = "parentCode", width = 15)
+    @ApiModelProperty(value = "parentCode")
+	private String parentCode;
+	/**level*/
+	@Excel(name = "level", width = 15)
+    @ApiModelProperty(value = "level")
+	private Integer level;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+}

+ 14 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/mapper/BytedanceIndustryInfoMapper.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.toutiao.modules.batch.mapper;
+
+import cn.com.ctop.toutiao.modules.batch.entity.BytedanceIndustryInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 头条行业类别
+ * @author: jeecg-boot
+ * @date:   2020-07-30
+ * @cersion: V1.0
+ */
+public interface BytedanceIndustryInfoMapper extends BaseMapper<BytedanceIndustryInfo> {
+
+}

+ 5 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/mapper/xml/BytedanceIndustryInfoMapper.xml

@@ -0,0 +1,5 @@
+<?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.batch.mapper.BytedanceIndustryInfoMapper">
+
+</mapper>

+ 19 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/service/IBytedanceIndustryInfoService.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.toutiao.modules.batch.service;
+
+import cn.com.ctop.toutiao.modules.batch.entity.BytedanceIndustryInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.Map;
+
+/**
+ * 头条行业类别
+ * @author jeecg-boot
+ * @date   2020-07-30
+ * @version V1.0
+ */
+public interface IBytedanceIndustryInfoService extends IService<BytedanceIndustryInfo> {
+
+    Map<String, Object> getBytedanceIndustryList(Long accountId,Integer level);
+
+    Map<String, Object> getIndustryList();
+}

+ 116 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/service/impl/BytedanceIndustryInfoServiceImpl.java

@@ -0,0 +1,116 @@
+package cn.com.ctop.toutiao.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
+import cn.com.ctop.toutiao.modules.batch.entity.BytedanceIndustryInfo;
+import cn.com.ctop.toutiao.modules.batch.mapper.BytedanceIndustryInfoMapper;
+import cn.com.ctop.toutiao.modules.batch.service.IBytedanceIndustryInfoService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 头条行业类别
+ * @author jeecg-boot
+ * @date   2020-07-30
+ * @version V1.0
+ */
+@Service
+public class BytedanceIndustryInfoServiceImpl extends ServiceImpl<BytedanceIndustryInfoMapper, BytedanceIndustryInfo> implements IBytedanceIndustryInfoService {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Override
+    public Map<String, Object> getBytedanceIndustryList(Long accountId,Integer level) {
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        // 请求地址
+        String url = "https://ad.oceanengine.com/open_api/2/tools/industry/get/";
+        // 请求参数
+        JSONObject data = new JSONObject();
+        if(null!=level&&level!=0){
+            data.put("level",level);
+        }
+        JSONObject result = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, data);
+        JSONArray arrays = result.getJSONObject("data").getJSONArray("list");
+        for(int i=0;i<arrays.size();i++){
+            JSONObject getData = arrays.getJSONObject(i);
+            BytedanceIndustryInfo industryInfo = new BytedanceIndustryInfo();
+            Integer getLevel = getData.getInteger("level");
+            industryInfo.setLevel(getLevel);
+            industryInfo.setName(getData.getString("industry_name"));
+            industryInfo.setCode(getData.getLong("industry_id")+"");
+            industryInfo.setId(getData.getLong("industry_id"));
+            if(getLevel == 1){
+                industryInfo.setParentCode("0");
+            }
+            if(getLevel == 2){
+                industryInfo.setParentCode(getData.getLong("first_industry_id")+"");
+            }
+            if(getLevel == 3){
+                industryInfo.setParentCode(getData.getLong("second_industry_id")+"");
+            }
+            industryInfo.setUpdateTime(new Date());
+            this.saveOrUpdate(industryInfo);
+        }
+        return result;
+    }
+
+    @Override
+    public Map<String, Object> getIndustryList() {
+        Map<String,Object>result = new HashMap<>();
+        List<BytedanceIndustryInfo>firstLevelIndustry = this.getListByParams(1,"0");
+        JSONArray array = new JSONArray();
+        for (BytedanceIndustryInfo firstInfo:firstLevelIndustry) {
+            JSONObject firstData = new JSONObject();
+            firstData.put("id",firstInfo.getId());
+            firstData.put("name",firstInfo.getName());
+            List<BytedanceIndustryInfo>secondLevelIndustry = this.getListByParams(2,firstInfo.getCode());
+            if(null!=secondLevelIndustry&&!secondLevelIndustry.isEmpty()){
+                JSONArray firstChildrenArray = new JSONArray();
+                for(BytedanceIndustryInfo secendInfo:secondLevelIndustry){
+                    JSONObject secondData = new JSONObject();
+                    secondData.put("id",secendInfo.getId());
+                    secondData.put("name",secendInfo.getName());
+                    List<BytedanceIndustryInfo>thirdLevelIndustry = this.getListByParams(3,secendInfo.getCode());
+                    if(null!=thirdLevelIndustry&&!thirdLevelIndustry.isEmpty()){
+                        JSONArray secondChildrenArray = new JSONArray();
+                        for (BytedanceIndustryInfo thirdInfo:thirdLevelIndustry) {
+                            JSONObject thirdChData = new JSONObject();
+                            thirdChData.put("id",thirdInfo.getId());
+                            thirdChData.put("name",thirdInfo.getName());
+                            secondChildrenArray.add(thirdChData);
+                        }
+                        secondData.put("children",secondChildrenArray);
+                    }
+                    firstChildrenArray.add(secondData);
+                }
+                firstData.put("children",firstChildrenArray);
+            }
+            array.add(firstData);
+        }
+        result.put("data",array);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+    }
+
+    public List<BytedanceIndustryInfo>getListByParams(Integer level,String parentCode){
+        QueryWrapper<BytedanceIndustryInfo>queryWrapper = new QueryWrapper<>();
+        if(null!=level&&level!=0){
+            queryWrapper.eq("level",level);
+        }
+        if(null!=parentCode&&!parentCode.trim().equals("")){
+            queryWrapper.eq("parent_code",parentCode);
+        }
+       return this.list(queryWrapper);
+    }
+}