menurole.js 887 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. const assert = require('assert');
  3. const _ = require('lodash');
  4. const { ObjectId } = require('mongoose').Types;
  5. const { CrudService } = require('naf-framework-mongoose/lib/service');
  6. const { BusinessError, ErrorCode } = require('naf-core').Error;
  7. class MenuroleService extends CrudService {
  8. constructor(ctx) {
  9. super(ctx, 'menu_role');
  10. this.model = this.ctx.model.Menurole;
  11. this.othermodel = this.ctx.model.Otheruser;
  12. this.charmodel = this.ctx.model.Character;
  13. }
  14. //左侧菜单栏
  15. async getMenurole(data){
  16. const {uid} = data;
  17. const otheruser = await this.othermodel.findById(uid);
  18. const charid = otheruser.characterid;
  19. const menurole = await this.charmodel.findById(charid);
  20. const allmenu = await this.model.find({});
  21. const viewmenu = menurole.roles;
  22. return {allmenu,viewmenu};
  23. }
  24. }
  25. module.exports = MenuroleService;