Lombok @Data 注解替换为 @Getter @Setter注解

This commit is contained in:
myh 2023-11-12 16:45:09 +08:00
parent 87c09d8572
commit 9a0f860092
11 changed files with 69 additions and 57 deletions

View File

@ -1,14 +1,12 @@
package com.example.springdemo.entities; package com.example.springdemo.entities;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.*;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal; import java.math.BigDecimal;
@Data @Getter
@Setter
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ -28,7 +26,7 @@ public class Dishes {
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "merchants_dishes", @JoinTable(name = "merchants_dishes",
joinColumns = {@JoinColumn(name = "dishesID", referencedColumnName = "id")}, joinColumns = {@JoinColumn(name = "dishesId", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "merchantsID", referencedColumnName = "id")}) inverseJoinColumns = {@JoinColumn(name = "merchantsId", referencedColumnName = "id")})
private Merchants merchants;//商家 private Merchants merchants;//商家
} }

View File

@ -1,12 +1,15 @@
package com.example.springdemo.entities; package com.example.springdemo.entities;
import jakarta.persistence.*; 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; import java.util.List;
@Data @Getter
@Setter
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Entity @Entity
@ -23,8 +26,8 @@ public class Merchants {
//商家和菜品是一对多的关系有mappedBy的时候表示Merchants的dishes 字段放弃维护权而将维护权交给了Dishes的关联属性merchants //商家和菜品是一对多的关系有mappedBy的时候表示Merchants的dishes 字段放弃维护权而将维护权交给了Dishes的关联属性merchants
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "Merchants_Dishes", @JoinTable(name = "merchants_dishes",
joinColumns = @JoinColumn(name = "merchantsID"), joinColumns = @JoinColumn(name = "merchantsId"),
inverseJoinColumns = @JoinColumn(name = "dishesID")) inverseJoinColumns = @JoinColumn(name = "dishesId"))
private List<Dishes> dishes = new ArrayList<>();//菜品 private List<Dishes> dishes;//菜品
} }

View File

@ -1,13 +1,11 @@
package com.example.springdemo.entities; package com.example.springdemo.entities;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.*;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
//订单中的菜品 //订单中的菜品
@Data @Getter
@Setter
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ -19,16 +17,16 @@ public class OrderDishes {
private Long id;//主键ID private Long id;//主键ID
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn(name = "dishesID", referencedColumnName = "id") @PrimaryKeyJoinColumn(name = "dishesId", referencedColumnName = "id")
private Dishes dishes;//菜品ID private Dishes dishes;//菜品ID
@OneToOne(cascade = CascadeType.ALL) @OneToOne(cascade = CascadeType.ALL)
@PrimaryKeyJoinColumn(name = "merchantsID", referencedColumnName = "id") @PrimaryKeyJoinColumn(name = "merchantsId", referencedColumnName = "id")
private Merchants merchants;//商家ID private Merchants merchants;//商家ID
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "orders_orderDishes", @JoinTable(name = "orders_orderDishes",
joinColumns = @JoinColumn(name = "orderDishesID"), joinColumns = @JoinColumn(name = "orderDishesId"),
inverseJoinColumns = @JoinColumn(name = "ordersID")) inverseJoinColumns = @JoinColumn(name = "ordersId"))
private Orders orders;//订单ID private Orders orders;//订单ID
} }

View File

@ -1,16 +1,19 @@
package com.example.springdemo.entities; package com.example.springdemo.entities;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.*; import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.CreatedDate;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
//订单类 //订单类
@Data @Getter
@Setter
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Entity @Entity
@ -22,15 +25,15 @@ public class Orders {
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "orders_orderDishes", @JoinTable(name = "orders_orderDishes",
joinColumns = {@JoinColumn(name = "ordersID", referencedColumnName = "id")}, joinColumns = {@JoinColumn(name = "ordersId", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "orderDishesID", referencedColumnName = "id")}) inverseJoinColumns = {@JoinColumn(name = "orderDishesId", referencedColumnName = "id")})
private List<OrderDishes> orderDishes = new ArrayList<>();//订单中的菜品 private List<OrderDishes> orderDishes;//订单中的菜品
//多个订单对应一个用户关系是多对一订单创建后添加用户ID可以主动改变关系因此是主控方 //多个订单对应一个用户关系是多对一订单创建后添加用户ID可以主动改变关系因此是主控方
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "users_orders", @JoinTable(name = "users_orders",
joinColumns = {@JoinColumn(name = "ordersID", referencedColumnName = "id")}, joinColumns = {@JoinColumn(name = "ordersId", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "usersID", referencedColumnName = "id")}) inverseJoinColumns = {@JoinColumn(name = "usersId", referencedColumnName = "id")})
private Users user;//外键下单用户 private Users user;//外键下单用户
@Column(name = "allPrice") @Column(name = "allPrice")

View File

@ -1,10 +1,12 @@
package com.example.springdemo.entities.RBAC; package com.example.springdemo.entities.RBAC;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.Data; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter;
@Data @Getter
@Setter
@NoArgsConstructor @NoArgsConstructor
@Entity @Entity
@Table(name = "Permissions") @Table(name = "Permissions")

View File

@ -1,10 +1,12 @@
package com.example.springdemo.entities.RBAC; package com.example.springdemo.entities.RBAC;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.Data; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter;
@Data @Getter
@Setter
@NoArgsConstructor @NoArgsConstructor
@Entity @Entity
@Table(name = "Roles") @Table(name = "Roles")

View File

@ -1,12 +1,14 @@
package com.example.springdemo.entities.RBAC; package com.example.springdemo.entities.RBAC;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.Data; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List; import java.util.List;
@Data @Getter
@Setter
@NoArgsConstructor @NoArgsConstructor
@Entity @Entity
@Table(name = "roles_permissions") @Table(name = "roles_permissions")
@ -16,10 +18,10 @@ public class RolesPermissions {
private Long id;//主键 private Long id;//主键
@OneToMany(targetEntity = Roles.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(targetEntity = Roles.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Column(name = "RolesID") @Column(name = "rolesId")
private List<Roles> roles;//角色ID private List<Roles> roles;//角色ID
@OneToMany(targetEntity = Permissions.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(targetEntity = Permissions.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@Column(name = "PermissionsID") @Column(name = "permissionsId")
private List<Permissions> permissions;//权限ID private List<Permissions> permissions;//权限ID
} }

View File

@ -2,16 +2,13 @@ package com.example.springdemo.entities;
import com.example.springdemo.entities.RBAC.Roles; import com.example.springdemo.entities.RBAC.Roles;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.*;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List; import java.util.List;
//用户类 //用户类
@Data @Getter
@Setter
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ -30,13 +27,13 @@ public class Users {
//一个用户可能会有多个订单关系是一对多 //一个用户可能会有多个订单关系是一对多
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "users_orders", @JoinTable(name = "users_orders",
joinColumns = {@JoinColumn(name = "usersID", referencedColumnName = "id")}, joinColumns = {@JoinColumn(name = "usersId", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "ordersID", referencedColumnName = "id")}) inverseJoinColumns = {@JoinColumn(name = "ordersId", referencedColumnName = "id")})
private List<Orders> orders = new ArrayList<>();//订单 private List<Orders> orders;//订单
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "users_roles", @JoinTable(name = "users_roles",
joinColumns = {@JoinColumn(name = "usersID", referencedColumnName = "id")}, joinColumns = {@JoinColumn(name = "usersId", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "rolesID", referencedColumnName = "id")}) inverseJoinColumns = {@JoinColumn(name = "rolesId", referencedColumnName = "id")})
private Roles roles;//RBAC角色 private Roles roles;//RBAC角色
} }

View File

@ -2,10 +2,12 @@ package com.example.springdemo.entities.password;
import com.example.springdemo.entities.Merchants; import com.example.springdemo.entities.Merchants;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.Data; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter;
@Data @Getter
@Setter
@NoArgsConstructor @NoArgsConstructor
@Entity @Entity
@Table(name = "MerchantsPassword") @Table(name = "MerchantsPassword")
@ -15,7 +17,7 @@ public class MerchantsPassword {
private Long merchantsID; private Long merchantsID;
@OneToOne @OneToOne
@JoinColumn(name = "merchantsID", referencedColumnName = "id") @JoinColumn(name = "merchantsId", referencedColumnName = "id")
private Merchants merchants; private Merchants merchants;
private String password; private String password;

View File

@ -2,10 +2,12 @@ package com.example.springdemo.entities.password;
import com.example.springdemo.entities.Users; import com.example.springdemo.entities.Users;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.Data; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter;
@Data @Getter
@Setter
@NoArgsConstructor @NoArgsConstructor
@Entity @Entity
@Table(name = "UsersPassword") @Table(name = "UsersPassword")
@ -15,7 +17,7 @@ public class UsersPassword {
private Long id; private Long id;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "usersID", referencedColumnName = "id") @JoinColumn(name = "usersId", referencedColumnName = "id")
private Users users; private Users users;
private String password; private String password;

View File

@ -1,6 +1,9 @@
package com.example.springdemo.utils; 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.Contract;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;