No programming required, generate CRUD RESTful API by configuring zero code

Hello, crudapi! (Hello, add, delete, change and check the interface!)

This article uses the student object as an example, no programming is required, and CRUD RESTful API is realized through configuration.

Overview

Introduction to CRUD

Crud refers to the abbreviation of the initials of the words Add (Create), Retrieve (Retrieve), Update (Update) and Delete (Delete) when doing calculation processing. crud is mainly used to describe the basic operating functions of the database or persistence layer in a software system.

RESTfull API

REST (English: Representational State Transfer, REST for short) describes an architectural style network system, such as a web application. It first appeared in Roy Fielding's PhD thesis in 2000, Roy Fielding was one of the main authors of the HTTP specification. Among the three current mainstream web service interaction solutions, REST is simpler and clearer than SOAP (Simple Object Access Protocol) and XML-RPC. Whether it is URL processing or Payload encoding, REST is It tends to be designed and implemented in a simpler and lighter way. It is worth noting that REST does not have a clear standard, but is more like a design style implemented through RESTful API. The specific interface for students to operate is as follows

operating REST ACTION API
Add student POST /api/business/students
Get student details GET /api/business/students/id
Edit student PATCH /api/business/students/id
Delete student DELETE /api/business/students/id
Query student GET /api/business/students

Table design

Student field design

Design student table fields through the background metadata management UI, mainly including name, student ID, age, major and other fields

Basic attributes

Different object name that uniquely identifies an object, the object URL path for a plurality of resources, the physical name of the end of the table in the database table name
field properties include: name, type, index, length, precision
Student table design

More attributes

Including: whether it can be empty, the default value, whether it can be inserted, whether it can be edited, whether it can be queried, etc.
Student table design more fields

database

By viewing the mysql database, the student table ca_student has been generated
mysql ca_student

Swagger API documentation

https://demo.crudapi.cn/swagger-ui.html

Swagger

Take creation as an example: /api/business/{name}, where name is the plural form of the object name (compatible object name)

Business data

Verify API via post man

Create students

postman

Request URL
https://demo.crudapi.cn/api/business/students

Request body

{
    "name":"诸葛亮",
    "stuNo":"10000",
    "age":18,
    "major":"计算机科学与技术"
}

Return value 1 is id

Query the details of the student whose id is 1

getstudent

Request URL
https://demo.crudapi.cn/api/business/students/1

Return body

{
    "id": 1,
    "name": "诸葛亮",
    "createdDate": 1613013249000,
    "stuNo": "10000",
    "age": 18,
    "major": "计算机科学与技术"
}

Operate via UI

Create students

uicreate

Get a list of all students

uilist

Other operations

There are similar APIs for editing, deleting, etc. Just check the swap file!

summary

This article implements the RESTful CRUD API by configuring the form. The comparison with the traditional development method is as follows:

Method to realize Amount of code time stability
Traditional development About 1000 rows 2 days/person About 5 bugs
cruapi system 0 rows 1 minute Basically 0

In summary, the use of crudapi system can greatly improve work efficiency and save costs, and make data processing easier!

Attached demo

This system belongs to a product-level zero-code platform. It is different from an automatic code generator. It does not need to generate Controller, Service, Repository, Entity and other business codes. It can be used when the program is running. The real zero code can cover basic and business-independent CRUD RESTful API.

Official website address:https://crudapi.cn
test address:https://demo.crudapi.cn/crudapi/login

Guess you like

Origin blog.51cto.com/15149911/2676391