- 50个后端模块用git mv移入core/与domains/<领域>/,入口server.js、launch.js、restore.js及server/原位不动 - 所有require路径由脚本按新旧位置统一换算(后端、server/、测试) - 新增test/app-paths.test.js,锁定默认数据目录、public目录与飞书配置文件的绝对位置 - 维护与部署.md补充目录说明并更新模块路径 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
2.4 KiB
JavaScript
84 lines
2.4 KiB
JavaScript
'use strict';
|
|
// 回收/换货单、回收修改审批、客户来料。
|
|
const PrintStatus = require('../../domains/printing/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',
|
|
}),
|
|
];
|