/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.yuntong.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.yuntong.hibernate.database.dao.TRoleInfoDAO;
import com.yuntong.service.Y_IRoleManagerService;

/** 
 * MyEclipse Struts
 * Creation date: 04-13-2007
 * 更新用户权限
 * XDoclet definition:
 * @struts.action validate="true"
 * @struts.action-forward name="go" path="/Y_YHQX_1.jsp"
 */
public class Y_UpdataRoleAction extends Action {
	private  Log log = LogFactory.getLog(Y_UpdataRoleAction.class);
	private Y_IRoleManagerService roleManagerService;
	public Y_IRoleManagerService getRoleManagerService() {
		return roleManagerService;
	}
	public void setRoleManagerService(Y_IRoleManagerService roleManagerService) {
		this.roleManagerService = roleManagerService;
	}
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		//结果集数组
		String [] values;
		//修改记录编号
		int roleId=999;
		//修改参数
		int SHGL=0;
		int PWGL=0;
		int PSGL=0;
		int CWGL=0;
		int SCGL=0;
		int TJCX=0;
		int JBZL=0;
		//循环修改
		for (int j = 1; j <= 8; j++) {
			 SHGL=0;
			 PWGL=0;
			 PSGL=0;
			 CWGL=0;
			 SCGL=0;
			 TJCX=0;
			 JBZL=0;
			roleId=roleId+1;
			values=request.getParameterValues(j+"");
			for (int i = 0; i <values.length; i++) {
				for (int k = 1; k <=7; k++) {
					if(values[i].toString().equals(""+k)){
						if(k==1){
							SHGL=1;
						}
						if(k==2){
							PWGL=1;
						}
						if(k==3){
							PSGL=1;
						}
						if(k==4){
							CWGL=1;
						}
						if(k==5){
							SCGL=1;
						}
						if(k==6){
							TJCX=1;
						}
						if(k==7){
							JBZL=1;
						}
					}
				}				
			}
			roleManagerService.updataRoleInfo(SHGL, PWGL, PSGL, CWGL, SCGL, TJCX, JBZL, roleId);
			log.info("修改权限："+j);
			//得到所有权限信息
			List list=roleManagerService.findAllRoleInfo();
			//保存权限信息
			HttpSession session=request.getSession();
			session.setAttribute("Y_roinfo",list);
			session.setAttribute("y_upme", "修改成功");
		}							
		return mapping.findForward("go");
	}
}