package com.nroad.model;
import javax.persistence.*;
/**
* Created by jiyy on 2017/1/8.
*/
@Entity
@Table (name = "user" , schema = "test" )
public class User {
@Id
@GeneratedValue (strategy = GenerationType.AUTO)
@Column (name = "id" , unique = true , nullable = false )
private long id;
@Column (name = "name" , unique = true , nullable = false )
private String name;
@Column (name = "password" ,nullable = false )
private String password;
@Column (name="role" )
@Enumerated (EnumType.STRING)
private Role role;
public User () {
}
public User (String name) {
this .name = name;
}
public User (long id, String name, String password, Role role) {
this .id = id;
this .name = name;
this .password = password;
this .role = role;
}
public long getId () {
return id;
}
public void setId (long id) {
this .id = id;
}
public String getName () {
return name;
}
public void setName (String name) {
this .name = name;
}
public String getPassword () {
return password;
}
public void setPassword (String password) {
this .password = password;
}
public Role getRole () {
return role;
}
public void setRole (Role role) {
this .role = role;
}
}
package com.nroad.model;
/**
* Created by jiyy on 2017/1/8.
*/
public enum Role {
ADMIN,
ORDINARY
}
package com .nroad .security
import com .nroad .dao .UserDao
import com .nroad .model .User
import org.springframework .beans .factory .annotation .Autowired
import org.springframework .security .core .authority .SimpleGrantedAuthority
import org.springframework .security .core .userdetails .UserDetails
import org.springframework .security .core .userdetails .UserDetailsService
import org.springframework .security .core .userdetails .UsernameNotFoundException