Ready for Review ✅
作为企业用户, 我希望查看近期分配的人才(如最近30天入职), 以便快速了解最新的人力资源动态,及时跟进新员工的管理和培养。
从史诗文件复制的验收标准编号列表
将故事分解为实施所需的具体任务和子任务。 在相关处引用适用的验收标准编号。
[x] 任务1:近期分配人才查询API开发(company-module扩展)(AC: 1, 2, 3, 4, 5)
company-recent-allocations.route.ts,路径为/api/v1/yongren/company/allocations/recentcompany.service.ts中添加getRecentAllocations方法,基于order_person表关联employment_order和disabled_person表查询近期分配人才order_person.join_date在最近30天内,且order_person.work_status = 'working'的记录join_date降序排列employment_order.company_id匹配用户company_id)的数据order_person.join_date、order_person.work_status等字段索引)RecentAllocationsSchema[x] 任务2:API路由集成和认证中间件配置(AC: 4, 6)
company-statistics.route.ts或新建路由文件中集成近期分配人才查询路由enterpriseAuthMiddleware)company_id验证)/api/v1/yongren/{ "success": false, "message": "...", "code": "..." }[x] 任务3:数据库性能优化(AC: 5)
order_person.join_date、order_person.work_status、employment_order.company_idorder_person.order_id + join_date)[x] 任务4:集成测试开发(AC: 6)
company-recent-allocations.integration.test.ts[x] 任务5:API文档完善(AC: 7)
仅填充从docs文件夹中的实际工件提取的相关信息,与此故事相关:
故事012.001(数据库schema扩展)、012.002(企业用户认证API扩展)和012.003(企业统计与人才扩展API)已完成的变更:
数据库schema扩展(故事012.001):
order_person表已包含join_date字段(DATE类型,可为空)[来源:allin-packages/order-module/src/entities/order-person.entity.ts:48-54]order_person表已包含work_status字段(枚举类型:working, on_leave, left)[来源:allin-packages/order-module/src/entities/order-person.entity.ts:60-66]employment_order表已包含company_id字段(外键,引用employer_company.company_id)[来源:allin-packages/order-module/src/entities/employment-order.entity.ts:32-38]企业用户认证(故事012.002):
POST /api/v1/yongren/auth/login [来源:docs/stories/012.002.story.md#文件列表]enterpriseAuthMiddleware [来源:docs/stories/012.002.story.md#文件列表]users2表的company_id字段验证 [来源:docs/stories/012.002.story.md#文件列表]企业统计与人才扩展API(故事012.003):
GET /api/v1/yongren/company/overview [来源:docs/stories/012.003.story.md#文件列表]GET /api/v1/yongren/company/{id}/talents [来源:docs/stories/012.003.story.md#文件列表]CompanyService已包含getCompanyOverview和getCompanyTalents方法 [来源:allin-packages/company-module/src/services/company.service.ts]CompanyTalentResponseSchema已定义,包含人才列表和状态分布结构 [来源:allin-packages/company-module/src/schemas/company-statistics.schema.ts:72-79]基于现有实体定义和架构文档:
订单人员实体(allin-packages/order-module/src/entities/order-person.entity.ts):
order_person(@Entity('order_person'))[来源:allin-packages/order-module/src/entities/order-person.entity.ts:7]id(映射到op_id列)[来源:allin-packages/order-module/src/entities/order-person.entity.ts:8-14]orderId、personId、joinDate、salaryDetail、workStatus等 [来源:allin-packages/order-module/src/entities/order-person.entity.ts:16-73]orderId关联EmploymentOrder,personId关联DisabledPerson [来源:allin-packages/order-module/src/entities/order-person.entity.ts:75-83]就业订单实体(allin-packages/order-module/src/entities/employment-order.entity.ts):
employment_order(@Entity('employment_order'))[来源:allin-packages/order-module/src/entities/employment-order.entity.ts:4]id(映射到order_id列)[来源:allin-packages/order-module/src/entities/employment-order.entity.ts:7-13]orderName、platformId、companyId、channelId、orderStatus、workStatus等 [来源:allin-packages/order-module/src/entities/employment-order.entity.ts:15-104]companyId字段关联Company实体 [来源:allin-packages/order-module/src/entities/employment-order.entity.ts:32-38]残疾人实体(allin-packages/disability-module/src/entities/disabled-person.entity.ts):
disabled_person(@Entity('disabled_person'))[来源:allin-packages/disability-module/src/entities/disabled-person.entity.ts:8]id(映射到person_id列)[来源:allin-packages/disability-module/src/entities/disabled-person.entity.ts:9-14]name、gender、idCard、disabilityId、disabilityType、disabilityLevel、birthDate、phone、jobStatus等 [来源:allin-packages/disability-module/src/entities/disabled-person.entity.ts:16-217]API路径约定(来自史诗012):
api/v1/yongren 前缀 [来源:docs/prd/epic-012-api-supplement-for-employer-mini-program.md#api路径约定]GET /api/v1/yongren/company/overview [来源:docs/prd/epic-012-api-supplement-for-employer-mini-program.md#api路径约定]新增接口规范:
近期分配人才查询:
GET /api/v1/yongren/company/allocations/recentlimit(可选,number,默认5):返回记录数限制Authorization: Bearer <企业用户token>响应示例:
{
"人才列表": [
{
"personId": 123,
"personName": "张三",
"joinDate": "2024-12-15T00:00:00.000Z",
"workStatus": "working",
"orderName": "2024年第四季度用工订单"
},
{
"personId": 124,
"personName": "李四",
"joinDate": "2024-12-10T00:00:00.000Z",
"workStatus": "working",
"orderName": "2024年第四季度用工订单"
}
]
}
状态码:200成功,400参数错误,401未授权,403权限不足,500服务器错误
查询逻辑:
order_person.join_date >= CURRENT_DATE - INTERVAL '30 days'(最近30天)order_person.work_status = 'working'(在职状态)employment_order.company_id = 用户关联的企业IDorder_person.join_date降序(最新入职的排前面)order_person → employment_order(获取订单名称和企业ID)→ disabled_person(获取人员姓名)认证要求:
enterpriseAuthMiddleware中间件company_id字段不为空不适用(后端API故事)。
基于项目结构和后端模块包规范 [来源:architecture/source-tree.md, architecture/backend-module-package-standards.md]:
公司模块位置:
allin-packages/company-module/src/routes/ - 现有路由文件位置allin-packages/company-module/src/services/ - 服务层文件位置allin-packages/company-module/src/schemas/ - Schema验证文件位置allin-packages/company-module/tests/integration/ - 集成测试位置新文件建议位置:
allin-packages/company-module/src/routes/company-recent-allocations.route.ts - 近期分配人才查询路由allin-packages/company-module/src/schemas/company-statistics.schema.ts - 在现有Schema文件中添加RecentAllocationsSchema(或新建company-recent-allocations.schema.ts)allin-packages/company-module/tests/integration/company-recent-allocations.integration.test.ts - 集成测试现有文件需要修改:
allin-packages/company-module/src/services/company.service.ts - 添加getRecentAllocations方法allin-packages/company-module/src/routes/index.ts - 路由聚合,包含新路由基于技术栈和架构文档 [来源:architecture/tech-stack.md, architecture/backend-module-package-standards.md]:
技术栈约束:
API设计约束:
{ "success": false, "message": "...", "code": "..." } [来源:architecture/backend-module-package-standards.md#错误处理规范]性能约束:
安全约束:
company_id匹配性向后兼容性:
/api/v1/yongren基于monorepo结构和模块化包架构 [来源:architecture/source-tree.md]:
模块化架构:
allin-packages/ - Allin系统移植的业务模块company-module业务模块已存在,企业相关API在此模块扩展company-module中实现,与其他企业统计API保持一致依赖关系:
company-module依赖order-module查询订单和人员数据company-module依赖disability-module查询残疾人信息auth-module进行认证路由结构:
/api/v1/yongren/company/overview、/api/v1/yongren/company/{id}/talents/api/v1/yongren/company/allocations/recent代码组织:
tests/integration/目录列出开发者需要遵循的相关测试标准:
基于测试策略文档 [来源:architecture/testing-strategy.md]:
allin-packages/company-module/tests/integration/company-recent-allocations.integration.test.ts [来源:architecture/testing-strategy.md#集成测试]@d8d/shared-test-util提供的工具 [来源:architecture/testing-strategy.md#集成测试]基于测试策略文档 [来源:architecture/testing-strategy.md]:
hono/testing进行API端点测试 [来源:architecture/testing-strategy.md#集成测试]TestDataFactory创建测试数据基于现有集成测试模式:
集成测试模式:
setupIntegrationDatabaseHooksWithEntities设置测试数据库testClient创建Hono测试客户端TestDataFactory创建一致的测试数据测试场景覆盖:
断言模式:
expect(response.status).toBe(200)expect(responseData).toHaveProperty('人才列表')expect(responseData.人才列表.length).toBeLessThanOrEqual(limit)expect(responseData.人才列表[0].joinDate).toBeGreaterThan(responseData.人才列表[1].joinDate)expect(joinDate).toBeWithinDays(30)expect(responseData.message).toContain('权限不足')近期分配人才查询API测试:
权限测试:
性能测试:
跟踪对此故事文档所做的更改
| 日期 | 版本 | 描述 | 作者 |
|---|---|---|---|
| 2025-12-18 | 1.0 | 初始故事创建,实现近期分配人才查询API | Claude Code |
此部分由开发代理在实施过程中填充
claude-sonnet
/api/v1/yongren/company/allocations/recentcompany.service.ts 中添加了 getRecentAllocations 方法,查询最近30天入职的在职人员limit 参数(默认5条),按 join_date 降序排列order_person.join_date、order_person.order_id + join_date 等RecentAllocationsSchema Zod Schema 验证company-recent-allocations.route.ts 并集成到企业路由聚合enterpriseAuthMiddleware新建文件:
allin-packages/company-module/src/routes/company-recent-allocations.route.ts - 近期分配人才查询路由allin-packages/company-module/src/routes/company-enterprise.routes.ts - 企业路由聚合allin-packages/company-module/tests/integration/company-recent-allocations.integration.test.ts - 集成测试修改文件:
allin-packages/company-module/src/services/company.service.ts - 添加 getRecentAllocations 方法allin-packages/company-module/src/schemas/company-statistics.schema.ts - 添加 RecentAllocationsSchemaallin-packages/company-module/src/routes/index.ts - 导出新路由allin-packages/order-module/src/entities/order-person.entity.ts - 添加数据库索引packages/server/src/index.ts - 更新企业路由导入和挂载docs/stories/012.010.story.md - 更新任务状态和记录来自QA代理对已完成故事实施的QA审查结果