use of com.netsteadfast.greenstep.po.hbm.TbRolePermission in project bamboobsc by billchen198318.
the class GreenStepBaseAuthorizingLdapRealm method getSimpleAuthorizationInfo.
private SimpleAuthorizationInfo getSimpleAuthorizationInfo(String username) throws Exception {
Map<String, Object> params = new HashMap<String, Object>();
params.put("account", username);
List<TbUserRole> roleList = userRoleService.findListByParams(params);
if (roleList == null) {
return null;
}
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
for (TbUserRole userRole : roleList) {
info.addRole(userRole.getRole());
params.clear();
params.put("role", userRole.getRole());
List<TbRolePermission> rolePermissionList = rolePermissionService.findListByParams(params);
if (rolePermissionList == null) {
continue;
}
for (TbRolePermission rolePermission : rolePermissionList) {
info.addStringPermission(rolePermission.getPermission());
}
}
return info;
}
use of com.netsteadfast.greenstep.po.hbm.TbRolePermission in project bamboobsc by billchen198318.
the class RoleLogicServiceImpl method copyAsNew.
/**
* 拷備一份role
*
* @param fromRoleOid
* @param role
* @return
* @throws ServiceException
* @throws Exception
*/
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<RoleVO> copyAsNew(String fromRoleOid, RoleVO role) throws ServiceException, Exception {
if (role == null || super.isBlank(role.getRole()) || super.isBlank(fromRoleOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
super.setStringValueMaxLength(role, "description", MAX_DESCRIPTION_LENGTH);
DefaultResult<RoleVO> result = this.roleService.saveObject(role);
RoleVO oldRole = new RoleVO();
oldRole.setOid(fromRoleOid);
DefaultResult<RoleVO> fromResult = this.roleService.findObjectByOid(oldRole);
if (fromResult.getValue() == null) {
throw new ServiceException(fromResult.getSystemMessage().getValue());
}
oldRole = fromResult.getValue();
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("role", oldRole.getRole());
List<TbRolePermission> permissions = this.rolePermissionService.findListByParams(paramMap);
for (int i = 0; permissions != null && i < permissions.size(); i++) {
RolePermissionVO permission = new RolePermissionVO();
this.rolePermissionService.fillToValueObject(permission, permissions.get(i));
permission.setOid(null);
permission.setRole(result.getValue().getRole());
this.rolePermissionService.saveObject(permission);
}
// 選單menu role 也copy一份
List<TbSysMenuRole> menuRoles = this.sysMenuRoleService.findListByParams(paramMap);
for (int i = 0; menuRoles != null && i < menuRoles.size(); i++) {
SysMenuRoleVO menuRole = new SysMenuRoleVO();
this.sysMenuRoleService.fillToValueObject(menuRole, menuRoles.get(i));
menuRole.setOid(null);
menuRole.setRole(result.getValue().getRole());
this.sysMenuRoleService.saveObject(menuRole);
}
return result;
}
use of com.netsteadfast.greenstep.po.hbm.TbRolePermission in project bamboobsc by billchen198318.
the class GreenStepBaseAuthorizingRealm method getSimpleAuthorizationInfo.
private SimpleAuthorizationInfo getSimpleAuthorizationInfo(String username) throws Exception {
Map<String, Object> params = new HashMap<String, Object>();
params.put("account", username);
List<TbUserRole> roleList = userRoleService.findListByParams(params);
if (roleList == null) {
return null;
}
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
for (TbUserRole userRole : roleList) {
info.addRole(userRole.getRole());
params.clear();
params.put("role", userRole.getRole());
List<TbRolePermission> rolePermissionList = rolePermissionService.findListByParams(params);
if (rolePermissionList == null) {
continue;
}
for (TbRolePermission rolePermission : rolePermissionList) {
info.addStringPermission(rolePermission.getPermission());
}
}
return info;
}
Aggregations