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的使用方法的更多相关文章

  1. ThinkPHP3.2中字段unique验证出错的解决方法

    protected $_validate=array( array('stu_id','','学号已存在',1,'unique',1), ) 当一次插入多条数据时: 在进行循环 使用create验证时 ...

  2. 防御CSRF的方法有哪些(一) HTTP 头中自定义属性并验证 CSRF跨站域请求伪造攻击

    CSRF (Cross Site Request Forgery, 跨站域请求伪造)是一种网络的攻击方式,该攻击可以在受害者毫不知情的情况下以受害者名义伪造请求发送给受攻击站点,从而在并未授权的情况下 ...

  3. jeecg中vaildfrom的复杂的表单校验

    简介 jeecg生成的页面都是使用validfrom组件来确保数据的完整性和准确性. 凡要验证格式的元素均需绑定datatype属性,datatype可选值内置有10类,用来指定不同的验证格式. 如果 ...

  4. 改造一下jeecg中的部门树

    假装有需求 关于 jeecg 提供的部门树,相信很多小伙伴都已经用过了,今天假装有那么一个需求 "部门树弹窗选择默认展开下级部门",带着这个需求再次去探索一下吧. 一.改造之前的部 ...

  5. ASP.NET MVC5中的Model验证

    Model验证是ASP.NET MVC中的重要部分,它主要用于判断输入的数据类型及值是否符合我们设定的规则,这篇文章就介绍下ASP.NET MVC中Model验证的几种方式. 后台验证 DataAnn ...

  6. 用Retrofit发送请求中添加身份验证

    用Retrofit发送请求中添加身份验证====================在安卓应用开发中, retrofit可以极大的方便发送http网络请求,不管是GET, POST, 还是PUT, DEL ...

  7. Azure Service Bus 中的身份验证方式 Shared Access Signature

    var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...

  8. WPF中的数据验证

    数据验证 WPF的Binding使得数据能够在数据源和目标之间流通,在数据流通的中间,便能够对数据做一些处理. 数据转换和数据验证便是在数据从源到目标 or 从目标到源 的时候对数据的验证和转换. V ...

  9. thinkphp自动验证中的静态验证和动态验证和批量验证

    1.静态定义 在模型类里面预先定义好该模型的自动验证规则,我们称为静态定义. 举例说明,我们在模型类里面定义了$_validate属性如下: class UserModel extends Model ...

随机推荐

  1. 迭代dict的key和value

    我们了解了如何迭代 dict 的key和value,那么,在一个 for 循环中,能否同时迭代 key和value?答案是肯定的. 首先,我们看看 dict 对象的 items() 方法返回的值: & ...

  2. arcgispro字段计算器

    使用python语法 在python中没有类似sub()或者subString()的方法,但是字符串的截取操作却是更加简单. 只需要把字符串看作是一个字符数组,截取子串非常方便. 多余的话就不啰嗦了, ...

  3. C++类静态数据成员与类静态成员函数

    from:://http://blog.csdn.net/taina2008/article/details/1684834 把类中的函数都定义成静态函数,这样相当于在编译时就分配了空间,这样不需要实 ...

  4. python测试开发django-11.模型models详解

    前言 Django 模型是与数据库相关的,与数据库相关的代码一般写在 models.py 中,Django 支持 sqlite3, MySQL, PostgreSQL等数据库 只需要在settings ...

  5. lemon OA 我长时间经历的第一个开源项目

    对于原作者来说, 他长时间运营了一个项目,lemon OA .目前,八百多star.在运营这个项目的过程中,我想说,他成了activiti 目前国内比较牛逼的几个人.还有 spring securit ...

  6. 动态规划经典问题Java实现

    动态规划问题Java实现 如果我们有面值为1元.3元和5元的硬币若干枚,如何用最少的硬币凑够11元? public class DPProblem { public static void main( ...

  7. MyBatis入参类型是List时判断非空

    一.参数list时,先判断是否为空,否则会报错. 二.mybatis ${}与#{}的区别 简单来说#{} 解析的是占位符?可以防止SQL注入, 比如打印出来的语句 select * from tab ...

  8. 哥谭第四季/全集Gotham迅雷下载

    <哥谭>(Gotham)第三季刚刚结束,第四季首集的集名就公布了.<Pax Penguina>这个集名在拉丁语中意味着「Pax Romana」,也就是「罗马式的和平」(Roma ...

  9. Android 类加载原理 和热修复——深入浅出原理与实现

    一.简述 热修复无疑是这2年较火的新技术,是作为安卓工程师必学的技能之一.在热修复出现之前,一个已经上线的app中如果出现了bug,即使是一个非常小的bug,不及时更新的话有可能存在风险,若要及时更新 ...

  10. ExtJS 教程目录

    今天我创建了一个小组,取名ExtJS互助团,欢迎朋友们加入!遇到问题需要帮助的时候别忘了ExtJS互助团!希望更多的园友加入进来,帮别人,也是帮自己!组内讨论不限于ExtJS,还包括FineUI.Ex ...