|
@@ -4,19 +4,21 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
|
|
import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
|
|
-import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
|
|
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IMaterialRefuseService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IMaterialRefuseService;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
-import java.util.List;
|
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@@ -29,21 +31,27 @@ public class MaterialRefuseController {
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaiShouUpdateService updateService;
|
|
private IKuaiShouUpdateService updateService;
|
|
@Autowired
|
|
@Autowired
|
|
- private KuaiShouCreativeMapper creativeMapper;
|
|
|
|
|
|
+ private IKuaiShouCreativeService creativeService;
|
|
|
|
|
|
|
|
|
|
- @PostMapping(value = "/getRefuseCreative")
|
|
|
|
- public Map<String, Object> getRefuseCreative(@RequestBody JSONObject jsonObject) {
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
|
|
+ @GetMapping(value = "/getRefuseCreative")
|
|
|
|
+ public Result<IPage<KuaiShouCreative>> getRefuseCreative(KuaiShouCreative creative,
|
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
|
+ HttpServletRequest req) {
|
|
|
|
+ Result<IPage<KuaiShouCreative>> result = new Result<>();
|
|
try {
|
|
try {
|
|
- List<JSONObject> list = materialRefuseService.getRefuseCreative(jsonObject.getLong("accountId"));
|
|
|
|
- map.put("code", 0);
|
|
|
|
- map.put("data", list);
|
|
|
|
|
|
+
|
|
|
|
+ QueryWrapper<KuaiShouCreative> queryWrapper = QueryGenerator.initQueryWrapper(creative, req.getParameterMap());
|
|
|
|
+ Page<KuaiShouCreative> page = new Page<KuaiShouCreative>(pageNo, pageSize);
|
|
|
|
+ IPage<KuaiShouCreative> pageList = creativeService.page(page, queryWrapper);
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(pageList);
|
|
|
|
+
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- map.put("code", -1);
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ result.setSuccess(false);
|
|
}
|
|
}
|
|
- return map;
|
|
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
@PostMapping(value = "/updateCreative")
|
|
@PostMapping(value = "/updateCreative")
|
|
@@ -82,19 +90,137 @@ public class MaterialRefuseController {
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
- QueryWrapper<KuaiShouCreative> creativeQueryWrapper = new QueryWrapper<>();
|
|
|
|
- creativeQueryWrapper.eq("account_id", accountId);
|
|
|
|
- creativeQueryWrapper.eq("creative_id", jsonObject.getString("creativeId"));
|
|
|
|
- creativeQueryWrapper.eq("unit_id", jsonObject.getString("unitId"));
|
|
|
|
- creativeQueryWrapper.eq("campaign_id", jsonObject.getString("campaignId"));
|
|
|
|
- int i = creativeMapper.delete(creativeQueryWrapper);
|
|
|
|
- if (i > 0) {
|
|
|
|
- map.put("code", 0);
|
|
|
|
- map.put("message", "重审成功");
|
|
|
|
- return map;
|
|
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @PostMapping(value = "/batchUpdateCreative")
|
|
|
|
+ public Result<JSONObject> batchUpdateCreative(@RequestBody JSONObject jsonObject) {
|
|
|
|
+
|
|
|
|
+ Result<JSONObject> result = new Result<>();
|
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
|
+ if (Check.isNull(jsonObject)) {
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage("入参为空");
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
- return null;
|
|
|
|
|
|
+ Long accountId = jsonObject.getLong("accountId");
|
|
|
|
+ QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("account_id", accountId);
|
|
|
|
+ queryWrapper.eq("media_id", 2);
|
|
|
|
+ queryWrapper.orderByDesc("create_time");
|
|
|
|
+ queryWrapper.last("limit 1");
|
|
|
|
+ CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(queryWrapper);
|
|
|
|
+ if (Check.isNull(ctopOauthToken)) {
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage("未获取到授权信息");
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONArray creativeArr = jsonObject.getJSONArray("creativeArr");
|
|
|
|
+ Integer successCount = 0;
|
|
|
|
+ Integer failCount = 0;
|
|
|
|
+ if (!Check.isNull(creativeArr)) {
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < creativeArr.size(); i++) {
|
|
|
|
+ JSONObject creativeJson = creativeArr.getJSONObject(i);
|
|
|
|
+ if (!Check.isNull(creativeJson)) {
|
|
|
|
+ Long creativeId = creativeJson.getLong("creativeId");
|
|
|
|
+ JSONObject requestJson = new JSONObject();
|
|
|
|
+ requestJson.put("creativeId", creativeId);
|
|
|
|
+ System.err.println(creativeId);
|
|
|
|
+ String description = creativeJson.getString("description");
|
|
|
|
+ if (!Check.isNull(description)) {
|
|
|
|
+ requestJson.put("description", convertMoString(description));
|
|
|
|
+ Map<String, Object> creativeMap = updateService.updateCreative(ctopOauthToken.getAccessToken(), accountId, requestJson);
|
|
|
|
+ Integer code = (Integer) creativeMap.get("code");
|
|
|
|
+ if (code == 0) {
|
|
|
|
+ successCount += 1;
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ failCount += 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ returnJson.put("successCount", successCount);
|
|
|
|
+ returnJson.put("failCount", failCount);
|
|
|
|
+
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+ result.setResult(returnJson);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static synchronized String convertMoString(String sMo) {
|
|
|
|
+
|
|
|
|
+ if (Check.isNull(sMo)) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ String newString = null;
|
|
|
|
+ try {
|
|
|
|
+ if (sMo.contains(",")) {
|
|
|
|
+ return sMo.replace(',', ',');
|
|
|
|
+ } else if (sMo.contains("~")) {
|
|
|
|
+ newString = sMo.replace('~', '~');
|
|
|
|
+ } else if (sMo.contains("。")) {
|
|
|
|
+ newString = sMo.replace('。', '.');
|
|
|
|
+ } else if (sMo.contains(";")) {
|
|
|
|
+ newString = sMo.replace(';', ';');
|
|
|
|
+ } else if (sMo.contains("!")) {
|
|
|
|
+ newString = sMo.replace("!", "!");
|
|
|
|
+
|
|
|
|
+ } else if (sMo.contains("?")) {
|
|
|
|
+ newString = sMo.replace('?', '?');
|
|
|
|
+
|
|
|
|
+ } else if (sMo.contains(":")) {
|
|
|
|
+ newString = sMo.replace(':', ':');
|
|
|
|
+
|
|
|
|
+ } else if (sMo.contains("“")) {
|
|
|
|
+ newString = sMo.replace('“', '"');
|
|
|
|
+
|
|
|
|
+ } else if (sMo.contains("”")) {
|
|
|
|
+ newString = sMo.replace('”', '"');
|
|
|
|
+
|
|
|
|
+ } else if (sMo.contains("<")) {
|
|
|
|
+ newString = sMo.replace('>', '》').replace('<', '《');
|
|
|
|
+ } else if (sMo.contains(",")) {
|
|
|
|
+ newString = sMo.replace(',', ',');
|
|
|
|
+ } else if (sMo.contains(".")) {
|
|
|
|
+ newString = sMo.replace('.', '。');
|
|
|
|
+ } else if (sMo.contains(";")) {
|
|
|
|
+ newString = sMo.replace(';', ';');
|
|
|
|
+ } else if (sMo.contains("!")) {
|
|
|
|
+ newString = sMo.replace("!", "!");
|
|
|
|
+
|
|
|
|
+ } else if (sMo.contains("?")) {
|
|
|
|
+ newString = sMo.replace('?', '?');
|
|
|
|
+
|
|
|
|
+ } else if (sMo.contains(":")) {
|
|
|
|
+ newString = sMo.replace(':', ':');
|
|
|
|
+
|
|
|
|
+ } else if (sMo.contains(""")) {
|
|
|
|
+ newString = sMo.replace('"', '“');
|
|
|
|
+
|
|
|
|
+ } else if (sMo.contains(""")) {
|
|
|
|
+ newString = sMo.replace('"', '”');
|
|
|
|
+ } else if (sMo.contains("《")) {
|
|
|
|
+ newString = sMo.replace('》', '>').replace('《', '<');
|
|
|
|
+ } else if (sMo.contains("~")) {
|
|
|
|
+ newString = sMo.replace('~', '~');
|
|
|
|
+ } else {
|
|
|
|
+ newString = sMo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ return sMo;
|
|
|
|
+ }
|
|
|
|
+ return newString;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|