roledao.java
来自「Java开发的权限管理的例子」· Java 代码 · 共 51 行
JAVA
51 行
package org.artemis.right.dao; import java.util.List;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.hibernate.Hibernate;import org.hibernate.type.Type;import com.gsta.eshore.framework.dao.BaseDao;import com.gsta.eshore.framework.daoutil.HqlQuery;import com.gsta.eshore.framework.daoutil.PageSupport;import com.gsta.eshore.framework.jcf.JCFException;import com.gsta.eshore.framework.util.StringUtil;/** * @author He-WenQiang. Create in 2007-05-03 13:50:02. * */public class RoleDao extends BaseDao { private static final Log logger = LogFactory.getLog(RoleDao.class); private String findRoleByFunction="select r from Role r,Permission p,Function f where r.id=p.id.roleId and f.id=p.id.functionId and f.id = ?"; private String findRoleByUserId="select r from Role r,UserRole ur,User u where r.id=ur.id.roleId and u.id=ur.id.userId and u.id = ?"; private String findOtherRoleByUser="from Role where id not in (select r.id from Role r,UserRole ur,User u where r.id=ur.id.roleId and u.id=ur.id.userId and u.id = ?)"; public List FindRoleByFunction(String functionId) throws JCFException { logger.info(StringUtil.convert(findRoleByFunction, new String[]{functionId})); return find(findRoleByFunction, functionId); } public void DeletePermissionByRoleId(List permissions){ deleteAll(permissions); } public List FindRoleByUserId(String userId) throws JCFException { logger.info(StringUtil.convert(findRoleByUserId, new String[]{userId})); return find(findRoleByUserId, userId); } public PageSupport FindOtherRoleByUser(final HqlQuery hqlQuery,String userId) throws JCFException { logger.info(StringUtil.convert(findOtherRoleByUser, new String[]{userId})); hqlQuery.setQueryString(findOtherRoleByUser); hqlQuery.setParam(new Object[]{userId}); hqlQuery.setTypes(new Type[]{Hibernate.STRING}); return find(hqlQuery, true); } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?