コード例 #1
0
  @RequestMapping(value = "/update/editor", method = RequestMethod.POST)
  public String update(@Valid CaseDTO caseDTO, BindingResult br, Model model) {
    if (br.hasErrors()) {
      return "/case/edit";
    }
    ScenarioBean scenBean = new ScenarioBean();
    scenBean.setId(caseDTO.getScenId());
    String className = "";
    try {
      className =
          MethodPattern.result(
                  caseDTO.getCodeContent(), "public\\sclass\\s(.*)extends\\sWebElementActionProxy")
              .trim();
    } catch (NullPointerException e) {
    }
    CaseBean caseBean = caseService.getCaseBean(caseDTO.getId());
    caseBean.setCaseName(caseDTO.getCaseName());
    caseBean.setCodeContent(caseDTO.getCodeContent());
    caseBean.setRemark(caseDTO.getRemark());
    caseBean.setStatus(caseDTO.getStatus());
    caseBean.setScenarioBean(scenBean);
    caseBean.setClassName(className);
    caseBean.setDeleteMsg(caseDTO.isDeleteMsg());
    caseBean.setMsgSendType(caseDTO.getMsgSendType());

    caseService.updateCase(caseBean);

    return "redirect:/case/list";
  }
コード例 #2
0
  @RequestMapping(value = "/add", method = RequestMethod.POST)
  public String add(
      Integer scenId,
      @Valid CaseDTO caseDTO,
      BindingResult br,
      Model model,
      HttpSession httpSession) {
    if (br.hasErrors()) {
      return "case/add";
    }
    ScenarioBean scenaBean = new ScenarioBean();
    scenaBean.setId(scenId);
    CaseBean caseBean = new CaseBean();
    caseBean.setCreateDate(new Date());
    caseBean.setScenarioBean(scenaBean);
    User user = (User) httpSession.getAttribute("loginUser");
    caseBean.setUserId(user.getId());
    caseBean.setCaseName(caseDTO.getCaseName());
    caseBean.setRemark(caseDTO.getRemark());
    caseBean.setStatus(caseDTO.getStatus());
    caseBean.setDeleteMsg(caseDTO.isDeleteMsg());
    caseBean.setMsgSendType(caseDTO.getMsgSendType());

    caseService.addCase(caseBean);
    return "redirect:/case/list";
  }