📄 findgrantedauthorityfromdatabase.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -