ntk-cms-api 1.2.228 → 1.2.230

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.
@@ -1264,6 +1264,7 @@ class ApiServerBase {
1264
1264
  this.keyDeviceToken = 'deviceToken';
1265
1265
  this.keyBaseUrl = 'baseUrl';
1266
1266
  this.accessLoad = false;
1267
+ this.cashApiSeconds = 20;
1267
1268
  this.childConstructor();
1268
1269
  this.headers = new Map();
1269
1270
  }
@@ -1285,6 +1286,9 @@ class ApiServerBase {
1285
1286
  getModuleControllerUrl() {
1286
1287
  return 'Empty';
1287
1288
  }
1289
+ getModuleCashService() {
1290
+ return [];
1291
+ }
1288
1292
  setHeaders(key, value) {
1289
1293
  this.headers.set(key, value);
1290
1294
  }
@@ -1669,6 +1673,17 @@ class ApiCmsServerBase extends ApiServerBase {
1669
1673
  }));
1670
1674
  }
1671
1675
  ServiceGetOneById(id) {
1676
+ //! optimaze call api
1677
+ const serviceName = 'ServiceRecordStatusEnum';
1678
+ const serviceNameKay = serviceName + '_' + id;
1679
+ if (this.getModuleCashService().includes(serviceName)) {
1680
+ do {
1681
+ if (this.cachApiResult[serviceNameKay]?.isSuccess)
1682
+ return of(this.cachApiResult[serviceNameKay]);
1683
+ } while (this.cachApiCallDate[serviceNameKay] && (new Date().getTime() - this.cachApiCallDate[serviceNameKay].getTime()) > this.cashApiSeconds);
1684
+ this.cachApiCallDate[serviceNameKay] = new Date();
1685
+ }
1686
+ //! optimaze call api
1672
1687
  // this.loadingStatus=true;
1673
1688
  return this.http
1674
1689
  .get(this.getBaseUrl() + this.getModuleControllerUrl() + '/' + id, {
@@ -1677,6 +1692,10 @@ class ApiCmsServerBase extends ApiServerBase {
1677
1692
  .pipe(retry(this.configApiRetry),
1678
1693
  // catchError(this.handleError)
1679
1694
  map((ret) => {
1695
+ //! optimaze call api
1696
+ if (this.getModuleCashService().includes(serviceName))
1697
+ this.cachApiResult[serviceNameKay] = ret;
1698
+ //! optimaze call api
1680
1699
  return this.errorExceptionResultCheck(ret);
1681
1700
  }));
1682
1701
  }
@@ -2121,12 +2140,12 @@ class CoreEnumService extends ApiServerBase {
2121
2140
  }
2122
2141
  ServiceRecordStatusEnum() {
2123
2142
  //! optimaze call api
2143
+ const serviceName = 'ServiceRecordStatusEnum';
2124
2144
  do {
2125
- if (this.serviceRecordStatusEnumLastResult?.isSuccess) {
2126
- return of(this.serviceRecordStatusEnumLastResult);
2127
- }
2128
- } while (this.serviceRecordStatusEnumInCall.getTime() - new Date().getTime() > 10);
2129
- this.serviceRecordStatusEnumInCall = new Date();
2145
+ if (this.cachApiResult[serviceName]?.isSuccess)
2146
+ return of(this.cachApiResult[serviceName]);
2147
+ } while (this.cachApiCallDate[serviceName] && (new Date().getTime() - this.cachApiCallDate[serviceName].getTime()) > this.cashApiSeconds);
2148
+ this.cachApiCallDate[serviceName] = new Date();
2130
2149
  //! optimaze call api
2131
2150
  return this.http
2132
2151
  .get(this.getBaseUrl() + this.getModuleControllerUrl() + '/RecordStatusEnum', {
@@ -2135,7 +2154,9 @@ class CoreEnumService extends ApiServerBase {
2135
2154
  .pipe(
2136
2155
  // catchError(this.handleError)
2137
2156
  map((ret) => {
2138
- this.serviceRecordStatusEnumLastResult = ret;
2157
+ //! optimaze call api
2158
+ this.cachApiResult[serviceName] = ret;
2159
+ //! optimaze call api
2139
2160
  return this.errorExceptionResultCheck(ret);
2140
2161
  }));
2141
2162
  }
@@ -2758,6 +2779,9 @@ class CoreSiteService extends ApiCmsServerBase {
2758
2779
  getModuleControllerUrl() {
2759
2780
  return 'CoreSite';
2760
2781
  }
2782
+ getModuleCashService() {
2783
+ return ['ServiceGetOneById'];
2784
+ }
2761
2785
  ServiceModuleDataOptimaze(linkSiteId) {
2762
2786
  return this.http
2763
2787
  .get(this.getBaseUrl() + this.getModuleControllerUrl() + '/DataOptimaze/' + linkSiteId, {
@@ -3018,6 +3042,9 @@ class CoreUserService extends ApiCmsServerBase {
3018
3042
  getModuleControllerUrl() {
3019
3043
  return 'CoreUser';
3020
3044
  }
3045
+ getModuleCashService() {
3046
+ return ['ServiceGetOneById'];
3047
+ }
3021
3048
  ServiceGetRessellerChart(linkUserId) {
3022
3049
  return this.http
3023
3050
  .get(this.getBaseUrl() + this.getModuleControllerUrl() + '/GetRessellerChart/' + linkUserId, {