我有一个带登录页面的项目。在此页面上,用户点击"登录"后,我需要向checkUserName发送请求(检查我们是否有这样的用户并且他可以登录),然后才能进行身份验证。
在代码中我有这个:
接口:
@POST("endpoint")
Flowable<AccountResponse> auth(@Body AuthRequestBody authRequestBody);
@POST("endpoint")
Flowable<CheckUsernameResponse> checkUserName(@Body CheckUserNameRequest checkUserNameRequest);
RestService:
public Flowable<AccountResponse> auth(String login, String password) {
return api.auth(new AuthRequestBody(login, password)).compose(handleError());
}
public Flowable<CheckUsernameResponse> checkUserName(String login) {
return api.checkUserName(new CheckUserNameRequest(login)).compose(handleError());
}
和Rx:
public Flowable<AccountResponse> auth(String login, String password) {
return checkUsername(login).flatMap(checkUsernameResponse -> restService.auth(login, password))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnNext(loginResponse -> {
tokenManager.saveToken(loginResponse.getToken());
});
}
public Flowable<CheckUsernameResponse> checkUsername(String login) {
return restService.checkUserName(login)
.subscribeOn(Schedulers.io());
}
如果第一次查询没问题,我如何登记Rx? (checkUsername)。我的意思是,API没有返回错误信息,UserId没问题且isAccessGranted为真,然后才向auth发送第二个请求?
答案 0 :(得分:0)
在select NVL(TO_CHAR(APPROVER_EMPLOYEE_NAME), 'Grand Total') as EMPLOYEE_NAME,
SUM(COALESCE(ONE_DAY, 0)) one_day,
SUM(COALESCE(TWO_DAYS, 0)) TWO_DAYS ,
SUM(COALESCE(THREE_DAYS, 0)) THREE_DAYS,
SUM(COALESCE(ONE_DAY, 0) + COALESCE(TWO_DAYS, 0) + COALESCE(THREE_DAYS, 0)) TOTAL
from ic_request
group by rollup (APPROVER_EMPLOYEE_NAME);
内,您可以在返回新的flatMap
或发出错误之前自由地进行任何检查/验证。因此,为简洁起见,省略Scheduler注意事项,您可能会:
Flowable