Пример #1
0
  public Response getCommunityByDistance(String auth, String lonAndLat, String r) {
    Double distance = 0.0;
    if (StringUtils.isBlank(r) || !NumberUtils.isNumber(r)) {
      distance = 3.0; // 默认是3千米
    } else {
      distance = Double.valueOf(r);
    }

    List<CommunityVo> comms = commDao.getCommunityByDistance(lonAndLat, distance);

    Map<String, Object> result = new HashMap<String, Object>();

    FaultTolerant fault = new Gson().fromJson(auth, FaultTolerant.class);
    // 进行验证
    if (!"0".equals(fault.getUid())) {
      if (Auth.auth(fault) == false) {
        result.put("code", CommonErrorEnum.FAULT_FOLERANT.getCode());
        result.put("msg", CommonErrorEnum.FAULT_FOLERANT.getMessage());
        return ReturnJSON.getInstance().ret(result);
      }
    }
    result.put("code", 0);
    result.put("msg", "查询成功");
    result.put("data", comms);

    return ReturnJSON.getInstance().ret(result);
  }
Пример #2
0
  public Map<String, Object> delete(String delIds) {
    // TODO 删除房源
    Map<String, Object> map = new HashMap<String, Object>();
    if (StringUtils.isBlank(delIds)) {
      map.put("error", "请选中要删除的数据");
      return map;
    }
    String[] ids = delIds.split(",");
    StringBuilder sb = new StringBuilder("delete  from " + Room.TABLENAME);
    StringBuilder condition = new StringBuilder();

    for (String id : ids) {
      if (NumberUtils.isNumber(id)) {
        condition.append(" id = " + id + " or ");
      }
    }
    if (StringUtils.isNotBlank(condition.toString())) {
      sb.append(" where ").append(condition.toString());
    }
    int pos = sb.toString().lastIndexOf("or");
    String sql = "";
    if (pos != -1) {
      sql = sb.toString().substring(0, pos);
    } else {
      sql = sb.toString();
    }
    System.out.println("RoomDaoImpl.delete() Sql : " + sql);
    int affected = jdbcTemplate.update(sql);
    // 同时把图标标志位改为0
    imageDaoImpl.delete(delIds);

    map.put("success", "已经成功删除" + affected + "条记录...");
    return map;
  }
Пример #3
0
  @RequestMapping(value = "/uploadImage", method = RequestMethod.POST)
  public ModelAndView upload(
      HttpServletResponse resp, HttpServletRequest req, @RequestParam MultipartFile[] image) {
    String id = (String) req.getSession().getAttribute("room_id");
    ModelAndView view = new ModelAndView("redirect:/fileUpView?id=" + id);
    Map<String, Object> map = new HashMap<String, Object>();

    String room_id = (String) req.getSession().getAttribute("room_id");
    if (NumberUtils.isNumber(room_id)) {
      String dir = req.getSession().getServletContext().getRealPath("/upload");
      map = imageBo.upload(image, dir, Integer.parseInt(room_id));
      // req.getSession().setAttribute("imageList", map.get("success"));
      return view;
    } else {
      //			map.put("error", "房源为空...");
      return new ModelAndView("error");
    }
  }