| | |
| | | response.getWriter().write("{\"message\":\"401:找不到院区编号\"}"); |
| | | return false; |
| | | } |
| | | DataSourceContextHolder.setDataSourceKey("default"); |
| | | LambdaQueryWrapper<DictHosp> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(DictHosp::getCode,hospId); |
| | | DictHosp hosp = dictHospService.getOne(wrapper); |
| | | if (hosp == null || hosp.getDatabase() == null || hosp.getDatabase().trim().isEmpty()) { |
| | | response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); |
| | | response.setContentType("application/json;charset=UTF-8"); |
| | | response.getWriter().write("{\"message\":\"401:找不到院区数据\"}"); |
| | | // DictHosp hosp = null; |
| | | try { |
| | | DataSourceContextHolder.setDataSourceKey("default"); |
| | | LambdaQueryWrapper<DictHosp> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(DictHosp::getCode,hospId); |
| | | DictHosp hosp = dictHospService.getOne(wrapper); |
| | | if (hosp == null || hosp.getDbname() == null || hosp.getDbname().trim().isEmpty()) { |
| | | response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); |
| | | response.setContentType("application/json;charset=UTF-8"); |
| | | response.getWriter().write("{\"message\":\"401:找不到院区数据\"}"); |
| | | return false; |
| | | } |
| | | dataSourceConfig.addDataSource(hosp.getDbname()); |
| | | DataSourceContextHolder.setDataSourceKey(hosp.getDbname()); |
| | | } catch (IOException e) { |
| | | return false; |
| | | } |
| | | dataSourceConfig.addDataSource(hosp.getDatabase()); |
| | | DataSourceContextHolder.setDataSourceKey(hosp.getDatabase()); |
| | | |
| | | return true; |
| | | } |
| | | |