Files
AIclinicalresearch/docs/04-开发规范/README.md
HaHafeng a79abf88db docs(platform): Complete platform infrastructure planning
- Create platform infrastructure planning core document (766 lines)
- Update architecture design to support cloud-native deployment
- Update development specs and operations documentation
- Simplify ASL module docs by removing duplicate implementations

New Documents:
- Platform Infrastructure Planning (04-骞冲彴鍩虹璁炬柦瑙勫垝.md)
- Cloud-Native Development Standards (08-浜戝師鐢熷紑鍙戣鑼?md)
- Git Commit Standards (06-Git鎻愪氦瑙勮寖.md)
- Cloud-Native Deployment Guide (03-浜戝師鐢熼儴缃叉灦鏋勬寚鍗?md)
- Daily Summary (2025-11-16 work summary)

Updated Documents (11 files):
- System architecture design docs (3 files)
- Implementation and standards docs (4 files)
- Operations documentation (1 file)
- ASL module planning docs (3 files)

Key Achievements:
- Platform-level infrastructure architecture established
- Zero-code switching between local/cloud environments
- 100% support for 4 PRD deployment modes
- Support for modular product combinations
- 99% efficiency improvement for module development
- Net +1426 lines of quality documentation

Implementation: 2.5 days (20 hours) for 8 infrastructure modules
2025-11-16 21:36:57 +08:00

220 lines
5.0 KiB
Markdown
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.
# 04-开发规范
> **目标:** 统一团队开发规范,提高代码质量和协作效率
> **适用范围:** 平台层 + 能力层 + 业务模块层
> **强制等级:** ⭐⭐⭐⭐⭐ 必须遵守
---
## 📋 规范文档列表
### 1. 数据库设计规范 ⭐⭐⭐⭐⭐
**文件:** `01-数据库设计规范.md` ⏳ 待创建(从 `01-设计文档/数据库设计文档.md` 提取)
**核心内容:**
- Schema隔离策略platform_schema、asl_schema等
- 表命名规范(小写+下划线)
- 字段命名规范
- 索引设计规范
- 外键约束规范
- 通用字段created_at、updated_at等
**快速参考:** [数据库全局视图](./03-数据库全局视图.md) ⭐ 已创建
---
### 2. API设计规范 ⭐⭐⭐⭐⭐
**文件:** `02-API设计规范.md` ⏳ 待创建(从 `01-设计文档/API设计规范.md` 提取)
**核心内容:**
- RESTful API设计原则
- URL命名规范`/api/v1/模块/资源`
- HTTP方法使用规范
- 请求/响应格式规范
- 错误码设计
- 认证和权限
**快速参考:** [API路由总览](./04-API路由总览.md) ⭐ 已创建
---
### 3. 数据库全局视图 ⭐⭐⭐⭐⭐ ✅ 新增
**文件:** `03-数据库全局视图.md`
**用途:** 提供所有Schema和表的快速索引
**核心内容:**
- Schema划分策略8个Schema
- 所有表的总览和跳转链接
- 跨Schema依赖关系
- 数据量预估
**使用场景:**
- 查看全局数据架构
- 快速定位某个表属于哪个Schema
- 了解跨模块数据关系
---
### 4. API路由总览 ⭐⭐⭐⭐⭐ ✅ 新增
**文件:** `04-API路由总览.md`
**用途:** 提供所有API端点的快速索引
**核心内容:**
- 路由命名规范
- 所有模块的API端点总览
- 路由冲突检查
- 端点统计(~85个
**使用场景:**
- 查看全局API架构
- 避免路由冲突
- 快速查找某个功能的API端点
---
### 5. 代码规范 ⭐⭐⭐⭐
**文件:** `05-代码规范.md` → 重命名自 `代码规范.md`已存在818行
**核心内容:**
- TypeScript编码规范
- React组件规范
- 文件和目录命名
- 代码注释规范
- 错误处理规范
- 日志记录规范
**已有内容,包含:**
- ESLint配置
- Prettier配置
- 详细的编码规范
---
### 6. Git提交规范 ⭐⭐⭐⭐⭐ ✅ 已完成
**文件:** `06-Git提交规范.md`
**核心内容:**
- 远程仓库配置Gitee
- Commit Message格式规范
- 分支管理策略
- 中文编码问题解决方案 ⭐ 重要
- Git历史重写与维护
- PR/MR规范和代码审查流程
- 常见问题与最佳实践
**包含实用工具:**
- `fix-git-commit-messages.ps1` 脚本使用说明
- Git 别名配置
- 中文乱码修复完整流程
**快速参考:**
```
<type>(<scope>): <subject>
feat: 新功能 fix: Bug修复 docs: 文档
style: 格式 refactor: 重构 perf: 优化
test: 测试 chore: 构建 ci: CI/CD
```
---
### 7. 测试规范 ⭐⭐⭐
**文件:** `07-测试规范.md` ⏳ 待创建
**核心内容:**
- 单元测试规范
- 集成测试规范
- E2E测试规范
- 测试覆盖率要求
**测试覆盖率要求:**
- 核心业务逻辑≥80%
- 工具函数≥90%
- API Controller≥70%
---
## 🎯 规范优先级
### P0 - 必须遵守
- ✅ 数据库设计规范
- ✅ API设计规范
- ✅ Git提交规范Commit Message
### P1 - 强烈建议
- ✅ 代码规范TypeScript/React
- ✅ 错误处理规范
- ✅ 日志记录规范
### P2 - 建议遵守
- ⚪ 测试规范
- ⚪ 文档注释规范
- ⚪ 性能优化规范
---
## 🔍 快速查找
**我要设计数据库表:**`01-数据库设计规范.md`
**我要设计API接口**`02-API设计规范.md`
**我要查看全局数据架构:**`03-数据库全局视图.md`
**我要查看全局API路由**`04-API路由总览.md`
**我要编写代码:**`05-代码规范.md`
**我要提交代码:**`06-Git提交规范.md`
**我要解决中文乱码:**`06-Git提交规范.md` (第4节) ✅
**我要配置远程仓库:**`06-Git提交规范.md` (第1节) ✅
**我要编写测试:**`07-测试规范.md`
---
## ⚠️ 违反规范的后果
### 数据库设计不规范
- ❌ Schema混乱模块耦合
- ❌ 无法实现模块独立部署
- ❌ 数据迁移困难
### API设计不规范
- ❌ 前后端对接困难
- ❌ API文档混乱
- ❌ 版本升级困难
### 代码不规范
- ❌ 代码可读性差
- ❌ 维护成本高
- ❌ Bug率上升
---
## 📝 规范更新流程
1. 提出规范变更需求Issue或PR
2. 团队讨论和评审
3. 更新规范文档
4. 通知全员
5. 逐步迁移旧代码
---
## 🔗 相关工具
**代码检查:**
- ESLintJavaScript/TypeScript
- Prettier代码格式化
- StylelintCSS
**提交检查:**
- HuskyGit Hooks
- CommitlintCommit Message检查
**数据库:**
- PrismaORM + Migration
- pgAdmin数据库管理
---
**最后更新:** 2025-11-06
**维护人:** 技术架构师