@Override
  public void modifyUser2Menu(User user) throws BusinessException {
    if (user == null || user.getId() == null) {
      throw new BusinessException("用户不存在!");
    }
    CoreUserModel coreUserEntity = new CoreUserModel();
    coreUserEntity.setId(user.getId());

    // 先清除旧的关联关系,后再计算新的关联关系
    User2MenuModel user2MenuModel = new User2MenuModel();
    user2MenuModel.setUserId(user.getId());
    user2MenuDao.deleteByModel(user2MenuModel);

    Set<Integer> menuIds = user.getMenuIds();
    if (menuIds != null && !menuIds.isEmpty()) {
      List<User2MenuModel> user2MenuModelList = new ArrayList<User2MenuModel>();
      Iterator<Integer> it = menuIds.iterator();
      while (it.hasNext()) {
        Integer menuId = it.next();
        if (menuId != null) {
          user2MenuModel = new User2MenuModel();
          user2MenuModel.setUserId(user.getId());
          user2MenuModel.setMenuId(menuId);
          user2MenuModelList.add(user2MenuModel);
        }
      }
      user2MenuDao.batchInsert(user2MenuModelList);
    }
  }
  @Override
  public void removeMenu(Menu menu) throws BusinessException {

    if (menu.getId() == null) return;

    CoreMenuModel coreMenuEntity = new CoreMenuModel();
    coreMenuEntity.setId(menu.getId());
    coreMenuDao.delete(coreMenuEntity);

    User2MenuModel user2MenuModel = new User2MenuModel();
    user2MenuModel.setMenuId(menu.getId());
    user2MenuDao.deleteByModel(user2MenuModel);
  }