Commit 10fb5222 authored by 赵啸非's avatar 赵啸非

添加区域树

parent 23fcd536
{
"local": {
"baseUrl": "http://192.168.0.217:17211"
},
"dev": {
"baseUrl": "http://192.168.0.251:1023"
},
"other": {
"baseUrl": "http://192.168.0.30:17211"
}
}
\ No newline at end of file
...@@ -29,7 +29,7 @@ public class BaseAreaTreeSelect implements Serializable { ...@@ -29,7 +29,7 @@ public class BaseAreaTreeSelect implements Serializable {
/** /**
* 节点ID * 节点ID
*/ */
private Long id; private String id;
/** /**
* 节点名称 * 节点名称
...@@ -39,6 +39,7 @@ public class BaseAreaTreeSelect implements Serializable { ...@@ -39,6 +39,7 @@ public class BaseAreaTreeSelect implements Serializable {
* 区域编码 * 区域编码
*/ */
private String areaCode; private String areaCode;
/** /**
* 是否叶子节点 * 是否叶子节点
*/ */
...@@ -68,11 +69,12 @@ public class BaseAreaTreeSelect implements Serializable { ...@@ -68,11 +69,12 @@ public class BaseAreaTreeSelect implements Serializable {
public BaseAreaTreeSelect() {}; public BaseAreaTreeSelect() {};
public BaseAreaTreeSelect(BaseAreaEntity entity) { public BaseAreaTreeSelect(BaseAreaEntity entity) {
this.id = entity.getId(); this.id = entity.getIid();
this.label = entity.getName(); this.label = entity.getName();
this.children = new ArrayList();
if ("False".equalsIgnoreCase(entity.getHaveSonArea())) { if ("False".equalsIgnoreCase(entity.getHaveSonArea())) {
this.isLeaf = true; this.isLeaf = true;
this.children = new ArrayList();
} else { } else {
this.isLeaf = false; this.isLeaf = false;
} }
...@@ -91,7 +93,7 @@ public class BaseAreaTreeSelect implements Serializable { ...@@ -91,7 +93,7 @@ public class BaseAreaTreeSelect implements Serializable {
public BaseAreaTreeSelect deserialze(DefaultJSONParser parser, Type type, Object fieldName) { public BaseAreaTreeSelect deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
BaseAreaTreeSelect node = new BaseAreaTreeSelect(); BaseAreaTreeSelect node = new BaseAreaTreeSelect();
JSONObject jsonObject = parser.parseObject(); JSONObject jsonObject = parser.parseObject();
node.setId(jsonObject.getLong("id")); node.setId(jsonObject.getString("id"));
node.setLabel(jsonObject.getString("label")); node.setLabel(jsonObject.getString("label"));
JSONArray jsonArray = jsonObject.getJSONArray("children"); JSONArray jsonArray = jsonObject.getJSONArray("children");
List<BaseAreaTreeSelect> children = new ArrayList<>(); List<BaseAreaTreeSelect> children = new ArrayList<>();
......
...@@ -5,6 +5,7 @@ import cn.hutool.core.io.FileUtil; ...@@ -5,6 +5,7 @@ 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.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.mortals.framework.annotation.UnAuth; import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
...@@ -23,6 +24,7 @@ import com.mortals.xhx.module.setup.model.SetupProjectQuery; ...@@ -23,6 +24,7 @@ import com.mortals.xhx.module.setup.model.SetupProjectQuery;
import com.mortals.xhx.module.setup.service.SetupDbService; import com.mortals.xhx.module.setup.service.SetupDbService;
import com.mortals.xhx.module.setup.service.SetupProjectService; import com.mortals.xhx.module.setup.service.SetupProjectService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -42,6 +44,7 @@ import java.util.Map; ...@@ -42,6 +44,7 @@ import java.util.Map;
*/ */
@RestController @RestController
@RequestMapping("setup/project") @RequestMapping("setup/project")
@Slf4j
public class SetupProjectController extends BaseCRUDJsonBodyMappingController<SetupProjectService, SetupProjectEntity, Long> { public class SetupProjectController extends BaseCRUDJsonBodyMappingController<SetupProjectService, SetupProjectEntity, Long> {
...@@ -242,34 +245,48 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se ...@@ -242,34 +245,48 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se
* *
* @return * @return
*/ */
@PostMapping("/site/add") @PostMapping("/site/updateSite")
@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("请输入站点名称!");
if (ObjectUtils.isEmpty(siteEntity.getSiteName())) throw new AppException("请输入站点名称"); if (ObjectUtils.isEmpty(siteEntity.getAreaCode())) 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 {
//生成子区域/base/area/genSubAreaByAreaName
String resp = HttpUtil.post("http://127.0.0.1:11078/base/site/api/add", JSON.toJSONString(siteEntity)); String resp = HttpUtil.post("http://127.0.0.1:11078/base/area/genSubAreaByAreaName", JSON.toJSONString(siteEntity));
Rest rest = JSON.parseObject(resp, Rest.class); Rest<String> rest = JSON.parseObject(resp, new TypeReference<Rest<String>>() {
log.info(JSON.toJSONString(rest)); });
if (YesNoEnum.YES.getValue() == rest.getCode()) { if (YesNoEnum.YES.getValue() == rest.getCode()) {
ret.put(KEY_RESULT_MSG, "站点添加成功!"); resp = HttpUtil.post("http://127.0.0.1:11078/base/site/api/add", JSON.toJSONString(siteEntity));
SetupProjectEntity setupProjectEntity = new SetupProjectEntity(); log.info("站点添加返回:{}", resp);
setupProjectEntity.setId(siteEntity.getId()); Rest<SiteEntity> siteAddRest = JSON.parseObject(resp, new TypeReference<Rest<SiteEntity>>() {
setupProjectEntity.setSiteName(siteEntity.getSiteName()); });
// setupProjectEntity.setSiteCode();
//setupProjectEntity.setSiteId(); if (YesNoEnum.YES.getValue() == siteAddRest.getCode()) {
this.service.update(setupProjectEntity); //更新所有项目的站点编码与名称
SetupProjectEntity setupProjectEntity = new SetupProjectEntity();
setupProjectEntity.setSiteName(siteAddRest.getData().getSiteName());
setupProjectEntity.setSiteCode(siteAddRest.getData().getSiteCode());
setupProjectEntity.setSiteId(siteAddRest.getData().getId());
setupProjectEntity.setAreaCode(siteAddRest.getData().getAreaCode());
setupProjectEntity.setAreaName(siteAddRest.getData().getAreaName());
this.service.getDao().update(setupProjectEntity);
this.service.update(setupProjectEntity);
//todo 更新门户站点信息,用户站点树等
//todo 更加站点编码生成基础服务应用,并部署
} else {
throw new AppException("站点添加失败! " + rest.getMsg());
}
} else {
throw new AppException("子区域更新失败! " + rest.getMsg());
} }
// ret.put(KEY_RESULT_DATA, resp);
ret.put(KEY_RESULT_MSG, "站点添加成功!"); ret.put(KEY_RESULT_MSG, "站点添加成功!");
} catch (Exception e) { } catch (Exception e) {
code = VALUE_RESULT_FAILURE; code = VALUE_RESULT_FAILURE;
......
{ {
"local": { "local": {
"baseUrl": "http://192.168.0.224/" "baseUrl": "http://127.0.0.1:18000/m"
}, },
"dev": { "dev": {
"baseUrl": "http://192.168.0.64:80/" "baseUrl": "http://127.0.0.1:18000/m"
}, },
"test": { "test": {
"baseUrl": "http://192.168.0.121:80/" "baseUrl": "http://192.168.0.250:8082/m"
},
"portal": {
"baseUrl": "http://192.168.0.98:11072/zwfw"
} }
} }
\ No newline at end of file
### ###
POST http://localhost:8081/db/importDb POST {{baseUrl}}/db/importDb
Content-Type: multipart/form-data; boundary=WebAppBoundary Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary --WebAppBoundary
...@@ -13,7 +13,7 @@ Content-Disposition: form-data; name="file"; filename="file.sql" ...@@ -13,7 +13,7 @@ Content-Disposition: form-data; name="file"; filename="file.sql"
###上传数据库文件 ###上传数据库文件
POST http://localhost:8081/file/commonupload POST {{baseUrl}}/file/commonupload
Content-Type: multipart/form-data; boundary=WebAppBoundary Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary --WebAppBoundary
...@@ -24,7 +24,7 @@ Content-Disposition: form-data; name="file"; filename="file.sql" ...@@ -24,7 +24,7 @@ Content-Disposition: form-data; name="file"; filename="file.sql"
###上传资源文件 ###上传资源文件
POST http://localhost:8081/file/commonupload POST {{baseUrl}}/file/commonupload
Content-Type: multipart/form-data; boundary=WebAppBoundary Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary --WebAppBoundary
...@@ -34,7 +34,7 @@ Content-Disposition: form-data; name="file"; filename="file.zip" ...@@ -34,7 +34,7 @@ Content-Disposition: form-data; name="file"; filename="file.zip"
--WebAppBoundary-- --WebAppBoundary--
###测试链接数据库 ###测试链接数据库
POST http://localhost:8081/m/db/connect POST {{baseUrl}}/m/db/connect
Content-Type: application/json Content-Type: application/json
{ {
...@@ -48,7 +48,7 @@ Content-Type: application/json ...@@ -48,7 +48,7 @@ Content-Type: application/json
###测试导入sql数据库文件 ###测试导入sql数据库文件
POST http://localhost:8081/db/init POST {{baseUrl}}/db/init
Content-Type: application/json Content-Type: application/json
{ {
...@@ -62,14 +62,14 @@ Content-Type: application/json ...@@ -62,14 +62,14 @@ Content-Type: application/json
###测试导入sql数据库文件 form ###测试导入sql数据库文件 form
POST http://localhost:8081/db/init POST {{baseUrl}}/db/init
Content-Type: application/x-www-form-urlencoded Content-Type: application/x-www-form-urlencoded
dbFilePath=/file/fileupload/1724915454477.sql&dbHost=localhost&dbName=test1&dbPort=3306&userName=root&password=12345678 dbFilePath=/file/fileupload/1724915454477.sql&dbHost=localhost&dbName=test1&dbPort=3306&userName=root&password=12345678
###测试导入资源文件 ###测试导入资源文件
POST http://localhost:8081/resource/init POST {{baseUrl}}/resource/init
Content-Type: application/json Content-Type: application/json
{ {
...@@ -78,7 +78,7 @@ Content-Type: application/json ...@@ -78,7 +78,7 @@ Content-Type: application/json
###测试项目部署1 ###测试项目部署1
POST http://localhost:8081/project/distribute POST {{baseUrl}}/project/distribute
Content-Type: application/json Content-Type: application/json
{ {
...@@ -87,7 +87,7 @@ Content-Type: application/json ...@@ -87,7 +87,7 @@ Content-Type: application/json
###测试项目部署2 ###测试项目部署2
POST http://localhost:8081/project/distribute POST {{baseUrl}}/project/distribute
Content-Type: application/json Content-Type: application/json
{ {
...@@ -95,4 +95,15 @@ Content-Type: application/json ...@@ -95,4 +95,15 @@ Content-Type: application/json
} }
###区域树测试
POST {{baseUrl}}/base/area/treeselect
Content-Type: application/json
{}
###区域查看
GET {{baseUrl}}/base/area/getListByParentId?parentId=6182157d00ce41559e001a89d87f4057
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