@ResponseBody @RequestMapping(value = "check", method = RequestMethod.POST) public int checkName( @RequestParam(value = "name") String name, @RequestParam(value = "flag") int flag, @RequestParam(value = "brandId", defaultValue = "0") int brandId) { int re = 1; Brand brand = null; if (flag == 1) { brand = this.brandService.getBrandByName(name, null, SystemConstants.DB_STATUS_VALID); if (brand == null || brand.getBrandId() == brandId) { re = 0; } } else if (flag == 2) { brand = this.brandService.getBrandByName( null, name.toLowerCase(), SystemConstants.DB_STATUS_VALID); if (brand == null || brand.getBrandId() == brandId) { re = 0; } } return re; }
@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; }
@RequestMapping(value = "/applyDetail", method = RequestMethod.GET) public String applyDetail(@RequestParam(value = "sbId") int sellerBrandId, Model model) { SellerBrand sellerBrand = this.sellerBrandService.getSellerBrandById(sellerBrandId); model.addAttribute("sellerBrand", sellerBrand); if (sellerBrand != null) { Brand brand = this.brandService.getByBrandId(sellerBrand.getBrandId().longValue()); if (brand != null) { model.addAttribute("name", brand.getShowName()); } } return "brand/applyDetail"; }
@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; }