@azteam/express 1.2.122 → 1.2.125
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 +1 -1
- package/src/AdminController.js +22 -4
package/package.json
CHANGED
package/src/AdminController.js
CHANGED
|
@@ -14,7 +14,8 @@ class AdminController extends Controller {
|
|
|
14
14
|
CREATE: 2,
|
|
15
15
|
UPDATE: 3,
|
|
16
16
|
DELETE: 4,
|
|
17
|
-
RESTORE: 5
|
|
17
|
+
RESTORE: 5,
|
|
18
|
+
DESTROY: 6
|
|
18
19
|
}, // system roles
|
|
19
20
|
|
|
20
21
|
paginateOptions: {},
|
|
@@ -127,12 +128,12 @@ class AdminController extends Controller {
|
|
|
127
128
|
validateMiddleware(REQUEST_TYPE.BODY, this.options.rulesModify),
|
|
128
129
|
async (req, res) => {
|
|
129
130
|
|
|
130
|
-
let item = await this.
|
|
131
|
+
let item = await this.repository.findOneById(req.params.id);
|
|
131
132
|
if (!item) return res.error(NOT_EXISTS);
|
|
132
133
|
|
|
133
134
|
const data = await this.beforeModify(req.body, req.user);
|
|
134
135
|
|
|
135
|
-
item = await this.
|
|
136
|
+
item = await this.repository.modifyByUser(req.user.id, item, data);
|
|
136
137
|
|
|
137
138
|
return res.success(item, this.options.guardResponse, this.options.allowResponse);
|
|
138
139
|
}
|
|
@@ -173,6 +174,23 @@ class AdminController extends Controller {
|
|
|
173
174
|
]
|
|
174
175
|
};
|
|
175
176
|
};
|
|
177
|
+
|
|
178
|
+
deleteDestroy() {
|
|
179
|
+
return {
|
|
180
|
+
path: '/destroy/:id',
|
|
181
|
+
method: [
|
|
182
|
+
roleMiddleware([this.options.roles.DESTROY], USER_LEVEL.ADMIN),
|
|
183
|
+
validateMiddleware(REQUEST_TYPE.PARAMS, rulesID),
|
|
184
|
+
async (req, res) => {
|
|
185
|
+
const item = await this.repository.findOneTrashById(req.params.id);
|
|
186
|
+
if (!item) return res.error(NOT_EXISTS);
|
|
187
|
+
|
|
188
|
+
await this.repository.destroy(item);
|
|
189
|
+
return res.success(true);
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
};
|
|
193
|
+
};
|
|
176
194
|
}
|
|
177
195
|
|
|
178
|
-
export default AdminController;
|
|
196
|
+
export default AdminController;
|