|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package cn.estsh.i3plus.pojo.base.enumutil;
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description : 软适配 枚举接口
|
|
|
|
@ -18,7 +19,10 @@ public class SoftSwitchEnumUtil {
|
|
|
|
|
public enum CASE_TYPE{
|
|
|
|
|
SOCKET(1,"SOCKET"),
|
|
|
|
|
RESTFUL(2,"RESTFUL"),
|
|
|
|
|
DATASOURCE(3,"数据源");
|
|
|
|
|
DATASOURCE(3,"数据源"),
|
|
|
|
|
WEBSERVICE(4,"WebService"),
|
|
|
|
|
MQ(5,"消息队列"),
|
|
|
|
|
WebSocket(6,"WebSocket");
|
|
|
|
|
|
|
|
|
|
private int value;
|
|
|
|
|
private String description;
|
|
|
|
@ -150,5 +154,293 @@ public class SoftSwitchEnumUtil {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//keyTypeId
|
|
|
|
|
/**
|
|
|
|
|
* 数据库连接方式
|
|
|
|
|
*/
|
|
|
|
|
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
|
|
|
|
public enum DATA_SOURCE_TYPE {
|
|
|
|
|
SOURCE_MARIA_DB(100, "MariaDB", "MariaDB 10.1","com.mysql.jdbc.Driver",3306,null),
|
|
|
|
|
SOURCE_SQL_SERVER(200, "SQL Server", "SQL Server 2017","com.microsoft.sqlserver.jdbc.SQLServerDriver",1433,"dbo"),
|
|
|
|
|
SOURCE_ORACLE(300, "Oracle", "Oralce 12C","oracle.jdbc.driver.OracleDriver",1521,null),
|
|
|
|
|
SOURCE_POSTGRE_SQL(400, "PostgreSql", "PostgreSql 10.5","org.postgresql.Driver",5432,"public");
|
|
|
|
|
|
|
|
|
|
private int value;
|
|
|
|
|
private String code;
|
|
|
|
|
private String description;
|
|
|
|
|
private String driverClassName;
|
|
|
|
|
private int defaultPort;
|
|
|
|
|
private String defaultSchemaPattern;
|
|
|
|
|
|
|
|
|
|
private DATA_SOURCE_TYPE (int value, String code, String description,String driverClassName,int port,String defaultSchemaPattern) {
|
|
|
|
|
this.value = value;
|
|
|
|
|
this.code = code;
|
|
|
|
|
this.description = description;
|
|
|
|
|
this.driverClassName = driverClassName;
|
|
|
|
|
this.defaultPort = port;
|
|
|
|
|
this.defaultSchemaPattern = defaultSchemaPattern;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getValue() {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getCode() {
|
|
|
|
|
return code;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
|
return description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getDriverClassName() {
|
|
|
|
|
return driverClassName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getDefaultPort() {
|
|
|
|
|
return defaultPort;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getDefaultSchemaPattern() {
|
|
|
|
|
return defaultSchemaPattern;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String valueOfCode(int val) {
|
|
|
|
|
String tmp = null;
|
|
|
|
|
for (int i = 0; i < values().length; i++) {
|
|
|
|
|
if (values()[i].value == val) {
|
|
|
|
|
tmp = values()[i].code;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int codeOfValue(String code) {
|
|
|
|
|
int tmp = 1;
|
|
|
|
|
for (int i = 0; i < values().length; i++) {
|
|
|
|
|
if (values()[i].code.equals(code)) {
|
|
|
|
|
tmp = values()[i].value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String valueOfDescription(int val) {
|
|
|
|
|
String tmp = null;
|
|
|
|
|
for (int i = 0; i < values().length; i++) {
|
|
|
|
|
if (values()[i].value == val) {
|
|
|
|
|
tmp = values()[i].description;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static SoftSwitchEnumUtil.DATA_SOURCE_TYPE valueOf(int val) {
|
|
|
|
|
String tmp = null;
|
|
|
|
|
for (int i = 0; i < values().length; i++) {
|
|
|
|
|
if (values()[i].value == val) {
|
|
|
|
|
return values()[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String codeOfDescription(String code) {
|
|
|
|
|
String tmp = null;
|
|
|
|
|
for (int i = 0; i < values().length; i++) {
|
|
|
|
|
if (values()[i].code.equals(code)) {
|
|
|
|
|
tmp = values()[i].description;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getJDBCUrl(String database,String host,Integer port){
|
|
|
|
|
if(this.getValue() == SOURCE_MARIA_DB.getValue()){
|
|
|
|
|
return getJDBCUrlMySQL(database,host,port);
|
|
|
|
|
}else if(this.getValue() == SOURCE_ORACLE.getValue()){
|
|
|
|
|
return getJDBCUrlOracle(database,host,port);
|
|
|
|
|
}else if(this.getValue() == SOURCE_POSTGRE_SQL.getValue()){
|
|
|
|
|
return getJDBCUrlPostgreSQL(database,host,port);
|
|
|
|
|
}else if(this.getValue() == SOURCE_SQL_SERVER.getValue()){
|
|
|
|
|
return getJDBCUrlSQLServer(database,host,port);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static SoftSwitchEnumUtil.DATA_SOURCE_TYPE getDataSourceURL(String databaseProductName){
|
|
|
|
|
if(StringUtils.isNotBlank(databaseProductName)){
|
|
|
|
|
if(databaseProductName.indexOf(":mysql:") != -1){
|
|
|
|
|
return SOURCE_MARIA_DB;
|
|
|
|
|
}else if(databaseProductName.indexOf(":oracle:") != -1){
|
|
|
|
|
return SOURCE_ORACLE;
|
|
|
|
|
}else if(databaseProductName.indexOf(":postgresql:") != -1){
|
|
|
|
|
return SOURCE_POSTGRE_SQL;
|
|
|
|
|
}else if(databaseProductName.indexOf(":sqlserver:") != -1){
|
|
|
|
|
return SOURCE_SQL_SERVER;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getJDBCUrlMySQL(String database,String host,Integer port){
|
|
|
|
|
return "jdbc:mysql://"+host+":"+port+"/"+database+"?autoReconnect=true&useSSL=false&characterEncoding=utf-8";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getJDBCUrlOracle(String database,String host,Integer port){
|
|
|
|
|
return "jdbc:oracle:thin:@"+host+":"+port+":"+database;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getJDBCUrlPostgreSQL(String database,String host,Integer port){
|
|
|
|
|
return "jdbc:postgresql://"+host+":"+port+"/"+database;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getJDBCUrlSQLServer(String database,String host,Integer port){
|
|
|
|
|
return "jdbc:sqlserver://" + host + ":" + port + ";database=" + database;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 参数值类型
|
|
|
|
|
*/
|
|
|
|
|
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
|
|
|
|
public enum PARAM_VALUE_TYPE{
|
|
|
|
|
NUM(1,"数字"),
|
|
|
|
|
STRING(2,"字符串"),
|
|
|
|
|
BOOLEAN(3,"布尔"),
|
|
|
|
|
MAP(4,"字典"),
|
|
|
|
|
LIST(5,"列表");
|
|
|
|
|
|
|
|
|
|
private int value;
|
|
|
|
|
private String description;
|
|
|
|
|
|
|
|
|
|
PARAM_VALUE_TYPE(int value, String description) {
|
|
|
|
|
this.value = value;
|
|
|
|
|
this.description = description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getValue() {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
|
return description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String valueOfDescription(int val) {
|
|
|
|
|
String tmp = null;
|
|
|
|
|
for (int i = 0; i < values().length; i++) {
|
|
|
|
|
if (values()[i].value == val) {
|
|
|
|
|
tmp = values()[i].description;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 参数类型
|
|
|
|
|
*/
|
|
|
|
|
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
|
|
|
|
public enum PARAM_TYPE{
|
|
|
|
|
OUT_PARAM(1,"出参"),
|
|
|
|
|
IN_PARAM(2,"入参"),
|
|
|
|
|
REQUEST_HEADER(3,"请求头");
|
|
|
|
|
|
|
|
|
|
private int value;
|
|
|
|
|
private String description;
|
|
|
|
|
|
|
|
|
|
PARAM_TYPE(int value, String description) {
|
|
|
|
|
this.value = value;
|
|
|
|
|
this.description = description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getValue() {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
|
return description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String valueOfDescription(int val) {
|
|
|
|
|
String tmp = null;
|
|
|
|
|
for (int i = 0; i < values().length; i++) {
|
|
|
|
|
if (values()[i].value == val) {
|
|
|
|
|
tmp = values()[i].description;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 适配模式
|
|
|
|
|
*/
|
|
|
|
|
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
|
|
|
|
public enum SUIT_MODE{
|
|
|
|
|
ACTIVE(1,"主动"),
|
|
|
|
|
PASSIVE(2,"被动");
|
|
|
|
|
|
|
|
|
|
private int value;
|
|
|
|
|
private String description;
|
|
|
|
|
|
|
|
|
|
SUIT_MODE(int value, String description) {
|
|
|
|
|
this.value = value;
|
|
|
|
|
this.description = description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getValue() {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
|
return description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String valueOfDescription(int val) {
|
|
|
|
|
String tmp = null;
|
|
|
|
|
for (int i = 0; i < values().length; i++) {
|
|
|
|
|
if (values()[i].value == val) {
|
|
|
|
|
tmp = values()[i].description;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 适配方式
|
|
|
|
|
*/
|
|
|
|
|
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
|
|
|
|
|
public enum SUIT_METHOD{
|
|
|
|
|
ACTIVE(1,"主动适配"),
|
|
|
|
|
SCHEDULE(2,"定时调度");
|
|
|
|
|
|
|
|
|
|
private int value;
|
|
|
|
|
private String description;
|
|
|
|
|
|
|
|
|
|
SUIT_METHOD(int value, String description) {
|
|
|
|
|
this.value = value;
|
|
|
|
|
this.description = description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getValue() {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
|
return description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String valueOfDescription(int val) {
|
|
|
|
|
String tmp = null;
|
|
|
|
|
for (int i = 0; i < values().length; i++) {
|
|
|
|
|
if (values()[i].value == val) {
|
|
|
|
|
tmp = values()[i].description;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|