Search in sources :

Example 61 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.

the class SystemProgramLogicServiceImpl method createMultiName.

/**
	 * 產生 tb_sys_prog_multi_name 資料
	 * 
	 * @param multiName
	 * @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<SysProgMultiNameVO> createMultiName(SysProgMultiNameVO multiName) throws ServiceException, Exception {
    if (null == multiName || super.isBlank(multiName.getProgId()) || super.isBlank(multiName.getName()) || super.isBlank(multiName.getLocaleCode())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    if (LocaleLanguageUtils.getMap().get(multiName.getLocaleCode()) == null) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
    }
    SysProgVO sysProg = new SysProgVO();
    sysProg.setProgId(multiName.getProgId());
    DefaultResult<SysProgVO> progResult = this.sysProgService.findByUK(sysProg);
    if (progResult.getValue() == null) {
        throw new ServiceException(progResult.getSystemMessage().getValue());
    }
    super.setStringValueMaxLength(multiName, "name", 100);
    return this.sysProgMultiNameService.saveObject(multiName);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysProgVO(com.netsteadfast.greenstep.vo.SysProgVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 62 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.

the class SystemFormLogicServiceImpl method update.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysFormVO> update(SysFormVO form, String templateOid) throws ServiceException, Exception {
    if (null == form || super.isBlank(templateOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<SysFormVO> oldResult = this.sysFormService.findObjectByOid(form);
    if (oldResult.getValue() == null) {
        throw new ServiceException(oldResult.getSystemMessage().getValue());
    }
    form.setFormId(oldResult.getValue().getFormId());
    super.setStringValueMaxLength(form, "description", MAX_DESCRIPTION_LENGTH);
    SysFormTemplateVO template = this.findTemplate(templateOid);
    form.setTemplateId(template.getTplId());
    return this.sysFormService.updateObject(form);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysFormVO(com.netsteadfast.greenstep.vo.SysFormVO) SysFormTemplateVO(com.netsteadfast.greenstep.vo.SysFormTemplateVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 63 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.

the class SystemMenuLogicServiceImpl method findForMenuSettingsEnableAndAll.

/**
	 * 找出選單設定功能要的
	 * 已在選單的程式 與 同SYS的程式
	 * 
	 * map 中的  key 
	 * enable	- 已在選單的程式
	 * all	- 同SYS的程式
	 * 
	 * @param folderProgramOid
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Override
public Map<String, List<SysProgVO>> findForMenuSettingsEnableAndAll(String folderProgramOid) throws ServiceException, Exception {
    if (StringUtils.isBlank(folderProgramOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    SysProgVO sysProg = new SysProgVO();
    sysProg.setOid(folderProgramOid);
    DefaultResult<SysProgVO> spResult = this.sysProgService.findObjectByOid(sysProg);
    if (spResult.getValue() == null) {
        throw new ServiceException(spResult.getSystemMessage().getValue());
    }
    sysProg = spResult.getValue();
    Map<String, List<SysProgVO>> dataMap = new HashMap<String, List<SysProgVO>>();
    SysMenuVO sysMenu = new SysMenuVO();
    List<SysProgVO> enableList = null;
    List<SysProgVO> allList = null;
    sysMenu.setProgId(sysProg.getProgId());
    sysMenu.setParentOid(ZeroKeyProvide.OID_KEY);
    DefaultResult<SysMenuVO> smResult = this.sysMenuService.findByUK(sysMenu);
    if (smResult.getValue() != null) {
        sysMenu = smResult.getValue();
        enableList = this.sysProgService.findForInTheFolderMenuItems(sysProg.getProgSystem(), sysMenu.getOid(), MenuItemType.ITEM);
    }
    allList = this.sysProgService.findForSystemItems(sysProg.getProgSystem());
    if (enableList == null) {
        enableList = new ArrayList<SysProgVO>();
    }
    if (allList == null) {
        allList = new ArrayList<SysProgVO>();
    }
    dataMap.put("enable", enableList);
    dataMap.put("all", allList);
    return dataMap;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) SysMenuVO(com.netsteadfast.greenstep.vo.SysMenuVO) SysProgVO(com.netsteadfast.greenstep.vo.SysProgVO) ArrayList(java.util.ArrayList) List(java.util.List) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)

Example 64 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority 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)

Example 65 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority 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);
}
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) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)95 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)91 Transactional (org.springframework.transaction.annotation.Transactional)84 HashMap (java.util.HashMap)32 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)31 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)29 SysVO (com.netsteadfast.greenstep.vo.SysVO)13 LinkedHashMap (java.util.LinkedHashMap)13 Map (java.util.Map)12 AccountVO (com.netsteadfast.greenstep.vo.AccountVO)7 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)7 BaseEntity (com.netsteadfast.greenstep.base.model.BaseEntity)6 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)6 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)6 IOException (java.io.IOException)6 BaseValueObj (com.netsteadfast.greenstep.base.model.BaseValueObj)5 RoleVO (com.netsteadfast.greenstep.vo.RoleVO)5 SysProgVO (com.netsteadfast.greenstep.vo.SysProgVO)5 UserRoleVO (com.netsteadfast.greenstep.vo.UserRoleVO)5 BbReportRoleView (com.netsteadfast.greenstep.po.hbm.BbReportRoleView)4