You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
2.7 KiB
125 lines
2.7 KiB
package com.atm.model;
|
|
|
|
import jakarta.persistence.*;
|
|
import java.math.BigDecimal;
|
|
import java.time.LocalDateTime;
|
|
|
|
/**
|
|
* 账户实体类
|
|
*/
|
|
@Entity
|
|
@Table(name = "account")
|
|
public class Account {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
@Column(name = "aid")
|
|
private Long aid;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
@JoinColumn(name = "cid", nullable = false)
|
|
private Customer customer;
|
|
|
|
@Column(name = "atype", nullable = false)
|
|
private String atype;
|
|
|
|
@Column(name = "abalance", precision = 15, scale = 2)
|
|
private BigDecimal abalance;
|
|
|
|
@Column(name = "astatus")
|
|
private String astatus;
|
|
|
|
@Column(name = "created_at")
|
|
private LocalDateTime createdAt;
|
|
|
|
@Column(name = "updated_at")
|
|
private LocalDateTime updatedAt;
|
|
|
|
// 默认构造函数
|
|
public Account() {
|
|
this.abalance = BigDecimal.ZERO;
|
|
this.astatus = "active";
|
|
this.createdAt = LocalDateTime.now();
|
|
this.updatedAt = LocalDateTime.now();
|
|
}
|
|
|
|
// 带参构造函数
|
|
public Account(Customer customer, String atype) {
|
|
this();
|
|
this.customer = customer;
|
|
this.atype = atype;
|
|
}
|
|
|
|
// Getter和Setter方法
|
|
public Long getAid() {
|
|
return aid;
|
|
}
|
|
|
|
public void setAid(Long aid) {
|
|
this.aid = aid;
|
|
}
|
|
|
|
public Customer getCustomer() {
|
|
return customer;
|
|
}
|
|
|
|
public void setCustomer(Customer customer) {
|
|
this.customer = customer;
|
|
}
|
|
|
|
public String getAtype() {
|
|
return atype;
|
|
}
|
|
|
|
public void setAtype(String atype) {
|
|
this.atype = atype;
|
|
}
|
|
|
|
public BigDecimal getAbalance() {
|
|
return abalance;
|
|
}
|
|
|
|
public void setAbalance(BigDecimal abalance) {
|
|
this.abalance = abalance;
|
|
}
|
|
|
|
public String getAstatus() {
|
|
return astatus;
|
|
}
|
|
|
|
public void setAstatus(String astatus) {
|
|
this.astatus = astatus;
|
|
}
|
|
|
|
public LocalDateTime getCreatedAt() {
|
|
return createdAt;
|
|
}
|
|
|
|
public void setCreatedAt(LocalDateTime createdAt) {
|
|
this.createdAt = createdAt;
|
|
}
|
|
|
|
public LocalDateTime getUpdatedAt() {
|
|
return updatedAt;
|
|
}
|
|
|
|
public void setUpdatedAt(LocalDateTime updatedAt) {
|
|
this.updatedAt = updatedAt;
|
|
}
|
|
|
|
@PreUpdate
|
|
public void preUpdate() {
|
|
this.updatedAt = LocalDateTime.now();
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "Account{" +
|
|
"aid=" + aid +
|
|
", customer=" + (customer != null ? customer.getCid() : null) +
|
|
", atype='" + atype + '\'' +
|
|
", abalance=" + abalance +
|
|
", astatus='" + astatus + '\'' +
|
|
'}';
|
|
}
|
|
} |