增加feign客户端调用排除 tenant的注解。
修改完善诊断记录查看的细节问题
9 files modified
3 files added
| | |
| | | package com.kidgrow.oprationcenter.vo; |
| | | |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | |
| | | import java.util.Date; |
| | | |
| | |
| | | /** |
| | | *诊断门诊名称 |
| | | */ |
| | | private String diagnostictDepartName; |
| | | private String diagnosticDepartName; |
| | | /** |
| | | *诊断医生名称 |
| | | */ |
| | |
| | | */ |
| | | private String childPhone; |
| | | /** |
| | | * 诊断时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date diagnosticDiagnoseTime; |
| | | /** |
| | | * 诊断创建时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss") |
| | | private Date createTime; |
| | | /** |
| | | * 诊断更新时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss") |
| | | private Date updateTime; |
| | | } |
| | |
| | | package com.kidgrow; |
| | | |
| | | import com.kidgrow.ribbon.annotation.EnableFeignInterceptor; |
| | | import com.kidgrow.ribbon.annotation.EnableFeignTenantInterceptor; |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
| | |
| | | @SpringBootApplication |
| | | @EnableFeignClients |
| | | @EnableDiscoveryClient |
| | | @EnableFeignInterceptor |
| | | @EnableFeignTenantInterceptor |
| | | public class OprationCenterApplication { |
| | | public static void main(String[] args) { |
| | | SpringApplication.run(OprationCenterApplication.class,args); |
| | |
| | | params.put("page", 1); |
| | | params.put("limit", 10); |
| | | } |
| | | if(params.get("diagnosticHospitalId").toString().isEmpty()) |
| | | if(params.get("diagnosticHospitalId")==null) |
| | | return PageResult.<ProductOrderJoinDetail>builder().data(null).code(0).count(0L).build(); |
| | | return productOrderDetailService.findAllDataList(params); |
| | | } |
| | |
| | | if (sysUserOrg.getId().equals(userOrgList.get(i).getId())) { |
| | | userOrgList.get(i).setOrgId(sysUserOrg.getOrgId()); |
| | | } |
| | | else |
| | | { |
| | | userOrgList.get(i).setOrgId(sysUserOrg.getUpdateUserId()); |
| | | } |
| | | userOrgList.get(i).setEnabled(sysUserOrg.getEnabled()); |
| | | userOrgList.get(i).setCreateUserOrgCode(createUserOrgCode); |
| | | } |
| | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @Description: 开启feign拦截器传递数据给下游服务,包含基础数据和http的相关数据 |
| | | * @Description: 开启feign拦截器传递数据给下游服务,包含基础数据,tenant信息和http的相关数据 |
| | | * @Project: <br> |
| | | * @CreateDate: Created in 2020/2/21 13:31 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
New file |
| | |
| | | package com.kidgrow.ribbon.annotation; |
| | | |
| | | import com.kidgrow.ribbon.config.FeignHttpTenantInterceptorConfig; |
| | | import com.kidgrow.ribbon.config.FeignTenantInterceptorConfig; |
| | | import org.springframework.context.annotation.Import; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @Description: 开启feign拦截器传递数据给下游服务,包含基础数据和http的相关数据,不含tenant |
| | | * @Project: <br> |
| | | * @CreateDate: Created in 2020/2/21 13:31 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">houruijun</a> |
| | | */ |
| | | @Target(ElementType.TYPE) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Import({FeignTenantInterceptorConfig.class, FeignHttpTenantInterceptorConfig.class}) |
| | | public @interface EnableFeignTenantInterceptor { |
| | | |
| | | } |
New file |
| | |
| | | package com.kidgrow.ribbon.config; |
| | | |
| | | import com.kidgrow.common.constant.CommonConstant; |
| | | import com.kidgrow.common.constant.SecurityConstants; |
| | | import feign.RequestInterceptor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.Enumeration; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @Description: feign拦截器,只包含http相关数据 |
| | | * @Project: <br> |
| | | * @CreateDate: Created in 2020/2/21 13:31 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | */ |
| | | @Slf4j |
| | | public class FeignHttpTenantInterceptorConfig { |
| | | protected List<String> requestHeaders = new ArrayList<>(); |
| | | |
| | | @PostConstruct |
| | | public void initialize() { |
| | | requestHeaders.add(SecurityConstants.USER_ID_HEADER); |
| | | requestHeaders.add(SecurityConstants.USER_HEADER); |
| | | requestHeaders.add(SecurityConstants.USER_DEP_ID_HEADER); |
| | | requestHeaders.add(SecurityConstants.USER_DEP_NAME_HEADER); |
| | | requestHeaders.add(SecurityConstants.USER_ORG_ID_HEADER); |
| | | requestHeaders.add(SecurityConstants.USER_ORGS_HEADER); |
| | | requestHeaders.add(SecurityConstants.USER_ORG_NAME_HEADER); |
| | | requestHeaders.add(SecurityConstants.ROLE_HEADER); |
| | | requestHeaders.add(SecurityConstants.CLIENT_HEADER); |
| | | //requestHeaders.add(SecurityConstants.TENANT_HEADER); |
| | | requestHeaders.add(CommonConstant.KIDGROW_VERSION); |
| | | requestHeaders.add(CommonConstant.USER_AGENT_BROWSER); |
| | | requestHeaders.add(CommonConstant.USER_AGENT_IP); |
| | | requestHeaders.add(CommonConstant.USER_AGENT_SYSTEM); |
| | | } |
| | | |
| | | /** |
| | | * 使用feign client访问别的微服务时,将上游传过来的access_token、clientid、tenantid、username、roles等信息放入header传递给下一个服务 |
| | | */ |
| | | @Bean |
| | | public RequestInterceptor httpFeignInterceptor() { |
| | | return template -> { |
| | | ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder |
| | | .getRequestAttributes(); |
| | | if (attributes != null) { |
| | | HttpServletRequest request = attributes.getRequest(); |
| | | Enumeration<String> headerNames = request.getHeaderNames(); |
| | | if (headerNames != null) { |
| | | String headerName; |
| | | String headerValue; |
| | | while(headerNames.hasMoreElements()) { |
| | | headerName = headerNames.nextElement(); |
| | | if (requestHeaders.contains(headerName)) { |
| | | headerValue = request.getHeader(headerName); |
| | | template.header(headerName, headerValue); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //传递access_token,无网络隔离时需要传递 |
| | | /* |
| | | String token = extractHeaderToken(request); |
| | | if (StrUtil.isEmpty(token)) { |
| | | token = request.getParameter(CommonConstant.ACCESS_TOKEN); |
| | | } |
| | | if (StrUtil.isNotEmpty(token)) { |
| | | template.header(CommonConstant.TOKEN_HEADER, CommonConstant.BEARER_TYPE + " " + token); |
| | | } |
| | | */ |
| | | } |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * 解析head中的token |
| | | * @param request |
| | | */ |
| | | private String extractHeaderToken(HttpServletRequest request) { |
| | | Enumeration<String> headers = request.getHeaders(CommonConstant.TOKEN_HEADER); |
| | | while (headers.hasMoreElements()) { |
| | | String value = headers.nextElement(); |
| | | if ((value.toLowerCase().startsWith(CommonConstant.BEARER_TYPE))) { |
| | | String authHeaderValue = value.substring(CommonConstant.BEARER_TYPE.length()).trim(); |
| | | int commaIndex = authHeaderValue.indexOf(','); |
| | | if (commaIndex > 0) { |
| | | authHeaderValue = authHeaderValue.substring(0, commaIndex); |
| | | } |
| | | return authHeaderValue; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | |
| | | */ |
| | | public class FeignInterceptorConfig { |
| | | /** |
| | | * 使用feign client访问别的微服务时,将上游传过来的client、tenant、traceid等信息放入header传递给下一个服务 |
| | | * 使用feign client访问别的微服务时,将上游传过来的client、traceid等信息放入header传递给下一个服务 |
| | | */ |
| | | @Bean |
| | | public RequestInterceptor baseFeignInterceptor() { |
New file |
| | |
| | | package com.kidgrow.ribbon.config; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.kidgrow.common.constant.CommonConstant; |
| | | import com.kidgrow.common.constant.SecurityConstants; |
| | | import com.kidgrow.common.context.ClientContextHolder; |
| | | import feign.RequestInterceptor; |
| | | import org.slf4j.MDC; |
| | | import org.springframework.context.annotation.Bean; |
| | | |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @Description: feign拦截器,只包含基础数据 |
| | | * @Project: <br> |
| | | * @CreateDate: Created in 2020/2/21 13:31 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | */ |
| | | public class FeignTenantInterceptorConfig { |
| | | /** |
| | | * 使用feign client访问别的微服务时,将上游传过来的client、traceid等信息放入header传递给下一个服务 |
| | | */ |
| | | @Bean |
| | | public RequestInterceptor baseFeignInterceptor() { |
| | | return template -> { |
| | | //传递client |
| | | String client = ClientContextHolder.getClient(); |
| | | if (StrUtil.isNotEmpty(client)) { |
| | | template.header(SecurityConstants.CLIENT_HEADER, client); |
| | | } |
| | | |
| | | // //传递tenant |
| | | // String tenant = TenantContextHolder.getTenant(); |
| | | // if (StrUtil.isNotEmpty(tenant)) { |
| | | // template.header(SecurityConstants.TENANT_HEADER, tenant); |
| | | // } |
| | | |
| | | //传递日志traceId |
| | | String traceId = MDC.get(CommonConstant.LOG_TRACE_ID); |
| | | if (StrUtil.isNotEmpty(traceId)) { |
| | | template.header(CommonConstant.TRACE_ID_HEADER, traceId); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | headers: { 'Authorization': 'Bearer ' + config.getToken().access_token }, |
| | | page: true, |
| | | cols: [[ |
| | | { field: 'hospitalName', width: 300, title: '医院名称' }, |
| | | { field: 'departmentName', width: 100, title: '科室名称' }, |
| | | { field: 'diagnosticHospitalName', width: 300, title: '医院名称' }, |
| | | { field: 'diagnosticDepartName', width: 100, title: '科室名称' }, |
| | | { field: 'diagnosticDoctorName', width: 100, title: '医生姓名' }, |
| | | { field: 'childName', width: 100, title: '患者姓名' }, |
| | | { field: 'childSex', width: 80, title: '性别' }, |
| | | { field: 'childBirthday', width: 100, title: '出生日期' }, |
| | | { field: 'childBirthday', width: 120, title: '出生日期',templet:function(d){ |
| | | return new Date(d.createTime).dateFormat("yyyy/MM/dd"); |
| | | }}, |
| | | { field: 'childPhone', width: 150, title: '联系电话' }, |
| | | { |
| | | field: 'isDelete', sort: true, align: 'center', width: 80, templet: function (d) { |
| | | field: 'isDelete', sort: true, align: 'center', width: 100, templet: function (d) { |
| | | if (d.proType === 0) |
| | | return "正常" |
| | | else |
| | |
| | | }, title: '状态' |
| | | }, |
| | | { |
| | | field: 'createTime', width: 160, sort: true, title: '创建时间', templet: function (d) { |
| | | field: 'createTime', width: 170, sort: true, title: '创建时间', templet: function (d) { |
| | | return new Date(d.createTime).dateFormat("yyyy/MM/dd hh:mm:ss"); |
| | | } |
| | | },{ |
| | | field: 'diagnosticDiagnoseTime', width: 120, sort: true, title: '诊断时间', templet: function (d) { |
| | | return new Date(d.diagnosticDiagnoseTime).dateFormat("yyyy/MM/dd"); |
| | | } |
| | | }, |
| | | { |
| | | field: 'updateTime', width: 160, sort: true, title: '修改时间', templet: function (d) { |
| | | field: 'updateTime', width: 170, sort: true, title: '修改时间', templet: function (d) { |
| | | return new Date(d.createTime).dateFormat("yyyy/MM/dd hh:mm:ss"); |
| | | } |
| | | }, |
| | |
| | | { |
| | | //诊断记录ID |
| | | var id=diagnosis.diagnosticId; |
| | | |
| | | } |
| | | }); |
| | | </script> |
| | |
| | | data.field.enabled = (data.field.enabled == 0) ? false : true; |
| | | admin.req('api-user/sysuserorg', JSON.stringify(data.field), function (data) { |
| | | layer.closeAll('loading'); |
| | | debugger |
| | | if (data.code == 0) { |
| | | layer.msg(data.msg, { icon: 1, time: 1000 }); |
| | | admin.finishPopupCenter(); |