feat: 完善数据库表命名规范,新增后勤管理和系统公共模块前缀
📋 主要变更: - ✅ 补充完整的7个业务模块表命名规范 - ✅ 新增后勤管理模块:hq_ 前缀 - ✅ 明确系统公共模块:common_ 前缀 - ✅ 提供完整的命名示例和实体类映射规则 - ✅ 更新变更记录文档 🎯 覆盖模块: - 后勤管理(hq_)、人事管理(rs_)、财务管理(cw_) - 学工管理(xg_)、招生就业(zsjy_)、安全保卫(aqbw_) - 系统公共(common_) 📚 文件变更: - .cursor/cursorrules-backend.md - 数据库表命名规范 - docs/变更管理/code-adjust-record-2025-01-23-wuzilong.md - 变更记录 - 各业务模块工程文件和前端结构文件 Co-authored-by: Cursor AI <cursor@cursor.sh>
This commit is contained in:
1 parent
00297e714b
commit
90b13a6e0c
193 files changed
+2726
-409
No files matched your search
@@ -40,11 +40,262 @@ backend/
|
||||
├── ruoyi-modules/ # 业务模块组
|
||||
│ ├── ruoyi-system/ # 系统管理模块
|
||||
│ ├── ruoyi-demo/ # 示例模块
|
||||
│ ├── ruoyi-hq/ # 后勤管理模块 (hq)
|
||||
│ ├── ruoyi-rs/ # 人事管理模块 (rs)
|
||||
│ ├── ruoyi-cw/ # 财务管理模块 (cw)
|
||||
│ ├── ruoyi-aqbw/ # 安全保卫管理模块 (aqbw)
|
||||
│ ├── ruoyi-zsjy/ # 招生就业管理模块 (zsjy)
|
||||
│ ├── ruoyi-xg/ # 学工管理模块 (xg)
|
||||
│ └── ... (其他业务模块)
|
||||
├── ruoyi-extend/ # 扩展模块组
|
||||
└── script/ # 脚本和SQL
|
||||
```
|
||||
|
||||
## 🔴 模块工程管理规范(强制性,2025-01-23新增)
|
||||
|
||||
### 📦 模块工程创建规范
|
||||
|
||||
**⚠️ 基于ruoyi-hq工程实践制定,后续所有新模块必须遵循此规范!**
|
||||
|
||||
#### 🏗️ 模块命名和位置规范
|
||||
|
||||
**模块位置**: `backend/ruoyi-modules/ruoyi-{模块简称}/`
|
||||
|
||||
**已规划模块列表**:
|
||||
- ✅ `ruoyi-hq` - 后勤管理模块 (已完成)
|
||||
- 🚧 `ruoyi-rs` - 人事管理模块
|
||||
- 🚧 `ruoyi-cw` - 财务管理模块
|
||||
- 🚧 `ruoyi-aqbw` - 安全保卫管理模块
|
||||
- 🚧 `ruoyi-zsjy` - 招生就业管理模块
|
||||
- 🚧 `ruoyi-xg` - 学工管理模块
|
||||
|
||||
#### 📋 Maven配置规范
|
||||
|
||||
**pom.xml标准模板**:
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi-modules</artifactId>
|
||||
<groupId>org.dromara</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-{模块简称}</artifactId>
|
||||
<description>
|
||||
{模块名称}管理模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- 通用工具 -->
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-doc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-mybatis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-log</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-excel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-idempotent</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-tenant</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-social</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-ratelimiter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-mail</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 系统模块依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-system</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-job</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 代码生成-->
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-generator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- demo模块 -->
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-demo</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 工作流模块 -->
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-workflow</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
```
|
||||
|
||||
#### 🏛️ 包结构规范
|
||||
|
||||
**Java包结构**: `org.dromara.{模块简称}`
|
||||
|
||||
**标准目录结构**:
|
||||
```
|
||||
ruoyi-{模块简称}/
|
||||
├── pom.xml
|
||||
└── src/main/
|
||||
├── java/org/dromara/{模块简称}/
|
||||
│ ├── controller/ # REST API控制器层
|
||||
│ ├── service/ # 业务服务接口层
|
||||
│ │ └── impl/ # 业务服务实现层
|
||||
│ ├── mapper/ # 数据访问层接口
|
||||
│ └── domain/ # 数据对象层
|
||||
│ ├── [Entity].java # 实体类 (继承TenantEntity)
|
||||
│ ├── bo/ # 业务对象 (Business Object)
|
||||
│ └── vo/ # 视图对象 (View Object)
|
||||
└── resources/
|
||||
└── mapper/ # MyBatis XML映射文件
|
||||
```
|
||||
|
||||
#### 🎯 代码规范要求
|
||||
|
||||
**Entity实体类**:
|
||||
```java
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("表名")
|
||||
public class EntityName extends TenantEntity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
// 业务字段...
|
||||
}
|
||||
```
|
||||
|
||||
**Service接口**:
|
||||
```java
|
||||
public interface IEntityService {
|
||||
EntityVo queryById(Long id);
|
||||
TableDataInfo<EntityVo> queryPageList(EntityBo bo, PageQuery pageQuery);
|
||||
List<EntityVo> queryList(EntityBo bo);
|
||||
Boolean insertByBo(EntityBo bo);
|
||||
Boolean updateByBo(EntityBo bo);
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
```
|
||||
|
||||
**Controller控制器**:
|
||||
```java
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/{模块简称}/entity")
|
||||
public class EntityController extends BaseController {
|
||||
|
||||
private final IEntityService entityService;
|
||||
|
||||
@SaCheckPermission("{模块简称}:entity:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<EntityVo> list(EntityBo bo, PageQuery pageQuery) {
|
||||
return entityService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
// 其他标准接口...
|
||||
}
|
||||
```
|
||||
|
||||
**Mapper接口**:
|
||||
```java
|
||||
public interface EntityMapper extends BaseMapperPlus<Entity, EntityVo> {
|
||||
// 自定义查询方法...
|
||||
}
|
||||
```
|
||||
|
||||
#### 🔐 权限命名规范
|
||||
|
||||
**权限编码格式**: `{模块简称}:{功能}:{操作}`
|
||||
|
||||
**示例**:
|
||||
- `hq:repair:list` - 后勤模块报修列表查询权限
|
||||
- `rs:employee:add` - 人事模块员工新增权限
|
||||
- `cw:budget:export` - 财务模块预算导出权限
|
||||
|
||||
#### 📚 模块开发最佳实践
|
||||
|
||||
**1. 遵循ruoyi-hq标准模式**:
|
||||
- 继承TenantEntity支持多租户
|
||||
- 使用@SaCheckPermission进行权限控制
|
||||
- 遵循TableDataInfo分页响应格式
|
||||
- 使用MapstructUtils进行对象转换
|
||||
|
||||
**2. 代码质量要求**:
|
||||
- 使用Lombok减少样板代码
|
||||
- 完整的中文注释和文档
|
||||
- 统一的异常处理机制
|
||||
- 完善的参数校验
|
||||
|
||||
**3. 模块间解耦**:
|
||||
- 模块间通过Service接口交互
|
||||
- 避免直接依赖其他模块的内部实现
|
||||
- 共用功能提取到common模块
|
||||
|
||||
**4. 数据库设计**:
|
||||
- 必须遵循数据库规范基础字段
|
||||
- 支持逻辑删除和多租户
|
||||
- 合理的索引设计
|
||||
- 完整的数据字典配置
|
||||
|
||||
#### 🚨 模块创建检查清单
|
||||
|
||||
**创建新模块前必须检查**:
|
||||
- [ ] 模块名称符合规范?(`ruoyi-{简称}`)
|
||||
- [ ] Maven配置是否正确?
|
||||
- [ ] 包结构是否遵循标准?
|
||||
- [ ] 是否包含完整的分层架构?
|
||||
- [ ] 权限编码是否符合规范?
|
||||
- [ ] 是否遵循ruoyi-hq的最佳实践?
|
||||
- [ ] 数据库设计是否符合规范?
|
||||
- [ ] 是否添加了相关文档?
|
||||
|
||||
## 3. 开发规范
|
||||
|
||||
### 代码规范
|
||||
@@ -71,6 +322,93 @@ backend/
|
||||
5. **完整的中文注释是必须的**
|
||||
6. **禁止使用数据库外键约束**,关联关系通过应用层维护
|
||||
|
||||
#### 🔴 表命名规范(强制性)
|
||||
|
||||
**⚠️ 超级重要:所有数据库表必须按业务模块使用统一前缀命名!**
|
||||
|
||||
**模块表名前缀规范**:
|
||||
- **后勤管理**:`hq_` 开头 (如:`hq_repair`, `hq_maintenance`)
|
||||
- **人事管理**:`rs_` 开头 (如:`rs_employee`, `rs_department`)
|
||||
- **财务管理**:`cw_` 开头 (如:`cw_budget`, `cw_expense`)
|
||||
- **学工管理**:`xg_` 开头 (如:`xg_student`, `xg_dormitory`)
|
||||
- **招生就业**:`zsjy_` 开头 (如:`zsjy_application`, `zsjy_job`)
|
||||
- **安全保卫**:`aqbw_` 开头 (如:`aqbw_security`, `aqbw_patrol`)
|
||||
- **系统公共**:`common_` 开头 (如:`common_dict`, `common_config`)
|
||||
|
||||
**命名示例**:
|
||||
```sql
|
||||
-- 后勤管理模块表
|
||||
CREATE TABLE `hq_repair` (
|
||||
`id` bigint(20) NOT NULL COMMENT '报修ID',
|
||||
-- 其他字段...
|
||||
) COMMENT='报修管理表';
|
||||
|
||||
-- 人事管理模块表
|
||||
CREATE TABLE `rs_employee` (
|
||||
`id` bigint(20) NOT NULL COMMENT '员工ID',
|
||||
-- 其他字段...
|
||||
) COMMENT='员工信息表';
|
||||
|
||||
-- 财务管理模块表
|
||||
CREATE TABLE `cw_budget` (
|
||||
`id` bigint(20) NOT NULL COMMENT '预算ID',
|
||||
-- 其他字段...
|
||||
) COMMENT='预算管理表';
|
||||
|
||||
-- 学工管理模块表
|
||||
CREATE TABLE `xg_student` (
|
||||
`id` bigint(20) NOT NULL COMMENT '学生ID',
|
||||
-- 其他字段...
|
||||
) COMMENT='学生信息表';
|
||||
|
||||
-- 招生就业模块表
|
||||
CREATE TABLE `zsjy_application` (
|
||||
`id` bigint(20) NOT NULL COMMENT '申请ID',
|
||||
-- 其他字段...
|
||||
) COMMENT='招生申请表';
|
||||
|
||||
-- 安全保卫模块表
|
||||
CREATE TABLE `aqbw_security` (
|
||||
`id` bigint(20) NOT NULL COMMENT '安全记录ID',
|
||||
-- 其他字段...
|
||||
) COMMENT='安全管理表';
|
||||
|
||||
-- 系统公共模块表
|
||||
CREATE TABLE `common_dict` (
|
||||
`id` bigint(20) NOT NULL COMMENT '字典ID',
|
||||
-- 其他字段...
|
||||
) COMMENT='数据字典表';
|
||||
```
|
||||
|
||||
**强制性要求**:
|
||||
- ✅ 新建表时必须使用对应模块前缀
|
||||
- ✅ 表名采用下划线命名法(snake_case)
|
||||
- ✅ 表名必须是英文,禁止使用中文或拼音
|
||||
- ✅ 表注释必须用中文清楚说明表的用途
|
||||
- ❌ 禁止跨模块混用前缀(如人事模块不能创建 cw_ 开头的表)
|
||||
- ❌ 禁止使用无前缀的表名(系统核心表除外)
|
||||
|
||||
**实体类命名对应**:
|
||||
```java
|
||||
// 表名: hq_repair -> 实体类: HqRepair
|
||||
@TableName("hq_repair")
|
||||
public class HqRepair extends TenantEntity {
|
||||
// ...
|
||||
}
|
||||
|
||||
// 表名: rs_employee -> 实体类: RsEmployee
|
||||
@TableName("rs_employee")
|
||||
public class RsEmployee extends TenantEntity {
|
||||
// ...
|
||||
}
|
||||
|
||||
// 表名: cw_budget -> 实体类: CwBudget
|
||||
@TableName("cw_budget")
|
||||
public class CwBudget extends TenantEntity {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
#### 🔴 强制性基础字段模板
|
||||
|
||||
```sql
|
||||
@@ -1156,7 +1494,7 @@ testPermissions(token, permissionTests).then((results) => {
|
||||
|
||||
```
|
||||
org.mybatis.spring.MyBatisSystemException:
|
||||
Could not set property 'createBy' of 'class org.dromara.venue.domain.vo.HqVenueReservationVo'
|
||||
Could not set property 'createBy' of 'class org.dromara.hq.domain.vo.HqVenueReservationVo'
|
||||
with value '1' Cause: There is no setter for property named 'createBy'
|
||||
```
|
||||
|
||||
|
||||
Reference in new issue
Block a user