Forráskód Böngészése

定型包初版开发

zhaoxian 4 éve
szülő
commit
5e5316fa09

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -83,8 +83,19 @@ public class KuaishouInterfaceConstant {
      * 创建定向模板
      */
     public static final String TEMPLATE_CREATE = "/rest/openapi/v1/target/template/create";
+
     public static final String TEMPLATE_UPDATE = "/rest/openapi/v1/target/template/update";
     /**
+     * 获取行为与兴趣"类目"
+     */
+    public static final String BEHAVIOR_INTEREST = "/rest/openapi/v1/tool/label/behavior_interest";
+
+    /**
+     * 获取行为兴趣"关键词"
+     */
+    public static final String KEYWORD_QUERY = "/rest/openapi/v1/tool/keyword/query";
+
+    /**
      * 获取地域信息
      */
     public static final String REGION_LIST = "/rest/openapi/v1/region/list";

+ 460 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaishouDirectionalPackageController.java

@@ -0,0 +1,460 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.QueryGenerator;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+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.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 自动投放-定向包详情
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-20
+ */
+@Slf4j
+@Api(tags = "自动投放-定向包详情")
+@RestController
+@RequestMapping("/kuaishouDirectionalPackage")
+public class KuaishouDirectionalPackageController {
+    @Autowired
+    private IKuaishouDirectionalPackageService kuaishouDirectionalPackageService;
+
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouDirectionalPackage
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "自动投放-定向包详情-分页列表查询")
+    @ApiOperation(value = "自动投放-定向包详情-分页列表查询", notes = "自动投放-定向包详情-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouDirectionalPackage>> queryPageList(KuaishouDirectionalPackage kuaishouDirectionalPackage,
+                                                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                   HttpServletRequest req) {
+        Result<IPage<KuaishouDirectionalPackage>> result = new Result<>();
+        QueryWrapper<KuaishouDirectionalPackage> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouDirectionalPackage, req.getParameterMap());
+        Page<KuaishouDirectionalPackage> page = new Page<KuaishouDirectionalPackage>(pageNo, pageSize);
+        IPage<KuaishouDirectionalPackage> pageList = kuaishouDirectionalPackageService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 查询定向包列表
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/queryList")
+    public Result<Object> queryList(KuaishouDirectionalPackage directionalPackage,
+                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            return kuaishouDirectionalPackageService.queryList(directionalPackage, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 相关账户/组
+     *
+     * @param projectId 账户ID
+     * @param type      1是账户,2是组维度
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getRelatedAccountGroup")
+    public Result<Object> getRelatedAccountGroup(Long projectId, Long templateId, Integer type,
+                                                 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(templateId)) {
+                return Result.error("请选择人群包");
+            }
+            if (Check.isNull(projectId)) {
+                return Result.error("请选择项目");
+            }
+            if (Check.isNull(type)) {
+                return Result.error("请选择查询类型");
+            }
+            return kuaishouDirectionalPackageService.getRelatedAccountGroup(projectId, templateId, type, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 查询定向包推送历史
+     *
+     * @param projectId 账户ID
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getHistory")
+    public Result<Object> getHistory(Long projectId, Long templateId,
+                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(templateId)) {
+                return Result.error("请选择人群包");
+            }
+            if (Check.isNull(projectId)) {
+                return Result.error("请选择项目");
+            }
+
+            return kuaishouDirectionalPackageService.getHistory(projectId, templateId, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 查询项目下有效账户
+     *
+     * @param projectId 账户ID
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getHistory")
+    public Result<Object> getAccountByProjectId(Long projectId,
+                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            if (Check.isNull(projectId)) {
+                return Result.error("请选择项目");
+            }
+            return kuaishouDirectionalPackageService.getAccountByProjectId(projectId, pageNo, pageSize);
+        } catch (Exception e) {
+            log.error("查询异常,", e.getMessage());
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /**
+     * 创建定向包
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/createDirectionalPackage")
+    public Result<Object> createDirectionalPackage(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson.getString("templateName"))) {
+                return Result.error("定向模板名称为必传项");
+            }
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                return Result.error("请选择账户id");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                return Result.error("未获取到账户信息");
+            }
+            return kuaishouDirectionalPackageService.createDirectionalPackage(oauthToken.getAccessToken(), requestJson);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return Result.error("上传失败");
+    }
+
+    /**
+     * 修改定向包
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/updateDirectionalPackage")
+    public Result<Object> updateDirectionalPackage(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson.getString("templateName"))) {
+                return Result.error("定向模板名称为必传项");
+            }
+            if (Check.isNull(requestJson.getLong("templateId"))) {
+                return Result.error("定向模板id为必传项");
+            }
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                return Result.error("请选择账户id");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                return Result.error("未获取到账户信息");
+            }
+            return kuaishouDirectionalPackageService.updateDirectionalPackage(oauthToken.getAccessToken(), requestJson);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return Result.error("上传失败");
+    }
+
+    /**
+     * 推送定向包
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "/pushDirectionalPackage")
+    public Result<Object> pushDirectionalPackage(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            Long templateId = requestJson.getLong("templateId");
+            JSONArray ids = requestJson.getJSONArray("ids");
+            if (Check.isNull(templateId)) {
+                return Result.error("请选择人群包");
+            }
+            if (Check.isNull(accountId)) {
+                return Result.error("请选择目标账户");
+            }
+            if (Check.isNull(ids)) {
+                return Result.error("请选择推送账户");
+            }
+            return kuaishouDirectionalPackageService.pushDirectionalPackage(accountId, templateId, ids);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return Result.error("上传失败");
+    }
+
+
+    /**
+     * 添加
+     *
+     * @param kuaishouDirectionalPackage
+     * @return
+     */
+    @AutoLog(value = "自动投放-定向包详情-添加")
+    @ApiOperation(value = "自动投放-定向包详情-添加", notes = "自动投放-定向包详情-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouDirectionalPackage> add(@RequestBody KuaishouDirectionalPackage kuaishouDirectionalPackage) {
+        Result<KuaishouDirectionalPackage> result = new Result<>();
+        try {
+            kuaishouDirectionalPackageService.save(kuaishouDirectionalPackage);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouDirectionalPackage
+     * @return
+     */
+    @AutoLog(value = "自动投放-定向包详情-编辑")
+    @ApiOperation(value = "自动投放-定向包详情-编辑", notes = "自动投放-定向包详情-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouDirectionalPackage> edit(@RequestBody KuaishouDirectionalPackage kuaishouDirectionalPackage) {
+        Result<KuaishouDirectionalPackage> result = new Result<KuaishouDirectionalPackage>();
+        KuaishouDirectionalPackage kuaishouDirectionalPackageEntity = kuaishouDirectionalPackageService.getById(kuaishouDirectionalPackage.getId());
+        if (kuaishouDirectionalPackageEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouDirectionalPackageService.updateById(kuaishouDirectionalPackage);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "自动投放-定向包详情-通过id删除")
+    @ApiOperation(value = "自动投放-定向包详情-通过id删除", notes = "自动投放-定向包详情-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            kuaishouDirectionalPackageService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "自动投放-定向包详情-批量删除")
+    @ApiOperation(value = "自动投放-定向包详情-批量删除", notes = "自动投放-定向包详情-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouDirectionalPackage> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouDirectionalPackage> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouDirectionalPackageService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "自动投放-定向包详情-通过id查询")
+    @ApiOperation(value = "自动投放-定向包详情-通过id查询", notes = "自动投放-定向包详情-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouDirectionalPackage> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouDirectionalPackage> result = new Result<>();
+        KuaishouDirectionalPackage kuaishouDirectionalPackage = kuaishouDirectionalPackageService.getById(id);
+        if (kuaishouDirectionalPackage == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouDirectionalPackage);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouDirectionalPackage> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouDirectionalPackage kuaishouDirectionalPackage = JSON.parseObject(deString, KuaishouDirectionalPackage.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouDirectionalPackage, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouDirectionalPackage> pageList = kuaishouDirectionalPackageService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "自动投放-定向包详情列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouDirectionalPackage.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("自动投放-定向包详情列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaishouDirectionalPackage> listKuaishouDirectionalPackages = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouDirectionalPackage.class, params);
+                kuaishouDirectionalPackageService.saveBatch(listKuaishouDirectionalPackages);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouDirectionalPackages.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 258 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/KuaishouDirectionalPackage.java

@@ -0,0 +1,258 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+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
+ * @version V1.0
+ * @date 2021-04-20
+ */
+@Data
+@TableName("ctop_kuaishou_directional_package")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_directional_package对象", description = "自动投放-定向包详情")
+public class KuaishouDirectionalPackage {
+
+    /**
+     * id
+     */
+    private String id;
+    /**
+     * 定向模板id
+     */
+    @Excel(name = "定向模板id", width = 15)
+    @ApiModelProperty(value = "定向模板id")
+    private Long templateId;
+
+    private Long accountId;
+    /**
+     * 0无效,1有效
+     */
+    private int dataStatus;
+
+    private String message;
+    private String templateName;
+    /**
+     * 地域
+     */
+    @Excel(name = "地域", width = 15)
+    @ApiModelProperty(value = "地域")
+    private String region;
+    /**
+     * 商圈定向
+     */
+    @Excel(name = "商圈定向", width = 15)
+    @ApiModelProperty(value = "商圈定向")
+    private String districtIds;
+    /**
+     * 用户类型 0:实时1:常驻 2:不限
+     */
+    @Excel(name = "用户类型 0:实时1:常驻 2:不限 ", width = 15)
+    @ApiModelProperty(value = "用户类型 0:实时1:常驻 2:不限 ")
+    private Integer userType;
+    /**
+     * 可选年龄段 18:18-23岁 24:24-30岁 31:31-40岁 41:41-49岁 50:50-100岁
+     */
+    @Excel(name = "可选年龄段 18:18-23岁 24:24-30岁 31:31-40岁 41:41-49岁 50:50-100岁 ", width = 15)
+    @ApiModelProperty(value = "可选年龄段 18:18-23岁 24:24-30岁 31:31-40岁 41:41-49岁 50:50-100岁 ")
+    private String agesRange;
+    /**
+     * 年龄最小值
+     */
+    @Excel(name = "年龄最小值", width = 15)
+    @ApiModelProperty(value = "年龄最小值")
+    private Integer min;
+    /**
+     * 年龄最大值
+     */
+    @Excel(name = "年龄最大值", width = 15)
+    @ApiModelProperty(value = "年龄最大值")
+    private Integer max;
+    /**
+     * 性别 1:女性, 2:男性,0 表示不限
+     */
+    @Excel(name = "性别 1:女性, 2:男性,0 表示不限", width = 15)
+    @ApiModelProperty(value = "性别 1:女性, 2:男性,0 表示不限")
+    private Integer gender;
+    /**
+     * 定向的 os 版本 应用安装类计划以app_id中的platform_os为准 1:Android,2:iOS,0 表示不限
+     */
+    @Excel(name = "定向的 os 版本 应用安装类计划以app_id中的platform_os为准 1:Android,2:iOS,0 表示不限", width = 15)
+    @ApiModelProperty(value = "定向的 os 版本 应用安装类计划以app_id中的platform_os为准 1:Android,2:iOS,0 表示不限")
+    private Integer platformOs;
+    /**
+     * Android 版本 3:不限,4:4.x+,5:5.x+,6:6.x+,7:7.x+
+     */
+    @Excel(name = "Android 版本 3:不限,4:4.x+,5:5.x+,6:6.x+,7:7.x+", width = 15)
+    @ApiModelProperty(value = "Android 版本 3:不限,4:4.x+,5:5.x+,6:6.x+,7:7.x+")
+    private Integer androidOsv;
+    /**
+     * iOS 版本 6:不限, 7:7.x+, 8:8.x+, 9:9.x+, 10:10.x+
+     */
+    @Excel(name = "iOS 版本 6:不限, 7:7.x+, 8:8.x+, 9:9.x+, 10:10.x+", width = 15)
+    @ApiModelProperty(value = "iOS 版本 6:不限, 7:7.x+, 8:8.x+, 9:9.x+, 10:10.x+")
+    private Integer iosOsv;
+    /**
+     * 网络环境 1:WI-FI,2:移动网络,0:表示不限
+     */
+    @Excel(name = "网络环境 1:WI-FI,2:移动网络,0:表示不限", width = 15)
+    @ApiModelProperty(value = "网络环境 1:WI-FI,2:移动网络,0:表示不限")
+    private Integer network;
+    /**
+     * 过滤已转化人群纬度 0:不限 1:广告组 2:广告计划 3:本账户 4:公司主体 5:APP
+     */
+    @Excel(name = "过滤已转化人群纬度 0:不限 1:广告组 2:广告计划 3:本账户 4:公司主体 5:APP", width = 15)
+    @ApiModelProperty(value = "过滤已转化人群纬度 0:不限 1:广告组 2:广告计划 3:本账户 4:公司主体 5:APP")
+    private Integer filterConvertedLevel;
+    /**
+     * 设备品牌  1:OPPO,2:VIVO, 3:华为,4:小米,5:荣耀,6:三星,7:金立,8:魅族,9:乐视,10:其他,11:苹果(只有 platform_os 为不限时支持此选项);传值为 [] 表示不限;当 platform_os 表示 iOS 的时候,没有设备品牌定向
+     */
+    @Excel(name = "设备品牌  1:OPPO,2:VIVO, 3:华为,4:小米,5:荣耀,6:三星,7:金立,8:魅族,9:乐视,10:其他,11:苹果(只有 platform_os 为不限时支持此选项);传值为 [] 表示不限;当 platform_os 表示 iOS 的时候,没有设备品牌定向", width = 15)
+    @ApiModelProperty(value = "设备品牌  1:OPPO,2:VIVO, 3:华为,4:小米,5:荣耀,6:三星,7:金立,8:魅族,9:乐视,10:其他,11:苹果(只有 platform_os 为不限时支持此选项);传值为 [] 表示不限;当 platform_os 表示 iOS 的时候,没有设备品牌定向")
+    private String deviceBrand;
+    /**
+     * 设备价格 1:1,500元以下,2:1,501~2,000,3:2,001~2,500,4:2,501~3,000,5、3,001~3,500,6:3,501~4,000,7:4,001~4,500,8:4,501~5,000,9:5,001~5,500,10:5,500元以上,传值为 [] 表示不限
+     */
+    @Excel(name = "设备价格 1:1,500元以下,2:1,501~2,000,3:2,001~2,500,4:2,501~3,000,5、3,001~3,500,6:3,501~4,000,7:4,001~4,500,8:4,501~5,000,9:5,001~5,500,10:5,500元以上,传值为 [] 表示不限", width = 15)
+    @ApiModelProperty(value = "设备价格 1:1,500元以下,2:1,501~2,000,3:2,001~2,500,4:2,501~3,000,5、3,001~3,500,6:3,501~4,000,7:4,001~4,500,8:4,501~5,000,9:5,001~5,500,10:5,500元以上,传值为 [] 表示不限")
+    private String devicePrice;
+    /**
+     * 商业兴趣类型 0:默认值 1:智能投放 2:兴趣标签
+     */
+    @Excel(name = "商业兴趣类型 0:默认值 1:智能投放 2:兴趣标签", width = 15)
+    @ApiModelProperty(value = "商业兴趣类型 0:默认值 1:智能投放 2:兴趣标签")
+    private Integer businessInterestType;
+    /**
+     * 商业兴趣
+     */
+    @Excel(name = "商业兴趣", width = 15)
+    @ApiModelProperty(value = "商业兴趣")
+    private String businessInterest;
+    /**
+     * 网红类别
+     */
+    @Excel(name = "网红类别", width = 15)
+    @ApiModelProperty(value = "网红类别")
+    private String fansStar;
+    /**
+     * 兴趣视频
+     */
+    @Excel(name = "兴趣视频", width = 15)
+    @ApiModelProperty(value = "兴趣视频")
+    private String interestVideo;
+    /**
+     * APP行为-按分类
+     */
+    @Excel(name = "APP行为-按分类", width = 15)
+    @ApiModelProperty(value = "APP行为-按分类")
+    private String appInterest;
+    /**
+     * APP行为-按APP名称
+     */
+    @Excel(name = "APP行为-按APP名称", width = 15)
+    @ApiModelProperty(value = "APP行为-按APP名称")
+    private String appIds;
+    /**
+     * 定向人群包
+     */
+    @Excel(name = "定向人群包", width = 15)
+    @ApiModelProperty(value = "定向人群包")
+    private String population;
+    /**
+     * 付费人群包
+     */
+    @Excel(name = "付费人群包", width = 15)
+    @ApiModelProperty(value = "付费人群包")
+    private String paidAudience;
+    /**
+     * 排除人群包
+     */
+    @Excel(name = "排除人群包", width = 15)
+    @ApiModelProperty(value = "排除人群包")
+    private String excludePopulation;
+    /**
+     * 开启智能扩量 默认为0,为1时打开智能扩量,其他数值报错;关闭智能扩量时,以下三个字段必须为0
+     */
+    @Excel(name = "开启智能扩量 默认为0,为1时打开智能扩量,其他数值报错;关闭智能扩量时,以下三个字段必须为0", width = 15)
+    @ApiModelProperty(value = "开启智能扩量 默认为0,为1时打开智能扩量,其他数值报错;关闭智能扩量时,以下三个字段必须为0")
+    private Integer isOpen;
+    /**
+     * 不可突破年龄 默认为0(可突破/无需控制),定向age数据不为空时,可设为1(不可突破)
+     */
+    @Excel(name = "不可突破年龄 默认为0(可突破/无需控制),定向age数据不为空时,可设为1(不可突破)", width = 15)
+    @ApiModelProperty(value = "不可突破年龄 默认为0(可突破/无需控制),定向age数据不为空时,可设为1(不可突破)")
+    private Integer noAgeBreak;
+    /**
+     * 不可突破性别 默认为0(可突破/无需控制),定向gender数据不为空时,可设为1(不可突破
+     */
+    @Excel(name = "不可突破性别 默认为0(可突破/无需控制),定向gender数据不为空时,可设为1(不可突破", width = 15)
+    @ApiModelProperty(value = "不可突破性别 默认为0(可突破/无需控制),定向gender数据不为空时,可设为1(不可突破")
+    private Integer noGenderBreak;
+    /**
+     * 不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)
+     */
+    @Excel(name = "不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)", width = 15)
+    @ApiModelProperty(value = "不可突破地域 默认为0(可突破/无需控制),定向region数据不为空时,可设为1(不可突破)")
+    private Integer noAreaBreak;
+    /**
+     * 行为定向关键词
+     */
+    @Excel(name = "行为定向关键词", width = 15)
+    @ApiModelProperty(value = "行为定向关键词")
+    private String keyword;
+    /**
+     * 行为定向 类目词
+     */
+    @Excel(name = "行为定向 类目词", width = 15)
+    @ApiModelProperty(value = "行为定向 类目词")
+    private String label;
+    /**
+     * 兴趣定向类目词
+     */
+    @Excel(name = "兴趣定向类目词", width = 15)
+    @ApiModelProperty(value = "兴趣定向类目词")
+    private String interestLabel;
+    /**
+     * 在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天
+     */
+    @Excel(name = "在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天", width = 15)
+    @ApiModelProperty(value = "在多少天内发生行为的用户 0:7天 1:15天 2:30天 3:90天 4:180天")
+    private Integer timeType;
+    /**
+     * 行为强度	0:不限 1:高强度
+     */
+    @Excel(name = "行为强度	0:不限 1:高强度", width = 15)
+    @ApiModelProperty(value = "行为强度	0:不限 1:高强度")
+    private Integer strengthType;
+    /**
+     * 行为场景	1:社区 2:APP 4:推广
+     */
+    @Excel(name = "行为场景	1:社区 2:APP 4:推广", width = 15)
+    @ApiModelProperty(value = "行为场景	1:社区 2:APP 4:推广")
+    private String sceneType;
+    /**
+     * 定向模板创建时间
+     */
+    @ApiModelProperty(value = "定向模板创建时间")
+    private Date createTime;
+    /**
+     * 定向模板修改时间
+     */
+    @ApiModelProperty(value = "定向模板修改时间")
+    private Date updateTime;
+
+    @TableField(exist = false)
+    private Long projectId;
+}

+ 15 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/KuaishouDirectionalPackageMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 自动投放-定向包详情
+ *
+ * @author: jeecg-boot
+ * @date: 2021-04-20
+ * @cersion: V1.0
+ */
+public interface KuaishouDirectionalPackageMapper extends BaseMapper<KuaishouDirectionalPackage> {
+
+}

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/KuaishouDirectionalPackageMapper.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.kuaishou.modules.ai.mapper.KuaishouDirectionalPackageMapper">
+
+</mapper>

+ 30 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IKuaishouDirectionalPackageService.java

@@ -0,0 +1,30 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * @Description: 自动投放-定向包详情
+ * @Author: jeecg-boot
+ * @Date: 2021-04-20
+ * @Version: V1.0
+ */
+public interface IKuaishouDirectionalPackageService extends IService<KuaishouDirectionalPackage> {
+
+    Result<Object> createDirectionalPackage(String accessToken, JSONObject requestJson);
+
+    Result<Object> updateDirectionalPackage(String accessToken, JSONObject requestJson);
+
+    Result<Object> queryList(KuaishouDirectionalPackage directionalPackage, Integer pageNo, Integer pageSize);
+
+    Result<Object> getRelatedAccountGroup(Long projectId,Long templateId, Integer type, Integer pageNo, Integer pageSize);
+
+    Result<Object> pushDirectionalPackage(Long accountId, Long templateId, JSONArray ids);
+
+    Result<Object> getHistory(Long projectId, Long templateId, Integer pageNo, Integer pageSize);
+
+    Result<Object> getAccountByProjectId(Long projectId, Integer pageNo, Integer pageSize);
+}

+ 397 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouDirectionalPackageServiceImpl.java

@@ -0,0 +1,397 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouDirectionalPackageMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 自动投放-定向包详情
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-04-20
+ */
+@Slf4j
+@Service
+public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouDirectionalPackageMapper, KuaishouDirectionalPackage> implements IKuaishouDirectionalPackageService {
+
+    @Override
+    public Result<Object> createDirectionalPackage(String accessToken, JSONObject requestJson) {
+        JSONObject returnJson = new JSONObject();
+        String message = "";
+        int flag = -1;
+        try {
+            JSONObject param = new JSONObject();
+            param.put("advertiser_id", requestJson.getLong("accountId"));
+            param.put("template_name", requestJson.getString("templateName"));
+            JSONObject targetJson = new JSONObject();
+            if (!Check.isNull(requestJson.getJSONArray("region"))) {
+                targetJson.put("region", requestJson.getJSONArray("region"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("districtIds"))) {
+                targetJson.put("district_ids", requestJson.getJSONArray("districtIds"));
+            }
+            if (!Check.isNull(requestJson.getInteger("userType"))) {
+                targetJson.put("user_type", requestJson.getInteger("userType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("agesRange"))) {
+                targetJson.put("ages_range", requestJson.getJSONArray("agesRange"));
+            }
+
+            JSONObject ageJson = new JSONObject();
+            if (!Check.isNull(requestJson.getInteger("min"))) {
+                ageJson.put("min", requestJson.getInteger("min"));
+            }
+            if (!Check.isNull(requestJson.getInteger("max"))) {
+                ageJson.put("max", requestJson.getInteger("max"));
+            }
+            if (!Check.isNull(ageJson)) {
+                targetJson.put("age", ageJson);
+            }
+
+            if (!Check.isNull(requestJson.getInteger("gender"))) {
+                targetJson.put("gender", requestJson.getInteger("gender"));
+            }
+            if (!Check.isNull(requestJson.getInteger("platformOs"))) {
+                targetJson.put("platform_os", requestJson.getInteger("platformOs"));
+            }
+            if (!Check.isNull(requestJson.getInteger("androidOsv"))) {
+                targetJson.put("android_osv", requestJson.getInteger("androidOsv"));
+            }
+            if (!Check.isNull(requestJson.getInteger("iosOsv"))) {
+                targetJson.put("ios_osv", requestJson.getInteger("iosOsv"));
+            }
+            if (!Check.isNull(requestJson.getInteger("network"))) {
+                targetJson.put("network", requestJson.getInteger("network"));
+            }
+            if (!Check.isNull(requestJson.getInteger("filterConvertedLevel"))) {
+                targetJson.put("filter_converted_level", requestJson.getInteger("filterConvertedLevel"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("deviceBrand"))) {
+                targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
+                targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
+            }
+            if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
+                targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
+                targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
+                targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
+                targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
+                targetJson.put("app_interest", requestJson.getJSONArray("appInterest"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("appIds"))) {
+                targetJson.put("app_ids", requestJson.getJSONArray("appIds"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("population"))) {
+                targetJson.put("population", requestJson.getJSONArray("population"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("paidAudience"))) {
+                targetJson.put("paid_audience", requestJson.getJSONArray("paidAudience"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
+                targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
+            }
+            JSONObject intelliExtendJson = new JSONObject();
+
+            if (!Check.isNull(requestJson.getInteger("isOpen"))) {
+                intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
+            }
+            if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
+                intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
+            }
+            if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
+                intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
+            }
+            if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
+                intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
+            }
+            if (!Check.isNull(intelliExtendJson)) {
+                targetJson.put("intelli_extend", intelliExtendJson);
+            }
+            if (!Check.isNull(targetJson)) {
+                param.put("target", targetJson);
+            }
+            JSONObject behaviorInterest = new JSONObject();
+            JSONObject behavior = new JSONObject();
+            JSONObject interest = new JSONObject();
+            if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
+                behavior.put("keyword", requestJson.getJSONArray("keyword"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("label"))) {
+                behavior.put("label", requestJson.getJSONArray("label"));
+            }
+            if (!Check.isNull(requestJson.getInteger("strengthType"))) {
+                behavior.put("strength_type", requestJson.getInteger("strengthType"));
+            }
+            if (!Check.isNull(requestJson.getInteger("timeType"))) {
+                behavior.put("time_type", requestJson.getInteger("timeType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("sceneType"))) {
+                behavior.put("scene_type", requestJson.getJSONArray("sceneType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("interestLabel"))) {
+                interest.put("label", requestJson.getJSONArray("interestLabel"));
+            }
+            if (!Check.isNull(behavior)) {
+                behaviorInterest.put("behavior", behavior);
+            }
+            if (!Check.isNull(interest)) {
+                behaviorInterest.put("interest", interest);
+            }
+            if (!Check.isNull(behaviorInterest)) {
+                param.put("behavior_interest", behaviorInterest);
+            }
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Access-Token", accessToken);
+            headers.put("Content-Type", " application/json");
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_CREATE;
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                message = resultJson.getString("message");
+                if (code == 0) {
+                    flag = code;
+                    JSONObject data = resultJson.getJSONObject("data");
+                    requestJson.put("templateId", data.getLong("template_id"));
+                    requestJson.put("dataStatus", 1);
+                } else {
+                    requestJson.put("dataStatus", 0);
+                }
+            } else {
+                requestJson.put("dataStatus", 0);
+                message = "返回结果为空";
+            }
+            requestJson.put("message", message);
+            KuaishouDirectionalPackage kuaishouDirectionalPackage = JSONObject.toJavaObject(requestJson, KuaishouDirectionalPackage.class);
+            this.save(kuaishouDirectionalPackage);
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        if (flag == 0) {
+            return Result.ok(message);
+        } else {
+            return Result.error(message);
+        }
+    }
+
+    @Override
+    public Result<Object> updateDirectionalPackage(String accessToken, JSONObject requestJson) {
+        JSONObject returnJson = new JSONObject();
+        String message = "";
+        int flag = -1;
+        try {
+            JSONObject param = new JSONObject();
+            param.put("template_id", requestJson.getLong("templateId"));
+            param.put("advertiser_id", requestJson.getLong("accountId"));
+            if (!Check.isNull(requestJson.getString("templateName"))) {
+                param.put("template_name", requestJson.getString("templateName"));
+            }
+            JSONObject targetJson = new JSONObject();
+            if (!Check.isNull(requestJson.getJSONArray("region"))) {
+                targetJson.put("region", requestJson.getJSONArray("region"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("districtIds"))) {
+                targetJson.put("district_ids", requestJson.getJSONArray("districtIds"));
+            }
+            if (!Check.isNull(requestJson.getInteger("userType"))) {
+                targetJson.put("user_type", requestJson.getInteger("userType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("agesRange"))) {
+                targetJson.put("ages_range", requestJson.getJSONArray("agesRange"));
+            }
+
+            if (!Check.isNull(requestJson.getInteger("min")) && !Check.isNull(requestJson.getInteger("max"))) {
+                JSONObject ageJson = new JSONObject();
+                ageJson.put("min", requestJson.getInteger("min"));
+                ageJson.put("max", requestJson.getInteger("max"));
+                targetJson.put("age", ageJson);
+            }
+
+            if (!Check.isNull(requestJson.getInteger("gender"))) {
+                targetJson.put("gender", requestJson.getInteger("gender"));
+            }
+            if (!Check.isNull(requestJson.getInteger("platformOs"))) {
+                targetJson.put("platform_os", requestJson.getInteger("platformOs"));
+            }
+            if (!Check.isNull(requestJson.getInteger("androidOsv"))) {
+                targetJson.put("android_osv", requestJson.getInteger("androidOsv"));
+            }
+            if (!Check.isNull(requestJson.getInteger("iosOsv"))) {
+                targetJson.put("ios_osv", requestJson.getInteger("iosOsv"));
+            }
+            if (!Check.isNull(requestJson.getInteger("network"))) {
+                targetJson.put("network", requestJson.getInteger("network"));
+            }
+            if (!Check.isNull(requestJson.getInteger("filterConvertedLevel"))) {
+                targetJson.put("filter_converted_level", requestJson.getInteger("filterConvertedLevel"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("deviceBrand"))) {
+                targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
+                targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
+            }
+            if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
+                targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
+                targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
+                targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
+                targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
+                targetJson.put("app_interest", requestJson.getJSONArray("appInterest"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("appIds"))) {
+                targetJson.put("app_ids", requestJson.getJSONArray("appIds"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("population"))) {
+                targetJson.put("population", requestJson.getJSONArray("population"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("paidAudience"))) {
+                targetJson.put("paid_audience", requestJson.getJSONArray("paidAudience"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
+                targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
+            }
+
+
+            if (!Check.isNull(requestJson.getInteger("isOpen"))) {
+                JSONObject intelliExtendJson = new JSONObject();
+                intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
+
+                if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
+                    intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
+                }
+                if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
+                    intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
+                }
+                if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
+                    intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
+                }
+                if (!Check.isNull(intelliExtendJson)) {
+                    targetJson.put("intelli_extend", intelliExtendJson);
+                }
+            }
+            if (!Check.isNull(targetJson)) {
+                param.put("target", targetJson);
+            }
+            JSONObject behaviorInterest = new JSONObject();
+            JSONObject behavior = new JSONObject();
+            JSONObject interest = new JSONObject();
+            if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
+                behavior.put("keyword", requestJson.getJSONArray("keyword"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("label"))) {
+                behavior.put("label", requestJson.getJSONArray("label"));
+            }
+            if (!Check.isNull(requestJson.getInteger("strengthType"))) {
+                behavior.put("strength_type", requestJson.getInteger("strengthType"));
+            }
+            if (!Check.isNull(requestJson.getInteger("timeType"))) {
+                behavior.put("time_type", requestJson.getInteger("timeType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("sceneType"))) {
+                behavior.put("scene_type", requestJson.getJSONArray("sceneType"));
+            }
+            if (!Check.isNull(requestJson.getJSONArray("interestLabel"))) {
+                interest.put("label", requestJson.getJSONArray("interestLabel"));
+            }
+            if (!Check.isNull(behavior)) {
+                behaviorInterest.put("behavior", behavior);
+            }
+            if (!Check.isNull(interest)) {
+                behaviorInterest.put("interest", interest);
+            }
+            if (!Check.isNull(behaviorInterest)) {
+                param.put("behavior_interest", behaviorInterest);
+            }
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Access-Token", accessToken);
+            headers.put("Content-Type", " application/json");
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_UPDATE;
+            log.info("入参:" + param);
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                message = resultJson.getString("message");
+                if (code == 0) {
+                    flag = code;
+                    JSONObject data = resultJson.getJSONObject("data");
+                }
+            }
+            KuaishouDirectionalPackage kuaishouDirectionalPackage = JSONObject.toJavaObject(requestJson, KuaishouDirectionalPackage.class);
+            this.saveOrUpdate(kuaishouDirectionalPackage);
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        if (flag == 0) {
+            return Result.ok(message);
+        } else {
+            return Result.error(message);
+        }
+    }
+
+    @Override
+    public Result<Object> queryList(KuaishouDirectionalPackage directionalPackage, Integer pageNo, Integer pageSize) {
+
+        PageHelper.startPage(pageNo, pageSize, false);
+
+
+        return null;
+    }
+
+    @Override
+    public Result<Object> getRelatedAccountGroup(Long projectId,Long templateId, Integer type, Integer pageNo, Integer pageSize) {
+        return null;
+    }
+
+    @Override
+    public Result<Object> pushDirectionalPackage(Long accountId, Long templateId, JSONArray ids) {
+        return null;
+    }
+
+    @Override
+    public Result<Object> getHistory(Long projectId, Long templateId, Integer pageNo, Integer pageSize) {
+        return null;
+    }
+
+    @Override
+    public Result<Object> getAccountByProjectId(Long projectId, Integer pageNo, Integer pageSize) {
+        return null;
+    }
+}

+ 38 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateController.java

@@ -21,7 +21,15 @@ import org.jeecgframework.poi.excel.entity.ExportParams;
 import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
@@ -67,6 +75,35 @@ public class KuaishouTemplateController {
 
 
     /**
+     * 获取行为与兴趣"类目"
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @GetMapping(value = "/getbehaviorInterest")
+    public Result<Object> getbehaviorInterest(Long accountId) {
+        Result<List<JSONObject>> result = new Result<>();
+        return kuaishouTemplateService.getbehaviorInterest(accountId);
+    }
+
+    /**
+     * 获取行为兴趣"关键词"
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @PostMapping(value = "/getKeywordQuery")
+    public Result<Object> getKeywordQuery(@RequestBody JSONObject data) {
+        Result<List<JSONObject>> result = new Result<>();
+        return kuaishouTemplateService.getKeywordQuery(data);
+    }
+
+
+    /**
      * 分页列表查询
      *
      * @param kuaishouTemplate

+ 6 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouTemplateService.java

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplate;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
 
 import java.util.List;
 
@@ -20,5 +21,9 @@ public interface IKuaishouTemplateService extends IService<KuaishouTemplate> {
 
     JSONObject updateTemplate(Long accountId, String accessToken, JSONObject requestJson);
 
-    List<JSONObject> getJsonArrByAccountId(Long accountId,Integer platformOs);
+    List<JSONObject> getJsonArrByAccountId(Long accountId, Integer platformOs);
+
+    Result<Object> getbehaviorInterest(Long accountId);
+
+    Result<Object> getKeywordQuery(JSONObject data);
 }

+ 89 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouTemplateServiceImpl.java

@@ -1,5 +1,7 @@
 package cn.com.ctop.kuaishou.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.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
@@ -13,6 +15,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -32,13 +35,16 @@ import java.util.Map;
 public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMapper, KuaishouTemplate> implements IKuaishouTemplateService {
     @Autowired
     private IKuaishouTemplateTargetService templateTargetService;
- @Autowired
+    @Autowired
     private KuaishouTemplateMapper templateMapper;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
 
     @Override
-    public List<JSONObject> getJsonArrByAccountId(Long accountId,Integer platformOs) {
-        return templateMapper.getJsonArrByAccountId(accountId,platformOs);
+    public List<JSONObject> getJsonArrByAccountId(Long accountId, Integer platformOs) {
+        return templateMapper.getJsonArrByAccountId(accountId, platformOs);
     }
+
     @Override
     public void getTemplateByAccountId(Long accountId, String accessToken, Integer page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_LIST;
@@ -349,7 +355,6 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
      */
     @Override
     public JSONObject updateTemplate(Long accountId, String accessToken, JSONObject requestJson) {
-        System.err.println(requestJson);
         JSONObject returnJson = new JSONObject();
         try {
             if (Check.isNull(requestJson.getString("templateName"))) {
@@ -466,7 +471,7 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
             headers.put("Access-Token", accessToken);
             headers.put("Content-Type", " application/json");
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_UPDATE;
-            System.err.println("入参:" + param);
+            log.info("入参:" + param);
             String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
             if (!Check.isNull(resultJson)) {
@@ -494,4 +499,83 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
         }
         return returnJson;
     }
+
+    /**
+     * 查询加速探索信息
+     *
+     * @param
+     * @throws
+     * @author ZHAOXA
+     */
+    @Override
+    public Result<Object> getbehaviorInterest(Long accountId) {
+        try {
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.BEHAVIOR_INTEREST;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token.getAccessToken());
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+            params.put("advertiser_id", accountId);
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    return Result.ok(resultJson.getJSONObject("data"));
+                } else {
+                    log.info(" 获取行为与兴趣类目失败,accountId:{},返回信息:{}", accountId, resultJson);
+                    return Result.error("获取行为与兴趣类目失败," + resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            log.error("获取行为与兴趣类目失败", e);
+        }
+        return Result.error("获取行为与兴趣类目失败");
+    }
+
+    @Override
+    public Result<Object> getKeywordQuery(JSONObject data) {
+        try {
+            Long accountId = data.getLong("accountId");
+            String query_str = data.getString("query_str");
+            Integer type = data.getInteger("type");
+            JSONArray ids = data.getJSONArray("ids");
+            if (Check.isNull(accountId) || Check.isNull(type)) {
+                return Result.error("缺失参数");
+            }
+            if (Check.isNull(query_str) && Check.isNull(ids)) {
+                return Result.error("缺失参数");
+            }
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.KEYWORD_QUERY;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token.getAccessToken());
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+            params.put("advertiser_id", accountId);
+            params.put("type", type);
+            if (!Check.isNull(query_str)) {
+                params.put("query_str", query_str);
+            }
+            if (!Check.isNull(ids)) {
+                params.put("ids", ids);
+            }
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    return Result.ok(resultJson.getJSONObject("data"));
+                } else {
+                    log.info("获取行为兴趣关键词失败,accountId:{},返回信息:{}", accountId, resultJson);
+                    return Result.error("获取行为兴趣关键词失败," + resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            log.error("获取行为兴趣关键词失败", e);
+        }
+        return Result.error("获取行为兴趣关键词失败");
+    }
+
 }