예제 #1
0
 /**
  * 修改
  *
  * @param inv
  * @param actGuessGameConf
  * @param startTime
  * @param endTime
  * @return
  * @throws Exception
  */
 @Post("edit_do")
 public String edit_do(
     final Invocation inv,
     ActGuessGameConf actGuessGameConf,
     @Param("createTime") final Date createTime,
     @Param("activityTime") final String activityTime)
     throws Exception {
   if (activityTime == null || activityTime.length() == 0) {
     inv.addModel("tip", "非法操作,请重试");
     inv.addModel(
         "backUrl",
         ReadProperties.getPara("httpPath")
             + "/pluginadmin/guessgame/edit/"
             + actGuessGameConf.getActivityId());
     return "../pc/tip.jsp";
   }
   if (activityTime.length() != 0) {
     String[] time = activityTime.split(" - ");
     actGuessGameConf.setStartTime(DateUtils.converDate(time[0]));
     actGuessGameConf.setEndTime(DateUtils.converDate(time[1]));
   }
   actGuessGameConf.setCreateTime(createTime);
   actGuessGameConfService.update(actGuessGameConf);
   inv.getResponse().sendRedirect(WebApplicationUtils.getBasePath() + "/pc/my/actList");
   return null;
 }
예제 #2
0
 /**
  * 添加
  *
  * @param inv
  * @param actPintuConf
  * @param startTime
  * @param endTime
  * @param userPluginId
  * @return
  * @throws Exception
  */
 @Post("add_do")
 public String add_do(
     final Invocation inv,
     ActPintuConf actPintuConf,
     @Param("activityTime") final String activityTime,
     @Param("userPluginId") final Integer userPluginId)
     throws Exception {
   if (activityTime == null
       || activityTime.length() == 0
       || actPintuConf.getAwards() == null
       || actPintuConf.getAwards().toString().length() == 0) {
     inv.addModel("tip", "非法操作,请重试");
     inv.addModel(
         "backUrl", ReadProperties.getPara("httpPath") + "/pluginadmin/pintu/add/" + userPluginId);
     return "../pc/tip.jsp";
   }
   if (activityTime.length() != 0) {
     String[] time = activityTime.split(" - ");
     actPintuConf.setStartTime(DateUtils.converDate(time[0]));
     actPintuConf.setEndTime(DateUtils.converDate(time[1]));
   }
   actPintuConf.setCreateTime(new Date());
   actPintuConfService.save(actPintuConf, userPluginId);
   actPintuConfService.savePrize(
       actPintuConf.getActivityId(), actPintuConf.getAwards().toString());
   inv.getResponse().sendRedirect(WebApplicationUtils.getBasePath() + "/pc/my/actList");
   return null;
 }
  /**
   * 位置和周边
   *
   * @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";
    }
  }
예제 #4
0
 /**
  * 编辑活动跳转
  *
  * @param inv
  * @param id 活动id activityId
  * @return
  * @throws Exception
  */
 @ActOptRequired
 @Get("edit/{activityId:[0-9]+}")
 public String edit(final Invocation inv, @Param("activityId") final Integer activityId)
     throws Exception {
   ActPintuConf actPintuConf = actPintuConfService.findByActId(activityId);
   if (actPintuConf != null) {
     List<PintuAwardsVo> pintuAwardsVoList =
         actPintuConfService.parseJson(actPintuConf.getAwards().toString());
     inv.addModel("awardslist", pintuAwardsVoList);
     inv.addModel("conf", actPintuConf);
   }
   return "pintu/edit";
 }
예제 #5
0
 @ActOptRequired
 @Get("record/{activityId:[0-9]+}")
 public String record(
     final Invocation inv,
     @Param("activityId") final Integer activityId,
     @Param("currentPage") final int currentPage,
     @Param("count") final int count,
     @Param("upid") final Integer userPluginId) {
   Pagination<ActPintuRecord> paginationRecord =
       actPintuConfService.getRecordPage(activityId, currentPage, Globals.PAGE_SHOW_NUMBER);
   inv.addModel("recordVos", paginationRecord);
   inv.addModel("activityId", activityId);
   inv.addModel("userPluginId", userPluginId);
   return "pintu/record";
 }
예제 #6
0
 @ActOptRequired
 @Get("rank/{activityId:[0-9]+}")
 public String rank(
     final Invocation inv,
     @Param("activityId") final Integer activityId,
     @Param("currentPage") final int currentPage,
     @Param("count") final int count,
     @Param("upid") final Integer userPluginId) {
   Pagination<ActPintuRecord> paginationRecord =
       actPintuConfService.getRankPage(activityId, currentPage, Globals.PAGE_SHOW_NUMBER);
   inv.addModel("recordVos", paginationRecord);
   inv.addModel("activityId", activityId);
   inv.addModel("userPluginId", userPluginId);
   inv.addModel("rankUrl", ReadProperties.getPara("httpPath") + "/cj/pintu/rank/" + activityId);
   return "pintu/rank";
 }
예제 #7
0
 @ActOptRequired
 @Get("gameadmin/{activityId:[0-9]+}")
 public String gameadmin(
     final Invocation inv,
     @Param("activityId") final Integer activityId,
     @Param("currentPage") final int currentPage,
     @Param("count") final int count,
     @Param("upid") final Integer userPluginId) {
   Pagination<ActGuessGameAdmin> paginationRecord =
       actGuessGameConfService.getGameAdminPage(activityId, currentPage, Globals.PAGE_SHOW_NUMBER);
   inv.addModel("bJoinType", actGuessGameConfService.getJoinType(activityId));
   inv.addModel("recordVos", paginationRecord);
   inv.addModel("activityId", activityId);
   inv.addModel("userPluginId", userPluginId);
   return "guessgame/gameadmin";
 }
예제 #8
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";
 }
 @Override
 public Object render(Invocation inv, Object instruction) throws Exception {
   // 设置到request中,使测试用例可以从request对象取回instruction对象
   if (storesInstructionInRequest) {
     inv.getRequest().setAttribute(INSTRUCTION, instruction);
   }
   return instruction;
 }
예제 #10
0
 /**
  * 编辑活动跳转
  *
  * @param inv
  * @param id 活动id activityId
  * @return
  * @throws Exception
  */
 @ActOptRequired
 @Get("edit/{activityId:[0-9]+}")
 public String edit(final Invocation inv, @Param("activityId") final Integer activityId)
     throws Exception {
   ActGuessGameConf actGuessGameConf = actGuessGameConfService.findByActId(activityId);
   if (actGuessGameConf != null) {
     inv.addModel("conf", actGuessGameConf);
   }
   return "guessgame/edit";
 }
예제 #11
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;
  }
예제 #12
0
 @Post("addGame/{activityId:[0-9]+}")
 public String addGame(
     final Invocation inv,
     ActGuessGameAdmin actGuessGameAdmin,
     @Param("activityTime") final String activityTime)
     throws Exception {
   if (activityTime.length() != 0) {
     String[] time = activityTime.split(" - ");
     actGuessGameAdmin.setStartTime(DateUtils.converDate(time[0]));
     actGuessGameAdmin.setEndTime(DateUtils.converDate(time[1]));
   }
   actGuessGameAdmin.setUpdateTime(new Date());
   int ret = actGuessGameConfService.addGame(actGuessGameAdmin);
   if (ret == 0) {
     return "@<script>alert('新增失败');window.history.go(-1);</script>";
   } else {
     inv.getResponse()
         .sendRedirect(
             WebApplicationUtils.getContextPath()
                 + "/pluginadmin/guessgame/gameadmin/"
                 + actGuessGameAdmin.getActivityId());
     return null;
   }
 }
예제 #13
0
 /**
  * 增加拼图活动页面跳转
  *
  * @param inv
  * @param userPluginId
  * @return
  */
 @ActOptRequired
 @Get("add/{userPluginId}")
 public String add(final Invocation inv, @Param("userPluginId") final Integer userPluginId) {
   inv.addModel("userPluginId", userPluginId);
   return "pintu/add";
 }
  public Object[] resolve(final Invocation inv, final ParameterBindingResult parameterBindingResult)
      throws Exception {
    Object[] parameters = new Object[paramMetaDatas.length];
    for (int i = 0; i < resolvers.length; i++) {
      if (resolvers[i] == null) {
        continue;
      }
      try {
        if (logger.isDebugEnabled()) {
          logger.debug(
              "Resolves parameter "
                  + paramMetaDatas[i].getParamType().getSimpleName()
                  + " using "
                  + resolvers[i].getClass().getName());
        }
        parameters[i] = resolvers[i].resolve(inv, paramMetaDatas[i]);
        // afterPropertiesSet
        if (parameters[i] instanceof InitializingBean) {
          ((InitializingBean) parameters[i]).afterPropertiesSet();
        }
        if (parameters[i] == null) {
          DefValue defValudeAnnotation = paramMetaDatas[i].getAnnotation(DefValue.class);
          if (defValudeAnnotation != null && paramMetaDatas[i].getParamType() == String.class) {
            parameters[i] = defValudeAnnotation.value();
          }
        }
      } catch (TypeMismatchException e) {
        // 出现这个错误肯定是解析一般参数失败导致的,而非bean里面的某个属性值的解析失败

        logger.debug("", e);

        // 对简单类型的参数,设置一个默认值给它以支持对该方法的继续调用
        if (paramMetaDatas[i].getParamType().isPrimitive()) {
          DefValue defValudeAnnotation = paramMetaDatas[i].getAnnotation(DefValue.class);
          if (defValudeAnnotation == null
              || DefValue.NATIVE_DEFAULT.equals(defValudeAnnotation.value())) {
            // 对这最常用的类型做一下if-else判断,其他类型就简单使用converter来做吧
            if (paramMetaDatas[i].getParamType() == int.class) {
              parameters[i] = Integer.valueOf(0);
            } else if (paramMetaDatas[i].getParamType() == long.class) {
              parameters[i] = Long.valueOf(0);
            } else if (paramMetaDatas[i].getParamType() == boolean.class) {
              parameters[i] = Boolean.FALSE;
            } else if (paramMetaDatas[i].getParamType() == double.class) {
              parameters[i] = Double.valueOf(0);
            } else if (paramMetaDatas[i].getParamType() == float.class) {
              parameters[i] = Float.valueOf(0);
            } else {
              TypeConverter typeConverter = SafedTypeConverterFactory.getCurrentConverter();
              parameters[i] =
                  typeConverter.convertIfNecessary("0", paramMetaDatas[i].getParamType());
            }
          } else {
            TypeConverter typeConverter = SafedTypeConverterFactory.getCurrentConverter();
            parameters[i] =
                typeConverter.convertIfNecessary(
                    defValudeAnnotation.value(), paramMetaDatas[i].getParamType());
          }
        }
        //
        String paramName = parameterNames[i];
        if (paramName == null) {
          for (String name : paramMetaDatas[i].getParamNames()) {
            if ((paramName = name) != null) {
              break;
            }
          }
        }
        Assert.isTrue(paramName != null);
        FieldError fieldError =
            new FieldError( //
                "method", // 该出错字段所在的对象的名字;对于这类异常我们统一规定名字为method
                paramName, // 出错的字段的名字;取其参数名
                inv.getParameter(paramName), // 被拒绝的值
                true, // whether this error represents a binding failure (like a type mismatch);
                // else, it is a validation failure
                new String[] {e.getErrorCode()}, // "typeMismatch"
                new String[] {
                  inv.getParameter(paramName)
                }, // the array of arguments to be used to resolve this message
                null // the default message to be used to resolve this message
                );
        parameterBindingResult.addError(fieldError);
      } catch (Exception e) {
        // 什么错误呢?比如很有可能是构造对象不能成功导致的错误,没有默认构造函数、构造函数执行失败等等
        logger.error("", e);
        throw e;
      }
    }
    return parameters;
  }