From 41ef9b40dedbce141d65f1f490328112cba5e754 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Mon, 6 Jul 2026 22:07:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20storeWarehouse.warehouse.l?= =?UTF-8?q?ist=20API=EF=BC=9A=E4=BB=93=E5=BA=93=E4=BE=A7=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E7=AD=BE=E7=BA=A6=E8=B4=A7=E4=B8=BB=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/systemMethods/storeWarehouse.js | 2 + .../systemMethods/storeWarehouse/warehouse.js | 53 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 app/service/systemMethods/storeWarehouse/warehouse.js diff --git a/app/service/systemMethods/storeWarehouse.js b/app/service/systemMethods/storeWarehouse.js index db6e15f..c2d748e 100644 --- a/app/service/systemMethods/storeWarehouse.js +++ b/app/service/systemMethods/storeWarehouse.js @@ -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); } } diff --git a/app/service/systemMethods/storeWarehouse/warehouse.js b/app/service/systemMethods/storeWarehouse/warehouse.js new file mode 100644 index 0000000..3a5bdcc --- /dev/null +++ b/app/service/systemMethods/storeWarehouse/warehouse.js @@ -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} 统一响应结果。 + */ + 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;