JEECG中的validform验证ajaxurl的使用方法
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="" 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="">
- <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("");
- }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();
- //查询出所有的 关于你所在后台操作员的用户列表
- 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(), ); //计算起始和终止的条数
- 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();
- 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(,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 > ){
- 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 > ){
- 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();
- roleList = roleService.searchEntityList(role);
- }else{
- if( == org.getType() && == operatorUser.getType()){//OEM管理员
- //登录用户所属机构角色
- role.setOrganizationId(operatorUser.getOrganizationId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //OEM公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( < org.getType() && == operatorUser.getType()){//代理商管理员
- //登录用户所属机构角色
- role.setOrganizationId(operatorUser.getOrganizationId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( == operatorUser.getType()){
- if(GlobalConstant.ROOT_ORGANIZATIONID.equals(operatorUser.getOrganizationId())){//顶层用户登录
- //顶级机构角色
- role.setOrganizationId(operatorUser.getOrganizationId());
- role.setIsOperatorRole();//不是超级管理员的角色
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- }else if( == org.getType()){//OEM用户登录
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //OEM公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( < org.getType()){//代理商用户登录
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, 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();//普通用户
- operatorUser.setPassword(MD5.mD5ofStr(operatorUser.getLoginName()+operatorUser.getPassword()));
- operatorUser.setAuthorizepwd(MD5.mD5ofStr(operatorUser.getAuthorizepwd()));
- //添加
- long id = operatorUserService.insertEntity(operatorUser);
- if(id > ){//添加成功返回列表
- 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( == params.getType().intValue()){//OEM
- operatorUser.setRoleId(GlobalConstant.OEM_ROLEID);
- }else if( == params.getType().intValue()){//省代
- operatorUser.setRoleId(GlobalConstant.AGENT_ROLEID);//暂时没有定义
- }else if( == params.getType().intValue()){//市代
- operatorUser.setRoleId(GlobalConstant.AGENT_ROLEID);//暂时没有定义
- }else{//其他代理
- operatorUser.setRoleId(GlobalConstant.AGENT_ROLEID);
- }
- operatorUser.setType();
- 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();
- roleList = roleService.searchEntityList(role);
- }else if( == org.getType()){//OEM
- //机构所属角色
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //OEM公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( < org.getType()){//代理商
- //机构所属角色
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }
- }else{
- if( == org.getType() && == getSessionUser().getType()){//OEM管理员
- //登录用户所属机构角色
- role.setOrganizationId(getSessionUser().getOrganizationId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //OEM公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( < org.getType() && == getSessionUser().getType()){//代理商管理员
- //登录用户所属机构角色
- role.setOrganizationId(getSessionUser().getOrganizationId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( == getSessionUser().getType()){
- if(GlobalConstant.ROOT_ORGANIZATIONID.equals(getSessionUser().getOrganizationId())){//顶层用户登录
- //顶级机构角色
- role.setOrganizationId(getSessionUser().getOrganizationId());
- role.setIsOperatorRole();//不是超级管理员的角色
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- }else if( == org.getType()){//OEM用户登录
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //OEM公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( < org.getType()){//代理商用户登录
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, 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 = ;
- 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 > ){//修改成功 返回列表
- OperatorUser param = new OperatorUser();
- param.setId(operatorUser.getId());
- operatorUser = operatorUserService.searchEntity(param);
- if(null != operatorUser.getType() && == 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();
- 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 > ){
- 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( < 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();
- roleList = roleService.searchEntityList(role);
- }else if( == org.getType()){//OEM
- //机构所属角色
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //OEM公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( < org.getType()){//代理商
- //机构所属角色
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }
- }else{
- if( == getSessionUser().getType() && == organ.getType()){//OEM管理员登录
- if( == org.getType()){//权限机构 OEM
- //机构所属角色
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //OEM公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( < org.getType()){//代理商
- //机构所属角色
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }
- }else if( == getSessionUser().getType() && < organ.getType()){//代理商管理员
- //机构所属角色
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( == getSessionUser().getType()){//普通用户
- if(GlobalConstant.ROOT_ORGANIZATIONID.equals(getSessionUser().getOrganizationId())){//顶级机构用户登录
- if(GlobalConstant.ROOT_ORGANIZATIONID.equals(org.getId())){//权限机构 顶级机构
- //顶级机构角色
- role.setOrganizationId(getSessionUser().getOrganizationId());
- role.setIsOperatorRole();//不是超级管理员的角色
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- }else if( == org.getType()){//权限机构 OEM
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //OEM公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( < org.getType()){//权限机构 代理商
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }
- }else if( == organ.getType()){//OEM普通用户登录
- if( == org.getType()){//权限机构 OEM
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //OEM公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( < org.getType()){//权限机构 代理商
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }
- }else if( < organ.getType()){//代理商普通用户登录
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, 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();
- roleList = roleService.searchEntityList(role);
- }else if( == org.getType()){//OEM
- //机构所属角色
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //OEM公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( < org.getType()){//代理商
- //机构所属角色
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }
- }else{
- if( == getSessionUser().getType() && == organ.getType()){//OEM管理员登录
- if( == org.getType()){//权限机构 OEM
- //机构所属角色
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //OEM公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( < org.getType()){//代理商
- //机构所属角色
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }
- }else if( == getSessionUser().getType() && < organ.getType()){//代理商管理员
- //机构所属角色
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( == getSessionUser().getType()){//普通用户
- if(GlobalConstant.ROOT_ORGANIZATIONID.equals(getSessionUser().getOrganizationId())){//顶级机构用户登录
- if(GlobalConstant.ROOT_ORGANIZATIONID.equals(org.getId())){//权限机构 顶级机构
- //顶级机构角色
- role.setOrganizationId(getSessionUser().getOrganizationId());
- role.setIsOperatorRole();//不是超级管理员的角色
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- }else if( == org.getType()){//权限机构 OEM
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //OEM公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( < org.getType()){//权限机构 代理商
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }
- }else if( == organ.getType()){//OEM普通用户登录
- if( == org.getType()){//权限机构 OEM
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //OEM公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }else if( < org.getType()){//权限机构 代理商
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, rList);
- }
- }
- }else if( < organ.getType()){//代理商普通用户登录
- role.setOrganizationId(org.getId());
- role.setDeleted();
- roleList = roleService.searchEntityList(role);
- //特殊指定角色
- role = new Role();
- role.setAssignOrgId(org.getId());
- role.setDeleted();
- rList = roleService.searchEntityList(role);
- if(null != rList && rList.size() > ){
- roleList.addAll(, rList);
- }
- //代理商公有角色
- role = new Role();
- role.setType();
- role.setDeleted();
- rList = new ArrayList<Role>();
- rList = roleService.searchEntityList(role);
- if(null != rList || rList.size() > ){
- roleList.addAll(, 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的使用方法的更多相关文章
- ThinkPHP3.2中字段unique验证出错的解决方法
protected $_validate=array( array('stu_id','','学号已存在',1,'unique',1), ) 当一次插入多条数据时: 在进行循环 使用create验证时 ...
- 防御CSRF的方法有哪些(一) HTTP 头中自定义属性并验证 CSRF跨站域请求伪造攻击
CSRF (Cross Site Request Forgery, 跨站域请求伪造)是一种网络的攻击方式,该攻击可以在受害者毫不知情的情况下以受害者名义伪造请求发送给受攻击站点,从而在并未授权的情况下 ...
- jeecg中vaildfrom的复杂的表单校验
简介 jeecg生成的页面都是使用validfrom组件来确保数据的完整性和准确性. 凡要验证格式的元素均需绑定datatype属性,datatype可选值内置有10类,用来指定不同的验证格式. 如果 ...
- 改造一下jeecg中的部门树
假装有需求 关于 jeecg 提供的部门树,相信很多小伙伴都已经用过了,今天假装有那么一个需求 "部门树弹窗选择默认展开下级部门",带着这个需求再次去探索一下吧. 一.改造之前的部 ...
- ASP.NET MVC5中的Model验证
Model验证是ASP.NET MVC中的重要部分,它主要用于判断输入的数据类型及值是否符合我们设定的规则,这篇文章就介绍下ASP.NET MVC中Model验证的几种方式. 后台验证 DataAnn ...
- 用Retrofit发送请求中添加身份验证
用Retrofit发送请求中添加身份验证====================在安卓应用开发中, retrofit可以极大的方便发送http网络请求,不管是GET, POST, 还是PUT, DEL ...
- Azure Service Bus 中的身份验证方式 Shared Access Signature
var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...
- WPF中的数据验证
数据验证 WPF的Binding使得数据能够在数据源和目标之间流通,在数据流通的中间,便能够对数据做一些处理. 数据转换和数据验证便是在数据从源到目标 or 从目标到源 的时候对数据的验证和转换. V ...
- thinkphp自动验证中的静态验证和动态验证和批量验证
1.静态定义 在模型类里面预先定义好该模型的自动验证规则,我们称为静态定义. 举例说明,我们在模型类里面定义了$_validate属性如下: class UserModel extends Model ...
随机推荐
- 点击cell动态修改高度动画
点击cell动态修改高度动画 效果 源码 https://github.com/YouXianMing/Animations // // TapCellAnimationController.m // ...
- Asp.Net Mvc表单提交之List集合
一.说明 1.Asp.Net Mvc中Action的参数可以自动接收和反序列化form表单的值, 2.对于name=value类型,只要Action参数的变量名和input的name相同就行,不区分大 ...
- Caffe SSD AttributeError: 'module' object has no attribute 'LabelMap'
caffe ssd 错误描述: AttributeError: 'module' object has no attribute 'LabelMap' SSD from caffe.proto imp ...
- MySql清空所有表数据【慎用】
CREATE PROCEDURE `up_truncate_all_table`() BEGIN ; ); DECLARE cur1 CURSOR FOR SELECT table_name from ...
- golang的日志系统log和glog
go语言有一个标准库,log,提供了最基本的日志功能,但是没有什么高级的功能,如果需要高级的特性,可以选择glog或log4go. 参考:https://cloud.tencent.com/devel ...
- Grizzly HTTP CoDec ThreadCache 浅析
Grizzly 的 HTTP CoDec 实现方法更 Netty 的 CoDec 完全不同, 他们思想上的差异主要在于: 1. 解码方式 Grizzly 使用流式解码, 它的HttpHeader对象内 ...
- DP思路
在这里记录一些在大神们的博客,以及自己做过的一些DP的神奇思路吧 1.2015/04 NEUQ 月赛 转自:http://zyfzyf.is-programmer.com/posts/89993.h ...
- 《UNIX环境高级编程》笔记--环境变量
ISO C定义了一个函数getenv,可以用其取环境变量值. #include <stdlib.h> char* getenv(const char* name); //返回与name关联 ...
- hdu4753 Fishhead’s Little Game 状态压缩,总和一定的博弈
此题和UVA 10891 Game of Sum 总和一定的博弈,区间dp是一个道理,就是预处理麻烦 这是南京网络赛的一题,一直没做,今天做了,虽然时间有点长,但是1ac,这几乎是南京现场赛的最后一道 ...
- ZMQ和MessagePack的简单使用(转)
近段日子在做一个比较复杂的项目,其中用到了开源软件ZMQ和MessagePack.ZMQ对底层网络通信进行了封装,是一个消息处理队列库, 使用起来非常方便.MessagePack是一个基于二进制的对象 ...