Files
dukang/.cursor/rules/backend-modules.mdc
2026-07-01 17:12:46 +08:00

43 lines
1002 B
Plaintext
Raw Permalink 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: NestJS 模块依赖与 Prisma 写权限 — 后端 OWNER 边界
globs: server/dukang-api/src/**/*.ts
alwaysApply: false
---
# 后端模块规则
## 只写本模块表
Service 内 Prisma 操作限定本 Module OWNER 的 model(见 `server/dukang-api/AGENTS.md`)。
## 禁止依赖(示例)
```typescript
// ❌ redeem.service.ts
await this.prisma.order.update(...)
// ✅ redeem.service.ts
await this.benefitService.deduct(dto)
await this.settlementService.createStorePayout(recordId)
```
```typescript
// ❌ benefit.module.ts imports TradeModule
// ❌ store.service.ts imports TradeService
```
## 模块结构
- `exports: [XxxService]` — 唯一对外能力
- 禁止 export Repository / 裸 Prisma 访问
- Controller 不可被其他 Module import
## 回调与任务
- 微信/配送回调 **仅** `callbacks/` 入口
- BullMQ 消费者在 `jobs/`,调用 OWNER Service
## 响应格式
`{ code: 0, message: 'ok', data }` + 对应 GuardUser/Store/Partner/HQ