angular 应用程序的业务规则引擎
Business Rules Engine for angular Application
我目前正在设计一个销售应用程序 (Angular 6 + Bootstrap) 作为对其中一家电信运营商的响应式应用程序,我的系统用户超过 10K,他们正在访问系统每天同时进行销售活动,我有很多业务规则需要 运行 有时是顺序的,有时是并行的,有时是它的客户端业务规则,有时 运行 基于网络服务调用休息。
在另一个应用程序 (HTML5 & JQUERY) 中,我们使用了手动设计的动作链概念,链中的每个动作都将 HTML 元素作为输入并开始应用逻辑然后前进到下一个动作或失败并结束链。
我的问题是考虑到整个后端都是 RESTful 网络服务,如何在 Angular 链式概念应用程序中应用业务规则。?
一种实现您在示例场景中所说的检查的方法:
首先,我们假设规则 1、2 和 3 是独立的,应该平行检查:
请注意,在 Angular 中调用 API 的正确方法是通过 service。
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();
}
});
}
});
}
});
感谢您的支持..
我已经像 OOP 一样为我的 actions/validations 手动开发了它,并且 Angular 控制器将管理 运行 操作列表(如果存在)。
我目前正在设计一个销售应用程序 (Angular 6 + Bootstrap) 作为对其中一家电信运营商的响应式应用程序,我的系统用户超过 10K,他们正在访问系统每天同时进行销售活动,我有很多业务规则需要 运行 有时是顺序的,有时是并行的,有时是它的客户端业务规则,有时 运行 基于网络服务调用休息。
在另一个应用程序 (HTML5 & JQUERY) 中,我们使用了手动设计的动作链概念,链中的每个动作都将 HTML 元素作为输入并开始应用逻辑然后前进到下一个动作或失败并结束链。
我的问题是考虑到整个后端都是 RESTful 网络服务,如何在 Angular 链式概念应用程序中应用业务规则。?
一种实现您在示例场景中所说的检查的方法:
首先,我们假设规则 1、2 和 3 是独立的,应该平行检查:
请注意,在 Angular 中调用 API 的正确方法是通过 service。
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();
}
});
}
});
}
});
感谢您的支持..
我已经像 OOP 一样为我的 actions/validations 手动开发了它,并且 Angular 控制器将管理 运行 操作列表(如果存在)。