Lombok @Data 注解替换为 @Getter @Setter注解
This commit is contained in:
parent
87c09d8572
commit
9a0f860092
@ -1,14 +1,12 @@
|
||||
package com.example.springdemo.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ -28,7 +26,7 @@ public class Dishes {
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "merchants_dishes",
|
||||
joinColumns = {@JoinColumn(name = "dishesID", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "merchantsID", referencedColumnName = "id")})
|
||||
joinColumns = {@JoinColumn(name = "dishesId", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "merchantsId", referencedColumnName = "id")})
|
||||
private Merchants merchants;//商家
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
package com.example.springdemo.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@ -23,8 +26,8 @@ public class Merchants {
|
||||
|
||||
//商家和菜品是一对多的关系,有mappedBy的时候,表示Merchants的dishes 字段放弃维护权,而将维护权交给了Dishes的关联属性merchants
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "Merchants_Dishes",
|
||||
joinColumns = @JoinColumn(name = "merchantsID"),
|
||||
inverseJoinColumns = @JoinColumn(name = "dishesID"))
|
||||
private List<Dishes> dishes = new ArrayList<>();//菜品
|
||||
@JoinTable(name = "merchants_dishes",
|
||||
joinColumns = @JoinColumn(name = "merchantsId"),
|
||||
inverseJoinColumns = @JoinColumn(name = "dishesId"))
|
||||
private List<Dishes> dishes;//菜品
|
||||
}
|
||||
|
@ -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.*;
|
||||
|
||||
//订单中的菜品
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ -19,16 +17,16 @@ public class OrderDishes {
|
||||
private Long id;//主键ID
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@PrimaryKeyJoinColumn(name = "dishesID", referencedColumnName = "id")
|
||||
@PrimaryKeyJoinColumn(name = "dishesId", referencedColumnName = "id")
|
||||
private Dishes dishes;//菜品ID
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
@PrimaryKeyJoinColumn(name = "merchantsID", referencedColumnName = "id")
|
||||
@PrimaryKeyJoinColumn(name = "merchantsId", referencedColumnName = "id")
|
||||
private Merchants merchants;//商家ID
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "orders_orderDishes",
|
||||
joinColumns = @JoinColumn(name = "orderDishesID"),
|
||||
inverseJoinColumns = @JoinColumn(name = "ordersID"))
|
||||
joinColumns = @JoinColumn(name = "orderDishesId"),
|
||||
inverseJoinColumns = @JoinColumn(name = "ordersId"))
|
||||
private Orders orders;//订单ID
|
||||
}
|
@ -1,16 +1,19 @@
|
||||
package com.example.springdemo.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
//订单类
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@ -22,15 +25,15 @@ public class Orders {
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "orders_orderDishes",
|
||||
joinColumns = {@JoinColumn(name = "ordersID", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "orderDishesID", referencedColumnName = "id")})
|
||||
private List<OrderDishes> orderDishes = new ArrayList<>();//订单中的菜品
|
||||
joinColumns = {@JoinColumn(name = "ordersId", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "orderDishesId", referencedColumnName = "id")})
|
||||
private List<OrderDishes> orderDishes;//订单中的菜品
|
||||
|
||||
//多个订单对应一个用户,关系是多对一,订单创建后添加用户ID,可以主动改变关系,因此是主控方
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "users_orders",
|
||||
joinColumns = {@JoinColumn(name = "ordersID", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "usersID", referencedColumnName = "id")})
|
||||
joinColumns = {@JoinColumn(name = "ordersId", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "usersId", referencedColumnName = "id")})
|
||||
private Users user;//外键,下单用户
|
||||
|
||||
@Column(name = "allPrice")
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.example.springdemo.entities.RBAC;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "Permissions")
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.example.springdemo.entities.RBAC;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "Roles")
|
||||
|
@ -1,12 +1,14 @@
|
||||
package com.example.springdemo.entities.RBAC;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "roles_permissions")
|
||||
@ -16,10 +18,10 @@ public class RolesPermissions {
|
||||
private Long id;//主键
|
||||
|
||||
@OneToMany(targetEntity = Roles.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@Column(name = "RolesID")
|
||||
@Column(name = "rolesId")
|
||||
private List<Roles> roles;//角色ID
|
||||
|
||||
@OneToMany(targetEntity = Permissions.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@Column(name = "PermissionsID")
|
||||
@Column(name = "permissionsId")
|
||||
private List<Permissions> permissions;//权限ID
|
||||
}
|
||||
|
@ -2,16 +2,13 @@ package com.example.springdemo.entities;
|
||||
|
||||
import com.example.springdemo.entities.RBAC.Roles;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
//用户类
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ -30,13 +27,13 @@ public class Users {
|
||||
//一个用户可能会有多个订单,关系是一对多
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "users_orders",
|
||||
joinColumns = {@JoinColumn(name = "usersID", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "ordersID", referencedColumnName = "id")})
|
||||
private List<Orders> orders = new ArrayList<>();//订单
|
||||
joinColumns = {@JoinColumn(name = "usersId", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "ordersId", referencedColumnName = "id")})
|
||||
private List<Orders> orders;//订单
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "users_roles",
|
||||
joinColumns = {@JoinColumn(name = "usersID", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "rolesID", referencedColumnName = "id")})
|
||||
joinColumns = {@JoinColumn(name = "usersId", referencedColumnName = "id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "rolesId", referencedColumnName = "id")})
|
||||
private Roles roles;//RBAC角色
|
||||
}
|
||||
|
@ -2,10 +2,12 @@ package com.example.springdemo.entities.password;
|
||||
|
||||
import com.example.springdemo.entities.Merchants;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "MerchantsPassword")
|
||||
@ -15,7 +17,7 @@ public class MerchantsPassword {
|
||||
private Long merchantsID;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "merchantsID", referencedColumnName = "id")
|
||||
@JoinColumn(name = "merchantsId", referencedColumnName = "id")
|
||||
private Merchants merchants;
|
||||
|
||||
private String password;
|
||||
|
@ -2,10 +2,12 @@ package com.example.springdemo.entities.password;
|
||||
|
||||
import com.example.springdemo.entities.Users;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "UsersPassword")
|
||||
@ -15,7 +17,7 @@ public class UsersPassword {
|
||||
private Long id;
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "usersID", referencedColumnName = "id")
|
||||
@JoinColumn(name = "usersId", referencedColumnName = "id")
|
||||
private Users users;
|
||||
|
||||
private String password;
|
||||
|
@ -1,6 +1,9 @@
|
||||
package com.example.springdemo.utils;
|
||||
|
||||
import lombok.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user