UserRole.java 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package cn.minbb.edu.model;
  2. import lombok.Getter;
  3. import lombok.NoArgsConstructor;
  4. import lombok.Setter;
  5. import javax.persistence.*;
  6. import java.io.Serializable;
  7. @Entity
  8. @Table(name = "user_role",
  9. uniqueConstraints = {@UniqueConstraint(name = "unique_name", columnNames = {"name"})},
  10. indexes = {@Index(name = "index_name", columnList = "name")})
  11. @NoArgsConstructor
  12. public class UserRole implements Serializable {
  13. @Getter
  14. @Setter
  15. @Id
  16. @GeneratedValue(strategy = GenerationType.IDENTITY)
  17. @Column(name = "id", nullable = false, columnDefinition = "INT COMMENT '用户角色'")
  18. private Integer id;
  19. @Getter
  20. @Setter
  21. @Column(name = "name", nullable = false, columnDefinition = "VARCHAR(32) COMMENT '角色名称'")
  22. private String name;
  23. @Getter
  24. @Setter
  25. @Column(name = "description", columnDefinition = "VARCHAR(255) COMMENT '角色描述'")
  26. private String description;
  27. public UserRole(String name) {
  28. this.name = name;
  29. }
  30. public UserRole(String name, String description) {
  31. this.name = name;
  32. this.description = description;
  33. }
  34. @Getter
  35. public enum Role {
  36. USER("用户"),
  37. STUDENT("学生"),
  38. TEACHER("教师"),
  39. ADMIN("管理员");
  40. String description;
  41. Role(String description) {
  42. this.description = description;
  43. }
  44. }
  45. }