ntk-cms-api 1.2.240 → 1.2.242

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.
@@ -1688,11 +1688,16 @@ class ApiCmsServerBase extends ApiServerBase {
1688
1688
  const serviceName = 'ServiceGetOneById';
1689
1689
  const serviceNameKay = serviceName + '_' + id;
1690
1690
  if (this.getModuleCashService().includes(serviceName)) {
1691
- do {
1692
- if (this.cashApiIsValid(serviceNameKay))
1693
- return of(this.cachApiResult[serviceNameKay]);
1694
- } while (this.cachApiCallDate[serviceNameKay] && (new Date().getTime() - this.cachApiCallDate[serviceNameKay].getTime()) < this.cashApiSeconds);
1695
- this.cachApiCallDate[serviceNameKay] = new Date();
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;
1696
1701
  }
1697
1702
  //! optimaze call api
1698
1703
  // this.loadingStatus=true;
@@ -1707,6 +1712,7 @@ class ApiCmsServerBase extends ApiServerBase {
1707
1712
  if (this.getModuleCashService().includes(serviceName)) {
1708
1713
  this.cachApiResult[serviceNameKay] = ret;
1709
1714
  this.cachApiResult[serviceNameKay].dateResult = new Date();
1715
+ this.cachApiCallDate[serviceNameKay] = false;
1710
1716
  }
1711
1717
  //! optimaze call api
1712
1718
  return this.errorExceptionResultCheck(ret);
@@ -2159,13 +2165,16 @@ class CoreEnumService extends ApiServerBase {
2159
2165
  const serviceName = 'ServiceRecordStatusEnum';
2160
2166
  const serviceNameKay = serviceName;
2161
2167
  if (this.getModuleCashService().includes(serviceName)) {
2162
- if (this.cachApiResult[serviceNameKay]?.isSuccess)
2168
+ if (this.cashApiIsValid(serviceNameKay))
2163
2169
  return of(this.cachApiResult[serviceNameKay]);
2164
- while (this.cachApiCallDate[serviceNameKay] && (new Date().getTime() - this.cachApiCallDate[serviceNameKay].getTime()) < this.cashApiSeconds) {
2165
- if (this.cachApiResult[serviceNameKay]?.isSuccess)
2166
- 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
+ }
2167
2176
  }
2168
- this.cachApiCallDate[serviceNameKay] = new Date();
2177
+ this.cachApiCallDate[serviceNameKay] = true;
2169
2178
  }
2170
2179
  //! optimaze call api
2171
2180
  return this.http
@@ -2176,7 +2185,11 @@ class CoreEnumService extends ApiServerBase {
2176
2185
  // catchError(this.handleError)
2177
2186
  map((ret) => {
2178
2187
  //! optimaze call api
2179
- this.cachApiResult[serviceName] = ret;
2188
+ if (this.getModuleCashService().includes(serviceName)) {
2189
+ this.cachApiResult[serviceNameKay] = ret;
2190
+ this.cachApiResult[serviceNameKay].dateResult = new Date();
2191
+ this.cachApiCallDate[serviceNameKay] = false;
2192
+ }
2180
2193
  //! optimaze call api
2181
2194
  return this.errorExceptionResultCheck(ret);
2182
2195
  }));