Commit fd361591 authored by 赵啸非's avatar 赵啸非

添加实例查询

parent 676c6471
......@@ -2,6 +2,7 @@ package com.mortals.xhx.module.setup.web;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ZipUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.exception.AppException;
......@@ -43,13 +44,14 @@ import static com.mortals.framework.web.BaseController.*;
public class SetupProjectController {
@Value("${upload.path}")
@Getter
private String filePath;
@Value("${project.publishPath}")
@Getter
private String publishPath;
@Value("${project.nacosUrl}")
private String nacosUrl;
@Autowired
private UploadService uploadService;
......@@ -106,13 +108,68 @@ public class SetupProjectController {
String sourcePath = "/project/" + ProductDisEnum.getByValue(projectSetupEntity.getProjectValue()).getDesc() + "/" + projectSetupEntity.getProjectValue() + ".tar.gz";
InputStream inputStream = this.getClass().getResourceAsStream(sourcePath);
ZipUtils.unGzip(inputStream, unZipPath);
ret.put(KEY_RESULT_MSG, "项目资源部署成功");
} catch (Exception e) {
code = VALUE_RESULT_FAILURE;
log.error("导入资源文件失败", e);
ret.put(KEY_RESULT_MSG, e.getMessage());
}
ret.put(KEY_RESULT_CODE, code);
return ret.toJSONString();
}
/**
* 服务列表查询
*
* @param projectSetupEntity
* @return
*/
@PostMapping("/list")
@UnAuth
public String list(@RequestBody ProjectSetupEntity projectSetupEntity) {
JSONObject ret = new JSONObject();
int code = VALUE_RESULT_SUCCESS;
try {
// curl -X GET 'http://127.0.0.1:8848/nacos/v1/ns/catalog/services?pageNo=1&pageSize=100&namespaceId=smart-gov'
String resp = HttpUtil.get(nacosUrl + "/v1/ns/catalog/services?pageNo=1&pageSize=100&namespaceId=smart-gov");
ret.put(KEY_RESULT_DATA, resp);
ret.put(KEY_RESULT_MSG, "项目资源部署成功");
} catch (Exception e) {
code = VALUE_RESULT_FAILURE;
log.error("查询服务状态失败", e);
ret.put(KEY_RESULT_MSG, e.getMessage());
}
ret.put(KEY_RESULT_CODE, code);
return ret.toJSONString();
}
/**
* 服务实例详细查询
*
* @param projectSetupEntity
* @return
*/
@PostMapping("/instances")
@UnAuth
public String instances(@RequestBody ProjectSetupEntity projectSetupEntity) {
JSONObject ret = new JSONObject();
int code = VALUE_RESULT_SUCCESS;
try {
// curl -X GET 'http://127.0.0.1:8848/nacos/v1/ns/catalog/instances?serviceName=base-manager&clusterName=DEFAULT&groupName=DEFAULT_GROUP&pageSize=10&pageNo=1&namespaceId=smart-gov'
String resp = HttpUtil.get(nacosUrl + "/v1/ns/catalog/instances?serviceName=" + projectSetupEntity.getProjectValue() + "&clusterName=DEFAULT&groupName=DEFAULT_GROUP&pageSize=10&pageNo=1&namespaceId=smart-gov");
ret.put(KEY_RESULT_DATA, resp);
ret.put(KEY_RESULT_MSG, "服务实例详细查询成功");
} catch (Exception e) {
code = VALUE_RESULT_FAILURE;
log.error("服务实例详细查询失败", e);
ret.put(KEY_RESULT_MSG, e.getMessage());
}
ret.put(KEY_RESULT_CODE, code);
return ret.toJSONString();
}
......
......@@ -64,7 +64,7 @@ public class SetupResourceController {
throw new AppException("部署只支持zip文件!");
}
if(!FileUtil.isDirectory(filePath)){
if (!FileUtil.isDirectory(filePath)) {
//部署路径是否存在 如果不存在 创建目录,
FileUtil.mkdir(filePath);
}
......@@ -88,20 +88,6 @@ public class SetupResourceController {
return ret.toJSONString();
}
//检查bank数据库是否存在
private boolean databaseExists(Connection conn, String dbName) throws SQLException {
ResultSet resultSet = conn.getMetaData().getCatalogs();
while (resultSet.next()) {
if (dbName.equals(resultSet.getString(1))) {
return true;
}
}
return false;
}
public static void main(String[] args) {
System.out.println(FileUtil.isDirectory("E://pic"));
......
......@@ -28,3 +28,4 @@ upload:
path: E:/pic
project:
publishPath: E:\pic\zip\
nacosUrl: http://127.0.0.1:8848
......@@ -82,7 +82,7 @@ POST http://localhost:8081/project/distribute
Content-Type: application/json
{
"projectValue": "base-manager"
"projectValue": "portal-manager"
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment