User.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package nju.seec.helper.entity;
  2. import lombok.Data;
  3. import lombok.experimental.Accessors;
  4. import nju.seec.helper.enums.UserRole;
  5. import org.hibernate.annotations.CacheConcurrencyStrategy;
  6. import org.hibernate.annotations.CreationTimestamp;
  7. import org.hibernate.annotations.DynamicInsert;
  8. import org.hibernate.annotations.DynamicUpdate;
  9. import javax.persistence.*;
  10. import java.time.LocalDateTime;
  11. /**
  12. * @author cst
  13. */
  14. @Data
  15. @Accessors(chain = true)
  16. @Entity
  17. @Table(name = "user", uniqueConstraints = {@UniqueConstraint(name = "user_phone_unique", columnNames = "phone"),
  18. @UniqueConstraint(name = "user_email_unique", columnNames = "email")})
  19. @DynamicUpdate
  20. @DynamicInsert
  21. @Cacheable
  22. @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
  23. public class User {
  24. @Id
  25. @GeneratedValue(strategy = GenerationType.IDENTITY)
  26. private Long id;
  27. @Column(nullable = false)
  28. private String name;
  29. @Column(nullable = false)
  30. private String email;
  31. @Enumerated(EnumType.STRING)
  32. @Column(nullable = false, updatable = false)
  33. private UserRole role;
  34. @Column(nullable = false)
  35. private String phone;
  36. @Column(nullable = false)
  37. private String password;
  38. @Column(name = "create_at", updatable = false, nullable = false)
  39. @CreationTimestamp
  40. private LocalDateTime createAt;
  41. // @ColumnDefault("'NORMAL'")
  42. // @Enumerated(EnumType.STRING)
  43. // @Column(nullable = false)
  44. // private UserState state;
  45. private Long pid;
  46. }