コード例 #1
0
 /** DELETE /projects/:id -> delete the "id" project. */
 @RequestMapping(
     value = "/projects/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public void delete(@PathVariable Long id) {
   log.debug("REST request to delete Project : {}", id);
   projectRepository.delete(id);
 }
コード例 #2
0
 /** GET /projects -> get all the projects. */
 @RequestMapping(
     value = "/projects",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public List<Project> getAll() {
   log.debug("REST request to get all Projects");
   return projectRepository.findAll();
 }
コード例 #3
0
 /** GET /projects/:id -> get the "id" project. */
 @RequestMapping(
     value = "/projects/{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Project> get(@PathVariable Long id) {
   log.debug("REST request to get Project : {}", id);
   return Optional.ofNullable(projectRepository.findOne(id))
       .map(project -> new ResponseEntity<>(project, HttpStatus.OK))
       .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
 }
コード例 #4
0
 /** PUT /projects -> Updates an existing project. */
 @RequestMapping(
     value = "/projects",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> update(@Valid @RequestBody Project project)
     throws URISyntaxException {
   log.debug("REST request to update Project : {}", project);
   if (project.getId() == null) {
     return create(project);
   }
   projectRepository.save(project);
   return ResponseEntity.ok().build();
 }
コード例 #5
0
 /** POST /projects -> Create a new project. */
 @RequestMapping(
     value = "/projects",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> create(@Valid @RequestBody Project project)
     throws URISyntaxException {
   log.debug("REST request to save Project : {}", project);
   if (project.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new project cannot already have an ID")
         .build();
   }
   projectRepository.save(project);
   return ResponseEntity.created(new URI("/api/projects/" + project.getId())).build();
 }