重构所有VO对象,统一字段命名规范,移除冗余字段,优化接口实现 新增Voable接口用于VO对象转换 调整BaseViewModel和ProjectBasedViewModel接口定义 更新相关服务和控制器以适应VO对象变更
106 lines
2.5 KiB
Java
106 lines
2.5 KiB
Java
package com.ecep.contract.model;
|
|
|
|
import java.io.Serializable;
|
|
import java.time.LocalDate;
|
|
import java.util.Objects;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import com.ecep.contract.util.HibernateProxyUtils;
|
|
import com.ecep.contract.vo.InvoiceVo;
|
|
|
|
import jakarta.persistence.Column;
|
|
import jakarta.persistence.Entity;
|
|
import jakarta.persistence.FetchType;
|
|
import jakarta.persistence.GeneratedValue;
|
|
import jakarta.persistence.GenerationType;
|
|
import jakarta.persistence.Id;
|
|
import jakarta.persistence.JoinColumn;
|
|
import jakarta.persistence.ManyToOne;
|
|
import jakarta.persistence.Table;
|
|
import lombok.Getter;
|
|
import lombok.Setter;
|
|
import lombok.ToString;
|
|
|
|
/**
|
|
* 发票
|
|
*/
|
|
@Getter
|
|
@Setter
|
|
@Entity
|
|
@Table(name = "INVOICE", schema = "supplier_ms")
|
|
@ToString
|
|
public class Invoice implements IdentityEntity, BasedEntity, Serializable, Voable<InvoiceVo> {
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
@Column(name = "ID", nullable = false)
|
|
private Integer id;
|
|
|
|
/**
|
|
* 发票号
|
|
*/
|
|
@Column(name = "CODE")
|
|
private String code;
|
|
|
|
/**
|
|
* 发票所属公司
|
|
*/
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
@JoinColumn(name = "COMPANY_ID")
|
|
@ToString.Exclude
|
|
private Company company;
|
|
|
|
/**
|
|
* 发票开票日期
|
|
*/
|
|
@Column(name = "INVOICE_DATE")
|
|
private LocalDate invoiceDate;
|
|
|
|
/**
|
|
* 备注
|
|
*/
|
|
@Column(name = "DESCRIPTION", columnDefinition = "TEXT")
|
|
private String description;
|
|
|
|
@Override
|
|
public String toPrettyString() {
|
|
if (StringUtils.hasText(getCode())) {
|
|
return getCode();
|
|
}
|
|
return "#" + getId();
|
|
}
|
|
|
|
@Override
|
|
public final boolean equals(Object object) {
|
|
if (this == object)
|
|
return true;
|
|
if (object == null)
|
|
return false;
|
|
if (HibernateProxyUtils.isNotEffectiveClassEquals(object, this)) {
|
|
return false;
|
|
}
|
|
Invoice that = (Invoice) object;
|
|
return getId() != null && Objects.equals(getId(), that.getId());
|
|
}
|
|
|
|
@Override
|
|
public final int hashCode() {
|
|
return HibernateProxyUtils.hashCode(this);
|
|
}
|
|
|
|
@Override
|
|
public InvoiceVo toVo() {
|
|
InvoiceVo vo = new InvoiceVo();
|
|
vo.setId(id);
|
|
if (company != null) {
|
|
vo.setCompanyId(company.getId());
|
|
}
|
|
vo.setCode(code);
|
|
vo.setInvoiceDate(invoiceDate);
|
|
vo.setDescription(description);
|
|
return vo;
|
|
}
|
|
}
|