content: package com.us.example.domain;
  
  import com.fasterxml.jackson.annotation.JsonIgnore;
  import org.springframework.security.core.GrantedAuthority;
  import org.springframework.security.core.userdetails.UserDetails;
  
  import java.util.Collection;
  import java.util.List;
  
  /**
   * Created by yangyibo on 17/1/17.
   */
  
  public class SysUser implements UserDetails {  // implements UserDetails 用于登录时 @AuthenticationPrincipal 标签取值
      private Integer id;
      private String username;
      @JsonIgnore
      private String password;
      private String rawPassword;
      @JsonIgnore
      private List<SysRole> roles;
      private List<? extends GrantedAuthority> authorities;
  
  
      public Integer getId() {
          return id;
      }
  
      public void setId(Integer id) {
          this.id = id;
      }
  
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public List<SysRole> getRoles() {
          return roles;
      }
  
      public void setRoles(List<SysRole> roles) {
          this.roles = roles;
      }
  
      public String getRawPassword() {
          return rawPassword;
      }
  
      public void setRawPassword(String rawPassword) {
          this.rawPassword = rawPassword;
      }
  
  
      @JsonIgnore
      @Override
      public boolean isAccountNonExpired() {
          return true;
      }
  
      @JsonIgnore
      @Override
      public boolean isAccountNonLocked() {
          return true;
      }
  
      @JsonIgnore
      @Override
      public boolean isCredentialsNonExpired() {
          return true;
      }
  
  
      @JsonIgnore
      @Override
      public boolean isEnabled() {
          return true;
      }
  
      @JsonIgnore
      @Override
      public Collection<? extends GrantedAuthority> getAuthorities() {
          return authorities;
      }
  
      public void setGrantedAuthorities(List<? extends GrantedAuthority> authorities) {
          this.authorities = authorities;
      }
  
  }
  