| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | |
| | | ComActDiscussOptionVO comActDiscussOptionVO=new ComActDiscussOptionVO(); |
| | | BeanUtils.copyProperties(comActDiscussOptionDO,comActDiscussOptionVO); |
| | | comActDiscussOptionVO.setNum(selectCount); |
| | | |
| | | //判断选项是否已投票 |
| | | int haveVote=comActDiscussOptionUserDAO.selectHaveVotes(comActDiscussOptionDO.getId(),loginUserId); |
| | | comActDiscussOptionVO.setHaveVote(haveVote>0?1:0); |
| | | comActDiscussOptionVOS.add(comActDiscussOptionVO); |
| | | }); |
| | | comActDiscussOptionVOS.sort(Comparator.comparing(ComActDiscussOptionVO::getNum).reversed()); |
| | |
| | | comActDiscussCommentVO.setHaveSign(0); |
| | | } |
| | | |
| | | //判断当前评论是否是社区管理员评论 |
| | | if(!comActDiscussCommentVO.getUserType().equals(1)){ |
| | | comActDiscussCommentVO.setUserNickName("社区管理员"); |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(iPage); |
| | |
| | | ComActDiscussOptionVO comActDiscussOptionVO=new ComActDiscussOptionVO(); |
| | | BeanUtils.copyProperties(comActDiscussOptionDO,comActDiscussOptionVO); |
| | | comActDiscussOptionVO.setNum(selectCount); |
| | | //判断选项是否已投票 |
| | | int haveVote=comActDiscussOptionUserDAO.selectHaveVotes(comActDiscussOptionDO.getId(),loginUserId); |
| | | comActDiscussOptionVO.setHaveVote(haveVote>0?1:0); |
| | | comActDiscussOptionVOS.add(comActDiscussOptionVO); |
| | | }); |
| | | comActDiscussOptionVOS.sort(Comparator.comparing(ComActDiscussOptionVO::getNum).reversed()); |
| | |
| | | LoginUserInfoVO loginUserInfoVO=comActDiscussDAO.selectUserByUserId(userId); |
| | | if(loginUserInfoVO != null){ |
| | | comActDiscussVO.setUserName(loginUserInfoVO.getName()); |
| | | comActDiscussVO.setUserNickName(loginUserInfoVO.getNickName()); |
| | | if(StringUtils.isEmpty(loginUserInfoVO.getNickName())){ |
| | | comActDiscussVO.setUserNickName(loginUserInfoVO.getName()); |
| | | }else{ |
| | | comActDiscussVO.setUserNickName(loginUserInfoVO.getNickName()); |
| | | } |
| | | comActDiscussVO.setImageUrl(loginUserInfoVO.getImageUrl()); |
| | | comActDiscussVO.setUserType(loginUserInfoVO.getType()); |
| | | } |
| | | Long communityId = comActDiscussDO.getCommunityId(); |
| | | Integer type1 = loginUserInfoVO.getType(); |
| | |
| | | if (ObjectUtils.isEmpty(comActDiscussOptionDO)) { |
| | | return R.fail("选项不存在"); |
| | | } |
| | | Long discussId = comActDiscussOptionDO.getDiscussId(); |
| | | List<ComActDiscussOptionDO> comActDiscussOptionDOS = comActDiscussOptionDAO.selectList(new QueryWrapper<ComActDiscussOptionDO>().lambda().eq(ComActDiscussOptionDO::getDiscussId, discussId)); |
| | | List<Long> longList=comActDiscussOptionDOS.stream().map(comActDiscussOptionDO1 -> comActDiscussOptionDO1.getId()).collect(Collectors.toList()); |
| | | Integer integer = comActDiscussOptionUserDAO.selectCount(new QueryWrapper<ComActDiscussOptionUserDO>().lambda().eq(ComActDiscussOptionUserDO::getUserId, userId).in(ComActDiscussOptionUserDO::getDiscussOptionId, longList)); |
| | | // Long discussId = comActDiscussOptionDO.getDiscussId(); |
| | | // List<ComActDiscussOptionDO> comActDiscussOptionDOS = comActDiscussOptionDAO.selectList(new QueryWrapper<ComActDiscussOptionDO>().lambda().eq(ComActDiscussOptionDO::getDiscussId, discussId)); |
| | | // List<Long> longList=comActDiscussOptionDOS.stream().map(comActDiscussOptionDO1 -> comActDiscussOptionDO1.getId()).collect(Collectors.toList()); |
| | | Integer integer = comActDiscussOptionUserDAO.selectCount(new QueryWrapper<ComActDiscussOptionUserDO>().lambda().eq(ComActDiscussOptionUserDO::getUserId, userId).eq(ComActDiscussOptionUserDO::getDiscussOptionId, discussOptionId)); |
| | | if (integer>0) { |
| | | return R.fail("不要重复投票"); |
| | | } |