提交 5d3b35dc 作者: 沈振路

关键词复用指定关键词

上级 320e65ac
...@@ -17,4 +17,6 @@ public class CustomerKeywordCopyDTO implements Serializable { ...@@ -17,4 +17,6 @@ public class CustomerKeywordCopyDTO implements Serializable {
private List<AuthInfoVO> targetAuthList; private List<AuthInfoVO> targetAuthList;
private List<String> targetKeywordList;
} }
...@@ -228,15 +228,16 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe ...@@ -228,15 +228,16 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe
public BaseResult copy(CustomerKeywordCopyDTO copyDto) { public BaseResult copy(CustomerKeywordCopyDTO copyDto) {
AuthInfoVO sourceAuth = copyDto.getSourceAuth(); AuthInfoVO sourceAuth = copyDto.getSourceAuth();
List<AuthInfoVO> targetAuthList = copyDto.getTargetAuthList(); List<AuthInfoVO> targetAuthList = copyDto.getTargetAuthList();
List<String> targetKeywordList = copyDto.getTargetKeywordList();
long copyFlag = System.currentTimeMillis(); long copyFlag = System.currentTimeMillis();
localLog.info("关键词复用, 复用批次号: {}, 源公众号: {}, 目标公众号: {}条", copyFlag, sourceAuth.getAccountName(), targetAuthList.size()); localLog.info("关键词复用, 复用批次号: {}, 源公众号: {}, 目标公众号: {}条, 目标关键词列表 {}", copyFlag, sourceAuth.getAccountName(), targetAuthList.size(), targetKeywordList);
List<CustomerKeyword> sourceMaterialList = getSourceMaterialList(sourceAuth.getAppId()); List<CustomerKeyword> sourceMaterialList = getSourceMaterialList(sourceAuth.getAppId(), targetKeywordList);
if (CollectionUtil.isEmpty(sourceMaterialList)) { if (CollectionUtil.isEmpty(sourceMaterialList)) {
return new BaseResult().error("源公众号找不到素材"); return new BaseResult().error("源公众号找不到素材");
} }
// 删除目标公众号现有的素材和链接 // 删除目标公众号现有的素材和链接
removeOriginMaterialList(targetAuthList); removeOriginMaterialList(targetAuthList, targetKeywordList);
List<String> errorAuthList = null; List<String> errorAuthList = null;
int idx = 1; int idx = 1;
...@@ -311,8 +312,12 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe ...@@ -311,8 +312,12 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe
return JSONUtil.toList(referralJsonArray, CommonReferralBody.class); return JSONUtil.toList(referralJsonArray, CommonReferralBody.class);
} }
private List<CustomerKeyword> getSourceMaterialList(String appid) { private List<CustomerKeyword> getSourceMaterialList(String appid, List<String> targetKeywordList) {
List<CustomerKeyword> sourceMaterialList = this.list(new QueryWrapper<CustomerKeyword>().eq("appid", appid)); QueryWrapper<CustomerKeyword> queryWrapper = new QueryWrapper<CustomerKeyword>().eq("appid", appid);
if (CollectionUtil.isNotEmpty(targetKeywordList)) {
queryWrapper = queryWrapper.in("keyword", targetKeywordList);
}
List<CustomerKeyword> sourceMaterialList = this.list(queryWrapper);
if (CollectionUtil.isEmpty(sourceMaterialList)) { if (CollectionUtil.isEmpty(sourceMaterialList)) {
return null; return null;
...@@ -337,10 +342,13 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe ...@@ -337,10 +342,13 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe
return sourceMaterialList; return sourceMaterialList;
} }
private void removeOriginMaterialList(List<AuthInfoVO> targetList) { private void removeOriginMaterialList(List<AuthInfoVO> targetList, List<String> targetKeywordList) {
List<String> targetAppidList = targetList.stream().map(AuthInfoVO::getAppId).collect(Collectors.toList()); List<String> targetAppidList = targetList.stream().map(AuthInfoVO::getAppId).collect(Collectors.toList());
QueryWrapper<CustomerKeyword> queryWrapper = new QueryWrapper<CustomerKeyword>().in("appid", targetAppidList);
List<CustomerKeyword> sourceMaterialList = this.list(new QueryWrapper<CustomerKeyword>().in("appid", targetAppidList)); if (CollectionUtil.isNotEmpty(targetKeywordList)) {
queryWrapper = queryWrapper.in("keyword", targetKeywordList);
}
List<CustomerKeyword> sourceMaterialList = this.list(queryWrapper);
// 原来没有 // 原来没有
if (CollectionUtil.isEmpty(sourceMaterialList)) { if (CollectionUtil.isEmpty(sourceMaterialList)) {
return; return;
...@@ -386,6 +394,6 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe ...@@ -386,6 +394,6 @@ public class CustomerKeywordServiceImpl extends ServiceImpl<CustomerKeywordMappe
redisTemplate.opsForHash().delete(CustomerMaterialConstant.CUSTOMER_KEYWORD_REDIS_KEY, appid); redisTemplate.opsForHash().delete(CustomerMaterialConstant.CUSTOMER_KEYWORD_REDIS_KEY, appid);
} }
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论