Files
dukang/.cursor/rules/packages-shared.mdc
T
2026-08-04 21:38:49 +08:00

44 lines
1.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
description: 杜康好客共享包(shared-types / domain / shared-ui)规范
globs: packages/**/*.{ts,tsx}
alwaysApply: false
---
# 共享包规范
## 包职责
| 包 | 用途 | 约束 |
|----|------|------|
| `@dukang/shared-types` | DTO、枚举、错误码、JWT Payload | 前后端唯一契约 |
| `@dukang/domain` | 纯函数业务规则 | **禁止 IO**,含 Vitest 单测 |
| `@dukang/shared-ui` | H5 共享组件 + `tokens.css` | 仅 H5 三端使用 |
## shared-types
- 枚举用 `SCREAMING_SNAKE_CASE`(如 `OrderStatus.PENDING_PAY`
- API Tab 查询用 snake_case`pending_pay`
- **加法优先**:新字段 optional;删除/改名先 deprecated
- 改 API 必须同步 V2 手册 §六 与 shared-types
## domain
- 纯函数,无 IO(无 Prisma/Redis/HTTP
- 起购 2/6 瓶、权益 `benefitAmount ?? price`、V3 两路径核销规则在此实现
- 变更必须有单元测试
```typescript
const benefitAmount = product.benefitAmount ?? product.price;
// 同城起购 2 瓶 / 跨城 6 瓶
// 直接核销按全部 ACTIVE 权益总余额;带单据核销按该单据可用金额
```
## shared-ui
- 跨 App 组件;禁止 import 特定 App 代码
- admin-web 使用 Ant Design,不引用 shared-ui
## 破坏性改动
需通知 **jacy-dukang** 与 **刘京尧**(若影响 partner/shop API)并在 PR 说明影响面。Prisma 迁移需双方 Review(涉及 store/redeem 表时)。