コード例 #1
0
  @RequestMapping(value = "/editkitchen", method = RequestMethod.GET)
  public String editKitchen(@RequestParam("kit") Integer Id, ModelMap map) {

    EBKitchen kit = ebKitchenService.searchKitchen(Id);
    map.addAttribute("kitedit", "true");
    map.addAttribute("kitscount", kit.getSrvCount());
    map.addAttribute("kitlat", kit.getLat());
    map.addAttribute("kitlng", kit.getLng());
    map.addAttribute("kitfund", kit.getFunds());
    map.addAttribute("kitid", Id);
    map.addAttribute("object1", ebOrgService.findAllOrganization());

    List<EBUser> list = new ArrayList<EBUser>();
    boolean check = false;
    for (EBUser e : ebUserService.getAllUser()) {
      check = false;
      for (EBUserRole r : e.getUserRole()) {
        if (r.getRoleName().equals("ROLE_KITCHEN_USER")) check = true;
      }
      if (check == true) list.add(e);
    }
    map.addAttribute("object2", list);
    map.addAttribute("orgid", kit.getKitchenOrg().getId());
    map.addAttribute("adminid", kit.getEbUser().getId());

    return "addkitchen";
  }
コード例 #2
0
  @RequestMapping(value = "/editkitchenpos", method = RequestMethod.GET)
  public String editKitchenPos(
      @RequestParam("kid") Integer Id,
      @RequestParam("status") Integer status,
      @RequestParam("lat") Double lat,
      @RequestParam("lng") Double lng,
      ModelMap map) {

    EBKitchen kit = ebKitchenService.searchKitchen(Id);
    if (status == 0) {
      map.addAttribute("lat", lat);
      map.addAttribute("lng", lng);
      map.addAttribute("status", status);
      map.addAttribute("kitid", Id);
      return "editkitchenpos";
    } else {
      kit.setLat(lat);
      kit.setLng(lng);
      ebKitchenService.newKitchen(kit);
      map.addAttribute("object", ebKitchenService.getAll());
      return "viewkitchen";
    }
  }
コード例 #3
0
  @RequestMapping(value = "/newkitchen", method = RequestMethod.POST)
  public String newKitchen(
      @RequestParam("funds") String fund,
      @RequestParam("srvCount") String srvCount,
      @RequestParam("lng") double lng,
      @RequestParam("lat") double lat,
      @RequestParam("org") Integer oId,
      @RequestParam("edit") String edit,
      @RequestParam("id") Integer kId,
      @RequestParam("kitadmin") Integer admin,
      ModelMap map) {

    try {
      ebDoubleValidator.validate(fund);
      ebDoubleValidator.validate(srvCount);
    } catch (EBException e) {

      List<EBUser> list = new ArrayList<EBUser>();
      boolean check = false;
      for (EBUser u : ebUserService.getAllUser()) {
        check = false;
        for (EBUserRole r : u.getUserRole()) {
          if (r.getRoleName().equals("ROLE_KITCHEN_USER")) check = true;
        }
        if (check == true) list.add(u);
      }
      map.addAttribute("object2", list);

      if (edit.equals("false")) {
        map.addAttribute("object1", ebOrgService.findAllOrganization());
        map.addAttribute("kitedit", "false");
        map.addAttribute("kitlat", lat);
        map.addAttribute("kitlng", lng);
        map.addAttribute("kitscount", srvCount);
        map.addAttribute("kitfund", fund);

      } else if (edit.equals("true")) {

        EBKitchen kit = ebKitchenService.searchKitchen(kId);
        map.addAttribute("kitedit", "true");
        map.addAttribute("kitscount", kit.getSrvCount());
        map.addAttribute("kitlat", kit.getLat());
        map.addAttribute("kitlng", kit.getLng());
        map.addAttribute("kitfund", kit.getFunds());
        map.addAttribute("kitid", kId);
        map.addAttribute("object1", ebOrgService.findAllOrganization());
        map.addAttribute("orgid", kit.getKitchenOrg().getId());
        map.addAttribute("adminid", kit.getEbUser().getId());
      }
      map.addAttribute("error", e.getErrorMessage());
      return "addkitchen";
    }

    EBKitchen k = null;
    EBKitchenOrg e = ebOrgService.getOrgById(oId);

    if (edit.equals("false")) {
      k = new EBKitchen();
    } else if (edit.equals("true")) {
      k = ebKitchenService.searchKitchen(kId);
    }
    k.setFunds(new Float(fund));
    k.setSrvCount(new Integer(srvCount));
    k.setLng(lng);
    k.setLat(lat);
    e.setKitchenCount(ebKitchenService.getKitchenCount(oId));
    ebKitchenService.newKitchen(k);
    k.setKitchenOrg(e);
    k.setEbUser(ebUserService.getUserById(admin));
    ebKitchenService.newKitchen(k);
    ebOrgService.saveKitchenOrg(e);

    map.addAttribute("object", ebKitchenService.getAll());
    return "viewkitchen";
  }