|
@@ -235,6 +235,35 @@ Ready for Review
|
|
|
- `PUT /videos/{id}/status` - 更新视频审核状态接口(支持pending/verified/rejected状态更新)
|
|
- `PUT /videos/{id}/status` - 更新视频审核状态接口(支持pending/verified/rejected状态更新)
|
|
|
- `GET /video-statistics` - 视频统计接口(分类统计、类型分布)
|
|
- `GET /video-statistics` - 视频统计接口(分类统计、类型分布)
|
|
|
|
|
|
|
|
|
|
+### RPC类型推断实现
|
|
|
|
|
+参考 `allin-packages/disability-person-management-ui/src/api/types.ts` 的实现模式,使用Hono的类型推导工具 `InferResponseType` 和 `InferRequestType` 从API客户端自动推导请求和响应类型,避免手动定义重复的自定义类型。
|
|
|
|
|
+
|
|
|
|
|
+**实现示例**:
|
|
|
|
|
+```typescript
|
|
|
|
|
+import type { InferResponseType, InferRequestType } from 'hono/client';
|
|
|
|
|
+import { enterpriseOrderClient } from './enterpriseOrderClient';
|
|
|
|
|
+
|
|
|
|
|
+// 使用Hono类型推导
|
|
|
|
|
+export type OrderDetailResponse = InferResponseType<typeof enterpriseOrderClient.detail[':id'].$get, 200>;
|
|
|
|
|
+export type OrderListResponse = InferResponseType<typeof enterpriseOrderClient['company-orders'].$get, 200>;
|
|
|
|
|
+export type OrderData = InferResponseType<typeof enterpriseOrderClient['company-orders'].$get, 200>['data'][0];
|
|
|
|
|
+
|
|
|
|
|
+export type CreateOrderRequest = InferRequestType<typeof enterpriseOrderClient.create.$post>['json'];
|
|
|
|
|
+export type UpdateOrderRequest = InferRequestType<typeof enterpriseOrderClient.update[':id'].$put>['json'];
|
|
|
|
|
+
|
|
|
|
|
+// 分页响应类型(通用)
|
|
|
|
|
+export type PaginatedResponse<T> = {
|
|
|
|
|
+ data: T[];
|
|
|
|
|
+ total: number;
|
|
|
|
|
+};
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+**优势**:
|
|
|
|
|
+- 类型安全:自动与后端路由类型保持同步
|
|
|
|
|
+- 减少重复:避免手动定义重复的类型定义
|
|
|
|
|
+- 维护性:后端路由变更时,前端类型自动更新
|
|
|
|
|
+- 一致性:确保请求/响应类型与API契约完全匹配
|
|
|
|
|
+
|
|
|
**技术集成**:
|
|
**技术集成**:
|
|
|
- **RPC客户端工具**:使用`@d8d/mini-shared-ui-components/utils/rpc/rpc-client`提供的RPC客户端工具,在UI包内创建企业专用API客户端
|
|
- **RPC客户端工具**:使用`@d8d/mini-shared-ui-components/utils/rpc/rpc-client`提供的RPC客户端工具,在UI包内创建企业专用API客户端
|
|
|
- **企业专用API路径前缀**:`api/v1/yongren`
|
|
- **企业专用API路径前缀**:`api/v1/yongren`
|