|
@@ -3,8 +3,7 @@ package cn.minbb.job.model;
|
|
|
import cn.minbb.job.enumerate.Role;
|
|
|
import com.alibaba.fastjson.annotation.JSONField;
|
|
|
import lombok.Data;
|
|
|
-import lombok.Getter;
|
|
|
-import lombok.Setter;
|
|
|
+import lombok.EqualsAndHashCode;
|
|
|
import org.springframework.security.core.GrantedAuthority;
|
|
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
|
import org.springframework.security.core.userdetails.UserDetails;
|
|
@@ -20,24 +19,26 @@ import java.util.Set;
|
|
|
*/
|
|
|
@Data
|
|
|
@Entity
|
|
|
+@EqualsAndHashCode(callSuper = true)
|
|
|
@Table(name = "user",
|
|
|
indexes = {
|
|
|
@Index(name = "index_id", columnList = "id"),
|
|
|
@Index(name = "index_username", columnList = "username"),
|
|
|
- @Index(name = "index_name", columnList = "name")
|
|
|
+ @Index(name = "index_name", columnList = "name"),
|
|
|
+ @Index(name = "index_company_id", columnList = "company_id")
|
|
|
}
|
|
|
)
|
|
|
public class User extends Auditable implements UserDetails {
|
|
|
|
|
|
+ @Column(name = "name", columnDefinition = "VARCHAR(32) COMMENT '姓名'")
|
|
|
+ private String name;
|
|
|
+
|
|
|
@Column(name = "username", nullable = false, columnDefinition = "VARCHAR(32) COMMENT '用户名'")
|
|
|
private String username;
|
|
|
|
|
|
@Column(name = "password", nullable = false, columnDefinition = "VARCHAR(256) COMMENT '密码'")
|
|
|
private String password;
|
|
|
|
|
|
- @Column(name = "name", columnDefinition = "VARCHAR(32) COMMENT '姓名'")
|
|
|
- private String name;
|
|
|
-
|
|
|
@Column(name = "signature", columnDefinition = "VARCHAR(255) COMMENT '签名'")
|
|
|
private String signature;
|
|
|
|
|
@@ -53,28 +54,18 @@ public class User extends Auditable implements UserDetails {
|
|
|
@Column(name = "qq", columnDefinition = "VARCHAR(16) COMMENT 'QQ'")
|
|
|
private String qq;
|
|
|
|
|
|
- @Getter
|
|
|
- @Setter
|
|
|
@Column(name = "is_account_non_expired", nullable = false, columnDefinition = "TINYINT DEFAULT '1' COMMENT '帐户未过期'")
|
|
|
private Boolean isAccountNonExpired;
|
|
|
|
|
|
- @Getter
|
|
|
- @Setter
|
|
|
@Column(name = "is_account_non_locked", nullable = false, columnDefinition = "TINYINT DEFAULT '1' COMMENT '帐户未锁定'")
|
|
|
private Boolean isAccountNonLocked;
|
|
|
|
|
|
- @Getter
|
|
|
- @Setter
|
|
|
@Column(name = "is_credentials_non_expired", nullable = false, columnDefinition = "TINYINT DEFAULT '1' COMMENT '凭据未过期'")
|
|
|
private Boolean isCredentialsNonExpired;
|
|
|
|
|
|
- @Getter
|
|
|
- @Setter
|
|
|
@Column(name = "is_enabled", nullable = false, columnDefinition = "TINYINT DEFAULT '1' COMMENT '帐户已启用'")
|
|
|
private Boolean isEnabled;
|
|
|
|
|
|
- @Getter
|
|
|
- @Setter
|
|
|
@ManyToMany(cascade = {CascadeType.REFRESH}, fetch = FetchType.EAGER)
|
|
|
@JoinTable(name = "user_user_role",
|
|
|
joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")},
|
|
@@ -82,6 +73,10 @@ public class User extends Auditable implements UserDetails {
|
|
|
)
|
|
|
private Set<UserRole> userRoleSet;
|
|
|
|
|
|
+ @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, optional = true)
|
|
|
+ @JoinColumn(name = "company_id", columnDefinition = "INT COMMENT '企业ID'")
|
|
|
+ private Company company;
|
|
|
+
|
|
|
@JSONField(serialize = false)
|
|
|
@Override
|
|
|
public Collection<? extends GrantedAuthority> getAuthorities() {
|