refactor(service): 统一Service缓存为VO对象并优化关联实体处理
重构Service类实现,将QueryService泛型参数调整为VO类型,确保缓存VO对象而非实体。优化关联实体处理逻辑,减少重复代码。修改findById方法返回VO对象,新增getById方法获取实体。更新相关调用点以适配新接口。 调整WebSocket处理、控制器及Service实现,确保数据类型一致性。完善文档记录重构过程及发现的问题。为后续优化提供基础架构支持。
This commit is contained in:
@@ -4,6 +4,7 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.vo.CompanyInvoiceInfoVo;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -26,7 +27,7 @@ import lombok.ToString;
|
||||
@Entity
|
||||
@Table(name = "COMPANY_INVOICE_INFO", schema = "supplier_ms")
|
||||
@ToString
|
||||
public class CompanyInvoiceInfo implements IdentityEntity, NamedEntity, BasedEntity, CompanyBasedEntity, Serializable {
|
||||
public class CompanyInvoiceInfo implements IdentityEntity, NamedEntity, BasedEntity, CompanyBasedEntity, Serializable, Voable<CompanyInvoiceInfoVo> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@@ -79,4 +80,20 @@ public class CompanyInvoiceInfo implements IdentityEntity, NamedEntity, BasedEnt
|
||||
public final int hashCode() {
|
||||
return HibernateProxyUtils.hashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyInvoiceInfoVo toVo() {
|
||||
CompanyInvoiceInfoVo vo = new CompanyInvoiceInfoVo();
|
||||
vo.setId(id);
|
||||
vo.setName(name);
|
||||
if (company != null) {
|
||||
vo.setCompanyId(company.getId());
|
||||
}
|
||||
vo.setTaxId(taxId);
|
||||
vo.setAddress(address);
|
||||
vo.setPhone(phone);
|
||||
vo.setBankName(bankName);
|
||||
vo.setBankAccount(bankAccount);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.Objects;
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.vo.CompanyOldNameVo;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -24,7 +25,7 @@ import lombok.ToString;
|
||||
@Entity
|
||||
@Table(name = "COMPANY_OLDNAME")
|
||||
@ToString
|
||||
public class CompanyOldName implements IdentityEntity, NamedEntity, Serializable {
|
||||
public class CompanyOldName implements IdentityEntity, NamedEntity, Serializable, Voable<CompanyOldNameVo> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@@ -79,4 +80,19 @@ public class CompanyOldName implements IdentityEntity, NamedEntity, Serializable
|
||||
public final int hashCode() {
|
||||
return HibernateProxyUtils.hashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyOldNameVo toVo() {
|
||||
CompanyOldNameVo vo = new CompanyOldNameVo();
|
||||
vo.setId(id);
|
||||
vo.setCompanyId(companyId);
|
||||
vo.setName(name);
|
||||
vo.setBeginDate(beginDate);
|
||||
vo.setEndDate(endDate);
|
||||
vo.setAmbiguity(ambiguity);
|
||||
vo.setPath(path);
|
||||
vo.setMemo(memo);
|
||||
vo.setVersion(version);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.vo.ContractBidVendorVo;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -28,7 +29,7 @@ import lombok.ToString;
|
||||
|
||||
})
|
||||
@ToString
|
||||
public class ContractBidVendor implements IdentityEntity, ContractBasedEntity, Serializable {
|
||||
public class ContractBidVendor implements IdentityEntity, ContractBasedEntity, Serializable, Voable<ContractBidVendorVo> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@@ -70,4 +71,20 @@ public class ContractBidVendor implements IdentityEntity, ContractBasedEntity, S
|
||||
public final int hashCode() {
|
||||
return HibernateProxyUtils.hashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractBidVendorVo toVo() {
|
||||
ContractBidVendorVo vo = new ContractBidVendorVo();
|
||||
vo.setId(id);
|
||||
if (contract != null) {
|
||||
vo.setContractId(contract.getId());
|
||||
}
|
||||
if (company != null) {
|
||||
vo.setCompanyId(company.getId());
|
||||
}
|
||||
if (quotationSheet != null) {
|
||||
vo.setQuotationSheetFileId(quotationSheet.getId());
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ public class ContractPayPlan implements IdentityEntity, ContractBasedEntity, Ser
|
||||
vo.setContractId(contract.getId());
|
||||
}
|
||||
vo.setRefId(refId);
|
||||
vo.setPayRatio(payRatio);
|
||||
vo.setPayCurrency(payCurrency);
|
||||
vo.setPayDate(payDate);
|
||||
vo.setUpdateDate(updateDate);
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.vo.CustomerCatalogVo;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -23,7 +24,7 @@ import lombok.ToString;
|
||||
@Entity
|
||||
@Table(name = "CUSTOMER_CATALOG", schema = "supplier_ms")
|
||||
@ToString
|
||||
public class CustomerCatalog implements BasedEntity, IdentityEntity, Serializable {
|
||||
public class CustomerCatalog implements BasedEntity, IdentityEntity, Serializable, Voable<CustomerCatalogVo> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@Column(name = "ID", nullable = false)
|
||||
@@ -64,4 +65,14 @@ public class CustomerCatalog implements BasedEntity, IdentityEntity, Serializabl
|
||||
public final int hashCode() {
|
||||
return HibernateProxyUtils.hashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomerCatalogVo toVo() {
|
||||
CustomerCatalogVo vo = new CustomerCatalogVo();
|
||||
vo.setId(id);
|
||||
vo.setCode(code);
|
||||
vo.setName(name);
|
||||
vo.setDescription(description);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.vo.FunctionVo;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
@@ -17,7 +18,7 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@jakarta.persistence.Entity
|
||||
@Table(name = "FUNC", schema = "supplier_ms")
|
||||
public class Function implements IdentityEntity, NamedEntity, Serializable {
|
||||
public class Function implements IdentityEntity, NamedEntity, Serializable, Voable<FunctionVo> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@@ -60,4 +61,17 @@ public class Function implements IdentityEntity, NamedEntity, Serializable {
|
||||
public final int hashCode() {
|
||||
return HibernateProxyUtils.hashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FunctionVo toVo() {
|
||||
FunctionVo vo = new FunctionVo();
|
||||
vo.setId(id);
|
||||
vo.setName(name);
|
||||
vo.setKey(key);
|
||||
vo.setActive(active);
|
||||
vo.setController(controller);
|
||||
vo.setIcon(icon);
|
||||
vo.setDescription(description);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.vo.InventoryCatalogVo;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -21,7 +22,7 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "INVENTORY_CATALOG", schema = "supplier_ms")
|
||||
public class InventoryCatalog implements IdentityEntity, BasedEntity, Serializable {
|
||||
public class InventoryCatalog implements IdentityEntity, BasedEntity, Serializable, Voable<InventoryCatalogVo> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@@ -53,4 +54,13 @@ public class InventoryCatalog implements IdentityEntity, BasedEntity, Serializab
|
||||
public final int hashCode() {
|
||||
return HibernateProxyUtils.hashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryCatalogVo toVo() {
|
||||
InventoryCatalogVo vo = new InventoryCatalogVo();
|
||||
vo.setId(id);
|
||||
vo.setName(name);
|
||||
vo.setCode(code);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.vo.PermissionVo;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.FetchType;
|
||||
@@ -21,7 +22,7 @@ import lombok.ToString;
|
||||
@Setter
|
||||
@jakarta.persistence.Entity
|
||||
@Table(name = "PERMISSION", schema = "supplier_ms")
|
||||
public class Permission implements IdentityEntity, NamedEntity, Serializable {
|
||||
public class Permission implements IdentityEntity, NamedEntity, Serializable, Voable<PermissionVo> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@@ -56,4 +57,14 @@ public class Permission implements IdentityEntity, NamedEntity, Serializable {
|
||||
public final int hashCode() {
|
||||
return HibernateProxyUtils.hashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionVo toVo() {
|
||||
PermissionVo vo = new PermissionVo();
|
||||
vo.setId(id);
|
||||
vo.setName(name);
|
||||
vo.setKey(key);
|
||||
vo.setFunctionId(function.getId());
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.vo.ProductUsageVo;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -21,7 +22,7 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "PRODUCT_USAGE", schema = "supplier_ms")
|
||||
public class ProductUsage implements BasedEntity, IdentityEntity, Serializable {
|
||||
public class ProductUsage implements BasedEntity, IdentityEntity, Serializable, Voable<ProductUsageVo> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@Column(name = "ID", nullable = false)
|
||||
@@ -56,4 +57,14 @@ public class ProductUsage implements BasedEntity, IdentityEntity, Serializable {
|
||||
public final int hashCode() {
|
||||
return HibernateProxyUtils.hashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductUsageVo toVo() {
|
||||
ProductUsageVo vo = new ProductUsageVo();
|
||||
vo.setId(id);
|
||||
vo.setName(name);
|
||||
vo.setCode(code);
|
||||
vo.setDescription(description);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
@@ -178,12 +178,10 @@ public class ProjectBid implements IdentityEntity, ProjectBasedEntity, Serializa
|
||||
vo.setBidAcceptanceLetterFile(bidAcceptanceLetterFile);
|
||||
if (applicant != null) {
|
||||
vo.setApplicantId(applicant.getId());
|
||||
vo.setApplicantName(applicant.getName());
|
||||
}
|
||||
vo.setApplyTime(applyTime);
|
||||
if (authorizer != null) {
|
||||
vo.setAuthorizerId(authorizer.getId());
|
||||
vo.setAuthorizerName(authorizer.getName());
|
||||
}
|
||||
vo.setAuthorizationTime(authorizationTime);
|
||||
vo.setDescription(description);
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.vo.ProjectIndustryVo;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -25,7 +26,7 @@ import lombok.ToString;
|
||||
|
||||
})
|
||||
@ToString
|
||||
public class ProjectIndustry implements BasedEntity, IdentityEntity, NamedEntity, Serializable {
|
||||
public class ProjectIndustry implements BasedEntity, IdentityEntity, NamedEntity, Serializable, Voable<ProjectIndustryVo> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@Column(name = "ID", nullable = false)
|
||||
@@ -65,4 +66,14 @@ public class ProjectIndustry implements BasedEntity, IdentityEntity, NamedEntity
|
||||
public final int hashCode() {
|
||||
return HibernateProxyUtils.hashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectIndustryVo toVo() {
|
||||
ProjectIndustryVo vo = new ProjectIndustryVo();
|
||||
vo.setId(id);
|
||||
vo.setName(name);
|
||||
vo.setCode(code);
|
||||
vo.setDescription(description);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.vo.ProjectSaleTypeVo;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -21,7 +22,8 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "PROJECT_SALE_TYPE")
|
||||
public class ProjectSaleType implements IdentityEntity, NamedEntity, BasedEntity, Serializable {
|
||||
public class ProjectSaleType
|
||||
implements IdentityEntity, NamedEntity, BasedEntity, Serializable, Voable<ProjectSaleTypeVo> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@Column(name = "ID", nullable = false)
|
||||
@@ -82,4 +84,19 @@ public class ProjectSaleType implements IdentityEntity, NamedEntity, BasedEntity
|
||||
public final int hashCode() {
|
||||
return HibernateProxyUtils.hashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectSaleTypeVo toVo() {
|
||||
ProjectSaleTypeVo vo = new ProjectSaleTypeVo();
|
||||
vo.setId(id);
|
||||
vo.setName(name);
|
||||
vo.setCode(code);
|
||||
vo.setPath(path);
|
||||
vo.setDescription(description);
|
||||
vo.setStoreByYear(storeByYear);
|
||||
vo.setCriticalProjectDecision(criticalProjectDecision);
|
||||
vo.setCriticalProjectLimit(criticalProjectLimit);
|
||||
vo.setActive(active);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.ContractFileType;
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.vo.ProjectSaleTypeRequireFileTypeVo;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -27,7 +28,7 @@ import lombok.ToString;
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "PROJECT_SALE_TYPE_REQ_FILE_TYPE")
|
||||
public class ProjectSaleTypeRequireFileType implements IdentityEntity, BasedEntity, java.io.Serializable {
|
||||
public class ProjectSaleTypeRequireFileType implements IdentityEntity, BasedEntity, java.io.Serializable , Voable<ProjectSaleTypeRequireFileTypeVo>{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@Column(name = "ID", nullable = false)
|
||||
@@ -74,4 +75,14 @@ public class ProjectSaleTypeRequireFileType implements IdentityEntity, BasedEnti
|
||||
public final int hashCode() {
|
||||
return HibernateProxyUtils.hashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectSaleTypeRequireFileTypeVo toVo() {
|
||||
ProjectSaleTypeRequireFileTypeVo vo = new ProjectSaleTypeRequireFileTypeVo();
|
||||
vo.setId(id);
|
||||
vo.setSaleTypeId(saleType.getId());
|
||||
vo.setFileType(fileType);
|
||||
vo.setFrequency(frequency.name());
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.vo.PurchaseOrderItemVo;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -27,7 +28,8 @@ import lombok.ToString;
|
||||
@Entity
|
||||
@Table(name = "PURCHASE_ORDER_ITEM", schema = "supplier_ms")
|
||||
@ToString
|
||||
public class PurchaseOrderItem implements IdentityEntity, BasedEntity, java.io.Serializable {
|
||||
public class PurchaseOrderItem
|
||||
implements IdentityEntity, BasedEntity, java.io.Serializable, Voable<PurchaseOrderItemVo> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@@ -98,4 +100,20 @@ public class PurchaseOrderItem implements IdentityEntity, BasedEntity, java.io.S
|
||||
public String toPrettyString() {
|
||||
return "#" + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PurchaseOrderItemVo toVo() {
|
||||
PurchaseOrderItemVo vo = new PurchaseOrderItemVo();
|
||||
vo.setId(id);
|
||||
vo.setOrder(order != null ? order.getId() : null);
|
||||
vo.setRefId(refId);
|
||||
vo.setInventoryId(inventory != null ? inventory.getId() : null);
|
||||
vo.setQuantity(quantity);
|
||||
vo.setPrice(price);
|
||||
vo.setTaxRate(taxRate);
|
||||
vo.setExclusiveTaxPrice(exclusiveTaxPrice);
|
||||
vo.setArriveDate(arriveDate);
|
||||
vo.setDescription(description);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +126,7 @@ public class SalesOrder
|
||||
vo.setVerifierId(verifier.getId());
|
||||
}
|
||||
vo.setVerifierDate(verifierDate);
|
||||
vo.setDescription(description);
|
||||
|
||||
// active字段默认为false,在SalesOrderVo类中已经设置
|
||||
return vo;
|
||||
|
||||
@@ -9,5 +9,4 @@ public class ContractBidVendorVo implements IdentityEntity, ContractBasedVo, Com
|
||||
private Integer contractId;
|
||||
private Integer companyId;
|
||||
private Integer quotationSheetFileId;
|
||||
private String quotationSheetFileName;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ecep.contract.vo;
|
||||
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
|
||||
@@ -16,13 +16,17 @@ public class ProjectBidVo implements IdentityEntity, ProjectBasedVo {
|
||||
private String noStandardPayWayText;
|
||||
private boolean standardContractText = false;
|
||||
private String noStandardContractText;
|
||||
/**
|
||||
* 审核文件
|
||||
*/
|
||||
private String authorizationFile;
|
||||
/**
|
||||
* 中标通知书文件
|
||||
*/
|
||||
private String bidAcceptanceLetterFile;
|
||||
private Integer applicantId;
|
||||
private String applicantName;
|
||||
private LocalDateTime applyTime;
|
||||
private Integer authorizerId;
|
||||
private String authorizerName;
|
||||
private LocalDateTime authorizationTime;
|
||||
private String description;
|
||||
private boolean active = false;
|
||||
|
||||
@@ -9,7 +9,6 @@ import lombok.Data;
|
||||
public class ProjectSaleTypeRequireFileTypeVo implements IdentityEntity {
|
||||
private Integer id;
|
||||
private Integer saleTypeId;
|
||||
private String saleTypeName;
|
||||
private ContractFileType fileType;
|
||||
private String frequency;
|
||||
private ContractFileType fileType;
|
||||
}
|
||||
Reference in New Issue
Block a user