?? rightbean.java
字號:
/**********************************************************
Version 1.0
Date:2003-11-07
Description:權限控制
Other:
Variable List:
1.String uid = "-1";//人員編號
String Orgid = "-1";//部門編號
Function List:
1.public void setUID(String uid)//設置人員編號
2.public void setOrgid(String Orgid)//設置部門編號
//三種權限
3.public boolean isAdmin();//判斷是否是系統管理員
4.public Vector getRightConf()//配置權限
5.public Vector getRightMode()//模塊權限
6.public Vector getRightFlow()//流程權限
7.public String getConfValue(String type)//取得配置數字
8.public boolean isRightMode(String mode,String button)//是否有操作button對模塊mode的權限
9.public boolean isRightFlow(String flow)//是否有操作流程flow的權限
//公文權限
10.public Vector getRightConfidential()機要權限
11.public boolean isRightConfidential()判斷當前是否有該權限
12.public boolean isRightSecretary()文書權限
13.public Vector getRightDuty()職務權限
14.public Vector getRightArchives()檔案權限
15.public Vector getRightPeriodical()期刊權限
//版面管理權限
16.public Vector getBMBHS()//當前職工所在的部門編號(包括被分配職務后得到的職務部門編號) 柳美\
17.public boolean isRightOrg(String lbid)//部門新聞操作權限(根據orgmenu.id判斷)(uid,orgid)
18.public boolean isRightPage(String dxbh,String whichtable,String sf,String cz)//版面權限
19. //*取得模塊權限------------lbh-----------11-29
//public String getRightModelbh()
20. //是否有模塊操作權限------------lbh-----------11-29
//public boolean isRightModelbh(String strmkmc,String strbtnmc)
History:
***********************************************************/
package oa.bean;
import java.text.*;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.sql.*;
import oa.main.*;
public class RightBean extends ParentBean
{
String uid = "-1";//人員編號
String Orgid = "-1";//部門編號
public void setUID(String uid)//設置人員編號
{
this.uid = uid.trim();
}
public void setOrgid(String Orgid)//設置部門編號
{
this.Orgid = Orgid.trim();
}
/**判斷是否是系統管理員*/
public boolean isAdmin()
{
String name = toName("ZZ_ZGB","ZGBH","ZGBH",uid).toLowerCase();
if(name.equals("1"))return true;
else return false;
}
/**配置權限*/
public Vector getRightConf()
{
Vector vect = new Vector();
String right = "";
ResultSet rs = selectRecord("select PZCS from news.ZZ_ZGB where ZGBH='"+uid+"'");
Statement stmt = null;
try{
if(rs.next())
{
right = ds.toString(rs.getString("PZCS"));
}
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("RightBean.getRightConf()關閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("RightBean.getRightConf()關閉聲明時statement出錯"+e);}
//if(right.equals(""))//當當前人員表為空時,查詢職務表權限集合
{
rs = selectRecord("select PZCS from news.ZZ_ZWB where (BMBH,ZWBH) in (select BMBH,ZWBH from ZZ_ZGZWB where ZGBH='"+uid+"')");
if(rs.next())
{
if(!right.equals(""))right+=",";
right = ds.toString(rs.getString("PZCS"));
}
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("RightBean.getRightConf()關閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("RightBean.getRightConf()關閉聲明時statement出錯"+e);}
}
if(right.equals(""))//當職務表集合為空時
{
stmt = rs.getStatement(); rs.close(); stmt.close();
rs = selectRecord("select PZSZ from news.CODE_XTPZ order by PZBH");
while(rs.next())
{
vect.add(ds.toString(rs.getString(1)));
}
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("RightBean.getRightConf()關閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("RightBean.getRightConf()關閉聲明時statement出錯"+e);}
}
else
{
String str[] = ds.splitStr(right,',');
for(int i=0;i<str.length;i++)
{
vect.add(str[i]);
}
}
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關閉聲明時statement出錯"+e);}
}
return vect;
}
public String getConfValue(String type)//取得配置數字
{
String confvalue = "";
Vector vect = getRightConf();
int pzbh = toID("CODE_XTPZ","PZMC","PZBH",type.trim());
if(vect.size()>=pzbh&&pzbh>0)
confvalue = (String)vect.get(pzbh-1);
return confvalue;
}
/**模塊權限*/
public Vector getRightMode()
{
Vector vect = new Vector();
String sql = "select BMBH,ZWBH,CZQX from news.ZZ_ZGZWB where ZGBH='"+uid+"'";
if(!uid.equals("1") && !Orgid.equals("-1"))
{
char bmsub;
int n=19;
for(n=19;n>=0;n--)
{
bmsub = Orgid.charAt(n);
if(bmsub!='0')
break;
}
if(n==-1) n=1;
sql += " and (BMBH='"+Orgid+"' or BMBH like '%"+Orgid.substring(0,n+1)+"%')";
}
String right = "";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try{
while(rs.next())//取得職務表權限
{
String czqx = ds.toString(rs.getString("CZQX"));
String bmbh = ds.toString(rs.getString("BMBH"));
String zwbh = ds.toString(rs.getString("ZWBH"));
if(czqx.equals(""))//當職務表中權限為空時,去部門職務表權限
{
sql = "select CZQX from news.ZZ_ZWB where BMBH='"+bmbh+"' and ZWBH="+zwbh+" and ZWZT=0";
ResultSet rs_t = selectRecord(sql);
try{
rs_t.next();
czqx = ds.toString(rs_t.getString("CZQX"));
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs_t!=null)try{ stmt = rs_t.getStatement(); rs_t.close();}catch(Exception e){System.out.println("關閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關閉聲明時statement出錯"+e);}
}
}
if(!right.equals("")&&!czqx.equals(""))
right += ",";
if(!czqx.equals(""))
right += czqx;
}
//if(right.equals(""))//當職務權限集合為空時查詢字典
//{
stmt = rs.getStatement(); rs.close();stmt.close();
rs = selectRecord("select ID from news.CODE_ANCZQXB where MRCZ=1 and SYZT=0");
while(rs.next())
{
vect.add(rs.getString(1));
}
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關閉聲明時statement出錯"+e);}
}
//}
//else
//{
String str[] = ds.splitStr(right,',');
for(int i=0;i<str.length;i++)
{
vect.add(str[i]);
}
//}
return vect;
}
/**流程權限*/
public Vector getRightFlow()
{
Vector vect = new Vector();
String sql = "select BMBH,ZWBH,LCQX from news.ZZ_ZGZWB where ZGBH='"+uid+"'";
if(!Orgid.equals("-1"))sql += " and BMBH='"+Orgid+"'";
String right = "";
ResultSet rs = selectRecord(sql);
Statement stmt = null;
try{
while(rs.next())//取得職務表權限
{
String czqx = ds.toString(rs.getString("LCQX"));
String bmbh = ds.toString(rs.getString("BMBH"));
String zwbh = ds.toString(rs.getString("ZWBH"));
if(czqx.equals(""))//當職務表中權限為空時,去部門職務表權限
{
sql = "select LCQX from news.ZZ_ZWB where BMBH='"+bmbh+"' and ZWBH="+zwbh+" and ZWZT=0";
ResultSet rs_t = selectRecord(sql);
try{
if(rs_t.next())
czqx = ds.toString(rs_t.getString("LCQX"));
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs_t!=null)try{ stmt = rs_t.getStatement(); rs_t.close();}catch(Exception e){System.out.println("關閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關閉聲明時statement出錯"+e);}
}
}
if(!right.equals("")&&!czqx.equals(""))
right += ",";
if(!czqx.equals(""))
right += czqx;
}
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關閉聲明時statement出錯"+e);}
}
if(right.equals(""))//當職務權限集合為空時查詢字典
{
rs = selectRecord("select MKBH from news.CODE_LCQXB where MRCZ=1 and SYZT=0");
try{
while(rs.next())
{
vect.add(rs.getString(1));
}
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關閉聲明時statement出錯"+e);}
}
}
else
{
String str[] = ds.splitStr(right,',');
for(int i=0;i<str.length;i++)
{
vect.add(str[i]);
}
}
return vect;
}
/**是否有操作button對模塊mode的權限*/
public boolean isRightMode(String mode,String button)
{
boolean bool = false;
ResultSet rs = selectRecord("select ID from news.CODE_ANCZQXB where MKMC='"+ds.toString(mode)+"' and ANMC='"+ds.toString(button)+"'");
String mkbh = "";
Statement stmt = null;
try{
if(rs.next())
{
mkbh = ds.toString(rs.getString("ID"));
}
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關閉聲明時statement出錯"+e);}
}
Vector vect = getRightMode();
int index = vect.indexOf(mkbh);
if(index!=-1)bool = true;
return bool;
}
public boolean isRightFlow(String flow)//是否有操作流程flow的權限
{
boolean bool = false;
ResultSet rs = selectRecord("select MKBH from news.CODE_LCQXB where MKMC='"+ds.toString(flow)+"'");
String mkbh = "";
Statement stmt = null;
try{
if(rs.next())
{
mkbh = ds.toString(rs.getString("MKBH"));
}
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關閉聲明時statement出錯"+e);}
}
Vector vect = getRightFlow();
int index = vect.indexOf(mkbh);
if(index!=-1)bool = true;
return bool;
}
/**機要權限*/
public Vector getRightConfidential()
{
Vector vect = new Vector();
ResultSet rs = selectRecord("select CKQX from news.ZZ_BMB where BMBH ='"+Orgid+"'");
String right = "";
Statement stmt = null;
try{
if(rs.next())
right = rs.getString("CKQX");
}catch(Exception e){System.out.println("運行時出錯:"+e);}
finally{
if(rs!=null)try{ stmt = rs.getStatement(); rs.close();}catch(Exception e){System.out.println("關閉記錄集rs時出錯"+e);}
if(stmt!=null) try{stmt.close();}catch(Exception e){System.out.println("關閉聲明時statement出錯"+e);}
}
String str[] = ds.splitStr(right,',');
for(int i=0;i<str.length;i++)
{
vect.add(toName("ZZ_ZGB","ZGBH","XM",str[i]));
}
return vect;
}
/*判斷當前是否有該權限*/
public boolean isRightConfidential()
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -