コード例 #1
0
 /**
  * Accepts a POST request with an XML message parameter
  *
  * @param message serialized Message object
  * @return a string with the result of the POST
  */
 @RequestMapping(
     value = "nickname",
     method = RequestMethod.POST,
     consumes = "application/json",
     produces = "application/json")
 public @ResponseBody ResultResponse nickName(
     @RequestBody NickNameRequest req, HttpServletResponse response, HttpServletRequest request) {
   ResultResponse rp = new ResultResponse();
   rp.setResult(Cookie.RESPONSE_BAD_REQUEST);
   String strId = SecurityContextHolder.getContext().getAuthentication().getName();
   long userId =
       Cookie.checkCommonUser(
           strId, response, request, SecurityContextHolder.getContext().getAuthentication());
   if (NickNameRequest.checkParameters(req) <= 0) {
     return rp;
   }
   try {
     rp.setResult(positionRequestBo.addNickName(userId, req.getUserId(), req.getNickName()));
     return rp;
   } catch (Exception e) {
     e.printStackTrace();
     rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR);
   }
   return rp;
 }
コード例 #2
0
 /**
  * 车库中精准定位为司机发定位短信 Accepts a POST request with an XML message parameter
  *
  * @param message serialized Message object
  * @return a string with the result of the POST
  */
 @RequestMapping(
     value = "sendpossms",
     method = RequestMethod.POST,
     consumes = "application/json",
     produces = "application/json")
 public @ResponseBody ResultResponse sendPosSms(
     @RequestBody IdRequest req, HttpServletResponse response, HttpServletRequest request) {
   ResultResponse rp = new ResultResponse();
   rp.setResult(Cookie.RESPONSE_BAD_REQUEST);
   String strId = SecurityContextHolder.getContext().getAuthentication().getName();
   Cookie.checkCommonUser(
       strId, response, request, SecurityContextHolder.getContext().getAuthentication());
   try {
     User user = userBo.findById(req.getId());
     if (user != null) {
       int smsLocate = PositionHelper.checkAvailable(user.getTelephone().toString());
       positionBo.updateSmsLocateState(smsLocate, req.getId());
     } else {
       UnregisterUser unUser = unregisterUserBo.findById(req.getId());
       if (unUser != null) {
         int smsLocate = PositionHelper.checkAvailable(unUser.getTelephone().toString());
         if (smsLocate != unUser.getSmsLocate()) {
           unregisterUserBo.updateSmsLocateState(smsLocate, req.getId());
         }
       }
     }
     rp.setResult(Cookie.RESPONSE_SUCCESS);
   } catch (Exception e) {
     e.printStackTrace();
     rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR);
   }
   return rp;
 }
コード例 #3
0
  /**
   * Accepts a POST request with an XML message parameter
   *
   * @param message serialized Message object
   * @return a string with the result of the POST
   */
  @RequestMapping(
      value = "addcarandprice",
      method = RequestMethod.POST,
      consumes = "application/json",
      produces = "application/json")
  public @ResponseBody ResultResponse addCarAndPrice(
      @RequestBody AddCarAndPriceRequest req,
      HttpServletResponse response,
      HttpServletRequest request) {
    ResultResponse rp = new ResultResponse();
    rp.setResult(Cookie.RESPONSE_BAD_REQUEST);
    String strId = SecurityContextHolder.getContext().getAuthentication().getName();
    long userId =
        Cookie.checkCommonUser(
            strId, response, request, SecurityContextHolder.getContext().getAuthentication());
    // LogUtil.i("test:", "userId =" + userId + "price:"+req.getPrice());
    if (0 >= AddCarAndPriceRequest.checkParameters(req)) {
      return rp;
    }
    if (!priceRequestBo.isPriceValid(req)) {
      rp.setResult(Cookie.RESPONSE_USE_ERROR_MSG);
      rp.setErrorMsg("所输价格不合理,请重新录入");
      return rp;
    }
    Long driverId = req.getDriverUserId();

    PositionRequest pos = positionRequestBo.findById(userId, driverId);
    // 不在我的车场内,先添加到车场
    if (pos == null || pos.getType() < 0) {
      int size = positionRequestBo.getRemainFocusSize(userId);
      if (size <= 0) {
        rp.setResult(Cookie.RESPONSE_TOO_MUCH);
        return rp;
      }
      ProcessPositionRequest processPositionRequest = new ProcessPositionRequest(driverId);
      rp = positionRequestBo.askPosition(processPositionRequest, userId, 1, 1);
      if (rp.getResult() <= 0) {
        return rp;
      }
    }
    // 添加或更新价格
    rp = priceRequestBo.updatePrice(req, userId);
    return rp;
  }
コード例 #4
0
 /**
  * Accepts a POST request with an XML message parameter
  *
  * @param message serialized Message object
  * @return a string with the result of the POST
  */
 @RequestMapping(
     value = "deletefans",
     method = RequestMethod.POST,
     consumes = "application/json",
     produces = "application/json")
 public @ResponseBody ResultResponse deleteFansPosition(
     @RequestBody ProcessPositionRequest req,
     HttpServletResponse response,
     HttpServletRequest request) {
   ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST);
   String strId = SecurityContextHolder.getContext().getAuthentication().getName();
   long userId =
       Cookie.checkCommonUser(
           strId, response, request, SecurityContextHolder.getContext().getAuthentication());
   if (ProcessPositionRequest.checkParameters(req, userId) <= 0) {
     return rp;
   }
   rp.setResult(
       positionRequestBo.deletePosition(req.getUserId(), Constant.TYPE_POSITION_DELETED, userId));
   return rp;
 }
コード例 #5
0
  /**
   * Accepts a POST request with an XML message parameter
   *
   * @param message serialized Message object
   * @return a string with the result of the POST
   */
  @RequestMapping(
      value = "postpos",
      method = RequestMethod.POST,
      consumes = "application/json",
      produces = "application/json")
  public @ResponseBody ResultResponse postPosition(
      @RequestBody PostPositionRequest req,
      HttpServletResponse response,
      HttpServletRequest request) {
    ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST);
    String strId = SecurityContextHolder.getContext().getAuthentication().getName();
    long userId =
        Cookie.checkCommonUser402(
            strId, response, request, SecurityContextHolder.getContext().getAuthentication());

    if (PostPositionRequest.checkParameters(req) <= 0) {
      return rp;
    }
    if (req.getLon() < 0.1 && req.getLat() < 0.1) {
      rp.setResult(Cookie.RESPONSE_SUCCESS);
      return rp;
    }
    City city = cityBo.findById(req.getCityId());
    if (city == null || city.getId() <= 0) {
      rp.setResult(Cookie.RESPONSE_SUCCESS);
      return rp;
    }
    int id = 0;
    if (city.getDeep() == Constant.DEEP_CITY) {
      id = city.getId();
    } else if (city.getDeep() == Constant.DEEP_DISTRICT) {
      id = city.getParentId();
    }
    req.setCityId(id);
    Position pos = positionBo.createIfNull(userId);
    if ((req.getCityId() > 0 && pos.getLastEffectCity() != req.getCityId())
        || (req.getCityId() <= 0
            && PositionHelper.distFrom(req.getLat(), req.getLon(), pos.getLat(), pos.getLon())
                > 30000)) {
      PositionLog log =
          new PositionLog(
              null,
              userId,
              pos.getLastPositionTime(),
              pos.getLastEffectLon(),
              pos.getLastEffectLat(),
              pos.getLastEffectCity());
      positionLogBo.save(log);
    }
    pos.setLastEffectCity(pos.getCity());
    pos.setLastEffectLat(pos.getLat());
    pos.setLastEffectLon(pos.getLon());
    pos.setCity(req.getCityId());
    pos.setLon(req.getLon());
    pos.setLat(req.getLat());
    pos.setPositionTime(System.currentTimeMillis());
    pos.setLastPositionTime(System.currentTimeMillis());
    pos.setUpdateTime(System.currentTimeMillis());
    positionBo.update(pos);
    User user = userBo.findById(userId);
    if (user != null && user.getInstallPlace() <= 0) {
      user.setInstallPlace(req.getCityId());
      user.setUpdateTime(System.currentTimeMillis());
      userBo.update(user);
    }
    rp.setResult(Cookie.RESPONSE_SUCCESS);
    return rp;
  }