Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package edu.eci.arsw.kalendan.controllers; import edu.eci.arsw.kalendan.model.Project; import edu.eci.arsw.kalendan.model.User; import edu.eci.arsw.kalendan.services.TeamService; import edu.eci.arsw.kalendan.services.ProjectService; import java.util.HashMap; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; /** * * @author Juan */ @RestController @RequestMapping(value = "/kalendan") public class TeamResourceController { ProjectService ps; TeamService ts; @RequestMapping(path = "/equipos/{idT}", method = RequestMethod.GET) public ResponseEntity<?> teamGetMembers(@PathVariable("idT") Integer teamid) { try { return new ResponseEntity<>(ts.getEquipo(teamid), HttpStatus.ACCEPTED); } catch (Exception ex) { Logger.getLogger(TeamResourceController.class.getName()).log(Level.SEVERE, null, ex); return new ResponseEntity<>(HttpStatus.NOT_FOUND); } } @RequestMapping(path = "/equipos/{idT}/{permiso}", method = RequestMethod.POST) public ResponseEntity<?> teamAddMember(@PathVariable("idT") Integer teamid, @PathVariable String permiso, @RequestBody User u) { try { List<Project> con = ps.getProyectos(); ts.setProyectos(con); ts.agregaProject(); System.out.println("lalalalala"); ts.agregarMiembro(u, teamid, permiso); return new ResponseEntity<>(HttpStatus.CREATED); } catch (Exception e) { Logger.getLogger(TeamResourceController.class.getName()).log(Level.SEVERE, null, e); return new ResponseEntity<>("Equipo no creado!", HttpStatus.FORBIDDEN); } } }