61 lines
1.5 KiB
JavaScript

'use strict';
const MainService = require('../../main');
class storeWarehouseService extends MainService {
constructor(ctx) {
super(ctx);
const _noNeedLogin = '';
const _noNeedRight = 'list,sign,unbind,rename';
const _noNeedLog = '*';
const _noNeedAuth = 'list,sign,unbind,rename';
this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog, _noNeedAuth);
}
async callSystemStoreWarehouse(methodName, data, defaultMessage) {
const { service } = this;
try {
const result = await service.systems.storeWarehouse[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.callSystemStoreWarehouse('list', data, '获取签约列表失败');
}
/**
* 建立/更新签约关系。
* @param {*} data
*/
async sign(data = {}) {
return this.callSystemStoreWarehouse('sign', data, '签约失败');
}
/**
* 修改当前主体对签约对象的名称/备注。
* @param {*} data
*/
async rename(data = {}) {
return this.callSystemStoreWarehouse('rename', data, '修改签约名称失败');
}
/**
* 解除签约关系。
* @param {*} data
*/
async unbind(data = {}) {
return this.callSystemStoreWarehouse('unbind', data, '解除签约失败');
}
}
module.exports = storeWarehouseService;