Skip to content

Commit

Permalink
Правки
Browse files Browse the repository at this point in the history
  • Loading branch information
I1yi4 committed Jun 16, 2024
1 parent 8f0b24f commit e810561
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.Optional;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.util.MimeTypeUtils.IMAGE_PNG_VALUE;

@RestController
@RequestMapping("/project")
Expand All @@ -24,21 +23,21 @@ public ProjectController(final ProjectRepository projectRepository) {
this.projectRepository = projectRepository;
}

@RequestMapping(value = "/{id}", method = RequestMethod.POST, produces = IMAGE_PNG_VALUE)
@RequestMapping(value = "/{id}", method = RequestMethod.POST, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Project> create(@RequestHeader final HttpHeaders headers,
@RequestBody final Project project) throws Exception {
projectRepository.save(project);
return ResponseEntity.ok().build();
}

@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = IMAGE_PNG_VALUE)
@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Project> getById(@RequestHeader final HttpHeaders headers,
@PathVariable("id") final int id) throws Exception {
Optional<Project> result = projectRepository.findById(id);
return result.map(ResponseEntity::ok).orElseGet(() -> ResponseEntity.notFound().build());
}

@RequestMapping(value = "/all", method = RequestMethod.GET, produces = IMAGE_PNG_VALUE)
@RequestMapping(value = "/all", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Project>> getAll(@RequestHeader final HttpHeaders headers) throws Exception {
return ResponseEntity.ok(projectRepository.findAll());
}
Expand All @@ -56,7 +55,7 @@ public ResponseEntity<Project> addStage(@PathVariable("id") final int id,
return ResponseEntity.ok(result);
}

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = IMAGE_PNG_VALUE)
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Void> delete(@RequestHeader final HttpHeaders headers,
@PathVariable("id") final int id) throws Exception {
Optional<Project> result = projectRepository.findById(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.Optional;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.util.MimeTypeUtils.IMAGE_PNG_VALUE;

@RestController
@RequestMapping("/stage")
Expand All @@ -25,22 +24,22 @@ public StageController(final StageRepository stageRepository) {
this.stageRepository = stageRepository;
}

@RequestMapping(value = "/{id}", method = RequestMethod.POST, produces = IMAGE_PNG_VALUE)
@RequestMapping(value = "/{id}", method = RequestMethod.POST, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Stage> create(@RequestHeader final HttpHeaders headers,
@RequestBody final Stage stage) throws Exception {
stageRepository.save(stage);

return ResponseEntity.ok().build();
}

@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = IMAGE_PNG_VALUE)
@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Stage> getById(@RequestHeader final HttpHeaders headers,
@PathVariable("id") final int id) throws Exception {
Optional<Stage> result = stageRepository.findById(id);
return result.map(ResponseEntity::ok).orElseGet(() -> ResponseEntity.notFound().build());
}

@RequestMapping(value = "/all", method = RequestMethod.GET, produces = IMAGE_PNG_VALUE)
@RequestMapping(value = "/all", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Stage>> getAll(@RequestHeader final HttpHeaders headers) throws Exception {
return ResponseEntity.ok(stageRepository.findAll());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.Optional;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import static org.springframework.util.MimeTypeUtils.IMAGE_PNG_VALUE;

@RestController
@RequestMapping("/task")
Expand All @@ -27,20 +26,20 @@ public TaskController(final TaskRepository taskRepository) {
this.taskRepository = taskRepository;
}

@RequestMapping(value = "/{id}", method = RequestMethod.POST, produces = IMAGE_PNG_VALUE)
@RequestMapping(value = "/{id}", method = RequestMethod.POST, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Task> create(@RequestHeader final HttpHeaders headers,
@RequestBody final Task stage) throws Exception {
return ResponseEntity.ok(taskRepository.save(stage));
}

@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = IMAGE_PNG_VALUE)
@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Task> getById(@RequestHeader final HttpHeaders headers,
@PathVariable("id") final int id) throws Exception {
Optional<Task> result = taskRepository.findById(id);
return result.map(ResponseEntity::ok).orElseGet(() -> ResponseEntity.notFound().build());
}

@RequestMapping(value = "/all", method = RequestMethod.GET, produces = IMAGE_PNG_VALUE)
@RequestMapping(value = "/all", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<List<Task>> getAll(@RequestHeader final HttpHeaders headers) throws Exception {
return ResponseEntity.ok(taskRepository.findAll());
}
Expand Down

0 comments on commit e810561

Please sign in to comment.