|
@@ -91,6 +91,21 @@ class UserService extends CrudService {
|
|
|
await user.save();
|
|
|
}
|
|
|
|
|
|
+ async querymenus({ id }) {
|
|
|
+ const user = await this.model.findById(id);
|
|
|
+ if (!user) {
|
|
|
+ throw new BusinessError(ErrorCode.USER_NOT_EXIST);
|
|
|
+ }
|
|
|
+ const _menus = [];
|
|
|
+ for (const elm of user.menus) {
|
|
|
+ const _menu = await this.rmodel.findById({ _id: ObjectId(elm) });
|
|
|
+ if (_menu) {
|
|
|
+ _menus.push({ id: elm, role_name: _menu.role_name, url: _menu.url });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return { id, menus: _menus };
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
module.exports = UserService;
|