Example #1
0
  @RequestMapping(value = "mod", method = RequestMethod.POST)
  public String modBrandSubmit(
      @ModelAttribute Brand brand,
      HttpServletRequest request,
      RedirectAttributes redirectAttributes) {
    String reP = "redirect:/brand/list?m=75";

    if (StringUtils.isEmpty(brand.getBrandName()) && StringUtils.isEmpty(brand.getBrandEname())
        || StringUtils.isEmpty(brand.getPinyin())
        || (StringUtils.isNotEmpty(brand.getBrandStory())
            && brand.getBrandStory().length() > 1000)) {

      request.setAttribute("warnFlag", true);
      reP = "/brand/modBrand";
    } else {
      try {
        boolean b = this.brandService.updateByBrandId(brand);
        if (b) {
          redirectAttributes.addFlashAttribute("modFlag", true);
        } else {
          request.setAttribute("warnFlag", true);
          reP = "/brand/modBrand";
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    return reP;
  }
Example #2
0
  @RequestMapping(value = "add", method = RequestMethod.POST)
  public String addBrandSubmit(
      @ModelAttribute Brand brand,
      HttpServletRequest request,
      RedirectAttributes redirectAttributes) {
    String reP = "redirect:/brand/list?m=75";

    if (StringUtils.isEmpty(brand.getBrandName()) && StringUtils.isEmpty(brand.getBrandEname())
        || StringUtils.isEmpty(brand.getPinyin())
        || (StringUtils.isNotEmpty(brand.getBrandStory())
            && brand.getBrandStory().length() > 1000)) {

      request.setAttribute("warnFlag", true);
      reP = "/brand/add";
    } else {
      TStaff staff = (TStaff) SecurityUtils.getSubject().getPrincipal();
      brand.setCreateByName(staff.getLoginName());
      brand.setCreateDate(DateUtils.currentDate());
      brand.setStatus(SystemConstants.DB_STATUS_VALID);

      try {
        this.brandService.insertBrand(brand);
      } catch (Exception e) {
        e.printStackTrace();
      }

      redirectAttributes.addFlashAttribute("addFlag", true);
    }

    return reP;
  }