Application
This commit is contained in:
34
application/pom.xml
Normal file
34
application/pom.xml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>ms-library</artifactId>
|
||||||
|
<groupId>org.example</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>application</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.example</groupId>
|
||||||
|
<artifactId>domain</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package org.example.controller;
|
||||||
|
|
||||||
|
import org.exemple.data.BookDto;
|
||||||
|
import org.exemple.ports.api.BookServicePort;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/book")
|
||||||
|
public class BookController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BookServicePort bookServicePort;
|
||||||
|
|
||||||
|
@PostMapping("/add")
|
||||||
|
public BookDto addBook(@RequestBody BookDto bookDto) {
|
||||||
|
return bookServicePort.addBook(bookDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
public BookDto updateBook(@RequestBody BookDto bookDto) {
|
||||||
|
return bookServicePort.updateBook(bookDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get/{id}")
|
||||||
|
public BookDto getBookByID(@PathVariable long id) {
|
||||||
|
return bookServicePort.getBookById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
public List<BookDto> getAllBooks() {
|
||||||
|
return bookServicePort.getBooks();
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete/{id}")
|
||||||
|
public void deleteBookByID(@PathVariable long id) {
|
||||||
|
bookServicePort.deleteBookById(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user