ntk-cms-api 1.2.242 → 1.2.243

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.
@@ -1265,8 +1265,6 @@ class ApiServerBase {
1265
1265
  this.keyBaseUrl = 'baseUrl';
1266
1266
  this.accessLoad = false;
1267
1267
  this.cachApiResult = [];
1268
- this.cachApiCallDate = [];
1269
- this.cashApiSeconds = 5000;
1270
1268
  this.childConstructor();
1271
1269
  this.headers = new Map();
1272
1270
  }
@@ -1275,13 +1273,15 @@ class ApiServerBase {
1275
1273
  localStorage.setItem(this.keyBaseUrl, url);
1276
1274
  this.configApiRetry = apiRetry;
1277
1275
  }
1278
- cashApiIsValid(serviceNameKay) {
1279
- if (!this.cachApiResult[serviceNameKay])
1280
- return false;
1281
- if (!this.cachApiResult[serviceNameKay].isSuccess)
1282
- return true;
1283
- if (this.cachApiResult[serviceNameKay].dateResult && (new Date().getTime() - this.cachApiResult[serviceNameKay].dateResult) < this.cashApiSeconds)
1284
- return true;
1276
+ cashApiIsValid(serviceNameKay, cashApiSeconds) {
1277
+ if (cashApiSeconds > 0) {
1278
+ if (!this.cachApiResult[serviceNameKay])
1279
+ return false;
1280
+ if (!this.cachApiResult[serviceNameKay].isSuccess)
1281
+ return false;
1282
+ if (this.cachApiResult[serviceNameKay].dateResult && (new Date().getTime() - this.cachApiResult[serviceNameKay].dateResult) < cashApiSeconds)
1283
+ return true;
1284
+ }
1285
1285
  return false;
1286
1286
  }
1287
1287
  childConstructor() {
@@ -1297,9 +1297,6 @@ class ApiServerBase {
1297
1297
  getModuleControllerUrl() {
1298
1298
  return 'Empty';
1299
1299
  }
1300
- getModuleCashService() {
1301
- return [];
1302
- }
1303
1300
  setHeaders(key, value) {
1304
1301
  this.headers.set(key, value);
1305
1302
  }
@@ -1683,22 +1680,11 @@ class ApiCmsServerBase extends ApiServerBase {
1683
1680
  return this.errorExceptionResultCheck(ret);
1684
1681
  }));
1685
1682
  }
1686
- ServiceGetOneById(id) {
1683
+ ServiceGetOneById(id, cashApiSeconds) {
1687
1684
  //! optimaze call api
1688
- const serviceName = 'ServiceGetOneById';
1689
- const serviceNameKay = serviceName + '_' + id;
1690
- if (this.getModuleCashService().includes(serviceName)) {
1691
- if (this.cashApiIsValid(serviceNameKay))
1692
- return of(this.cachApiResult[serviceNameKay]);
1693
- if (this.cachApiCallDate[serviceNameKay]) {
1694
- const startDate = new Date();
1695
- while ((new Date().getTime() - startDate.getTime()) < this.cashApiSeconds) {
1696
- if (this.cashApiIsValid(serviceNameKay))
1697
- return of(this.cachApiResult[serviceNameKay]);
1698
- }
1699
- }
1700
- this.cachApiCallDate[serviceNameKay] = true;
1701
- }
1685
+ const serviceNameKay = 'ServiceGetOneById' + '_' + id;
1686
+ if (this.cashApiIsValid(serviceNameKay, cashApiSeconds))
1687
+ return of(this.cachApiResult[serviceNameKay]);
1702
1688
  //! optimaze call api
1703
1689
  // this.loadingStatus=true;
1704
1690
  return this.http
@@ -1709,10 +1695,9 @@ class ApiCmsServerBase extends ApiServerBase {
1709
1695
  // catchError(this.handleError)
1710
1696
  map((ret) => {
1711
1697
  //! optimaze call api
1712
- if (this.getModuleCashService().includes(serviceName)) {
1698
+ if (cashApiSeconds > 0) {
1713
1699
  this.cachApiResult[serviceNameKay] = ret;
1714
1700
  this.cachApiResult[serviceNameKay].dateResult = new Date();
1715
- this.cachApiCallDate[serviceNameKay] = false;
1716
1701
  }
1717
1702
  //! optimaze call api
1718
1703
  return this.errorExceptionResultCheck(ret);
@@ -2157,25 +2142,11 @@ class CoreEnumService extends ApiServerBase {
2157
2142
  getModuleControllerUrl() {
2158
2143
  return 'CoreEnum';
2159
2144
  }
2160
- getModuleCashService() {
2161
- return ['ServiceRecordStatusEnum'];
2162
- }
2163
- ServiceRecordStatusEnum() {
2145
+ ServiceRecordStatusEnum(cashApiSeconds) {
2164
2146
  //! optimaze call api
2165
- const serviceName = 'ServiceRecordStatusEnum';
2166
- const serviceNameKay = serviceName;
2167
- if (this.getModuleCashService().includes(serviceName)) {
2168
- if (this.cashApiIsValid(serviceNameKay))
2169
- return of(this.cachApiResult[serviceNameKay]);
2170
- if (this.cachApiCallDate[serviceNameKay]) {
2171
- const startDate = new Date();
2172
- while ((new Date().getTime() - startDate.getTime()) < this.cashApiSeconds) {
2173
- if (this.cashApiIsValid(serviceNameKay))
2174
- return of(this.cachApiResult[serviceNameKay]);
2175
- }
2176
- }
2177
- this.cachApiCallDate[serviceNameKay] = true;
2178
- }
2147
+ const serviceNameKay = 'ServiceRecordStatusEnum';
2148
+ if (this.cashApiIsValid(serviceNameKay, cashApiSeconds))
2149
+ return of(this.cachApiResult[serviceNameKay]);
2179
2150
  //! optimaze call api
2180
2151
  return this.http
2181
2152
  .get(this.getBaseUrl() + this.getModuleControllerUrl() + '/RecordStatusEnum', {
@@ -2185,10 +2156,9 @@ class CoreEnumService extends ApiServerBase {
2185
2156
  // catchError(this.handleError)
2186
2157
  map((ret) => {
2187
2158
  //! optimaze call api
2188
- if (this.getModuleCashService().includes(serviceName)) {
2159
+ if (cashApiSeconds > 0) {
2189
2160
  this.cachApiResult[serviceNameKay] = ret;
2190
2161
  this.cachApiResult[serviceNameKay].dateResult = new Date();
2191
- this.cachApiCallDate[serviceNameKay] = false;
2192
2162
  }
2193
2163
  //! optimaze call api
2194
2164
  return this.errorExceptionResultCheck(ret);
@@ -2813,9 +2783,6 @@ class CoreSiteService extends ApiCmsServerBase {
2813
2783
  getModuleControllerUrl() {
2814
2784
  return 'CoreSite';
2815
2785
  }
2816
- getModuleCashService() {
2817
- return ['ServiceGetOneById'];
2818
- }
2819
2786
  ServiceModuleDataOptimaze(linkSiteId) {
2820
2787
  return this.http
2821
2788
  .get(this.getBaseUrl() + this.getModuleControllerUrl() + '/DataOptimaze/' + linkSiteId, {
@@ -3076,9 +3043,6 @@ class CoreUserService extends ApiCmsServerBase {
3076
3043
  getModuleControllerUrl() {
3077
3044
  return 'CoreUser';
3078
3045
  }
3079
- getModuleCashService() {
3080
- return ['ServiceGetOneById'];
3081
- }
3082
3046
  ServiceGetRessellerChart(linkUserId) {
3083
3047
  return this.http
3084
3048
  .get(this.getBaseUrl() + this.getModuleControllerUrl() + '/GetRessellerChart/' + linkUserId, {