新增 storeWarehouse.warehouse.list API:仓库侧查询签约货主列表
This commit is contained in:
parent
4e20831386
commit
41ef9b40de
@ -2,12 +2,14 @@
|
||||
|
||||
const MainService = require('../main');
|
||||
const StoreWarehouseStoreService = require('./storeWarehouse/store');
|
||||
const StoreWarehouseWarehouseService = require('./storeWarehouse/warehouse');
|
||||
|
||||
class StoreWarehouseNamespaceService extends MainService {
|
||||
constructor(ctx) {
|
||||
super(ctx);
|
||||
this.systemInit('', '', '*', '');
|
||||
this.store = new StoreWarehouseStoreService(ctx);
|
||||
this.warehouse = new StoreWarehouseWarehouseService(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
53
app/service/systemMethods/storeWarehouse/warehouse.js
Normal file
53
app/service/systemMethods/storeWarehouse/warehouse.js
Normal file
@ -0,0 +1,53 @@
|
||||
'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;
|
||||
Loading…
x
Reference in New Issue
Block a user