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

📄 c05ed6ae7e30001d1f81bebe3c68a6df

📁 客户关系管理系统主要管理新老客户的一些信息并可以发现潜在客户
💻
字号:
/**
 * 
 */
package com.qrsx.qrsxcrm.dao;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;


import com.qrsx.qrsxcrm.model.Chance;
import com.qrsx.qrsxcrm.model.Power;
import com.qrsx.qrsxcrm.model.Role;

/**
 * @author Administrator
 *
 */
public class RoleDAO extends BaseDAO
{
	@SuppressWarnings("unchecked")
	public RoleDAO(Class Role) {
		super(Role);
	}	
	
	
	public void updates(Chance chance)
	{
		Chance chance1 = new Chance();
		chance1=(Chance) session.get(Chance.class, chance.getId());
		chance1.setBalance(chance.getBalance());
		chance1.setClient(chance.getClient());
		chance1.setEmployee(chance.getEmployee());
		chance1.setMotif(chance.getMotif());
		chance1.setProbability(chance.getProbability());
		chance1.setRemark(chance.getRemark());
		chance1.setRival(chance.getRival());
		chance1.setSelf(chance.getSelf());
		session.update(chance1);
	}
	
	/**
	 * 根据角色获得所有权限 2008-5-28  14:38
	 */
	
	public List findPowers(Role role){
		Set powers=role.getPowers();
		List<Power> list=new ArrayList<Power>();
		Iterator it=powers.iterator();
		while(it.hasNext()){
			Power power=(Power) it.next();
			System.out.println("得到权限");
			list.add(power);
		}
		return list;
	}
	/**
	 * 根据角色获得所有权限的id
	 * @param id
	 * @return
	 */
	public String [] findPowersId(Role role){
		String powersIds[]=new String[50];
		List powers=this.findPowers(role);
		for(int i=0;i<powers.size();i++){
			powersIds[i]=((Power)powers.get(i)).getId();
		}
		return powersIds;
	}
	/**
	 * 删除此角色的所有权限
	 */
	public void deleteAllPowers(Role role){
		List allPowers=this.findPowers(role);
		for(int i=0;i<allPowers.size();i++){
			role.getPowers().remove(allPowers.get(i));
		}
	}
	
	/**
	 * 为此角色添加权限
	 */
	
	public void addPowers(String powerIds[],Role role){
		PowerDAO pdao=new PowerDAO(Power.class);
		Power power=null;
		for(int i=0;i<powerIds.length;i++){
			power=(Power) pdao.findById(Power.class, powerIds[i]);
			role.getPowers().add(power);
		}
	}
}

⌨️ 快捷键说明

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