简单的权限管理-资源,角色,用户,部门(一)

在ssh框架下,分为资源:menu,角色:role,用户user,其中menu和role是多对多关系,role和user是多对多关系,分为三个层级管理。

menu是控制url访问地址的,是属于粗粒度的权限控制

1.menu

public class Menu implements Serializable {
	private static final long serialVersionUID = 1L;
	private Long id;
	private String lable;//标签
	private String uri;
	private String description;
	private Integer status;
	private Date date;
	
	private Set roles=new HashSet();
	
	public String getStatusStr(){
		if(status==1){
			return "启用";
		}else{
			return "禁用";
		}
	}
	public String getOperStr(){
		if(status==0){
			return "启用";
		}else{
			return "禁用";
		}
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getLable() {
		return lable;
	}
	public void setLable(String lable) {
		this.lable = lable;
	}
	public String getUri() {
		return uri;
	}
	public void setUri(String uri) {
		this.uri = uri;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Set getRoles() {
		return roles;
	}
	public void setRoles(Set roles) {
		this.roles = roles;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	

}





    
        
            
            
        
        
            
        
        
            
        
        
            
        
        
			
		  
		
            
        
        
        		
        	
            
    

2.role

public class Role implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private Long id;
	private String name;
	private String description;
	private Integer status;
	private Date date;
	private Set menus=new HashSet();
	private Set users=new HashSet();
	
	public String getStatusStr(){
		if(status==1){
			return "启用";
		}else{
			return "禁用";
		}
	}
	public String getOperStr(){
		if(status==0){
			return "启用";
		}else{
			return "禁用";
		}
	}
	
	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 getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Set getMenus() {
		return menus;
	}
	public void setMenus(Set menus) {
		this.menus = menus;
	}
	public Set getUsers() {
		return users;
	}
	public void setUsers(Set users) {
		this.users = users;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	
}




    
        
            
            
        
        
            
        
        
            
        
        
			
		
		
            
        
        
        		
        	
        
        
        		
        	
        
    



3.User

public class User implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private Long id;			// 主键
	private String username; 	// 用户名
	private String nickname;
	private String password; 	// 密码
	private Integer permission; // 权限标志位,暂时通过此标志位控制不同的登录用户操作不同的页面及页面按钮。
	private Integer gender;		//1:男 0:n:女
	private Integer status;

	private Date date;
	private Set roles=new HashSet();//该用户所拥有的角色
	private Department department;//用户所属部门
	private String description; 
	
	public String getStatusStr(){
		if(status==1){
			return "启用";
		}else{
			return "禁用";
		}
	}
	public String getOperStr(){
		if(status==0){
			return "启用";
		}else{
			return "禁用";
		}
	}
	public String getGenderStr(){
		if(gender==1){
			return "男";
		}else{
			return "女";
		}
	}
	
	public String getNickname() {
		return nickname;
	}
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long 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 Integer getPermission() {
		return permission;
	}
	public void setPermission(Integer permission) {
		this.permission = permission;
	}
	public Set getRoles() {
		return roles;
	}
	public void setRoles(Set roles) {
		this.roles = roles;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public Department getDepartment() {
		return department;
	}
	public void setDepartment(Department department) {
		this.department = department;
	}
	public Integer getGender() {
		return gender;
	}
	public void setGender(Integer gender) {
		this.gender = gender;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	
}





    
        
            
            
        
        
            
        
        
            
        
        
            
        
        
            
        
        
            
        
        
            
        
        
			
		
		
            
        
        
        		
        	
        
          
    


4.department

public class Department implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private Long id;			// 主键
	private String name; 	// 用户名
	private String guider;
	private String description; 	
	private Integer status;//状态:禁用,启用
	private Date date;

	public String getStatusStr(){
		if(status==1){
			return "启用";
		}else{
			return "禁用";
		}
	}
	public String getOperStr(){
		if(status==0){
			return "启用";
		}else{
			return "禁用";
		}
	}
	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 getGuider() {
		return guider;
	}
	public void setGuider(String guider) {
		this.guider = guider;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	
}




    
        
            
            
        
        
            
        
        
            
        
        
            
        
        
            
         
        
        
			
		     
    




你可能感兴趣的:(工作项目)