- 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>
119 lines
3.8 KiB
JavaScript
119 lines
3.8 KiB
JavaScript
'use strict';
|
|
// 团队资金、团队利润、私账经营与人数、每日资金、报销。
|
|
const PrivateOperations = require('../../domains/funds/private-operations');
|
|
const { today } = require('../../core/ledger');
|
|
const { notFound } = require('../http');
|
|
const { peopleCountResponse } = require('../people-count-response');
|
|
|
|
const TRANSFER_PATHS = ['/api/team-funds/transfers', '/api/team-funds/transfer'];
|
|
|
|
module.exports = [
|
|
{
|
|
method: 'GET',
|
|
path: '/api/team-funds',
|
|
role: 'owner',
|
|
handler: ({ ledger, query, actor }) => ledger.teamFunds(query, actor),
|
|
},
|
|
...TRANSFER_PATHS.flatMap(path => [
|
|
// 旧代码对转账地址不分请求方式先校验店主,GET 随后 404。
|
|
{ method: 'GET', path, role: 'owner', handler: notFound },
|
|
{
|
|
method: 'POST',
|
|
path,
|
|
role: 'owner',
|
|
write: true,
|
|
handler: ({ ledger, body, actor }) => ledger.transferTeamFunds(body, actor),
|
|
},
|
|
]),
|
|
{
|
|
method: 'GET',
|
|
path: '/api/team-profits',
|
|
role: 'owner',
|
|
handler: ({ ledger, query, actor }) => ledger.teamProfits(query, actor),
|
|
},
|
|
{
|
|
method: 'GET',
|
|
path: '/api/private-operations',
|
|
role: 'owner',
|
|
handler: ({ ledger, query, actor }) => PrivateOperations.report(ledger, query, actor),
|
|
},
|
|
// 旧代码对这两个地址不分请求方式先校验店主;POST 随后照常读请求体、进入事务再 404。
|
|
{ method: 'POST', path: '/api/private-operations', role: 'owner', write: true, handler: notFound },
|
|
{
|
|
method: 'GET',
|
|
path: '/api/private-operations/people-history',
|
|
handler: ({ ledger, query, actor }) => PrivateOperations.peopleHistory(ledger, query, actor),
|
|
},
|
|
{
|
|
method: 'GET',
|
|
path: '/api/private-operations/people',
|
|
handler: ({ ledger, query, actor }) => PrivateOperations.entry(ledger, query, actor),
|
|
},
|
|
{
|
|
method: 'POST',
|
|
path: '/api/private-operations/people',
|
|
write: true,
|
|
syncTeamFunds: false,
|
|
handler: ({ ledger, body, actor }) => PrivateOperations.save(ledger, body, actor),
|
|
},
|
|
{
|
|
method: 'GET',
|
|
path: '/api/people-count',
|
|
role: 'owner',
|
|
handler: ({ ledger, url }) => ledger.peopleCount(url.searchParams.get('date') ?? today()),
|
|
},
|
|
{
|
|
method: 'POST',
|
|
path: '/api/people-count',
|
|
role: 'owner',
|
|
write: true,
|
|
handler: ({ ledger, body, actor }) => ledger.savePeopleCount(body, actor),
|
|
project: ({ ledger, actor }, result) => peopleCountResponse(ledger, result, actor),
|
|
},
|
|
{
|
|
method: 'GET',
|
|
path: '/api/people-count-history',
|
|
role: 'owner',
|
|
handler: ({ ledger, query }) => ledger.peopleCountHistory(query),
|
|
},
|
|
{ method: 'POST', path: '/api/people-count-history', role: 'owner', write: true, handler: notFound },
|
|
{
|
|
method: 'GET',
|
|
path: '/api/daily-funds',
|
|
handler: ({ ledger, query, actor }) => ledger.dailyFunds(query, actor),
|
|
},
|
|
{
|
|
method: 'POST',
|
|
path: '/api/daily-funds/confirm',
|
|
write: true,
|
|
handler: ({ ledger, body, actor }) => ledger.confirmDailyOutlay(body, actor),
|
|
},
|
|
{
|
|
method: 'GET',
|
|
path: '/api/reimbursement-funding-options',
|
|
handler: ({ ledger, query, actor }) => ledger.reimbursementFundingOptions(query, actor),
|
|
},
|
|
{
|
|
method: 'GET',
|
|
path: '/api/reimbursements',
|
|
handler: ({ ledger, query, actor }) => ledger.reimbursements(query, actor),
|
|
},
|
|
{
|
|
method: 'POST',
|
|
path: '/api/reimbursements',
|
|
write: true,
|
|
handler: ({ ledger, body, actor }) => ledger.createReimbursement(body, actor),
|
|
},
|
|
{
|
|
method: 'POST',
|
|
path: '/api/reimbursements/:id(uuid)/:action(update|approve|reject)',
|
|
write: true,
|
|
handler: ({ ledger, params: { id, action }, body, actor }) =>
|
|
action === 'update'
|
|
? ledger.updateReimbursement(id, body, actor)
|
|
: action === 'approve'
|
|
? ledger.approveReimbursement(id, body, actor)
|
|
: ledger.rejectReimbursement(id, body, actor),
|
|
},
|
|
];
|