sysMenuService.js 747 B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. const Service = require('../service/baseService');
  3. class SysMenuService extends Service {
  4. tag() {
  5. return this.ctx.model.SysMenuModel;
  6. }
  7. async loginerRoleMenu(id) {
  8. const { model } = this.ctx;
  9. const data = { sort: { order: 1 } };
  10. const dbMenuArr = await this.list(data);
  11. const dbUserOne = await model.SysUserModel.findById(id);
  12. const roleMenu = await model.SysRoleModel.findById(dbUserOne.role);
  13. return { dbMenuArr, roleMenu: JSON.parse(roleMenu.roleMenu) };
  14. }
  15. async deleteWithSub(id) {
  16. const dbMenuArr = await this.ctx.model.SysMenuModel.find({ fid: id });
  17. if (dbMenuArr.length > 0) {
  18. return null;
  19. }
  20. return await this.delete(id);
  21. }
  22. }
  23. module.exports = SysMenuService;