ntk-cms-api 20.25.42 → 20.25.44

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.
@@ -1148,6 +1148,7 @@ class ApiServerBase {
1148
1148
  this.keyBaseVer = 'Ver';
1149
1149
  this.accessLoad = false;
1150
1150
  this.cachApiResult = [];
1151
+ this.apiCallStatusInRunResult = [];
1151
1152
  this.childConstructor();
1152
1153
  this.headers = new Map();
1153
1154
  }
@@ -1160,17 +1161,30 @@ class ApiServerBase {
1160
1161
  get Ver() {
1161
1162
  return localStorage.getItem(this.keyBaseVer) + '_';
1162
1163
  }
1163
- cashApiIsValid(serviceNameKay, cashApiSeconds = 0) {
1164
+ async cashApiIsValid(serviceNameKay, cashApiSeconds = 0) {
1164
1165
  if (cashApiSeconds > 0) {
1166
+ while (this.apiCallStatusInRunResult[serviceNameKay]?.getTime() >
1167
+ new Date().getTime() - 10000) {
1168
+ await new Promise((resolve) => setTimeout(resolve, 100));
1169
+ }
1165
1170
  if (!this.cachApiResult[serviceNameKay])
1166
1171
  return false;
1167
1172
  if (!this.cachApiResult[serviceNameKay].isSuccess)
1168
1173
  return false;
1169
- if (this.cachApiResult[serviceNameKay].dateResult && (new Date().getTime() - this.cachApiResult[serviceNameKay].dateResult) < cashApiSeconds)
1174
+ if (this.cachApiResult[serviceNameKay].dateResult &&
1175
+ new Date().getTime() - this.cachApiResult[serviceNameKay].dateResult <
1176
+ cashApiSeconds)
1170
1177
  return true;
1178
+ this.apiCallStatusInRunResult[serviceNameKay] = new Date();
1171
1179
  }
1172
1180
  return false;
1173
1181
  }
1182
+ async cashApiVlaueSet(serviceNameKay, ret) {
1183
+ this.cachApiResult[serviceNameKay] = ret;
1184
+ this.cachApiResult[serviceNameKay].dateResult = new Date();
1185
+ this.apiCallStatusInRunResult[serviceNameKay] = undefined;
1186
+ delete this.apiCallStatusInRunResult[serviceNameKay];
1187
+ }
1174
1188
  childConstructor() {
1175
1189
  // test
1176
1190
  }
@@ -1547,7 +1561,7 @@ class ApiCmsServerBase extends ApiServerBase {
1547
1561
  return ret;
1548
1562
  }));
1549
1563
  }
1550
- ServiceGetOneById(id, cashApiSeconds = 0) {
1564
+ async ServiceGetOneById(id, cashApiSeconds = 0) {
1551
1565
  //! optimaze call api
1552
1566
  const serviceNameKay = this.constructor.name + '_ServiceGetOneById_' + id;
1553
1567
  if (this.cashApiIsValid(serviceNameKay, cashApiSeconds))
@@ -1561,8 +1575,7 @@ class ApiCmsServerBase extends ApiServerBase {
1561
1575
  .pipe(retry(this.configApiRetry), map((ret) => {
1562
1576
  //! optimaze call api
1563
1577
  if (cashApiSeconds > 0) {
1564
- this.cachApiResult[serviceNameKay] = ret;
1565
- this.cachApiResult[serviceNameKay].dateResult = new Date();
1578
+ this.cashApiVlaueSet(serviceNameKay, ret);
1566
1579
  }
1567
1580
  //! optimaze call api
1568
1581
  return ret;
@@ -1582,7 +1595,7 @@ class ApiCmsServerBase extends ApiServerBase {
1582
1595
  return this.http
1583
1596
  .get(this.getBaseUrl() +
1584
1597
  this.getModuleControllerUrl() +
1585
- '/SetStatus/' +
1598
+ '/SetRecordStatus/' +
1586
1599
  id +
1587
1600
  '/' +
1588
1601
  recordStatus, {
@@ -1592,6 +1605,21 @@ class ApiCmsServerBase extends ApiServerBase {
1592
1605
  return ret;
1593
1606
  }));
1594
1607
  }
1608
+ ServiceSetAdminStatus(id, recordAdminStatus) {
1609
+ // this.loadingStatus=true;
1610
+ return this.http
1611
+ .get(this.getBaseUrl() +
1612
+ this.getModuleControllerUrl() +
1613
+ '/SetRecordAdminStatus/' +
1614
+ id +
1615
+ '/' +
1616
+ recordAdminStatus, {
1617
+ headers: this.getHeaders(),
1618
+ })
1619
+ .pipe(retry(this.configApiRetry), map((ret) => {
1620
+ return ret;
1621
+ }));
1622
+ }
1595
1623
  ServiceGetExist(model) {
1596
1624
  return this.http
1597
1625
  .post(this.getBaseUrl() + this.getModuleControllerUrl() + '/exist', model, {
@@ -1967,8 +1995,7 @@ class CoreEnumService extends ApiServerBase {
1967
1995
  .pipe(map((ret) => {
1968
1996
  //! optimaze call api
1969
1997
  if (cashApiSeconds > 0) {
1970
- this.cachApiResult[serviceNameKay] = ret;
1971
- this.cachApiResult[serviceNameKay].dateResult = new Date();
1998
+ this.cashApiVlaueSet(serviceNameKay, ret);
1972
1999
  }
1973
2000
  //! optimaze call api
1974
2001
  return ret;
@@ -1981,14 +2008,15 @@ class CoreEnumService extends ApiServerBase {
1981
2008
  return of(this.cachApiResult[serviceNameKay]);
1982
2009
  //! optimaze call api
1983
2010
  return this.http
1984
- .get(this.getBaseUrl() + this.getModuleControllerUrl() + '/RecordAdminStatusEnum', {
2011
+ .get(this.getBaseUrl() +
2012
+ this.getModuleControllerUrl() +
2013
+ '/RecordAdminStatusEnum', {
1985
2014
  headers: this.getHeaders(),
1986
2015
  })
1987
2016
  .pipe(map((ret) => {
1988
2017
  //! optimaze call api
1989
2018
  if (cashApiSeconds > 0) {
1990
- this.cachApiResult[serviceNameKay] = ret;
1991
- this.cachApiResult[serviceNameKay].dateResult = new Date();
2019
+ this.cashApiVlaueSet(serviceNameKay, ret);
1992
2020
  }
1993
2021
  //! optimaze call api
1994
2022
  return ret;