| | |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.constraints.NotEmpty; |
| | | |
| | | import com.panzhihua.common.model.dtos.community.ComActDiscussVoteOptionDTO; |
| | | import com.panzhihua.common.model.dtos.community.DiscussVoteOptionDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageVoteSituationDTO; |
| | | import com.panzhihua.service_community.dao.ComPbMemberDAO; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.data.redis.connection.StringRedisConnection; |
| | | import org.springframework.data.redis.core.RedisCallback; |
| | |
| | | private UserService userService; |
| | | @Resource |
| | | private StringRedisTemplate stringRedisTemplate; |
| | | @Resource |
| | | private ComPbMemberDAO pbMemberDAO; |
| | | |
| | | /** |
| | | * 议事投票-新增 |
| | |
| | | comActDiscussOptionDO.setDiscussId(comActDiscussDO1Id); |
| | | comActDiscussOptionDO.setOptionContent(s.getOptionContent()); |
| | | comActDiscussOptionDO.setOptionUrl(s.getOptionUrl()); |
| | | comActDiscussOptionDO.setNeedReason(s.getNeedReason()); |
| | | comActDiscussOptionDOS.add(comActDiscussOptionDO); |
| | | }); |
| | | comActDiscussOptionService.saveBatch(comActDiscussOptionDOS); |
| | |
| | | } |
| | | }); |
| | | 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); |
| | | } |
| | | |
| | |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | pageComActDiscussDTO.setIsPbMember(0); |
| | | pageComActDiscussDTO.setIsVolunteer(0); |
| | | if (nonNull(loginUserId)) { |
| | | pageComActDiscussDTO.setIsPbMember(pbMemberDAO.checkIsPbMember(loginUserId) > 0 ? 1 : 0); |
| | | pageComActDiscussDTO.setIsVolunteer(pbMemberDAO.checkIsVolunteer(loginUserId) > 0 ? 1 : 0); |
| | | } |
| | | IPage<ComActDiscussVO> iPage = comActDiscussDAO.pageDiscussApplets(page, pageComActDiscussDTO); |
| | | List<ComActDiscussVO> records = iPage.getRecords(); |
| | | if (!ObjectUtils.isEmpty(records)) { |
| | |
| | | /** |
| | | * 议事投票-投票 |
| | | * |
| | | * @param comActDiscussOptionUserDTO 投票信息 |
| | | * @param discussVoteOptionDTO 投票信息 |
| | | * @return 投票结果 |
| | | */ |
| | | @Override |
| | | public R addDiscussOptionUser(ComActDiscussOptionUserDTO comActDiscussOptionUserDTO) { |
| | | List<Long> discussOptionIds = comActDiscussOptionUserDTO.getDiscussOptionIds(); |
| | | Long discussOptionId = discussOptionIds.get(0); |
| | | Long userId = comActDiscussOptionUserDTO.getUserId(); |
| | | public R addDiscussOptionUser(DiscussVoteOptionDTO discussVoteOptionDTO) { |
| | | List<ComActDiscussVoteOptionDTO> options = discussVoteOptionDTO.getOptions(); |
| | | Long discussOptionId = options.get(0).getId(); |
| | | Long userId = discussVoteOptionDTO.getUserId(); |
| | | ComActDiscussOptionDO comActDiscussOptionDO = comActDiscussOptionDAO.selectById(discussOptionId); |
| | | if (ObjectUtils.isEmpty(comActDiscussOptionDO)) { |
| | | return R.fail("选项不存在"); |
| | |
| | | } |
| | | boolean isRepeat = comActDiscussDO.getIsRepeat().intValue() == 1; |
| | | int usableVoteVotes = comActDiscussDO.getCount().intValue(); |
| | | int currentVoteNum = discussOptionIds.size(); |
| | | int currentVoteNum = options.size(); |
| | | if (isRepeat) { |
| | | //可重复投票 |
| | | int votedVotesInToday = comActDiscussOptionUserDAO.selectVotedVotesInToday(discussId, userId); |
| | |
| | | } |
| | | } |
| | | List<ComActDiscussOptionUserDO> comActDiscussOptionUserDOList = new ArrayList<>(); |
| | | discussOptionIds.forEach(optionId -> { |
| | | options.forEach(option -> { |
| | | ComActDiscussOptionUserDO comActDiscussOptionUserDO = new ComActDiscussOptionUserDO(); |
| | | comActDiscussOptionUserDO.setUserId(userId); |
| | | comActDiscussOptionUserDO.setDiscussOptionId(optionId); |
| | | comActDiscussOptionUserDO.setDiscussOptionId(option.getId()); |
| | | comActDiscussOptionUserDO.setDiscussId(discussId); |
| | | comActDiscussOptionUserDOList.add(comActDiscussOptionUserDO); |
| | | comActDiscussOptionUserDO.setSignUrl(option.getSignUrl()); |
| | | comActDiscussOptionUserDO.setReason(option.getReason()); |
| | | comActDiscussOptionUserDAO.insert(comActDiscussOptionUserDO); |
| | | }); |
| | | int result = comActDiscussOptionUserDAO.batchInsert(comActDiscussOptionUserDOList); |
| | | if (result > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 投票情况-分页查询 |
| | | * @param pageVoteSituationDTO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R pageVoteSituation(PageVoteSituationDTO pageVoteSituationDTO) { |
| | | Page page = new Page<>(); |
| | | page.setCurrent(pageVoteSituationDTO.getPageNum()); |
| | | page.setSize(pageVoteSituationDTO.getPageSize()); |
| | | return R.ok(comActDiscussOptionUserDAO.pageVoteSituation(page, pageVoteSituationDTO)); |
| | | } |
| | | |
| | | /** |
| | | * 投票情况详情 |
| | | * @param optionUserId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R detailVoteSituation(Long optionUserId) { |
| | | return R.ok(comActDiscussOptionUserDAO.detailVoteSituation(optionUserId)); |
| | | } |
| | | |
| | | /** |
| | | * 将redis中浏览量写入表中 |
| | | * @return 执行结果 |
| | | */ |