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 {
/**
* 节点ID
*/
private Long id;
private String id;
/**
* 节点名称
......@@ -39,6 +39,7 @@ public class BaseAreaTreeSelect implements Serializable {
* 区域编码
*/
private String areaCode;
/**
* 是否叶子节点
*/
......@@ -68,11 +69,12 @@ public class BaseAreaTreeSelect implements Serializable {
public BaseAreaTreeSelect() {};
public BaseAreaTreeSelect(BaseAreaEntity entity) {
this.id = entity.getId();
this.id = entity.getIid();
this.label = entity.getName();
this.children = new ArrayList();
if ("False".equalsIgnoreCase(entity.getHaveSonArea())) {
this.isLeaf = true;
this.children = new ArrayList();
} else {
this.isLeaf = false;
}
......@@ -91,7 +93,7 @@ public class BaseAreaTreeSelect implements Serializable {
public BaseAreaTreeSelect deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
BaseAreaTreeSelect node = new BaseAreaTreeSelect();
JSONObject jsonObject = parser.parseObject();
node.setId(jsonObject.getLong("id"));
node.setId(jsonObject.getString("id"));
node.setLabel(jsonObject.getString("label"));
JSONArray jsonArray = jsonObject.getJSONArray("children");
List<BaseAreaTreeSelect> children = new ArrayList<>();
......
......@@ -5,6 +5,7 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
......@@ -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.SetupProjectService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ObjectUtils;
......@@ -42,6 +44,7 @@ import java.util.Map;
*/
@RestController
@RequestMapping("setup/project")
@Slf4j
public class SetupProjectController extends BaseCRUDJsonBodyMappingController<SetupProjectService, SetupProjectEntity, Long> {
......@@ -242,34 +245,48 @@ public class SetupProjectController extends BaseCRUDJsonBodyMappingController<Se
*
* @return
*/
@PostMapping("/site/add")
@PostMapping("/site/updateSite")
@UnAuth
public String updateSite(@RequestBody SiteEntity siteEntity) {
JSONObject ret = new JSONObject();
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("请先创建区域");
if (ObjectUtils.isEmpty(siteEntity.getSiteName())) throw new AppException("请输入站点名称!");
if (ObjectUtils.isEmpty(siteEntity.getAreaCode())) throw new AppException("请先选择区域!");
try {
String resp = HttpUtil.post("http://127.0.0.1:11078/base/site/api/add", JSON.toJSONString(siteEntity));
Rest rest = JSON.parseObject(resp, Rest.class);
log.info(JSON.toJSONString(rest));
//生成子区域/base/area/genSubAreaByAreaName
String resp = HttpUtil.post("http://127.0.0.1:11078/base/area/genSubAreaByAreaName", JSON.toJSONString(siteEntity));
Rest<String> rest = JSON.parseObject(resp, new TypeReference<Rest<String>>() {
});
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);
resp = HttpUtil.post("http://127.0.0.1:11078/base/site/api/add", JSON.toJSONString(siteEntity));
log.info("站点添加返回:{}", resp);
Rest<SiteEntity> siteAddRest = JSON.parseObject(resp, new TypeReference<Rest<SiteEntity>>() {
});
if (YesNoEnum.YES.getValue() == siteAddRest.getCode()) {
//更新所有项目的站点编码与名称
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, "站点添加成功!");
} catch (Exception e) {
code = VALUE_RESULT_FAILURE;
......
{
"local": {
"baseUrl": "http://192.168.0.224/"
"baseUrl": "http://127.0.0.1:18000/m"
},
"dev": {
"baseUrl": "http://192.168.0.64:80/"
"baseUrl": "http://127.0.0.1:18000/m"
},
"test": {
"baseUrl": "http://192.168.0.121:80/"
},
"portal": {
"baseUrl": "http://192.168.0.98:11072/zwfw"
"baseUrl": "http://192.168.0.250:8082/m"
}
}
\ No newline at end of file
###
POST http://localhost:8081/db/importDb
POST {{baseUrl}}/db/importDb
Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary
......@@ -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
--WebAppBoundary
......@@ -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
--WebAppBoundary
......@@ -34,7 +34,7 @@ Content-Disposition: form-data; name="file"; filename="file.zip"
--WebAppBoundary--
###测试链接数据库
POST http://localhost:8081/m/db/connect
POST {{baseUrl}}/m/db/connect
Content-Type: application/json
{
......@@ -48,7 +48,7 @@ Content-Type: application/json
###测试导入sql数据库文件
POST http://localhost:8081/db/init
POST {{baseUrl}}/db/init
Content-Type: application/json
{
......@@ -62,14 +62,14 @@ Content-Type: application/json
###测试导入sql数据库文件 form
POST http://localhost:8081/db/init
POST {{baseUrl}}/db/init
Content-Type: application/x-www-form-urlencoded
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
{
......@@ -78,7 +78,7 @@ Content-Type: application/json
###测试项目部署1
POST http://localhost:8081/project/distribute
POST {{baseUrl}}/project/distribute
Content-Type: application/json
{
......@@ -87,7 +87,7 @@ Content-Type: application/json
###测试项目部署2
POST http://localhost:8081/project/distribute
POST {{baseUrl}}/project/distribute
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