forked from kidgrow-microservices-platform

zhaoxiaohao
2020-11-17 b7265cdd6f3e1fbb0d428c27e5b5e29e34d56953
kidgrow-springcloud/kidgrow-springcloud-zuul/src/main/java/com/kidgrow/zuul/filter/UserInfoHeaderFilter.java
@@ -90,22 +90,22 @@
                    doctorId=sysDoctors.get(0).getId();
                    departmentId=sysDoctors.get(0).getDepartmentId();
                    departmentName=sysDoctors.get(0).getDepartmentName();
                    ctx.addZuulRequestHeader(SecurityConstants.USER_ORG_NAME_HEADER, URLEncoder.encode(sysDoctors.get(0).getHospitalName(),"UTF-8"));
                    ctx.addZuulRequestHeader(SecurityConstants.USER_DEP_ID_HEADER,String.valueOf(departmentId));
                    ctx.addZuulRequestHeader(SecurityConstants.USER_DEP_NAME_HEADER,URLEncoder.encode(departmentName,"UTF-8"));
                }
                ctx.addZuulRequestHeader(SecurityConstants.USER_ID_HEADER, String.valueOf(user.getId()));
                ctx.addZuulRequestHeader(SecurityConstants.DOCTOR_ID_HEADER, String.valueOf(doctorId));
                ctx.addZuulRequestHeader(SecurityConstants.USER_HEADER, user.getUsername());
                ctx.addZuulRequestHeader(SecurityConstants.USER_REAL_NAME,URLEncoder.encode(str,"UTF-8"));//待完善
                ctx.addZuulRequestHeader(SecurityConstants.USER_REAL_NAME,URLEncoder.encode(str,"UTF-8"));
                ctx.addZuulRequestHeader(SecurityConstants.USER_HOSPITAL_ID_HEADER,hospital.toString());
                tenantId=hospital.toString();
                List<SysOrganization> organizations = (List<SysOrganization>) user.getOrganizations();
                //将组织数据 存到header 里面
                organizations.sort((e1,e2)->e1.getOrgLevel().compareTo(e2.getOrgLevel()));
                if (organizations != null&&organizations.size()>0) {
                    organizations.sort((e1,e2)->e1.getOrgLevel().compareTo(e2.getOrgLevel()));
                    ctx.addZuulRequestHeader(SecurityConstants.USER_ORG_ID_HEADER,String.valueOf(organizations.get(0).getId()));
                    ctx.addZuulRequestHeader(SecurityConstants.USER_ORG_NAME_HEADER, URLEncoder.encode(organizations.get(0).getOrgName(),"UTF-8"));
                    ctx.addZuulRequestHeader(SecurityConstants.USER_DEP_ID_HEADER,String.valueOf(departmentId));
                    ctx.addZuulRequestHeader(SecurityConstants.USER_DEP_NAME_HEADER,(departmentName.equals("")?URLEncoder.encode(organizations.get(organizations.size()-1).getOrgName(),"UTF-8"):departmentName));
                    ctx.addZuulRequestHeader(SecurityConstants.USER_ORGS_HEADER,JSON.toJSONString(organizations));
                }
                //将角色放到header