A simple CRUD with posts and comments with one-to-many association and unit ant integration test
To run this project, you will need to add the following variables.
For MySQL
spring.datasource.url
spring.datasource.username
spring.datasource.password
spring.jpa.properties.hibernate.dialect
For H2 database
spring.datasource.username
spring.datasource.password
Just clone the repository and change the application.properties values from your own.
You can use MySql and H2 databases at your choise
To start project just type this into the terminal
mvnw spring-boot:run
- 2 Entities Publications and Comments
- One-to-many relation between them
- Repository and Service interfaces
- Pagination for Publications
- Individual Controllers for each entity
- Unit and integration test for both Entities
GET /api/publications
Parameter | Type | Description |
---|---|---|
pageNo |
int |
Page number, default value '0' |
pageSize |
int |
Page size, default value '10' |
sortBy |
string |
Page number, default value 'id' |
sortDir |
string |
Page number, default value 'asc' |
GET /api/publications/${id}
Parameter | Type | Description |
---|---|---|
id |
long |
Required. Id of item to fetch |
POST /api/publications
Body
Parameter | Type | Description |
---|---|---|
title |
string |
Required. publication title |
description |
string |
Required. publication description |
content |
string |
Required. publication content |
PUT /api/publications/${id}
Parameter | Type | Description |
---|---|---|
id |
long |
Required. Id of item to fetch |
Body
Parameter | Type | Description |
---|---|---|
title |
string |
Required. publication title |
description |
string |
Required. publication description |
content |
string |
Required. publication content |
DELETE /api/publications/${id}
Parameter | Type | Description |
---|---|---|
id |
long |
Required. Id of item to fetch |
GET /api/publications/{publicationId}/comments
Parameter | Type | Description |
---|---|---|
publicationId |
long |
Required. Id of publication |
GET /api/publications/{publicationId}/comments/{id}
Parameter | Type | Description |
---|---|---|
id |
long |
Required. Id of comment to fetch |
publicationId |
long |
Required. Id of publication |
POST /api/publications/{publicationId}/comments
Parameter | Type | Description |
---|---|---|
publicationId |
long |
Required. Id of publication |
Body
Parameter | Type | Description |
---|---|---|
name |
string |
Required. publication name |
email |
string |
Required. publication email |
body |
string |
Required. publication body |
PUT /api/publications/{publicationId}/comments/{id}
Parameter | Type | Description |
---|---|---|
id |
long |
Required. Id of comment to fetch |
publicationId |
long |
Required. Id of publication |
Body
Parameter | Type | Description |
---|---|---|
name |
string |
Required. publication name |
email |
string |
Required. publication email |
body |
string |
Required. publication body |
DELETE /api/publications/{publicationId}/comments/{id}
Parameter | Type | Description |
---|---|---|
id |
long |
Required. Id of comment to fetch |
publicationId |
long |
Required. Id of publication |