| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jetbrains.annotations.Nullable; |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.modules.discuss.entity.PublicDiscussEntity; |
| | |
| | | import org.springblade.modules.discuss.service.IUserTopicsService; |
| | | import org.springblade.modules.discuss.vo.TopicsVO; |
| | | import org.springblade.modules.discuss.vo.UserTopicsVO; |
| | | import org.springblade.modules.district.entity.DistrictEntity; |
| | | import org.springblade.modules.district.service.IDistrictService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 用户议题报表 服务实现类 |
| | |
| | | |
| | | @Override |
| | | public IPage<UserTopicsVO> selectUserTopicsPage(IPage<UserTopicsVO> page, UserTopicsVO userTopics) { |
| | | if (StringUtils.isNotBlank(userTopics.getDistrictId())) { |
| | | List<String> longs = JSON.parseArray(userTopics.getDistrictId()).toJavaList(String.class); |
| | | IDistrictService bean = SpringUtils.getBean(IDistrictService.class); |
| | | List<DistrictEntity> list = bean.list(Wrappers.<DistrictEntity>lambdaQuery().in(DistrictEntity::getId, longs)); |
| | | List<String> collect = list.stream().map(item -> |
| | | item.getAoiCode() |
| | | ).collect(Collectors.toList()); |
| | | if (collect != null) { |
| | | userTopics.setAoiCodeList(collect); |
| | | } |
| | | } |
| | | return page.setRecords(baseMapper.selectUserTopicsPage(page, userTopics)); |
| | | } |
| | | |
| | |
| | | PublicDiscussEntity one = bean.getOne(Wrappers.<PublicDiscussEntity>lambdaQuery().eq(PublicDiscussEntity::getArticleId, topics.get(0).getArticleId())); |
| | | // 一户一票 |
| | | if (one.getVoteRestrictions().equals(CommonConstant.NUMBER_ONE)) { |
| | | long count = count(Wrappers.<UserTopicsEntity>lambdaQuery().eq(UserTopicsEntity::getHouseCode, topics.get(0).getHouseCode())); |
| | | long count = count(Wrappers.<UserTopicsEntity>lambdaQuery() |
| | | .eq(UserTopicsEntity::getHouseCode, topics.get(0).getHouseCode()) |
| | | .eq(UserTopicsEntity::getArticleId,topics.get(0).getArticleId())); |
| | | if (count > 1) { |
| | | throw new Exception("您的房屋已投票,不能重复投票!"); |
| | | } |
| | | } else { |
| | | // |
| | | long count = count(Wrappers.<UserTopicsEntity>lambdaQuery().eq(UserTopicsEntity::getUserId, AuthUtil.getUserId())); |
| | | long count = count(Wrappers.<UserTopicsEntity>lambdaQuery() |
| | | .eq(UserTopicsEntity::getUserId, AuthUtil.getUserId()) |
| | | .eq(UserTopicsEntity::getArticleId,topics.get(0).getArticleId())); |
| | | if (count > 1) { |
| | | throw new Exception("您的已投票,不能重复投票!"); |
| | | } |
| | |
| | | userTopics.setSelected(topic.getSelected()); |
| | | userTopics.setUserId(AuthUtil.getUserId()); |
| | | userTopics.setPublicDiscussId(topic.getPublicDiscussId()); |
| | | userTopics.setTopicsId(Integer.valueOf(topic.getSelected())); |
| | | userTopics.setArticleId(topic.getArticleId()); |
| | | userTopics.setHouseCode(topic.getHouseCode()); |
| | | userTopics.setSignaturePath(topic.getSignaturePath()); |
| | | UpdateWrapper<TopicsEntity> objectUpdateWrapper = new UpdateWrapper<>(); |
| | | objectUpdateWrapper.setSql("number = number + 1"); |
| | | objectUpdateWrapper.eq("id", topic.getSelected()); |
| | |
| | | userTopics.setPublicDiscussId(topic.getPublicDiscussId()); |
| | | userTopics.setArticleId(topic.getArticleId()); |
| | | userTopics.setHouseCode(topic.getHouseCode()); |
| | | userTopics.setTopicsId((Integer) o); |
| | | userTopics.setSignaturePath(topic.getSignaturePath()); |
| | | objectsTwo.add(userTopics); |
| | | UpdateWrapper<TopicsEntity> objectUpdateWrapper = new UpdateWrapper<>(); |
| | | objectUpdateWrapper.setSql("number = number + 1"); |
| | | objectUpdateWrapper.eq("id", o); |
| | | objectsTwo.add(userTopics); |
| | | topicsService.update(null, objectUpdateWrapper); |
| | | } |
| | | return save(objectsTwo.get(0)); |
| | | return saveBatch(objectsTwo); |
| | | } |
| | | } |
| | | return null; |