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

📄 sysrolemodify.java.svn-base

📁 用JSP JAVA 做的 系统 只是初来扎到还望西黄!别乱来哦!
💻 SVN-BASE
字号:
package com.chis.model.user;

import java.util.List;

import com.chis.util.GUIDKeyGen;
import com.stframe.dao.DaoUtil;
import com.stframe.form.ActionForm;
import com.stframe.form.DataForm;
import com.stframe.servlet.ActionInstance;
/**
 * 修改角色
 * @author zxh
 *
 */
public class SysRoleModify extends ActionInstance{

	public int execute(ActionForm af) throws Exception {
		String shbdwbh = af.getHttpSession().getAttribute("HBDWBH").toString();
		String roleid = af.getHttpRequest().getParameter("ID");	
		DataForm roledf = new DataForm("SYS_ROLE","ID");
		StringBuffer sbsql = new StringBuffer();
		try{
			roledf.setValues(af.getHttpRequest());	
			String rolename = roledf.get("NAME").toString().trim();
			
//			角色名是否存在
			sbsql.append("select * from sys_role where corp_id='"+shbdwbh+"' and name='"+rolename+"' and id<>'"+roleid+"'");
			List testList=DaoUtil.select(af.getConnection(),sbsql.toString(),roledf);
			if(testList.size()>0){
				af.getHttpRequest().setAttribute("result","该角色名已经存在!");
				return 0;
			}
			
			
			roledf.set("NAME",rolename);
			
			//角色群组
			String rolegroupsql = "DELETE FROM SYS_GROUP_ROLE WHERE ROLE_ID='"+roleid+"'";
			DaoUtil.execute(af.getConnection(),rolegroupsql);
			
			String[] newrolegroup = af.getHttpRequest().getParameterValues("grouparray");
			if(newrolegroup != null && !"".equals(newrolegroup))
			{
				for(int i =0;i<newrolegroup.length;i++)
				{
					DataForm newrolegroupdf = new DataForm("SYS_GROUP_ROLE","ID");
					newrolegroupdf.set("ID",GUIDKeyGen.getGUIDKey(af.getConnection()));
					newrolegroupdf.set("GROUP_ID", newrolegroup[i]);
					newrolegroupdf.set("ROLE_ID", roledf.get("ID"));
					DaoUtil.insert(af.getConnection(), newrolegroupdf);
				}
			}

			//角色用户
			String roleusersql = "DELETE FROM SYS_USER_ROLE WHERE ROLE_ID='"+roleid+"'";
			DaoUtil.execute(af.getConnection(),roleusersql);			
			
/*			String newroleuser = af.getHttpRequest().getParameter("userarray");			
			if(newroleuser!=null && !"".equals(newroleuser))
			{
				String[] userarray = newroleuser.split(";");
				for(int i = 0;i<userarray.length;i++)
				{
					DataForm newroleuserdf = new DataForm("SYS_USER_ROLE","ID");
					newroleuserdf.set("ID",GUIDKeyGen.getGUIDKey(af.getConnection()));
					
					String usql = "SELECT * FROM SYS_USER WHERE LOGON_NAME='"+userarray[i]+"'";
					DataForm[] udf = DaoUtil.getDFListBySQL(af.getConnection(),usql);
					
					newroleuserdf.set("ROLE_ID", roledf.get("ID"));
					newroleuserdf.set("USER_ID", udf[0].get("ID"));
					
					DaoUtil.insert(af.getConnection(), newroleuserdf);				
				}
			}*/
			
			String userrole = af.getHttpRequest().getParameter("hid_");
			if(userrole!=null && !"".equals(userrole))
			{
				String[] userarray = userrole.split(",");
				for(int i = 0;i < userarray.length;i++)
				{
					DataForm userroledf = new DataForm("SYS_USER_ROLE","ID");
					userroledf.set("ID",GUIDKeyGen.getGUIDKey(af.getConnection()));
					userroledf.set("USER_ID",userarray[i]);
					userroledf.set("ROLE_ID",roledf.get("ID"));
					DaoUtil.insert(af.getConnection(),userroledf);
				}	
			}
			
			//角色功能
			String rolefuncsql = "DELETE FROM SYS_ROLE_MODULE WHERE ROLE_ID='"+roleid+"'";
			DaoUtil.execute(af.getConnection(),rolefuncsql);			
			String newrolefunc = af.getHttpRequest().getParameter("rolefunc");
			String[] moduleid=new String[40];
			moduleid=newrolefunc.split(",");
			if(newrolefunc != null && !"".equals(newrolefunc))
			{
				for(int i = 0;i<moduleid.length;i++){
					DataForm newrolefuncdf = new DataForm("SYS_ROLE_MODULE","ID");
					newrolefuncdf.set("ID",GUIDKeyGen.getGUIDKey(af.getConnection()));
					newrolefuncdf.set("ROLE_ID", roledf.get("ID"));
					newrolefuncdf.set("MODULE_ID",moduleid[i]);
					DaoUtil.insert(af.getConnection(), newrolefuncdf);								
				}
			}	
			//更新角色
			DaoUtil.update(af.getConnection(),roledf);
			af.getHttpRequest().setAttribute("result","修改角色");
			af.getHttpRequest().setAttribute("goto","Selevet.do?action=BASE_SYSROLE_LIST");
			af.getHttpRequest().setAttribute("CMD",af.getHttpRequest().getParameter("CMD"));
			return 1;
		}catch(Exception e)
		{
			e.printStackTrace();
			af.getHttpRequest().setAttribute("result","修改角色");
			return 0;
		}
	}

}

⌨️ 快捷键说明

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