Generate CRUD api code directly from 20 mysql tables in one go and add it seamlessly to the web service code

With the help of a code generation tool, sponge, download here

(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@( \
  --db-table=user \

(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@( \
  --db-table=Fill in the mysql table name, separating multiple table names with commas \

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.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.