?? staticbean.java
字號:
package com.db;
import java.lang.*;
import java.util.*;
public class StaticBean
{
public static Hashtable right = new Hashtable();//某角色,權限
public static Hashtable role = new Hashtable();//某人,角色
public static boolean existOfRole ( String roleid , String r )
{
Vector vect = (Vector)right.get(roleid);
if(vect==null)return false;
return vect.contains( r ) ;
}
public static boolean existOfMan ( String manid , String r )
{
com.util.DealString ds = new com.util.DealString();
String roleid = ds.toString((String)role.get(manid));
if(roleid.equals(""))return false;
else return existOfRole ( roleid , r ) ;
}
public static void init()
{
CommonBean cb = new CommonBean();
com.util.DealString ds = new com.util.DealString();
String sql = "select id,role from kjc_people";
Vector vrole = cb.getDataBySql(sql);
for(int i = 0 ; i < vrole.size(); i++ )
{
Hashtable h = (Hashtable)vrole.get( i ) ;
String id = (String)h.get("id");
String roleid = ds.toString((String)h.get("role"));
StaticBean.role.put( id , roleid ) ;
}
System.out.println("***********人員 - 角色對應表:"+role);
sql = "select id,rights from kjc_role";
Vector vect = cb.getDataBySql(sql);
for(int i = 0 ; i < vect.size(); i++ )
{
Hashtable h = (Hashtable)vect.get( i ) ;
String id = (String)h.get("id");
String rightsid = (String)h.get("rights");
sql = "select name from kjc_right where id in ("+rightsid+")";
Vector vect1 = cb.getDataBySql(sql);
Vector vect2 = new Vector ( );
vect2.clear();
for(int j = 0 ; j < vect1.size(); j++ )
{
Hashtable h1 = (Hashtable)vect1.get( j ) ;
String name = (String)h1.get("name");
vect2.add(name);
}
StaticBean.right.put ( id , vect2 ) ;
}
cb.closeConn();
System.out.println("**********角色- 權限對應表:"+right);
}
public static void main(String args[])
{
//StaticBean.init();
//System.out.println(StaticBean.existOfMan("1","sss"));
//sb.closeConn();
}
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -