use of com.netsteadfast.greenstep.vo.RoleVO in project bamboobsc by billchen198318.
the class RoleLogicServiceImpl method findForAccountRoleEnableAndAll.
/**
* 找出全部的role與某帳戶下的role
*
* map 中的 key
* enable - 帳戶下的role
* all - 所有role
*
* @param accountOid
* @return
* @throws ServiceException
* @throws Exception
*/
@Override
public Map<String, List<RoleVO>> findForAccountRoleEnableAndAll(String accountOid) throws ServiceException, Exception {
if (super.isBlank(accountOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
AccountVO account = new AccountVO();
account.setOid(accountOid);
DefaultResult<AccountVO> aResult = this.accountService.findObjectByOid(account);
if (aResult.getValue() == null) {
throw new ServiceException(aResult.getSystemMessage().getValue());
}
account = aResult.getValue();
Map<String, List<RoleVO>> roleMap = new HashMap<String, List<RoleVO>>();
List<RoleVO> enableRole = this.roleService.findForAccount(account.getAccount());
List<RoleVO> allRole = this.roleService.findForAll();
roleMap.put("enable", enableRole);
roleMap.put("all", allRole);
return roleMap;
}
use of com.netsteadfast.greenstep.vo.RoleVO in project bamboobsc by billchen198318.
the class RoleLogicServiceImpl method updateUserRole.
/**
* 更新帳戶的role
*
* @param accountOid
* @param roles
* @return
* @throws ServiceException
* @throws Exception
*/
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> updateUserRole(String accountOid, List<String> roles) throws ServiceException, Exception {
if (super.isBlank(accountOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
AccountVO account = new AccountVO();
account.setOid(accountOid);
DefaultResult<AccountVO> aResult = this.accountService.findObjectByOid(account);
if (aResult.getValue() == null) {
throw new ServiceException(aResult.getSystemMessage().getValue());
}
account = aResult.getValue();
DefaultResult<Boolean> result = new DefaultResult<Boolean>();
result.setValue(false);
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_FAIL)));
this.deleteUserRoleByAccount(account);
for (int i = 0; roles != null && i < roles.size(); i++) {
String roleOid = roles.get(i).trim();
if (super.isBlank(roleOid)) {
continue;
}
RoleVO role = new RoleVO();
role.setOid(roleOid);
DefaultResult<RoleVO> rResult = this.roleService.findObjectByOid(role);
if (rResult.getValue() == null) {
throw new ServiceException(rResult.getSystemMessage().getValue());
}
role = rResult.getValue();
UserRoleVO userRole = new UserRoleVO();
userRole.setAccount(account.getAccount());
userRole.setRole(role.getRole());
userRole.setDescription("");
DefaultResult<UserRoleVO> urResult = this.userRoleService.saveObject(userRole);
if (urResult.getValue() == null) {
throw new ServiceException(urResult.getSystemMessage().getValue());
}
}
result.setValue(true);
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
return result;
}
use of com.netsteadfast.greenstep.vo.RoleVO in project bamboobsc by billchen198318.
the class RoleLogicServiceImpl method createPermission.
/**
* 產生 TB_ROLE_PERMISSION 資料
*
* @param permission
* @param roleOid
* @return
* @throws ServiceException
* @throws Exception
*/
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<RolePermissionVO> createPermission(RolePermissionVO permission, String roleOid) throws ServiceException, Exception {
if (super.isBlank(roleOid) || permission == null || super.isBlank(permission.getPermission())) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
RoleVO role = new RoleVO();
role.setOid(roleOid);
DefaultResult<RoleVO> rResult = this.roleService.findObjectByOid(role);
if (rResult.getValue() == null) {
throw new ServiceException(rResult.getSystemMessage().getValue());
}
role = rResult.getValue();
if (Constants.SUPER_ROLE_ADMIN.equals(role.getRole()) || Constants.SUPER_ROLE_ALL.equals(role.getRole())) {
throw new ServiceException("Administrator or super role no need to set permission!");
}
permission.setRole(role.getRole());
if (super.defaultString(permission.getDescription()).length() > MAX_DESCRIPTION_LENGTH) {
permission.setDescription(permission.getDescription().substring(0, MAX_DESCRIPTION_LENGTH));
}
return this.rolePermissionService.saveObject(permission);
}
use of com.netsteadfast.greenstep.vo.RoleVO in project bamboobsc by billchen198318.
the class RoleSaveOrUpdateAction method saveCopyAsNew.
private void saveCopyAsNew() throws ControllerException, AuthorityException, ServiceException, Exception {
this.checkFields();
RoleVO role = new RoleVO();
this.transformFields2ValueObject(role, new String[] { "role", "description" });
DefaultResult<RoleVO> result = this.roleLogicService.copyAsNew(this.getFields().get("fromRoleOid"), role);
this.message = result.getSystemMessage().getValue();
if (result.getValue() == null) {
return;
}
this.success = IS_YES;
}
use of com.netsteadfast.greenstep.vo.RoleVO in project bamboobsc by billchen198318.
the class RoleSaveOrUpdateAction method save.
/**
* 建立 TB_ROLE 資料
*
* @throws ControllerException
* @throws AuthorityException
* @throws ServiceException
* @throws Exception
*/
private void save() throws ControllerException, AuthorityException, ServiceException, Exception {
this.checkFields();
RoleVO role = new RoleVO();
this.transformFields2ValueObject(role, new String[] { "role", "description" });
DefaultResult<RoleVO> result = this.roleLogicService.create(role);
this.message = result.getSystemMessage().getValue();
if (result.getValue() == null) {
return;
}
this.success = IS_YES;
}
Aggregations