2025-12-15 23:33:02 +08:00
|
|
|
|
<!-- 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 -->
|
2025-11-19 00:15:18 +08:00
|
|
|
|
# CLAUDE.md
|
|
|
|
|
|
|
2025-12-27 18:17:10 +08:00
|
|
|
|
## 项目简介
|
|
|
|
|
|
**Yudao(芋道)** - Spring Boot快速开发平台,AI/媒体功能增强版
|
2025-11-19 00:15:18 +08:00
|
|
|
|
|
|
|
|
|
|
### 核心技术栈
|
2025-12-27 18:17:10 +08:00
|
|
|
|
- **后端**: 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(...)")`
|
2025-11-19 00:15:18 +08:00
|
|
|
|
|
|
|
|
|
|
## 项目结构
|
|
|
|
|
|
```
|
|
|
|
|
|
/d/projects/sionrui/
|
2025-12-27 18:17:10 +08:00
|
|
|
|
├── yudao-server/ # 主应用(端口9900)
|
|
|
|
|
|
├── yudao-module-tik/ # 媒体模块(语音克隆、视频)
|
|
|
|
|
|
├── yudao-module-ai/ # AI模块(聊天、知识库)
|
|
|
|
|
|
├── yudao-module-system/ # 系统管理
|
|
|
|
|
|
└── frontend/app/web-gold/ # Vue前端
|
2025-11-19 00:15:18 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2025-12-27 18:17:10 +08:00
|
|
|
|
## 模块标准结构
|
2025-11-19 00:15:18 +08:00
|
|
|
|
```
|
|
|
|
|
|
module/
|
2025-12-27 18:17:10 +08:00
|
|
|
|
├── controller/ # REST控制器
|
|
|
|
|
|
├── service/ # 业务逻辑(接口+实现)
|
|
|
|
|
|
├── mapper/ # 数据访问层
|
|
|
|
|
|
└── vo/ # 值对象(SaveReq/PageReq/Resp)
|
2025-11-19 00:15:18 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
2025-12-27 18:17:10 +08:00
|
|
|
|
## 关键配置
|
|
|
|
|
|
- **后端配置**: `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`
|
2025-11-19 00:15:18 +08:00
|
|
|
|
|
2025-12-27 18:17:10 +08:00
|
|
|
|
## API约定
|
|
|
|
|
|
- 管理API: `/admin-api/{module}/{resource}`
|
|
|
|
|
|
- 应用API: `/api/{module}/{resource}`
|
|
|
|
|
|
- CRUD端点: create/update/delete/get/page
|
2025-11-19 00:15:18 +08:00
|
|
|
|
|
2025-12-27 18:17:10 +08:00
|
|
|
|
## 常见易错点
|
2025-11-19 00:15:18 +08:00
|
|
|
|
|
2025-12-27 18:17:10 +08:00
|
|
|
|
### 1. 权限控制
|
2025-11-24 23:51:22 +08:00
|
|
|
|
❌ `Long userId = 1L`
|
|
|
|
|
|
✅ `SecurityFrameworkUtils.getLoginUserId()`
|
|
|
|
|
|
|
2025-12-27 18:17:10 +08:00
|
|
|
|
### 2. 分页查询
|
|
|
|
|
|
❌ 自定义pageNo/pageSize
|
|
|
|
|
|
✅ VO继承 `SortablePageParam` + `selectPage(reqVO, wrapper)`
|
|
|
|
|
|
|
|
|
|
|
|
### 3. Mapper查询
|
2025-11-24 23:51:22 +08:00
|
|
|
|
❌ `QueryWrapper` + 字符串字段
|
|
|
|
|
|
✅ `LambdaQueryWrapperX` + 方法引用
|
|
|
|
|
|
|
2025-12-27 18:17:10 +08:00
|
|
|
|
### 4. JSON字段处理
|
2025-11-24 23:51:22 +08:00
|
|
|
|
❌ `private List<String> urls`
|
2025-12-27 18:17:10 +08:00
|
|
|
|
✅ `private String urls` + `getUrlList()/setUrlList()` 转换方法
|
2025-11-24 23:51:22 +08:00
|
|
|
|
|
2025-12-27 18:17:10 +08:00
|
|
|
|
### 5. Bean转换
|
2025-11-24 23:51:22 +08:00
|
|
|
|
❌ `org.springframework.beans.BeanUtils`
|
|
|
|
|
|
✅ `framework.common.util.object.BeanUtils`
|
|
|
|
|
|
|
2025-12-27 18:17:10 +08:00
|
|
|
|
### 6. 多租户
|
|
|
|
|
|
- DO类必须继承 `TenantBaseDO`
|
2025-11-19 00:15:18 +08:00
|
|
|
|
- 框架自动注入 `tenantId`
|
|
|
|
|
|
|
2025-12-27 18:17:10 +08:00
|
|
|
|
## 开发命令
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# 前端开发
|
|
|
|
|
|
cd frontend/app/web-gold
|
|
|
|
|
|
pnpm install
|
|
|
|
|
|
pnpm run dev # 启动开发服务器
|
2025-11-19 00:15:18 +08:00
|
|
|
|
|
2025-12-27 18:17:10 +08:00
|
|
|
|
# 后端开发
|
|
|
|
|
|
mvn clean install
|
|
|
|
|
|
mvn spring-boot:run
|
|
|
|
|
|
```
|
2025-11-19 00:15:18 +08:00
|
|
|
|
|
2025-12-27 18:17:10 +08:00
|
|
|
|
## 重要提醒
|
|
|
|
|
|
1. **OSS配额检查**: 文件上传前必须检查用户/系统配额
|
|
|
|
|
|
2. **多租户**: 默认启用,DO类需继承 `TenantBaseDO`
|
|
|
|
|
|
3. **异常处理**: 使用 `ErrorCodeConstants` 中的错误码
|
|
|
|
|
|
4. **事务管理**: Service写操作使用 `@Transactional`
|