@azteam/express 1.2.224 → 1.2.227

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azteam/express",
3
- "version": "1.2.224",
3
+ "version": "1.2.227",
4
4
  "main": "src/index.js",
5
5
  "engines": {
6
6
  "node": ">= 12.0.0",
@@ -209,12 +209,18 @@ class AdminController extends Controller {
209
209
  };
210
210
  }
211
211
 
212
+ async afterDelete(item) {
213
+ return item;
214
+ }
215
+
212
216
  methodDeletePublic = async (req, res) => {
213
217
  const item = await this.repository.findOneById(req.params.id);
214
218
  if (!item) return res.error(NOT_EXISTS);
215
219
 
216
220
  await item.delete(req.user.id);
217
221
 
222
+ await this.afterDelete(item);
223
+
218
224
  return res.success(true);
219
225
  };
220
226
 
@@ -243,12 +249,27 @@ class AdminController extends Controller {
243
249
  };
244
250
  }
245
251
 
252
+ async afterDestroy(item) {
253
+ return item;
254
+ }
255
+
246
256
  methodDeleteDestroyTrash = async (req, res) => {
247
- const item = await this.repository.findOneTrashById(req.params.id);
257
+ const item = await this.repository.findOne(
258
+ {
259
+ _id: req.params.id,
260
+ },
261
+ {
262
+ trash: true,
263
+ }
264
+ );
248
265
  if (!item) return res.error(NOT_EXISTS);
249
266
 
267
+ const oldItem = _.cloneDeep(item);
268
+
250
269
  await this.repository.destroy(item.id);
251
270
 
271
+ await this.afterDestroy(oldItem);
272
+
252
273
  return res.success(true);
253
274
  };
254
275