1.课程介绍
1. 采购订单模型设计(了解)
2. 建立采购订单模型(掌握)
3. 对采购订单进行CRUD(掌握)
明细数据的操作(难点)
一,采购单模型设计
判断数据库联系
如果是下拉列表:一般是多对一,一对一
如果是复选框:一般是多对多,一对多
采购单组合关系
主表
@Entity
@Table(name="purchasebill")
public class Purchasebill extends BaseDomain {
private Date vdate; // 交易时间 前台传过来
private BigDecimal totalAmount; //订单总金额 --后台计算出来
private BigDecimal totalNum; //订单数量 --后台计算出来
private Date inputtime = new Date();//采购单录入时间 -- 后台生成
private Date auditortime; //审核时间 --- 后台生成
private Integer status = 0; //单据状态 0 表示待审核 1 表示审核 -1表作废
//private Long supplierId;
@ManyToOne(fetch = FetchType.LAZY,optional = false)
@JoinColumn(name="supplier_id")
private Supplier supplier;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="auditor_id")
private Employee auditor;//审核人 录入可以为null
@ManyToOne(fetch = FetchType.LAZY,optional = false)
@JoinColumn(name="inputUser_id")
private Employee inputUser;//录入人 不能为null 当前登陆用户
@ManyToOne(fetch = FetchType.LAZY,optional = false)
@JoinColumn(name="buyer_id")
private Employee buyer;//采购员
//明細 强级联 orphanRemoval 一方解除关系 去删除
@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY,mappedBy = "bill",
orphanRemoval = true)
private List<Purchasebillitem> items = new ArrayList<>();
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
public Date getVdate() {
return vdate;
}
@DateTimeFormat(pattern = "yyyy-MM-dd")
public void setVdate(Date vdate) {
this.vdate = vdate;
}
public BigDecimal getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(BigDecimal totalAmount) {
this.totalAmount = totalAmount;
}
public BigDecimal getTotalNum() {
return totalNum;
}
public void setTotalNum(BigDecimal totalNum) {
this.totalNum = totalNum;
}
public Date getInputtime() {
return inputtime;
}
public void setInputtime(Date inputtime) {
this.inputtime = inputtime;
}
public Date getAuditortime() {
return auditortime;
}
public void setAuditortime(Date auditortime) {
this.auditortime = auditortime;
}
public Integer get