1/14/2024 0 Comments Openapi generator enumIn the package rest we see the REST controllers with the CRUD endpoints. In the package domain we see the entities and repositories that form the ORM layer using Spring Data and Hibernate. Now we can already have a look at the current code with the "Explore" item. We can now select the new enum as the custom enum type at the Voucher entity in the corresponding field. For our example this enum gets the constants VALID, REDEEMED and CANCELLED. Since we would like to have a defined set of states for the field voucherStatus, we create an additional enum VoucherStatus in the tab "Data Objects". This is also shown to us immediately as an UML diagram in the preview. "Voucher" and "VoucherActivity" are in an easy to understand 1:N relation, which we also adding now. For this example dateCreated should be sufficient to track the date of the activity.įor both of our tables we are keeping the "Add REST endpoints" flag checked, so a REST API with simple CRUD operations is provided. All tables come automatically with a primary key and date fields (if the option has not been disabled on the "General" tab). Here we have the fields source (string) and changeValue (numeric). With this information provided, we can already save our first table.Īs second table we want to have a VoucherActivity. We also change the type of our two value fields to numeric. All fields are required, whereby the voucherCode is also unique. In the tab "Entities" we create the first table Voucher with the fields voucherStatus, voucherCode, initialValue and currentValue. Let us now come to the core of our application, the tables. So apart from the name, we have not changed any of the default settings here. Therefore we stay with liquibase and changelogs for our schema will be provided.įurther dependencies are not needed for our simple example. The schema generation can be done using Hibernate ( ddl-auto: update), but this is not recommended for production usage. Here you can choose your database - you can find MySQL, MS SQL and Derby among others. On the first tab "General" there are settings like the project name, build type (Maven/Gradle) or enabling lombok. With this we are directly within the creation of our App. With "Start Project" on Bootify.io a new project is created, which is stored under its own URL. Select your preferred setup with Thymeleaf and Bootstrap/TailwindCSS and enable CRUD options for your entities. Update 2022: Bootify now also provides a frontend option. In this article we want to create a small example application for managing vouchers using Bootify. With the Spring Initializr we can create a basic project structure, but Bootify.io goes one step further: we define our own database schema, with all entities accessible through a simple REST API.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |