use of com.netsteadfast.greenstep.vo.AccountVO in project bamboobsc by billchen198318.
the class EmployeeLogicServiceImpl method delete.
@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> delete(EmployeeVO employee) throws ServiceException, Exception {
if (employee == null || super.isBlank(employee.getOid())) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
employee = this.findEmployeeData(employee.getOid());
AccountVO account = this.findAccountData(employee.getAccount());
if (this.isAdministrator(account.getAccount())) {
throw new ServiceException("Administrator cannot delete!");
}
// check account data for other table use.
this.checkInformationRelated(account, employee);
this.deleteEmployeeOrganization(employee);
// delete user role
Map<String, Object> params = new HashMap<String, Object>();
params.put("account", account.getAccount());
List<TbUserRole> userRoles = this.getUserRoleService().findListByParams(params);
for (int i = 0; userRoles != null && i < userRoles.size(); i++) {
TbUserRole uRole = userRoles.get(i);
this.getUserRoleService().delete(uRole);
}
// delete BB_REPORT_ROLE_VIEW
params.clear();
params.put("idName", account.getAccount());
List<BbReportRoleView> reportRoleViews = this.reportRoleViewService.findListByParams(params);
for (int i = 0; reportRoleViews != null && i < reportRoleViews.size(); i++) {
BbReportRoleView reportRoleView = reportRoleViews.get(i);
this.reportRoleViewService.delete(reportRoleView);
}
// delete from BB_MEASURE_DATA where EMP_ID = :empId
this.measureDataService.deleteForEmpId(employee.getEmpId());
this.monitorItemScoreService.deleteForEmpId(employee.getEmpId());
this.deleteHierarchy(employee);
this.getAccountService().deleteByPKng(account.getOid());
return getEmployeeService().deleteObject(employee);
}
use of com.netsteadfast.greenstep.vo.AccountVO 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.AccountVO in project bamboobsc by billchen198318.
the class SystemCalendarNoteLogicServiceImpl method create.
/**
* 產生 TB_SYS_CALENDAR_NOTE 資料
*
* @param sysCalendarNote
* @param accountOid
* @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<SysCalendarNoteVO> create(SysCalendarNoteVO sysCalendarNote, String accountOid) throws ServiceException, Exception {
if (super.isBlank(accountOid) || null == sysCalendarNote) {
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();
sysCalendarNote.setDate(sysCalendarNote.getDate().replaceAll("/", "").replaceAll("-", ""));
sysCalendarNote.setAccount(account.getAccount());
String canendarId = this.sysCalendarNoteService.findForMaxCalendarId(account.getAccount(), sysCalendarNote.getDate());
if (StringUtils.isBlank(canendarId)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
}
sysCalendarNote.setCalendarId(canendarId);
if (super.defaultString(sysCalendarNote.getNote()).length() > MAX_NOTE_LENGTH) {
sysCalendarNote.setNote(sysCalendarNote.getNote().substring(0, MAX_NOTE_LENGTH));
}
DefaultResult<SysCalendarNoteVO> result = this.sysCalendarNoteService.saveObject(sysCalendarNote);
this.createMailHelper(result.getValue());
return result;
}
use of com.netsteadfast.greenstep.vo.AccountVO in project bamboobsc by billchen198318.
the class SystemMessageNoticeLogicServiceImpl method create.
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysMsgNoticeVO> create(SysMsgNoticeVO notice, String configOid, String accountOid) throws ServiceException, Exception {
if (super.isBlank(configOid) || notice == null) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
SysMsgNoticeConfigVO config = new SysMsgNoticeConfigVO();
config.setOid(configOid);
DefaultResult<SysMsgNoticeConfigVO> configResult = this.sysMsgNoticeConfigService.findObjectByOid(config);
if (configResult.getValue() == null) {
throw new ServiceException(configResult.getSystemMessage().getValue());
}
config = configResult.getValue();
notice.setMsgId(config.getMsgId());
notice.setToAccount("*");
if (!super.isNoSelectId(accountOid) && !"*".equals(accountOid)) {
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();
notice.setToAccount(account.getAccount());
}
if (super.defaultString(notice.getMessage()).length() > MAX_MESSAGE_LENGTH) {
notice.setMessage(notice.getMessage().substring(0, MAX_MESSAGE_LENGTH));
}
return this.sysMsgNoticeService.saveObject(notice);
}
use of com.netsteadfast.greenstep.vo.AccountVO 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;
}
Aggregations