REST

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);
		}
	}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值