@Test
  @SuppressWarnings("unchecked")
  public void testGrantAllResourceToDept() throws Exception {
    // 岗位ID
    String deptId = "8a8140ef4c112cf6014c112d6efd0000";

    // 查询出所有有效的菜单的ID(在权限表中,资源的id对应的是菜单的id)
    List<String> resourceIds =
        session
            .createCriteria(Menu.class)
            .setProjection(Projections.id())
            .add(Restrictions.eq("status", CommonStatus.ACTIVE.getValue()))
            .add(Restrictions.eq("show", true))
            .list();
    Assert.assertNotNull("没有查询到菜单资源数据!", resourceIds);
    Assert.assertTrue("没有查询到菜单资源数据!", !resourceIds.isEmpty());

    logger.info("开始将[菜单资源]授予岗位:" + deptId);
    int i = 0;
    for (String id : resourceIds) {
      AccreditMenu accreditMenu = new AccreditMenu();
      accreditMenu.setResourceId(id);
      accreditMenu.setDeptId(deptId);
      accreditMenu.setId(UUIDGenerator.generate());
      session.save(accreditMenu);
      if (i++ % 10 == 0) {
        session.flush();
        session.clear();
      }
    }
  }
Exemplo n.º 2
0
 @Override
 public List<SysParamItemVo> queryValid(String type) {
   if (StringUtils.isEmpty(type)) {
     throw new IllegalArgumentException("根据参数类型查询有效的选项时,没有获得类型编号!");
   }
   SysParamItemBo bo = new SysParamItemBo();
   bo.setType(type);
   bo.setStatus(CommonStatus.ACTIVE.getValue());
   List<SysParamItem> items = dao.query(bo);
   return VoHelper.wrapVos(
       items,
       new VoWrapper<SysParamItem, SysParamItemVo>() {
         @Override
         public SysParamItemVo wrap(SysParamItem sysParamItem) {
           SysParamItemVo vo = new SysParamItemVo();
           vo.setId(sysParamItem.getId());
           vo.setName(sysParamItem.getName());
           vo.setType(sysParamItem.getType());
           vo.setValue(sysParamItem.getValue());
           vo.setCascadeTypeCode(sysParamItem.getCascadeTypeCode());
           vo.setCascadeItemValue(sysParamItem.getCascadeItemValue());
           return vo;
         }
       });
 }
Exemplo n.º 3
0
  @Override
  public void deleteByIds(String... ids) {
    if (ids == null || ids.length == 0) return;
    for (String id : ids) {
      SysParamItem item = dao.findById(id);
      if (item == null) {
        throw new EntityNotFoundException(id);
      }

      // 删除或更改状态
      String status = item.getStatus();
      if (CommonStatus.ACTIVE.getValue().equals(status)) {
        item.setStatus(CommonStatus.CANCELED.getValue());
      } else if (CommonStatus.INACTIVE.getValue().equals(status)) {
        dao.delete(item);
      }

      // 更新缓存
      //            noticeBroker(item.getType());
      ParameterContainer.getInstance().reloadSystem(item.getType());
    }
  }