Figure 28 Service implementation
In
the service layer, all the business logic will be handled
in those service classes, and each
service classes will integrate with mapper class and perform CRUD operations. Validation process will
also
be handle in the service layer, and customize exception will be
thrown when expected errors
happen.
2.2.7 Controller Layer
Figure 29 Controller classes
17
Figure 30 Controller implementation
In this application, we have different controller classes such as UserController, AddressController,
GoodController, CartController, and OrderController. Each controller will
handle different categories
of requests. As we can see in figure 30, there are multiple different requests related to the shopping cart,
and Service classes will be injected
into the controller classes, so we
usually call this feature
Dependency Injection.
18