Commit 68377a7a authored by 赵啸非's avatar 赵啸非

添加区域树

parent 72d30ae5
......@@ -161,50 +161,6 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se
return ret.toJSONString();
}
/*
@PostMapping("/init")
@UnAuth
public String initDb(@RequestBody ResourceSetupEntity resourceSetupEntity) {
JSONObject ret = new JSONObject();
int code = VALUE_RESULT_SUCCESS;
try {
if (ObjectUtils.isEmpty(resourceSetupEntity.getResourceFilePath())) {
throw new AppException("请上传资源文件");
}
String targetFilePath = uploadService.getFilePath(resourceSetupEntity.getResourceFilePath());
if (FileUtil.isEmpty(new File(targetFilePath))) {
throw new AppException("部署文件不存在!");
}
if (!FileUtil.getSuffix(resourceSetupEntity.getResourceFilePath()).equals("zip")) {
throw new AppException("部署只支持zip文件!");
}
if (!FileUtil.isDirectory(filePath)) {
//部署路径是否存在 如果不存在 创建目录,
FileUtil.mkdir(filePath);
}
String fileEncode = "UTF-8";
try {
fileEncode = EncodeUtil.getEncode(targetFilePath, true);
} catch (Exception e) {
log.error("异常", e);
}
ZipUtil.unzip(targetFilePath, filePath, Charset.forName(fileEncode));
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();
}*/
/**
* 更新基础服务子区域
*
......@@ -256,29 +212,29 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se
int code = VALUE_RESULT_SUCCESS;
SetupProjectEntity setupProject = this.service.get(siteEntity.getId());
if(ObjectUtils.isEmpty(setupProject)) throw new AppException("未找到项目信息");
if (ObjectUtils.isEmpty(setupProject)) throw new AppException("未找到项目信息");
if(ObjectUtils.isEmpty(setupProject.getSiteId())) throw new AppException("请同步更新站点信息");
if (ObjectUtils.isEmpty(setupProject.getSiteId())) throw new AppException("请同步更新站点信息!");
try {
HashMap<String, String> params = new HashMap<>();
params.put("areaCode", siteEntity.getAreaCode());
HashMap<String, Object> params = new HashMap<>();
params.put("id", setupProject.getSiteId());
String resp = HttpUtil.post("http://127.0.0.1:11078/base/area/genSubAreaByAreaName", JSON.toJSONString(params));
String resp = HttpUtil.post("http://127.0.0.1:11078/base/site/syncGovMatterBySiteId", JSON.toJSONString(params));
Rest rest = JSON.parseObject(resp, Rest.class);
if (YesNoEnum.YES.getValue() == rest.getCode()) {
ret.put(KEY_RESULT_MSG, "子区域更新成功");
ret.put(KEY_RESULT_MSG, "更新事项命令下发成功!");
SetupProjectEntity setupProjectEntity = new SetupProjectEntity();
setupProjectEntity.setId(siteEntity.getId());
setupProjectEntity.setAreaCode(siteEntity.getAreaCode());
this.service.update(setupProjectEntity);
}
ret.put(KEY_RESULT_MSG, "子区域更新失败");
ret.put(KEY_RESULT_MSG, "更新事项命令下发失败");
} catch (Exception e) {
code = VALUE_RESULT_FAILURE;
log.error("子区域更新失败失败", e);
log.error("更新事项命令下发失败", e);
ret.put(KEY_RESULT_MSG, e.getMessage());
}
ret.put(KEY_RESULT_CODE, code);
......@@ -287,7 +243,6 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se
}
/**
* 创建站点
*
......@@ -323,9 +278,7 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se
this.service.update(setupProjectEntity);
});
//todo 更加站点编码生成基础服务应用,并部署到/home/publish/app/ 目录下
//todo 在/home/publish/app/ 目录下 创建自助服务应用
//todo 在/home/publish/app/ 目录下 更加站点编码生成基础服务应用 创建自助服务应用
String projectPath = this.publishPath + "/app/" + siteAddRest.getData().getSiteCode();
//解压资源文件
String sourcePath = this.publishPath + "/temp/project/" + 基础服务.getValue() + "/app.tar.gz";
......@@ -355,19 +308,17 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se
destDir.mkdirs();
ua.setDestDirectory(destDir);
ua.extract();
//todo 更新门户站点信息,用户站点树等 user/initData
JSONObject json = new JSONObject();
json.put("siteIds", siteAddRest.getData().getId());
json.put("areaCodes", siteAddRest.getData().getAreaCode());
json.put("areaNames", siteAddRest.getData().getAreaName());
String portalResp = HttpUtil.post("http://127.0.0.1:11078/portal/base/user/initData", json.toJSONString());
log.info("门户站点更新返回:{}", portalResp);
} else {
throw new AppException("站点添加失败! " + rest.getMsg());
}
} else {
throw new AppException("子区域更新失败! " + rest.getMsg());
}
......@@ -418,33 +369,31 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se
}
/* *//**
/**
* 服务列表查询
*
* @param projectSetupEntity
* @return
*//*
*/
@PostMapping("/list")
@UnAuth
public String list(@RequestBody ProjectSetupEntity projectSetupEntity) {
public String list() {
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");
log.info("服务列表查询返回:{}", resp);
ret.put(KEY_RESULT_DATA, resp);
ret.put(KEY_RESULT_MSG, "项目资源部署成功");
ret.put(KEY_RESULT_MSG, "列表查询成功");
} catch (Exception e) {
code = VALUE_RESULT_FAILURE;
log.error("查询服务状态失败", e);
log.error("列表查询失败", e);
ret.put(KEY_RESULT_MSG, e.getMessage());
}
ret.put(KEY_RESULT_CODE, code);
return ret.toJSONString();
}
*/
/**
* 服务实例详细查询
......@@ -457,9 +406,14 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se
public String instances(@RequestBody ProjectSetupEntity projectSetupEntity) {
JSONObject ret = new JSONObject();
int code = VALUE_RESULT_SUCCESS;
SetupProjectEntity projectEntity = this.service.get(projectSetupEntity.getId());
if (ObjectUtils.isEmpty(projectEntity)) throw new AppException("项目不存在");
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");
String resp = HttpUtil.get(nacosUrl + "/v1/ns/catalog/instances?serviceName=" + projectEntity.getProjectCode() + "&clusterName=DEFAULT&groupName=DEFAULT_GROUP&pageSize=10&pageNo=1&namespaceId=smart-gov");
log.info("服务实例详细查询返回:{}", resp);
ret.put(KEY_RESULT_DATA, resp);
ret.put(KEY_RESULT_MSG, "服务实例详细查询成功");
} catch (Exception e) {
......@@ -468,7 +422,6 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se
ret.put(KEY_RESULT_MSG, e.getMessage());
}
ret.put(KEY_RESULT_CODE, code);
return ret.toJSONString();
}
......@@ -523,7 +476,6 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se
bool = true;
data.put("project", bool);
data.put("siteCode", setupProjectEntity.getSiteCode());
return Rest.ok("项目工程已部署", data);
}
return Rest.ok("项目工程未部署,进入引导界面", data);
......@@ -535,9 +487,7 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se
public static void main(String[] args) {
System.out.println(FileUtil.isDirectory("E://pic"));
}
}
\ No newline at end of file
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