| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.springblade.common.node.TreeStringNode; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.common.utils.AuthUtils; |
| | | import org.springblade.common.utils.NodeTreeUtil; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | |
| | | import org.springblade.modules.system.entity.Region; |
| | | import org.springblade.modules.system.mapper.DeptMapper; |
| | | import org.springblade.modules.system.node.DeptUserTreeNode; |
| | | import org.springblade.modules.system.node.TreeNode; |
| | | import org.springblade.modules.system.service.IDeptService; |
| | | import org.springblade.modules.system.service.IRegionService; |
| | | import org.springblade.modules.system.vo.DeptDetailVO; |
| | | import org.springblade.modules.system.vo.DeptVO; |
| | | import org.springblade.modules.system.wrapper.DeptWrapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | parentId = 0L; |
| | | } |
| | | // 判断数据权限控制,非超管角色只可看到本级及以下数据 |
| | | if (Func.toLong(parentId) == 0L && !AuthUtil.isAdministrator()) { |
| | | if (Func.toLong(parentId) == 0L && !AuthUtils.isAdministratorOrAdmin(AuthUtil.getUserRole())) { |
| | | Long deptId = Func.firstLong(AuthUtil.getDeptId()); |
| | | Dept dept = SysCache.getDept(deptId); |
| | | if (dept.getParentId() != 0) { |
| | | if (dept != null && dept.getParentId() != 0) { |
| | | parentId = dept.getParentId(); |
| | | } |
| | | List<DeptVO> deptVOS = baseMapper.lazyList(tenantId, parentId, param); |
| | |
| | | return ForestNodeMerger.merge(tree); |
| | | } |
| | | |
| | | /** |
| | | * 机构id |
| | | * @param deptId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DeptVO> tree(Long deptId) { |
| | | List<DeptVO> tree = baseMapper.tree("000000", deptId); |
| | | return ForestNodeMerger.merge(tree); |
| | | } |
| | | |
| | | @Override |
| | | public List<DeptVO> lazyTree(String tenantId, Long parentId) { |
| | | if (AuthUtil.isAdministrator()) { |
| | |
| | | if (Func.toLong(parentId) == 0L && !AuthUtil.isAdmin()) { |
| | | Long deptId = Func.firstLong(AuthUtil.getDeptId()); |
| | | Dept dept = SysCache.getDept(deptId); |
| | | if (dept.getParentId() != 0) { |
| | | if (dept != null && dept.getParentId() != 0) { |
| | | parentId = dept.getParentId(); |
| | | } |
| | | List<DeptVO> merge = ForestNodeMerger.merge(baseMapper.lazyTree(tenantId, parentId)); |
| | |
| | | // 查询当前机构信息 |
| | | DeptVO dept = baseMapper.getDeptById(id); |
| | | // 如果父机构为物业公司 |
| | | if (dept.getParentName().equals("物业公司")) { |
| | | if (!Strings.isBlank(dept.getParentName()) && dept.getParentName().equals("物业公司")) { |
| | | // 删除 |
| | | propertyCompanyService.remove(Wrappers.<PropertyCompanyEntity>update().lambda().eq(PropertyCompanyEntity::getDeptId, id)); |
| | | } |
| | |
| | | // 查询物业公司是否存在 |
| | | QueryWrapper<PropertyCompanyEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted", 0) |
| | | .eq("dept_id", dept.getId()) |
| | | .eq("name", dept.getDeptName()); |
| | | .eq("dept_id", dept.getId()); |
| | | PropertyCompanyEntity propertyCompanyEntity = propertyCompanyService.getOne(wrapper); |
| | | if (null != propertyCompanyEntity) { |
| | | // 修改 |