The role of DAO layer, Service layer, Controller layer

DAO layers:

The DAO layer is mainly to do the work of the data persistence layer. Some tasks responsible for communicating with the database are encapsulated here. The design of the DAO layer is to first design the DAO interface, and then define the implementation class of this interface in the Spring configuration file, and then You can call this interface in the module to process data services without worrying about the specific implementation class of this interface. The structure is very clear. The data source configuration of the DAO layer and the parameters related to the database connection are all in Spring. Configure in the configuration file.

Service layer:

The Service layer is mainly responsible for the logical application design of business modules. The same is to design the interface first, then design the class that it implements, and then configure the association of its implementation in the Spring configuration file. In this way, we can call the Service interface in the application for business processing. The service implementation of the Service layer specifically calls to the interface of the defined DAO layer. Encapsulating the business logic of the Service layer is conducive to the independence and reusability of the general business logic, and the program appears very concise.

Controller layer:

The Controller layer is responsible for the control of specific business module processes. In this layer, the interface of the Serice layer is called to control the business process. The configuration of the control is also carried out in the Spring configuration file. For specific business processes, there will be different Controller, in our specific design process, we can abstract the process and design sub-unit process modules that can be reused. This not only makes the program structure clear, but also greatly reduces the amount of code.

Guess you like

Origin blog.csdn.net/gsy_csdn1/article/details/114769930