| | |
| | | List<TDeliberationVoteOption> options = tDeliberationVoteOptionList.stream().filter(e -> e.getVoteId().equals(tDeliberationVote.getId())).collect(Collectors.toList()); |
| | | for (TDeliberationVoteOption option : options) { |
| | | |
| | | if (option.getVoteCount() != null) { |
| | | |
| | | |
| | | String[] split = option.getVoteCount().split(","); |
| | | // split转为数组 |
| | | List<String> list = Arrays.asList(split); |
| | | option.setVoteCountNum(list.size()); |
| | | if(tDeliberationVote.getVoteState()==1 && userId!=null && list.contains(userId)){ |
| | | tDeliberationVote.setVoteState(2); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | tDeliberationVotePage.setRecords(tDeliberationVoteList); |
| | | return R.ok(tDeliberationVotePage); |
| | | } |
| | | |
| | | @ApiOperation(value = "议事投票--详情", response = TDeliberationVote.class) |
| | | @GetMapping("/getDeliberationVoteDetail/{id}") |
| | | public R<TDeliberationVote> getDeliberationVoteDetail(@PathVariable String id) { |
| | | String userId = null; |
| | | try { |
| | | userId = tokenService.getLoginUserApplet().getUserId(); |
| | | } catch (Exception e) { |
| | | } |
| | | TDeliberationVote tDeliberationVote = tDeliberationVoteService.getById(id); |
| | | if (tDeliberationVote != null) { |
| | | List<TDeliberationVoteOption> tDeliberationVoteOptionList = tDeliberationVoteOptionService.list(new LambdaQueryWrapper<TDeliberationVoteOption>().eq(TDeliberationVoteOption::getVoteId, id)); |
| | | List<TDeliberationVoteOption> options = tDeliberationVoteOptionList.stream().filter(e -> e.getVoteId().equals(tDeliberationVote.getId())).collect(Collectors.toList()); |
| | | for (TDeliberationVoteOption option : options) { |
| | | if (option.getVoteCount() != null) { |
| | | String[] split = option.getVoteCount().split(","); |
| | | // split转为数组 |
| | | List<String> list = Arrays.asList(split); |
| | | option.setVoteCountNum(list.size()); |
| | | if (tDeliberationVote.getVoteState() == 1 && userId != null && list.contains(userId)) { |
| | | tDeliberationVote.setVoteState(2); |
| | | } |
| | | } |
| | | |
| | | } |
| | | tDeliberationVote.setOptions(options); |
| | | } |
| | | return R.ok(tDeliberationVote); |
| | | } |
| | | |
| | | |
| | |
| | | List<TDeliberationVoteOption> list = tDeliberationVoteOptionService.list(new LambdaQueryWrapper<TDeliberationVoteOption>().eq(TDeliberationVoteOption::getVoteId, dto.getVoteId())); |
| | | for (TDeliberationVoteOption tDeliberationVoteOption : list) { |
| | | String voteCount = tDeliberationVoteOption.getVoteCount(); |
| | | if(voteCount != null){ |
| | | String[] split = voteCount.split(","); |
| | | if (Arrays.asList(split).contains(userId)) { |
| | | return R.fail("你已经投票"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | TDeliberationVoteOption tDeliberationVoteOption = list.stream().filter(e -> e.getOptionContent().equals(dto.getOptionContent())).findFirst().orElse(null); |
| | | if (tDeliberationVoteOption == null) { |
| | | return R.fail("选项不存在"); |