feat(uapbd): 添加 QuerySync 接口,用来根据type来调用不同的查询
- 新增 QuerySync 类,实现 /uapbd/querySync 查询接口 - 添加 query 方法处理 JSON 请求,支持不同的查询类型
This commit is contained in:
parent
756afff77e
commit
db45890e10
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding='gb2312'?>
|
||||||
|
<module>
|
||||||
|
<rest>
|
||||||
|
<resource classname="nccloud.api.uapbd.QuerySync" exinfo=""/>
|
||||||
|
</rest>
|
||||||
|
</module>
|
|
@ -0,0 +1,59 @@
|
||||||
|
package nccloud.api.uapbd;
|
||||||
|
|
||||||
|
|
||||||
|
import nccloud.api.rest.utils.IJsonForAPI;
|
||||||
|
import nccloud.api.rest.utils.JsonFactoryForAPI;
|
||||||
|
import nccloud.api.rest.utils.ResultMessageUtil;
|
||||||
|
import nccloud.api.rest.utils.vo.ApiDataVO;
|
||||||
|
import nccloud.api.rest.utils.vo.ApiQueryParam;
|
||||||
|
import nccloud.api.rest.utils.vo.ApiUfinterface;
|
||||||
|
import nccloud.ws.rest.resource.AbstractNCCRestResource;
|
||||||
|
import org.json.JSONString;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
|
||||||
|
@Path("/uapbd/querySync")
|
||||||
|
public class QuerySync extends AbstractNCCRestResource {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModule() {
|
||||||
|
return "uapbd";
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("query")
|
||||||
|
@Consumes({"application/json"})
|
||||||
|
@Produces({"application/json"})
|
||||||
|
public JSONString query(JSONString json) {
|
||||||
|
IJsonForAPI iJsonForAPI = JsonFactoryForAPI.create();
|
||||||
|
ApiQueryParam apiQueryParam = iJsonForAPI.fromJson(json.toJSONString(), ApiQueryParam.class);
|
||||||
|
ApiDataVO apiDataVO = apiQueryParam.getUfinterface().getData();
|
||||||
|
// 从中抓取接口枚举类型
|
||||||
|
ApiUfinterface ufinterface = apiQueryParam.getUfinterface();
|
||||||
|
if (ufinterface.getData().getParamdata().containsKey("type")) {
|
||||||
|
String type = (String) ufinterface.getData().getParamdata().get("type");
|
||||||
|
try {
|
||||||
|
switch (type) {
|
||||||
|
case "queryStordoc":
|
||||||
|
return queryStordoc(ufinterface);
|
||||||
|
default:
|
||||||
|
return ResultMessageUtil.exceptionToJSON(new Exception("不支持的接口类型: " + type));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 捕获并返回异常信息
|
||||||
|
return ResultMessageUtil.exceptionToJSON(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ResultMessageUtil.exceptionToJSON(new Exception("缺失接口类型,请检查参数"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private JSONString queryStordoc(ApiUfinterface apiUfinterface) {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue