How to write a backend interface

3

 

1. The controller layer is used to accept front-end data and return page request information.
The control layer is responsible for the business process control of specific modules. It needs to call the interface of the service logic design layer to control the business process.
The controller performs business operations by receiving parameters passed from the front-end H5 or App, and then returns the processing results to the front-end.

public int UseLIUAdd(int name,String password) {
 userMapper.AddUser(name,password);
        System.err.println("1234");
        return "name";
    }

2. The service layer accepts controller layer information for business processing and logical judgment. Service is used to process business logic and will call the API of the mapper layer;

Servicelmpl is responsible for calling Service layer methods

public interface UserService {
    public String UserAdd(String name,String password);
    public String useglgyAdd(String name,String password);
}

3. Mapper layer (data persistence layer, specially used to deal with the database) .
The mapper layer is used to interact with the database. If you want to access the database and operate, you can only access the data through the mapper layer. 

@Mapper
public interface UserMapper {

    @Insert("INSERT INTO user(name,password) VALUES(#{n1},#{p1})")
    int AddUser(@Param("n1") String name, @Param("p1") String password);
}

Guess you like

Origin blog.csdn.net/weixin_61728046/article/details/127418926
Recommended