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

修改前端页面

parent ceb15f82
Subproject commit 41fb26137a8cd899930fd382d6d3947cdf9424ee Subproject commit acfb65a1e25fc0a9c207c06c532010ff43da6841
...@@ -18,4 +18,6 @@ public interface SetupProjectService extends ICRUDService<SetupProjectEntity,Lon ...@@ -18,4 +18,6 @@ public interface SetupProjectService extends ICRUDService<SetupProjectEntity,Lon
Rest<String> distribute(SetupProjectEntity setupProjectEntity, Context context); Rest<String> distribute(SetupProjectEntity setupProjectEntity, Context context);
Rest<String> appDeploy(SetupProjectEntity setupProjectEntity, Context context);
} }
\ No newline at end of file
...@@ -139,6 +139,31 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec ...@@ -139,6 +139,31 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
return Rest.ok(); return Rest.ok();
} }
@Override
public Rest<String> appDeploy(SetupProjectEntity setupProjectEntity, Context context) {
String sourcePath = "./../project/" + ProductDisEnum.getByValue(setupProjectEntity.getProjectCode()).getDesc() + "/app.tar.gz";
//创建目录
File appDir = new File(setupProjectEntity.getProjectPath() + "app/");
File appSiteDir = new File(setupProjectEntity.getProjectPath() + "app/"+setupProjectEntity.getSiteCode()+"/");
if(!FileUtil.exist(appDir)){
FileUtil.mkdir(appDir);
}
if(!FileUtil.exist(appSiteDir)){
FileUtil.mkdir(appSiteDir);
}
File file = new File(sourcePath);
log.info("文件存在:{}", file.exists());
InputStream inputStream = FileUtil.getInputStream(file);
ZipUtils.unGzip(inputStream, appSiteDir.getPath());
return Rest.ok("应用部署成功!");
}
// @Override // @Override
public Rest<String> updateBaseSystem(SiteEntity siteEntity) { public Rest<String> updateBaseSystem(SiteEntity siteEntity) {
......
...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.setup.web; ...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.setup.web;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth; import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
...@@ -28,19 +29,19 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -28,19 +29,19 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* * 项目工程信息
* 项目工程信息 *
* * @author zxfei
* @author zxfei * @date 2024-10-21
* @date 2024-10-21 */
*/
@RestController @RestController
@RequestMapping("setup/project") @RequestMapping("setup/project")
public class SetupProjectController extends BaseCRUDJsonBodyMappingController<SetupProjectService,SetupProjectEntity,Long> { public class SetupProjectController extends BaseCRUDJsonBodyMappingController<SetupProjectService, SetupProjectEntity, Long> {
@Value("${project.nacosUrl}") @Value("${project.nacosUrl}")
...@@ -50,8 +51,8 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se ...@@ -50,8 +51,8 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se
private SetupDbService setupDbService; private SetupDbService setupDbService;
public SetupProjectController(){ public SetupProjectController() {
super.setModuleDesc( "项目工程信息"); super.setModuleDesc("项目工程信息");
} }
@Override @Override
...@@ -174,25 +175,108 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se ...@@ -174,25 +175,108 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se
}*/ }*/
/**
* 更新基础服务子区域
*
* @return
*/
@PostMapping("/area/update")
@UnAuth
public String areaUpdate(@RequestBody SiteEntity siteEntity) {
JSONObject ret = new JSONObject();
int code = VALUE_RESULT_SUCCESS;
if (ObjectUtils.isEmpty(siteEntity.getAreaCode())) throw new AppException("请输入区域编码");
try {
HashMap<String, String> params = new HashMap<>();
params.put("areaCode", siteEntity.getAreaCode());
String resp = HttpUtil.post("http://127.0.0.1:11078/base/area/genSubAreaByAreaName", JSON.toJSONString(params));
Rest rest = JSON.parseObject(resp, Rest.class);
if (YesNoEnum.YES.getValue() == rest.getCode()) {
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, "子区域更新失败");
} 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();
}
/** /**
* 服务列表查询 * 创建站点
* *
* @return * @return
*/ */
@PostMapping("/update/site") @PostMapping("/site/add")
@UnAuth @UnAuth
public String updateSite(@RequestBody SiteEntity siteEntity) { public String updateSite(@RequestBody SiteEntity siteEntity) {
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
int code = VALUE_RESULT_SUCCESS; int code = VALUE_RESULT_SUCCESS;
if (ObjectUtils.isEmpty(siteEntity.getSiteName())) throw new AppException("请输入站点名称");
SetupProjectEntity setupProject = this.service.get(siteEntity.getId());
if(ObjectUtils.isEmpty(setupProject)) throw new AppException("请先创建项目");
if(ObjectUtils.isEmpty(setupProject.getAreaCode())) throw new AppException("请先创建区域");
try { 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); String resp = HttpUtil.post("http://127.0.0.1:11078/base/site/api/add", JSON.toJSONString(siteEntity));
ret.put(KEY_RESULT_MSG, "项目资源部署成功"); Rest rest = JSON.parseObject(resp, Rest.class);
log.info(JSON.toJSONString(rest));
if (YesNoEnum.YES.getValue() == rest.getCode()) {
ret.put(KEY_RESULT_MSG, "站点添加成功!");
SetupProjectEntity setupProjectEntity = new SetupProjectEntity();
setupProjectEntity.setId(siteEntity.getId());
setupProjectEntity.setSiteName(siteEntity.getSiteName());
// setupProjectEntity.setSiteCode();
//setupProjectEntity.setSiteId();
this.service.update(setupProjectEntity);
}
// 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();
}
/**
* 自助服务应用部署
*
* @return
*/
@PostMapping("/app/deploy")
@UnAuth
public String appDeploy(@RequestBody SiteEntity siteEntity) {
JSONObject ret = new JSONObject();
int code = VALUE_RESULT_SUCCESS;
if (ObjectUtils.isEmpty(siteEntity.getSiteCode())) throw new AppException("请先创建站点后再部署自助服务应用!");
try {
//todo 在/home/publish/app/ 目录下 创建自助服务应用
ret.put(KEY_RESULT_MSG, "子区域更新失败");
} catch (Exception e) { } catch (Exception e) {
code = VALUE_RESULT_FAILURE; code = VALUE_RESULT_FAILURE;
log.error("查询服务状态失败", e); log.error("查询服务状态失败", e);
......
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