Files
sionrui/.cursor/rules/project.mdc
2025-12-27 18:17:10 +08:00

116 lines
3.5 KiB
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.
<!-- OPENSPEC:START -->
# OpenSpec Instructions
These instructions are for AI assistants working in this project.
Always open `@/openspec/AGENTS.md` when the request:
- Mentions planning or proposals (words like proposal, spec, change, plan)
- Introduces new capabilities, breaking changes, architecture shifts, or big performance/security work
- Sounds ambiguous and you need the authoritative spec before coding
Use `@/openspec/AGENTS.md` to learn:
- How to create and apply change proposals
- Spec format and conventions
- Project structure and guidelines
Keep this managed block so 'openspec update' can refresh the instructions.
<!-- OPENSPEC:END -->
## 项目简介
**Yudao芋道** - Spring Boot快速开发平台AI/媒体功能增强版
### 核心技术栈
- **后端**: Java 17 + Spring Boot 3.5.5 + MyBatis Plus + Redis
- **前端**: Vue.js 3 + TypeScript + Ant Design Vue + TailwindCSS
- **数据库**: MySQL 8.0+,支持多种数据库
- **AI服务**: 语音克隆、图像生成、音乐生成、向量搜索
## 代码规范要点
### Vue.js 最佳实践
- 优先使用组合式API`<script setup>`
- 状态管理使用Pinia保持仓库模块化
- TypeScript类型定义规范
- 组件保持小巧专注,逻辑清晰
### Java开发规范
- 分层架构Controller → Service → Mapper → VO/DO
- Mapper继承 `BaseMapperX<T>`
- DO继承 `BaseDO` 或 `TenantBaseDO`
- API响应统一使用 `CommonResult<T>`
- 权限注解:`@PreAuthorize("hasPermission(...)")`
## 项目结构
```
/d/projects/sionrui/
├── yudao-server/ # 主应用端口9900
├── yudao-module-tik/ # 媒体模块(语音克隆、视频)
├── yudao-module-ai/ # AI模块聊天、知识库
├── yudao-module-system/ # 系统管理
└── frontend/app/web-gold/ # Vue前端
```
## 模块标准结构
```
module/
├── controller/ # REST控制器
├── service/ # 业务逻辑(接口+实现)
├── mapper/ # 数据访问层
└── vo/ # 值对象SaveReq/PageReq/Resp
```
## 关键配置
- **后端配置**: `yudao-server/src/main/resources/application-local.yaml`
- **数据库**: `jdbc:mysql://8.155.172.147:3306/sion_rui_dev`
- **Redis**: `8.155.172.147:6379`
- **前端代理**: `/admin-api` 和 `/api` 代理到 `http://localhost:9900`
## API约定
- 管理API: `/admin-api/{module}/{resource}`
- 应用API: `/api/{module}/{resource}`
- CRUD端点: create/update/delete/get/page
## 常见易错点
### 1. 权限控制
❌ `Long userId = 1L`
✅ `SecurityFrameworkUtils.getLoginUserId()`
### 2. 分页查询
❌ 自定义pageNo/pageSize
✅ VO继承 `SortablePageParam` + `selectPage(reqVO, wrapper)`
### 3. Mapper查询
❌ `QueryWrapper` + 字符串字段
✅ `LambdaQueryWrapperX` + 方法引用
### 4. JSON字段处理
❌ `private List<String> urls`
✅ `private String urls` + `getUrlList()/setUrlList()` 转换方法
### 5. Bean转换
❌ `org.springframework.beans.BeanUtils`
✅ `framework.common.util.object.BeanUtils`
### 6. 多租户
- DO类必须继承 `TenantBaseDO`
- 框架自动注入 `tenantId`
## 开发命令
```bash
# 前端开发
cd frontend/app/web-gold
pnpm install
pnpm run dev # 启动开发服务器
# 后端开发
mvn clean install
mvn spring-boot:run
```
## 重要提醒
1. **OSS配额检查**: 文件上传前必须检查用户/系统配额
2. **多租户**: 默认启用DO类需继承 `TenantBaseDO`
3. **异常处理**: 使用 `ErrorCodeConstants` 中的错误码
4. **事务管理**: Service写操作使用 `@Transactional`