'use strict'; const MainService = require('../../main'); class permissionService extends MainService { constructor(ctx) { super(ctx); const _noNeedLogin = ''; const _noNeedRight = 'list,add,delete,update'; const _noNeedLog = '*'; const _noNeedAuth = 'list,add,delete,update'; this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog, _noNeedAuth); } async callSystemPermission(methodName, data, defaultMessage) { const { service } = this; try { const result = await service.systems.setting.permission[methodName](data); return this.success('ok', result); } catch (error) { return this.fail(error.message || defaultMessage, { code: Number(error.code) || 500, }); } } /** * 权限列表。 * @param {Object} data 请求体 */ async list(data = {}) { return this.callSystemPermission('list', data, '获取权限列表失败'); } /** * 新增权限。 * @param {Object} data 请求体 */ async add(data = {}) { return this.callSystemPermission('add', data, '新增权限失败'); } /** * 删除权限。 * @param {Object} data 请求体 */ async delete(data = {}) { return this.callSystemPermission('delete', data, '删除权限失败'); } /** * 更新权限。 * @param {Object} data 请求体 */ async update(data = {}) { return this.callSystemPermission('update', data, '更新权限失败'); } } module.exports = permissionService;