findgrantedauthorityfromdatabase.java
来自「Java开发的权限管理的例子」· Java 代码 · 共 52 行
JAVA
52 行
package org.artemis.right.command;
import java.util.List;
import java.util.Map;
import org.artemis.right.model.Role;
import com.gsta.eshore.framework.dao.BaseDao;
import com.gsta.eshore.framework.jcf.Command;
import com.gsta.eshore.framework.jcf.JCFException;
import com.gsta.eshore.framework.util.AppUtils;
/**
* 从数据库中查找该角色Role和所拥有的Function
* @author hewenqiang Nov 23, 2006 9:56:04 AM
*/
public class FindgrantedAuthorityFromDataBase extends Command
{
private BaseDao dao;
public void setDao(BaseDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception
{
List list=dao.find("from Role r where r.name = ?",(String) params.get("authority"));
if(!AppUtils.isBlank(list)){
Role role=(Role)list.get(0);
//增加权限
role.setFunctions(findFunctionsByRole(role));
response.put("resultObject",role);
}else{
response.put("resultObject",null);
}
}
private List findFunctionsByRole(Role role){
Object[] param = {role.getId()};
String strHql="select f from Permission p ,Function f where p.id.roleId=? and p.id.functionId=f.id";
return dao.find(strHql,param);
}
public void fini() throws JCFException
{
}
public void init(String arg0) throws JCFException
{
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?