Esempio n. 1
0
 @RequestMapping(value = "/showUpdate", method = RequestMethod.GET)
 public String showUpdate(Model model, Long actId) {
   if (actId == null) actId = 0l;
   Act act = actService.getActById(actId);
   assembleCiteys(model);
   model.addAttribute("act", act);
   model.addAttribute("logoWebPath", JzCoreFunction.actLogo(act.getId(), act.getLogo(), 0));
   model.addAttribute("age", SuitAge.getByIndex(act.getSuitAge()));
   model.addAttribute("gender", SuitGender.getByIndex(act.getSuitGender()));
   model.addAttribute("stauts", SuitStatus.getByIndex(act.getSuitStatus()));
   return "cms/updateAct";
 }
Esempio n. 2
0
  private void assembleCiteys(Model model) {
    List<City> citys = new ArrayList<City>();
    List<Province> provinces = new ArrayList<Province>();
    for (Entry<Long, City> entry : com.juzhai.passport.InitData.CITY_MAP.entrySet()) {
      citys.add(entry.getValue());
    }
    for (Entry<Long, Province> entry : com.juzhai.passport.InitData.PROVINCE_MAP.entrySet()) {
      provinces.add(entry.getValue());
    }
    List<Category> categoryList = new ArrayList<Category>();
    Set<Long> keys = InitData.CATEGORY_MAP.keySet();
    for (Long key : keys) {
      categoryList.add(InitData.CATEGORY_MAP.get(key));
    }

    model.addAttribute("categoryList", categoryList);
    model.addAttribute("citys", citys);
    model.addAttribute("suitAges", SuitAge.values());
    model.addAttribute("suitGenders", SuitGender.values());
    model.addAttribute("suitStatus", SuitStatus.values());
    model.addAttribute("provinces", provinces);
  }
Esempio n. 3
0
 private Act converAct(AddActForm form, Long uid) {
   if (form == null) {
     return null;
   }
   Act act = null;
   if (form.getId() != null) {
     act = actService.getActById(form.getId());
     if (act == null) {
       return null;
     }
     if (form.getImgFile() != null && form.getImgFile().getSize() > 0) {
       UUID uuid = UUID.randomUUID();
       String fileName = uuid.toString() + "." + uploadImageService.getImgType(form.getImgFile());
       uploadImageService.uploadImg(form.getId(), fileName, form.getImgFile());
       if (!StringUtils.isEmpty(act.getLogo())) {
         uploadImageService.deleteImg(form.getId(), act.getLogo());
       }
       act.setLogo(fileName);
     }
   } else {
     act = new Act();
     act.setCreateUid(uid);
     if (form.getImgFile() != null && form.getImgFile().getSize() > 0) {
       UUID uuid = UUID.randomUUID();
       if (form.getImgFile() != null) {
         String fileName =
             uuid.toString() + "." + uploadImageService.getImgType(form.getImgFile());
         act.setLogo(fileName);
       }
     }
   }
   if (!form.getCheckAddress()) {
     act.setAddress(form.getAddress());
     act.setCity(form.getCity());
     act.setProvince(form.getProvince());
   }
   Date startTime = null;
   Date endTime = null;
   try {
     if (!StringUtils.isEmpty(form.getStartTime())) {
       startTime = DateUtils.parseDate(form.getStartTime(), new String[] {"yyyy-MM-dd"});
       act.setStartTime(startTime);
     }
     if (!StringUtils.isEmpty(form.getEndTime())) {
       endTime = DateUtils.parseDate(form.getEndTime(), new String[] {"yyyy-MM-dd"});
       act.setEndTime(endTime);
     }
   } catch (ParseException e) {
     log.error("parse search date error.", e);
   }
   String intro = form.getIntro();
   if (intro != null) act.setIntro(subString(200, form.getIntro()));
   if (form.getMaxCharge() == null) {
     act.setMaxCharge(0);
   } else {
     act.setMaxCharge(form.getMaxCharge());
   }
   if (form.getMinCharge() == null) {
     act.setMinCharge(0);
   } else {
     act.setMinCharge(form.getMinCharge());
   }
   if (form.getMaxRoleNum() == null) {
     act.setMaxRoleNum(0);
   } else {
     act.setMaxRoleNum(form.getMaxRoleNum());
   }
   if (form.getMinRoleNum() == null) {
     act.setMinRoleNum(0);
   } else {
     act.setMinRoleNum(form.getMinRoleNum());
   }
   act.setName(subString(10, form.getName()));
   act.setCategoryIds(StringUtils.join(form.getCatIds(), ","));
   if (!StringUtils.isEmpty(form.getSuiAge())) {
     act.setSuitAge(SuitAge.getSuitAge(form.getSuiAge()));
   }
   if (!StringUtils.isEmpty(form.getSuitGender())) {
     act.setSuitGender(SuitGender.getSuitGender(form.getSuitGender()));
   }
   if (!StringUtils.isEmpty(form.getSuitStatu())) {
     act.setSuitStatus(SuitStatus.getSuitStatus(form.getSuitStatu()));
   }
   act.setFullName(subString(30, form.getFullName()));
   return act;
 }
Esempio n. 4
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";
  }