54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
const MainService = require('../../main');
|
|
|
|
/**
|
|
* 规范签约请求入参。
|
|
*
|
|
* @param {Object} data 请求数据。
|
|
* @return {Object} 复制后的请求数据。
|
|
*/
|
|
function normalizeWarehouseStorePayload(data) {
|
|
if (!data || typeof data !== 'object' || Array.isArray(data)) {
|
|
return {};
|
|
}
|
|
return { ...data };
|
|
}
|
|
|
|
class StoreWarehouseWarehouseService extends MainService {
|
|
constructor(ctx) {
|
|
super(ctx);
|
|
const _noNeedLogin = '';
|
|
const _noNeedRight = 'list';
|
|
const _noNeedLog = '*';
|
|
const _noNeedAuth = 'list';
|
|
this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog, _noNeedAuth);
|
|
}
|
|
|
|
/**
|
|
* 仓库侧获取签约列表。
|
|
*
|
|
* @param {Object} data 请求数据。
|
|
* @return {Promise<Object>} 统一响应结果。
|
|
*/
|
|
async list(data = {}) {
|
|
const targetService = this.service && this.service.systems && this.service.systems.storeWarehouse;
|
|
|
|
if (!targetService || typeof targetService.list !== 'function') {
|
|
return this.fail('获取签约列表失败', { code: 500 });
|
|
}
|
|
|
|
try {
|
|
const payload = normalizeWarehouseStorePayload(data);
|
|
const result = await targetService.list(payload);
|
|
return this.success('ok', result);
|
|
} catch (error) {
|
|
return this.fail(error.message || '获取签约列表失败', {
|
|
code: Number(error.code) || 500,
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = StoreWarehouseWarehouseService;
|