The recommended timeline for the whole module is 2 weeks.
- Add Comment entity with fields Id, Content(should have length from 5 to 255), NewsId, Created, Modified.
- Implement REST controllers for Author, News, Tag and Comment entities.
- Implement exception handler for REST controllers. Use @ControllerAdvice annotation.
- The REST controllers should support of CRUD operations for above mentioned objects.
- The REST controller methods should:
- Support retrieval of collection of authors, tags, news and comments using search criteria, pagination and sorting.
- Support retrieval of author, tag, news and comment by id.
- Support creation of author, tag, news and comment.
- Support modification of author, tag, news and comment.
- Support partial modification of author, tag, news and comment using PATCH HTTP Verb.
- Support deletion of author, tag, news and comment by id.
- Support retrieval of author by news id.
- Support retrieval of tags by news id.
- Support retrieval of comments by news id.
- Support retrieval of news by tag names, tag ids, author name, title, content (all params are optional and can be used in conjunction) [optional].
- Use versioning of REST controllers and their methods [optional].
- Use Data transfer objects DTO as input parameters (requests) and output result (response).
- Validate input parameters (requests) of REST controller methods.
Your ORM solution. Do not delete or move basic interfaces.
You may create your own REST controller interfaces on the base of the BaseController interface.
Use Spring Boot starter: org.springframework.boot:spring-boot-starter-web
for implementing REST functionality.
The system should expose CRUD operations for News, Author, Tag and Comments from the web module in the project:
-
Create News - fill only title, content, authorId, tag ids (optional) in news dto request and return created news, as dto response, http response status - 201.
-
Create Author - fill only name in author dto request and return created author, as dto response, http response status - 201.
-
Create Tag - fill only name in tag dto request and return created tag as dto response, http response status - 201.
-
Create Comment - fill only content and newsId in comment dto request and return created comment as dto response, http response status - 201.
-
Get All News – return list of news dtos using search criteria, pagination and sorting, http response status - 200.
-
Get All Authors – return list of authors dtos using search criteria, pagination and sorting, http response status - 200.
-
Get All Tags – return list of tag dtos using search criteria, pagination and sorting, http response status - 200.
-
Get All Comments – return list of comment dtos using search criteria, pagination and sorting, http response status - 200.
-
Get News by id – return news by provided id, http response status - 200.
-
Get Author by id – return author by provided id, http response status - 200.
-
Get Tag by id – return tag by provided id, http response status - 200.
-
Get Comment by id – return comment by provided id, http response status - 200.
-
Update News – update only title, content, authorId, tag ids [tag ids are optional] by provided news id and return updated news as dto, http response status - 200.
-
Update Author – update only name by provided author id and return updated author as dto, http response status - 200.
-
Update Tag – update only name by provided tag id and return updated tag as dto, http response status - 200.
-
Update Comment – update only content by provided comment id and return updated comment as dto, http response status - 200.
-
Delete News – delete news by provided news id and return no value, http response status - 204.
-
Delete Author – delete author by provided author id and return no value, http response status - 204.
-
Delete Tag – delete tag by provided tag id and return no value, http response status - 204.
-
Delete Comment – delete comment by provided comment id and return no value, http response status - 204.
-
Get Author by news id – return author as dto by provided news id, http response status - 200.
-
Get Tags by news id – return tags as list of dtos by provided news id, http response status - 200.
-
Get Comments by news id – return comments as list of dtos by provided news id, http response status - 200.
-
Get News by tag names, tag ids, author name, title, content (all params are optional and can be used in conjunction) – return news by provided params, http response status - 200. [optional].
All returned and received data should be like DTO type.
The mapping between the dto
and the model (domain object)
should be done at the service layer using any library.
For example: Mapstruct, Modelmapper.
All input parameters (requests) should be validated directly in business logic code via custom validation or spring functionality.
Note: to support your custom annotations and perform validation outside of business logic code you can use e.g. Aspects.
- Cover controller layer with JUnit tests using e.g. RestAssured Framework.
- Code should be clean and should not contain any “developer-purpose” constructions.
- App should be designed and written with respect to OOD, SOLID principles and best REST design practices.
- Clear layered structure should be used with responsibilities of each application layer defined.
- All business logic should be written in the module-service: mapping
model
todto
and vice versa, validation, etc. - Module-web should accept and return
dto
data transfer objects. - Controller methods that return collection of
dto
should support pagination and sorting. - Controllers and their methods should support versioning.
- Convenient error/exception should be implemented: all errors should be meaningful. Errors should
contain
errorMessage
anderrorCode
, whereerrorCode
is your custom code. - Application should be tested and pass all tests suites.
- Java 17 should be used.
- Gradle. Multi-module project. Spring Boot.
- Application packages root:
com.mjc.school
. - Java Code Convention is mandatory.
If you have finished task and would like to see the original solution of it written by our experts, write in #stage-3 channel about it. Access will be provided.