新增外键注释

This commit is contained in:
myh 2023-10-26 11:17:08 +08:00
parent a2bc716716
commit 251f379035
3 changed files with 19 additions and 14 deletions

View File

@ -1,9 +1,11 @@
package com.example.springdemo.entities; package com.example.springdemo.entities;
import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import java.util.Date; import java.util.Date;
@ -12,13 +14,18 @@ import java.util.Date;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Entity
@Table(name = "Indent")
public class Indent { public class Indent {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;//订单ID private Long id;//订单ID
private Float allPrice;//菜品总价 private Float allPrice;//菜品总价
Date createdDate;//订单创建时间 @CreatedDate
private Date createdDate;//订单创建时间
private String message;//下单备注 private String message;//下单备注
@OneToOne
private Users userID;//外键下单用户ID private Users userID;//外键下单用户ID
@OneToOne
private Merchants merchantsID;//外键餐厅ID private Merchants merchantsID;//外键餐厅ID
} }

View File

@ -1,5 +1,6 @@
package com.example.springdemo.entities; package com.example.springdemo.entities;
import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@ -10,13 +11,18 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Entity
public class IndentItem { public class IndentItem {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;//主键菜品ID private Long id;//主键菜品ID
private String name;//菜品名字 private String name;//菜品名字
@Column(name = "initialPrice")
private Float initialPrice;//菜品原价 private Float initialPrice;//菜品原价
private Float discount;//折扣 private Float discount;//折扣
@Column(name = "finalPrice")
private Float finalPrice;//最终价格 private Float finalPrice;//最终价格
private String description;//菜品描述 private String description;//菜品描述
@OneToOne
private Indent indentID;//外键订单ID private Indent indentID;//外键订单ID
} }

View File

@ -1,9 +1,6 @@
package com.example.springdemo.entities; package com.example.springdemo.entities;
import jakarta.persistence.Column; import jakarta.persistence.*;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.*; import lombok.*;
@Data @Data
@ -12,18 +9,13 @@ import lombok.*;
@AllArgsConstructor @AllArgsConstructor
@Entity @Entity
@Table(name = "Merchants") @Table(name = "Merchants")
public class Merchants { public class Merchants {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;//主键,商家编号 private Long id;//主键,商家编号
private String name;//店铺名字 private String name;//店铺名字
private String address;//店铺地址 private String address;//店铺地址
private String description;//店铺描述 private String description;//店铺描述
@Column(name = "phoneNumber") @Column(name = "phoneNumber")
private String phoneNumber;//商家联系方式 private String phoneNumber;//商家联系方式