Explorar el Código

修改创意批量代码接口

syh hace 4 años
padre
commit
ae1513b094

+ 12 - 10
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceCampaignController.java

@@ -14,7 +14,6 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.system.query.QueryGenerator;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -51,19 +50,22 @@ public class ByteDanceCampaignController {
     @AutoLog(value = "今日头条广告组信息-分页列表查询")
     @ApiOperation(value = "今日头条广告组信息-分页列表查询", notes = "今日头条广告组信息-分页列表查询")
     @GetMapping(value = "/list")
-    public Result<IPage<ByteDanceCampaign>> queryPageList(ByteDanceCampaign byteDanceCampaign,
-                                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                                          @RequestParam(name="startDate",defaultValue = "")String startDate,
-                                                          @RequestParam(name="endDate",defaultValue = "")String endDate,
-                                                          HttpServletRequest req) {
+    public Result<IPage<ByteDanceCampaign>> queryPageList(
+            @RequestParam(name = "name",defaultValue = "")String name,
+            @RequestParam(name = "status",defaultValue = "")String status,
+            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+            @RequestParam(name="startDate",defaultValue = "")String startDate,
+            @RequestParam(name="endDate",defaultValue = "")String endDate,
+            HttpServletRequest req) {
         Result<IPage<ByteDanceCampaign>> result = new Result<>();
-        String name = byteDanceCampaign.getName();
-        byteDanceCampaign.setName(null);
-        QueryWrapper<ByteDanceCampaign> queryWrapper = QueryGenerator.initQueryWrapper(byteDanceCampaign, req.getParameterMap());
+        QueryWrapper<ByteDanceCampaign> queryWrapper = new QueryWrapper<>();
         if(null!=name&&!"".equalsIgnoreCase(name)){
             queryWrapper.like("name",name);
         }
+        if(null!=status&&!"".equals(status.trim())){
+            queryWrapper.eq("status","CAMPAIGN_STATUS_"+status);
+        }
         if(null!=startDate&&!"".equals(startDate)){
             queryWrapper.ge("campaign_create_time",startDate+" 00:00:00");
         }

+ 37 - 15
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceCreativeController.java

@@ -1,6 +1,8 @@
 package cn.com.ctop.toutiao.modules.material.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.common.module.utils.StringUtils;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceCreative;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
@@ -11,13 +13,13 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.system.query.QueryGenerator;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -37,33 +39,37 @@ public class ByteDanceCreativeController {
     /**
      * 分页列表查询
      *
-     * @param byteDanceCreative
      * @param pageNo
      * @param pageSize
-     * @param req
      * @return
      */
     @AutoLog(value = "今日头条创意信息-分页列表查询")
     @ApiOperation(value = "今日头条创意信息-分页列表查询", notes = "今日头条创意信息-分页列表查询")
     @GetMapping(value = "/list")
-    public Result<IPage<ByteDanceCreative>> queryPageList(ByteDanceCreative byteDanceCreative,
-                                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                                          @RequestParam(name="startDate",defaultValue = "")String startDate,
-                                                          @RequestParam(name="endDate",defaultValue = "")String endDate,
-                                                          HttpServletRequest req) {
+    public Result<IPage<ByteDanceCreative>> queryPageList(
+            @RequestParam(name = "accountId", defaultValue = "0") Long accountId,
+            @RequestParam(name = "status",required = false) String status,
+            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+            @RequestParam(name="startDate",defaultValue = "",required = false)String startDate,
+            @RequestParam(name="endDate",defaultValue = "",required = false)String endDate,
+            @RequestParam(name = "name",defaultValue = "",required = false)String name) {
         Result<IPage<ByteDanceCreative>> result = new Result<>();
-        String title = byteDanceCreative.getTitle();
-        byteDanceCreative.setTitle(null);
-        QueryWrapper<ByteDanceCreative> queryWrapper = QueryGenerator.initQueryWrapper(byteDanceCreative, req.getParameterMap());
+        QueryWrapper<ByteDanceCreative> queryWrapper = new QueryWrapper<>();
         if(null!=startDate&&!startDate.trim().equals("")){
             queryWrapper.ge("",startDate+" 00:00:00");
         }
+        if(null!=accountId){
+            queryWrapper.eq("account_id",accountId);
+        }
         if(null!=endDate&&!endDate.trim().equals("")){
             queryWrapper.le("",startDate+" 23:59:59");
         }
-        if(null!=title&&!"".equals(title.trim())){
-            queryWrapper.like("title",title);
+        if(null!=name&&!"".equals(name.trim())){
+            queryWrapper.like("title",name);
+        }
+        if(null!=status&&!status.trim().equals("")){
+            queryWrapper.eq("status","CREATIVE_STATUS_AD_"+status);
         }
         Page<ByteDanceCreative> page = new Page<>(pageNo, pageSize);
         IPage<ByteDanceCreative> pageList = byteDanceCreativeService.page(page, queryWrapper);
@@ -99,6 +105,22 @@ public class ByteDanceCreativeController {
     }
 
     /**
+     * 修改广告组状态
+     * @return
+     */
+    @PostMapping("/editStatus")
+    public Map<String,Object> editStatus(@RequestParam(name = "accountId",defaultValue = "0")Long accountId,
+                                         @RequestParam(name = "ids") String ids,
+                                         @RequestParam(name = "status")String status){
+        Map<String,Object>result = new HashMap();
+        if(null == accountId||accountId==0||null == ids||ids.trim().equals("")||null==status||status.trim().equals("")){
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
+            return result;
+        }
+        return byteDanceCreativeService.advertiserCreativeUpdateStatus(accountId,ids,status);
+    }
+
+    /**
      * 编辑
      *
      * @param byteDanceCreative

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceCreativeService.java

@@ -20,7 +20,7 @@ public interface IByteDanceCreativeService extends IService<ByteDanceCreative> {
 
     Map<String, Object> getAdvertiserCreative(CtopOauthToken token, String ids, String date);
 
-    Map<String, Object> advertiserCreativeUpdateStatus(String accountId, String creativeIds, String optStatus);
+    Map<String, Object> advertiserCreativeUpdateStatus(Long accountId, String creativeIds, String optStatus);
 
     void replaceBatch(List<ByteDanceCreative> creatives);
 

+ 10 - 7
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceCreativeServiceImpl.java

@@ -42,7 +42,7 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
      * @return
      */
     @Override
-    public Map<String, Object> advertiserCreativeUpdateStatus(String accountId, String creativeIds, String optStatus) {
+    public Map<String, Object> advertiserCreativeUpdateStatus(Long accountId, String creativeIds, String optStatus) {
         Map<String, Object> resultMap = new HashMap<>();
         JSONArray ids = new JSONArray();
         String[] getCreativeIds = creativeIds.split(StringUtils.COMMA);
@@ -51,7 +51,7 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
                 ids.add(Long.parseLong(getCreativeIds[i]));
             }
         }
-        CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
+        CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId+"");
         //2: 根据token以及用户id获取用户信息数据
         String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_creative_update_status");
         Map<String, String> headers = new HashMap<>();
@@ -65,24 +65,27 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
         String result = HttpUtils.httpPostRequest(url, params, headers);
         JSONObject jsonObject = JSONObject.parseObject(result);
         Integer code = jsonObject.getInteger("code");
-
+        String message = jsonObject.getString("message");
         if (null == code || !code.equals(0)) {
-            log.info("修改创意状态接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
+            log.info("修改创意状态接口异常==》accountId:{},message:{}", accountId, message);
+            resultMap.put("success", false);
             resultMap.put("code", -1);
-            resultMap.put("message", "修改创意状态接口异常");
+            resultMap.put("message", message);
             return resultMap;
         }
         JSONObject data = jsonObject.getJSONObject("data");
         if (null == data) {
-            log.info("修改创意状态异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
+            log.info("修改创意状态异常==》accountId:{},message:{}", accountId, message);
+            resultMap.put("success", false);
             resultMap.put("code", -1);
-            resultMap.put("message", "修改创意状态异常");
+            resultMap.put("message", message);
             return resultMap;
         }
         JSONArray returnCreativeIds = data.getJSONArray("creative_ids");
         if (null != returnCreativeIds && !returnCreativeIds.isEmpty()) {
             getAdvertiserCreative(cTopOauthToken, creativeIds, null);
         }
+        resultMap.put("success", true);
         resultMap.put("code", 0);
         resultMap.put("message", "广告创意状态修改成功");
         return resultMap;