feat():完善故障报警
parent
fabd5e0d5e
commit
65494efb9c
|
@ -37,9 +37,9 @@ public class ManyDataSource {
|
||||||
DruidDataSourceFactory druidDataSourceFactory= SpringUtils.getBean(DruidDataSourceFactory.class);
|
DruidDataSourceFactory druidDataSourceFactory= SpringUtils.getBean(DruidDataSourceFactory.class);
|
||||||
DynamicDataSource dynamicDataSource= SpringUtils.getBean(DynamicDataSource.class);
|
DynamicDataSource dynamicDataSource= SpringUtils.getBean(DynamicDataSource.class);
|
||||||
EnterPriseInfo enterPriseInfo = EnterPriseInfo.builder()
|
EnterPriseInfo enterPriseInfo = EnterPriseInfo.builder()
|
||||||
.entCode("jiang_0530")
|
.entCode("jiang_15")
|
||||||
.ip("101.34.248.9")
|
.ip("101.34.248.9")
|
||||||
.port(3308)
|
.port(3321)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(enterPriseInfo.getEntCode(), enterPriseInfo.getIp(), enterPriseInfo.getPort());
|
DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(enterPriseInfo.getEntCode(), enterPriseInfo.getIp(), enterPriseInfo.getPort());
|
||||||
|
@ -53,9 +53,9 @@ public class ManyDataSource {
|
||||||
List<EnterPriseInfo> list = new ArrayList<>();
|
List<EnterPriseInfo> list = new ArrayList<>();
|
||||||
list.add(
|
list.add(
|
||||||
EnterPriseInfo.builder()
|
EnterPriseInfo.builder()
|
||||||
.entCode("jiang_0612")
|
.entCode("jiang_14")
|
||||||
.ip("101.34.248.9")
|
.ip("101.34.248.9")
|
||||||
.port(3309)
|
.port(3320)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
return list;
|
return list;
|
||||||
|
|
|
@ -7,7 +7,7 @@ package com.muyu.cloud.many.datasource.config.contents;
|
||||||
*/
|
*/
|
||||||
public class DatasourceContent {
|
public class DatasourceContent {
|
||||||
|
|
||||||
public final static String DATASOURCE_URL = "jdbc:mysql://{}:{}/etltest?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
|
public final static String DATASOURCE_URL = "jdbc:mysql://{}:{}/vehicle?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
|
||||||
|
|
||||||
public final static String USER_NAME = "root";
|
public final static String USER_NAME = "root";
|
||||||
|
|
||||||
|
|
|
@ -1,53 +1,53 @@
|
||||||
package com.muyu.cloud.many.datasource.config.interceptor;
|
//package com.muyu.cloud.many.datasource.config.interceptor;
|
||||||
|
//
|
||||||
import com.muyu.cloud.many.datasource.config.contents.SaaSConstant;
|
//import com.muyu.cloud.many.datasource.config.contents.SaaSConstant;
|
||||||
import com.muyu.cloud.many.datasource.config.exception.SaaSException;
|
//import com.muyu.cloud.many.datasource.config.exception.SaaSException;
|
||||||
import com.muyu.cloud.many.datasource.config.holder.DynamicDataSourceHolder;
|
//import com.muyu.cloud.many.datasource.config.holder.DynamicDataSourceHolder;
|
||||||
import com.muyu.cloud.many.datasource.config.role.DynamicDataSource;
|
//import com.muyu.cloud.many.datasource.config.role.DynamicDataSource;
|
||||||
import com.muyu.common.core.utils.ServletUtils;
|
//import com.muyu.common.core.utils.ServletUtils;
|
||||||
import com.muyu.common.core.utils.SpringUtils;
|
//import com.muyu.common.core.utils.SpringUtils;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
//import org.springframework.web.method.HandlerMethod;
|
||||||
import org.springframework.web.servlet.AsyncHandlerInterceptor;
|
//import org.springframework.web.servlet.AsyncHandlerInterceptor;
|
||||||
|
//
|
||||||
import javax.servlet.http.HttpServletRequest;
|
//import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
//import javax.servlet.http.HttpServletResponse;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* SaaS拦截器 SaaSInterceptor
|
// * SaaS拦截器 SaaSInterceptor
|
||||||
*
|
// *
|
||||||
* Date 2024/6/4 14:39
|
// * Date 2024/6/4 14:39
|
||||||
*/
|
// */
|
||||||
public class SaaSInterceptor implements AsyncHandlerInterceptor {
|
//public class SaaSInterceptor implements AsyncHandlerInterceptor {
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 之前
|
// * 之前
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
// public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
if (!(handler instanceof HandlerMethod)){
|
// if (!(handler instanceof HandlerMethod)){
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
String SaasKey = ServletUtils.getHeader(request, SaaSConstant.SAAS_KEY);
|
// String SaasKey = ServletUtils.getHeader(request, SaaSConstant.SAAS_KEY);
|
||||||
|
//
|
||||||
if (SaasKey==null){
|
// if (SaasKey==null){
|
||||||
throw new SaaSException("SaaS非法访问");
|
// throw new SaaSException("SaaS非法访问");
|
||||||
} else {
|
// } else {
|
||||||
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
|
// DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
|
||||||
if (!dynamicDataSource.hashKye(SaasKey)){
|
// if (!dynamicDataSource.hashKye(SaasKey)){
|
||||||
throw new SaaSException("SaaS非法访问");
|
// throw new SaaSException("SaaS非法访问");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
DynamicDataSourceHolder.setDynamicDataSourceKey(SaasKey);
|
// DynamicDataSourceHolder.setDynamicDataSourceKey(SaasKey);
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 之后
|
// * 之后
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
// public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
DynamicDataSourceHolder.removeDynamicDataSourceKey();
|
// DynamicDataSourceHolder.removeDynamicDataSourceKey();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
package com.muyu.cloud.many.datasource.config.interceptor;
|
//package com.muyu.cloud.many.datasource.config.interceptor;
|
||||||
|
//
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 拦截器配置
|
// * 拦截器配置
|
||||||
*
|
// *
|
||||||
* @author muyu
|
//// * @author muyua
|
||||||
*/
|
// */
|
||||||
public class WebMvcSaaSConfig implements WebMvcConfigurer {
|
//public class WebMvcSaaSConfig implements WebMvcConfigurer {
|
||||||
/**
|
// /**
|
||||||
* 不需要拦截地址
|
// * 不需要拦截地址
|
||||||
*/
|
// */
|
||||||
public static final String[] excludeUrls = {"/login", "/logout", "/refresh"};
|
// public static final String[] excludeUrls = {"/login", "/logout", "/refresh"};
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void addInterceptors (InterceptorRegistry registry) {
|
// public void addInterceptors (InterceptorRegistry registry) {
|
||||||
registry.addInterceptor(getHeaderInterceptor())
|
// registry.addInterceptor(getHeaderInterceptor())
|
||||||
.addPathPatterns("/**")
|
// .addPathPatterns("/**")
|
||||||
.excludePathPatterns(excludeUrls)
|
// .excludePathPatterns(excludeUrls)
|
||||||
.order(-10);
|
// .order(-10);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 自定义请求头拦截器
|
// * 自定义请求头拦截器
|
||||||
*/
|
// */
|
||||||
public SaaSInterceptor getHeaderInterceptor () {
|
// public SaaSInterceptor getHeaderInterceptor () {
|
||||||
return new SaaSInterceptor();
|
// return new SaaSInterceptor();
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
com.muyu.cloud.many.datasource.config.interceptor.WebMvcSaaSConfig
|
com.muyu.cloud.many.datasource.config.domain.model.EnterPriseInfo
|
||||||
|
com.muyu.cloud.many.datasource.config.factory.DruidDataSourceFactory
|
||||||
|
com.muyu.cloud.many.datasource.config.ManyDataSource
|
||||||
|
|
|
@ -94,11 +94,6 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>muyu-common-swagger</artifactId>
|
<artifactId>muyu-common-swagger</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.amqp</groupId>
|
|
||||||
<artifactId>spring-amqp</artifactId>
|
|
||||||
<version>2.4.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class FaultCodeController extends BaseController {
|
||||||
* 查询车辆故障码列表
|
* 查询车辆故障码列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取车辆故障码列表")
|
@ApiOperation("获取车辆故障码列表")
|
||||||
@RequiresPermissions("customerBusiness:faultCode:list")
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<TableDataInfo<FaultCode>> list(FaultCodeQueryReq faultCodeQueryReq) {
|
public Result<TableDataInfo<FaultCode>> list(FaultCodeQueryReq faultCodeQueryReq) {
|
||||||
startPage();
|
startPage();
|
||||||
|
@ -55,7 +55,6 @@ public class FaultCodeController extends BaseController {
|
||||||
* 导出车辆故障码列表
|
* 导出车辆故障码列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("导出车辆故障码列表")
|
@ApiOperation("导出车辆故障码列表")
|
||||||
@RequiresPermissions("customerBusiness:faultCode:export")
|
|
||||||
@Log(title = "车辆故障码", businessType = BusinessType.EXPORT)
|
@Log(title = "车辆故障码", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, FaultCode faultCode) {
|
public void export(HttpServletResponse response, FaultCode faultCode) {
|
||||||
|
@ -68,7 +67,6 @@ public class FaultCodeController extends BaseController {
|
||||||
* 获取车辆故障码详细信息
|
* 获取车辆故障码详细信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取车辆故障码详细信息")
|
@ApiOperation("获取车辆故障码详细信息")
|
||||||
@RequiresPermissions("customerBusiness:faultCode:query")
|
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||||
public Result<FaultCode> getInfo(@PathVariable("id") Long id) {
|
public Result<FaultCode> getInfo(@PathVariable("id") Long id) {
|
||||||
|
@ -78,7 +76,7 @@ public class FaultCodeController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 新增车辆故障码
|
* 新增车辆故障码
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("customerBusiness:faultCode:add")
|
|
||||||
@Log(title = "车辆故障码", businessType = BusinessType.INSERT)
|
@Log(title = "车辆故障码", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("新增车辆故障码")
|
@ApiOperation("新增车辆故障码")
|
||||||
|
@ -89,7 +87,7 @@ public class FaultCodeController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 修改车辆故障码
|
* 修改车辆故障码
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("customerBusiness:faultCode:edit")
|
|
||||||
@Log(title = "车辆故障码", businessType = BusinessType.UPDATE)
|
@Log(title = "车辆故障码", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
@ApiOperation("修改车辆故障码")
|
@ApiOperation("修改车辆故障码")
|
||||||
|
@ -100,7 +98,7 @@ public class FaultCodeController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 删除车辆故障码
|
* 删除车辆故障码
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("customerBusiness:faultCode:remove")
|
|
||||||
@Log(title = "车辆故障码", businessType = BusinessType.DELETE)
|
@Log(title = "车辆故障码", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
@ApiOperation("删除车辆故障码")
|
@ApiOperation("删除车辆故障码")
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class FaultRecordController extends BaseController {
|
||||||
* 查询故障记录列表
|
* 查询故障记录列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取故障记录列表")
|
@ApiOperation("获取故障记录列表")
|
||||||
@RequiresPermissions("customerBusiness:faultRecord:list")
|
// @RequiresPermissions("customerBusiness:faultRecord:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<TableDataInfo<FaultRecord>> list(FaultRecordQueryReq faultRecordQueryReq) {
|
public Result<TableDataInfo<FaultRecord>> list(FaultRecordQueryReq faultRecordQueryReq) {
|
||||||
startPage();
|
startPage();
|
||||||
|
@ -52,7 +52,7 @@ public class FaultRecordController extends BaseController {
|
||||||
* 导出故障记录列表
|
* 导出故障记录列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("导出故障记录列表")
|
@ApiOperation("导出故障记录列表")
|
||||||
@RequiresPermissions("customerBusiness:faultRecord:export")
|
|
||||||
@Log(title = "故障记录", businessType = BusinessType.EXPORT)
|
@Log(title = "故障记录", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, FaultRecord faultRecord) {
|
public void export(HttpServletResponse response, FaultRecord faultRecord) {
|
||||||
|
@ -65,7 +65,7 @@ public class FaultRecordController extends BaseController {
|
||||||
* 获取故障记录详细信息
|
* 获取故障记录详细信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取故障记录详细信息")
|
@ApiOperation("获取故障记录详细信息")
|
||||||
@RequiresPermissions("customerBusiness:faultRecord:query")
|
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||||
public Result<FaultRecord> getInfo(@PathVariable("id") Long id) {
|
public Result<FaultRecord> getInfo(@PathVariable("id") Long id) {
|
||||||
|
@ -75,7 +75,7 @@ public class FaultRecordController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 新增故障记录
|
* 新增故障记录
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("customerBusiness:faultRecord:add")
|
|
||||||
@Log(title = "故障记录", businessType = BusinessType.INSERT)
|
@Log(title = "故障记录", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("新增故障记录")
|
@ApiOperation("新增故障记录")
|
||||||
|
@ -86,7 +86,7 @@ public class FaultRecordController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 修改故障记录
|
* 修改故障记录
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("customerBusiness:faultRecord:edit")
|
|
||||||
@Log(title = "故障记录", businessType = BusinessType.UPDATE)
|
@Log(title = "故障记录", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
@ApiOperation("修改故障记录")
|
@ApiOperation("修改故障记录")
|
||||||
|
@ -97,7 +97,7 @@ public class FaultRecordController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 删除故障记录
|
* 删除故障记录
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("customerBusiness:faultRecord:remove")
|
|
||||||
@Log(title = "故障记录", businessType = BusinessType.DELETE)
|
@Log(title = "故障记录", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
@ApiOperation("删除故障记录")
|
@ApiOperation("删除故障记录")
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class FenceController extends BaseController {
|
||||||
* 查询电子围栏列表
|
* 查询电子围栏列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取电子围栏列表")
|
@ApiOperation("获取电子围栏列表")
|
||||||
@RequiresPermissions("customerBusiness:fence:list")
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<TableDataInfo<Fence>> list(FenceQueryReq fenceQueryReq) {
|
public Result<TableDataInfo<Fence>> list(FenceQueryReq fenceQueryReq) {
|
||||||
startPage();
|
startPage();
|
||||||
|
@ -55,7 +55,7 @@ public class FenceController extends BaseController {
|
||||||
* 导出电子围栏列表
|
* 导出电子围栏列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("导出电子围栏列表")
|
@ApiOperation("导出电子围栏列表")
|
||||||
@RequiresPermissions("customerBusiness:fence:export")
|
|
||||||
@Log(title = "电子围栏", businessType = BusinessType.EXPORT)
|
@Log(title = "电子围栏", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, Fence fence) {
|
public void export(HttpServletResponse response, Fence fence) {
|
||||||
|
@ -68,7 +68,6 @@ public class FenceController extends BaseController {
|
||||||
* 获取电子围栏详细信息
|
* 获取电子围栏详细信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取电子围栏详细信息")
|
@ApiOperation("获取电子围栏详细信息")
|
||||||
@RequiresPermissions("customerBusiness:fence:query")
|
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||||
public Result<Fence> getInfo(@PathVariable("id") Long id) {
|
public Result<Fence> getInfo(@PathVariable("id") Long id) {
|
||||||
|
@ -78,7 +77,7 @@ public class FenceController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 新增电子围栏
|
* 新增电子围栏
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("customerBusiness:fence:add")
|
|
||||||
@Log(title = "电子围栏", businessType = BusinessType.INSERT)
|
@Log(title = "电子围栏", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("新增电子围栏")
|
@ApiOperation("新增电子围栏")
|
||||||
|
@ -89,7 +88,7 @@ public class FenceController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 修改电子围栏
|
* 修改电子围栏
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("customerBusiness:fence:edit")
|
|
||||||
@Log(title = "电子围栏", businessType = BusinessType.UPDATE)
|
@Log(title = "电子围栏", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
@ApiOperation("修改电子围栏")
|
@ApiOperation("修改电子围栏")
|
||||||
|
@ -100,7 +99,7 @@ public class FenceController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 删除电子围栏
|
* 删除电子围栏
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("customerBusiness:fence:remove")
|
|
||||||
@Log(title = "电子围栏", businessType = BusinessType.DELETE)
|
@Log(title = "电子围栏", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
@ApiOperation("删除电子围栏")
|
@ApiOperation("删除电子围栏")
|
||||||
|
|
|
@ -48,7 +48,6 @@ public class VehicleController extends BaseController {
|
||||||
* 查询车辆录入列表
|
* 查询车辆录入列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取车辆录入列表")
|
@ApiOperation("获取车辆录入列表")
|
||||||
@RequiresPermissions("customerBusiness:vehicle:list")
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<TableDataInfo<Vehicle>> list(VehicleQueryReq vehicleQueryReq) {
|
public Result<TableDataInfo<Vehicle>> list(VehicleQueryReq vehicleQueryReq) {
|
||||||
startPage();
|
startPage();
|
||||||
|
@ -60,7 +59,7 @@ public class VehicleController extends BaseController {
|
||||||
* 导出车辆录入列表
|
* 导出车辆录入列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("导出车辆录入列表")
|
@ApiOperation("导出车辆录入列表")
|
||||||
@RequiresPermissions("customerBusiness:vehicle:export")
|
|
||||||
@Log(title = "车辆录入", businessType = BusinessType.EXPORT)
|
@Log(title = "车辆录入", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, Vehicle vehicle) {
|
public void export(HttpServletResponse response, Vehicle vehicle) {
|
||||||
|
@ -73,7 +72,7 @@ public class VehicleController extends BaseController {
|
||||||
* 获取车辆录入详细信息
|
* 获取车辆录入详细信息
|
||||||
*/
|
*/
|
||||||
@ApiOperation("获取车辆录入详细信息")
|
@ApiOperation("获取车辆录入详细信息")
|
||||||
@RequiresPermissions("customerBusiness:vehicle:query")
|
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||||
public Result<Vehicle> getInfo(@PathVariable("id") Long id) {
|
public Result<Vehicle> getInfo(@PathVariable("id") Long id) {
|
||||||
|
@ -83,7 +82,7 @@ public class VehicleController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 新增车辆录入
|
* 新增车辆录入
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("customerBusiness:vehicle:add")
|
|
||||||
@Log(title = "车辆录入", businessType = BusinessType.INSERT)
|
@Log(title = "车辆录入", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("新增车辆录入")
|
@ApiOperation("新增车辆录入")
|
||||||
|
@ -94,7 +93,7 @@ public class VehicleController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 修改车辆录入
|
* 修改车辆录入
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("customerBusiness:vehicle:edit")
|
|
||||||
@Log(title = "车辆录入", businessType = BusinessType.UPDATE)
|
@Log(title = "车辆录入", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
@ApiOperation("修改车辆录入")
|
@ApiOperation("修改车辆录入")
|
||||||
|
@ -105,7 +104,7 @@ public class VehicleController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 删除车辆录入
|
* 删除车辆录入
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("customerBusiness:vehicle:remove")
|
|
||||||
@Log(title = "车辆录入", businessType = BusinessType.DELETE)
|
@Log(title = "车辆录入", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
@ApiOperation("删除车辆录入")
|
@ApiOperation("删除车辆录入")
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.muyu.customer.business.saas.contents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 数据源常量
|
||||||
|
* @Date 2023-8-1 上午 11:02
|
||||||
|
*/
|
||||||
|
public class DatasourceContent {
|
||||||
|
|
||||||
|
public final static String DATASOURCE_URL = "jdbc:mysql://{}:{}/vehicle_networking?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
|
||||||
|
|
||||||
|
public final static String USER_NAME = "root";
|
||||||
|
|
||||||
|
public final static String PASSWORD = "L041120D";
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.muyu.customer.business.saas.contents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SaaS常量 SaaSConstant
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* Date 2024/6/4 18:34
|
||||||
|
*/
|
||||||
|
public class SaaSConstant {
|
||||||
|
|
||||||
|
public final static String SAAS_KEY="enterprise-code";
|
||||||
|
}
|
|
@ -0,0 +1,121 @@
|
||||||
|
package com.muyu.customer.business.saas.datasource;
|
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.muyu.common.core.utils.SpringUtils;
|
||||||
|
|
||||||
|
import com.muyu.common.redis.service.RedisService;
|
||||||
|
import com.muyu.customer.business.saas.domain.model.EnterPriseInfo;
|
||||||
|
import com.muyu.customer.business.saas.factory.DruidDataSourceFactory;
|
||||||
|
import com.muyu.customer.business.saas.domain.model.DataSourceInfo;
|
||||||
|
import com.muyu.customer.business.saas.role.DynamicDataSource;
|
||||||
|
import com.rabbitmq.client.Channel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.amqp.core.Message;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多数据源 ManyDataSource
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* Date 2024/6/3 20:01
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Log4j2
|
||||||
|
@AutoConfigureBefore(RedisService.class)
|
||||||
|
public class ManyDataSource {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate<String,String> redisTemplate;
|
||||||
|
|
||||||
|
// @Autowired
|
||||||
|
// private RemoteBusinessService remoteBusinessService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
@RabbitListener(queuesToDeclare = {@Queue(name = "smsConfig")})
|
||||||
|
public void smsConfig(String msg, Message message, Channel channel){
|
||||||
|
//获取消息的ID
|
||||||
|
String messageId = message.getMessageProperties().getMessageId();
|
||||||
|
try {
|
||||||
|
//添加消息id到redis set集合中 添加成功返回1 表示未消费 添加失败返回0 表示已消费
|
||||||
|
Long count = redisTemplate.opsForSet().add("messageId", messageId);
|
||||||
|
//添加成功 正常消费信息
|
||||||
|
if (count == 1) {
|
||||||
|
log.info("开始消费");
|
||||||
|
druidData(msg);
|
||||||
|
//确认消费
|
||||||
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
||||||
|
log.info("消费成功");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("消费失败,尝试重连");
|
||||||
|
try {
|
||||||
|
//回退消息,尝试重连
|
||||||
|
druidData(msg);
|
||||||
|
channel.basicReject(message.getMessageProperties().getDeliveryTag(),false);
|
||||||
|
log.info("消费失败");
|
||||||
|
} catch (IOException ex) {
|
||||||
|
//回退失败
|
||||||
|
log.info("消费异常");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void druidData(String msg) {
|
||||||
|
EnterPriseInfo entInfo= JSON.parseObject(msg, EnterPriseInfo.class);
|
||||||
|
log.info("消息为:{}",entInfo);
|
||||||
|
DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class);
|
||||||
|
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
|
||||||
|
DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(entInfo.getEntCode(), entInfo.getIp(), entInfo.getPort());
|
||||||
|
DruidDataSource druidDataSource = druidDataSourceFactory.create(dataSourceInfo);
|
||||||
|
dynamicDataSource.put(dataSourceInfo.getKey(), druidDataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
private List<EnterPriseInfo> dataSourceInfoList(){
|
||||||
|
List<EnterPriseInfo> list = new ArrayList<>();
|
||||||
|
list.add(
|
||||||
|
EnterPriseInfo.builder()
|
||||||
|
.entCode("jiang_14")
|
||||||
|
.ip("101.34.248.9")
|
||||||
|
.port(3320)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
|
||||||
|
|
||||||
|
//企业列表 企业CODE 端口 ip
|
||||||
|
Map<Object, Object> dataSourceMap = new HashMap<>();
|
||||||
|
dataSourceInfoList()
|
||||||
|
.stream()
|
||||||
|
.map(enterPriseInfo -> DataSourceInfo.hostAndPortBuild(enterPriseInfo.getEntCode(), enterPriseInfo.getIp(),enterPriseInfo.getPort()))
|
||||||
|
.forEach(dataSourceInfo -> {
|
||||||
|
dataSourceMap.put(dataSourceInfo.getKey(), druidDataSourceFactory.create(dataSourceInfo));
|
||||||
|
});
|
||||||
|
//设置动态数据源
|
||||||
|
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
||||||
|
// dynamicDataSource.setDefaultTargetDataSource(masterDataSource());
|
||||||
|
dynamicDataSource.setTargetDataSources(dataSourceMap);
|
||||||
|
//将数据源信息备份在defineTargetDataSources中
|
||||||
|
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
||||||
|
return dynamicDataSource;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.muyu.customer.business.saas.domain.model;
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import com.muyu.customer.business.saas.contents.DatasourceContent;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 数据源实体类
|
||||||
|
* @Date 2023-8-1 上午 11:15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DataSourceInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 键
|
||||||
|
*/
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
|
||||||
|
public static DataSourceInfo hostAndPortBuild(String key,String host, Integer port){
|
||||||
|
return DataSourceInfo.builder()
|
||||||
|
.key(key)
|
||||||
|
.url(StringUtils.format(DatasourceContent.DATASOURCE_URL, host, port,port))
|
||||||
|
.password(DatasourceContent.PASSWORD)
|
||||||
|
.userName(DatasourceContent.USER_NAME)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.muyu.customer.business.saas.domain.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业信息 EnterPriseInfo
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* Date 2024/6/4 08:53
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class EnterPriseInfo {
|
||||||
|
|
||||||
|
private String entCode;
|
||||||
|
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
private Integer port;
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.muyu.customer.business.saas.exception;
|
||||||
|
|
||||||
|
import com.muyu.common.core.exception.ServiceException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SaaS异常类 SaaSException
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* Date 2024/6/4 18:45
|
||||||
|
*/
|
||||||
|
public class SaaSException extends ServiceException {
|
||||||
|
|
||||||
|
public SaaSException(String message, Integer code) {
|
||||||
|
super(message, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SaaSException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SaaSException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.muyu.customer.business.saas.factory;
|
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import com.muyu.customer.business.saas.domain.model.DataSourceInfo;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Druid工厂 DruidDataSourceFactory
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* Date 2024/6/3 20:12
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@Component
|
||||||
|
public class DruidDataSourceFactory {
|
||||||
|
/**
|
||||||
|
* @Description: 根据传递的数据源信息测试数据库连接
|
||||||
|
* @Author Dongzl
|
||||||
|
*/
|
||||||
|
public DruidDataSource create(DataSourceInfo dataSourceInfo) {
|
||||||
|
DruidDataSource druidDataSource = new DruidDataSource();
|
||||||
|
druidDataSource.setUrl(dataSourceInfo.getUrl());
|
||||||
|
druidDataSource.setUsername(dataSourceInfo.getUserName());
|
||||||
|
druidDataSource.setPassword(dataSourceInfo.getPassword());
|
||||||
|
druidDataSource.setBreakAfterAcquireFailure(true);
|
||||||
|
druidDataSource.setConnectionErrorRetryAttempts(0);
|
||||||
|
try {
|
||||||
|
druidDataSource.getConnection(2000);
|
||||||
|
log.info("{} -> 数据源连接成功", dataSourceInfo.getKey());
|
||||||
|
return druidDataSource;
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
log.error("数据源 {} 连接失败,用户名:{},密码 {}",dataSourceInfo.getUrl(),dataSourceInfo.getUserName(),dataSourceInfo.getPassword());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.muyu.customer.business.saas.holder;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据源切换处理
|
||||||
|
*
|
||||||
|
* @author Dongzl
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class DynamicDataSourceHolder {
|
||||||
|
/**
|
||||||
|
* 保存动态数据源名称
|
||||||
|
*/
|
||||||
|
private static final ThreadLocal<String> DYNAMIC_DATASOURCE_KEY = new ThreadLocal<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置/切换数据源,决定当前线程使用哪个数据源
|
||||||
|
*/
|
||||||
|
public static void setDynamicDataSourceKey(String key){
|
||||||
|
log.info("数据源切换为:{}",key);
|
||||||
|
DYNAMIC_DATASOURCE_KEY.set(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取动态数据源名称,默认使用mater数据源
|
||||||
|
*/
|
||||||
|
public static String getDynamicDataSourceKey(){
|
||||||
|
String key = DYNAMIC_DATASOURCE_KEY.get();
|
||||||
|
Assert.notNull(key, "请携带数据标识");
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除当前数据源
|
||||||
|
*/
|
||||||
|
public static void removeDynamicDataSourceKey(){
|
||||||
|
log.info("移除数据源:{}",DYNAMIC_DATASOURCE_KEY.get());
|
||||||
|
DYNAMIC_DATASOURCE_KEY.remove();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.muyu.customer.business.saas.role;
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
|
import com.muyu.customer.business.saas.holder.DynamicDataSourceHolder;
|
||||||
|
import org.aspectj.lang.annotation.After;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Before;
|
||||||
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BingRui.Hou
|
||||||
|
* 数据源切面
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
public class DataSourceAsp {
|
||||||
|
@Lazy
|
||||||
|
@Autowired
|
||||||
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
|
@Pointcut(value = "execution(public * com.muyu.customer.business.controller.*Controller.*(..))")
|
||||||
|
public void pointcut () {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 的每一個方法執行之前 執行的處理
|
||||||
|
*/
|
||||||
|
@Before("pointcut()")
|
||||||
|
public void beforeMethod() {
|
||||||
|
DynamicDataSourceHolder.setDynamicDataSourceKey("jiang"+14);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 的每一個方法執行之后 執行的處理
|
||||||
|
* 无论正常还是异常终了
|
||||||
|
* 不能接受到返回值
|
||||||
|
*/
|
||||||
|
@After("pointcut()")
|
||||||
|
public void afterMethod() {
|
||||||
|
DynamicDataSourceHolder.removeDynamicDataSourceKey();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.muyu.customer.business.saas.role;
|
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import com.muyu.customer.business.saas.holder.DynamicDataSourceHolder;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动态数据源
|
||||||
|
* 调用AddDefineDataSource组件的addDefineDynamicDataSource()方法,获取原来targetdatasources的map,并将新的数据源信息添加到map中,并替换targetdatasources中的map
|
||||||
|
* 切换数据源时可以使用@DataSource(value = "数据源名称"),或者DynamicDataSourceContextHolder.setContextKey("数据源名称")
|
||||||
|
* @author Dongzl
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class DynamicDataSource extends AbstractRoutingDataSource {
|
||||||
|
//备份所有数据源信息,备份的是个 指针!!!
|
||||||
|
private Map<Object, Object> defineTargetDataSources;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判定键是否出站了
|
||||||
|
* @param key 键
|
||||||
|
* @return 存在结束 true 存在 false 不存在
|
||||||
|
*/
|
||||||
|
public boolean hashKye(String key){
|
||||||
|
return defineTargetDataSources.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加数据库
|
||||||
|
* @param key 键
|
||||||
|
* @param value 数据值
|
||||||
|
*/
|
||||||
|
public void put(String key, DruidDataSource value){
|
||||||
|
defineTargetDataSources.put(key,value);
|
||||||
|
this.afterPropertiesSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 决定当前线程使用哪个数据源
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Object determineCurrentLookupKey() {
|
||||||
|
return DynamicDataSourceHolder.getDynamicDataSourceKey();
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,7 @@ spring:
|
||||||
publisher-returns: true
|
publisher-returns: true
|
||||||
main:
|
main:
|
||||||
allow-circular-references: true
|
allow-circular-references: true
|
||||||
|
allow-bean-definition-overriding: true #当遇到同样名字的时候,是否允许覆盖注册
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: muyu-customer-business
|
name: muyu-customer-business
|
||||||
|
|
Loading…
Reference in New Issue