Init project
This commit is contained in:
commit
2dddff0199
38
.gitignore
vendored
Normal file
38
.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
7
.idea/encodings.xml
Normal file
7
.idea/encodings.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
17
.idea/misc.xml
Normal file
17
.idea/misc.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="openjdk-24" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
171
pom.xml
Normal file
171
pom.xml
Normal file
@ -0,0 +1,171 @@
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>ru.cft.booklib</groupId>
|
||||
<artifactId>cft-book-library</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<compiler-plugin.version>3.14.0</compiler-plugin.version>
|
||||
<maven.compiler.release>21</maven.compiler.release>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
|
||||
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
|
||||
<quarkus.platform.version>3.19.4</quarkus.platform.version>
|
||||
<skipITs>true</skipITs>
|
||||
<surefire-plugin.version>3.5.2</surefire-plugin.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${quarkus.platform.group-id}</groupId>
|
||||
<artifactId>${quarkus.platform.artifact-id}</artifactId>
|
||||
<version>${quarkus.platform.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-resteasy-jsonb</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-arc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-resteasy</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-junit5</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.18.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>2.0.1.Final</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>${quarkus.platform.group-id}</groupId>
|
||||
<artifactId>quarkus-maven-plugin</artifactId>
|
||||
<version>${quarkus.platform.version}</version>
|
||||
<extensions>true</extensions>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
<goal>generate-code</goal>
|
||||
<goal>generate-code-tests</goal>
|
||||
<goal>native-image-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<parameters>true</parameters>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||
<maven.home>${maven.home}</maven.home>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>${surefire-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<native.image.path>${project.build.directory}/${project.build.finalName}-runner
|
||||
</native.image.path>
|
||||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||
<maven.home>${maven.home}</maven.home>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Генератор контроллера. -->
|
||||
<plugin>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<version>7.8.0</version>
|
||||
<configuration>
|
||||
<inputSpec>${project.basedir}/src/main/resources/openapi/book-library.yaml</inputSpec>
|
||||
<generatorName>jaxrs-spec</generatorName>
|
||||
<apiPackage>ru.cft.booklib.controller</apiPackage>
|
||||
<modelPackage>ru.cft.booklib.model</modelPackage>
|
||||
<supportingFilesToGenerate>
|
||||
ApiUtil.java
|
||||
</supportingFilesToGenerate>
|
||||
<additionalProperties>interfaceOnly=true,useSwaggerAnnotations=false</additionalProperties>
|
||||
<configOptions>
|
||||
<library>quarkus</library>
|
||||
<delegatePattern>true</delegatePattern>
|
||||
<sourceFolder>src/main/java</sourceFolder>
|
||||
<implFolder>src/main/java</implFolder>
|
||||
</configOptions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>native</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>native</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<skipITs>false</skipITs>
|
||||
<quarkus.native.enabled>true</quarkus.native.enabled>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
||||
</project>
|
||||
25
src/main/java/ru/cft/booklib/Main.java
Normal file
25
src/main/java/ru/cft/booklib/Main.java
Normal file
@ -0,0 +1,25 @@
|
||||
package ru.cft.booklib;
|
||||
|
||||
import io.quarkus.runtime.Quarkus;
|
||||
import io.quarkus.runtime.QuarkusApplication;
|
||||
import io.quarkus.runtime.annotations.QuarkusMain;
|
||||
|
||||
@QuarkusMain
|
||||
public class Main {
|
||||
public static void main(String... args) {
|
||||
Quarkus.run(MyApp.class,
|
||||
(exitCode, exception) -> {
|
||||
// do whatever
|
||||
},
|
||||
args);
|
||||
}
|
||||
|
||||
public static class MyApp implements QuarkusApplication {
|
||||
|
||||
@Override
|
||||
public int run(String... args) throws Exception {
|
||||
Quarkus.waitForExit();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
src/main/java/ru/cft/booklib/controller/BooksApi.java
Normal file
22
src/main/java/ru/cft/booklib/controller/BooksApi.java
Normal file
@ -0,0 +1,22 @@
|
||||
package ru.cft.booklib.controller;
|
||||
|
||||
import jakarta.ws.rs.*;
|
||||
import ru.cft.booklib.model.Book;
|
||||
import ru.cft.booklib.model.BookCreate;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Path("/books")
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2025-03-24T21:29:52.803984263+07:00[Asia/Novosibirsk]", comments = "Generator version: 7.8.0")
|
||||
public interface BooksApi {
|
||||
|
||||
@POST
|
||||
@Consumes({"application/json"})
|
||||
@Produces({"application/json"})
|
||||
Book bookPost(@Valid @NotNull BookCreate bookCreate);
|
||||
|
||||
@GET
|
||||
@Produces({"application/json"})
|
||||
List<Book> booksGet();
|
||||
}
|
||||
22
src/main/java/ru/cft/booklib/controller/ReadersApi.java
Normal file
22
src/main/java/ru/cft/booklib/controller/ReadersApi.java
Normal file
@ -0,0 +1,22 @@
|
||||
package ru.cft.booklib.controller;
|
||||
|
||||
import jakarta.ws.rs.*;
|
||||
import ru.cft.booklib.model.Reader;
|
||||
import ru.cft.booklib.model.ReaderCreate;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Path("/readers")
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2025-03-24T21:29:52.803984263+07:00[Asia/Novosibirsk]", comments = "Generator version: 7.8.0")
|
||||
public interface ReadersApi {
|
||||
|
||||
@POST
|
||||
@Consumes({ "application/json" })
|
||||
@Produces({ "application/json" })
|
||||
Reader readerPost(@Valid @NotNull ReaderCreate readerCreate);
|
||||
|
||||
@GET
|
||||
@Produces({ "application/json" })
|
||||
List<Reader> readersGet();
|
||||
}
|
||||
21
src/main/java/ru/cft/booklib/controller/TransactionsApi.java
Normal file
21
src/main/java/ru/cft/booklib/controller/TransactionsApi.java
Normal file
@ -0,0 +1,21 @@
|
||||
package ru.cft.booklib.controller;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.ws.rs.*;
|
||||
import ru.cft.booklib.model.Transaction;
|
||||
import ru.cft.booklib.model.TransactionCreate;
|
||||
import java.util.List;
|
||||
|
||||
@Path("/transactions")
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2025-03-24T21:29:52.803984263+07:00[Asia/Novosibirsk]", comments = "Generator version: 7.8.0")
|
||||
public interface TransactionsApi {
|
||||
|
||||
@GET
|
||||
@Produces({ "application/json" })
|
||||
List<Transaction> transactionsGet();
|
||||
|
||||
@POST
|
||||
@Consumes({ "application/json" })
|
||||
@Produces({ "application/json" })
|
||||
Transaction transactionsPost(@NotNull TransactionCreate transactionCreate);
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package ru.cft.booklib.controller.impl;
|
||||
|
||||
import ru.cft.booklib.controller.BooksApi;
|
||||
import ru.cft.booklib.model.Book;
|
||||
import ru.cft.booklib.model.BookCreate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BooksApiImpl implements BooksApi {
|
||||
@Override
|
||||
public Book bookPost(BookCreate bookCreate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Book> booksGet() {
|
||||
var book = new Book();
|
||||
book.setId(1);
|
||||
book.setTitle("1984");
|
||||
|
||||
return List.of(book);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package ru.cft.booklib.controller.impl;
|
||||
|
||||
import ru.cft.booklib.controller.ReadersApi;
|
||||
import ru.cft.booklib.model.Reader;
|
||||
import ru.cft.booklib.model.ReaderCreate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReadersApiImpl implements ReadersApi {
|
||||
@Override
|
||||
public Reader readerPost(ReaderCreate readerCreate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Reader> readersGet() {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package ru.cft.booklib.controller.impl;
|
||||
|
||||
import ru.cft.booklib.controller.TransactionsApi;
|
||||
import ru.cft.booklib.model.Transaction;
|
||||
import ru.cft.booklib.model.TransactionCreate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TransactionsApiImpl implements TransactionsApi {
|
||||
@Override
|
||||
public List<Transaction> transactionsGet() {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction transactionsPost(TransactionCreate transactionCreate) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
180
src/main/java/ru/cft/booklib/model/Book.java
Normal file
180
src/main/java/ru/cft/booklib/model/Book.java
Normal file
@ -0,0 +1,180 @@
|
||||
package ru.cft.booklib.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Книга
|
||||
**/
|
||||
|
||||
@JsonTypeName("Book")
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2025-03-24T21:29:52.803984263+07:00[Asia/Novosibirsk]", comments = "Generator version: 7.8.0")
|
||||
public class Book {
|
||||
private String title;
|
||||
private @Valid List<String> authors = new ArrayList<>();
|
||||
private Integer year;
|
||||
private String genre;
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
**/
|
||||
public Book title(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("title")
|
||||
@NotNull public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@JsonProperty("title")
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Book authors(List<String> authors) {
|
||||
this.authors = authors;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("authors")
|
||||
@NotNull @Size(min=1)public List<String> getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
|
||||
@JsonProperty("authors")
|
||||
public void setAuthors(List<String> authors) {
|
||||
this.authors = authors;
|
||||
}
|
||||
|
||||
public Book addAuthorsItem(String authorsItem) {
|
||||
if (this.authors == null) {
|
||||
this.authors = new ArrayList<>();
|
||||
}
|
||||
|
||||
this.authors.add(authorsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Book removeAuthorsItem(String authorsItem) {
|
||||
if (authorsItem != null && this.authors != null) {
|
||||
this.authors.remove(authorsItem);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
**/
|
||||
public Book year(Integer year) {
|
||||
this.year = year;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("year")
|
||||
public Integer getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
@JsonProperty("year")
|
||||
public void setYear(Integer year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Book genre(String genre) {
|
||||
this.genre = genre;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("genre")
|
||||
public String getGenre() {
|
||||
return genre;
|
||||
}
|
||||
|
||||
@JsonProperty("genre")
|
||||
public void setGenre(String genre) {
|
||||
this.genre = genre;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Book id(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
@NotNull public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@JsonProperty("id")
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Book book = (Book) o;
|
||||
return Objects.equals(this.title, book.title) &&
|
||||
Objects.equals(this.authors, book.authors) &&
|
||||
Objects.equals(this.year, book.year) &&
|
||||
Objects.equals(this.genre, book.genre) &&
|
||||
Objects.equals(this.id, book.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(title, authors, year, genre, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Book {\n");
|
||||
|
||||
sb.append(" title: ").append(toIndentedString(title)).append("\n");
|
||||
sb.append(" authors: ").append(toIndentedString(authors)).append("\n");
|
||||
sb.append(" year: ").append(toIndentedString(year)).append("\n");
|
||||
sb.append(" genre: ").append(toIndentedString(genre)).append("\n");
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
160
src/main/java/ru/cft/booklib/model/BookCreate.java
Normal file
160
src/main/java/ru/cft/booklib/model/BookCreate.java
Normal file
@ -0,0 +1,160 @@
|
||||
package ru.cft.booklib.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Создание книги
|
||||
**/
|
||||
|
||||
@JsonTypeName("BookCreate")
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2025-03-24T21:29:52.803984263+07:00[Asia/Novosibirsk]", comments = "Generator version: 7.8.0")
|
||||
public class BookCreate {
|
||||
private String title;
|
||||
private @Valid List<String> authors = new ArrayList<>();
|
||||
private Integer year;
|
||||
private String genre;
|
||||
|
||||
/**
|
||||
**/
|
||||
public BookCreate title(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("title")
|
||||
@NotNull public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@JsonProperty("title")
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public BookCreate authors(List<String> authors) {
|
||||
this.authors = authors;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("authors")
|
||||
@NotNull @Size(min=1)public List<String> getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
|
||||
@JsonProperty("authors")
|
||||
public void setAuthors(List<String> authors) {
|
||||
this.authors = authors;
|
||||
}
|
||||
|
||||
public BookCreate addAuthorsItem(String authorsItem) {
|
||||
if (this.authors == null) {
|
||||
this.authors = new ArrayList<>();
|
||||
}
|
||||
|
||||
this.authors.add(authorsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
public BookCreate removeAuthorsItem(String authorsItem) {
|
||||
if (authorsItem != null && this.authors != null) {
|
||||
this.authors.remove(authorsItem);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
**/
|
||||
public BookCreate year(Integer year) {
|
||||
this.year = year;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("year")
|
||||
public Integer getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
@JsonProperty("year")
|
||||
public void setYear(Integer year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public BookCreate genre(String genre) {
|
||||
this.genre = genre;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("genre")
|
||||
public String getGenre() {
|
||||
return genre;
|
||||
}
|
||||
|
||||
@JsonProperty("genre")
|
||||
public void setGenre(String genre) {
|
||||
this.genre = genre;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
BookCreate bookCreate = (BookCreate) o;
|
||||
return Objects.equals(this.title, bookCreate.title) &&
|
||||
Objects.equals(this.authors, bookCreate.authors) &&
|
||||
Objects.equals(this.year, bookCreate.year) &&
|
||||
Objects.equals(this.genre, bookCreate.genre);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(title, authors, year, genre);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class BookCreate {\n");
|
||||
|
||||
sb.append(" title: ").append(toIndentedString(title)).append("\n");
|
||||
sb.append(" authors: ").append(toIndentedString(authors)).append("\n");
|
||||
sb.append(" year: ").append(toIndentedString(year)).append("\n");
|
||||
sb.append(" genre: ").append(toIndentedString(genre)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
98
src/main/java/ru/cft/booklib/model/Error.java
Normal file
98
src/main/java/ru/cft/booklib/model/Error.java
Normal file
@ -0,0 +1,98 @@
|
||||
package ru.cft.booklib.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Http ошибка
|
||||
**/
|
||||
|
||||
@JsonTypeName("Error")
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2025-03-24T21:29:52.803984263+07:00[Asia/Novosibirsk]", comments = "Generator version: 7.8.0")
|
||||
public class Error {
|
||||
private Integer code;
|
||||
private String message;
|
||||
|
||||
/**
|
||||
**/
|
||||
public Error code(Integer code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("code")
|
||||
@NotNull public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
@JsonProperty("code")
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Error message(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("message")
|
||||
@NotNull public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@JsonProperty("message")
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Error error = (Error) o;
|
||||
return Objects.equals(this.code, error.code) &&
|
||||
Objects.equals(this.message, error.message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(code, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Error {\n");
|
||||
|
||||
sb.append(" code: ").append(toIndentedString(code)).append("\n");
|
||||
sb.append(" message: ").append(toIndentedString(message)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
189
src/main/java/ru/cft/booklib/model/Reader.java
Normal file
189
src/main/java/ru/cft/booklib/model/Reader.java
Normal file
@ -0,0 +1,189 @@
|
||||
package ru.cft.booklib.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Читатель
|
||||
**/
|
||||
|
||||
@JsonTypeName("Reader")
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2025-03-24T21:29:52.803984263+07:00[Asia/Novosibirsk]", comments = "Generator version: 7.8.0")
|
||||
public class Reader {
|
||||
private String fullName;
|
||||
public enum GenderEnum {
|
||||
|
||||
MAN(String.valueOf("man")), FEMAIL(String.valueOf("femail"));
|
||||
|
||||
|
||||
private String value;
|
||||
|
||||
GenderEnum (String v) {
|
||||
value = v;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a String into String, as specified in the
|
||||
* <a href="https://download.oracle.com/otndocs/jcp/jaxrs-2_0-fr-eval-spec/index.html">See JAX RS 2.0 Specification, section 3.2, p. 12</a>
|
||||
*/
|
||||
public static GenderEnum fromString(String s) {
|
||||
for (GenderEnum b : GenderEnum.values()) {
|
||||
// using Objects.toString() to be safe if value type non-object type
|
||||
// because types like 'int' etc. will be auto-boxed
|
||||
if (java.util.Objects.toString(b.value).equals(s)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected string value '" + s + "'");
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static GenderEnum fromValue(String value) {
|
||||
for (GenderEnum b : GenderEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
}
|
||||
|
||||
private GenderEnum gender;
|
||||
private Integer age;
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
**/
|
||||
public Reader fullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("fullName")
|
||||
@NotNull public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
@JsonProperty("fullName")
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Reader gender(GenderEnum gender) {
|
||||
this.gender = gender;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("gender")
|
||||
public GenderEnum getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
@JsonProperty("gender")
|
||||
public void setGender(GenderEnum gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Reader age(Integer age) {
|
||||
this.age = age;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("age")
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
@JsonProperty("age")
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Reader id(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
@NotNull public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@JsonProperty("id")
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Reader reader = (Reader) o;
|
||||
return Objects.equals(this.fullName, reader.fullName) &&
|
||||
Objects.equals(this.gender, reader.gender) &&
|
||||
Objects.equals(this.age, reader.age) &&
|
||||
Objects.equals(this.id, reader.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(fullName, gender, age, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Reader {\n");
|
||||
|
||||
sb.append(" fullName: ").append(toIndentedString(fullName)).append("\n");
|
||||
sb.append(" gender: ").append(toIndentedString(gender)).append("\n");
|
||||
sb.append(" age: ").append(toIndentedString(age)).append("\n");
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
168
src/main/java/ru/cft/booklib/model/ReaderCreate.java
Normal file
168
src/main/java/ru/cft/booklib/model/ReaderCreate.java
Normal file
@ -0,0 +1,168 @@
|
||||
package ru.cft.booklib.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Добавление читателя
|
||||
**/
|
||||
|
||||
@JsonTypeName("ReaderCreate")
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2025-03-24T21:29:52.803984263+07:00[Asia/Novosibirsk]", comments = "Generator version: 7.8.0")
|
||||
public class ReaderCreate {
|
||||
private String fullName;
|
||||
public enum GenderEnum {
|
||||
|
||||
MAN(String.valueOf("man")), FEMAIL(String.valueOf("femail"));
|
||||
|
||||
|
||||
private String value;
|
||||
|
||||
GenderEnum (String v) {
|
||||
value = v;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a String into String, as specified in the
|
||||
* <a href="https://download.oracle.com/otndocs/jcp/jaxrs-2_0-fr-eval-spec/index.html">See JAX RS 2.0 Specification, section 3.2, p. 12</a>
|
||||
*/
|
||||
public static GenderEnum fromString(String s) {
|
||||
for (GenderEnum b : GenderEnum.values()) {
|
||||
// using Objects.toString() to be safe if value type non-object type
|
||||
// because types like 'int' etc. will be auto-boxed
|
||||
if (java.util.Objects.toString(b.value).equals(s)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected string value '" + s + "'");
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static GenderEnum fromValue(String value) {
|
||||
for (GenderEnum b : GenderEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
}
|
||||
|
||||
private GenderEnum gender;
|
||||
private Integer age;
|
||||
|
||||
/**
|
||||
**/
|
||||
public ReaderCreate fullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("fullName")
|
||||
@NotNull public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
@JsonProperty("fullName")
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public ReaderCreate gender(GenderEnum gender) {
|
||||
this.gender = gender;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("gender")
|
||||
public GenderEnum getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
@JsonProperty("gender")
|
||||
public void setGender(GenderEnum gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public ReaderCreate age(Integer age) {
|
||||
this.age = age;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("age")
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
@JsonProperty("age")
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ReaderCreate readerCreate = (ReaderCreate) o;
|
||||
return Objects.equals(this.fullName, readerCreate.fullName) &&
|
||||
Objects.equals(this.gender, readerCreate.gender) &&
|
||||
Objects.equals(this.age, readerCreate.age);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(fullName, gender, age);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ReaderCreate {\n");
|
||||
|
||||
sb.append(" fullName: ").append(toIndentedString(fullName)).append("\n");
|
||||
sb.append(" gender: ").append(toIndentedString(gender)).append("\n");
|
||||
sb.append(" age: ").append(toIndentedString(age)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
214
src/main/java/ru/cft/booklib/model/Transaction.java
Normal file
214
src/main/java/ru/cft/booklib/model/Transaction.java
Normal file
@ -0,0 +1,214 @@
|
||||
package ru.cft.booklib.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Выдача или возврат книги
|
||||
**/
|
||||
|
||||
@JsonTypeName("Transaction")
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2025-03-24T21:29:52.803984263+07:00[Asia/Novosibirsk]", comments = "Generator version: 7.8.0")
|
||||
public class Transaction {
|
||||
private Integer readerId;
|
||||
private Integer bookId;
|
||||
public enum ActionEnum {
|
||||
|
||||
BORROW(String.valueOf("borrow")), RETURN(String.valueOf("return"));
|
||||
|
||||
|
||||
private String value;
|
||||
|
||||
ActionEnum (String v) {
|
||||
value = v;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a String into String, as specified in the
|
||||
* <a href="https://download.oracle.com/otndocs/jcp/jaxrs-2_0-fr-eval-spec/index.html">See JAX RS 2.0 Specification, section 3.2, p. 12</a>
|
||||
*/
|
||||
public static ActionEnum fromString(String s) {
|
||||
for (ActionEnum b : ActionEnum.values()) {
|
||||
// using Objects.toString() to be safe if value type non-object type
|
||||
// because types like 'int' etc. will be auto-boxed
|
||||
if (java.util.Objects.toString(b.value).equals(s)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected string value '" + s + "'");
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static ActionEnum fromValue(String value) {
|
||||
for (ActionEnum b : ActionEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
}
|
||||
|
||||
private ActionEnum action;
|
||||
private Date date;
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* ID читателя
|
||||
**/
|
||||
public Transaction readerId(Integer readerId) {
|
||||
this.readerId = readerId;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("readerId")
|
||||
@NotNull public Integer getReaderId() {
|
||||
return readerId;
|
||||
}
|
||||
|
||||
@JsonProperty("readerId")
|
||||
public void setReaderId(Integer readerId) {
|
||||
this.readerId = readerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* ID книги
|
||||
**/
|
||||
public Transaction bookId(Integer bookId) {
|
||||
this.bookId = bookId;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("bookId")
|
||||
@NotNull public Integer getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
|
||||
@JsonProperty("bookId")
|
||||
public void setBookId(Integer bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Transaction action(ActionEnum action) {
|
||||
this.action = action;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("action")
|
||||
@NotNull public ActionEnum getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
@JsonProperty("action")
|
||||
public void setAction(ActionEnum action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Transaction date(Date date) {
|
||||
this.date = date;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("date")
|
||||
@NotNull public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
@JsonProperty("date")
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
/**
|
||||
* ID транзакции
|
||||
**/
|
||||
public Transaction id(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("id")
|
||||
@NotNull public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@JsonProperty("id")
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Transaction transaction = (Transaction) o;
|
||||
return Objects.equals(this.readerId, transaction.readerId) &&
|
||||
Objects.equals(this.bookId, transaction.bookId) &&
|
||||
Objects.equals(this.action, transaction.action) &&
|
||||
Objects.equals(this.date, transaction.date) &&
|
||||
Objects.equals(this.id, transaction.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(readerId, bookId, action, date, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Transaction {\n");
|
||||
|
||||
sb.append(" readerId: ").append(toIndentedString(readerId)).append("\n");
|
||||
sb.append(" bookId: ").append(toIndentedString(bookId)).append("\n");
|
||||
sb.append(" action: ").append(toIndentedString(action)).append("\n");
|
||||
sb.append(" date: ").append(toIndentedString(date)).append("\n");
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
192
src/main/java/ru/cft/booklib/model/TransactionCreate.java
Normal file
192
src/main/java/ru/cft/booklib/model/TransactionCreate.java
Normal file
@ -0,0 +1,192 @@
|
||||
package ru.cft.booklib.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Создание записи о выдаче или возврате книги
|
||||
**/
|
||||
|
||||
@JsonTypeName("TransactionCreate")
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2025-03-24T21:29:52.803984263+07:00[Asia/Novosibirsk]", comments = "Generator version: 7.8.0")
|
||||
public class TransactionCreate {
|
||||
private Integer readerId;
|
||||
private Integer bookId;
|
||||
public enum ActionEnum {
|
||||
|
||||
BORROW(String.valueOf("borrow")), RETURN(String.valueOf("return"));
|
||||
|
||||
|
||||
private String value;
|
||||
|
||||
ActionEnum (String v) {
|
||||
value = v;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a String into String, as specified in the
|
||||
* <a href="https://download.oracle.com/otndocs/jcp/jaxrs-2_0-fr-eval-spec/index.html">See JAX RS 2.0 Specification, section 3.2, p. 12</a>
|
||||
*/
|
||||
public static ActionEnum fromString(String s) {
|
||||
for (ActionEnum b : ActionEnum.values()) {
|
||||
// using Objects.toString() to be safe if value type non-object type
|
||||
// because types like 'int' etc. will be auto-boxed
|
||||
if (java.util.Objects.toString(b.value).equals(s)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected string value '" + s + "'");
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static ActionEnum fromValue(String value) {
|
||||
for (ActionEnum b : ActionEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
}
|
||||
|
||||
private ActionEnum action;
|
||||
private Date date;
|
||||
|
||||
/**
|
||||
* ID читателя
|
||||
**/
|
||||
public TransactionCreate readerId(Integer readerId) {
|
||||
this.readerId = readerId;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("readerId")
|
||||
@NotNull public Integer getReaderId() {
|
||||
return readerId;
|
||||
}
|
||||
|
||||
@JsonProperty("readerId")
|
||||
public void setReaderId(Integer readerId) {
|
||||
this.readerId = readerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* ID книги
|
||||
**/
|
||||
public TransactionCreate bookId(Integer bookId) {
|
||||
this.bookId = bookId;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("bookId")
|
||||
@NotNull public Integer getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
|
||||
@JsonProperty("bookId")
|
||||
public void setBookId(Integer bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public TransactionCreate action(ActionEnum action) {
|
||||
this.action = action;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("action")
|
||||
@NotNull public ActionEnum getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
@JsonProperty("action")
|
||||
public void setAction(ActionEnum action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public TransactionCreate date(Date date) {
|
||||
this.date = date;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("date")
|
||||
@NotNull public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
@JsonProperty("date")
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
TransactionCreate transactionCreate = (TransactionCreate) o;
|
||||
return Objects.equals(this.readerId, transactionCreate.readerId) &&
|
||||
Objects.equals(this.bookId, transactionCreate.bookId) &&
|
||||
Objects.equals(this.action, transactionCreate.action) &&
|
||||
Objects.equals(this.date, transactionCreate.date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(readerId, bookId, action, date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class TransactionCreate {\n");
|
||||
|
||||
sb.append(" readerId: ").append(toIndentedString(readerId)).append("\n");
|
||||
sb.append(" bookId: ").append(toIndentedString(bookId)).append("\n");
|
||||
sb.append(" action: ").append(toIndentedString(action)).append("\n");
|
||||
sb.append(" date: ").append(toIndentedString(date)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
13
src/main/resources/META-INF/config.json
Normal file
13
src/main/resources/META-INF/config.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"dateLibrary": "java8",
|
||||
"useJakartaEe": true,
|
||||
"hideGenerationTimestamp": true,
|
||||
"modelPackage": "com.model",
|
||||
"apiPackage": "com.model.rest",
|
||||
"invokerPackage": "com.model.rest",
|
||||
"serializableModel": true,
|
||||
"useTags": true,
|
||||
"useGzipFeature": true,
|
||||
"interfaceOnly": true,
|
||||
"java17" : true
|
||||
}
|
||||
262
src/main/resources/openapi/book-library.yaml
Normal file
262
src/main/resources/openapi/book-library.yaml
Normal file
@ -0,0 +1,262 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: Library Automation API
|
||||
description: API для автоматизации работы библиотеки
|
||||
version: 1.0.0
|
||||
contact:
|
||||
name: Max Rogov
|
||||
servers:
|
||||
- url: /api/v1
|
||||
description: Основной сервер API
|
||||
paths:
|
||||
/books:
|
||||
get:
|
||||
summary: Получить список книг
|
||||
operationId: booksGet
|
||||
security:
|
||||
- BasicAuth: []
|
||||
responses:
|
||||
'200':
|
||||
description: Список книг
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Books'
|
||||
'400':
|
||||
$ref: '#/components/responses/BadRequest'
|
||||
'401':
|
||||
$ref: '#/components/responses/Unauthorized'
|
||||
'403':
|
||||
$ref: '#/components/responses/Forbidden'
|
||||
'500':
|
||||
$ref: '#/components/responses/InternalServerError'
|
||||
post:
|
||||
summary: Добавить новую книгу
|
||||
operationId: bookPost
|
||||
security:
|
||||
- BasicAuth: []
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/BookCreate'
|
||||
responses:
|
||||
'201':
|
||||
description: Книга добавлена
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Book'
|
||||
'400':
|
||||
$ref: '#/components/responses/BadRequest'
|
||||
'401':
|
||||
$ref: '#/components/responses/Unauthorized'
|
||||
'403':
|
||||
$ref: '#/components/responses/Forbidden'
|
||||
'500':
|
||||
$ref: '#/components/responses/InternalServerError'
|
||||
/readers:
|
||||
get:
|
||||
summary: Получить список читателей
|
||||
operationId: readersGet
|
||||
security:
|
||||
- BasicAuth: []
|
||||
responses:
|
||||
'200':
|
||||
description: Список читателей
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Readers'
|
||||
'400':
|
||||
$ref: '#/components/responses/BadRequest'
|
||||
'401':
|
||||
$ref: '#/components/responses/Unauthorized'
|
||||
'403':
|
||||
$ref: '#/components/responses/Forbidden'
|
||||
'500':
|
||||
$ref: '#/components/responses/InternalServerError'
|
||||
post:
|
||||
summary: Добавить читателя
|
||||
operationId: readerPost
|
||||
security:
|
||||
- BasicAuth: []
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ReaderCreate'
|
||||
responses:
|
||||
'201':
|
||||
description: Читатель добавлен
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Reader'
|
||||
'400':
|
||||
$ref: '#/components/responses/BadRequest'
|
||||
'401':
|
||||
$ref: '#/components/responses/Unauthorized'
|
||||
'403':
|
||||
$ref: '#/components/responses/Forbidden'
|
||||
'500':
|
||||
$ref: '#/components/responses/InternalServerError'
|
||||
/transactions:
|
||||
get:
|
||||
summary: Получить список транзакций
|
||||
operationId: transactionsGet
|
||||
security:
|
||||
- BasicAuth: []
|
||||
responses:
|
||||
'200':
|
||||
description: Список транзакций
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Transactions'
|
||||
'400':
|
||||
$ref: '#/components/responses/BadRequest'
|
||||
'401':
|
||||
$ref: '#/components/responses/Unauthorized'
|
||||
'403':
|
||||
$ref: '#/components/responses/Forbidden'
|
||||
'500':
|
||||
$ref: '#/components/responses/InternalServerError'
|
||||
post:
|
||||
summary: Оформить выдачу/возврат книги
|
||||
operationId: transactionsPost
|
||||
security:
|
||||
- BasicAuth: []
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TransactionCreate'
|
||||
responses:
|
||||
'201':
|
||||
description: Транзакция зарегистрирована
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Transaction'
|
||||
'400':
|
||||
$ref: '#/components/responses/BadRequest'
|
||||
'401':
|
||||
$ref: '#/components/responses/Unauthorized'
|
||||
'403':
|
||||
$ref: '#/components/responses/Forbidden'
|
||||
'500':
|
||||
$ref: '#/components/responses/InternalServerError'
|
||||
components:
|
||||
securitySchemes:
|
||||
BasicAuth:
|
||||
type: http
|
||||
scheme: basic
|
||||
responses:
|
||||
BadRequest:
|
||||
description: Bad request
|
||||
Unauthorized:
|
||||
description: Unauthorized
|
||||
Forbidden:
|
||||
description: Forbidden
|
||||
InternalServerError:
|
||||
description: Internal Server Error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
schemas:
|
||||
Books:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Book'
|
||||
Book:
|
||||
description: Книга
|
||||
allOf:
|
||||
- properties:
|
||||
id:
|
||||
type: integer
|
||||
required: [id]
|
||||
- $ref: '#/components/schemas/BookCreate'
|
||||
BookCreate:
|
||||
description: Создание книги
|
||||
properties:
|
||||
title:
|
||||
type: string
|
||||
authors:
|
||||
type: array
|
||||
minItems: 1
|
||||
items:
|
||||
type: string
|
||||
year:
|
||||
type: integer
|
||||
genre:
|
||||
type: string
|
||||
required: [title, authors]
|
||||
Readers:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Reader'
|
||||
Reader:
|
||||
description: Читатель
|
||||
allOf:
|
||||
- properties:
|
||||
id:
|
||||
type: integer
|
||||
required: [id]
|
||||
- $ref: '#/components/schemas/ReaderCreate'
|
||||
ReaderCreate:
|
||||
description: Добавление читателя
|
||||
properties:
|
||||
fullName:
|
||||
type: string
|
||||
gender:
|
||||
type: string
|
||||
enum: [man, femail]
|
||||
x-enumNames: [man, femail]
|
||||
age:
|
||||
type: integer
|
||||
required: [fullName]
|
||||
Transactions:
|
||||
description: Список транзакций
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Transaction'
|
||||
Transaction:
|
||||
description: Выдача или возврат книги
|
||||
allOf:
|
||||
- properties:
|
||||
id:
|
||||
description: ID транзакции
|
||||
type: integer
|
||||
required: [id]
|
||||
- $ref: '#/components/schemas/TransactionCreate'
|
||||
TransactionCreate:
|
||||
description: Создание записи о выдаче или возврате книги
|
||||
properties:
|
||||
readerId:
|
||||
description: ID читателя
|
||||
type: integer
|
||||
bookId:
|
||||
description: ID книги
|
||||
type: integer
|
||||
action:
|
||||
type: string
|
||||
enum: [borrow, return]
|
||||
x-enumNames: [borrow, return]
|
||||
date:
|
||||
type: string
|
||||
format: date-time
|
||||
required: [readerId, bookId, action, date]
|
||||
Error:
|
||||
description: Http ошибка
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
message:
|
||||
type: string
|
||||
required: [code, message]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user