Commit c7837787 authored by chenyan's avatar chenyan

2024/05/09_API文档后台管理开发

parent 1ae0694d
...@@ -13,10 +13,14 @@ public class ApiCustomNodeVo { ...@@ -13,10 +13,14 @@ public class ApiCustomNodeVo {
private String method; private String method;
/** /**
* 主键自增ID * 请求参数id
*/ */
@Id private Integer paramId;
private Integer id;
/**
* 接口id
*/
private Integer nodeId;
/** /**
* api_doc主键ID * api_doc主键ID
......
...@@ -68,16 +68,14 @@ public class ApiCustomParamsBiz extends BaseBiz<ApiCustomParamsMapper, ApiCustom ...@@ -68,16 +68,14 @@ public class ApiCustomParamsBiz extends BaseBiz<ApiCustomParamsMapper, ApiCustom
return ObjectRestResponse.createFailedResult(ResultCode.EXIST_CODE, "API节点下已存在自定义参数"); return ObjectRestResponse.createFailedResult(ResultCode.EXIST_CODE, "API节点下已存在自定义参数");
} }
} }
Example exampleParams = new Example(ApiCustomParams.class); if (apiCustomParams.getId() != null) {
exampleParams.createCriteria() ApiCustomParams old = selectById(apiCustomParams.getId());
.andEqualTo("docId", apiCustomParams.getDocId()) if (old == null || old.getIsDel() == 1) {
.andEqualTo("nodeId", apiCustomParams.getNodeId()) return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, ResultCode.getMsg(ResultCode.NOTEXIST_CODE));
.andEqualTo("isDel",0); }
ApiCustomParams old = mapper.selectOneByExample(exampleParams);
if (old != null) {
BeanUtil.copyProperties(apiCustomParams, old, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true)); BeanUtil.copyProperties(apiCustomParams, old, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
updateSelectiveByIdRe(old); updateSelectiveByIdRe(old);
}else { } else {
insertSelectiveRe(apiCustomParams); insertSelectiveRe(apiCustomParams);
} }
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
...@@ -89,13 +87,6 @@ public class ApiCustomParamsBiz extends BaseBiz<ApiCustomParamsMapper, ApiCustom ...@@ -89,13 +87,6 @@ public class ApiCustomParamsBiz extends BaseBiz<ApiCustomParamsMapper, ApiCustom
return ObjectRestResponse.succ(pageDataVO); return ObjectRestResponse.succ(pageDataVO);
} }
public ObjectRestResponse getByNodeId(Integer id) {
Example exampleParams = new Example(ApiCustomParams.class);
exampleParams.createCriteria()
.andEqualTo("isDel",0)
.andEqualTo("nodeId", id);
return ObjectRestResponse.succ(mapper.selectOneByExample(exampleParams));
}
} }
......
...@@ -62,6 +62,7 @@ public class ApiDocBiz extends BaseBiz<ApiDocMapper, ApiDoc> { ...@@ -62,6 +62,7 @@ public class ApiDocBiz extends BaseBiz<ApiDocMapper, ApiDoc> {
List<ApiCustomNodeVo> nodeVos = nodeMapper.selectByExample(exampleNode).stream().map(apiCustomNode -> { List<ApiCustomNodeVo> nodeVos = nodeMapper.selectByExample(exampleNode).stream().map(apiCustomNode -> {
ApiCustomNodeVo nodeVoss = new ApiCustomNodeVo(); ApiCustomNodeVo nodeVoss = new ApiCustomNodeVo();
BeanUtils.copyProperties(apiCustomNode, nodeVoss); BeanUtils.copyProperties(apiCustomNode, nodeVoss);
nodeVoss.setNodeId(apiCustomNode.getId());
exampleParams.clear(); exampleParams.clear();
exampleParams.createCriteria() exampleParams.createCriteria()
.andEqualTo("nodeId", apiCustomNode.getId()) .andEqualTo("nodeId", apiCustomNode.getId())
...@@ -71,6 +72,7 @@ public class ApiDocBiz extends BaseBiz<ApiDocMapper, ApiDoc> { ...@@ -71,6 +72,7 @@ public class ApiDocBiz extends BaseBiz<ApiDocMapper, ApiDoc> {
if (Objects.isNull(params)) { if (Objects.isNull(params)) {
return nodeVoss; return nodeVoss;
} }
nodeVoss.setParamId(params.getId());
nodeVoss.setMethod(params.getMethod()); nodeVoss.setMethod(params.getMethod());
return nodeVoss; return nodeVoss;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
......
...@@ -14,7 +14,6 @@ import com.upyuns.platform.rs.website.entity.ApiCustomParams; ...@@ -14,7 +14,6 @@ import com.upyuns.platform.rs.website.entity.ApiCustomParams;
import com.upyuns.platform.rs.website.mapper.ApiCustomParamsMapper; import com.upyuns.platform.rs.website.mapper.ApiCustomParamsMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.entity.Example;
/** /**
* *
...@@ -39,7 +38,7 @@ public class ApiCustomParamsController extends BaseController<ApiCustomParamsBiz ...@@ -39,7 +38,7 @@ public class ApiCustomParamsController extends BaseController<ApiCustomParamsBiz
@GetMapping(value = "/detail") @GetMapping(value = "/detail")
public ObjectRestResponse detail(Integer id) { public ObjectRestResponse detail(Integer id) {
return baseBiz.getByNodeId(id); return ObjectRestResponse.succ(baseBiz.selectById(id));
} }
......
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