⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userinsession.java

📁 oa办公系统
💻 JAVA
字号:
/**
 * FileName:UserInSession.java,v 1.0 created in 2008-11-8 上午09:17:49
 * Created by yuankai
 * Copyright (c) 2008 www.ecjtu.jx.cn
 * All Rights Reserved.
 */
package cn.jx.ecjtu.oa.services;

import java.util.List;

import cn.jx.ecjtu.oa.ps.pojo.Permission;
import cn.jx.ecjtu.oa.ps.pojo.Role;

/**
 * @todo:这个类中保存了用户的角色(内有权限列表用于访问控制)和真实姓名
 * @author yuankai,胡楚斌,李春鹏
 * @version $Revision: 1.7 $
 * @since 1.0
 */

public class UserInSession implements java.io.Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 7356689164498933494L;

	public UserInSession() {
		super();
		// TODO Auto-generated constructor stub
	}

	private int id;

	private String realName;

	private Role role;
	
	private int  deptId;

	/**
	 * @return the deptId
	 */
	public int getDeptId() {
		return deptId;
	}

	/**
	 * @param deptId the deptId to set
	 */
	public void setDeptId(int deptId) {
		this.deptId = deptId;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	
	public UserInSession(int id, String realName, Role role, int deptId) {
		super();
		this.id = id;
		this.realName = realName;
		this.role = role;
		this.deptId = deptId;
	}

	public boolean checkPermission(String resource){
		Role role = getRole();
		if(role==null) return false;
		List<Permission> permissions = role.getPermissions();
		if(permissions==null) return false;
		boolean flag = false;
		for (Permission permission : permissions) {
			if(resource.startsWith(permission.getResource())){ //path.equals(permission.getResource()
				flag = true;
				break;
			}
		}
		return flag;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -