예제 #1
0
  @RequestMapping(value = "/admin/index.html", method = RequestMethod.GET)
  public ModelAndView index() {

    ModelAndView modelAndView = new ModelAndView(index);
    ModelMap modelMap = modelAndView.getModelMap();

    List<User> users = userService.findAllUsers();
    Account account = accountService.findLatestRecord();
    int totalIncome = incomeService.getTotal();

    List<Food> dishes = foodService.findAllFoods();

    Payment todayPayment = paymentService.getPaymentOfToday();

    List<FoodType> catagorys = foodTypeService.findAllFoodTypes();
    Map<String, List<Food>> map = new HashMap<String, List<Food>>();

    for (FoodType type : catagorys) {
      List<Food> foods = foodService.findFoodByType(type.getGuid());
      if (foods.size() > 0) {
        map.put(type.getName(), foods);
      }
    }

    modelMap.put(USERS, users);

    if (account != null) {
      modelMap.put(REMAINDER, account.getRemainder());
    }

    modelMap.put(INCOMETOTAL, totalIncome);

    modelMap.put(DISHES, dishes);
    modelMap.put(CATAGORYS, map);

    if (todayPayment != null) {
      modelMap.put(TODAYCONSUME, todayPayment.getAmount());
    }

    List<String> contentPages = new ArrayList<String>();
    contentPages.add(dashboard + JSPSUFFIX);
    contentPages.add(userManage + JSPSUFFIX);
    contentPages.add(dishManage + JSPSUFFIX);
    modelMap.put(CONTENTPAGE, contentPages);

    List<StepBean> emptyStepBean = Collections.emptyList();
    modelMap.put(STEPS, emptyStepBean);

    return modelAndView;
  }
예제 #2
0
 public Food getFoodFromCursor(Cursor cursor) {
   Food food = new Food();
   food.setFood_name(cursor.getString(1));
   food.setProtein(Double.parseDouble(cursor.getString(2)));
   food.setCarbo_hydr(Double.parseDouble(cursor.getString(3)));
   food.setFat(Double.parseDouble(cursor.getString(4)));
   food.setKcal(Double.parseDouble(cursor.getString(5)));
   food.setType(FoodType.getType(Integer.parseInt(cursor.getString(6))), 0);
   food.setType(FoodType.getType(Integer.parseInt(cursor.getString(7))), 1);
   food.setType(FoodType.getType(Integer.parseInt(cursor.getString(8))), 2);
   food.setCategory(FoodCategory.getCategory(Integer.parseInt(cursor.getString(9))));
   food.setFrequency(cursor.getInt(10));
   if (cursor.isNull(11) || cursor.getString(11) == "null") {
     food.setStrLastTransaction("");
   } else {
     food.setStrLastTransaction(cursor.getString(11));
   }
   cursor.close();
   return food;
 }