/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.memory.yT0202.web.action;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.memory.common.util.PageResult;
import com.memory.yT0202.biz.UserBiz;
import com.memory.yT0202.entity.Loginlog;
import com.memory.yT0202.entity.NodeMenu;
import com.memory.yT0202.entity.Role;
import com.memory.yT0202.entity.RoleRight;
import com.memory.yT0202.entity.Users;
/**
* MyEclipse Struts
* Creation date: 12-12-2008
*
* XDoclet definition:
* @struts.action parameter="operate" validate="true"
*/
public class PopedomallotAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
/**
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
private UserBiz userBiz = null;
public void setUserBiz(UserBiz userBiz) {
this.userBiz = userBiz;
}
public ActionForward doallot(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws IOException {
//RolerightForm rolerightForm = (RolerightForm) form;// TODO Auto-generated method stub
RoleRight roleright = new RoleRight();//rolerightForm.getRoleright();
String uid = request.getParameter("userid");
Long usid =Long.parseLong(uid);
Users users = (Users)userBiz.get(Users.class, usid);
Role role=(Role)users.getRole();
//删除所有的菜单
userBiz.del(RoleRight.class, usid);
String v1 =request.getParameter("101");
String v2 =request.getParameter("102");
String v3 =request.getParameter("103");
String v4 =request.getParameter("104");
String v5 =request.getParameter("105");
String v6 =request.getParameter("106");
String[] chs1 = request.getParameterValues("10101");
String[] chs2 = request.getParameterValues("10201");
String[] chs3 = request.getParameterValues("10301");
String[] chs4 = request.getParameterValues("10401");
String[] chs5 = request.getParameterValues("10501");
String[] chs6 = request.getParameterValues("10601");
//添加新的菜单
NodeMenu nodeMenu = null;
if(v1!=null&&!v1.equals(""))
{
nodeMenu=(NodeMenu)userBiz.get(NodeMenu.class, Long.parseLong(v1));
roleright.setNodeMenu(nodeMenu);
roleright.setRole(role);
roleright.setUsers(users);
userBiz.add(roleright);
}
if(v2!=null&&!v2.equals(""))
{
nodeMenu=(NodeMenu)userBiz.get(NodeMenu.class, Long.parseLong(v2));
roleright.setNodeMenu(nodeMenu);
roleright.setRole(role);
roleright.setUsers(users);
userBiz.add(roleright);
}
if(v3!=null&&!v3.equals(""))
{
nodeMenu=(NodeMenu)userBiz.get(NodeMenu.class, Long.parseLong(v3));
roleright.setNodeMenu(nodeMenu);
roleright.setRole(role);
roleright.setUsers(users);
userBiz.add(roleright);
}
if(v4!=null&&!v4.equals(""))
{
nodeMenu=(NodeMenu)userBiz.get(NodeMenu.class, Long.parseLong(v4));
roleright.setNodeMenu(nodeMenu);
roleright.setRole(role);
roleright.setUsers(users);
userBiz.add(roleright);
}
if(v5!=null&&!v5.equals(""))
{
nodeMenu=(NodeMenu)userBiz.get(NodeMenu.class, Long.parseLong(v5));
roleright.setNodeMenu(nodeMenu);
roleright.setRole(role);
roleright.setUsers(users);
userBiz.add(roleright);
}
if(v6!=null&&!v6.equals(""))
{
nodeMenu=(NodeMenu)userBiz.get(NodeMenu.class, Long.parseLong(v6));
roleright.setNodeMenu(nodeMenu);
roleright.setRole(role);
roleright.setUsers(users);
userBiz.add(roleright);
}
if(chs1!=null&&chs1.length>0){
for(int i =0;i<chs1.length;i++)
{
if(chs1[i]!=null||chs1[i].equals(""))
{
nodeMenu=(NodeMenu)userBiz.get(NodeMenu.class, Long.parseLong(chs1[i]));
roleright.setNodeMenu(nodeMenu);
roleright.setRole(role);
roleright.setUsers(users);
userBiz.add(roleright);
}
}
}
if(chs2!=null&&chs2.length>0){
for(int i =0;i<chs2.length;i++)
{
if(chs2[i]!=null||chs2[i].equals(""))
{
nodeMenu=(NodeMenu)userBiz.get(NodeMenu.class, Long.parseLong(chs2[i]));
roleright.setNodeMenu(nodeMenu);
roleright.setRole(role);
roleright.setUsers(users);
userBiz.add(roleright);
}
}
}
if(chs3!=null&&chs3.length>0){
for(int i =0;i<chs3.length;i++)
{
if(chs3[i]!=null||chs3[i].equals(""))
{
nodeMenu=(NodeMenu)userBiz.get(NodeMenu.class, Long.parseLong(chs3[i]));
roleright.setNodeMenu(nodeMenu);
roleright.setRole(role);
roleright.setUsers(users);
userBiz.add(roleright);
}
}
}
if(chs4!=null&&chs4.length>0){
for(int i =0;i<chs4.length;i++)
{
if(chs4[i]!=null||chs4[i].equals(""))
{
nodeMenu=(NodeMenu)userBiz.get(NodeMenu.class, Long.parseLong(chs4[i]));
roleright.setNodeMenu(nodeMenu);
roleright.setRole(role);
roleright.setUsers(users);
userBiz.add(roleright);
}
}
}
if(chs5!=null&&chs5.length>0){
for(int i =0;i<chs5.length;i++)
{
if(chs5[i]!=null||chs5[i].equals(""))
{
nodeMenu=(NodeMenu)userBiz.get(NodeMenu.class, Long.parseLong(chs5[i]));
roleright.setNodeMenu(nodeMenu);
roleright.setRole(role);
roleright.setUsers(users);
userBiz.add(roleright);
}
}
}
if(chs6!=null&&chs6.length>0){
for(int i =0;i<chs6.length;i++)
{
if(chs6[i]!=null||chs6[i].equals(""))
{
nodeMenu=(NodeMenu)userBiz.get(NodeMenu.class, Long.parseLong(chs6[i]));
roleright.setNodeMenu(nodeMenu);
roleright.setRole(role);
roleright.setUsers(users);
userBiz.add(roleright);
}
}
}
response.setCharacterEncoding("GBK");
String s = "<script>alert('分配成功');</script>";
response.getWriter().write(s);
return null;
}
public ActionForward dologinlog(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
String no=request.getParameter("pageNo");
int pageNo = 1;
if(no!=null&&!no.equals(""))
{
pageNo = Integer.parseInt(no);
}
PageResult pageResult = userBiz.seach(25,pageNo);
int total =pageResult.getRecTotal();//总记录数
int page=0;//总页数
if(total%25==0)
{
page=total/25;
}
else
{
page=total/25+1;
}
if(page==0)
pageNo=0;
request.setAttribute("loglist", pageResult.getList());//返回结果
request.setAttribute("page", page);//总页数
request.setAttribute("pageNo", pageNo);//第几页
return mapping.findForward("yes");
}
public ActionForward delloginlog(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws IOException {
String id = request.getParameter("logid");
Long logid = Long.parseLong(id);
userBiz.delLog(Loginlog.class, logid);
response.setCharacterEncoding("GBK");
String s = "<script>alert('删除成功');</script>";
response.getWriter().write(s);
return mapping.findForward("dellogin");
}
public ActionForward delallloginlog(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws IOException {
userBiz.DelAlllogin();
return mapping.findForward("dellogin");
}
}