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

📄 findfunctionfromdatabase.java

📁 Java开发的权限管理的例子
💻 JAVA
字号:
package org.artemis.right.command;

import java.util.List;
import java.util.Map;
import org.artemis.right.model.Function;
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;
/**
 * 从数据库中查找名为protectFunction的Function以及拥有这个function的角色
 * @author hewenqiang Nov 23, 2006 9:56:04 AM
 */
public class FindFunctionFromDataBase 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 Function f where f.protectFunction = ?",(String) params.get("protectfunction"));
			if(!AppUtils.isBlank(list)){
				Function function=(Function)list.get(0);
				//查找有该权限的角色
				function.setRoles(findRolesByFunction(function));
				response.put("resultObject",function);
			}else{
				response.put("resultObject",null);
			}

	}
	
	private List findRolesByFunction(Function function){
		return dao.find("select r from Permission p ,Role  r where p.id.functionId=? and p.id.roleId=r.id",function.getId());
		 
	}

	public void fini() throws JCFException
	{
	}

	public void init(String arg0) throws JCFException
	{
	}


}

⌨️ 快捷键说明

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