@RequestMapping("/jogo/logout") public String logout(HttpSession session) throws Exception { service.logout(); return "redirect:/jogo/index.action"; }
@RequestMapping("/jogo/comprarEnergia") public ModelAndView comprarEnergia( @RequestParam(value = "quantidade", required = false) String quantidade) throws ServletException, IOException { Map<String, Object> myModel = new HashMap<String, Object>(); try { myModel.put( "result", (new JSONObject(service.comprarEnergia(Integer.parseInt(quantidade)))).toString()); } catch (NumberFormatException e) { myModel.put("result", (new JSONObject(service.comprarEnergia())).toString()); } return new ModelAndView("servico.jsp", "model", myModel); }
@RequestMapping("/jogo/treinar") public ModelAndView treinar() throws ServletException, IOException { Map<String, Object> myModel = new HashMap<String, Object>(); myModel.put("result", (new JSONObject(service.treinar())).toString()); return new ModelAndView("servico.jsp", "model", myModel); }
@RequestMapping("/jogo/listaJogadores") public ModelAndView listaJogadores() throws ServletException, IOException { Map<String, Object> myModel = new HashMap<String, Object>(); myModel.put("result", (new JSONArray(service.listaJogadores())).toString()); return new ModelAndView("servico.jsp", "model", myModel); }
@RequestMapping("/jogo/compararComAmigo") public ModelAndView compararComAmigo( @RequestParam(value = "jogador", required = false) String jogador) throws ServletException, IOException { Map<String, Object> myModel = new HashMap<String, Object>(); myModel.put("result", (new JSONObject(service.compararComAmigo(jogador))).toString()); return new ModelAndView("servico.jsp", "model", myModel); }
@RequestMapping("/jogo/login") public String login( @RequestParam(value = "login", required = false) String login, @RequestParam(value = "senha", required = false) String password, @RequestParam(value = "requestedUrl", required = false) String requestedUrl) throws ServletException, IOException { if (service.login(login, password) != null) { return "redirect:/jogo/index.action"; } return "redirect:/jogo/index.action?error=Usuario e/ou senha invalidos"; }
@RequestMapping("/jogo/escolheEvento") public ModelAndView escolheEvento( @RequestParam(value = "nome", required = false) String nome, @RequestParam(value = "publico", required = false) String publico, @RequestParam(value = "cache", required = false) String cache) throws ServletException, IOException { Map<String, Object> myModel = new HashMap<String, Object>(); myModel.put("result", (new JSONObject(service.agendaShow(nome, publico, cache))).toString()); return new ModelAndView("servico.jsp", "model", myModel); }
@RequestMapping("/jogo/removeAgente") public ModelAndView removeAgente(@RequestParam(value = "agente", required = false) String agente) throws ServletException, IOException { Map<String, Object> myModel = new HashMap<String, Object>(); Long ag; try { ag = Long.parseLong(agente); } catch (NumberFormatException e) { ag = (long) -1; } myModel.put("result", (new JSONObject(service.removeAgente(ag))).toString()); return new ModelAndView("servico.jsp", "model", myModel); }
@RequestMapping("/jogo/escolheInstrumento") public ModelAndView escolheInstrumentos( @RequestParam(value = "instrumento", required = false) String instrumento) throws ServletException, IOException { Map<String, Object> myModel = new HashMap<String, Object>(); Long instr; try { instr = Long.parseLong(instrumento); } catch (NumberFormatException e) { instr = (long) -1; } myModel.put("result", (new JSONObject(service.escolheInstrumento(instr))).toString()); return new ModelAndView("servico.jsp", "model", myModel); }
@RequestMapping("/jogo/cadastro") public String cadastro( @RequestParam(value = "cad_email", required = false) String email, @RequestParam(value = "cad_login", required = false) String login, @RequestParam(value = "cad_senha", required = false) String password, @RequestParam(value = "requestedUrl", required = false) String requestedUrl) throws ServletException, IOException { try { if (service.cadastrar(login, email, password) != null) { return login(login, password, requestedUrl); } else { return "redirect:/jogo/index.action?error=Nao foi possivel realizar o cadastro"; } } catch (JogadorComNomeInvalidoException e) { return "redirect:/jogo/index.action?error=" + e.getMessage(); } }