📄 rightdelegate.java
字号:
Response resp = getDelegate().execute(req);
DelegateUtil.setIState(state, resp);
return(PageSupport)resp.getValue("roles");
} catch (Exception e) {
DelegateUtil.handleException(e, "findOtherRoleByUser", state);
return null;
}
}
public String saveRole(Role role, IState state) {
if (DelegateUtil.isNullParam(role, "role", state)) {
return null;
}
Request req = new Request();
req.setServiceName(ServiceConsts.SaveRoleProcessor);
req.setValue("role", role);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setIState(state, resp);
return ((String) resp.getValue("result"));
} catch (Exception e) {
DelegateUtil.handleException(e, "saveRole", state);
return null;
}
}
/**
* 删除角色,同时删除该角色对应的权限关系.deletePermissionByRoleId
*/
public void deleteRoleById(String roleId, IState state) {
if (DelegateUtil.isNullParam(roleId, "roleId", state)) {
return;
}
Request req = new Request();
req.setServiceName(ServiceConsts.DeleteRoleByIdProcessor);
req.setValue("roleId",roleId);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setIState(state, resp);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteRoleById", state);
}
}
public void deleteRole(Role role, IState state) {
if (DelegateUtil.isNullParam(role, "role", state)) {
return;
}
Request req = new Request();
req.setServiceName(ServiceConsts.DeleteRoleProcessor);
req.setValue("role", role);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setIState(state, resp);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteRole", state);
}
}
public void updateRole(Role role, IState state) {
if (DelegateUtil.isNullParam(role, "role", state)) {
return;
}
Request req = new Request();
req.setServiceName(ServiceConsts.UpdateRoleProcessor);
req.setValue("role", role);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setIState(state, resp);
} catch (Exception e) {
DelegateUtil.handleException(e, "updateRole", state);
}
}
public void updateUser(User user, IState state) {
try {
getDelegate().execute("user", user,
ServiceConsts.UpdateUserProcessor, state);
} catch (Exception e) {
DelegateUtil.handleException(e, "updateUser", state);
}
}
public PageSupport findAllRole(CriteriaQuery cq, IState state) {
if (DelegateUtil.isNullParam(cq, "CriteriaQuery", state)) {
return null;
}
Request req = new Request();
req.setServiceName(ServiceConsts.FindAllRoleProcessor);
req.setValue("CriteriaQuery", cq);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setIState(state, resp);
return (PageSupport) (resp.getValue("PageSupport"));
} catch (Exception e) {
DelegateUtil.handleException(e, "findAllRole", state);
}
return new PageSupport();
}
public Role findRoleById(String id, IState state) {
if (DelegateUtil.isNullParam(id, "id", state)) {
return null;
}
Request req = new Request();
req.setServiceName(ServiceConsts.FindRoleByIdProcessor);
req.setValue("id", id);
try {
Response resp = getDelegate().execute(req);
Role role = (Role) resp.getValue("role");
DelegateUtil.setIState(state, resp);
return role;
} catch (Exception e) {
DelegateUtil.handleException(e, "findRoleById", state);
return null;
}
}
public List findFunctionByRoleId(String roleId,IState state){
if (DelegateUtil.isNullParam(roleId, "roleId", state)) {
return null;
}
Request req = new Request();
req.setServiceName(ServiceConsts.FindFunctionByRoleIdProcessor);
req.setValue("roleId", roleId);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setIState(state, resp);
return(List)resp.getValue("functions");
} catch (Exception e) {
DelegateUtil.handleException(e, "findFunctionByRoleId", state);
return null;
}
}
public List findOtherFunctionByRoleId(String roleId,IState state){
if (DelegateUtil.isNullParam(roleId, "roleId", state)) {
return null;
}
Request req = new Request();
req.setServiceName(ServiceConsts.FindOtherFunctionByRoleIdProcessor);
req.setValue("roleId", roleId);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setIState(state, resp);
return(List)resp.getValue("functions");
} catch (Exception e) {
DelegateUtil.handleException(e, "findFunctionByRoleId", state);
throw new ClientException(e,"findFunctionByRoleId error in delegate!");
}
}
public PageSupport findOtherFunctionByHql(HqlQuery hqlQuery,String roleId,IState state){
if (DelegateUtil.isNullParam(hqlQuery, "hqlQuery", state)) {
return null;
}
Request req = new Request();
req.setServiceName(ServiceConsts.FindOtherFunctionByHqlProcessor);
req.setValue("hqlQuery", hqlQuery);
req.setValue("roleId", roleId);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setIState(state, resp);
return(PageSupport)resp.getValue("functions");
} catch (Exception e) {
DelegateUtil.handleException(e, "findOtherFunctionByHql", state);
throw new ClientException(e,"findOtherFunctionByHql error in delegate!");
}
}
public void deleteFunctionsFromRole(List permissions, IState state) {
try {
getDelegate().execute("permissions", permissions,
ServiceConsts.DeleteFunctionsFromRoleProcessor, state);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteFunctionsFromRole", state);
}
}
public void deleteRoleFromUser(List userRoles, IState state) {
try {
getDelegate().execute("userRoles", userRoles,
ServiceConsts.DeleteRoleFromUserProcessor, state);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteRoleFromUser", state);
}
}
public User findUserById(String userId, IState state) {
try {
return (User)getDelegate().execute("userId", userId,
ServiceConsts.FindUserByIdProcessor,"user", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "findUserById", state);
return null;
}
}
public void saveRoleToUser(UserRole userRole, IState state) {
try {
if(!AppUtils.isBlank(userRole)&&!AppUtils.isBlank(userRole.getId().getUserId())&&!AppUtils.isBlank(userRole.getId().getRoleId()))
{
List userRoles=new ArrayList();
userRoles.add(userRole);
saveRolesToUser(userRoles,state);
}else{
throw new JCFException(state.getErrCode(),"saveRoleToUser userRole is not validated!");
}
} catch (Exception e) {
DelegateUtil.handleException(e, "saveRoleToUser", state);
}
}
public void updateUserPassowrd(String userId, String password, IState state) {
if (DelegateUtil.isNullParam(userId, "userId", state)||DelegateUtil.isNullParam(password, "password", state)) {
return;
}
Request req = new Request();
req.setServiceName(ServiceConsts.UpdateUserPassowrdProcessor);
req.setValue("userId", userId);
req.setValue("password", password);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setIState(state, resp);
} catch (Exception e) {
DelegateUtil.handleException(e, "updateUserPassowrd", state);
}
}
public void deletePermissionByFunctionId(String functionId, IState state) {
try {
getDelegate().execute("functionId", functionId,
ServiceConsts.DeletePermissionByFunctionIdProcessor, state);
} catch (Exception e) {
DelegateUtil.handleException(e, "deletePermissionByFunctionId", state);
}
}
public void deleteUserRoleByUserId(String userId, IState state) {
try {
getDelegate().execute("userId", userId,
ServiceConsts.DeleteUserRoleByUserIdProcessor, state);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteUserRoleByUserId", state);
}
}
public void deleteRoleFromUser(UserRole userRole, IState state) {
if(AppUtils.isBlank(userRole))
throw new ClientException(ErrorCode.PARAMETER_ERROR,"deleteRoleFromUser");
List userRoles=new ArrayList();
userRoles.add(userRole);
deleteRoleFromUser(userRoles,state);
}
public void deleteUserRoleByRoleId(String roleId, IState state) {
try {
getDelegate().execute("roleId", roleId,
ServiceConsts.DeleteUserRoleByRoleIdProcessor, state);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteUserRoleByRoleId", state);
}
}
public void deletePermissionByRoleId(String roleId, IState state) {
try {
getDelegate().execute("roleId", roleId,
ServiceConsts.DeletePermissionByRoleIdProcessor, state);
} catch (Exception e) {
DelegateUtil.handleException(e, "deletePermissionByRoleId", state);
throw new ClientException(e,"deletePermissionByRoleId",state.getErrCode());
}
}
public void saveRolesToUser(List userRoles, IState state){
try {
getDelegate().execute("userRoles", userRoles,
ServiceConsts.SaveRolesToUserProcessor, state);
} catch (Exception e) {
DelegateUtil.handleException(e, "saveRolesToUser", state);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -