index.put.mjs
1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { e as eventHandler, d as getRouterParam, r as readBody, I as updateMockDraftWorkOrder } from '../../../nitro/nitro.mjs';
import { z } from 'zod';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'node:crypto';
import 'node:url';
import '@iconify/utils';
import 'consola';
const payloadSchema = z.object({
orderNo: z.string().trim().min(1),
deviceCode: z.string().trim().min(1),
batchNo: z.string().trim().min(1),
line: z.string().trim().min(1),
ownerUsername: z.string().trim().min(1),
plannedDate: z.string().trim().min(1),
totalSn: z.number().int().positive(),
operator: z.string().trim().min(1)
});
const index_put = eventHandler(async (event) => {
const idRaw = getRouterParam(event, "id");
const id = Number(idRaw);
if (!Number.isInteger(id) || id <= 0) {
return {
success: false,
errorCode: "VALIDATION_ERROR",
message: "\u5DE5\u5355\u6807\u8BC6\u4E0D\u6B63\u786E\u3002"
};
}
const body = await readBody(event);
const parsed = payloadSchema.safeParse(body);
if (!parsed.success) {
return {
success: false,
errorCode: "VALIDATION_ERROR",
message: "\u5DE5\u5355\u53C2\u6570\u4E0D\u6B63\u786E\u3002"
};
}
const { operator, ...payload } = parsed.data;
return updateMockDraftWorkOrder(id, payload, operator);
});
export { index_put as default };
//# sourceMappingURL=index.put.mjs.map