📄 userrightmgr.java
字号:
package com.saas.biz.userrightMgr;
import java.util.*;
import com.saas.biz.commen.commMethodMgr;
import com.saas.biz.dao.rightsDAO.MenuinfoExt;
import com.saas.biz.dao.rightsDAO.RightinfoExt;
import com.saas.sys.buffer.Buffers;
import com.saas.sys.dbm.Dbtable;
import com.saas.sys.exp.SaasApplicationException;
import com.saas.sys.log.Logger;
/**
*
* @author sjp
*
*/
public class UserrightMgr {
Logger log;
Buffers inBuffer;
Buffers outBuffer;
Dbtable tradeQuery;
commMethodMgr commen;
ArrayList queryResult = new ArrayList();
public UserrightMgr() {
log = new Logger(this);
tradeQuery = new Dbtable();
commen = new commMethodMgr();
outBuffer = new Buffers();
}
public void setOutBuffer(Buffers outBuffer) {
this.outBuffer = outBuffer;
}
public Buffers getOutBuffer() {
return this.outBuffer;
}
public void setTradeQuery(Dbtable tradeQuery) {
this.tradeQuery = tradeQuery;
}
public Dbtable getTradeQuery() {
return this.tradeQuery;
}
public ArrayList getQueryResult() {
return this.queryResult;
}
public void setQueryResult(ArrayList queryResult) {
this.queryResult = queryResult;
}
public void addMenuRight(Buffers inbuffer)
{
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
log.LOG_INFO("进入addMenuRight方法...");
int iResult = -1;
try {
String user_id = inbuffer.getString("SESSION_USER_ID");
String menu_id = inbuffer.getString("MENU_ID");
String cust_class = inbuffer.getString("CLASS_CODE");
String menu_class = inbuffer.getString("MENU_CLASS");
iResult = addMenuRight(menu_id,cust_class,user_id,menu_class);
} catch (SaasApplicationException e) {
log.LOG_INFO(e.getMessage());
}
if (iResult == -1) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "该菜单已经分配!");
}else if (iResult == -2) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "上级菜单没有分配,请先分配!");
}
else {
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "业务处理成功!");
}
log.LOG_INFO("退出addMenuRight方法...");
}
public int addMenuRight(String menu_id,String cust_class,String user_id,String menu_class)throws SaasApplicationException {
RightinfoExt rightinfoExt = new RightinfoExt();
int retInt = 0;
if(menu_class.equals("1"))
retInt = checkExitMenu(menu_id,cust_class);
else
{
retInt = checkMenuRight(menu_id,cust_class);
if(retInt == 0)
retInt = checkExitMenu(menu_id,cust_class);
}
if(retInt == 0)
{
rightinfoExt.setParam(":VMENU_ID", menu_id);
rightinfoExt.setParam(":VCUST_CLASS", cust_class);
rightinfoExt.setParam(":VIN_STAFF_ID", user_id);
rightinfoExt.setParam(":VREMARK", "");
tradeQuery.executeBy(rightinfoExt.insBy("INS_BY_ALL"));
}
return retInt;
}
/**
* 菜单验证
* @param menu_id
* @return
* @throws SaasApplicationException
*/
public int checkExitMenu(String menu_id ,String cust_class)throws SaasApplicationException {
ArrayList items = new ArrayList();
RightinfoExt rightinfoExt = new RightinfoExt();
rightinfoExt.setParam(":VMENU_ID", menu_id);
rightinfoExt.setParam(":VCUST_CLASS", cust_class);
items = rightinfoExt.selByList("SEL_BY_MENU");
if(items==null)
return 0;//用户权限表不存在该菜单
else
return -1;//用户权限表已经存在该菜单
}
public int checkMenuRight(String menu_id ,String cust_class)throws SaasApplicationException
{
ArrayList items = new ArrayList();
MenuinfoExt menuInfoExt = new MenuinfoExt();
int retInt = -1;
String strMenuId = "";
menuInfoExt.setParam(":VMENU_ID", menu_id);
items = menuInfoExt.selByList("SEL_BY_PK");
Iterator it = items.iterator();
HashMap infoMap =(HashMap) it.next();
if(infoMap.get("up_menu_id")!=null)
strMenuId = infoMap.get("up_menu_id").toString();
retInt = checkExitMenu(strMenuId,cust_class);
if(retInt==0) retInt = -2;//上级菜单不在用户权限表中
else retInt = 0 ; //上级菜单在用户权限表中
return retInt;
}
/**
*
*/
public ArrayList genUserMenu(String menu_class,String cust_class)throws SaasApplicationException
{
log.LOG_INFO("进入genUserMenu方法.............");
ArrayList menuList= new ArrayList();
RightinfoExt rightinfoExt = new RightinfoExt();
rightinfoExt.setParam(":VMENU_CLASS", menu_class);
rightinfoExt.setParam(":VCUST_CLASS", cust_class);
menuList = rightinfoExt.selByList("SEL_BY_CLASS");
log.LOG_INFO("退出genUserMenu方法.............");
return menuList;
}
public ArrayList genDownUserMenu(String menu_id,String menu_class,String cust_class)throws SaasApplicationException
{
log.LOG_INFO("进入genDownUserMenu方法.............");
ArrayList menuList= new ArrayList();
RightinfoExt rightinfoExt = new RightinfoExt();
rightinfoExt.setParam(":VUP_MENU_ID", menu_id);
rightinfoExt.setParam(":VMENU_CLASS", menu_class);
rightinfoExt.setParam(":VCUST_CLASS", cust_class);
menuList = rightinfoExt.selByList("SEL_BY_CLASSDOWN");
log.LOG_INFO("退出genDownUserMenu方法.............");
return menuList;
}
/**
* 菜单权限回收
* @param inbuffer
*/
public void callBackRights(Buffers inbuffer)
{
this.outBuffer = inbuffer;
this.inBuffer = inbuffer;
log.LOG_INFO("进入callBackRights方法...");
int iResult = -1;
String menu_id = inbuffer.getString("MENU_ID");
String cust_class = inbuffer.getString("CLASS_CODE");
String menu_class = inbuffer.getString("MENU_CLASS");
try {
iResult = callBackRights(menu_id,menu_class,cust_class);
} catch (SaasApplicationException e) {
log.LOG_INFO(e.getMessage());
}
if (iResult == -1) {
this.outBuffer.setInt("RESULT_CODE", -1);
this.outBuffer.setString("RESULT_INFO", "业务处理失败,请先将下级菜单权限删除!");
} else
{
this.outBuffer.setInt("RESULT_CODE", 0);
this.outBuffer.setString("RESULT_INFO", "业务处理成功!");
}
log.LOG_INFO("退出callBackRights方法...");
}
public int callBackRights(String menu_id,String menu_class,String cust_class)throws SaasApplicationException {
int iClass = new Integer(menu_class).intValue();
int retInt = 0 ;
ArrayList items = new ArrayList();
if(iClass<4)
{
RightinfoExt rightinfoExt = new RightinfoExt();
rightinfoExt.setParam(":VUP_MENU_ID", menu_id);
rightinfoExt.setParam(":VMENU_CLASS", menu_class);
rightinfoExt.setParam(":VCUST_CLASS", cust_class);
items = rightinfoExt.selByList("SEL_BY_CLASSDOWN");
if(items == null )
{
retInt = delRights(menu_id,cust_class);
}
else return -1 ;//有上级目录
}
else
retInt = delRights(menu_id,cust_class);
return retInt;
}
public int delRights(String menu_id,String cust_class)throws SaasApplicationException {
RightinfoExt rightinfoExt = new RightinfoExt();
rightinfoExt.setParam(":VMENU_ID", menu_id);
rightinfoExt.setParam(":VCUST_CLASS", cust_class);
tradeQuery.executeBy(rightinfoExt.insBy("DEL_BY_ONE"));
return 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -