forked from kidgrow-microservices-platform

dougang
2021-04-08 6d0fee3cdc8cb213d0388ffa2e7ed7a091a1ea4c
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/service/impl/SysRoleOrganizationServiceImpl.java
@@ -1,29 +1,26 @@
package com.kidgrow.usercenter.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kidgrow.common.annotation.LoginUser;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kidgrow.common.model.*;
import com.kidgrow.common.service.impl.SuperServiceImpl;
import com.kidgrow.usercenter.dto.SysRoleOrganizationDto;
import com.kidgrow.usercenter.dto.SysRoleOrganizationMybatisDto;
import com.kidgrow.usercenter.mapper.SysRoleMapper;
import com.kidgrow.usercenter.mapper.SysRoleOrganizationMapper;
import com.kidgrow.usercenter.model.SysRoleOrganization;
import com.kidgrow.usercenter.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kidgrow.common.service.impl.SuperServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.collections4.MapUtils;
import lombok.extern.slf4j.Slf4j;
import com.kidgrow.usercenter.model.SysRoleOrganization;
import com.kidgrow.usercenter.mapper.SysRoleOrganizationMapper;
import org.springframework.transaction.annotation.Transactional;
/**
 * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br>
@@ -136,7 +133,7 @@
    public List<Map<String, Object>> getTreeData(Long MyId, List<SysOrganization> sysOrganizations, List<Long> col) {
        List<Map<String, Object>> listMap = new ArrayList<>();
        Map<Long, SysOrganization> collect = sysOrganizations.stream().collect(Collectors.toMap(SysOrganization::getId, SysOrganization -> SysOrganization));
        List<Long> idList = sysOrganizations.stream().filter(e -> e.getOrgParentId() == MyId).map(e -> e.getId()).collect(Collectors.toList());
        List<Long> idList = sysOrganizations.stream().filter(e -> e.getOrgParentId() .equals(MyId)).map(e -> e.getId()).collect(Collectors.toList());
        for (Long id : idList
        ) {
            Map<String, Object> map = new HashMap<>();
@@ -144,7 +141,7 @@
            map.put("name", collect.get(id).getOrgName());
            map.put("level", collect.get(id).getOrgLevel());
            map.put("checked", col.contains(id));
            List<Long> childs = sysOrganizations.stream().filter(e -> e.getOrgParentId() == id).map(e -> e.getId()).collect(Collectors.toList());
            List<Long> childs = sysOrganizations.stream().filter(e -> e.getOrgParentId().equals(id)).map(e -> e.getId()).collect(Collectors.toList());
            if (childs.size() > 0) {
                List<Map<String, Object>> treeData = getTreeData(id, sysOrganizations, col);
                map.put("children", treeData);
@@ -173,7 +170,7 @@
                    Map<Integer, Object> rolemap = new HashMap<>();
                    SysRoleOrganizationMybatisDto dto=new SysRoleOrganizationMybatisDto();
                    if(e.getType() == 1){
                        dto.setFlag(index==0);
                        dto.setFlag(index==0);//角色如果只有一条的话,将进行and的sql拼写;角色如果多条的话将进行or的sql拼写
                        dto.setObject(user.getId());
                        rolemap.put(e.getType(), dto);
                    }else if (e.getType() == 2) {