ntk-cms-api 20.25.54 → 20.25.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/ntk-cms-api.mjs +58 -49
- package/fesm2022/ntk-cms-api.mjs.map +1 -1
- package/index.d.ts +2 -1
- package/package.json +1 -1
package/fesm2022/ntk-cms-api.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import * as i1 from '@angular/common/http';
|
|
|
2
2
|
import { HttpClient } from '@angular/common/http';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
4
|
import { Inject, Injectable } from '@angular/core';
|
|
5
|
-
import { throwError, of, BehaviorSubject } from 'rxjs';
|
|
6
|
-
import { retry, map } from 'rxjs/operators';
|
|
5
|
+
import { throwError, from, of, BehaviorSubject } from 'rxjs';
|
|
6
|
+
import { retry, map, mergeMap } from 'rxjs/operators';
|
|
7
7
|
|
|
8
8
|
class AccessHelper {
|
|
9
9
|
AccessFieldsSet(access) {
|
|
@@ -1118,15 +1118,15 @@ class ApiServerBase {
|
|
|
1118
1118
|
get Ver() {
|
|
1119
1119
|
return localStorage.getItem(this.keyBaseVer) + '_';
|
|
1120
1120
|
}
|
|
1121
|
-
cashApiIsValid(serviceNameKay, cashApiSeconds = 0, runApiSeconds = 1000) {
|
|
1121
|
+
async cashApiIsValid(serviceNameKay, cashApiSeconds = 0, runApiSeconds = 1000) {
|
|
1122
1122
|
if (cashApiSeconds <= 0)
|
|
1123
1123
|
return false;
|
|
1124
|
-
|
|
1124
|
+
// wait asynchronously while another call is in-flight within the allowed window
|
|
1125
1125
|
while (this.cachApiInRunResult[serviceNameKay] &&
|
|
1126
1126
|
new Date().getTime() -
|
|
1127
1127
|
this.cachApiInRunResult[serviceNameKay]?.getTime() <
|
|
1128
1128
|
runApiSeconds) {
|
|
1129
|
-
|
|
1129
|
+
await this.delay(50);
|
|
1130
1130
|
}
|
|
1131
1131
|
if (this.cachApiResult[serviceNameKay]?.isSuccess === true &&
|
|
1132
1132
|
this.cachApiResult[serviceNameKay]?.dateResult &&
|
|
@@ -1267,6 +1267,9 @@ class ApiServerBase {
|
|
|
1267
1267
|
}
|
|
1268
1268
|
return throwError(errorMessage);
|
|
1269
1269
|
}
|
|
1270
|
+
delay(ms) {
|
|
1271
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1272
|
+
}
|
|
1270
1273
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: ApiServerBase, deps: [{ token: HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1271
1274
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: ApiServerBase }); }
|
|
1272
1275
|
}
|
|
@@ -1523,21 +1526,23 @@ class ApiCmsServerBase extends ApiServerBase {
|
|
|
1523
1526
|
ServiceGetOneById(id, cashApiSeconds = 0) {
|
|
1524
1527
|
//! optimaze call api
|
|
1525
1528
|
const serviceNameKay = this.constructor.name + '_ServiceGetOneById_' + id;
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
// this.loadingStatus=true;
|
|
1530
|
-
return this.http
|
|
1531
|
-
.get(this.getBaseUrl() + this.getModuleControllerUrl() + '/' + id, {
|
|
1532
|
-
headers: this.getHeaders(),
|
|
1533
|
-
})
|
|
1534
|
-
.pipe(retry(this.configApiRetry), map((ret) => {
|
|
1529
|
+
return from(this.cashApiIsValid(serviceNameKay, cashApiSeconds)).pipe(mergeMap((isValid) => {
|
|
1530
|
+
if (isValid)
|
|
1531
|
+
return of(this.cachApiResult[serviceNameKay]);
|
|
1535
1532
|
//! optimaze call api
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1533
|
+
// this.loadingStatus=true;
|
|
1534
|
+
return this.http
|
|
1535
|
+
.get(this.getBaseUrl() + this.getModuleControllerUrl() + '/' + id, {
|
|
1536
|
+
headers: this.getHeaders(),
|
|
1537
|
+
})
|
|
1538
|
+
.pipe(retry(this.configApiRetry), map((ret) => {
|
|
1539
|
+
//! optimaze call api
|
|
1540
|
+
if (cashApiSeconds > 0) {
|
|
1541
|
+
this.cashApiVlaueSet(serviceNameKay, ret);
|
|
1542
|
+
}
|
|
1543
|
+
//! optimaze call api
|
|
1544
|
+
return ret;
|
|
1545
|
+
}));
|
|
1541
1546
|
}));
|
|
1542
1547
|
}
|
|
1543
1548
|
ServiceGetCount(model) {
|
|
@@ -1944,41 +1949,45 @@ class CoreEnumService extends ApiServerBase {
|
|
|
1944
1949
|
ServiceRecordStatusEnum(cashApiSeconds = 0) {
|
|
1945
1950
|
//! optimaze call api
|
|
1946
1951
|
const serviceNameKay = 'ServiceRecordStatusEnum';
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1952
|
+
return from(this.cashApiIsValid(serviceNameKay, cashApiSeconds)).pipe(mergeMap((isValid) => {
|
|
1953
|
+
if (isValid)
|
|
1954
|
+
return of(this.cachApiResult[serviceNameKay]);
|
|
1955
|
+
return this.http
|
|
1956
|
+
.get(this.getBaseUrl() +
|
|
1957
|
+
this.getModuleControllerUrl() +
|
|
1958
|
+
'/RecordStatusEnum', {
|
|
1959
|
+
headers: this.getHeaders(),
|
|
1960
|
+
})
|
|
1961
|
+
.pipe(map((ret) => {
|
|
1962
|
+
//! optimaze call api
|
|
1963
|
+
if (cashApiSeconds > 0) {
|
|
1964
|
+
this.cashApiVlaueSet(serviceNameKay, ret);
|
|
1965
|
+
}
|
|
1966
|
+
//! optimaze call api
|
|
1967
|
+
return ret;
|
|
1968
|
+
}));
|
|
1961
1969
|
}));
|
|
1962
1970
|
}
|
|
1963
1971
|
ServiceRecordAdminStatusEnum(cashApiSeconds = 0) {
|
|
1964
1972
|
//! optimaze call api
|
|
1965
1973
|
const serviceNameKay = 'ServiceRecordAdminStatusEnum';
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1974
|
+
return from(this.cashApiIsValid(serviceNameKay, cashApiSeconds)).pipe(mergeMap((isValid) => {
|
|
1975
|
+
if (isValid)
|
|
1976
|
+
return of(this.cachApiResult[serviceNameKay]);
|
|
1977
|
+
return this.http
|
|
1978
|
+
.get(this.getBaseUrl() +
|
|
1979
|
+
this.getModuleControllerUrl() +
|
|
1980
|
+
'/RecordAdminStatusEnum', {
|
|
1981
|
+
headers: this.getHeaders(),
|
|
1982
|
+
})
|
|
1983
|
+
.pipe(map((ret) => {
|
|
1984
|
+
//! optimaze call api
|
|
1985
|
+
if (cashApiSeconds > 0) {
|
|
1986
|
+
this.cashApiVlaueSet(serviceNameKay, ret);
|
|
1987
|
+
}
|
|
1988
|
+
//! optimaze call api
|
|
1989
|
+
return ret;
|
|
1990
|
+
}));
|
|
1982
1991
|
}));
|
|
1983
1992
|
}
|
|
1984
1993
|
ServiceLocationTypeEnum() {
|