Exemplo n.º 1
0
 @Get("")
 public String index() {
   if (inv.getRequest().getSession().getAttribute("username") != null) {
     inv.addModel("username", inv.getRequest().getSession().getAttribute("username"));
     inv.addModel("TypeList", customerDAO.getTypeList());
     inv.addModel("AgreementtypeList", customerDAO.getAgreementtypeList());
     inv.addModel("SalegroupList", customerDAO.getSalegroupList());
     inv.addModel("LevelList", customerDAO.getLevelList());
     inv.addModel("SignproductList", customerDAO.getSignproductList());
   }
   inv.addModel("count", 0);
   return "index";
 }
  /**
   * 位置和周边
   *
   * @param inv
   * @param cityName
   * @param groupId
   * @param whatfor 需要地图还是周边信息
   * @return
   * @throws InvocationTargetException
   * @throws IllegalAccessException
   * @throws MalformedURLException
   */
  @Get({"/{groupId:[0-9]+}/zhoubian/", "/{groupId:[0-9]+}/ditu/"})
  public String mapAndArround(
      Invocation inv,
      @Param("cityName") @DefValue("bj") String cityName,
      @Param("groupId") @DefValue("0") int groupId,
      @Param("whatfor") @DefValue("whatfor") String whatfor)
      throws IllegalAccessException, InvocationTargetException, MalformedURLException {
    BuildingInfo buildingDetailInfo = buildingService.getBuildingDetailInfo(groupId);
    if (null != buildingDetailInfo) {
      String longtitude = buildingDetailInfo.getLongitude();
      String latitude = buildingDetailInfo.getLatitude();
      if (null == longtitude
          || !longtitude.matches(lngLatPattern)
          || null == latitude
          || !latitude.matches(lngLatPattern)) {
        return "e:404";
      }
    } else {
      return "e:404";
    }

    int phone400 = 0;
    if (null != buildingDetailInfo) {
      phone400 = buildingDetailInfo.getPhone400();
    }
    inv.addModel("phone400", phone400);

    DictCity city = null;
    try {
      city = cityService.getCity(buildingDetailInfo.getCityId());
    } catch (Exception e) {
      logger.error("", e);
    }
    City cityInfo = new City();
    BeanUtils.copyProperties(cityInfo, city);
    cityInfo.setCityStatus(AppConstants.CityPageStatus.getCityStatus(cityInfo.getCityName()));
    cityInfo.setEsfUrl("http://" + city.getCityPinyinAbbr() + "." + CityPageStatus.getEsfUrl());
    cityInfo.setXinfangUrl("/" + city.getCityPinyinAbbr() + "/search/list/");
    cityInfo.setSuggestUrl("/" + city.getCityPinyinAbbr() + "/search/suggest/");
    inv.addModel("cityStr", JSONObject.toJSONString(cityInfo));
    inv.addModel("_city", cityInfo);
    inv.addModel("groupId", groupId);
    inv.addModel("info", buildingDetailInfo);

    String buildingName = buildingDetailInfo.getProjName();
    if (buildingName.length() >= 5) {
      buildingName = buildingName.substring(0, 4) + "...";
    }
    inv.addModel("buildName", buildingName);
    // 返回标志 0表示返回历史记录 1 表示返回首页
    int returnFlag = Utils.getBackStatus(inv.getRequest());
    inv.addModel("returnFlag", returnFlag);
    // phone展示页
    if (inv.getRequestPath().getUri().contains("ditu")) {
      return "phone/map";
    } else {
      return "phone/arround";
    }
  }
 @Override
 public Object render(Invocation inv, Object instruction) throws Exception {
   // 设置到request中,使测试用例可以从request对象取回instruction对象
   if (storesInstructionInRequest) {
     inv.getRequest().setAttribute(INSTRUCTION, instruction);
   }
   return instruction;
 }
Exemplo n.º 4
0
  /** before方法在调用控制器方法前执行,相反的after则是控制器执行后才执行 */
  @Override
  protected Object before(Invocation inv) throws Exception {
    HttpServletRequest request = inv.getRequest();
    HttpSession session = request.getSession();

    if (session == null || session.getAttribute("loginUser") == null) {
      String pwd = inv.getParameter("pwd");
      String userName = inv.getParameter("userName");
      if (StringUtils.isNotBlank(pwd) && StringUtils.isNotBlank(userName)) {
        Admin admin = adminService.queryAdmin(userName, pwd);

        if (null != admin) {
          UserSession loginUser = this.createAdminSession(admin);
          session.setAttribute("loginUser", loginUser);
        }
      }
    }

    return true;
  }