Esempio n. 1
0
  @RequestMapping("/apply")
  public String getApplyBrandsByPage(HttpServletRequest request) {
    // 处理分页信息
    PageInfo pageInfo = null;

    if (request.getParameter("query") != null) { // 查询
      pageInfo = PageUtils.registerPageInfo(request);

    } else if (request.getParameter("pageNo") != null) { // 分页
      int pageNo = NumberUtils.toInt(request.getParameter("pageNo"), 1);

      pageInfo = PageUtils.getPageInfo(request);
      pageInfo.setPageNo(pageNo);
    } else {
      pageInfo = PageUtils.getPageInfo(request);

      if (pageInfo == null) {
        pageInfo = PageUtils.registerPageInfo(request);
        pageInfo.getConditions().put("status", SystemConstants.DB_STATUS_VALID); // 默认有效
        pageInfo.getConditions().put("createDate", "DESC"); // 默认降序
      }
    }

    request.setAttribute("pageInfo", pageInfo);

    // 查询
    Map<String, Object> map = Maps.newHashMap();

    if (StringUtils.isNotBlank(pageInfo.getConditions().get("brandName"))) {
      map.put("brandName", pageInfo.getConditions().get("brandName"));
    }
    if (StringUtils.isNotBlank(pageInfo.getConditions().get("coName"))) {
      map.put("coName", pageInfo.getConditions().get("coName").toLowerCase());
    }
    if (StringUtils.isNotBlank(pageInfo.getConditions().get("startDt"))) {
      map.put(
          "startDt", DateUtils.parseDate(pageInfo.getConditions().get("startDt"), "yyyy-MM-dd"));
    }
    if (StringUtils.isNotBlank(pageInfo.getConditions().get("endDt"))) {
      Date endDt = DateUtils.parseDate(pageInfo.getConditions().get("endDt"), "yyyy-MM-dd");

      endDt = DateUtils.addDay(endDt, 1);

      map.put("endDt", endDt);
    }
    if (StringUtils.isNotBlank(pageInfo.getConditions().get("status"))) {
      map.put("status", pageInfo.getConditions().get("status"));
    }
    if (StringUtils.isNotBlank(pageInfo.getConditions().get("loginName"))) {
      map.put("loginName", pageInfo.getConditions().get("loginName"));
    }

    Page<SellerBrand> sellerBrands =
        this.sellerBrandService.queryWaitAuditApplyByPage(map, pageInfo.getPageNo());

    request.setAttribute("sellerBrands", sellerBrands);

    return "brand/applyList";
  }
Esempio n. 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;
  }