reset 相当于java request/respond处理.
1 web vs web
this._restExec.queryRecentCall用于rest发送;
next用于rest响应处理
```
this._restExec.queryRecentCall(pCurDateTime.getTime().toString(_radix)).subscribe({
next: (data) => {
if (data.length > 0) {
this._clearRecentCallsDisabled = false;
} else {
this._clearRecentCallsDisabled = true;
}
}
```
2 web vs java
rest 形式(条件用?多个条件用&)
/rest/calllog/queries/id?start=1&limit=100
restlet框架实现从前端到后端的映射.
前端rest发给后台, 后端java @Post("json|form"),@Get("json")函数接收.
接收有两种形式form or json.
productA 是通过button ,submit 整体提交form(表单),
productB 通过post rest api作为输入,根本没有提交form,form中绑定的value也都没有,rest post一个body {“callType”:"ALL"},
同一个函数可以采用下面两个方式rest处理
handlePostAction(Form form)
handlePostAction(PojoRecentCallEntry recentCallEntry)
前台rest和后台交互就这两种套路: 接收 form or json
1 @Post("json|form") //ProductA
public Object createQuery(Form form)
{
// call type, default to ALL
// form submit 变成 json string。RestParameters 根据key callType,获取value
RecentCallType callType = RestParameters.callType.getValue(form,RecentCallType.ALL);
}
2 @Post("json|form") //ProductB
public Object createQuery(CallLogQueriesInput queriesInput)
{
RecentCallType valueCall = queriesInput.getCallType();
}
2.1 发送json, {"CallType":"NEWEST_ORDER"}
createQuery 用一个class的get的函数就可以取到 QueriesInput.getCallType()\
//define get/set interface
public class CallLogQueriesInput{
public RecentCallType getCallType() {
return callType;
}
public void setCallType(String callType) {
this.callType = RecentCallType.valueOf(callType);
}
}
//前端post json相当于setCallType
//后端直接通过getCallType获取value
@Post("json|form")
public Object createQuery(CallLogQueriesInput queriesInput) {
RecentCallType valueCall = queriesInput.getCallType();
}
2.2 注意json这种也可以用转成form获取传来的value
@Get("json")
public PojoRecentCallQueryOut<PojoRecentCallOut> getPojoRecentCallQuery() {
// json change to form parse
Form form = getReference().getQueryAsForm();
if (form != null)
{
//use form to get parameter
start = RestParameters.start.getValue(form, 1);
limit = RestParameters.limit.getValue(form, 1);
}
}