| | |
| | | //组装viewNum key |
| | | List<String> viewNumKeys = new ArrayList<>(); |
| | | Iterator<String> iterator = needWriteDiscussIdSet.iterator(); |
| | | List<String> idList = null; |
| | | while (iterator.hasNext()) { |
| | | viewNumKeys.add(String.join("_", DISCUSS_VIEW_NUM_PREFIX, iterator.next())); |
| | | idList = Arrays.asList(iterator.next().split(",")); |
| | | if (nonNull(idList) && !idList.isEmpty()) { |
| | | idList.forEach(discussId -> viewNumKeys.add(String.join("_", DISCUSS_VIEW_NUM_PREFIX, discussId))); |
| | | } |
| | | } |
| | | |
| | | ValueOperations opsForValue = stringRedisTemplate.opsForValue(); |
| | |
| | | |
| | | //待处理集合,以key-value/discussId-viewNum 存放 |
| | | HashMap<Long, Integer> needDealMap = new HashMap<>(); |
| | | for (String discussId : needWriteDiscussIdSet) { |
| | | if (nonNull(idList) && !idList.isEmpty()) { |
| | | for (String discussId : idList) { |
| | | try { |
| | | needDealMap.put(Long.parseLong(discussId), Integer.parseInt(viewNumList.get(0))); |
| | | viewNumList.remove(0); |
| | |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | int result = comActDiscussDAO.batchUpdateViewNum(needDealMap); |
| | | if (result <= 0) { |
| | | return R.fail("处理失败"); |