TODO:bug fix
This commit is contained in:
parent
c6e1ec0771
commit
d248755b28
@ -26,8 +26,7 @@ public class Dishes {
|
||||
private BigDecimal finalPrice;//菜品最终价格
|
||||
private String description;//菜品描述
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "merchantsID", referencedColumnName = "id")
|
||||
@Column(name = "merchantsID")
|
||||
private Merchants merchants;//商家
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.example.springdemo.entities;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ -23,6 +24,5 @@ public class Merchants {
|
||||
|
||||
//商家和菜品是一对多的关系,有mappedBy的时候,表示Merchants的dishes 字段放弃维护权,而将维护权交给了Dishes的关联属性merchants
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "merchants")
|
||||
@Column(name = "dishesID")
|
||||
private List<Dishes> dishes;//菜品
|
||||
private List<Dishes> dishes = new ArrayList<>();//菜品
|
||||
}
|
||||
|
@ -19,15 +19,14 @@ public class OrderDishes {
|
||||
private Long id;//主键ID
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "dishesID", referencedColumnName = "id")
|
||||
@Column(name = "dishesID")
|
||||
@PrimaryKeyJoinColumn(name = "dishesID", referencedColumnName = "id")
|
||||
private Dishes dishes;//菜品ID
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "merchantsID", referencedColumnName = "id")
|
||||
@PrimaryKeyJoinColumn(name = "merchantsID", referencedColumnName = "id")
|
||||
private Merchants merchants;//商家ID
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "ordersID", referencedColumnName = "id")
|
||||
private Orders orders;//订单ID
|
||||
}
|
@ -1,13 +1,11 @@
|
||||
package com.example.springdemo.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ -24,12 +22,11 @@ public class Orders {
|
||||
private Long id;//订单ID
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "orders")
|
||||
@Column(name = "orderDishesID")
|
||||
private List<OrderDishes> orderDishes;//订单中的菜品
|
||||
private List<OrderDishes> orderDishes = new ArrayList<>();//订单中的菜品
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "usersID", referencedColumnName = "id")
|
||||
@Column(name = "usersID")
|
||||
//多个订单对应一个用户,关系是多对一,订单创建后添加用户ID,可以主动改变关系,因此是主控方
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinTable()
|
||||
private Users user;//外键,下单用户
|
||||
|
||||
@Column(name = "allPrice")
|
||||
|
@ -14,9 +14,11 @@ public class RolesPermissions {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;//主键
|
||||
|
||||
@OneToMany(targetEntity = Roles.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@Column(name = "RolesID")
|
||||
private List<Roles> roles;//角色ID
|
||||
|
||||
@OneToMany(targetEntity = Permissions.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@Column(name = "PermissionsID")
|
||||
private List<Permissions> permissions;//权限ID
|
||||
|
@ -7,6 +7,7 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
//用户类
|
||||
@ -26,12 +27,12 @@ public class Users {
|
||||
private String phoneNumber;//用户联系方式
|
||||
private String address;//家庭住址
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
|
||||
@Column(name = "ordersID")
|
||||
private List<Orders> orders;//订单
|
||||
//一个用户可能会有多个订单,关系是一对多
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "id")
|
||||
private List<Orders> orders = new ArrayList<>();//订单
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "rolesID", referencedColumnName = "id")
|
||||
@Column(name = "rolesID")
|
||||
private Roles roles;//RBAC角色
|
||||
}
|
||||
|
@ -12,8 +12,7 @@ import lombok.NoArgsConstructor;
|
||||
public class MerchantsPassword {
|
||||
@Id
|
||||
@OneToOne
|
||||
@Column(name = "merchantID")
|
||||
@JoinColumn(name = "merchantID", referencedColumnName = "id")
|
||||
@PrimaryKeyJoinColumn(name = "merchantID", referencedColumnName = "id")
|
||||
private Merchants merchants;
|
||||
private String password;
|
||||
}
|
||||
|
@ -12,8 +12,7 @@ import lombok.NoArgsConstructor;
|
||||
public class UsersPassword {
|
||||
@Id
|
||||
@OneToOne
|
||||
@Column(name = "userID")
|
||||
@JoinColumn(name = "userID", referencedColumnName = "id")
|
||||
@PrimaryKeyJoinColumn(name = "userID", referencedColumnName = "id")
|
||||
private Users users;
|
||||
private String password;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user