提交 f3a57d41 作者: 沈振路

关回多图文配置(不入库,进缓存)

上级 b9723371
...@@ -39,6 +39,8 @@ public class FollowReplySaveDTO implements Serializable { ...@@ -39,6 +39,8 @@ public class FollowReplySaveDTO implements Serializable {
private CommonReferralBody referralBody; private CommonReferralBody referralBody;
private AuthInfoVO accountEntity;
/** /**
* 多图文的图文列表 * 多图文的图文列表
*/ */
......
...@@ -3,6 +3,7 @@ package com.yaoyaozw.customer.service; ...@@ -3,6 +3,7 @@ package com.yaoyaozw.customer.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yaoyaozw.customer.dto.follow.FollowReplyMultiNewsCreateDTO; import com.yaoyaozw.customer.dto.follow.FollowReplyMultiNewsCreateDTO;
import com.yaoyaozw.customer.entity.CustomerFollowReplyMultiNews; import com.yaoyaozw.customer.entity.CustomerFollowReplyMultiNews;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import java.util.List; import java.util.List;
...@@ -15,9 +16,9 @@ public interface CustomerFollowReplyMultiNewsService extends IService<CustomerFo ...@@ -15,9 +16,9 @@ public interface CustomerFollowReplyMultiNewsService extends IService<CustomerFo
/** /**
* 保存关回多图文的图文列表 * 保存关回多图文的图文列表
* @param replyId 关回配置的主键Id * @param replyId 关回配置的主键Id
* @param appId 公众号 appId * @param accountEntity 公众号
* @param multiNewsList 图文列表 * @param multiNewsList 图文列表
*/ */
void saveFollowReplyMultiNews(Long replyId, String appId, List<FollowReplyMultiNewsCreateDTO> multiNewsList); void saveFollowReplyMultiNews(Long replyId, AuthInfoVO accountEntity, List<FollowReplyMultiNewsCreateDTO> multiNewsList);
} }
...@@ -16,6 +16,7 @@ import com.yaoyaozw.customer.entity.ReferralEntity; ...@@ -16,6 +16,7 @@ import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.mapper.CustomerFollowReplyMultiNewsMapper; import com.yaoyaozw.customer.mapper.CustomerFollowReplyMultiNewsMapper;
import com.yaoyaozw.customer.service.CustomerFollowReplyMultiNewsService; import com.yaoyaozw.customer.service.CustomerFollowReplyMultiNewsService;
import com.yaoyaozw.customer.service.ReferralEntityService; import com.yaoyaozw.customer.service.ReferralEntityService;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -46,7 +47,7 @@ public class CustomerFollowReplyMultiNewsServiceImpl extends ServiceImpl<Custome ...@@ -46,7 +47,7 @@ public class CustomerFollowReplyMultiNewsServiceImpl extends ServiceImpl<Custome
private SnowflakeComponent snowflakeComponent; private SnowflakeComponent snowflakeComponent;
@Override @Override
public void saveFollowReplyMultiNews(Long replyId, String appId, List<FollowReplyMultiNewsCreateDTO> multiNewsList) { public void saveFollowReplyMultiNews(Long replyId, AuthInfoVO accountEntity, List<FollowReplyMultiNewsCreateDTO> multiNewsList) {
if (CollectionUtil.isEmpty(multiNewsList)) { if (CollectionUtil.isEmpty(multiNewsList)) {
return; return;
} }
...@@ -58,27 +59,36 @@ public class CustomerFollowReplyMultiNewsServiceImpl extends ServiceImpl<Custome ...@@ -58,27 +59,36 @@ public class CustomerFollowReplyMultiNewsServiceImpl extends ServiceImpl<Custome
List<Long> multiNewsIdList = currentMultiNewsList.stream().map(CustomerFollowReplyMultiNews::getId).collect(Collectors.toList()); List<Long> multiNewsIdList = currentMultiNewsList.stream().map(CustomerFollowReplyMultiNews::getId).collect(Collectors.toList());
referralEntityService.remove(new QueryWrapper<ReferralEntity>().in(ReferralEntity.COL_MATERIAL_GRAPHICS_ID, multiNewsIdList)); referralEntityService.remove(new QueryWrapper<ReferralEntity>().in(ReferralEntity.COL_MATERIAL_GRAPHICS_ID, multiNewsIdList));
this.removeByIds(multiNewsIdList); this.removeByIds(multiNewsIdList);
redisTemplate.opsForHash().delete(FOLLOW_REPLY_MULTI_NEWS_CACHE_KEY, appId); redisTemplate.opsForHash().delete(FOLLOW_REPLY_MULTI_NEWS_CACHE_KEY, accountEntity.getAppId());
} }
List<ReferralEntity> referralEntityList = new ArrayList<>(multiNewsList.size()); List<ReferralEntity> referralEntityList = new ArrayList<>(multiNewsList.size());
List<CustomerFollowReplyMultiNews> entityList = new ArrayList<>(multiNewsList.size()); List<CustomerFollowReplyMultiNews> entityList = new ArrayList<>(multiNewsList.size());
// 处理链接 // 处理链接
for (FollowReplyMultiNewsCreateDTO multiNewsEntity : multiNewsList) { for (FollowReplyMultiNewsCreateDTO multiNewsEntity : multiNewsList) {
CommonReferralBody referralBody = multiNewsEntity.getReferralBody(); CommonReferralBody referralBody = multiNewsEntity.getReferralBody();
referralBody.setAccountName(accountEntity.getAccountName());
referralBody.setStoreTypeName(accountEntity.getStoreTypeName());
referralBody.setStoreType(accountEntity.getStoreType());
referralBody.setInfoId(accountEntity.getId());
referralBody.setAccountId(accountEntity.getAccountId());
referralBody.setAppId(accountEntity.getAppId());
// 调用通用方法生成referralEntity // 调用通用方法生成referralEntity
ReferralEntity referralEntity = followReplyComponent.getCreateReferralEntity(referralBody); ReferralEntity referralEntity = followReplyComponent.getCreateReferralEntity(referralBody);
referralEntityList.add(referralEntity);
// 将生成的链接设置到多图文表中 // 将生成的链接设置到多图文表中
multiNewsEntity.setLinkUrl(referralEntity.getReferral()); multiNewsEntity.setLinkUrl(referralEntity.getReferral());
CustomerFollowReplyMultiNews entity = new CustomerFollowReplyMultiNews(); CustomerFollowReplyMultiNews entity = new CustomerFollowReplyMultiNews();
BeanUtil.copyProperties(multiNewsEntity, entity); BeanUtil.copyProperties(multiNewsEntity, entity);
entity.setId(snowflakeComponent.snowflakeId());
referralEntity.setId(entity.getId());
entityList.add(entity); entityList.add(entity);
referralEntityList.add(referralEntity);
} }
localLog.info("generate multi news size {}, referral entity size {}", entityList.size(), referralEntityList.size()); localLog.info("generate multi news size {}, referral entity size {}", entityList.size(), referralEntityList.size());
// 将这些多图文信息转换到缓存 // 将这些多图文信息转换到缓存
List<NewsMessageReplyEntity> cacheEntityList = JSONUtil.toList(JSONUtil.parseArray(multiNewsList), NewsMessageReplyEntity.class); List<NewsMessageReplyEntity> cacheEntityList = JSONUtil.toList(JSONUtil.parseArray(multiNewsList), NewsMessageReplyEntity.class);
redisTemplate.opsForHash().put(FOLLOW_REPLY_MULTI_NEWS_CACHE_KEY, appId, JSONUtil.toJsonStr(cacheEntityList)); redisTemplate.opsForHash().put(FOLLOW_REPLY_MULTI_NEWS_CACHE_KEY, accountEntity.getAppId(), JSONUtil.toJsonStr(cacheEntityList));
......
...@@ -124,7 +124,7 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe ...@@ -124,7 +124,7 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
// 多图文 // 多图文
List<FollowReplyMultiNewsCreateDTO> multiNewsList = saveDto.getMultiNewsList(); List<FollowReplyMultiNewsCreateDTO> multiNewsList = saveDto.getMultiNewsList();
localLog.info("appId {} follow reply has multi news size {}", saveDto.getAppid(), multiNewsList.size()); localLog.info("appId {} follow reply has multi news size {}", saveDto.getAppid(), multiNewsList.size());
followReplyMultiNewsService.saveFollowReplyMultiNews(entity.getId(), saveDto.getAppid(), saveDto.getMultiNewsList()); followReplyMultiNewsService.saveFollowReplyMultiNews(entity.getId(), saveDto.getAccountEntity(), saveDto.getMultiNewsList());
return new GenericsResult<>(true, "【测试】多图文关回设置成功"); return new GenericsResult<>(true, "【测试】多图文关回设置成功");
} else if (!CustomerMaterialConstant.TENCENT_MEDIA_TYPE_TEXT.equals(entity.getType())){ } else if (!CustomerMaterialConstant.TENCENT_MEDIA_TYPE_TEXT.equals(entity.getType())){
// 获取书城公众号链接(图文) // 获取书城公众号链接(图文)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论