From b9a73644c11e7d6cc93ca0c26e61451222fad356 Mon Sep 17 00:00:00 2001
From: 101captain <237651143@qq.com>
Date: 星期四, 11 十一月 2021 16:42:40 +0800
Subject: [PATCH] 1111修改提交
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActDiscussServiceImpl.java | 54 +++++++++++++++++++++++++++---------------------------
1 files changed, 27 insertions(+), 27 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..dee86d2 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
@@ -204,10 +204,13 @@
}
if (currentUserRoles.isEmpty()) {
checkResult = false;
- }
- boolean result = sysAllowedRoles.stream().anyMatch(role -> currentUserRoles.contains(role));
- if (!result) {
- checkResult = false;
+ } else {
+ if (!sysAllowedRoles.contains("1")) {
+ boolean result = sysAllowedRoles.stream().anyMatch(role -> currentUserRoles.contains(role));
+ if (!result) {
+ checkResult = false;
+ }
+ }
}
}
}
@@ -251,7 +254,7 @@
} else {
comActDiscussDO.setStatus(ComActDiscussDO.status.yfb);
}
- comActDiscussDO.setUpdateAt(new Date());
+ comActDiscussDO.setUpdateAt(nowDate);
int insert = comActDiscussDAO.updateById(comActDiscussDO);
if (insert > 0) {
//如果是投票,需要把投票的选项存储
@@ -597,12 +600,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 +671,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);
}
@@ -687,11 +681,13 @@
*/
private void checkDiscussStatusIsCorrect(ComActDiscussVO comActDiscussVO) {
//判断discuss状态是否正确
- boolean isIncorrectStatus = comActDiscussVO.getEndTime().before(new Date()) &&
- (comActDiscussVO.getStatus().intValue() == 1 || comActDiscussVO.getStatus().intValue() == 2);
- if (isIncorrectStatus) {
- comActDiscussVO.setStatus(3);
- comActDiscussDAO.updateStatusById(comActDiscussVO.getId(), 3);
+ if(comActDiscussVO.getEndTime() != null){
+ boolean isIncorrectStatus = comActDiscussVO.getEndTime().before(new Date()) &&
+ (comActDiscussVO.getStatus().intValue() == 1 || comActDiscussVO.getStatus().intValue() == 2);
+ if (isIncorrectStatus) {
+ comActDiscussVO.setStatus(3);
+ comActDiscussDAO.updateStatusById(comActDiscussVO.getId(), 3);
+ }
}
}
@@ -904,9 +900,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 +1138,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