@azteam/express 1.2.394 → 1.2.396

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.
@@ -46,18 +46,20 @@ var AdminController = /*#__PURE__*/function (_Controller) {
46
46
  var pathName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
47
47
  _classCallCheck(this, AdminController);
48
48
  _this = _super.call(this, repository, pathName);
49
- _defineProperty(_assertThisInitialized(_this), "methodGetPaginate", /*#__PURE__*/function () {
49
+ _defineProperty(_assertThisInitialized(_this), "methodGetAll", /*#__PURE__*/function () {
50
50
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, res) {
51
- var paginateData;
51
+ var data;
52
52
  return _regeneratorRuntime().wrap(function _callee$(_context) {
53
53
  while (1) {
54
54
  switch (_context.prev = _context.next) {
55
55
  case 0:
56
56
  _context.next = 2;
57
- return _this.repository.find(req.query, req.paginate);
57
+ return _this.repository.findAll(req.query, {
58
+ limit: 2000
59
+ });
58
60
  case 2:
59
- paginateData = _context.sent;
60
- return _context.abrupt("return", res.success(paginateData, _this.guardResponse, _this.allowResponse));
61
+ data = _context.sent;
62
+ return _context.abrupt("return", res.success(data, _this.guardResponse, _this.allowResponse));
61
63
  case 4:
62
64
  case "end":
63
65
  return _context.stop();
@@ -69,7 +71,7 @@ var AdminController = /*#__PURE__*/function (_Controller) {
69
71
  return _ref.apply(this, arguments);
70
72
  };
71
73
  }());
72
- _defineProperty(_assertThisInitialized(_this), "methodGetPaginateTrash", /*#__PURE__*/function () {
74
+ _defineProperty(_assertThisInitialized(_this), "methodGetPaginate", /*#__PURE__*/function () {
73
75
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(req, res) {
74
76
  var paginateData;
75
77
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
@@ -77,7 +79,7 @@ var AdminController = /*#__PURE__*/function (_Controller) {
77
79
  switch (_context2.prev = _context2.next) {
78
80
  case 0:
79
81
  _context2.next = 2;
80
- return _this.repository.findTrash(req.query, req.paginate);
82
+ return _this.repository.find(req.query, req.paginate);
81
83
  case 2:
82
84
  paginateData = _context2.sent;
83
85
  return _context2.abrupt("return", res.success(paginateData, _this.guardResponse, _this.allowResponse));
@@ -92,25 +94,19 @@ var AdminController = /*#__PURE__*/function (_Controller) {
92
94
  return _ref2.apply(this, arguments);
93
95
  };
94
96
  }());
95
- _defineProperty(_assertThisInitialized(_this), "methodGetOne", /*#__PURE__*/function () {
97
+ _defineProperty(_assertThisInitialized(_this), "methodGetPaginateTrash", /*#__PURE__*/function () {
96
98
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(req, res) {
97
- var item;
99
+ var paginateData;
98
100
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
99
101
  while (1) {
100
102
  switch (_context3.prev = _context3.next) {
101
103
  case 0:
102
104
  _context3.next = 2;
103
- return _this.repository.findOneById(req.params.id);
105
+ return _this.repository.findTrash(req.query, req.paginate);
104
106
  case 2:
105
- item = _context3.sent;
106
- if (item) {
107
- _context3.next = 5;
108
- break;
109
- }
110
- return _context3.abrupt("return", res.error(_error.NOT_EXISTS));
111
- case 5:
112
- return _context3.abrupt("return", res.success(item, _this.guardResponse, _this.allowResponse));
113
- case 6:
107
+ paginateData = _context3.sent;
108
+ return _context3.abrupt("return", res.success(paginateData, _this.guardResponse, _this.allowResponse));
109
+ case 4:
114
110
  case "end":
115
111
  return _context3.stop();
116
112
  }
@@ -121,7 +117,7 @@ var AdminController = /*#__PURE__*/function (_Controller) {
121
117
  return _ref3.apply(this, arguments);
122
118
  };
123
119
  }());
124
- _defineProperty(_assertThisInitialized(_this), "methodGetOneTrash", /*#__PURE__*/function () {
120
+ _defineProperty(_assertThisInitialized(_this), "methodGetOne", /*#__PURE__*/function () {
125
121
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(req, res) {
126
122
  var item;
127
123
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
@@ -129,7 +125,7 @@ var AdminController = /*#__PURE__*/function (_Controller) {
129
125
  switch (_context4.prev = _context4.next) {
130
126
  case 0:
131
127
  _context4.next = 2;
132
- return _this.repository.findOneTrashById(req.params.id);
128
+ return _this.repository.findOneById(req.params.id);
133
129
  case 2:
134
130
  item = _context4.sent;
135
131
  if (item) {
@@ -150,14 +146,25 @@ var AdminController = /*#__PURE__*/function (_Controller) {
150
146
  return _ref4.apply(this, arguments);
151
147
  };
152
148
  }());
153
- _defineProperty(_assertThisInitialized(_this), "methodPostCreate", /*#__PURE__*/function () {
154
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(data, user) {
149
+ _defineProperty(_assertThisInitialized(_this), "methodGetOneTrash", /*#__PURE__*/function () {
150
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(req, res) {
151
+ var item;
155
152
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
156
153
  while (1) {
157
154
  switch (_context5.prev = _context5.next) {
158
155
  case 0:
159
- return _context5.abrupt("return", _this.repository.createByUser(user.id, data));
160
- case 1:
156
+ _context5.next = 2;
157
+ return _this.repository.findOneTrashById(req.params.id);
158
+ case 2:
159
+ item = _context5.sent;
160
+ if (item) {
161
+ _context5.next = 5;
162
+ break;
163
+ }
164
+ return _context5.abrupt("return", res.error(_error.NOT_EXISTS));
165
+ case 5:
166
+ return _context5.abrupt("return", res.success(item, _this.guardResponse, _this.allowResponse));
167
+ case 6:
161
168
  case "end":
162
169
  return _context5.stop();
163
170
  }
@@ -168,13 +175,13 @@ var AdminController = /*#__PURE__*/function (_Controller) {
168
175
  return _ref5.apply(this, arguments);
169
176
  };
170
177
  }());
171
- _defineProperty(_assertThisInitialized(_this), "methodPutModify", /*#__PURE__*/function () {
172
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(item, data, user) {
178
+ _defineProperty(_assertThisInitialized(_this), "methodPostCreate", /*#__PURE__*/function () {
179
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(data, user) {
173
180
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
174
181
  while (1) {
175
182
  switch (_context6.prev = _context6.next) {
176
183
  case 0:
177
- return _context6.abrupt("return", item.modify(data, user.id));
184
+ return _context6.abrupt("return", _this.repository.createByUser(user.id, data));
178
185
  case 1:
179
186
  case "end":
180
187
  return _context6.stop();
@@ -182,46 +189,29 @@ var AdminController = /*#__PURE__*/function (_Controller) {
182
189
  }
183
190
  }, _callee6);
184
191
  }));
185
- return function (_x11, _x12, _x13) {
192
+ return function (_x11, _x12) {
186
193
  return _ref6.apply(this, arguments);
187
194
  };
188
195
  }());
189
- _defineProperty(_assertThisInitialized(_this), "methodDelete", /*#__PURE__*/function () {
190
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(req, res) {
191
- var item;
196
+ _defineProperty(_assertThisInitialized(_this), "methodPutModify", /*#__PURE__*/function () {
197
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(item, data, user) {
192
198
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
193
199
  while (1) {
194
200
  switch (_context7.prev = _context7.next) {
195
201
  case 0:
196
- _context7.next = 2;
197
- return _this.repository.findOneById(req.params.id);
198
- case 2:
199
- item = _context7.sent;
200
- if (item) {
201
- _context7.next = 5;
202
- break;
203
- }
204
- return _context7.abrupt("return", res.error(_error.NOT_EXISTS));
205
- case 5:
206
- _context7.next = 7;
207
- return item["delete"](req.user.id);
208
- case 7:
209
- _context7.next = 9;
210
- return _this.afterDelete(item);
211
- case 9:
212
- return _context7.abrupt("return", res.success(true));
213
- case 10:
202
+ return _context7.abrupt("return", item.modify(data, user.id));
203
+ case 1:
214
204
  case "end":
215
205
  return _context7.stop();
216
206
  }
217
207
  }
218
208
  }, _callee7);
219
209
  }));
220
- return function (_x14, _x15) {
210
+ return function (_x13, _x14, _x15) {
221
211
  return _ref7.apply(this, arguments);
222
212
  };
223
213
  }());
224
- _defineProperty(_assertThisInitialized(_this), "methodPostRestoreTrash", /*#__PURE__*/function () {
214
+ _defineProperty(_assertThisInitialized(_this), "methodDelete", /*#__PURE__*/function () {
225
215
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(req, res) {
226
216
  var item;
227
217
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
@@ -229,7 +219,7 @@ var AdminController = /*#__PURE__*/function (_Controller) {
229
219
  switch (_context8.prev = _context8.next) {
230
220
  case 0:
231
221
  _context8.next = 2;
232
- return _this.repository.findOneTrashById(req.params.id);
222
+ return _this.repository.findOneById(req.params.id);
233
223
  case 2:
234
224
  item = _context8.sent;
235
225
  if (item) {
@@ -239,10 +229,13 @@ var AdminController = /*#__PURE__*/function (_Controller) {
239
229
  return _context8.abrupt("return", res.error(_error.NOT_EXISTS));
240
230
  case 5:
241
231
  _context8.next = 7;
242
- return item.restore(req.user.id);
232
+ return item["delete"](req.user.id);
243
233
  case 7:
234
+ _context8.next = 9;
235
+ return _this.afterDelete(item);
236
+ case 9:
244
237
  return _context8.abrupt("return", res.success(true));
245
- case 8:
238
+ case 10:
246
239
  case "end":
247
240
  return _context8.stop();
248
241
  }
@@ -253,44 +246,76 @@ var AdminController = /*#__PURE__*/function (_Controller) {
253
246
  return _ref8.apply(this, arguments);
254
247
  };
255
248
  }());
256
- _defineProperty(_assertThisInitialized(_this), "methodDeleteDestroyTrash", /*#__PURE__*/function () {
249
+ _defineProperty(_assertThisInitialized(_this), "methodPostRestoreTrash", /*#__PURE__*/function () {
257
250
  var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(req, res) {
258
- var item, oldItem;
251
+ var item;
259
252
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
260
253
  while (1) {
261
254
  switch (_context9.prev = _context9.next) {
262
255
  case 0:
263
256
  _context9.next = 2;
257
+ return _this.repository.findOneTrashById(req.params.id);
258
+ case 2:
259
+ item = _context9.sent;
260
+ if (item) {
261
+ _context9.next = 5;
262
+ break;
263
+ }
264
+ return _context9.abrupt("return", res.error(_error.NOT_EXISTS));
265
+ case 5:
266
+ _context9.next = 7;
267
+ return item.restore(req.user.id);
268
+ case 7:
269
+ return _context9.abrupt("return", res.success(true));
270
+ case 8:
271
+ case "end":
272
+ return _context9.stop();
273
+ }
274
+ }
275
+ }, _callee9);
276
+ }));
277
+ return function (_x18, _x19) {
278
+ return _ref9.apply(this, arguments);
279
+ };
280
+ }());
281
+ _defineProperty(_assertThisInitialized(_this), "methodDeleteDestroyTrash", /*#__PURE__*/function () {
282
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(req, res) {
283
+ var item, oldItem;
284
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
285
+ while (1) {
286
+ switch (_context10.prev = _context10.next) {
287
+ case 0:
288
+ _context10.next = 2;
264
289
  return _this.repository.findOne({
265
290
  _id: req.params.id
266
291
  }, {
267
292
  force: true
268
293
  });
269
294
  case 2:
270
- item = _context9.sent;
295
+ item = _context10.sent;
271
296
  if (item) {
272
- _context9.next = 5;
297
+ _context10.next = 5;
273
298
  break;
274
299
  }
275
- return _context9.abrupt("return", res.error(_error.NOT_EXISTS));
300
+ return _context10.abrupt("return", res.error(_error.NOT_EXISTS));
276
301
  case 5:
277
302
  oldItem = _lodash["default"].cloneDeep(item);
278
- _context9.next = 8;
303
+ _context10.next = 8;
279
304
  return _this.repository.destroy(item.id);
280
305
  case 8:
281
- _context9.next = 10;
306
+ _context10.next = 10;
282
307
  return _this.afterDestroy(oldItem);
283
308
  case 10:
284
- return _context9.abrupt("return", res.success(true));
309
+ return _context10.abrupt("return", res.success(true));
285
310
  case 11:
286
311
  case "end":
287
- return _context9.stop();
312
+ return _context10.stop();
288
313
  }
289
314
  }
290
- }, _callee9);
315
+ }, _callee10);
291
316
  }));
292
- return function (_x18, _x19) {
293
- return _ref9.apply(this, arguments);
317
+ return function (_x20, _x21) {
318
+ return _ref10.apply(this, arguments);
294
319
  };
295
320
  }());
296
321
  _this.roles = _objectSpread({
@@ -325,6 +350,15 @@ var AdminController = /*#__PURE__*/function (_Controller) {
325
350
  return _this;
326
351
  }
327
352
  _createClass(AdminController, [{
353
+ key: "getAll",
354
+ value: function getAll() {
355
+ return {
356
+ disabled: !this.roles.READ,
357
+ path: '/all',
358
+ method: [(0, _middleware.adminRoleMiddleware)([this.roles.READ], this.roleMiddlewareOptions), this.methodGetAll]
359
+ };
360
+ }
361
+ }, {
328
362
  key: "getPaginate",
329
363
  value: function getPaginate() {
330
364
  return {
@@ -363,20 +397,20 @@ var AdminController = /*#__PURE__*/function (_Controller) {
363
397
  }, {
364
398
  key: "beforeCreate",
365
399
  value: function () {
366
- var _beforeCreate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(data) {
367
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
400
+ var _beforeCreate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(data) {
401
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
368
402
  while (1) {
369
- switch (_context10.prev = _context10.next) {
403
+ switch (_context11.prev = _context11.next) {
370
404
  case 0:
371
- return _context10.abrupt("return", data);
405
+ return _context11.abrupt("return", data);
372
406
  case 1:
373
407
  case "end":
374
- return _context10.stop();
408
+ return _context11.stop();
375
409
  }
376
410
  }
377
- }, _callee10);
411
+ }, _callee11);
378
412
  }));
379
- function beforeCreate(_x20) {
413
+ function beforeCreate(_x22) {
380
414
  return _beforeCreate.apply(this, arguments);
381
415
  }
382
416
  return beforeCreate;
@@ -384,20 +418,20 @@ var AdminController = /*#__PURE__*/function (_Controller) {
384
418
  }, {
385
419
  key: "afterCreate",
386
420
  value: function () {
387
- var _afterCreate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(item) {
388
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
421
+ var _afterCreate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(item) {
422
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
389
423
  while (1) {
390
- switch (_context11.prev = _context11.next) {
424
+ switch (_context12.prev = _context12.next) {
391
425
  case 0:
392
- return _context11.abrupt("return", item);
426
+ return _context12.abrupt("return", item);
393
427
  case 1:
394
428
  case "end":
395
- return _context11.stop();
429
+ return _context12.stop();
396
430
  }
397
431
  }
398
- }, _callee11);
432
+ }, _callee12);
399
433
  }));
400
- function afterCreate(_x21) {
434
+ function afterCreate(_x23) {
401
435
  return _afterCreate.apply(this, arguments);
402
436
  }
403
437
  return afterCreate;
@@ -410,34 +444,34 @@ var AdminController = /*#__PURE__*/function (_Controller) {
410
444
  disabled: !this.roles.CREATE,
411
445
  path: '/',
412
446
  method: [(0, _middleware.adminRoleMiddleware)([this.roles.CREATE], this.roleMiddlewareOptions), /*#__PURE__*/function () {
413
- var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(req, res) {
447
+ var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(req, res) {
414
448
  var data, item;
415
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
449
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
416
450
  while (1) {
417
- switch (_context12.prev = _context12.next) {
451
+ switch (_context13.prev = _context13.next) {
418
452
  case 0:
419
- _context12.next = 2;
453
+ _context13.next = 2;
420
454
  return _this2.beforeCreate(req.body);
421
455
  case 2:
422
- data = _context12.sent;
423
- _context12.next = 5;
456
+ data = _context13.sent;
457
+ _context13.next = 5;
424
458
  return _this2.methodPostCreate(data, req.user);
425
459
  case 5:
426
- item = _context12.sent;
427
- _context12.next = 8;
460
+ item = _context13.sent;
461
+ _context13.next = 8;
428
462
  return _this2.afterCreate(item);
429
463
  case 8:
430
- item = _context12.sent;
431
- return _context12.abrupt("return", res.success(item, _this2.guardResponse, _this2.allowResponse));
464
+ item = _context13.sent;
465
+ return _context13.abrupt("return", res.success(item, _this2.guardResponse, _this2.allowResponse));
432
466
  case 10:
433
467
  case "end":
434
- return _context12.stop();
468
+ return _context13.stop();
435
469
  }
436
470
  }
437
- }, _callee12);
471
+ }, _callee13);
438
472
  }));
439
- return function (_x22, _x23) {
440
- return _ref10.apply(this, arguments);
473
+ return function (_x24, _x25) {
474
+ return _ref11.apply(this, arguments);
441
475
  };
442
476
  }()]
443
477
  };
@@ -445,20 +479,20 @@ var AdminController = /*#__PURE__*/function (_Controller) {
445
479
  }, {
446
480
  key: "beforeModify",
447
481
  value: function () {
448
- var _beforeModify = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(data) {
449
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
482
+ var _beforeModify = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(data) {
483
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
450
484
  while (1) {
451
- switch (_context13.prev = _context13.next) {
485
+ switch (_context14.prev = _context14.next) {
452
486
  case 0:
453
- return _context13.abrupt("return", data);
487
+ return _context14.abrupt("return", data);
454
488
  case 1:
455
489
  case "end":
456
- return _context13.stop();
490
+ return _context14.stop();
457
491
  }
458
492
  }
459
- }, _callee13);
493
+ }, _callee14);
460
494
  }));
461
- function beforeModify(_x24) {
495
+ function beforeModify(_x26) {
462
496
  return _beforeModify.apply(this, arguments);
463
497
  }
464
498
  return beforeModify;
@@ -466,20 +500,20 @@ var AdminController = /*#__PURE__*/function (_Controller) {
466
500
  }, {
467
501
  key: "afterModify",
468
502
  value: function () {
469
- var _afterModify = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(item) {
470
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
503
+ var _afterModify = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(item) {
504
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
471
505
  while (1) {
472
- switch (_context14.prev = _context14.next) {
506
+ switch (_context15.prev = _context15.next) {
473
507
  case 0:
474
- return _context14.abrupt("return", item);
508
+ return _context15.abrupt("return", item);
475
509
  case 1:
476
510
  case "end":
477
- return _context14.stop();
511
+ return _context15.stop();
478
512
  }
479
513
  }
480
- }, _callee14);
514
+ }, _callee15);
481
515
  }));
482
- function afterModify(_x25) {
516
+ function afterModify(_x27) {
483
517
  return _afterModify.apply(this, arguments);
484
518
  }
485
519
  return afterModify;
@@ -492,41 +526,41 @@ var AdminController = /*#__PURE__*/function (_Controller) {
492
526
  disabled: !this.roles.UPDATE,
493
527
  path: '/:id([a-zA-Z0-9]+)',
494
528
  method: [(0, _middleware.adminRoleMiddleware)([this.roles.UPDATE], this.roleMiddlewareOptions), (0, _middleware.validateMiddleware)(_constant.REQUEST_TYPE.PARAMS, _validator.rulesId), /*#__PURE__*/function () {
495
- var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(req, res) {
529
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(req, res) {
496
530
  var item, data;
497
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
531
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
498
532
  while (1) {
499
- switch (_context15.prev = _context15.next) {
533
+ switch (_context16.prev = _context16.next) {
500
534
  case 0:
501
- _context15.next = 2;
535
+ _context16.next = 2;
502
536
  return _this3.repository.findOneById(req.params.id);
503
537
  case 2:
504
- item = _context15.sent;
538
+ item = _context16.sent;
505
539
  if (item) {
506
- _context15.next = 5;
540
+ _context16.next = 5;
507
541
  break;
508
542
  }
509
- return _context15.abrupt("return", res.error(_error.NOT_EXISTS));
543
+ return _context16.abrupt("return", res.error(_error.NOT_EXISTS));
510
544
  case 5:
511
- _context15.next = 7;
545
+ _context16.next = 7;
512
546
  return _this3.beforeModify(req.body);
513
547
  case 7:
514
- data = _context15.sent;
548
+ data = _context16.sent;
515
549
  item = _this3.methodPutModify(item, data, req.user);
516
- _context15.next = 11;
550
+ _context16.next = 11;
517
551
  return _this3.afterModify(item);
518
552
  case 11:
519
- item = _context15.sent;
520
- return _context15.abrupt("return", res.success(item, _this3.guardResponse, _this3.allowResponse));
553
+ item = _context16.sent;
554
+ return _context16.abrupt("return", res.success(item, _this3.guardResponse, _this3.allowResponse));
521
555
  case 13:
522
556
  case "end":
523
- return _context15.stop();
557
+ return _context16.stop();
524
558
  }
525
559
  }
526
- }, _callee15);
560
+ }, _callee16);
527
561
  }));
528
- return function (_x26, _x27) {
529
- return _ref11.apply(this, arguments);
562
+ return function (_x28, _x29) {
563
+ return _ref12.apply(this, arguments);
530
564
  };
531
565
  }()]
532
566
  };
@@ -539,39 +573,39 @@ var AdminController = /*#__PURE__*/function (_Controller) {
539
573
  disabled: !this.roles.UPDATE,
540
574
  path: '/available/:id([a-zA-Z0-9]+)',
541
575
  method: [(0, _middleware.adminRoleMiddleware)([this.roles.UPDATE], this.roleMiddlewareOptions), (0, _middleware.validateMiddleware)(_constant.REQUEST_TYPE.PARAMS, _validator.rulesId), /*#__PURE__*/function () {
542
- var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(req, res) {
576
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(req, res) {
543
577
  var item;
544
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
578
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
545
579
  while (1) {
546
- switch (_context16.prev = _context16.next) {
580
+ switch (_context17.prev = _context17.next) {
547
581
  case 0:
548
- _context16.next = 2;
582
+ _context17.next = 2;
549
583
  return _this4.repository.findOneById(req.params.id);
550
584
  case 2:
551
- item = _context16.sent;
585
+ item = _context17.sent;
552
586
  if (item) {
553
- _context16.next = 5;
587
+ _context17.next = 5;
554
588
  break;
555
589
  }
556
- return _context16.abrupt("return", res.error(_error.NOT_EXISTS));
590
+ return _context17.abrupt("return", res.error(_error.NOT_EXISTS));
557
591
  case 5:
558
- _context16.next = 7;
592
+ _context17.next = 7;
559
593
  return item.modifyStatusAvailable(req.user.id);
560
594
  case 7:
561
- _context16.next = 9;
595
+ _context17.next = 9;
562
596
  return _this4.afterModify(item);
563
597
  case 9:
564
- item = _context16.sent;
565
- return _context16.abrupt("return", res.success(item, _this4.guardResponse, _this4.allowResponse));
598
+ item = _context17.sent;
599
+ return _context17.abrupt("return", res.success(item, _this4.guardResponse, _this4.allowResponse));
566
600
  case 11:
567
601
  case "end":
568
- return _context16.stop();
602
+ return _context17.stop();
569
603
  }
570
604
  }
571
- }, _callee16);
605
+ }, _callee17);
572
606
  }));
573
- return function (_x28, _x29) {
574
- return _ref12.apply(this, arguments);
607
+ return function (_x30, _x31) {
608
+ return _ref13.apply(this, arguments);
575
609
  };
576
610
  }()]
577
611
  };
@@ -584,39 +618,39 @@ var AdminController = /*#__PURE__*/function (_Controller) {
584
618
  disabled: !this.roles.UPDATE,
585
619
  path: '/unavailable/:id([a-zA-Z0-9]+)',
586
620
  method: [(0, _middleware.adminRoleMiddleware)([this.roles.UPDATE], this.roleMiddlewareOptions), (0, _middleware.validateMiddleware)(_constant.REQUEST_TYPE.PARAMS, _validator.rulesId), /*#__PURE__*/function () {
587
- var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(req, res) {
621
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(req, res) {
588
622
  var item;
589
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
623
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
590
624
  while (1) {
591
- switch (_context17.prev = _context17.next) {
625
+ switch (_context18.prev = _context18.next) {
592
626
  case 0:
593
- _context17.next = 2;
627
+ _context18.next = 2;
594
628
  return _this5.repository.findOneById(req.params.id);
595
629
  case 2:
596
- item = _context17.sent;
630
+ item = _context18.sent;
597
631
  if (item) {
598
- _context17.next = 5;
632
+ _context18.next = 5;
599
633
  break;
600
634
  }
601
- return _context17.abrupt("return", res.error(_error.NOT_EXISTS));
635
+ return _context18.abrupt("return", res.error(_error.NOT_EXISTS));
602
636
  case 5:
603
- _context17.next = 7;
637
+ _context18.next = 7;
604
638
  return item.modifyStatusUnavailable(req.body.message, req.user.id);
605
639
  case 7:
606
- _context17.next = 9;
640
+ _context18.next = 9;
607
641
  return _this5.afterModify(item);
608
642
  case 9:
609
- item = _context17.sent;
610
- return _context17.abrupt("return", res.success(item, _this5.guardResponse, _this5.allowResponse));
643
+ item = _context18.sent;
644
+ return _context18.abrupt("return", res.success(item, _this5.guardResponse, _this5.allowResponse));
611
645
  case 11:
612
646
  case "end":
613
- return _context17.stop();
647
+ return _context18.stop();
614
648
  }
615
649
  }
616
- }, _callee17);
650
+ }, _callee18);
617
651
  }));
618
- return function (_x30, _x31) {
619
- return _ref13.apply(this, arguments);
652
+ return function (_x32, _x33) {
653
+ return _ref14.apply(this, arguments);
620
654
  };
621
655
  }()]
622
656
  };
@@ -629,39 +663,39 @@ var AdminController = /*#__PURE__*/function (_Controller) {
629
663
  disabled: !this.roles.UPDATE,
630
664
  path: '/waiting/:id([a-zA-Z0-9]+)',
631
665
  method: [(0, _middleware.adminRoleMiddleware)([this.roles.UPDATE], this.roleMiddlewareOptions), (0, _middleware.validateMiddleware)(_constant.REQUEST_TYPE.PARAMS, _validator.rulesId), /*#__PURE__*/function () {
632
- var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(req, res) {
666
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(req, res) {
633
667
  var item;
634
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
668
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
635
669
  while (1) {
636
- switch (_context18.prev = _context18.next) {
670
+ switch (_context19.prev = _context19.next) {
637
671
  case 0:
638
- _context18.next = 2;
672
+ _context19.next = 2;
639
673
  return _this6.repository.findOneById(req.params.id);
640
674
  case 2:
641
- item = _context18.sent;
675
+ item = _context19.sent;
642
676
  if (item) {
643
- _context18.next = 5;
677
+ _context19.next = 5;
644
678
  break;
645
679
  }
646
- return _context18.abrupt("return", res.error(_error.NOT_EXISTS));
680
+ return _context19.abrupt("return", res.error(_error.NOT_EXISTS));
647
681
  case 5:
648
- _context18.next = 7;
682
+ _context19.next = 7;
649
683
  return item.modifyStatusWaiting(req.user.id);
650
684
  case 7:
651
- _context18.next = 9;
685
+ _context19.next = 9;
652
686
  return _this6.afterModify(item);
653
687
  case 9:
654
- item = _context18.sent;
655
- return _context18.abrupt("return", res.success(item, _this6.guardResponse, _this6.allowResponse));
688
+ item = _context19.sent;
689
+ return _context19.abrupt("return", res.success(item, _this6.guardResponse, _this6.allowResponse));
656
690
  case 11:
657
691
  case "end":
658
- return _context18.stop();
692
+ return _context19.stop();
659
693
  }
660
694
  }
661
- }, _callee18);
695
+ }, _callee19);
662
696
  }));
663
- return function (_x32, _x33) {
664
- return _ref14.apply(this, arguments);
697
+ return function (_x34, _x35) {
698
+ return _ref15.apply(this, arguments);
665
699
  };
666
700
  }()]
667
701
  };
@@ -669,20 +703,20 @@ var AdminController = /*#__PURE__*/function (_Controller) {
669
703
  }, {
670
704
  key: "afterDelete",
671
705
  value: function () {
672
- var _afterDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(item) {
673
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
706
+ var _afterDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(item) {
707
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
674
708
  while (1) {
675
- switch (_context19.prev = _context19.next) {
709
+ switch (_context20.prev = _context20.next) {
676
710
  case 0:
677
- return _context19.abrupt("return", item);
711
+ return _context20.abrupt("return", item);
678
712
  case 1:
679
713
  case "end":
680
- return _context19.stop();
714
+ return _context20.stop();
681
715
  }
682
716
  }
683
- }, _callee19);
717
+ }, _callee20);
684
718
  }));
685
- function afterDelete(_x34) {
719
+ function afterDelete(_x36) {
686
720
  return _afterDelete.apply(this, arguments);
687
721
  }
688
722
  return afterDelete;
@@ -708,20 +742,20 @@ var AdminController = /*#__PURE__*/function (_Controller) {
708
742
  }, {
709
743
  key: "afterDestroy",
710
744
  value: function () {
711
- var _afterDestroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(item) {
712
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
745
+ var _afterDestroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(item) {
746
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
713
747
  while (1) {
714
- switch (_context20.prev = _context20.next) {
748
+ switch (_context21.prev = _context21.next) {
715
749
  case 0:
716
- return _context20.abrupt("return", item);
750
+ return _context21.abrupt("return", item);
717
751
  case 1:
718
752
  case "end":
719
- return _context20.stop();
753
+ return _context21.stop();
720
754
  }
721
755
  }
722
- }, _callee20);
756
+ }, _callee21);
723
757
  }));
724
- function afterDestroy(_x35) {
758
+ function afterDestroy(_x37) {
725
759
  return _afterDestroy.apply(this, arguments);
726
760
  }
727
761
  return afterDestroy;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azteam/express",
3
- "version": "1.2.394",
3
+ "version": "1.2.396",
4
4
  "license": "MIT",
5
5
  "author": "toda <sp.azsolution.net@gmail.com>",
6
6
  "main": "./lib/index.js",
@@ -12,7 +12,7 @@
12
12
  "@azteam/constant": "1.0.7",
13
13
  "@azteam/crypto": "1.0.34",
14
14
  "@azteam/error": "1.0.32",
15
- "@azteam/http-client": "1.0.111",
15
+ "@azteam/http-client": "1.0.112",
16
16
  "@azteam/util": "1.0.36",
17
17
  "@azteam/validator": "1.0.17",
18
18
  "@grpc/grpc-js": "1.6.7",
@@ -1,9 +1,9 @@
1
1
  import _ from 'lodash';
2
- import {NOT_EXISTS} from '@azteam/error';
3
- import {rulesId} from '@azteam/validator';
2
+ import { NOT_EXISTS } from '@azteam/error';
3
+ import { rulesId } from '@azteam/validator';
4
4
 
5
- import {adminRoleMiddleware, paginateMiddleware, validateMiddleware} from '../middleware';
6
- import {REQUEST_TYPE} from '../constant';
5
+ import { adminRoleMiddleware, paginateMiddleware, validateMiddleware } from '../middleware';
6
+ import { REQUEST_TYPE } from '../constant';
7
7
 
8
8
  import Controller from './Controller';
9
9
 
@@ -74,6 +74,21 @@ class AdminController extends Controller {
74
74
  ];
75
75
  }
76
76
 
77
+ methodGetAll = async (req, res) => {
78
+ const data = await this.repository.findAll(req.query, {
79
+ limit: 2000,
80
+ });
81
+ return res.success(data, this.guardResponse, this.allowResponse);
82
+ };
83
+
84
+ getAll() {
85
+ return {
86
+ disabled: !this.roles.READ,
87
+ path: '/all',
88
+ method: [adminRoleMiddleware([this.roles.READ], this.roleMiddlewareOptions), this.methodGetAll],
89
+ };
90
+ }
91
+
77
92
  methodGetPaginate = async (req, res) => {
78
93
  const paginateData = await this.repository.find(req.query, req.paginate);
79
94
  return res.success(paginateData, this.guardResponse, this.allowResponse);
@@ -327,12 +342,12 @@ class AdminController extends Controller {
327
342
 
328
343
  methodDeleteDestroyTrash = async (req, res) => {
329
344
  const item = await this.repository.findOne(
330
- {
331
- _id: req.params.id,
332
- },
333
- {
334
- force: true,
335
- }
345
+ {
346
+ _id: req.params.id,
347
+ },
348
+ {
349
+ force: true,
350
+ }
336
351
  );
337
352
  if (!item) return res.error(NOT_EXISTS);
338
353