动态数据源垮系统加载
parent
17531927aa
commit
f27d2dcbe9
@ -0,0 +1,29 @@
|
|||||||
|
package com.op.system.api;
|
||||||
|
|
||||||
|
import com.op.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.op.common.core.domain.R;
|
||||||
|
import com.op.system.api.domain.DataSourcePropertyDTO;
|
||||||
|
import com.op.system.api.factory.RemoteWmsFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户服务
|
||||||
|
*
|
||||||
|
* @author OP
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteWmsService", value = ServiceNameConstants.WMS_SERVICE, fallbackFactory = RemoteWmsFallbackFactory.class)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public interface RemoteWmsService {
|
||||||
|
|
||||||
|
@PostMapping("/area/addDatasource")
|
||||||
|
public R addDatasource(@RequestBody DataSourcePropertyDTO dataSourceProperty);
|
||||||
|
|
||||||
|
@PostMapping("/area/removeDatasource")
|
||||||
|
public R removeDatasource(@RequestBody DataSourcePropertyDTO dataSourceProperty);
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
package com.op.system.api.domain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zxl
|
||||||
|
* @date 2024年04月12日 11:57
|
||||||
|
*/
|
||||||
|
public class DataSourcePropertyDTO {
|
||||||
|
private String poolName;
|
||||||
|
private String driverClassName;
|
||||||
|
private String url;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private String jndiName;
|
||||||
|
private Boolean seata = true;
|
||||||
|
private Boolean lazy;
|
||||||
|
|
||||||
|
public String getPoolName() {
|
||||||
|
return poolName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPoolName(String poolName) {
|
||||||
|
this.poolName = poolName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDriverClassName() {
|
||||||
|
return driverClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDriverClassName(String driverClassName) {
|
||||||
|
this.driverClassName = driverClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJndiName() {
|
||||||
|
return jndiName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJndiName(String jndiName) {
|
||||||
|
this.jndiName = jndiName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getSeata() {
|
||||||
|
return seata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeata(Boolean seata) {
|
||||||
|
this.seata = seata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getLazy() {
|
||||||
|
return lazy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLazy(Boolean lazy) {
|
||||||
|
this.lazy = lazy;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.op.system.api.factory;
|
||||||
|
|
||||||
|
import com.op.common.core.domain.R;
|
||||||
|
import com.op.system.api.RemoteWmsService;
|
||||||
|
import com.op.system.api.domain.DataSourcePropertyDTO;
|
||||||
|
import com.op.system.api.domain.dto.WCSDTO;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户服务降级处理
|
||||||
|
*
|
||||||
|
* @author OP
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RemoteWmsFallbackFactory implements FallbackFactory<RemoteWmsService> {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RemoteWmsFallbackFactory.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RemoteWmsService create(Throwable throwable) {
|
||||||
|
log.error("Wms服务调用失败:{}", throwable.getMessage());
|
||||||
|
return new RemoteWmsService() {
|
||||||
|
@Override
|
||||||
|
public R addDatasource(DataSourcePropertyDTO dataSourceProperty) {
|
||||||
|
return R.fail("mes数据源创建失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R removeDatasource(DataSourcePropertyDTO dataSourceProperty) {
|
||||||
|
return R.fail("mes数据源删除失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue