From 7a282d69e08d875a016975ea4b980bec98a9bab8 Mon Sep 17 00:00:00 2001
From: huanghongfa <huanghongfa123456>
Date: 星期五, 24 九月 2021 18:06:21 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/four_member' into four_member
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActDiscussServiceImpl.java | 29 ++++++++++++-----------------
1 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActDiscussServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActDiscussServiceImpl.java
index 2dbcd46..8db80c5 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActDiscussServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActDiscussServiceImpl.java
@@ -597,12 +597,14 @@
IPage<ComActDiscussVO> iPage = comActDiscussDAO.pageDiscussApplets(page, pageComActDiscussDTO);
List<ComActDiscussVO> records = iPage.getRecords();
if (!ObjectUtils.isEmpty(records)) {
- List<String> viewNumKeys = new ArrayList<>();
records.forEach(comActDiscussVO -> {
Integer type = comActDiscussVO.getType();
Long id = comActDiscussVO.getId();
String viewNumKey = String.join("_", DISCUSS_VIEW_NUM_PREFIX, id.toString());
- viewNumKeys.add(viewNumKey);
+ if (stringRedisTemplate.hasKey(viewNumKey)) {
+ ValueOperations<String, String> opsForValue = stringRedisTemplate.opsForValue();
+ comActDiscussVO.setViewsNum(Integer.parseInt(opsForValue.get(viewNumKey)));
+ }
if (type.equals(2)) {
List<ComActDiscussOptionDO> comActDiscussOptionDOS = comActDiscussOptionDAO.selectList(
new QueryWrapper<ComActDiscussOptionDO>().lambda().eq(ComActDiscussOptionDO::getDiscussId, id));
@@ -666,17 +668,6 @@
comActDiscussVO.setHaveVote(haveVote > 0 ? 1 : 0);
}
});
- ValueOperations opsForValue = stringRedisTemplate.opsForValue();
- List<String> viewNumList = opsForValue.multiGet(viewNumKeys);
- for (ComActDiscussVO discussVO : records) {
- try {
- discussVO.setViewsNum(Integer.parseInt(viewNumList.get(0)));
- viewNumList.remove(0);
- } catch (IndexOutOfBoundsException e) {
- //数据存在异常了,跳过,继续执行正确的
- continue;
- }
- }
}
return R.ok(iPage);
}
@@ -904,9 +895,11 @@
comActDiscussVO.setHaveVote(comActDiscussVO1.getHaveVote());
}
String viewNumKey = String.join("_", DISCUSS_VIEW_NUM_PREFIX, id.toString());
- ValueOperations opsForValue = stringRedisTemplate.opsForValue();
- int viewNum = Integer.parseInt((String) opsForValue.get(viewNumKey));
- comActDiscussVO.setViewsNum(viewNum);
+ if (stringRedisTemplate.hasKey(viewNumKey)) {
+ ValueOperations opsForValue = stringRedisTemplate.opsForValue();
+ int viewNum = Integer.parseInt((String) opsForValue.get(viewNumKey));
+ comActDiscussVO.setViewsNum(viewNum);
+ }
return R.ok(comActDiscussVO);
}
@@ -1140,7 +1133,9 @@
@Override
public R discussJurisdictionGet(Long communityId, Long userId) {
List<SysConfDO> confDOList = sysConfDao.selectList(new LambdaQueryWrapper<SysConfDO>()
- .eq(SysConfDO::getCommunityId, communityId).orderByDesc(SysConfDO::getCreateAt));
+ .eq(SysConfDO::getCommunityId, communityId)
+ .eq(SysConfDO::getCode,Constants.DISCUSS_IDENTITY_KEY + communityId)
+ .orderByDesc(SysConfDO::getCreateAt));
if (confDOList == null || confDOList.size() == 0) {
SysConfDO sysConfDO = new SysConfDO();
sysConfDO.setCode(Constants.DISCUSS_IDENTITY_KEY + communityId);
--
Gitblit v1.7.1