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

📄 functiondaoimpl.java

📁 利用STRUTS2+SPRING+HIBERNATE/IBATIS建立的基本开发框架
💻 JAVA
字号:
/**
 * 
 */
package com.sunwah.baseapp.system.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.sunwah.baseapp.common.DictionaryConstants;
import com.sunwah.baseapp.dao.GenericDaoImpl;
import com.sunwah.baseapp.system.model.Functions;

/**
 * @author MARK
 * 
 */
public class FunctionDaoImpl extends GenericDaoImpl<Functions, Long> implements
		FunctionDao {

	public FunctionDaoImpl() {
		super(Functions.class);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sunwah.baseapp.system.dao.FunctionDao#findMenusByFunctionLevel(java
	 * .lang.String)
	 */
	@Override
	public List<Functions> findMenusByFunctionLevel(String functionLevel) {
		Map<String, Object> queryParams = new HashMap<String, Object>();
		queryParams.put("functionLevel", functionLevel);
		queryParams.put("functionType",
				DictionaryConstants.FUNCTION_TYPE_RESOURCE);
		return super
				.findByNamedParam(
						"from Functions f where f.functionLevel=:functionLevel and f.functionType<>:functionType",
						queryParams);
//		return super.findByProperty("functionLevel", functionLevel);
	}

	@Override
	public Functions findFunctionByFunctionName(String functionName) {
		List<Functions> functions = super.findByProperty("functionName",
				functionName);
		return functions.size() > 0 ? functions.get(0) : null;
	}

	@Override
	public List<String> findAllAvailableResources() {
		StringBuffer stringBuffer = new StringBuffer(
				" SELECT DISTINCT f.assemblyName ");
		stringBuffer.append("from Functions f where f.functionType = '");
		stringBuffer.append(DictionaryConstants.FUNCTION_TYPE_RESOURCE);
		stringBuffer.append("' and f.state ='");
		stringBuffer.append(DictionaryConstants.STATE_ENABLED);
		stringBuffer.append("'");
		return this.getHibernateTemplate().find(stringBuffer.toString());
	}

	@Override
	public List<String> findUserAvailableResources(Long userId) {
		StringBuffer stringBuffer = new StringBuffer(
				" SELECT DISTINCT a.assemblyName ");
		stringBuffer.append(" FROM Functions a, RoleFunction b, UserRole c ");
		stringBuffer.append(" WHERE a.functionId = b.id.functions.functionId ");
		stringBuffer.append(" AND b.id.roles.roleId = c.id.roles.roleId ");
		stringBuffer.append(" AND c.id.users.userId = ");
		stringBuffer.append(userId);
		stringBuffer.append(" AND a.functionType = '");
		stringBuffer.append(DictionaryConstants.FUNCTION_TYPE_RESOURCE);
		stringBuffer.append("' and a.state ='");
		stringBuffer.append(DictionaryConstants.STATE_ENABLED);
		stringBuffer.append("'");
		return this.getHibernateTemplate().find(stringBuffer.toString());
	}
}

⌨️ 快捷键说明

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