コード例 #1
0
  @RequestMapping("whitelist-type-remove")
  public String remove(
      @RequestParam("selectedItem") List<Long> selectedItem,
      RedirectAttributes redirectAttributes) {
    List<WhitelistType> whitelistTypes = whitelistTypeManager.findByIds(selectedItem);
    whitelistTypeManager.removeAll(whitelistTypes);
    messageHelper.addFlashMessage(redirectAttributes, "core.success.delete", "删除成功");

    return "redirect:/whitelist/whitelist-type-list.do";
  }
コード例 #2
0
ファイル: WhitelistService.java プロジェクト: robinwuwu/lemon
  public void saveWhitelistApp(
      WhitelistApp whitelistApp,
      Long whitelistTypeId,
      String hostContent,
      String ipContent,
      String username,
      String tenantId) {
    Long id = whitelistApp.getId();
    WhitelistApp dest = null;

    if (id != null) {
      whitelistApp.setWhitelistHosts(null);
      whitelistApp.setWhitelistIps(null);
      dest = whitelistAppManager.get(id);
      beanMapper.copy(whitelistApp, dest);
    } else {
      dest = whitelistApp;
      dest.setUserId(username);
      dest.setTenantId(tenantId);
    }

    // type
    WhitelistType whitelistType = whitelistTypeManager.get(whitelistTypeId);
    dest.setWhitelistType(whitelistType);

    // host
    this.processHost(dest, Arrays.asList(hostContent.split("\n")));

    // ip
    this.processIp(dest, Arrays.asList(ipContent.split("\n")));

    whitelistAppManager.save(dest);
  }
コード例 #3
0
  @RequestMapping("whitelist-type-input")
  public String input(@RequestParam(value = "id", required = false) Long id, Model model) {
    if (id != null) {
      WhitelistType whitelistType = whitelistTypeManager.get(id);
      model.addAttribute("model", whitelistType);
    }

    return "whitelist/whitelist-type-input";
  }
コード例 #4
0
  @RequestMapping("whitelist-type-save")
  public String save(
      @ModelAttribute WhitelistType whitelistType, RedirectAttributes redirectAttributes) {
    String tenantId = tenantHolder.getTenantId();
    Long id = whitelistType.getId();
    WhitelistType dest = null;

    if (id != null) {
      dest = whitelistTypeManager.get(id);
      beanMapper.copy(whitelistType, dest);
    } else {
      dest = whitelistType;
      dest.setTenantId(tenantId);
    }

    whitelistTypeManager.save(dest);
    messageHelper.addFlashMessage(redirectAttributes, "core.success.save", "保存成功");

    return "redirect:/whitelist/whitelist-type-list.do";
  }
コード例 #5
0
  @RequestMapping("whitelist-type-list")
  public String list(
      @ModelAttribute Page page, @RequestParam Map<String, Object> parameterMap, Model model) {
    String tenantId = tenantHolder.getTenantId();
    List<PropertyFilter> propertyFilters = PropertyFilter.buildFromMap(parameterMap);
    propertyFilters.add(new PropertyFilter("EQS_tenantId", tenantId));
    page = whitelistTypeManager.pagedQuery(page, propertyFilters);
    model.addAttribute("page", page);

    return "whitelist/whitelist-type-list";
  }
コード例 #6
0
  @RequestMapping("whitelist-type-export")
  public void export(
      @ModelAttribute Page page,
      @RequestParam Map<String, Object> parameterMap,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    String tenantId = tenantHolder.getTenantId();
    List<PropertyFilter> propertyFilters = PropertyFilter.buildFromMap(parameterMap);
    propertyFilters.add(new PropertyFilter("EQS_tenantId", tenantId));
    page = whitelistTypeManager.pagedQuery(page, propertyFilters);

    List<WhitelistType> whitelistTypes = (List<WhitelistType>) page.getResult();

    TableModel tableModel = new TableModel();
    tableModel.setName("whitelistType");
    tableModel.addHeaders("id", "name");
    tableModel.setData(whitelistTypes);
    exportor.export(request, response, tableModel);
  }