use of com.netsteadfast.greenstep.vo.UserRoleVO 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.UserRoleVO in project bamboobsc by billchen198318.
the class EmployeeLogicServiceImpl method create.
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<EmployeeVO> create(EmployeeVO employee, List<String> organizationOid) throws ServiceException, Exception {
if (employee == null || super.isBlank(employee.getEmpId())) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("empId", employee.getEmpId());
if (this.getEmployeeService().countByParams(params) > 0) {
throw new ServiceException("Please change another Id!");
}
AccountVO account = this.tranAccount(employee);
if (this.isAdministrator(account.getAccount())) {
throw new ServiceException("Please change another Account!");
}
DefaultResult<AccountVO> mResult = this.getAccountService().saveObject(account);
if (mResult.getValue() == null) {
throw new ServiceException(mResult.getSystemMessage().getValue());
}
DefaultResult<EmployeeVO> result = this.getEmployeeService().saveObject(employee);
employee = result.getValue();
this.createEmployeeOrganization(employee, organizationOid);
// create default role
UserRoleVO userRole = new UserRoleVO();
userRole.setAccount(employee.getAccount());
userRole.setRole(this.roleLogicService.getDefaultUserRole());
userRole.setDescription(employee.getAccount() + " `s role!");
this.getUserRoleService().saveObject(userRole);
this.createHierarchy(employee, BscConstants.EMPLOYEE_HIER_ZERO_OID);
return result;
}
Aggregations