refactor(service): 修改IEntityService泛型为VO类型并优化缓存策略

重构所有注解@CacheConfig的Service类,将IEntityService泛型从实体类改为VO类
实现实体与VO之间的转换逻辑,使用VO替代实体进行缓存以避免序列化问题
更新相关依赖组件和测试用例,确保功能完整性和系统兼容性
优化Redis缓存配置,清理旧缓存数据并验证新缓存策略有效性
This commit is contained in:
2025-09-28 18:19:00 +08:00
parent df6188db40
commit b03b5385a5
75 changed files with 3144 additions and 1377 deletions

View File

@@ -3,7 +3,7 @@ package com.ecep.contract.constant;
public class WebSocketConstant {
public static final String MESSAGE_ID_FIELD_NAME = "messageId";
public static final String MESSAGE_TYPE_FIELD_NAME = "messageType";
public static final String SUCCESS_FIELD_VALUE = "success";
public static final String SUCCESS_FIELD_NAME = "success";
public static final String MESSAGE_FIELD_NAME = "message";
public static final String ERROR_CODE_FIELD_NAME = "errorCode";
@@ -13,5 +13,9 @@ public class WebSocketConstant {
public static final String SESSION_ID_FIELD_NAME = "sessionId";
public static final int ERROR_CODE_UNAUTHORIZED = 401;
public static final int ERROR_CODE_NOT_FOUND = 404;
public static final int ERROR_CODE_INTERNAL_SERVER_ERROR = 500;
}

View File

@@ -17,7 +17,7 @@ import lombok.ToString;
@Setter
@Entity
@Table(name = "COMPANY_CUSTOMER_FILE_TYPE_LOCAL")
@ToString
@ToString(callSuper = true)
public class CompanyCustomerFileTypeLocal extends BaseEnumEntity<CustomerFileType> implements Serializable, Voable<CompanyCustomerFileTypeLocalVo> {
private static final long serialVersionUID = 1L;

View File

@@ -19,7 +19,7 @@ import lombok.Setter;
import lombok.ToString;
/**
* 公司发票信息
* 公司发票信息(开票)
*/
@Getter
@Setter

View File

@@ -5,6 +5,8 @@ import java.time.LocalDate;
import java.util.Objects;
import com.ecep.contract.ContractFileType;
import com.ecep.contract.model.Voable;
import com.ecep.contract.vo.ContractFileVo;
import com.ecep.contract.util.HibernateProxyUtils;
import jakarta.persistence.Column;
@@ -30,7 +32,7 @@ import lombok.ToString;
@Entity
@Table(name = "CONTRACT_FILE")
@ToString
public class ContractFile implements IdentityEntity, ContractBasedEntity, Serializable {
public class ContractFile implements IdentityEntity, ContractBasedEntity, Serializable, Voable<ContractFileVo> {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -82,4 +84,23 @@ public class ContractFile implements IdentityEntity, ContractBasedEntity, Serial
public final int hashCode() {
return HibernateProxyUtils.hashCode(this);
}
@Override
public ContractFileVo toVo() {
ContractFileVo vo = new ContractFileVo();
// 基本属性映射
vo.setId(this.getId());
vo.setType(this.getType());
vo.setFileName(this.getFileName());
vo.setApplyDate(this.getApplyDate());
vo.setDescription(this.getDescription());
// 关联对象ID映射
if (this.getContract() != null) {
vo.setContractId(this.getContract().getId());
}
return vo;
}
}

View File

@@ -21,7 +21,7 @@ import lombok.ToString;
@Setter
@Entity
@Table(name = "CONTRACT_FILE_TYPE_LOCAL")
@ToString
@ToString(callSuper = true)
public class ContractFileTypeLocal extends BaseEnumEntity<ContractFileType> implements Serializable, Voable<ContractFileTypeLocalVo> {
private static final long serialVersionUID = 1L;
/**

View File

@@ -5,6 +5,8 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Objects;
import com.ecep.contract.model.Voable;
import com.ecep.contract.vo.InventoryVo;
import com.ecep.contract.util.HibernateProxyUtils;
import jakarta.persistence.AttributeOverride;
@@ -30,7 +32,7 @@ import lombok.ToString;
@Setter
@Entity
@Table(name = "INVENTORY", schema = "supplier_ms")
public class Inventory implements IdentityEntity, BasedEntity, Serializable {
public class Inventory implements IdentityEntity, BasedEntity, Serializable, Voable<InventoryVo> {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -184,4 +186,74 @@ public class Inventory implements IdentityEntity, BasedEntity, Serializable {
public final int hashCode() {
return HibernateProxyUtils.hashCode(this);
}
@Override
public InventoryVo toVo() {
InventoryVo vo = new InventoryVo();
// 基本属性映射
vo.setId(this.getId());
vo.setName(this.getName());
vo.setCode(this.getCode());
vo.setSpecification(this.getSpecification());
vo.setSpecificationLock(this.isSpecificationLock());
vo.setNameLock(this.isNameLock());
vo.setUnit(this.getUnit());
vo.setDescription(this.getDescription());
// 关联对象ID映射
if (this.getCatalog() != null) {
vo.setCatalogId(this.getCatalog().getId());
}
if (this.getCreator() != null) {
vo.setCreatorId(this.getCreator().getId());
}
if (this.getUpdater() != null) {
vo.setUpdaterId(this.getUpdater().getId());
}
// 时间属性映射
vo.setCreateTime(this.getCreateTime());
vo.setUpdateDate(this.getUpdateDate());
// 重量属性映射
vo.setWeight(this.getWeight());
vo.setPackagedWeight(this.getPackagedWeight());
vo.setWeightUnit(this.getWeightUnit());
vo.setVolumeUnit(this.getVolumeUnit());
vo.setSizeUnit(this.getSizeUnit());
// 价格属性映射
Price purchasePrice = new Price();
purchasePrice.setTaxRate(this.getPurchasePrice().getTaxRate());
purchasePrice.setPreTaxPrice(this.getPurchasePrice().getPreTaxPrice());
purchasePrice.setPostTaxPrice(this.getPurchasePrice().getPostTaxPrice());
vo.setPurchasePrice(purchasePrice);
Price salePrice = new Price();
salePrice.setTaxRate(this.getSalePrice().getTaxRate());
salePrice.setPreTaxPrice(this.getSalePrice().getPreTaxPrice());
salePrice.setPostTaxPrice(this.getSalePrice().getPostTaxPrice());
vo.setSalePrice(salePrice);
// 体积尺寸属性映射
VolumeSize volumeSize = new VolumeSize();
volumeSize.setVolume(this.getVolumeSize().getVolume());
volumeSize.setLength(this.getVolumeSize().getLength());
volumeSize.setWidth(this.getVolumeSize().getWidth());
volumeSize.setHeight(this.getVolumeSize().getHeight());
vo.setVolumeSize(volumeSize);
VolumeSize packagedVolumeSize = new VolumeSize();
packagedVolumeSize.setVolume(this.getPackagedVolumeSize().getVolume());
packagedVolumeSize.setLength(this.getPackagedVolumeSize().getLength());
packagedVolumeSize.setWidth(this.getPackagedVolumeSize().getWidth());
packagedVolumeSize.setHeight(this.getPackagedVolumeSize().getHeight());
vo.setPackagedVolumeSize(packagedVolumeSize);
// 设置默认状态
vo.setActive(false);
return vo;
}
}

View File

@@ -23,7 +23,7 @@ import lombok.Setter;
import lombok.ToString;
/**
* 发票
* 收到的公司发票
*/
@Getter
@Setter

View File

@@ -65,6 +65,12 @@ public class ProjectType
@Override
public ProjectTypeVo toVo() {
throw new UnsupportedOperationException("Unimplemented method 'toVo'");
ProjectTypeVo vo = new ProjectTypeVo();
vo.setId(getId());
vo.setName(getName());
vo.setCode(getCode());
vo.setDescription(getDescription());
vo.setActive(false); // 设置默认值
return vo;
}
}