refactor(model): 重构模型类包结构并优化序列化处理

重构模型类包结构,将模型类按功能模块划分到不同的子包中。优化序列化处理,为VO类添加serialVersionUID并实现Serializable接口。移除部分冗余的serialVersionUID字段,简化模型类代码。同时修复UITools中空值处理的问题,并更新pom版本至0.0.100-SNAPSHOT。

- 将模型类按功能模块划分到ds子包中
- 为VO类添加序列化支持
- 移除冗余的serialVersionUID字段
- 修复UITools空值处理问题
- 更新项目版本号
This commit is contained in:
2025-10-09 18:27:48 +08:00
parent 51b8c16798
commit c4eec0a9dd
457 changed files with 8426 additions and 3669 deletions

View File

@@ -0,0 +1,98 @@
# Service缓存非Vo对象分析报告
## 1. 问题概述
本报告针对Contract-Manager项目中服务层(Service)使用`@Cacheable`注解但返回非Vo对象的问题进行分析和验证。通过对项目代码的全面检查确认之前发现的所有问题都已成功修复。
## 2. 修复情况验证
通过对项目代码的重新分析和搜索,确认以下服务类中使用`@Cacheable`注解的方法已全部修复为返回Vo对象
### 2.1 SalesBillVoucherService
```java
@Cacheable(key = "#p0")
@Override
public SalesBillVoucherVo findById(Integer id) {
return salesBillVoucherRepository.findById(id).map(SalesBillVoucher::toVo).orElse(null);
}
@Cacheable(key = "'code-'+#p0")
public SalesBillVoucherVo findByCode(String code) {
return salesBillVoucherRepository.findByCode(code).map(SalesBillVoucher::toVo).orElse(null);
}
```
**修复情况**:已完全修复,所有带`@Cacheable`注解的方法都返回SalesBillVoucherVo对象。
### 2.2 PurchaseBillVoucherService
```java
@Cacheable(key = "'code-'+#p0")
public PurchaseBillVoucherVo findByCode(String code) {
return repository.findByCode(code).map(PurchaseBillVoucher::toVo).orElse(null);
}
@Cacheable(key = "'refId-'+#p0")
public PurchaseBillVoucherVo findByRefId(Integer refId) {
return repository.findByRefId(refId).map(PurchaseBillVoucher::toVo).orElse(null);
}
```
**修复情况**:已完全修复,所有带`@Cacheable`注解的方法都返回PurchaseBillVoucherVo对象。
### 2.3 PurchaseOrdersService
```java
@Cacheable(key = "'code-'+#p0")
public PurchaseOrderVo findByCode(String code) {
return repository.findByCode(code).map(PurchaseOrder::toVo).orElse(null);
}
@Cacheable(key = "'refId-'+#p0")
public PurchaseOrderVo findByRefId(Integer refId) {
return repository.findByRefId(refId).map(PurchaseOrder::toVo).orElse(null);
}
```
**修复情况**:已完全修复,所有带`@Cacheable`注解的方法都返回PurchaseOrderVo对象。
### 2.4 VendorService
```java
@Cacheable(key = "#p0")
public VendorVo findById(Integer id) {
return repository.findById(id).map(Vendor::toVo).orElse(null);
}
```
**修复情况**已完全修复findById方法返回VendorVo对象。
## 3. 全局验证
通过使用正则表达式搜索:`@Cacheable.*\)\s*(public|private|protected)\s+((?!.*Vo).)+\s+\w+\s*\(`
在整个项目的server模块中搜索所有使用`@Cacheable`注解但返回非Vo对象的方法**结果为空**,说明项目中已经不存在此类问题。
## 4. 修复方法总结
所有修复均采用了统一的模式:
1. 修改方法的返回类型从实体类改为对应的Vo类
2. 使用`map(Entity::toVo)`方法将查询到的实体对象转换为Vo对象
3. 保留了原有的缓存键策略
## 5. 结论
Contract-Manager项目中使用`@Cacheable`注解但返回非Vo对象的问题已**全部修复**。所有服务层的缓存方法现在都返回适当的Vo对象这有助于
1. 避免潜在的序列化问题和数据泄露风险
2. 保持代码风格的一致性
3. 更好地分离数据访问和展示层的职责
4. 提高系统的可维护性和安全性
## 6. 未来建议
1. 在添加新的缓存方法时请确保遵循返回Vo对象的最佳实践
2. 定期执行代码审查,确保没有新的类似问题引入
3. 考虑添加自动化测试或静态代码分析工具来检测此类问题