Search in sources :

Example 1 with RolePermissionVO

use of com.netsteadfast.greenstep.vo.RolePermissionVO in project bamboobsc by billchen198318.

the class RoleLogicServiceImpl method copyAsNew.

/**
	 * 拷備一份role
	 * 
	 * @param fromRoleOid
	 * @param role
	 * @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<RoleVO> copyAsNew(String fromRoleOid, RoleVO role) throws ServiceException, Exception {
    if (role == null || super.isBlank(role.getRole()) || super.isBlank(fromRoleOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    super.setStringValueMaxLength(role, "description", MAX_DESCRIPTION_LENGTH);
    DefaultResult<RoleVO> result = this.roleService.saveObject(role);
    RoleVO oldRole = new RoleVO();
    oldRole.setOid(fromRoleOid);
    DefaultResult<RoleVO> fromResult = this.roleService.findObjectByOid(oldRole);
    if (fromResult.getValue() == null) {
        throw new ServiceException(fromResult.getSystemMessage().getValue());
    }
    oldRole = fromResult.getValue();
    Map<String, Object> paramMap = new HashMap<String, Object>();
    paramMap.put("role", oldRole.getRole());
    List<TbRolePermission> permissions = this.rolePermissionService.findListByParams(paramMap);
    for (int i = 0; permissions != null && i < permissions.size(); i++) {
        RolePermissionVO permission = new RolePermissionVO();
        this.rolePermissionService.fillToValueObject(permission, permissions.get(i));
        permission.setOid(null);
        permission.setRole(result.getValue().getRole());
        this.rolePermissionService.saveObject(permission);
    }
    // 選單menu role 也copy一份
    List<TbSysMenuRole> menuRoles = this.sysMenuRoleService.findListByParams(paramMap);
    for (int i = 0; menuRoles != null && i < menuRoles.size(); i++) {
        SysMenuRoleVO menuRole = new SysMenuRoleVO();
        this.sysMenuRoleService.fillToValueObject(menuRole, menuRoles.get(i));
        menuRole.setOid(null);
        menuRole.setRole(result.getValue().getRole());
        this.sysMenuRoleService.saveObject(menuRole);
    }
    return result;
}
Also used : SysMenuRoleVO(com.netsteadfast.greenstep.vo.SysMenuRoleVO) TbSysMenuRole(com.netsteadfast.greenstep.po.hbm.TbSysMenuRole) HashMap(java.util.HashMap) TbRolePermission(com.netsteadfast.greenstep.po.hbm.TbRolePermission) RolePermissionVO(com.netsteadfast.greenstep.vo.RolePermissionVO) 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)

Example 2 with RolePermissionVO

use of com.netsteadfast.greenstep.vo.RolePermissionVO in project bamboobsc by billchen198318.

the class RolePermittedSaveOrUpdateAction method save.

/**
	 * 建立 TB_ROLE_PERMISSION 資料
	 * 
	 * @throws ControllerException
	 * @throws AuthorityException
	 * @throws ServiceException
	 * @throws Exception
	 */
private void save() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    String roleOid = this.getFields().get("roleOid");
    RolePermissionVO permission = new RolePermissionVO();
    this.transformFields2ValueObject(permission, new String[] { "permType", "permission", "description" });
    DefaultResult<RolePermissionVO> result = this.roleLogicService.createPermission(permission, roleOid);
    this.message = result.getSystemMessage().getValue();
    if (result.getValue() == null) {
        return;
    }
    this.success = IS_YES;
}
Also used : RolePermissionVO(com.netsteadfast.greenstep.vo.RolePermissionVO)

Example 3 with RolePermissionVO

use of com.netsteadfast.greenstep.vo.RolePermissionVO in project bamboobsc by billchen198318.

the class RolePermittedSaveOrUpdateAction method delete.

/**
	 * 刪除 TB_ROLE_PERMISSION 資料
	 * 
	 * @throws ControllerException
	 * @throws AuthorityException
	 * @throws ServiceException
	 * @throws Exception
	 */
private void delete() throws ControllerException, AuthorityException, ServiceException, Exception {
    RolePermissionVO permission = new RolePermissionVO();
    this.transformFields2ValueObject(permission, new String[] { "oid" });
    DefaultResult<Boolean> result = this.roleLogicService.deletePermission(permission);
    this.message = result.getSystemMessage().getValue();
    if (result.getValue() == null || !result.getValue()) {
        return;
    }
    this.success = IS_YES;
}
Also used : RolePermissionVO(com.netsteadfast.greenstep.vo.RolePermissionVO)

Aggregations

RolePermissionVO (com.netsteadfast.greenstep.vo.RolePermissionVO)3 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)1 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)1 TbRolePermission (com.netsteadfast.greenstep.po.hbm.TbRolePermission)1 TbSysMenuRole (com.netsteadfast.greenstep.po.hbm.TbSysMenuRole)1 RoleVO (com.netsteadfast.greenstep.vo.RoleVO)1 SysMenuRoleVO (com.netsteadfast.greenstep.vo.SysMenuRoleVO)1 UserRoleVO (com.netsteadfast.greenstep.vo.UserRoleVO)1 HashMap (java.util.HashMap)1 Transactional (org.springframework.transaction.annotation.Transactional)1