- 商品/商品图片、店铺、店铺商品、组合商品及明细 - 仓库、仓库商品(WMS itemId 映射)、仓库接口配置与字段定义(warehouseApi/warehouseApiField) - 库存:stock_items、product_stocks(ZC/CC 双维度)与库存重算工具(utils/recalcStock.js) - 库存单据与对接日志:stock orders、api_outbound_logs - 相关迁移:shops/shop_products/stock_orders/warehouses/warehouse_apis/warehouse_products/product_stocks/files-images 等表与字段
54 lines
2.1 KiB
JavaScript
54 lines
2.1 KiB
JavaScript
'use strict';
|
||
|
||
const { Controller } = require('egg');
|
||
const { parsePagination, buildPageResult } = require('../lib/pagination');
|
||
|
||
/**
|
||
* @controller ApiOutboundLogController 对外 API 调用日志
|
||
* 记录 OMS → 外部 WMS 的调用(index.ping / singleitem.synchronize 等),数据按主体隔离
|
||
*/
|
||
class ApiOutboundLogController extends Controller {
|
||
/**
|
||
* @summary 对外 API 调用日志列表
|
||
* @description 分页查询当前主体下的对外调用记录,支持按仓库、接口配置、方法、关键词过滤
|
||
* @router get /api/outbound-logs
|
||
* @apikey
|
||
* @request query integer page 页码,默认 1
|
||
* @request query integer pageSize 每页条数,默认 20
|
||
* @request query integer warehouse_id 仓库ID,不传则返回该主体下全部
|
||
* @request query integer warehouse_api_id 接口配置ID,不传则不过滤
|
||
* @request query string method WMS 方法名,如 index.ping / singleitem.synchronize
|
||
* @request query string keyword 关键词,匹配请求地址/业务提示/异常信息
|
||
* @response 200 apiOutboundLogListResponse success
|
||
*/
|
||
async index() {
|
||
const { ctx } = this;
|
||
const Op = this.app.Sequelize.Op;
|
||
const { page, pageSize, offset, limit } = parsePagination(ctx.query);
|
||
const { warehouse_id: warehouseId, warehouse_api_id: apiId, method, keyword } = ctx.query;
|
||
|
||
const where = { principal_id: ctx.state.principalId };
|
||
if (warehouseId) where.warehouse_id = Number(warehouseId);
|
||
if (apiId) where.warehouse_api_id = Number(apiId);
|
||
if (method) where.method = method;
|
||
if (keyword) {
|
||
where[Op.or] = [
|
||
{ url: { [Op.like]: `%${keyword}%` } },
|
||
{ business_message: { [Op.like]: `%${keyword}%` } },
|
||
{ error: { [Op.like]: `%${keyword}%` } },
|
||
];
|
||
}
|
||
|
||
const { count, rows } = await ctx.model.ApiOutboundLog.findAndCountAll({
|
||
where,
|
||
offset,
|
||
limit,
|
||
order: [[ 'id', 'DESC' ]],
|
||
});
|
||
|
||
ctx.body = { code: 0, message: 'success', data: buildPageResult(rows, count, { page, pageSize }) };
|
||
}
|
||
}
|
||
|
||
module.exports = ApiOutboundLogController;
|