'use strict'; const MainService = require('../../main'); class roleService extends MainService { constructor(ctx) { super(ctx); const _noNeedLogin = ''; <<<<<<< HEAD const _noNeedRight = 'list,add,delete,update,permission'; const _noNeedLog = '*'; const _noNeedAuth = 'list,add,delete,update,permission'; ======= const _noNeedRight = 'list,add,delete,update'; const _noNeedLog = '*'; const _noNeedAuth = 'list,add,delete,update'; >>>>>>> 26af1a7039685344b2ea591cc28e63080c1b8893 this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog, _noNeedAuth); } async callSystemRole(methodName, data, defaultMessage) { const { service } = this; try { const result = await service.systems.setting.role[methodName](data); return this.success('ok', result); } catch (error) { return this.fail(error.message || defaultMessage, { code: Number(error.code) || 500, }); } } /** * 角色列表。 * @param {*} data */ async list(data = {}) { return this.callSystemRole('list', data, '获取角色列表失败'); } /** <<<<<<< HEAD * 角色权限列表(兼容旧入口)。 * @param {*} data */ async permission(data = {}) { return this.callSystemRole('permission', data, '获取角色权限列表失败'); } /** ======= >>>>>>> 26af1a7039685344b2ea591cc28e63080c1b8893 * 新增角色。 * @param {*} data */ async add(data = {}) { return this.callSystemRole('add', data, '新增角色失败'); } /** * 删除角色。 * @param {*} data */ async delete(data = {}) { return this.callSystemRole('delete', data, '删除角色失败'); } /** * 更新角色。 * @param {*} data */ async update(data = {}) { return this.callSystemRole('update', data, '更新角色失败'); } } module.exports = roleService;