vendredi 10 juillet 2020

How to use MVC design pattern in a spring console application

I developed an application which gets the data from the user from the console and pass the data to the frontend and Spring rest api is used for that purpose. So now I want to rearrange the folder structure according to the MVC.
Here is how I've done it so far.

enter image description here

Controlller

BookController - Class with rest api to pass data to frontend

Model

Book - Parent class with variables and relevant methods
Novel - Child class with variables and relevant methods
Poems - Child class with variables and relevant methods
MyBookManager - BookManager interface implemented class which includes crud operations with mongoDB

View

BookManager - Interface related to MyBookManager
Console - Class which takes the input from users from the the console and calls methods in MyBookManager to save them to DB

Repository

BookRepository - Interface which extends MongoRepository

Other classes

BookStoreApplication - Class which includes the main method
ErrorHandle - Class which includes methods for validations

Aucun commentaire:

Enregistrer un commentaire