| | |
| | | } |
| | | }); |
| | | comActDiscussVO.setDiscussCommentList(discussComments.getRecords()); |
| | | String viewNumKey = String.join("_", DISCUSS_VIEW_NUM_PREFIX, id.toString()); |
| | | if (stringRedisTemplate.hasKey(viewNumKey)) { |
| | | ValueOperations<String, String> opsForValue = stringRedisTemplate.opsForValue(); |
| | | comActDiscussVO.setViewsNum(Integer.parseInt(opsForValue.get(viewNumKey))); |
| | | } |
| | | return R.ok(comActDiscussVO); |
| | | } |
| | | |
| | |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(); |
| | | return R.ok(comActDiscussVOIPage); |
| | | } |
| | | |
| | | /** |
| | |
| | | comActDiscussOptionUserDO.setUserId(userId); |
| | | comActDiscussOptionUserDO.setDiscussOptionId(optionId); |
| | | comActDiscussOptionUserDO.setDiscussId(discussId); |
| | | comActDiscussOptionUserDOList.add(comActDiscussOptionUserDO); |
| | | comActDiscussOptionUserDAO.insert(comActDiscussOptionUserDO); |
| | | }); |
| | | int result = comActDiscussOptionUserDAO.batchInsert(comActDiscussOptionUserDOList); |
| | | if (result > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | //组装viewNum key |
| | | List<String> viewNumKeys = new ArrayList<>(); |
| | | Iterator<String> iterator = needWriteDiscussIdSet.iterator(); |
| | | List<String> idList = null; |
| | | List<String> idList = new ArrayList<>(); |
| | | while (iterator.hasNext()) { |
| | | idList = Arrays.asList(iterator.next().split(",")); |
| | | if (nonNull(idList) && !idList.isEmpty()) { |
| | | idList.forEach(discussId -> viewNumKeys.add(String.join("_", DISCUSS_VIEW_NUM_PREFIX, discussId))); |
| | | String next = iterator.next(); |
| | | String key = String.join("_", DISCUSS_VIEW_NUM_PREFIX, next); |
| | | if (stringRedisTemplate.hasKey(key)) { |
| | | idList.add(next); |
| | | viewNumKeys.add(key); |
| | | } |
| | | } |
| | | |
| | |
| | | //待处理集合,以key-value/discussId-viewNum 存放 |
| | | HashMap<Long, Integer> needDealMap = new HashMap<>(); |
| | | if (nonNull(idList) && !idList.isEmpty()) { |
| | | log.error("一起议id列表:" + idList.toString()); |
| | | log.error("一起议浏览量:" + viewNumList.toString()); |
| | | for (String discussId : idList) { |
| | | try { |
| | | needDealMap.put(Long.parseLong(discussId), Integer.parseInt(viewNumList.get(0))); |
| | | viewNumList.remove(0); |
| | | } catch (IndexOutOfBoundsException e) { |
| | | log.error("数据异常:" + discussId, e.getMessage()); |
| | | //数据存在异常了,跳过,继续执行正确的 |
| | | continue; |
| | | } |