diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/BannerDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/BannerDTO.java index 30e093db9..836470f4e 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/BannerDTO.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/BannerDTO.java @@ -19,6 +19,7 @@ package com.elink.esua.epdc.dto; import java.io.Serializable; import java.util.Date; +import java.util.List; import lombok.Data; @@ -129,4 +130,24 @@ public class BannerDTO implements Serializable { */ private String newsId; + /** + * 父所有部门 + */ + private String parentDeptIds; + + /** + * 父所有部门名称 + */ + private String parentDeptNames; + + /** + * 所有部门 + */ + private List allDeptIds; + + /** + * 所有部门名称 + */ + private String allDeptNames; + } \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/BannerEntity.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/BannerEntity.java index 4fd6392d6..92a1bda23 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/BannerEntity.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/BannerEntity.java @@ -98,4 +98,23 @@ public class BannerEntity extends BaseEpdcEntity { */ private String newsId; + /** + * 父所有部门 + */ + private String parentDeptIds; + + /** + * 父所有部门名称 + */ + private String parentDeptNames; + + /** + * 所有部门 + */ + private String allDeptIds; + + /** + * 所有部门名称 + */ + private String allDeptNames; } \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/BannerServiceImpl.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/BannerServiceImpl.java index 6299abcad..9dd90b2f7 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/BannerServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/BannerServiceImpl.java @@ -32,6 +32,7 @@ import com.elink.esua.epdc.commons.tools.constant.FieldConstant; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dao.BannerDao; import com.elink.esua.epdc.dto.BannerDTO; +import com.elink.esua.epdc.dto.ParentAndAllDeptDTO; import com.elink.esua.epdc.dto.epdc.form.EpdcBannerListFromDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcBannerListResultDTO; import com.elink.esua.epdc.entity.BannerEntity; @@ -44,6 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -107,29 +109,34 @@ public class BannerServiceImpl extends BaseServiceImpl if (StringUtils.isBlank(dto.getId())) { entity.setState(YesOrNoEnum.NO.value()); } - // 通知所属部门id - Long noticeDeptId = entity.getStreetId(); - // 能接收通知的所有网格的ID - List noticeGridList = Lists.newArrayList(); - if (null != entity.getCommunityId()) { - noticeDeptId = entity.getCommunityId(); - } - if (null != entity.getGridId()) { - noticeDeptId = entity.getGridId(); - noticeGridList.add(noticeDeptId); + List allDeptIds = dto.getAllDeptIds(); + // bnner所属部门id + Long bnnerDeptId = 0L; + if(allDeptIds != null && allDeptIds.size() != 0){ + // 塞入全部部门ids,names + bnnerDeptId = Long.valueOf(allDeptIds.get(allDeptIds.size() - 1)); + Result parentResult = adminFeignClient.getParentAndAllDept(String.valueOf(bnnerDeptId)); + if (!parentResult.success() || parentResult.getData() == null) { + throw new RenException("获取部门信息失败"); + }else { + ParentAndAllDeptDTO deptDTO = parentResult.getData(); + entity.setAllDeptIds(deptDTO.getAllDeptIds()); + entity.setAllDeptNames(deptDTO.getAllDeptNames()); + entity.setParentDeptIds(deptDTO.getParentDeptIds()); + entity.setParentDeptNames(deptDTO.getParentDeptNames()); + } + }else { + throw new RenException("所属部门不能为空"); } - - if (!user.getDeptIdList().contains(noticeDeptId)) { + if (!user.getDeptIdList().contains(bnnerDeptId)) { throw new RenException("您没有操作此部门的数据权限"); } - - if (CollUtil.isEmpty(noticeGridList)) { - Result> adminResult = adminFeignClient.listGridIdByDeptPid(noticeDeptId); - if (!adminResult.success() || CollUtil.isEmpty(adminResult.getData())) { - throw new RenException("获取部门信息失败"); - } - noticeGridList = adminResult.getData(); + List bannerGridList = new ArrayList<>(); + Result> adminResult = adminFeignClient.listGridIdByDeptPid(bnnerDeptId); + if (!adminResult.success() || CollUtil.isEmpty(adminResult.getData())) { + throw new RenException("获取部门信息失败"); } + bannerGridList = adminResult.getData(); boolean isSave = true; if (StringUtils.isNotBlank(dto.getId())) { @@ -143,7 +150,7 @@ public class BannerServiceImpl extends BaseServiceImpl bannerDepartmentService.deleteByBannerId(entity.getId()); } - this.bannerDepartmentService.save(entity.getId(), noticeGridList); + this.bannerDepartmentService.save(entity.getId(), bannerGridList); } @Override