路由表化:迁移锁价、购料、库存与回收路由

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
黄健铭andClaude Opus 5.5 committed 2026-12-04 12:31:26 -08:00
1 parent babb914c59
commit d5c015f826
6 files changed
+302 -170

No files matched your search

@@ -0,0 +1,83 @@
'use strict';
// 回收/换货单、回收修改审批、客户来料。
const PrintStatus = require('../../print-status');
const { reviewRoutes } = require('./review');
const RECOVERY = '/api/recoveries/:id(uuid)';
module.exports = [
{
method: 'GET',
path: '/api/customer-materials',
handler: ({ ledger, query, actor }) => ledger.customerMaterials(query, actor),
},
{
method: 'POST',
path: '/api/customer-materials',
write: true,
handler: ({ ledger, body, actor }) => ledger.createCustomerMaterial(body, actor),
},
{
method: 'GET',
path: '/api/recoveries',
handler: ({ ledger, query, actor }) => {
const result = ledger.recoveries(query, actor);
return {
...result,
rows: result.rows.map(row => ({ ...row, printStatus: PrintStatus.projection(ledger, 'recovery', row.id) })),
};
},
},
{
method: 'POST',
path: '/api/recoveries',
write: true,
handler: ({ ledger, body, actor }) => ledger.createRecovery(body, actor),
},
{
// 试算:读请求体、复核会话后直接返回,不进入事务。
method: 'POST',
path: '/api/recoveries/quote',
handler: ({ ledger, body, actor }) => ledger.recoveryQuote(body, actor),
},
{
method: 'GET',
path: RECOVERY,
handler: ({ ledger, params: { id }, actor }) => ({
...ledger.recovery(id, actor),
printStatus: PrintStatus.projection(ledger, 'recovery', id),
}),
},
{
method: 'GET',
path: RECOVERY + '/edit',
handler: ({ ledger, params: { id }, actor }) => {
const result = ledger.recoveryEdit(id, actor);
return { ...result, record: { ...result.record, printStatus: PrintStatus.projection(ledger, 'recovery', id) } };
},
},
{
method: 'POST',
path: RECOVERY + '/update',
write: true,
handler: ({ ledger, params: { id }, body, actor }) => ledger.updateRecovery(id, body, actor),
},
{
method: 'POST',
path: RECOVERY + '/cancel',
write: true,
handler: ({ ledger, params: { id }, body, actor }) => ledger.cancelRecovery(id, body, actor),
},
{
// 试算:不进入事务。
method: 'POST',
path: RECOVERY + '/quote',
handler: ({ ledger, params: { id }, body, actor }) => ledger.recoveryEditQuote(id, body, actor),
},
...reviewRoutes('/api/recovery-changes', {
list: 'recoveryChanges',
one: 'recoveryChange',
approve: 'approveRecoveryChange',
reject: 'rejectRecoveryChange',
}),
];