我目前正在设计一个销售应用程序(Range6+ Bootstrap),它是一个针对电信运营商的响应应用程序,我的系统用户超过10K,每天访问系统进行销售活动,我有很多业务规则需要运行,有时是顺序的,有时是并行的,有时是客户端的业务规则,有时是基于web服务调用REST的。
在另一个应用程序(HTML5 & JQUERY)中,我们使用了手动设计的动作链概念,链中的每个动作都以HTML作为输入,并开始应用逻辑,然后转发到下一个动作或失败和结束链。
我的问题是,考虑到整个后端是RESTful web服务,如何将业务规则应用于链概念中的角应用中。
发布于 2018-05-27 09:57:50
谢谢你的支持..。
我已经像OOP一样手动开发了它,用于操作/验证,如果存在,角度控制器将管理运行操作列表。
发布于 2018-05-12 17:52:47
正如您在示例场景中所说的那样,实现检查的一种方法是:
首先,我们假定规则1、2和3是独立的,应该并行检查:
请注意,在角中调用API的正确方法是通过服务。
let checkNumber1 = this.http.post('https://example.com/api/checkNumber', { mobileNo: '0123920802' });
let checkNumber2 = this.http.post('https://example2.com/api/checkNumber', { mobileNo: '0123920802' });
let checkOutstanding = this.http.post('https://example.com/api/checkOutstanding', { userId: 23910231 });
forkJoin([checkNumber1, checkNumber2, checkOutstanding]).subscribe(results => {
// results[0] is our result from checkNumber1
// results[1] is our result from checkNumber2
// results[2] is our result from checkOutstanding
if (results[0] && results[1] && results[2]) {
// if all checks return true
proceed();
} else {
error();
}
});如果您想按顺序进行检查,一种可能的方法是:
checkNumber1.subscribe((result) => {
if (result) {
checkNumber2.subscribe((result) => {
if (result) {
checkOutstanding.subscribe((result) => {
if (result) {
proceed();
}
});
}
});
}
});https://stackoverflow.com/questions/50308168
复制相似问题