Search in sources :

Example 11 with AccountVO

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);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) BbReportRoleView(com.netsteadfast.greenstep.po.hbm.BbReportRoleView) TbUserRole(com.netsteadfast.greenstep.po.hbm.TbUserRole) AccountVO(com.netsteadfast.greenstep.vo.AccountVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with AccountVO

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;
}
Also used : UserRoleVO(com.netsteadfast.greenstep.vo.UserRoleVO) SysMenuRoleVO(com.netsteadfast.greenstep.vo.SysMenuRoleVO) RoleVO(com.netsteadfast.greenstep.vo.RoleVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) List(java.util.List) AccountVO(com.netsteadfast.greenstep.vo.AccountVO)

Example 13 with AccountVO

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;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysCalendarNoteVO(com.netsteadfast.greenstep.vo.SysCalendarNoteVO) AccountVO(com.netsteadfast.greenstep.vo.AccountVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with AccountVO

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);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysMsgNoticeConfigVO(com.netsteadfast.greenstep.vo.SysMsgNoticeConfigVO) AccountVO(com.netsteadfast.greenstep.vo.AccountVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with AccountVO

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;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) UserRoleVO(com.netsteadfast.greenstep.vo.UserRoleVO) AccountVO(com.netsteadfast.greenstep.vo.AccountVO) UserRoleVO(com.netsteadfast.greenstep.vo.UserRoleVO) SysMenuRoleVO(com.netsteadfast.greenstep.vo.SysMenuRoleVO) RoleVO(com.netsteadfast.greenstep.vo.RoleVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AccountVO (com.netsteadfast.greenstep.vo.AccountVO)26 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)12 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)7 Transactional (org.springframework.transaction.annotation.Transactional)7 Subject (org.apache.shiro.subject.Subject)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)3 UserRoleVO (com.netsteadfast.greenstep.vo.UserRoleVO)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 AuthenticationException (org.apache.shiro.authc.AuthenticationException)3 RoleVO (com.netsteadfast.greenstep.vo.RoleVO)2 SysCalendarNoteVO (com.netsteadfast.greenstep.vo.SysCalendarNoteVO)2 SysMenuRoleVO (com.netsteadfast.greenstep.vo.SysMenuRoleVO)2 SysMsgNoticeConfigVO (com.netsteadfast.greenstep.vo.SysMsgNoticeConfigVO)2 SysMsgNoticeVO (com.netsteadfast.greenstep.vo.SysMsgNoticeVO)2 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)1 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)1 WebMessagePublishBaseObj (com.netsteadfast.greenstep.model.WebMessagePublishBaseObj)1 BbReportRoleView (com.netsteadfast.greenstep.po.hbm.BbReportRoleView)1