|
|
@@ -201,6 +201,28 @@ public class ApiService {
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
+ // 删除数据源表数据
|
|
|
+ public Map delDatasource(Map params) {
|
|
|
+ Map ret = new HashMap<>();
|
|
|
+ String id = params.get("id").toString();
|
|
|
+ Boolean isUsed = apiDao.usedDatasource(params);// 判断是否有sql在使用此数据源
|
|
|
+ if(!isUsed) {
|
|
|
+ ret.put("sysErrorCode", "51000");
|
|
|
+ ret.put("sysErrorMessage", "此数据被Sql使用中,无法删除");
|
|
|
+
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ // 删除此数据源配置
|
|
|
+ Map deleteParams = new HashMap<>();
|
|
|
+ deleteParams.put("id", id);
|
|
|
+ Integer delRet = apiDao.deleteDatasourceById(deleteParams);
|
|
|
+ if (delRet < 1) {
|
|
|
+ ret.put("sysErrorCode", "51000");
|
|
|
+ }
|
|
|
+
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
// 删除对应基础表数据
|
|
|
public Map delDetailById(Map params) {
|
|
|
Map ret = new HashMap<>();
|
|
|
@@ -315,6 +337,26 @@ public class ApiService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ // 数据源管理列表-获取带分页的page数据
|
|
|
+ public Map datasourceListHasPaging(Map<String, String> maps) {
|
|
|
+ String page = "1"; // 页数
|
|
|
+ String perPage = "15"; // 显示多少条
|
|
|
+ Map res = new HashMap<>();
|
|
|
+ Map bindData = commonUtil.filterApiBindParams(maps);
|
|
|
+ if(maps.containsKey("page")) {
|
|
|
+ page = maps.get("page");
|
|
|
+ }
|
|
|
+ if(maps.containsKey("perPage")) {
|
|
|
+ perPage = maps.get("perPage");
|
|
|
+ }
|
|
|
+ Integer count = pageDao.getAllDatasourceListHasPagingCount(bindData);
|
|
|
+ List info = pageDao.getAllDatasourceListHasPaging(bindData, page, perPage, count);
|
|
|
+ res.put("count", count);
|
|
|
+ res.put("rows", info);
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
// api管理列表-获取带分页的page数据
|
|
|
public Map apiListHasPaging(Map<String, String> maps) {
|
|
|
String page = "1"; // 页数
|
|
|
@@ -385,6 +427,14 @@ public class ApiService {
|
|
|
return menuData;
|
|
|
}
|
|
|
|
|
|
+ // 获取数据库配置源
|
|
|
+ public List datasource() {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ List<Map<String, Object>> datasource = pageDao.getAllDatasource();
|
|
|
+
|
|
|
+ return datasource;
|
|
|
+ }
|
|
|
+
|
|
|
// 获取全部sql_details---配置权限关联item使用,无分页
|
|
|
public List itemList() {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
@@ -649,10 +699,34 @@ public class ApiService {
|
|
|
return retInfo;
|
|
|
}
|
|
|
|
|
|
+ // 添加数据源
|
|
|
+ public Map saveDatasource(Map maps){
|
|
|
+ // 通过是否存在id,判读是新增还是修改
|
|
|
+ String editId = "";
|
|
|
+ if (maps.containsKey("id")) {
|
|
|
+ editId = maps.get("id").toString();
|
|
|
+ }
|
|
|
+ String createdAt = commonUtil.getNowYYMMDDHHIISS();
|
|
|
+ Map params = new HashMap<>();
|
|
|
+ params.put("datasourceCode", maps.get("datasource_code"));
|
|
|
+ params.put("datasourceUrl", maps.get("datasource_url"));
|
|
|
+ params.put("datasourceUsername", maps.get("datasource_username"));
|
|
|
+ params.put("datasourcePassword", maps.get("datasource_password"));
|
|
|
+ params.put("createdAt", createdAt);
|
|
|
+ // 添加/编辑Sql
|
|
|
+ Integer pageId = apiDao.saveDatasource(params, editId);
|
|
|
+ Map retInfo = new HashMap<>();
|
|
|
+ if(pageId <= 0){
|
|
|
+ retInfo.put("sysErrorCode", "500");
|
|
|
+ }
|
|
|
+ return retInfo;
|
|
|
+ }
|
|
|
+
|
|
|
// 添加sql_details表数据
|
|
|
public Map addSql(Map maps, String authorization) {
|
|
|
String sqlDesc = "";
|
|
|
String isList = "0";
|
|
|
+ String datasource = maps.get("datasource_code").toString();
|
|
|
if (maps.containsKey("is_list")) {
|
|
|
isList = maps.get("is_list").toString();
|
|
|
}
|
|
|
@@ -678,6 +752,7 @@ public class ApiService {
|
|
|
addPagePamars.put("sqlName", sqlName);
|
|
|
addPagePamars.put("sqlString", sqlString);
|
|
|
addPagePamars.put("sqlDesc", sqlDesc);
|
|
|
+ addPagePamars.put("datasourceCode", datasource);
|
|
|
Map<String, Object> loginResult = this.userInfo(authorization);
|
|
|
addPagePamars.put("actionUser", loginResult.get("userName")); // 获取当前用户信息
|
|
|
if (editId.length()==0) {
|