Esempio n. 1
0
  @RequestMapping(value = "/searchActs")
  public String searchActs(HttpServletRequest request, Model model, SearchActForm form) {
    if (null != form
        && StringUtils.isNotEmpty(form.getStartDate())
        && StringUtils.isNotEmpty(form.getEndDate())) {
      try {
        Date startDate = DateUtils.parseDate(form.getStartDate(), new String[] {"yyyy-MM-dd"});
        Date endDate = DateUtils.parseDate(form.getEndDate(), new String[] {"yyyy-MM-dd"});

        PagerManager pager =
            new PagerManager(form.getPageId(), 10, actService.countNewActs(startDate, endDate));
        List<Act> actList =
            actService.searchNewActs(
                startDate, endDate, form.getOrder(), pager.getFirstResult(), pager.getMaxResult());
        List<CmsActView> viewList = new ArrayList<CmsActView>(actList.size());
        for (Act act : actList) {
          viewList.add(
              new CmsActView(
                  act,
                  actService.listSynonymActs(act.getId()),
                  actService.isShieldAct(act.getId())));
        }
        model.addAttribute("cmsActViewList", viewList);
        model.addAttribute("pager", pager);
      } catch (ParseException e) {
        log.error("parse search date error.", e);
      }
      model.addAttribute("searchActForm", form);
    }
    return "cms/act_list";
  }
Esempio n. 2
0
  @RequestMapping(value = "/searchAct", method = RequestMethod.GET)
  public String searchAct(Model model, String bDate, String eDate, String name, Integer pageId) {
    List<Act> acts = null;
    if (pageId == null) pageId = 1;
    Date startDate = null;
    Date endDate = null;
    try {
      if (!StringUtils.isEmpty(bDate)) {
        startDate = DateUtils.parseDate(bDate, new String[] {"yyyy-MM-dd"});
      }
      if (!StringUtils.isEmpty(eDate)) {
        endDate = DateUtils.parseDate(eDate, new String[] {"yyyy-MM-dd"});
      }
    } catch (ParseException e) {
      log.error("parse search date error.", e);
    }
    PagerManager pager =
        new PagerManager(pageId, 10, actService.searchActsCount(startDate, endDate, name));
    acts =
        actService.searchActs(
            startDate, endDate, name, pager.getFirstResult(), pager.getMaxResult());

    List<CmsActMagerView> viewList = new ArrayList<CmsActMagerView>(acts.size());
    for (Act act : acts) {
      String age = SuitAge.getByIndex(act.getSuitAge()).getType();
      String status = SuitStatus.getByIndex(act.getSuitStatus()).getType();
      String gender = SuitGender.getByIndex(act.getSuitGender()).getType();
      City city = com.juzhai.passport.InitData.CITY_MAP.get(act.getCity());
      Province pro = com.juzhai.passport.InitData.PROVINCE_MAP.get(act.getProvince());
      String proName = "";
      String cityName = "";
      if (pro != null) {
        proName = pro.getName();
      }
      if (city != null) {
        cityName = city.getName();
      }
      String address = "";
      if (act.getAddress() != null) {
        address = act.getAddress();
      }
      String logoWebPath = "";
      if (act.getLogo() != null) {
        logoWebPath = JzCoreFunction.actLogo(act.getId(), act.getLogo(), 0);
      }
      StringBuffer categorys = new StringBuffer();
      String cats = act.getCategoryIds();
      if (cats != null) {
        for (String cat : cats.split(",")) {
          Category c = InitData.CATEGORY_MAP.get(Long.valueOf(cat));
          if (c != null) {
            categorys.append(c.getName() + " ");
          }
        }
      }
      viewList.add(
          new CmsActMagerView(
              act,
              logoWebPath,
              proName,
              cityName,
              address,
              age,
              gender,
              status,
              categorys.toString()));
    }
    model.addAttribute("cmsActMagerViews", viewList);
    model.addAttribute("pager", pager);
    model.addAttribute("acts", acts);
    model.addAttribute("eDate", eDate);
    model.addAttribute("bDate", bDate);
    model.addAttribute("name", name);
    return "cms/ajax/actManager_list";
  }