/** * 自定义保存资源. <br> * 说明:如果保存的资源类型为“功能” 则将所有子资源都设置为“功能”类型 * * @param entity 资源对象 * @throws DaoException * @throws SystemException * @throws ServiceException */ public void saveResource(Resource entity) throws DaoException, SystemException, ServiceException { Assert.notNull(entity, "参数[entity]为空!"); this.saveEntity(entity); if (entity.getType() != null && ResourceState.function.getValue().equals(entity.getType())) { List<Resource> subResources = entity.getSubResources(); while (!Collections3.isEmpty(subResources)) { Iterator<Resource> iterator = subResources.iterator(); while (iterator.hasNext()) { Resource subResource = iterator.next(); subResource.setType(ResourceState.function.getValue()); iterator.remove(); subResources = ListUtils.union(subResources, subResource.getSubResources()); super.update(subResource); } } } }
/** 设置组织机构页面. */ @RequestMapping(value = {"organ"}) public String organ(@ModelAttribute("model") User user, Model model) throws Exception { // 设置默认组织机构初始值 List<Combobox> defaultOrganCombobox = Lists.newArrayList(); if (user.getId() != null) { List<Organ> organs = user.getOrgans(); Combobox combobox; if (!Collections3.isEmpty(organs)) { for (Organ organ : organs) { combobox = new Combobox(organ.getId().toString(), organ.getName()); defaultOrganCombobox.add(combobox); } } } String defaultOrganComboboxData = JsonMapper.nonDefaultMapper().toJson(defaultOrganCombobox); logger.debug(defaultOrganComboboxData); model.addAttribute("defaultOrganComboboxData", defaultOrganComboboxData); return "modules/sys/user-organ"; }