| | |
| | | package org.springblade.modules.article.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.springblade.common.utils.AuthUtils; |
| | | import org.springblade.common.utils.RoleUtil; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.modules.article.entity.Article; |
| | | import org.springblade.modules.article.entity.ArticleIntegralEntity; |
| | | import org.springblade.modules.article.mapper.ArticleMapper; |
| | | import org.springblade.modules.article.service.ArticleService; |
| | | import org.springblade.modules.article.service.IArticleIntegralService; |
| | | import org.springblade.modules.article.vo.ArticleVO; |
| | | import org.springblade.modules.district.entity.DistrictEntity; |
| | | import org.springblade.modules.district.service.IDistrictService; |
| | | import org.springblade.modules.house.entity.HouseholdEntity; |
| | | import org.springblade.modules.house.service.IHouseholdService; |
| | | import org.springblade.modules.property.entity.PropertyCompanyDistrictEntity; |
| | | import org.springblade.modules.property.entity.PropertyCompanyEntity; |
| | | import org.springblade.modules.property.service.IPropertyCompanyDistrictService; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | // List<String> collect = list.stream().map(PropertyCompanyDistrictEntity::getDistrictId).collect(Collectors.toList()); |
| | | // article.setDistrictIdList(collect); |
| | | // } |
| | | if (userRole.contains("wygly") || userRole.contains("wyxmjl")) { |
| | | if (RoleUtil.isProperty(userRole)) { |
| | | // 查询小区id |
| | | IPropertyDistrictUserService propertyDistrictUserService = SpringUtils.getBean(IPropertyDistrictUserService.class); |
| | | List<String> districtIds = propertyDistrictUserService.selectPropertyDistrictByUserId(AuthUtil.getUserId()); |
| | | // 通过用户机构查询用户的物业公司 |
| | | IPropertyCompanyService bean = SpringUtil.getBean(IPropertyCompanyService.class); |
| | | PropertyCompanyEntity companyEntity = bean.getOne(Wrappers.<PropertyCompanyEntity>lambdaQuery().eq(PropertyCompanyEntity::getDeptId, AuthUtil.getDeptId())); |
| | | PropertyCompanyEntity companyEntity = bean.getOne(Wrappers.<PropertyCompanyEntity>lambdaQuery() |
| | | .eq(PropertyCompanyEntity::getDeptId, AuthUtil.getDeptId()).last("limit 1")); |
| | | if (companyEntity != null) { |
| | | IPropertyCompanyDistrictService bean2 = SpringUtils.getBean(IPropertyCompanyDistrictService.class); |
| | | // 通过物业公司,查询小区 |
| | |
| | | } |
| | | article.setPropertyFlag(1); |
| | | } |
| | | if (userRole.contains("jdgly")) { |
| | | List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId()); |
| | | if (regionChildCodesList.size() > 0) { |
| | | article.setDistrictIdList(regionChildCodesList); |
| | | if (userRole.contains("jdgly") || userRole.contains("sqgly")) { |
| | | IDistrictService districtService = SpringUtils.getBean(IDistrictService.class); |
| | | List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId(), null); |
| | | List<DistrictEntity> list = districtService.list(Wrappers.<DistrictEntity>lambdaQuery().in(DistrictEntity::getCommunityCode, regionChildCodesList)); |
| | | if (list.size() > 0) { |
| | | article.setDistrictIdList(list.stream().map(item -> item.getId()).collect(Collectors.toList())); |
| | | } |
| | | } |
| | | return page.setRecords(baseMapper.selectArticlePage(page, article)); |
| | |
| | | */ |
| | | @Override |
| | | public IPage<ArticleVO> selectArticlePageByApp(IPage<ArticleVO> page, ArticleVO article) { |
| | | // 查询用户小区的id |
| | | String districId = baseMapper.getDistrictId(article.getHouseCode()); |
| | | article.setDistrictId(districId); |
| | | article.setUserId(AuthUtil.getUserId()); |
| | | // 判断是否管理员 |
| | | if (AuthUtils.isAdministratorOrAdmin(SpringUtils.getRequestParam("roleName"))) { |
| | | IDistrictService districtService = SpringUtils.getBean(IDistrictService.class); |
| | | String communityCode = SpringUtils.getRequestParam("communityCode"); |
| | | List<DistrictEntity> list = districtService.list(Wrappers.<DistrictEntity>lambdaQuery() |
| | | .like(DistrictEntity::getCommunityCode, communityCode)); |
| | | if (list.size() > 0) { |
| | | article.setDistrictIdList(list.stream().map(item -> item.getId()).collect(Collectors.toList())); |
| | | } |
| | | } else { |
| | | // 查询用户小区的id |
| | | String districId = baseMapper.getDistrictId(article.getHouseCode()); |
| | | List<String> objects = new ArrayList<>(); |
| | | objects.add(districId); |
| | | article.setDistrictIdList(objects); |
| | | } |
| | | IHouseholdService householdService = SpringUtils.getBean(IHouseholdService.class); |
| | | HouseholdEntity householdEntity = householdService.getOne(Wrappers.<HouseholdEntity>lambdaQuery() |
| | | .eq(HouseholdEntity::getHouseCode, article.getHouseCode()) |
| | | .eq(HouseholdEntity::getAssociatedUserId, AuthUtil.getUserId()) |
| | | .eq(HouseholdEntity::getIsDeleted, 0) |
| | | .last("limit 1")); |
| | | if (householdEntity != null) { |
| | | article.setHouseholdId(householdEntity.getId()); |
| | | } |
| | | List<ArticleVO> articleVOS = baseMapper.selectArticlePageByApp(page, article); |
| | | return page.setRecords(articleVOS); |
| | | } |
| | |
| | | ArticleVO articleVO = baseMapper.getArticleOne(article); |
| | | return articleVO; |
| | | } |
| | | |
| | | @Override |
| | | public List<ArticleVO> getArticleByDistrictId(ArticleVO article) { |
| | | List<String> stringList = Arrays.asList(article.getDistrictId().split(",")); |
| | | article.setDistrictIdList(stringList); |
| | | return baseMapper.getArticleByDistrictId(article); |
| | | } |
| | | |
| | | /** |
| | | * 文章信息更新 |
| | | * |
| | | * @param objectUpdateWrapper |
| | | * @param id |
| | | * @param houseCode |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateArticle(UpdateWrapper<Article> objectUpdateWrapper, Long id, String houseCode) { |
| | | boolean update = update(null, objectUpdateWrapper); |
| | | if (update) { |
| | | // 查询对应的文章 |
| | | Article article = getById(id); |
| | | // 只有反诈的有浏览积分 |
| | | if (article.getType() == 6) { |
| | | // 添加浏览记录信息 |
| | | ArticleIntegralEntity integralEntity = new ArticleIntegralEntity(); |
| | | integralEntity.setScore(article.getScore()); |
| | | integralEntity.setArticleId(id); |
| | | integralEntity.setHouseCode(houseCode); |
| | | integralEntity.setCreateUser(AuthUtil.getUserId()); |
| | | // 插入记录 |
| | | update = SpringUtils.getBean(IArticleIntegralService.class).save(integralEntity); |
| | | } |
| | | } |
| | | // 返回 |
| | | return update; |
| | | } |
| | | |
| | | /** |
| | | * 查询所有文章数据 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Article> getAllList(int i, int size) { |
| | | return baseMapper.getAllList(i, size); |
| | | } |
| | | |
| | | /** |
| | | * 查询所有文章数据总数 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int getAllListTotal() { |
| | | return baseMapper.getAllListTotal(); |
| | | } |
| | | } |