With the help of a code generation tool, sponge, download here https://github.com/zhufuyi/sponge
(1) Creating a web service
Execute the command to generate a web service code, generated for use in real projects in production.
sponge web http \
--module-name=edusys \
--server-name=edusys \
--project-name=edusys \
--db-dsn=root:123456@(192.168.3.37:3306)/edusys \
--db-table=user \
--out=./edusys
(2) Batch add CRUD interface
Add the CRUD interface code for 20 mysql tables to the web service, execute the command.
sponge web handler \
--db-dsn=root:123456@(127.0.0.1:3306)/school \
--db-table=Fill in the mysql table name, separating multiple table names with commas \
--out=./edusys
Each mysql table has a corresponding 7 CRUD-related interfaces, generating a total of 140 interfaces, supporting paging, filtering, sorting and fuzzy queries.
(3) Start the service
# Generate swagger documentation
make docs
# Start the service
make run
After starting the service you can test the 140 interfaces on swagger.