数据权限的控制 SSH,jdk7 阶段性总结. --两个select来回移动-模板文章★

阅读更多
1.
数据权限的控制 SSH,jdk7 阶段性总结. --两个select来回移动-模板文章★_第1张图片
2.
数据权限的控制 SSH,jdk7 阶段性总结. --两个select来回移动-模板文章★_第2张图片





二次Rev 贴上去.
//================
页面效果




1.主要Action: ResDataAction  ,SimpleHelpAction
2.页面部分.
userList.jsp  开始页面 ,点击帮助,进入 选择权限可.
resData下的三个主要页面.
resdataDetail.jsp
resDataList.jsp  左边显示全部的信息.  Ok.
simpleHelp.jsp
3.struts.xml
struts-adminx.xml

/=================
可扩展部分:
加上复选框,参见 examAction. 考试章节管理. 谢国芹的.


ResDataAction 数据权限的action

package com.myland.jp.adminx.resdata.action;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.myland.framework.base.BaseAction;
import com.myland.framework.init.BaseConf;
import com.myland.framework.sequence.SeqUtil;
import com.myland.framework.util.Constants;
import com.myland.jp.common.service.ResDataService;
import com.myland.pojo.ResData;

/**
 * 数据权限操作action
 * 
 * @author chenem
 * @email [email protected]
 * @create 2014年10月13日 下午8:02:07
 */
public class ResDataAction extends BaseAction {

    private static final long serialVersionUID = 5188450563333761481L;

    private static final Logger log = LogManager.getLogger(ResDataAction.class);

    private ResDataService resDataService;

    private String userId; // 用户id

    private String resKey;

    /**
     * 数据权限对象
     */
    private ResData resDataBean; // 对象

    // 传过来 就id, resData.

    private String rdNames;

    private List cfgResDataLst; // 数据权限的option显示用的.

    private String id; // ? 我不用.

    private String resData;

    /**
     * 反馈信息. 成功
     */
    private String msg; //

    /**
     * 默认方法
     */
    public String execute() throws Exception {
        return SUCCESS;
    }

    /**
     * 打开数据权限操作页面
     * 
     * @author chenem
     * @create 2014年10月13日 下午8:06:01
     * @return
     */
    public String resDataOpen() {
        cfgResDataLst = BaseConf.get().getList(BaseConf.RES_DATA); // [AGENT_DATA:代理商] 获取的 键值, XPath.

        if (StringUtils.isBlank(StringUtils.trim(resKey))) {  // 初,key空,得1可.
            // get()获取配置,getList .get(0 ) agent | 得到key可.
            resKey = ((String) BaseConf.get().getList(BaseConf.RES_DATA).get(0)).split(":")[0];
        }
        
        resDataBean = resDataService.getResDataByUserId(userId, resKey); // userId,402,null 有时候为null,
        // resData带有,的就是显示后面驾校的内容. 几个,,的.
        rdNames = resDataService.getRdNamesByRd_comma(resDataBean); //
        return "open";
    }

    /**
     * 保存数据权限
     * 
     * @author lengzl
     * @create 2014年12月6日 下午5:08:35
     * @return
     */
    public String save() {
        resDataBean = new ResData();
        //新加
        if(StringUtils.isBlank(StringUtils.trim(id))){
            if(StringUtils.isNotBlank(StringUtils.trim(resData))){
                resDataBean.setId(SeqUtil.getNextKeyDefaultDsContext(Constants.TSeq.T_RES_DATA));
                resDataBean.setResData(resData);
                resDataBean.setResKey(resKey);
                resDataBean.setUserId(Long.valueOf(userId));
                resDataService.addResData(resDataBean);
                msg = "新增成功!";
            }
        }else{
            if(StringUtils.isBlank(StringUtils.trim(resData))){
                resDataService.delResData(Long.valueOf(id));
                msg = "修改成功!";
            }else{
                resDataBean.setId(Long.valueOf(id));
                resDataBean.setResData(resData);
                resDataService.updateResData(resDataBean);
                msg = "修改成功!";
            }
        }
        return resDataOpen();
    }

    public void setResDataService(ResDataService resDataService) {
        this.resDataService = resDataService;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getResKey() {
        return resKey;
    }

    public void setResKey(String resKey) {
        this.resKey = resKey;
    }

    public String getRdNames() {
        return rdNames;
    }

    public void setRdNames(String rdNames) {
        this.rdNames = rdNames;
    }

    public List getCfgResDataLst() {
        return cfgResDataLst;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public ResData getResDataBean() {
        return resDataBean;
    }

    public void setResDataBean(ResData resDataBean) {
        this.resDataBean = resDataBean;
    }

    public String getResData() {
        return resData;
    }

    public void setResData(String resData) {
        this.resData = resData;
    }

    public String getMsg() {
        return msg;
    }
    
    public void setMsg(String msg) {
        this.msg = msg;
    }

}


SimpleHelpAction  帮助页面的action

package com.myland.jp.adminx.resdata.action;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.myland.framework.base.BaseAction;
import com.myland.framework.init.BaseConf;
import com.myland.framework.mybatis.query.Condition;
import com.myland.framework.mybatis.query.CxxString;
import com.myland.framework.mybatis.query.DefaultQueryRulesCreator;
import com.myland.framework.mybatis.query.QueryCriterion;
import com.myland.framework.util.ExceptionPrintUtil;
import com.myland.jp.common.service.ResDataService;
import com.myland.pojo.ResData;
import com.myland.pojo.User;

/**
 * 报名管理???通用帮助
 * 
 * 
 * 作者:WuM
 * 日期:2012-12-8
 * 
 */

public class SimpleHelpAction extends BaseAction {

    private static final long serialVersionUID = -6809838912828224054L;

    private static final Logger log = LogManager.getLogger(SimpleHelpAction.class);

    private ResDataService resDataService;

    private String userId;

    /**
     * 搜索的名字,如 agent的名字.
     */
    private String sechName;

    private String idAndName;

    private String resKeyValue;

    private String selectIdAndNames;

    private String info;

    private String resKey; // 下拉框的值 **) 将原页面的 c 同意换成resKey ★)

    private List> resDataList;

    private QueryCriterion qc;

    private String bar;

    /**
     * 通用帮助
     * 
     * @return
     * @throws Exception
     */
    public String simpleHelp() throws Exception {

        User curuser = (User) getRequest().getSession().getAttribute("curuser");
        if (curuser == null) {
            getRequest().setAttribute("err", "session信息丢失!");
            getRequest().setAttribute("rtnurl", BaseConf.get().getString(BaseConf._ADMINX_NAMED_RESOURCES_LOGIN));
            return ERROR;
        }

        ResData rd = resDataService.getResDataByUserId(userId, resKey); //ResData对象.

        if(rd != null){
            info = resDataService.getRdNamesByRd(rd);  //, |的格式.
        }
        
        return SUCCESS;
    }

    /**
     * 查询data
     * 查询全部的List //要确保,可以查agent... ★)
     * @author lengzl
     * @create 2014年12月6日 下午12:22:42
     * @return
     */
    public String resDataSearch() {
        
        if(StringUtils.isNotBlank(StringUtils.trim(sechName))){
            try {
                sechName = java.net.URLDecoder.decode(sechName,"UTF-8";);
            } catch(UnsupportedEncodingException e) {
                log.error("转码出现异常!");
                ExceptionPrintUtil.PrintErrorMessage(e, log);
            }   
        }

        qc = getQueryCriterion(new DefaultQueryRulesCreator() {

            private static final long serialVersionUID = -6488407568459794160L;

            public Map createConditions() {

                Map conditions = new HashMap();
                conditions.put("resKey", new CxxString(resKey));
                if (StringUtils.isNotBlank(StringUtils.trim(sechName))) {
                    conditions.put("sechName", new CxxString(sechName));
                }

                return conditions;
            }
        });

        //分页部分
        qc.getPagination().setPageSize(3);
        resDataList = resDataService.getViewResDate(qc);
        qc.getPagination().setShowType("001"); //默认显示的.
        bar = qc.getPagination().toBar();

        return "list";
    }

    public String getSechName() {
        return sechName;
    }

    public void setSechName(String sechName) {
        this.sechName = sechName;
    }

    public String getIdAndName() {
        return idAndName;
    }

    public void setIdAndName(String idAndName) {
        this.idAndName = idAndName;
    }

    public String getResKeyValue() {
        return resKeyValue;
    }

    public void setResKeyValue(String resKeyValue) {
        this.resKeyValue = resKeyValue;
    }

    public String getSelectIdAndNames() {
        return selectIdAndNames;
    }

    public void setSelectIdAndNames(String selectIdAndNames) {
        this.selectIdAndNames = selectIdAndNames;
    }

    public QueryCriterion getQc() {
        return qc;
    }

    public void setQc(QueryCriterion qc) {
        this.qc = qc;
    }

    public String getResKey() {
        return resKey;
    }

    public void setResKey(String resKey) {
        this.resKey = resKey;
    }

    public List> getResDataList() {
        return resDataList;
    }

    public void setResDataList(List> resDataList) {
        this.resDataList = resDataList;
    }

    public void setResDataService(ResDataService resDataService) {
        this.resDataService = resDataService;
    }

    public String getBar() {
        return bar;
    }

    public void setBar(String bar) {
        this.bar = bar;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

}



resdataDetail.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>









数据权限



查看用户权限信息
数据权限: 帮助 ${rdNames }


simpleHelp.jsp 弹出的帮助页面
亮点:下拉框值的获取与移动. 优于 之前廖永鹏的.

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp"%>





 <%-- 引入分页样式.--%>

数据权限




	<%--border="1px solid black;" --%>
		
确定 关闭 清除

名称:
<%--已选项 --%>
<%--怎么传值? --%>

resDataList.jsp simpleHelp.jsp已加载就ajax请求的嵌入页面
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>

没有权限信息! ${bar}

pubHelp.jsp 点击帮助,用于嵌套的.
<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/common/common.jsp"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="java.util.Enumeration"%>

	
		通用帮助
	
	
		
<% Enumeration pname = request.getParameterNames(); String para = ""; String cmd = ""; while (pname.hasMoreElements()) { String temp = (String) pname.nextElement(); if (!temp.equals("url")) { if (para.equals("")) { para = temp + "="; } else { para = para + "&" + temp + "="; } para += request.getParameter(temp); } else cmd = request.getParameter(temp); } %>



struts-adminx.xml 控制权限的



    
    
    	
    	
    		
    			
    		
    	
    	
    	
    	
    	
    		/adminx/login/adminLogin.jsp
    		/adminx/home/home.jsp
    	
    	
    	
    	
    		/adminx/exam/examList.jsp
    		/adminx/exam/examAdd.jsp
    		/adminx/exam/examUpdate.jsp
    		/adminx/exam/examBatchAdd.jsp
    	
    	
    	
    	
    		/adminx/testpaper/testPaperList.jsp
    		/adminx/testpaper/testPaperAdd.jsp
    		/adminx/testpaper/testPaperUpdate.jsp
    	
    	
    	
    	
    		/adminx/plan/planList.jsp
    		/adminx/plan/planList.jsp
    		/adminx/plan/planList.jsp
    		/adminx/plan/planAdd.jsp
    		/adminx/plan/planModify.jsp
    	
    	
    	
    		/adminx/plan/planNodeList.jsp
    		/adminx/plan.do
    		/adminx/plan/planNodeAdd.jsp
    		/adminx/plan/interfaceList.jsp
    		/adminx/plan/jsPlanNode.jsp
    		/adminx/plan/orderPlanNode.jsp
    	
    	
    		/adminx/plan/courseList.jsp
    	
    	
    		/adminx/plan/examList.jsp
    	
    	
    	
    		/adminx/agent/agentList.jsp
    		/adminx/agent/agentAdd.jsp
    		/adminx/agent/agentModify.jsp
    		/adminx/agent/agentDetail.jsp
    		/adminx/agent/bindedPlanAgent.jsp
    	
    	
    	
    		/adminx/agent/bindAgent.jsp
    	
    	
    	
    		/adminx/agent/bindedPlanAgent.jsp
    	
    	
    	
    		/adminx/cont/contList.jsp
    		/adminx/cont/contAdd.jsp
    		/adminx/cont/contModify.jsp
    		/adminx/cont/contDetail.jsp
    	
    	
    	
    		/adminx/payAccnt/payAccntList.jsp
    		/adminx/payAccnt/payAccntAdd.jsp
    		/adminx/payAccnt/payAccntModify.jsp
    	
    	
    	
    		/adminx/payAccnt/payAccntAdd.jsp
    	
    	
    	
    		/adminx/payAccnt/agentList.jsp
    	
    	
    		/adminx/payAccnt/contList.jsp
    	
    	
    	
    	
    		/adminx/viewPerson/viewPersonList.jsp
    	
    	
    	
    		/adminx/payBank/payBankList.jsp
    		/adminx/payBank/payBankAdd.jsp
    		/adminx/payBank/payBankModify.jsp
    	
    	
    	
    		/adminx/agentChange/agentList.jsp
    		/adminx/agentChange/agentModify.jsp
    		/adminx/agentChange/agentChangeList.jsp
    		/adminx/agentChange/agentChangeModify.jsp
    		/adminx/agentChange/agentInvoiceModify.jsp
    		/adminx/agentChange/agentChangeConfirm.jsp
    	
    	
    		/adminx/agentChange/agentChangeList.jsp
    	
    	
    		/adminx/agentChange/agentChangeAdd.jsp
    	
    	
    		/adminx/agentChange/payAccntList.jsp
    	
    	
    		/adminx/agentChange/payBankList.jsp
    	
    	
    		/adminx/agentChange/agentChangeConfirm.jsp
    	
    	
    	
    		/adminx/dept/deptList.jsp
    		/adminx/dept/deptUpdate.jsp
    		/adminx/deptAction.do?conditions=keep
    		/adminx/deptAction.do?conditions=keep
    		/adminx/deptAction.do?conditions=keep
    	
    	
    	
    	
    		/adminx/role/roleList.jsp
    		/adminx/roleAction.do?conditions=keep
    		/adminx/role/roleUpdate.jsp
    		/adminx/roleAction.do?conditions=keep
    		/adminx/roleAction.do?conditions=keep
    		/adminx/role/roleDetail.jsp
    	
    	
    	
    	
    		/adminx/getUsersInfo.do?conditions=keep
    		/adminx/user/userView.jsp
    		/adminx/user/userUpdate.jsp
    		/adminx/getUsersInfo.do?conditions=keep
    		/adminx/getUsersInfo.do?conditions=keep
    	
    	
    	
    		/adminx/user/userList.jsp
    	
    	
    	
    		/adminx/user/userAdd.jsp
    	
    	
    	
    	
    	
    		/adminx/resdata/resdataDetail.jsp
    		/adminx/resdata/resdataDetail.jsp
    	
    	
    	 
    	 
    	
    	
    		/adminx/resdata/simpleHelp.jsp
    	
    	
    	
    		/adminx/resdata/resDataList.jsp
    	
    	
    	
    	
    	
    	
    	
    	
    		/adminx/pay/payOrderListAdminx.jsp
    		/adminx/pay/payOrdersListAdminx.jsp
    		/web/pay/alipayapi.jsp
    		/web/pay/alipayapi.jsp
    	
    	
    	
    		/adminx/exam/appExamVersion.jsp
    	
    	
    	
		
			/adminx/catType/demo-index.jsp
		
    	
    	
    	
		
			/adminx/chapter/chapterParentList.jsp
			/adminx/chapter/chapterParentAdd.jsp
			/adminx/chapter/chapterParentUpdate.jsp
			/adminx/chapter/works.jsp
			/adminx/chapter/chapterTopList.jsp
			/adminx/chapter/chapterTree.jsp
			/adminx/chapter/chapterList.jsp
			/adminx/chapter/chapterAdd.jsp
			/adminx/chapter/chapterUpdate.jsp
		
    	
    	
    	
		
			/adminx/chapter/examHelp.jsp
		
		
		
			/adminx/chapter/examList.jsp
		
		
    	
    	
    	
		
			/adminx/course/courseList.jsp
			/adminx/course/courseAdd.jsp
			/adminx/course/courseUpdate.jsp
		
    	
    	
    	
    	
    		/adminx/course/coursePower.jsp
    		/adminx/course/chapterSelectList.jsp
    		/adminx/chapterSelListAction.do?id=${id}
    		/adminx/chapterSelListAction.do?id=${id}
    	
    	
    	
    		/adminx/course/chapterList.jsp
    	
    	
    	
    		/adminx/course/chapterSelectList.jsp
    	
    	
    	
    		/adminx/course/chapterSelectList.jsp
    	
    	
    	
    	
    		/adminx/pay/payInvoiceListAdminx.jsp
    		
    			queryInvoice
    			payInvoiceAdmin 
    			/adminx 
    		
    	
    	
    	
    	
    		/adminx/dic/dicMain.jsp 
    		/adminx/dic/dicMain.jsp
    		/adminx/dic/dicUpdate.jsp
    		/adminx/queryAllCode!queryAllCode.do?conditions=keep
    		/adminx/queryAllCode!queryAllCode.do?conditions=keep
    		/adminx/dic/aud.jsp
    		
    	
    	
    
    





  • 数据权限的控制 SSH,jdk7 阶段性总结. --两个select来回移动-模板文章★_第3张图片
  • 大小: 186.5 KB
  • 数据权限的控制 SSH,jdk7 阶段性总结. --两个select来回移动-模板文章★_第4张图片
  • 大小: 127.7 KB
  • 数据权限的控制 SSH,jdk7 阶段性总结. --两个select来回移动-模板文章★_第5张图片
  • 大小: 24.8 KB
  • 数据权限的控制 SSH,jdk7 阶段性总结. --两个select来回移动-模板文章★_第6张图片
  • 大小: 1016.5 KB
  • 查看图片附件

你可能感兴趣的:(java,jsp,jquery,ajax)