# HealthLink-HIS — AI 开发规范 (GitHub Copilot) > 🤖 GitHub Copilot 打开本项目时自动加载此文件。 --- # HealthLink-HIS — AI 开发规范(自动加载) > 🤖 **本文件供所有 AI 编码工具自动读取**。无论使用 Claude Code、Cursor、Codex CLI、Copilot、Qwen、Cline 还是其他工具,进入本项目后必须遵守以下规范。 --- ## 一、项目概览 | 属性 | 值 | |------|------| | 项目名 | HealthLink-HIS(医院信息系统) | | 后端路径 | `healthlink-his-server/` | | 前端路径 | `healthlink-his-ui/` | | 文档路径 | `MD/` | | JDK | 25 (OpenJDK) | | Spring Boot | 4.0.6 | | Vue | 3.x + Vite + Element Plus | | 数据库 | PostgreSQL 15+ | | 包名 | `com.healthlink.his` | --- ## 二、铁律(必须遵守,违反即失败) ### 🔴 P0 铁律 — 不可违反 **铁律1: 修改完必须测试** ``` 后端: mvn clean compile -DskipTests → mvn install -DskipTests → mvn test 前端: npm run build:dev → npm run lint ``` - 白盒:编译通过,无 ERROR - 黑盒:关键接口返回 `{code:200, data:...}` - 冒烟:应用正常启动,核心流程通畅 **铁律2: Flyway 数据库迁移** - 凡是新建表、新增字段,必须创建 Flyway 迁移脚本 - 路径:`healthlink-his-domain/src/main/resources/db/migration/` - 命名:`V{版本号}__{描述}.sql`(双下划线) - 禁止直接在数据库执行 SQL 不走 Flyway **铁律3: 测试通过后才提交** - 编译 + 测试全部通过后才能 git commit - 不提交未完成的功能、调试代码、临时文件 **铁律4: 前后端API路径对齐** - 后端前缀:`/healthlink-his/api/v1/` - 前端 `request.js` 的 baseURL 必须与后端匹配 - 接口变更必须同步更新前后端代码 ### 🟡 P1 铁律 — 强烈建议 **铁律5: 先分解再行动** - 修改超过3个文件、涉及多模块、数据库变更,必须先制定计划 **铁律6: 验证后信** - 每次修改后必须验证编译通过,不信记忆 - 重新编译命令:`mvn clean compile -DskipTests` **铁律7: 文档统一管理** - 所有文档存储在 `MD/` 目录 - 文件名:大写英文+下划线(如 `BACKEND_CHECKLIST.md`) - 文档头部必须包含元数据块(文档类型、版本、日期) **铁律8: 规范文档在 MD/specs/** - 完整铁律:`MD/specs/IRON_RULES.md` - 后端规范:`MD/specs/BACKEND_DEVELOPMENT_STANDARD.md` - 前端规范:`MD/specs/FRONTEND_DEVELOPMENT_STANDARD.md` --- ## 三、后端开发规范 ### 分层架构 ``` Controller → AppService → Service → Mapper → Entity 接收请求 编排业务 单表CRUD 数据访问 实体定义 ``` ### 命名规范 | 类型 | 规则 | 示例 | |------|------|------| | Controller | `XxxController` | `RegistrationController` | | AppService | `IXxxAppService` / `XxxAppServiceImpl` | `IRegistrationAppService` | | Service | `IXxxService` / `XxxServiceImpl` | `IRegistrationService` | | Mapper | `XxxMapper` | `RegistrationMapper` | | Entity | `Xxx` | `Registration` | | DTO | `XxxDto` / `XxxQueryDto` | `RegistrationDto` | ### 包结构 ``` com.healthlink.his.web.{module}.controller com.healthlink.his.web.{module}.appservice com.healthlink.his.web.{module}.service com.healthlink.his.web.{module}.mapper com.healthlink.his.web.{module}.dto com.healthlink.his.domain.{module} com.healthlink.his.common.enums ``` ### 统一返回格式 ```java // 成功 AjaxResult.success(data) // 失败 AjaxResult.error("错误信息") // 列表 getDataTable(list) ``` ### 关键约束 - 所有查询使用 `LambdaQueryWrapper`,禁止字符串拼接 SQL - `@Transactional(rollbackFor = Exception.class)` 管理事务 - 所有接口标注 `@PreAuthorize` 权限控制 - 患者敏感信息(身份证、手机号)在日志中脱敏 - 扩展功能不要修改原有函数签名,新建 Service/AppService --- ## 四、前端开发规范 ### 技术栈 - Vue 3 + Vite + Element Plus + Pinia + Axios - 基于 RuoYi-Vue3 框架 ### 目录结构 ``` src/api/{module}/ # API接口(kebab-case路径) src/views/{module}/ # 页面组件 src/store/modules/ # Pinia状态管理 src/components/ # 公共组件 ``` ### API 路径规范 ```javascript // 统一前缀 /healthlink-his/api/v1/ export function listXxx(query) { return request({ url: '/healthlink-his/api/v1/xxx/list', method: 'get', params: query }) } ``` ### 组件规范 - 页面组件使用 `