Пример #1
0
  public Object searchFood(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    Object uri = null;

    PageBean<Food> pb = new PageBean<Food>();
    Condition condition = new Condition();

    String keyword = request.getParameter("keyword"); // 设置关键词
    if (keyword != null && !keyword.isEmpty()) {
      condition.setFoodName(keyword);
    }
    if (condition != null) {
      pb.setCondition(condition);
    }

    pb.setCondition(condition);

    foodService.getAll(pb);

    request.setAttribute("pageBean", pb);
    // 跳转
    uri = request.getRequestDispatcher("/app/detail/caidan.jsp");

    return uri;
  }
Пример #2
0
  public Object getMenu(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    Object uri = null;
    HttpSession session = request.getSession(); // 用于存储订单信息
    // 获取session里的值
    Object obj = session.getAttribute("table_id");

    String table_id = request.getParameter("table_id"); // 桌的id
    if (table_id != null) {
      tableService.changeState(Integer.parseInt(table_id));
      if (obj == null) {
        session.setAttribute("table_id", table_id); // 存放桌id以备订单用
      }
    }

    // 查询菜系信息
    List<FoodType> foodtypes = foodTypeService.query();
    request.setAttribute("foodtypes", foodtypes);

    // 获取菜单页面信息
    PageBean<Food> pb = new PageBean<Food>();

    Condition con = new Condition();
    // 获取页面得到的参数
    String foodtype = request.getParameter("foodtype");
    String foodName = request.getParameter("foodName");
    if (foodtype != null && !foodtype.isEmpty()) {
      con.setFoodType_id(Integer.parseInt(foodtype));
      pb.setCondition(con);
    }
    if (foodName != null && !foodName.isEmpty()) {
      con.setFoodName(foodName);
      pb.setCondition(con);
    }

    pb.setPageCount(6);
    String curPage = request.getParameter("currentPage"); // 获取当前页
    if (curPage == null || curPage.isEmpty()) {
      pb.setCurrentPage(1);
    }
    if (curPage != null && !curPage.isEmpty()) {
      int currentPage = Integer.parseInt(curPage);
      pb.setCurrentPage(currentPage);
    }

    foodService.getAll(pb);

    request.setAttribute("pageBean", pb);
    // 跳转
    uri = request.getRequestDispatcher("/app/detail/caidan.jsp");

    return uri;
  }