'use strict'; const MainService = require('../../main'); class accountService extends MainService { constructor(ctx) { super(ctx); const _noNeedLogin = ''; const _noNeedRight = 'getAccountInfo,updatePassword,list,add,delete,update'; const _noNeedLog = '*'; const _noNeedAuth = 'getAccountInfo,updatePassword,list,add,delete,update'; this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog, _noNeedAuth); } async callSystemAccount(methodName, data, defaultMessage) { const { service } = this; try { const result = await service.systems.setting.account[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.callSystemAccount('list', data, '获取工号列表失败'); } /** * 新增工号。 * @param {*} data */ async add(data = {}) { return this.callSystemAccount('add', data, '添加工号失败'); } /** * 删除工号。 * @param {*} data */ async delete(data = {}) { return this.callSystemAccount('delete', data, '删除工号失败'); } /** * 更新工号。 * @param {*} data */ async update(data = {}) { return this.callSystemAccount('update', data, '更新工号失败'); } } module.exports = accountService;