35 lines
1.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
const { Controller } = require('egg');
/**
* web 主体端:**运单回放查询**(`GET /api/web/pack-query?code=xxx`)
*
* 给一个运单号,返回:
* - 这个运单在本主体下的所有扫码记录(可能被扫了多次)
* - 每条记录当时的**工作台快照**(录像机 / 摄像头 / 布局 / 录制范围)
* - 每条记录的**回放计划**(拉哪段时间、哪些流)
* - 拍平去重后的 `streams`(桌面端一次拿全,不用二次查询)
*
* 鉴权:`apiAuth` + `subjectAuth`,**范围限定当前主体**(别的主体的运单查不到)。
*/
class WebPackController extends Controller {
/**
* GET /api/web/pack-query?code=运单号
*/
async query() {
const { ctx } = this;
const code = String(ctx.query.code || ctx.query.barcode || '').trim();
if (!code) ctx.throw(422, '缺少运单号(?code=)');
const data = await ctx.service.pack.query({
subjectId: ctx.state.subjectId,
code,
});
ctx.body = { ok: true, data };
}
}
module.exports = WebPackController;