This commit is contained in:
2023-06-27 18:08:04 +08:00
parent ae12b7f2ff
commit 5d52e6f166
31 changed files with 813 additions and 140 deletions

View File

@ -0,0 +1,43 @@
package com.qiaoba.common.base.code;
import lombok.Getter;
/**
* 数据源错误信息
*
* @author ailanyin
* @version 1.0
* @since 2023/6/27 9:22
*/
@Getter
public enum DatasourceErrorCode {
/**
* 未找到
*/
NOT_FIND(50101, "未找到数据源信息"),
/**
* 连接错误
*/
CONNECT_ERROR(50102, "数据源无法连接"),
/**
* 切换模式错误
*/
SWITCH_SCHEMA_ERROR(50103, "切换模式错误"),
/**
* 创建表错误
*/
CREATE_TABLE_ERROR(50104, "创建表错误");
private final Integer code;
private final String msg;
DatasourceErrorCode(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
}

View File

@ -38,7 +38,7 @@ public enum DataBaseEnum {
* PostgreSQL
*/
POSTGRE_SQL("PostgreSQL",
"jdbc:postgresql://{}:{}/mydb?currentSchema={}&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowMultiQueries=true",
"jdbc:postgresql://{}:{}/{}?currentSchema={}&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowMultiQueries=true",
"org.postgresql.Driver",
"SELECT 1"),
@ -65,10 +65,10 @@ public enum DataBaseEnum {
throw new ServiceException(StrUtil.format("未找到数据库驱动, Type: {}", type));
}
public static String getUrl(String type, String ip, String port, String database) {
public static String getUrl(String type, String ip, String port, String dbName, String schema) {
for (DataBaseEnum dataBaseEnum : values()) {
if (dataBaseEnum.getType().equals(type)) {
return StrUtil.format(dataBaseEnum.url, ip, port, database);
return StrUtil.format(dataBaseEnum.url, ip, port, dbName, schema);
}
}
throw new ServiceException(StrUtil.format("未找到数据库Url, Type: {}", type));

View File

@ -17,7 +17,7 @@ public class AjaxResult extends HashMap<String, Object> {
/**
* 状态码
*/
public static final String CODE_TAG = "code";
public static final String CODE_TAG = "result";
/**
* 返回内容