码迷,mamicode.com
首页 > Web开发 > 详细

JEECG中的validform验证ajaxurl的使用方法

时间:2020-04-01 16:27:25      阅读:87      评论:0      收藏:0      [点我收藏+]

标签:etl   lsp   css   数据库   erro   批量删除   idt   ogg   algo   

validform验证是一种非常方便的,实用的验证方式

对于需要验证后台数据的,validform是一个非常明智的选择

validform的ajaxurl属性能够完美的实现:当输入完成某一输入框,就会调用后台方法进行验证,如果符合要求就返回y,如果不符合要求就返回n

 

现在以添加乡镇信息为例作为讲解:

业务需求:用户录入乡镇信息,包括乡镇编码和乡镇名称,每当输入完成编号或名称光标移开的时候,就要验证编码或者名称是否在数据库中已经存在,如果存在,那么就提示进行重新输入,如果不存在就提示编码或名称可用

用户界面:

前台页面:

技术图片
<%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@ include file="/back/main/include/baseInclude.jsp" %>
<html>
    <head>
        <title>个人设置</title>
        <meta name="menu" content="user" />
        <link href="${basePath}/common/css/table.css" rel="stylesheet" type="text/css" />
        <script src="${basePath}/common/js/validform.min.js" type="text/javascript" ></script>
        <script src="${basePath}/common/js/validform_datatype.js" type="text/javascript" ></script>
        <script src="${basePath}/back/user/js/dealerUser.js" type="text/javascript"></script>
    </head>
    
    <body style="text-align:left;">
        <input type="hidden" id="basePath" value="${basePath}"/>
        <h3 style="text-align:center;">个人设置</h3>
        <s:form name="myform" action="personalSettings.action" method="post" id="pageform">
            <table id="mytable" cellspacing="0" summary="个人设置">
            <caption>
                个人信息
                <a style="float:right;margin:0 -100px" href="javascript:history.go(-1);">返回</a>
            </caption>
                <tr>
                    <th scope="col" style="width:100px;text-align:right;" class="specalt">帐号:</th>
                    <td scope="col" class="alt" style="text-align: left;">
                        ${operatorUser.loginName}
                    </td>
                </tr>
                <tr>
                    <th scope="col" style="width:100px;text-align:right;" class="specalt">旧密码:</th>
                    <td scope="col" class="alt" style="text-align: left;">
                        <input type="password" name="oldPass" nullmsg="请填写密码!" datatype="*6-20" errormsg="密码范围在6~20位之间!" ajaxurl="checkPassword.action" />
                    </td>
                </tr>
                <tr>
                    <th scope="col" style="width:100px;text-align:right;" class="specalt">密码:</th>
                    <td scope="col" class="alt" style="text-align: left;">
                        <input type="password" name="operatorUser.password" id="password" nullmsg="请填写密码!" datatype="*6-20" errormsg="密码范围在6~20位之间!" ajaxurl="checkNewPassword.action" />
                    </td>
                </tr>
                <tr>
                    <th scope="col" style="width:100px;text-align:right;" class="specalt">确认密码:</th>
                    <td scope="col" class="alt" style="text-align: left;">
                        <input type="password" nullmsg="请再输入一次密码!" recheck="operatorUser.password" datatype="*" />
                    </td>
                </tr>
                <tr>
                    <th scope="col" style="width:100px;text-align:right;" class="specalt">原授权码:</th>
                    <td scope="col" class="alt" style="text-align: left;">
                        <input type="password" nullmsg="请填写授权码!" datatype="*6-20" errormsg="授权码范围在6~20位之间!" ajaxurl="checkAuthorizepwd.action" />
                    </td>
                </tr>
                <tr>
                    <th scope="col" style="width:100px;text-align:right;" class="specalt">授权码:</th>
                    <td scope="col" class="alt" style="text-align: left;">
                        <input type="password" nullmsg="请填写授权码!" name="operatorUser.authorizepwd" datatype="*6-20" errormsg="授权码范围在6~20位之间!" />
                    </td>
                </tr>
                <tr>
                    <th scope="col" style="width:100px;text-align:right;" class="specalt">真实姓名:</th>
                    <td scope="col" class="alt" style="text-align: left;">
                        <input type="text" name="operatorUser.userName" id="userName" value="${operatorUser.userName}" nullmsg="请填写真实姓名!" datatype="*" />
                    </td>
                </tr>
                <tr>
                    <th scope="col" style="width:100px;text-align:right;" class="specalt">email:</th>
                    <td scope="col" class="alt" style="text-align: left;">
                        <input type="text" name="operatorUser.email" id="email" value="${operatorUser.email}" nullmsg="请填写邮箱信息!" datatype="e" errormsg="请填写正确的邮箱地址!" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="submit" onclick="return checkField();" value="确 定"/>
                        <input type="button" onclick="qxBtn();" value="取 消"/>
                    </td>
                </tr>
            </table>
        </s:form>
    </body>

</html>
技术图片

 

后台代码实现:

技术图片
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Resource;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.hsmpay.back.action.base.BackBaseAction;
import com.hsmpay.back.pojo.organization.Organization;
import com.hsmpay.back.pojo.system.Role;
import com.hsmpay.back.pojo.user.OperatorUser;
import com.hsmpay.back.service.organization.OrganizationService;
import com.hsmpay.back.service.system.RoleService;
import com.hsmpay.back.service.user.OperatorUserService;
import com.hsmpay.back.util.GlobalConstant;
import com.hsmpay.back.util.PageDown;
import com.hsmpay.common.util.MD5;

/**
 * 后台用户action
 * @author 颜铃璋
 * @version 1.0
 * @date 2012-11-28    
 */
@Controller("operatorUserAction")
@Scope("prototype")
public class OperatorUserAction extends BackBaseAction{
    private static final long serialVersionUID = -5319745710227353987L;
    static Logger log = Logger.getLogger(OperatorUserAction.class);
    private OperatorUser operatorUser;//jsp直接引用或传参 操作员对象
    private List<OperatorUser> operatorUserList;
    private List<Role> roleList;//角色列表
    private List<Organization> organizationList;//后台操作员列表
    
    @Resource(name="roleService")
    private RoleService<Role,Long> roleService;
    @Resource(name="organizationService")
    private OrganizationService<Organization,Long> organizationService;//
    
    @Resource(name="operatorUserService")
    private OperatorUserService<OperatorUser,Long> operatorUserService;//操作员服务对象
    //机构
    private Organization organization;
    
    /**
     * 授权码验证
     * @return
     * @throws Exception
     */
    public String passWordVerify() throws Exception{
        try{
            log.debug("*****************进入密码验证*******************");
            
            String password = getRequest().getParameter("password");
//            String type = getRequest().getParameter("type");
            
            if(null == password||"".equals(password)){
                sendAjaxResponse("传递参数错误!!");
                return null;
            }
            
            if(getSessionUser()==null){
                sendAjaxResponse("noLogin");
                return null;
            }
            
            operatorUser = new OperatorUser();
            operatorUser.setId(getSessionUser().getId());
            operatorUser.setAuthorizepwd(MD5.mD5ofStr(password));
            boolean tag = operatorUserService.checkAuthorizePassword(operatorUser);
            if(tag){//密码验证成功
                sendAjaxResponse("1");
            }else{
                sendAjaxResponse("-1");
            }
            log.debug("*****************密码验证结束*******************");
            return null;
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }
    }

    /**
     * 进入后台操作员列表 准备好  将要使用的数据
     * @return
     * @throws Exception
     */
    public String list()throws Exception{
        try{
            
            log.debug("进入后台操作员list: OperatorUser "+(OperatorUser)getSession().getAttribute(SESSION_OPERATORUSER));
            log.debug("进入后台操作员list: checkOperatorUser "+checkOperatorUser());
            initRpo("OperatorUserAction");
            if(null == operatorUser){
                operatorUser = new OperatorUser();
            }else{
                String startDateStr = getRequest().getParameter("startDateStr");
                String endDateStr = getRequest().getParameter("endDateStr");
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                if(StringUtils.isNotBlank(startDateStr)){
                    Date startDate = sdf.parse(startDateStr);
                    operatorUser.setStartDate(startDate);
                }
                if(StringUtils.isNotBlank(endDateStr)){
                    Date endDate = sdf.parse(endDateStr);
                    operatorUser.setEndDate(endDate);
                }
            }
            operatorUser.setDeleted(0);
            //查询出所有的 关于你所在后台操作员的用户列表
            if(!GlobalConstant.ROOT_ORGANIZATIONID.equals(getSessionUser().getRpOrganId())){//如果不是管理员身份  查出用户所属后台操作员的用户列表
                //operatorUser.setLayer(getSessionUser().getLayer());
                operatorUser.setOrganizationId(getSessionUser().getRpOrganId());
                //operatorUserList = operatorUserService.searchEntityList(operatorUser);
            }
//            if(null != operatorUser.getOrganizationId()){//添加 层级
//                organization = organizationService.searchEntityById(Organization.class, operatorUser.getOrganizationId());
//                operatorUser.setLayer(organization.getLayer());
//            }
            
            /* 屏蔽自己
            //operatorUser.setId(getSessionUser().getId()); */
            
            PageDown pageDown = new PageDown(getCurrentPage(), 20);    //计算起始和终止的条数
            int categoryCount = (int)operatorUserService.getEntityCount(operatorUser);//计算总条数
            pageDown.setTotalRecordNumber(categoryCount);    //总数存到分页方法里。
            operatorUser.setStart(pageDown.getStart());
            operatorUser.setStop(pageDown.getStop());
            operatorUserList = operatorUserService.searchEntityList(operatorUser);
            pagerString = pageDown.getScript();
            
            //后台用户角色
            Role role = new Role();
            role.setLayer(operatorUser.getLayer());
            role.setDeleted(0);
            if(!ADMIN_ROLEID.equals(getSessionUser().getRoleId())){//如果是管理员  就显示所有角色
                role.setOrganizationId(operatorUser.getOrganizationId());
                //添加登录后台用户所属角色
                roleList = new LinkedList<Role>();
                roleList = roleService.searchEntityList(role);
                Role r = new Role();
                r.setId(getSessionUser().getRoleId());
                r = roleService.searchEntity(r);
                roleList.add(0,r);
            }else{
                //添加登录后台用户所属角色
                roleList = roleService.searchEntityList(role);
            }
            
            log.debug("退出后台操作员list");
            
            if(GlobalConstant.ROOT_ORGANIZATIONID.equals(getSessionUser().getRpOrganId())){//如果不是顶级机构
                return "list";
            }else{
                return "agent_list";
            }
            
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }
    }
    
    /**
     * 删除单个后台用户
     * @return
     * @throws Exception
     */
    public String delete(){
        try{
            if(operatorUser.getId().equals(getSessionUser().getId())){
                log.warn("非法操作!您不能删除当前用户!");
                sendAjaxResponse("false");
                return null;
            }
            //删除后台用户
//            if(ZYZF_ORGANIZATIONID.equals(getSessionUser().getRpOrganId())){
                int flag = operatorUserService.logicDelete(operatorUser);
                if(flag > 0){
                    sendAjaxResponse("true");
                }else{
                    sendAjaxResponse("false");
                }
//            }else{
//                notice = "非法操作!";
//                return "globalGoback";
//            }
        }catch(Exception e){
            e.printStackTrace();
            sendAjaxResponse("error");
        }
        return null;
    }
    
    /**
     * 批量删除后台用户
     * @return
     * @throws Exception
     */
    public String batchDelete(){
        try{
            log.debug("批量删除后台用户"+ids);
            String[] idArray = ids.split(",");
            for(String id : idArray){
                if(id.equals(getSessionUser().getId())){
                    log.warn("非法操作!您不能删除当前用户!");
                    sendAjaxResponse("false");
                    return null;
                }
            }
//            if(ZYZF_ORGANIZATIONID.equals(getSessionUser().getRpOrganId())){
                int flag = operatorUserService.logicDeletes(ids);
                if(flag > 0){
                    sendAjaxResponse("true");
                }else{
                    sendAjaxResponse("false");
                }
//            }else{
//                notice = "非法操作!";
//                return "globalGoback";
//            }
        }catch(Exception e){
            e.printStackTrace();
            sendAjaxResponse("error");
        }
        return null;
    }
    
    /**
     * 跳转到添加
     * @return
     * @throws Exception
     */
    public String addS() throws Exception{
        try{
            operatorUser = getSessionUser();
            
            //登录用户所属机构
            Organization org = new Organization();
            org.setId(operatorUser.getOrganizationId());
            org = organizationService.searchEntity(org);
            
            Role role = new Role();
            
            List<Role> rList = new ArrayList<Role>();
            if(ADMIN_ROLEID.equals(operatorUser.getRoleId())){//超级管理员
                //登录用户所属机构角色
                role.setOrganizationId(operatorUser.getOrganizationId());
                role.setDeleted(0);
                roleList = roleService.searchEntityList(role);
            }else{
                if(1 == org.getType() && 1 == operatorUser.getType()){//OEM管理员
                    //登录用户所属机构角色
                    role.setOrganizationId(operatorUser.getOrganizationId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                    //特殊指定角色
                    role = new Role();
                    role.setAssignOrgId(org.getId());
                    role.setDeleted(0);
                    rList = roleService.searchEntityList(role);
                    if(null != rList && rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                    //OEM公有角色
                    role = new Role();
                    role.setType(2);
                    role.setDeleted(0);
                    rList = new ArrayList<Role>();
                    rList = roleService.searchEntityList(role);
                    if(null != rList || rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                }else if(1 < org.getType() && 1 == operatorUser.getType()){//代理商管理员
                    //登录用户所属机构角色
                    role.setOrganizationId(operatorUser.getOrganizationId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                    //特殊指定角色
                    role = new Role();
                    role.setAssignOrgId(org.getId());
                    role.setDeleted(0);
                    rList = roleService.searchEntityList(role);
                    if(null != rList && rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                    //代理商公有角色
                    role = new Role();
                    role.setType(3);
                    role.setDeleted(0);
                    rList = new ArrayList<Role>();
                    rList = roleService.searchEntityList(role);
                    if(null != rList || rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                }else if(0 == operatorUser.getType()){
                    if(GlobalConstant.ROOT_ORGANIZATIONID.equals(operatorUser.getOrganizationId())){//顶层用户登录
                        //顶级机构角色
                        role.setOrganizationId(operatorUser.getOrganizationId());
                        role.setIsOperatorRole(0);//不是超级管理员的角色
                        role.setDeleted(0);
                        roleList = roleService.searchEntityList(role);
                    }else if(1 == org.getType()){//OEM用户登录
                        role.setOrganizationId(org.getId());
                        role.setDeleted(0);
                        roleList = roleService.searchEntityList(role);
                        //特殊指定角色
                        role = new Role();
                        role.setAssignOrgId(org.getId());
                        role.setDeleted(0);
                        rList = roleService.searchEntityList(role);
                        if(null != rList && rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                        //OEM公有角色
                        role = new Role();
                        role.setType(2);
                        role.setDeleted(0);
                        rList = new ArrayList<Role>();
                        rList = roleService.searchEntityList(role);
                        if(null != rList || rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                    }else if(1 < org.getType()){//代理商用户登录
                        role.setOrganizationId(org.getId());
                        role.setDeleted(0);
                        roleList = roleService.searchEntityList(role);
                        //特殊指定角色
                        role = new Role();
                        role.setAssignOrgId(org.getId());
                        role.setDeleted(0);
                        rList = roleService.searchEntityList(role);
                        if(null != rList && rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                        //代理商公有角色
                        role = new Role();
                        role.setType(3);
                        role.setDeleted(0);
                        rList = new ArrayList<Role>();
                        rList = roleService.searchEntityList(role);
                        if(null != rList || rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                    }
                }
            }                
                        
            if(GlobalConstant.ROOT_ORGANIZATIONID.equals(operatorUser.getRpOrganId())){//如果不是顶级机构
                return "add";
            }else{
                return "agent_add";
            }
            /*
            if(WANJX_ORGANIZATIONID.equals(user.getRpOrganId())){//所属帐号
                Role role = new Role();
//                role.setLayer(user.getLayer());
                role.setDeleted(0);
                roleList = roleService.searchEntityList(role);
                return "add";
            }else{//代理商帐号跳转到添加经销商管理员界面 -- 弃用
//                Organization param = new Organization();
//                param.setParentId(user.getRpOrganId());
//                organizationList = organizationService.searchOrganizationNameList(param);
//                return "addDealer";
                notice = "非法操作!";
                return "globalGoback";
            }*/
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }
    }
    
    /**
     * 添加或修改用户时,根据选择的角色查询角色机构 
     * @return
     * @throws Exception
     */
    public String searchRoleRpOrganIDAndName()throws Exception{
        try{
            String roleId = getRequest().getParameter("roleId");
            if(StringUtils.isBlank(roleId)){
                notice = "非法操作!";
                return "globalGoback";
            }
            Role role = new Role();
            role.setId(Long.parseLong(roleId));
            role = roleService.searchEntity(role);
            Map<String,Object> element = new LinkedHashMap<String,Object>();
            element.put("rpOrganName", role.getOrganizationName());
            element.put("rpOrganId", role.getOrganizationId());
            sendAjaxResponse(element);
            return null;
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }
    }
    
    /**
     * 添加经销商管理员
     * @return
     * @throws Exception
     */
//    public String addDealer() throws Exception{
//        try{
//            log.debug("************* 添加经销商管理员操作开始 ******************");
//            //判断是否为其所属经销商机构
//            Organization params = new Organization();
//            params.setId(operatorUser.getRpOrganId());
//            params.setParentId(getSessionUser().getRpOrganId());
//            params = organizationService.searchEntity(params);
//            if(null == params){
//                notice = "非法操作!";
//                return "globalGoback";
//            }
//            //所属代理商、角色
//            operatorUser.setOrganizationId(getSessionUser().getOrganizationId());
//            operatorUser.setRoleId(GlobalConstant.DEALER_ROLEID);//添加
//            long id = operatorUserService.insertEntity(operatorUser);
//            if(id > 0){//添加成功返回列表
//                return "listAction";
//            }else{//添加失败  返回登录页
//                notice = "添加失败!";
//                return "globalGoback";
//            }
//        }catch(Exception e){
//            e.printStackTrace();
//            throw e;
//        }finally{
//            log.debug("************* 添加经销商管理员操作结束 ******************");
//        }
//    }
    
    /**
     * 添加后台操作员
     * @return
     * @throws Exception
     */
    public String add() throws Exception{
        try{
            //不能添加超级管理员
            if(ADMIN_ROLEID.equals(operatorUser.getRoleId())){
                notice = "非法操作!";
                return "globalGoback";
            }
            if(null == operatorUser.getRpOrganId()){
                notice = "非法操作!权限机构不能为空!";
                return "globalGoback";
            }
            
            
            //--- 暂时所属机构与权限机构一致 均为 ---
            operatorUser.setOrganizationId(operatorUser.getRpOrganId());
            operatorUser.setType(0);//普通用户
            
            operatorUser.setPassword(MD5.mD5ofStr(operatorUser.getLoginName()+operatorUser.getPassword()));
            operatorUser.setAuthorizepwd(MD5.mD5ofStr(operatorUser.getAuthorizepwd()));
            //添加
            long id = operatorUserService.insertEntity(operatorUser);
            if(id > 0){//添加成功返回列表
                return "listAction";
            }else{//添加失败  返回登录页
                return "globalLogin";
            }
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }
    }
    
    /**
     * 跳转到添加代理商管理员页面
     * @return
     * @throws Exception
     */
    public String addRootS() throws Exception{
        try{
            operatorUser = getSessionUser();
            /*if(!ADMIN_ROLEID.equals(operatorUser.getRoleId()) && !WANJX_ORGANIZATIONID.equals(operatorUser.getRpOrganId())){//不是管理员
                notice = "非法操作!";
                return "globalGoback";
            }
            if(WANJX_ORGANIZATIONID.equals(organization.getId())){
                notice = "非法操作!";
                return "globalGoback";
            }*/
            //代理商验证
//            Organization params = new Organization();
//            params.setId(organization.getId());
//            params = organizationService.searchEntity(params);
            if(1L == organization.getId()){
                notice = "非法操作,顶级机构不能添加管理员!";
                return "globalGoback";
            }
            Organization params = new Organization();
            params.setId(organization.getId());
            organization = organizationService.searchEntity(params);
            //查询 当前机构管理员是否存在   限制一个用户只能添加一个管理员
            OperatorUser paramUser = operatorUserService.searchOperatorUserByRoot(organization.getId());
            if(null != paramUser){//
                notice = "非法操作!该机构已经存在一个管理员了!";
                return "globalGoback";
            }
            return "addRootS";
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }
    }
    
    public String addRoot() throws Exception{
        try{
            //要添加超级管理员 或者 要添加管理员
            /*if(ADMIN_ROLEID.equals(operatorUser.getRoleId()) || WANJX_ORGANIZATIONID.equals(operatorUser.getOrganizationId())){
                notice = "非法操作!";
                return "globalGoback";
            }*/
            if(null == operatorUser.getOrganizationId()){
                notice = "非法操作!权限机构不能为空!";
                return "globalGoback";
            }
            
            
            //设置权限机构
            operatorUser.setRpOrganId(operatorUser.getOrganizationId());
            //设置此机构管理员角色  判断代理商或经销商
            Organization params = new Organization();
            params.setId(operatorUser.getOrganizationId());
            params = organizationService.searchEntity(params);
            
            operatorUser.setPassword(MD5.mD5ofStr(operatorUser.getLoginName()+operatorUser.getPassword()));
            operatorUser.setAuthorizepwd(MD5.mD5ofStr(operatorUser.getAuthorizepwd()));
            if(1 == params.getType().intValue()){//OEM
                operatorUser.setRoleId(GlobalConstant.OEM_ROLEID);
            }else if(2 == params.getType().intValue()){//省代
                operatorUser.setRoleId(GlobalConstant.AGENT_ROLEID);//暂时没有定义
            }else if(3 == params.getType().intValue()){//市代
                operatorUser.setRoleId(GlobalConstant.AGENT_ROLEID);//暂时没有定义
            }else{//其他代理
                operatorUser.setRoleId(GlobalConstant.AGENT_ROLEID);
            }
            operatorUser.setType(1);
            operatorUserService.insertEntity(operatorUser);
            
            //直接返回到  机构树形页面
            return "organizationList";
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }
    }
    
    /**
     * 修改时 查询后台操作员
     * @return
     * @throws Exception
     */
    public String modifyS() throws Exception{
        try{
            log.debug("**************** 进入修改后台用户界面 ***********************");
            if(null!= operatorUser.getOrganizationId() && 1L == operatorUser.getOrganizationId()){//屏蔽最上级 多用户
                notice = "非法操作,顶级机构不能编辑管理员!";
                return "globalGoback";
            }
            
            operatorUser = operatorUserService.searchEntity(operatorUser);
            if(null == operatorUser){
                notice = "非法操作,该机构暂时没有管理员不能编辑!";
                return "globalGoback";
            }
            
            if(ADMIN_ROLEID.equals(operatorUser.getRoleId())){
                notice = "非法操作,超级管理员不能修改!";
                return "globalGoback";
            }
            
            //被修改用户所属机构
            Organization org = new Organization();
            org.setId(operatorUser.getOrganizationId());
            org = organizationService.searchEntity(org);
            
            Role role = new Role();
            
            List<Role> rList = new ArrayList<Role>();
            if(ADMIN_ROLEID.equals(getSessionUser().getRoleId())){//超级管理员
                if(GlobalConstant.ROOT_ORGANIZATIONID.equals(org.getId())){//顶级机构
                    role.setOrganizationId(org.getId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                }else if(1 == org.getType()){//OEM
                    //机构所属角色
                    role.setOrganizationId(org.getId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                    //特殊指定角色
                    role = new Role();
                    role.setAssignOrgId(org.getId());
                    role.setDeleted(0);
                    rList = roleService.searchEntityList(role);
                    if(null != rList && rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                    //OEM公有角色
                    role = new Role();
                    role.setType(2);
                    role.setDeleted(0);
                    rList = new ArrayList<Role>();
                    rList = roleService.searchEntityList(role);
                    if(null != rList || rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                }else if(1 < org.getType()){//代理商
                    //机构所属角色
                    role.setOrganizationId(org.getId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                    //特殊指定角色
                    role = new Role();
                    role.setAssignOrgId(org.getId());
                    role.setDeleted(0);
                    rList = roleService.searchEntityList(role);
                    if(null != rList && rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                    //代理商公有角色
                    role = new Role();
                    role.setType(3);
                    role.setDeleted(0);
                    rList = new ArrayList<Role>();
                    rList = roleService.searchEntityList(role);
                    if(null != rList || rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                }
            }else{
                if(1 == org.getType() && 1 == getSessionUser().getType()){//OEM管理员
                    //登录用户所属机构角色
                    role.setOrganizationId(getSessionUser().getOrganizationId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                    //特殊指定角色
                    role = new Role();
                    role.setAssignOrgId(org.getId());
                    role.setDeleted(0);
                    rList = roleService.searchEntityList(role);
                    if(null != rList && rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                    //OEM公有角色
                    role = new Role();
                    role.setType(2);
                    role.setDeleted(0);
                    rList = new ArrayList<Role>();
                    rList = roleService.searchEntityList(role);
                    if(null != rList || rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                }else if(1 < org.getType() && 1 == getSessionUser().getType()){//代理商管理员
                    //登录用户所属机构角色
                    role.setOrganizationId(getSessionUser().getOrganizationId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                    //特殊指定角色
                    role = new Role();
                    role.setAssignOrgId(org.getId());
                    role.setDeleted(0);
                    rList = roleService.searchEntityList(role);
                    if(null != rList && rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                    //代理商公有角色
                    role = new Role();
                    role.setType(3);
                    role.setDeleted(0);
                    rList = new ArrayList<Role>();
                    rList = roleService.searchEntityList(role);
                    if(null != rList || rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                }else if(0 == getSessionUser().getType()){
                    if(GlobalConstant.ROOT_ORGANIZATIONID.equals(getSessionUser().getOrganizationId())){//顶层用户登录
                        //顶级机构角色
                        role.setOrganizationId(getSessionUser().getOrganizationId());
                        role.setIsOperatorRole(0);//不是超级管理员的角色
                        role.setDeleted(0);
                        roleList = roleService.searchEntityList(role);
                    }else if(1 == org.getType()){//OEM用户登录
                        role.setOrganizationId(org.getId());
                        role.setDeleted(0);
                        roleList = roleService.searchEntityList(role);
                        //特殊指定角色
                        role = new Role();
                        role.setAssignOrgId(org.getId());
                        role.setDeleted(0);
                        rList = roleService.searchEntityList(role);
                        if(null != rList && rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                        //OEM公有角色
                        role = new Role();
                        role.setType(2);
                        role.setDeleted(0);
                        rList = new ArrayList<Role>();
                        rList = roleService.searchEntityList(role);
                        if(null != rList || rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                    }else if(1 < org.getType()){//代理商用户登录
                        role.setOrganizationId(org.getId());
                        role.setDeleted(0);
                        roleList = roleService.searchEntityList(role);
                        //特殊指定角色
                        role = new Role();
                        role.setAssignOrgId(org.getId());
                        role.setDeleted(0);
                        rList = roleService.searchEntityList(role);
                        if(null != rList && rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                        //代理商公有角色
                        role = new Role();
                        role.setType(3);
                        role.setDeleted(0);
                        rList = new ArrayList<Role>();
                        rList = roleService.searchEntityList(role);
                        if(null != rList || rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                    }
                }
            }
            
            return "modify";
//            if(WANJX_ORGANIZATIONID.equals(user.getRpOrganId())){//所属帐号
//                Role role = new Role();
////                role.setLayer(user.getLayer());
//                role.setDeleted(0);
//                roleList = roleService.searchEntityList(role);
//                return "modify";
//            }else{
////                Organization param = new Organization();
////                param.setParentId(user.getRpOrganId());
////                organizationList = organizationService.searchOrganizationNameList(param);
////                return "modifyDealer";
//                notice = "非法操作!";
//                return "globalGoback";
//            }
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }finally{
            log.debug("**************** 进入修改后台用户界面完成 ***********************");
        }
    }
    
    /**
     * 修改经销商管理员
     * @return
     * @throws Exception
     */
//    public String modifyDealer() throws Exception{
//        try{
//            log.debug("************* 修改经销商管理员操作开始 ******************");
//            //判断是否为其所属经销商机构
//            Organization params = new Organization();
//            params.setId(operatorUser.getRpOrganId());
//            params.setParentId(getSessionUser().getRpOrganId());
//            params = organizationService.searchEntity(params);
//            if(null == params){
//                notice = "非法操作!";
//                return "globalGoback";
//            }
//            //所属代理商、角色
//            operatorUser.setOrganizationId(getSessionUser().getOrganizationId());
//            operatorUser.setRoleId(GlobalConstant.DEALER_ROLEID);//添加
//            long id = operatorUserService.updateEntity(operatorUser);
//            if(id > 0){//添加成功返回列表
//                return "listAction";
//            }else{//添加失败  返回登录页
//                notice = "修改失败!";
//                return "globalGoback";
//            }
//        }catch(Exception e){
//            e.printStackTrace();
//            throw e;
//        }finally{
//            log.debug("************* 修改经销商管理员操作结束 ******************");
//        }
//    }
    
    /**
     * 修改后台操作员
     * @return
     * @throws Exception
     */
    public String modify() throws Exception{
        try{
            if(null == operatorUser.getRpOrganId()){
                notice = "非法操作!权限机构不能为空!";
                return "globalGoback";
            }
            
            //不能修改为超级管理员    非管理员角色不能修改
            if(ADMIN_ROLEID.equals(operatorUser.getRoleId()) ){//|| !ADMIN_ROLEID.equals(getSessionUser().getRoleId())
                notice = "非法操作,超级管理员不能修改!";
                return "globalGoback";
            }
            //查询角色 所对应的机构ID 
//            Role role = new Role();
//            role.setId(operatorUser.getRoleId());
//            role = roleService.searchEntity(role);
            if(operatorUser.getRoleId() != GlobalConstant.DEALER_ROLEID){
                operatorUser.setOrganizationId(operatorUser.getRpOrganId());
            }
            int flag = 0;
            operatorUser.setPassword(MD5.mD5ofStr(operatorUser.getLoginName()+operatorUser.getPassword()));
//            operatorUser.setAuthorizepwd(MD5.mD5ofStr(operatorUser.getAuthorizepwd()));
            if(ZYZF_ORGANIZATIONID.equals(operatorUser.getRpOrganId())){
                operatorUser.setAuthorizepwd(MD5.mD5ofStr(operatorUser.getAuthorizepwd()));
                flag = operatorUserService.updateEntity(operatorUser);
            }else{
                OperatorUser param = new OperatorUser();
                param.setId(operatorUser.getId());
                param.setPassword(operatorUser.getPassword());
                param.setUserName(operatorUser.getUserName());
                param.setEmail(operatorUser.getEmail());
                param.setRoleId(operatorUser.getRoleId());
                param.setRpOrganId(operatorUser.getRpOrganId());
                param.setOrganizationId(operatorUser.getRpOrganId());
                param.setMerchantId(operatorUser.getMerchantId());
                param.setAuthorizepwd(MD5.mD5ofStr(operatorUser.getAuthorizepwd()));
                flag = operatorUserService.updateEntity(param);
            }
            if(flag > 0){//修改成功 返回列表
                OperatorUser param = new OperatorUser();
                param.setId(operatorUser.getId());
                operatorUser = operatorUserService.searchEntity(param);
                if(null != operatorUser.getType() && 1 == operatorUser.getType().intValue()){
                    //直接返回到  机构树形页面
                    return "organizationList";
                }else{
                    return "listAction";
                }
            }else{//修改失败 返回登录页面
                return "globalLogin";
            }
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }
    }
    
    /**
     * 检测登录名是否已经存在
     * @throws Exception
     */
    public void checkName() throws Exception{
        try{
            String name = getRequest().getParameter("param");
            log.debug("************ 检测用户名: "+name+" 是否存在 ************");
            Map<String,Object> element = new LinkedHashMap<String,Object>();
            OperatorUser params = new OperatorUser();
            params.setLoginName(name);
            params.setDeleted(0);
            int flag = operatorUserService.getEntityCount(params);
            
            //验证是否包含中文
            String regex = ".*?[\u4E00-\u9FFF]+.*";
            Pattern p = Pattern.compile(regex);
            Matcher m = p.matcher(name);
            
            //验证是否包含特殊字符
            String regex1 = "[`~!@#$%^&*()+=|{}‘:;‘,\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]";
            Pattern p1 = Pattern.compile(regex1);
            Matcher m1 = p1.matcher(name);
            
            //验证是否全为数字
            String regex2 = "^[0-9]*$";
            Pattern p2 = Pattern.compile(regex2);
            Matcher m2 = p2.matcher(name);
            
            if(flag > 0){
                element.put("info", "用户名已存在!");
                element.put("status", "n");
                log.debug("************ 用户名: "+name+" 已存在 ************");
            }else if(m.matches()){
                element.put("info", "用户名不能包含中文!");
                element.put("status", "n");
                log.debug("************ 用户名: "+name+" 包含中文 ************");
            }else if(m1.find()){
                element.put("info", "用户名不能包含特殊字符!");
                element.put("status", "n");
                log.debug("************ 用户名: "+name+" 包含特殊字符 ************");
            }else if(m2.matches()){
                element.put("info", "用户名不能全为数字!");
                element.put("status", "n");
                log.debug("************ 用户名: "+name+" 全为数字 ************");
            }else{
                element.put("info", "用户名可以使用!");
                element.put("status", "y");
                log.debug("************ 用户名: "+name+" 可以使用 ************");
            }
            sendAjaxResponse(element);
        }catch(Exception e){
            e.printStackTrace();
            throw  e;
        }
    }
    
    /**
     * 检测旧密码是否正确
     * @throws Exception
     */
    public void checkPassword() throws Exception{
        try{
            log.debug("************ 检测旧密码开始 ************");
            String old=getRequest().getParameter("param");
            operatorUser = getSessionUser();
            String pass = MD5.mD5ofStr(operatorUser.getLoginName()+old);
            Map<String,Object> element = new LinkedHashMap<String,Object>();
            if(pass.equals(getSessionUser().getPassword())){
                element.put("info", "");
                element.put("status", "y");
                log.debug("************ 旧密码正确! ************");
            }else{
                element.put("info", "旧密码输入错误!");
                element.put("status", "n");
                log.debug("************ 旧密码错误! ************");
            }
            sendAjaxResponse(element);
        }catch(Exception e){
            e.printStackTrace();
            throw  e;
        }finally{
            log.debug("************ 检测旧密码结束 ************");
        }
    }
    
    /**
     * 检测新密码格式是否符合要求
     * @throws Exception
     */
    public void checkNewPassword() throws Exception{
        try{
            log.debug("************ 检测新密码格式是否符合要求开始 ************");
            String newPass = getRequest().getParameter("param");
            
            String regex = "(?!^\\d+$)(?!^[a-zA-Z]+$)(?!^[_#@]+$).{6,}";//必须包含字母和数字 
            Pattern p = Pattern.compile(regex);
            Matcher m = p.matcher(newPass);
               
            Map<String,Object> element = new LinkedHashMap<String,Object>();
            if(m.matches()){
                element.put("info", "");
                element.put("status", "y");
                log.debug("************ 新密码格式符合要求! ************");
            }else{
                element.put("info", "密码必须包含字母和数字,请重新输入!");
                element.put("status", "n");
                log.debug("************ 新密码格式不符合要求! ************");
            }
            sendAjaxResponse(element);
        }catch(Exception e){
            e.printStackTrace();
            throw  e;
        }finally{
            log.debug("************ 检测新密码格式是否符合要求结束 ************");
        }
    }
    
    /**
     * 检测原授权码是否正确
     * @throws Exception
     */
    public void checkAuthorizepwd() throws Exception{
        try{
            log.debug("************ 检测原授权码开始 ************");
            String oldAuthorizepwd=getRequest().getParameter("param");
            String authorizepwd = MD5.mD5ofStr(oldAuthorizepwd);
            Map<String,Object> element = new LinkedHashMap<String,Object>();
            String auhol=getSessionUser().getAuthorizepwd();
            if(authorizepwd.equals(auhol)){
                element.put("info", "");
                element.put("status", "y");
                log.debug("************ 原授权码正确! ************");
            }else{
                element.put("info", "原授权码输入错误!");
                element.put("status", "n");
                log.debug("************ 原授权码错误! ************");
            }
            sendAjaxResponse(element);
        }catch(Exception e){
            e.printStackTrace();
            throw  e;
        }finally{
            log.debug("************ 检测原授权码结束 ************");
        }
    }
    
    /**
     * 跳转至个人设置视图
     * @return
     * @throws Exception
     */
    public String prePersonalSettings() throws Exception{
        try{
            log.debug("************** 进入个人设置页面开始 ********************");
            operatorUser = getSessionUser();
            return "settings";
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }finally{
            log.debug("************** 进入个人设置页面完成 ********************");
        }
    }
    
    /**
     * 个人设置
     * @return
     * @throws Exception
     */
    public String personalSettings() throws Exception{
        try{
            log.debug("************** 个人设置修改操作开始 ********************");
            OperatorUser operaUserSession = getSessionUser();
            String oldPass = MD5.mD5ofStr(operaUserSession.getLoginName()+getRequest().getParameter("oldPass"));
            String password = MD5.mD5ofStr(operaUserSession.getLoginName()+operatorUser.getPassword());
            if(oldPass.equals(getSessionUser().getPassword())){
                OperatorUser user = new OperatorUser();
                user.setId(getSessionUser().getId());
                user.setRoleId(getSessionUser().getRoleId());
                user.setOrganizationId(getSessionUser().getOrganizationId());
                user.setLoginName(getSessionUser().getLoginName());
                user.setRpOrganId(getSessionUser().getRpOrganId());
                //个人设置里要更新的字段
                user.setPassword(password);
                user.setAuthorizepwd(MD5.mD5ofStr(operatorUser.getAuthorizepwd()));
                user.setUserName(operatorUser.getUserName());
                user.setEmail(operatorUser.getEmail());
                int flag = operatorUserService.updateEntity(user);
                if(0 < flag){
                    log.debug("******************* 个人设置修改成功 ********************");
                    //修改SESSION里保存的信息
                    getSessionUser().setPassword(password);
                    getSessionUser().setUserName(user.getUserName());
                    getSessionUser().setEmail(user.getEmail());
                    return "settingsAction";
                }else{
                    log.debug("******************* 个人设置修改失败 ********************");
                    notice = "修改失败!";
                    return "globalGoback";
                }
            }else{
                log.debug("******************* 旧密码输入错误,个人设置修改失败 ********************");
                notice = "旧密码输入错误!!!";
                return "globalGoback";
            }
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }finally{
            log.debug("************** 个人设置修改操作完成 ********************");
        }
    }
    
    /**
     * 将所有用户的密码  md5 加密
     * @throws Exception
     */
    public String modifyAllUserPaswd()throws Exception{
        try{
            log.debug("************** 将所有用户的密码  md5 加密 ********************");
            operatorUser = new OperatorUser();
            operatorUserList = operatorUserService.searchEntityList(operatorUser);
            OperatorUser param = new OperatorUser();
            for(OperatorUser user : operatorUserList){
                param.setId(user.getId());
                param.setPassword(MD5.mD5ofStr(user.getLoginName()+user.getPassword()));
                operatorUserService.updateEntity(param);
            }
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }finally{
            log.debug("************** 将所有用户的密码  md5 加密 ********************");
        }
        return null;
    }
    
    public String searchRoleList() throws Exception{
        try {
            List<Role> roleList = new LinkedList<Role>();
            List<Role> rList = new ArrayList<Role>();
            Role role = new Role();
            String rpOrganId = getRequest().getParameter("rpOrganId");
            if(StringUtils.isBlank(rpOrganId)){
                notice = "非法操作!";
                return "globalGoback";
            }
            //登录用户所属机构
            Organization organ = new Organization();
            organ.setId(getSessionUser().getOrganizationId());
            organ = organizationService.searchEntity(organ);
            //权限机构
            Organization org = new Organization();
            org.setId(Long.parseLong(rpOrganId));
            org = organizationService.searchEntity(org);
            
            if(ADMIN_ROLEID.equals(getSessionUser().getRoleId())){//超级管理员登录
                if(GlobalConstant.ROOT_ORGANIZATIONID.equals(org.getId())){//顶级机构
                    role.setOrganizationId(org.getId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                }else if(1 == org.getType()){//OEM
                    //机构所属角色
                    role.setOrganizationId(org.getId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                    //特殊指定角色
                    role = new Role();
                    role.setAssignOrgId(org.getId());
                    role.setDeleted(0);
                    rList = roleService.searchEntityList(role);
                    if(null != rList && rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                    //OEM公有角色
                    role = new Role();
                    role.setType(2);
                    role.setDeleted(0);
                    rList = new ArrayList<Role>();
                    rList = roleService.searchEntityList(role);
                    if(null != rList || rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                }else if(1 < org.getType()){//代理商
                    //机构所属角色
                    role.setOrganizationId(org.getId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                    //特殊指定角色
                    role = new Role();
                    role.setAssignOrgId(org.getId());
                    role.setDeleted(0);
                    rList = roleService.searchEntityList(role);
                    if(null != rList && rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                    //代理商公有角色
                    role = new Role();
                    role.setType(3);
                    role.setDeleted(0);
                    rList = new ArrayList<Role>();
                    rList = roleService.searchEntityList(role);
                    if(null != rList || rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                }
            }else{
                if(1 == getSessionUser().getType() && 1 == organ.getType()){//OEM管理员登录
                    if(1 == org.getType()){//权限机构 OEM
                        //机构所属角色
                        role.setOrganizationId(org.getId());
                        role.setDeleted(0);
                        roleList = roleService.searchEntityList(role);
                        //特殊指定角色
                        role = new Role();
                        role.setAssignOrgId(org.getId());
                        role.setDeleted(0);
                        rList = roleService.searchEntityList(role);
                        if(null != rList && rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                        //OEM公有角色
                        role = new Role();
                        role.setType(2);
                        role.setDeleted(0);
                        rList = new ArrayList<Role>();
                        rList = roleService.searchEntityList(role);
                        if(null != rList || rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                    }else if(1 < org.getType()){//代理商
                        //机构所属角色
                        role.setOrganizationId(org.getId());
                        role.setDeleted(0);
                        roleList = roleService.searchEntityList(role);
                        //特殊指定角色
                        role = new Role();
                        role.setAssignOrgId(org.getId());
                        role.setDeleted(0);
                        rList = roleService.searchEntityList(role);
                        if(null != rList && rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                        //代理商公有角色
                        role = new Role();
                        role.setType(3);
                        role.setDeleted(0);
                        rList = new ArrayList<Role>();
                        rList = roleService.searchEntityList(role);
                        if(null != rList || rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                    }
                    
                }else if(1 == getSessionUser().getType() && 1 < organ.getType()){//代理商管理员
                    //机构所属角色
                    role.setOrganizationId(org.getId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                    //特殊指定角色
                    role = new Role();
                    role.setAssignOrgId(org.getId());
                    role.setDeleted(0);
                    rList = roleService.searchEntityList(role);
                    if(null != rList && rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                    //代理商公有角色
                    role = new Role();
                    role.setType(3);
                    role.setDeleted(0);
                    rList = new ArrayList<Role>();
                    rList = roleService.searchEntityList(role);
                    if(null != rList || rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                }else if(0 == getSessionUser().getType()){//普通用户
                    if(GlobalConstant.ROOT_ORGANIZATIONID.equals(getSessionUser().getOrganizationId())){//顶级机构用户登录
                        if(GlobalConstant.ROOT_ORGANIZATIONID.equals(org.getId())){//权限机构  顶级机构
                            //顶级机构角色
                            role.setOrganizationId(getSessionUser().getOrganizationId());
                            role.setIsOperatorRole(0);//不是超级管理员的角色
                            role.setDeleted(0);
                            roleList = roleService.searchEntityList(role);
                        }else if(1 == org.getType()){//权限机构 OEM
                            role.setOrganizationId(org.getId());
                            role.setDeleted(0);
                            roleList = roleService.searchEntityList(role);
                            //特殊指定角色
                            role = new Role();
                            role.setAssignOrgId(org.getId());
                            role.setDeleted(0);
                            rList = roleService.searchEntityList(role);
                            if(null != rList && rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                            //OEM公有角色
                            role = new Role();
                            role.setType(2);
                            role.setDeleted(0);
                            rList = new ArrayList<Role>();
                            rList = roleService.searchEntityList(role);
                            if(null != rList || rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                        }else if(1 < org.getType()){//权限机构 代理商
                            role.setOrganizationId(org.getId());
                            role.setDeleted(0);
                            roleList = roleService.searchEntityList(role);
                            //特殊指定角色
                            role = new Role();
                            role.setAssignOrgId(org.getId());
                            role.setDeleted(0);
                            rList = roleService.searchEntityList(role);
                            if(null != rList && rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                            //代理商公有角色
                            role = new Role();
                            role.setType(3);
                            role.setDeleted(0);
                            rList = new ArrayList<Role>();
                            rList = roleService.searchEntityList(role);
                            if(null != rList || rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                        }
                    }else if(1 == organ.getType()){//OEM普通用户登录
                        if(1 == org.getType()){//权限机构 OEM
                            role.setOrganizationId(org.getId());
                            role.setDeleted(0);
                            roleList = roleService.searchEntityList(role);
                            //特殊指定角色
                            role = new Role();
                            role.setAssignOrgId(org.getId());
                            role.setDeleted(0);
                            rList = roleService.searchEntityList(role);
                            if(null != rList && rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                            //OEM公有角色
                            role = new Role();
                            role.setType(2);
                            role.setDeleted(0);
                            rList = new ArrayList<Role>();
                            rList = roleService.searchEntityList(role);
                            if(null != rList || rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                        }else if(1 < org.getType()){//权限机构 代理商
                            role.setOrganizationId(org.getId());
                            role.setDeleted(0);
                            roleList = roleService.searchEntityList(role);
                            //特殊指定角色
                            role = new Role();
                            role.setAssignOrgId(org.getId());
                            role.setDeleted(0);
                            rList = roleService.searchEntityList(role);
                            if(null != rList && rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                            //代理商公有角色
                            role = new Role();
                            role.setType(3);
                            role.setDeleted(0);
                            rList = new ArrayList<Role>();
                            rList = roleService.searchEntityList(role);
                            if(null != rList || rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                        }
                    }else if(1 < organ.getType()){//代理商普通用户登录
                        role.setOrganizationId(org.getId());
                        role.setDeleted(0);
                        roleList = roleService.searchEntityList(role);
                        //特殊指定角色
                        role = new Role();
                        role.setAssignOrgId(org.getId());
                        role.setDeleted(0);
                        rList = roleService.searchEntityList(role);
                        if(null != rList && rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                        //代理商公有角色
                        role = new Role();
                        role.setType(3);
                        role.setDeleted(0);
                        rList = new ArrayList<Role>();
                        rList = roleService.searchEntityList(role);
                        if(null != rList || rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                    }
                }
            }
            
            StringBuilder sb = new StringBuilder("");
                
            for(Role r : roleList){
                sb.append(r.getId()).append(",").append(r.getName()).append("<-->");
            }
            
            this.sendAjaxResponse(sb.toString());
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
    
    public String searchRoleByOrgId() throws Exception{
        try{
            log.debug("***********************进入添加合作银行前 查询数据**********************");
            List<Role> roleList = new LinkedList<Role>();
            List<Role> rList = new ArrayList<Role>();
            Role role = new Role();
            String rpOrganId = getRequest().getParameter("rpOrganId");
            if(StringUtils.isBlank(rpOrganId)){
                notice = "非法操作!";
                return "globalGoback";
            }
            //登录用户所属机构
            Organization organ = new Organization();
            organ.setId(getSessionUser().getOrganizationId());
            organ = organizationService.searchEntity(organ);
            //权限机构
            Organization org = new Organization();
            org.setId(Long.parseLong(rpOrganId));
            org = organizationService.searchEntity(org);
            
            if(ADMIN_ROLEID.equals(getSessionUser().getRoleId())){//超级管理员登录
                if(GlobalConstant.ROOT_ORGANIZATIONID.equals(org.getId())){//顶级机构
                    role.setOrganizationId(org.getId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                }else if(1 == org.getType()){//OEM
                    //机构所属角色
                    role.setOrganizationId(org.getId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                    //特殊指定角色
                    role = new Role();
                    role.setAssignOrgId(org.getId());
                    role.setDeleted(0);
                    rList = roleService.searchEntityList(role);
                    if(null != rList && rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                    //OEM公有角色
                    role = new Role();
                    role.setType(2);
                    role.setDeleted(0);
                    rList = new ArrayList<Role>();
                    rList = roleService.searchEntityList(role);
                    if(null != rList || rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                }else if(1 < org.getType()){//代理商
                    //机构所属角色
                    role.setOrganizationId(org.getId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                    //特殊指定角色
                    role = new Role();
                    role.setAssignOrgId(org.getId());
                    role.setDeleted(0);
                    rList = roleService.searchEntityList(role);
                    if(null != rList && rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                    //代理商公有角色
                    role = new Role();
                    role.setType(3);
                    role.setDeleted(0);
                    rList = new ArrayList<Role>();
                    rList = roleService.searchEntityList(role);
                    if(null != rList || rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                }
            }else{
                if(1 == getSessionUser().getType() && 1 == organ.getType()){//OEM管理员登录
                    if(1 == org.getType()){//权限机构 OEM
                        //机构所属角色
                        role.setOrganizationId(org.getId());
                        role.setDeleted(0);
                        roleList = roleService.searchEntityList(role);
                        //特殊指定角色
                        role = new Role();
                        role.setAssignOrgId(org.getId());
                        role.setDeleted(0);
                        rList = roleService.searchEntityList(role);
                        if(null != rList && rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                        //OEM公有角色
                        role = new Role();
                        role.setType(2);
                        role.setDeleted(0);
                        rList = new ArrayList<Role>();
                        rList = roleService.searchEntityList(role);
                        if(null != rList || rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                    }else if(1 < org.getType()){//代理商
                        //机构所属角色
                        role.setOrganizationId(org.getId());
                        role.setDeleted(0);
                        roleList = roleService.searchEntityList(role);
                        //特殊指定角色
                        role = new Role();
                        role.setAssignOrgId(org.getId());
                        role.setDeleted(0);
                        rList = roleService.searchEntityList(role);
                        if(null != rList && rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                        //代理商公有角色
                        role = new Role();
                        role.setType(3);
                        role.setDeleted(0);
                        rList = new ArrayList<Role>();
                        rList = roleService.searchEntityList(role);
                        if(null != rList || rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                    }
                    
                }else if(1 == getSessionUser().getType() && 1 < organ.getType()){//代理商管理员
                    //机构所属角色
                    role.setOrganizationId(org.getId());
                    role.setDeleted(0);
                    roleList = roleService.searchEntityList(role);
                    //特殊指定角色
                    role = new Role();
                    role.setAssignOrgId(org.getId());
                    role.setDeleted(0);
                    rList = roleService.searchEntityList(role);
                    if(null != rList && rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                    //代理商公有角色
                    role = new Role();
                    role.setType(3);
                    role.setDeleted(0);
                    rList = new ArrayList<Role>();
                    rList = roleService.searchEntityList(role);
                    if(null != rList || rList.size() > 0){
                        roleList.addAll(0, rList);
                    }
                }else if(0 == getSessionUser().getType()){//普通用户
                    if(GlobalConstant.ROOT_ORGANIZATIONID.equals(getSessionUser().getOrganizationId())){//顶级机构用户登录
                        if(GlobalConstant.ROOT_ORGANIZATIONID.equals(org.getId())){//权限机构  顶级机构
                            //顶级机构角色
                            role.setOrganizationId(getSessionUser().getOrganizationId());
                            role.setIsOperatorRole(0);//不是超级管理员的角色
                            role.setDeleted(0);
                            roleList = roleService.searchEntityList(role);
                        }else if(1 == org.getType()){//权限机构 OEM
                            role.setOrganizationId(org.getId());
                            role.setDeleted(0);
                            roleList = roleService.searchEntityList(role);
                            //特殊指定角色
                            role = new Role();
                            role.setAssignOrgId(org.getId());
                            role.setDeleted(0);
                            rList = roleService.searchEntityList(role);
                            if(null != rList && rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                            //OEM公有角色
                            role = new Role();
                            role.setType(2);
                            role.setDeleted(0);
                            rList = new ArrayList<Role>();
                            rList = roleService.searchEntityList(role);
                            if(null != rList || rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                        }else if(1 < org.getType()){//权限机构 代理商
                            role.setOrganizationId(org.getId());
                            role.setDeleted(0);
                            roleList = roleService.searchEntityList(role);
                            //特殊指定角色
                            role = new Role();
                            role.setAssignOrgId(org.getId());
                            role.setDeleted(0);
                            rList = roleService.searchEntityList(role);
                            if(null != rList && rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                            //代理商公有角色
                            role = new Role();
                            role.setType(3);
                            role.setDeleted(0);
                            rList = new ArrayList<Role>();
                            rList = roleService.searchEntityList(role);
                            if(null != rList || rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                        }
                    }else if(1 == organ.getType()){//OEM普通用户登录
                        if(1 == org.getType()){//权限机构 OEM
                            role.setOrganizationId(org.getId());
                            role.setDeleted(0);
                            roleList = roleService.searchEntityList(role);
                            //特殊指定角色
                            role = new Role();
                            role.setAssignOrgId(org.getId());
                            role.setDeleted(0);
                            rList = roleService.searchEntityList(role);
                            if(null != rList && rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                            //OEM公有角色
                            role = new Role();
                            role.setType(2);
                            role.setDeleted(0);
                            rList = new ArrayList<Role>();
                            rList = roleService.searchEntityList(role);
                            if(null != rList || rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                        }else if(1 < org.getType()){//权限机构 代理商
                            role.setOrganizationId(org.getId());
                            role.setDeleted(0);
                            roleList = roleService.searchEntityList(role);
                            //特殊指定角色
                            role = new Role();
                            role.setAssignOrgId(org.getId());
                            role.setDeleted(0);
                            rList = roleService.searchEntityList(role);
                            if(null != rList && rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                            //代理商公有角色
                            role = new Role();
                            role.setType(3);
                            role.setDeleted(0);
                            rList = new ArrayList<Role>();
                            rList = roleService.searchEntityList(role);
                            if(null != rList || rList.size() > 0){
                                roleList.addAll(0, rList);
                            }
                        }
                    }else if(1 < organ.getType()){//代理商普通用户登录
                        role.setOrganizationId(org.getId());
                        role.setDeleted(0);
                        roleList = roleService.searchEntityList(role);
                        //特殊指定角色
                        role = new Role();
                        role.setAssignOrgId(org.getId());
                        role.setDeleted(0);
                        rList = roleService.searchEntityList(role);
                        if(null != rList && rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                        //代理商公有角色
                        role = new Role();
                        role.setType(3);
                        role.setDeleted(0);
                        rList = new ArrayList<Role>();
                        rList = roleService.searchEntityList(role);
                        if(null != rList || rList.size() > 0){
                            roleList.addAll(0, rList);
                        }
                    }
                }
            }
            
            StringBuilder sb = new StringBuilder("");
            
            for(Role r : roleList){
                sb.append(r.getId()).append(",").append(r.getName()).append("<-->");
            }
            
            this.sendAjaxResponse(sb.toString());
            return null;
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }
    
    }
    
    //---------------------set get start
    public OperatorUser getOperatorUser() {
        return operatorUser;
    }
    public void setOperatorUser(OperatorUser operatorUser) {
        this.operatorUser = operatorUser;
    }
    
    public List<OperatorUser> getOperatorUserList() {
        return operatorUserList;
    }
    public void setOperatorUserList(List<OperatorUser> operatorUserList) {
        this.operatorUserList = operatorUserList;
    }

    public List<Role> getRoleList() {
        return roleList;
    }
    public void setRoleList(List<Role> roleList) {
        this.roleList = roleList;
    }

    public List<Organization> getOrganizationList() {
        return organizationList;
    }
    public void setOrganizationList(List<Organization> organizationList) {
        this.organizationList = organizationList;
    }

    public Organization getOrganization() {
        return organization;
    }

    public void setOrganization(Organization organization) {
        this.organization = organization;
    }
    //---------------------set get end

}
技术图片

JEECG中的validform验证ajaxurl的使用方法

标签:etl   lsp   css   数据库   erro   批量删除   idt   ogg   algo   

原文地址:https://www.cnblogs.com/Jeely/p/12613220.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!