Browse Source

批量调整

yumeng 4 years ago
parent
commit
215a1448e5
16 changed files with 1261 additions and 4 deletions
  1. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  2. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java
  3. 2 2
      jeecg-boot-module-system/src/main/resources/application-dev.yml
  4. 8 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  5. 317 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateController.java
  6. 248 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateTargetController.java
  7. 68 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouTemplate.java
  8. 212 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouTemplateTarget.java
  9. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouTemplateMapper.java
  10. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouTemplateTargetMapper.java
  11. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouTemplateMapper.xml
  12. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouTemplateTargetMapper.xml
  13. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouTemplateService.java
  14. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouTemplateTargetService.java
  15. 313 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouTemplateServiceImpl.java
  16. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouTemplateTargetServiceImpl.java

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -666,7 +666,7 @@ public class TestController {
             List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(tokenQueryWrapper);
             if (!Check.isNull(ctopOauthTokens)) {
                 for (CtopOauthToken token : ctopOauthTokens) {
-                    historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
+                    historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), "2020-09-01", "2020-10-01", CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
                 }
 
             }

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java

@@ -122,7 +122,7 @@ public class SysBaseApiImpl implements ISysBaseApi {
 	}
 
 	@Override
-//	@Cacheable(cacheNames=CacheConstant.SYS_USERS_CACHE, key="#username")
+	//@Cacheable(cacheNames=CacheConstant.SYS_USERS_CACHE, key="#username")
 	public LoginUser getUserByName(String username) {
 		if(oConvertUtils.isEmpty(username)) {
 			return null;

+ 2 - 2
jeecg-boot-module-system/src/main/resources/application-dev.yml

@@ -135,9 +135,9 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://139.186.31.213:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true
+          url: jdbc:mysql://139.186.27.96:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true
           username: hcst
-          password: hcst2020
+          password: test@20190531
           driver-class-name: com.mysql.jdbc.Driver
           # 多数据源配置
           #multi-datasource1:

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

@@ -76,6 +76,14 @@ public class KuaishouInterfaceConstant {
      */
     public static final String IMAGE_GET = "/rest/openapi/v1/file/ad/image/get";
     /**
+     * 获取慕模列表
+     */
+    public static final String TEMPLATE_LIST = "/rest/openapi/v1/target/template/list";
+    /**
+     * 创建定向模板
+     */
+    public static final String TEMPLATE_CREATE = "/rest/openapi/v1/target/template/create";
+    /**
      * 获取地域信息
      */
     public static final String REGION_LIST = "/rest/openapi/v1/region/list";

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

@@ -0,0 +1,317 @@
+package cn.com.ctop.kuaishou.modules.batch.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.kuaishou.modules.batch.entity.KuaishouTemplate;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateService;
+import com.alibaba.fastjson.JSON;
+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.system.query.QueryGenerator;
+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.*;
+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 2020-11-09
+ */
+@Slf4j
+@Api(tags = "快手-定向模板")
+@RestController
+@RequestMapping("/batch/kuaishouTemplate")
+public class KuaishouTemplateController {
+    @Autowired
+    private IKuaishouTemplateService kuaishouTemplateService;
+
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouTemplate
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "快手-定向模板-分页列表查询")
+    @ApiOperation(value = "快手-定向模板-分页列表查询", notes = "快手-定向模板-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouTemplate>> queryPageList(KuaishouTemplate kuaishouTemplate,
+                                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                         HttpServletRequest req) {
+        Result<IPage<KuaishouTemplate>> result = new Result<>();
+        QueryWrapper<KuaishouTemplate> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouTemplate, req.getParameterMap());
+        Page<KuaishouTemplate> page = new Page<KuaishouTemplate>(pageNo, pageSize);
+        IPage<KuaishouTemplate> pageList = kuaishouTemplateService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+
+    /**
+     * 根据账户获取定向模板列表
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/getTemplateByAccountId")
+    public Result<Boolean> queryPageList(Long accountId) {
+
+        Result<Boolean> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("请选择账户id");
+            }
+
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+
+            kuaishouTemplateService.getTemplateByAccountId(accountId, oauthToken.getAccessToken(), 1);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
+     * 创建定向模板
+     *
+     * @param
+     * @return
+     */
+    @GetMapping(value = "/createTemplate")
+    public Result<Boolean> createTemplate(@RequestBody JSONObject requestJson) {
+        Result<Boolean> result = new Result<>();
+        try {
+
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("请选择账户id");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            JSONObject returnJson = kuaishouTemplateService.createTemplate(accountId, oauthToken.getAccessToken(), requestJson);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
+     * 添加
+     *
+     * @param kuaishouTemplate
+     * @return
+     */
+    @AutoLog(value = "快手-定向模板-添加")
+    @ApiOperation(value = "快手-定向模板-添加", notes = "快手-定向模板-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouTemplate> add(@RequestBody KuaishouTemplate kuaishouTemplate) {
+        Result<KuaishouTemplate> result = new Result<>();
+        try {
+            kuaishouTemplateService.save(kuaishouTemplate);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouTemplate
+     * @return
+     */
+    @AutoLog(value = "快手-定向模板-编辑")
+    @ApiOperation(value = "快手-定向模板-编辑", notes = "快手-定向模板-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouTemplate> edit(@RequestBody KuaishouTemplate kuaishouTemplate) {
+        Result<KuaishouTemplate> result = new Result<KuaishouTemplate>();
+        KuaishouTemplate kuaishouTemplateEntity = kuaishouTemplateService.getById(kuaishouTemplate.getId());
+        if (kuaishouTemplateEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouTemplateService.updateById(kuaishouTemplate);
+            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 {
+            kuaishouTemplateService.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<KuaishouTemplate> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouTemplate> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouTemplateService.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<KuaishouTemplate> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouTemplate> result = new Result<>();
+        KuaishouTemplate kuaishouTemplate = kuaishouTemplateService.getById(id);
+        if (kuaishouTemplate == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouTemplate);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouTemplate> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouTemplate kuaishouTemplate = JSON.parseObject(deString, KuaishouTemplate.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouTemplate, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouTemplate> pageList = kuaishouTemplateService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "快手-定向模板列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouTemplate.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<KuaishouTemplate> listKuaishouTemplates = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouTemplate.class, params);
+                kuaishouTemplateService.saveBatch(listKuaishouTemplates);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouTemplates.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("文件导入失败!");
+    }
+
+}

+ 248 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateTargetController.java

@@ -0,0 +1,248 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateTargetService;
+import com.alibaba.fastjson.JSON;
+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.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.*;
+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 2020-11-09
+ */
+@Slf4j
+@Api(tags = "快手-定向模板-详情")
+@RestController
+@RequestMapping("/batch/kuaishouTemplateTarget")
+public class KuaishouTemplateTargetController {
+    @Autowired
+    private IKuaishouTemplateTargetService kuaishouTemplateTargetService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouTemplateTarget
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "快手-定向模板-详情-分页列表查询")
+    @ApiOperation(value = "快手-定向模板-详情-分页列表查询", notes = "快手-定向模板-详情-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouTemplateTarget>> queryPageList(KuaishouTemplateTarget kuaishouTemplateTarget,
+                                                               @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                               @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                               HttpServletRequest req) {
+        Result<IPage<KuaishouTemplateTarget>> result = new Result<>();
+        QueryWrapper<KuaishouTemplateTarget> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouTemplateTarget, req.getParameterMap());
+        Page<KuaishouTemplateTarget> page = new Page<KuaishouTemplateTarget>(pageNo, pageSize);
+        IPage<KuaishouTemplateTarget> pageList = kuaishouTemplateTargetService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouTemplateTarget
+     * @return
+     */
+    @AutoLog(value = "快手-定向模板-详情-添加")
+    @ApiOperation(value = "快手-定向模板-详情-添加", notes = "快手-定向模板-详情-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouTemplateTarget> add(@RequestBody KuaishouTemplateTarget kuaishouTemplateTarget) {
+        Result<KuaishouTemplateTarget> result = new Result<>();
+        try {
+            kuaishouTemplateTargetService.save(kuaishouTemplateTarget);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouTemplateTarget
+     * @return
+     */
+    @AutoLog(value = "快手-定向模板-详情-编辑")
+    @ApiOperation(value = "快手-定向模板-详情-编辑", notes = "快手-定向模板-详情-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouTemplateTarget> edit(@RequestBody KuaishouTemplateTarget kuaishouTemplateTarget) {
+        Result<KuaishouTemplateTarget> result = new Result<KuaishouTemplateTarget>();
+        KuaishouTemplateTarget kuaishouTemplateTargetEntity = kuaishouTemplateTargetService.getById(kuaishouTemplateTarget.getId());
+        if (kuaishouTemplateTargetEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouTemplateTargetService.updateById(kuaishouTemplateTarget);
+            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 {
+            kuaishouTemplateTargetService.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<KuaishouTemplateTarget> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouTemplateTarget> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouTemplateTargetService.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<KuaishouTemplateTarget> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouTemplateTarget> result = new Result<>();
+        KuaishouTemplateTarget kuaishouTemplateTarget = kuaishouTemplateTargetService.getById(id);
+        if (kuaishouTemplateTarget == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouTemplateTarget);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouTemplateTarget> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouTemplateTarget kuaishouTemplateTarget = JSON.parseObject(deString, KuaishouTemplateTarget.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouTemplateTarget, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouTemplateTarget> pageList = kuaishouTemplateTargetService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "快手-定向模板-详情列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouTemplateTarget.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<KuaishouTemplateTarget> listKuaishouTemplateTargets = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouTemplateTarget.class, params);
+                kuaishouTemplateTargetService.saveBatch(listKuaishouTemplateTargets);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouTemplateTargets.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("文件导入失败!");
+    }
+
+}

+ 68 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouTemplate.java

@@ -0,0 +1,68 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+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 2020-11-09
+ */
+@Data
+@TableName("ctop_kuaishou_template")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_template对象", description = "快手-定向模板")
+public class KuaishouTemplate {
+
+    /**
+     * id
+     */
+    @ApiModelProperty(value = "id")
+    private String id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 定向模板id
+     */
+    @Excel(name = "定向模板id", width = 15)
+    @ApiModelProperty(value = "定向模板id")
+    private Long templateId;
+    /**
+     * 模板名称
+     */
+    @Excel(name = "模板名称", width = 15)
+    @ApiModelProperty(value = "模板名称")
+    private String templateName;
+    /**
+     * 绑定组个数
+     */
+    @Excel(name = "绑定组个数", width = 15)
+    @ApiModelProperty(value = "绑定组个数")
+    private Integer unitCount;
+    /**
+     * 定向模板创建时间
+     */
+    @Excel(name = "定向模板创建时间", width = 15)
+    @ApiModelProperty(value = "定向模板创建时间")
+    private Date createTime;
+    /**
+     * 定向模板修改时间
+     */
+    @Excel(name = "定向模板修改时间", width = 15)
+    @ApiModelProperty(value = "定向模板修改时间")
+    private Date updateTime;
+}

+ 212 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouTemplateTarget.java

@@ -0,0 +1,212 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+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 2020-11-09
+ */
+@Data
+@TableName("ctop_kuaishou_template_target")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_template_target对象", description = "快手-定向模板-详情")
+public class KuaishouTemplateTarget {
+
+    /**
+     * id
+     */
+    @ApiModelProperty(value = "id")
+    private String id;
+    /**
+     * 定向模板id
+     */
+    @Excel(name = "定向模板id", width = 15)
+    @ApiModelProperty(value = "定向模板id")
+    private Long templateId;
+    /**
+     * 地域
+     */
+    @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 Date createTime;
+    /**
+     * 定向模板修改时间
+     */
+    @Excel(name = "定向模板修改时间", width = 15)
+    @ApiModelProperty(value = "定向模板修改时间")
+    private Date updateTime;
+}

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplate;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手-定向模板
+ *
+ * @author: jeecg-boot
+ * @date: 2020-11-09
+ * @cersion: V1.0
+ */
+public interface KuaishouTemplateMapper extends BaseMapper<KuaishouTemplate> {
+
+}

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手-定向模板-详情
+ *
+ * @author: jeecg-boot
+ * @date: 2020-11-09
+ * @cersion: V1.0
+ */
+public interface KuaishouTemplateTargetMapper extends BaseMapper<KuaishouTemplateTarget> {
+
+}

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

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

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

@@ -0,0 +1,18 @@
+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;
+
+/**
+ * @Description: 快手-定向模板
+ * @Author: jeecg-boot
+ * @Date: 2020-11-09
+ * @Version: V1.0
+ */
+public interface IKuaishouTemplateService extends IService<KuaishouTemplate> {
+
+    void getTemplateByAccountId(Long accountId, String accessToken, Integer page);
+
+    JSONObject createTemplate(Long accountId, String accessToken, JSONObject requestJson);
+}

+ 14 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouTemplateTargetService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 快手-定向模板-详情
+ * @Author: jeecg-boot
+ * @Date: 2020-11-09
+ * @Version: V1.0
+ */
+public interface IKuaishouTemplateTargetService extends IService<KuaishouTemplateTarget> {
+
+}

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

@@ -0,0 +1,313 @@
+package cn.com.ctop.kuaishou.modules.batch.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.batch.entity.KuaishouTemplate;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouTemplateMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateTargetService;
+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.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 快手-定向模板
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-11-09
+ */
+@Slf4j
+@Service
+public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMapper, KuaishouTemplate> implements IKuaishouTemplateService {
+    @Autowired
+    private IKuaishouTemplateTargetService templateTargetService;
+
+    @Override
+    public void getTemplateByAccountId(Long accountId, String accessToken, Integer page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_LIST;
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", accountId);
+        param.put("page", page);
+        param.put("page_size", 500);
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Access-Token", accessToken);
+        headers.put("Content-Type", " application/json");
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (!Check.isNull(resultJson)) {
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                JSONObject dataJson = resultJson.getJSONObject("data");
+                if (!Check.isNull(dataJson)) {
+                    return;
+                }
+                JSONArray details = dataJson.getJSONArray("details");
+                if (!Check.isNull(details)) {
+                    return;
+                }
+                for (int i = 0; i < details.size(); i++) {
+                    JSONObject jsonObject = details.getJSONObject(i);
+                    Long templateId = jsonObject.getLong("template_id");
+                    KuaishouTemplate template = new KuaishouTemplate();
+                    template.setId(accountId + "_" + templateId);
+                    template.setAccountId(accountId);
+                    template.setTemplateId(templateId);
+                    template.setTemplateName(jsonObject.getString("template_name"));
+                    template.setUnitCount(jsonObject.getInteger("unit_count"));
+                    template.setCreateTime(jsonObject.getDate("create_time"));
+                    template.setUpdateTime(jsonObject.getDate("updateTime"));
+                    this.saveOrUpdate(template);
+                    JSONObject targetJson = jsonObject.getJSONObject("target");
+                    if (!Check.isNull(targetJson)) {
+                        KuaishouTemplateTarget templateTarget = new KuaishouTemplateTarget();
+                        templateTarget.setId(accountId + "_" + templateId);
+                        templateTarget.setTemplateId(templateId);
+                        if (!Check.isNull(targetJson.getJSONArray("region"))) {
+                            templateTarget.setRegion(targetJson.getJSONArray("region").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("district_ids"))) {
+                            templateTarget.setDistrictIds(targetJson.getJSONArray("district_ids").toString());
+                        }
+                        if (!Check.isNull(targetJson.getInteger("user_type"))) {
+                            templateTarget.setUserType(targetJson.getInteger("user_type"));
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("ages_range"))) {
+                            templateTarget.setAgesRange(targetJson.getJSONArray("ages_range").toJSONString());
+                        }
+                        JSONObject ageJson = targetJson.getJSONObject("age");
+                        if (!Check.isNull(ageJson)) {
+                            templateTarget.setMin(ageJson.getInteger("min"));
+                            templateTarget.setMax(ageJson.getInteger("max"));
+                        }
+                        if (!Check.isNull(targetJson.getInteger("gender"))) {
+                            templateTarget.setGender(targetJson.getInteger("gender"));
+                        }
+                        if (!Check.isNull(targetJson.getInteger("platform_os"))) {
+                            templateTarget.setPlatformOs(targetJson.getInteger("platform_os"));
+                        }
+                        if (!Check.isNull(targetJson.getInteger("android_osv"))) {
+                            templateTarget.setAndroidOsv(targetJson.getInteger("android_osv"));
+                        }
+                        if (!Check.isNull(targetJson.getInteger("ios_osv"))) {
+                            templateTarget.setIosOsv(targetJson.getInteger("ios_osv"));
+                        }
+                        if (!Check.isNull(targetJson.getInteger("network"))) {
+                            templateTarget.setNetwork(targetJson.getInteger("network"));
+                        }
+                        if (!Check.isNull(targetJson.getInteger("filter_converted_level"))) {
+                            templateTarget.setFilterConvertedLevel(targetJson.getInteger("filter_converted_level"));
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("device_brand"))) {
+                            templateTarget.setDeviceBrand(targetJson.getJSONArray("device_brand").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("device_price"))) {
+                            templateTarget.setDevicePrice(targetJson.getJSONArray("device_price").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getInteger("business_interest_type"))) {
+                            templateTarget.setBusinessInterestType(targetJson.getInteger("business_interest_type"));
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("business_interest"))) {
+                            templateTarget.setBusinessInterest(targetJson.getJSONArray("business_interest").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("fans_star"))) {
+                            templateTarget.setFansStar(targetJson.getJSONArray("fans_star").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("interest_video"))) {
+                            templateTarget.setInterestVideo(targetJson.getJSONArray("interest_video").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("app_interest"))) {
+                            templateTarget.setAppInterest(targetJson.getJSONArray("app_interest").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("app_ids"))) {
+                            templateTarget.setAppIds(targetJson.getJSONArray("app_ids").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("population"))) {
+                            templateTarget.setPopulation(targetJson.getJSONArray("population").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("paid_audience"))) {
+                            templateTarget.setPaidAudience(targetJson.getJSONArray("paid_audience").toJSONString());
+                        }
+                        if (!Check.isNull(targetJson.getJSONArray("exclude_population"))) {
+                            templateTarget.setExcludePopulation(targetJson.getJSONArray("exclude_population").toJSONString());
+                        }
+                        JSONObject intelliExtendJson = targetJson.getJSONObject("intelli_extend");
+                        if (!Check.isNull(intelliExtendJson)) {
+                            if (!Check.isNull(intelliExtendJson.getInteger("is_open"))) {
+                                templateTarget.setIsOpen(intelliExtendJson.getInteger("is_open"));
+                            }
+                            if (!Check.isNull(intelliExtendJson.getInteger("no_age_break"))) {
+                                templateTarget.setNoAgeBreak(intelliExtendJson.getInteger("no_age_break"));
+                            }
+                            if (!Check.isNull(intelliExtendJson.getInteger("no_gender_break"))) {
+                                templateTarget.setNoGenderBreak(intelliExtendJson.getInteger("no_gender_break"));
+                            }
+                            if (!Check.isNull(intelliExtendJson.getInteger("no_area_break"))) {
+                                templateTarget.setNoAreaBreak(intelliExtendJson.getInteger("no_area_break"));
+                            }
+                        }
+                        templateTargetService.saveOrUpdate(templateTarget);
+                    }
+
+                }
+
+                getTemplateByAccountId(accountId, accessToken, page + 1);
+            } else {
+                log.error("获取模板信息返回信息错误:accountId:{},返回信息:{}", accountId, resultJson);
+
+
+            }
+
+
+        } else {
+            log.error("获取模板信息返回信息为空:accountId:{}", accountId);
+        }
+
+
+    }
+
+
+    /**
+     * 创建定向模板
+     *
+     * @param accountId
+     * @param accessToken
+     * @param requestJson
+     * @return
+     */
+    @Override
+    public JSONObject createTemplate(Long accountId, String accessToken, JSONObject requestJson) {
+
+
+        try {
+            if (Check.isNull(requestJson.getString("templateName"))) {
+                throw new Exception("定向模板名称为必传项");
+            }
+
+            JSONObject param = new JSONObject();
+            param.put("advertiser_id", 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);
+            }
+
+            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;
+            System.err.println(param);
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+
+            JSONObject resultJson = JSONObject.parseObject(result);
+            System.err.println(resultJson);
+
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+}

+ 19 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouTemplateTargetServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouTemplateTargetMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateTargetService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 快手-定向模板-详情
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-11-09
+ */
+@Service
+public class KuaishouTemplateTargetServiceImpl extends ServiceImpl<KuaishouTemplateTargetMapper, KuaishouTemplateTarget> implements IKuaishouTemplateTargetService {
+
+}