mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 05:42:06 +08:00
1.修改数据源标识的获取途径,由原先从前端传递,到从网关统一传递
This commit is contained in:
+1
@@ -26,6 +26,7 @@ public interface GlobalErrorCodeConstants {
|
||||
ErrorCode LOCKED = new ErrorCode(423, "请求失败,请稍后重试"); // 并发请求,不允许
|
||||
ErrorCode TOO_MANY_REQUESTS = new ErrorCode(429, "请求过于频繁,请稍后重试");
|
||||
ErrorCode DATA_SOURCE_CODE_NOT_FOUND = new ErrorCode(430, "未传递数据源标识");
|
||||
ErrorCode ORGAN_ID_NOT_FOUND = new ErrorCode(431, "未传组织标识");
|
||||
|
||||
// ========== 服务端错误段 ==========
|
||||
|
||||
|
||||
+4
-4
@@ -19,7 +19,7 @@ import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConsta
|
||||
*/
|
||||
public class DataSourceFilter extends OncePerRequestFilter {
|
||||
//数据源编码
|
||||
private static final String DATA_SOURCE_CODE = "dataCode";
|
||||
private static final String DATA_SOURCE_CODE = "data-code";
|
||||
|
||||
private WebProperties webProperties;
|
||||
|
||||
@@ -36,12 +36,12 @@ public class DataSourceFilter extends OncePerRequestFilter {
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||
String dataSourceCode = request.getHeader(DATA_SOURCE_CODE);
|
||||
if(StrUtil.isBlank(dataSourceCode)) {
|
||||
String dataCode = request.getHeader(DATA_SOURCE_CODE);
|
||||
if(StrUtil.isEmpty(dataCode)) {
|
||||
ServletUtils.writeJSON(response, CommonResult.error(DATA_SOURCE_CODE_NOT_FOUND));
|
||||
return;
|
||||
}
|
||||
DynamicDataSourceContextHolder.push(dataSourceCode);
|
||||
DynamicDataSourceContextHolder.push(dataCode);
|
||||
filterChain.doFilter(request, response);
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user