Metadata management - complete implementation of dynamic form designer in crud API system

Form design

In the previous article, we introduced some basic functions of form design through a series of cases. Form design plays a very important role and is also the core of crud API. Therefore, this paper will introduce some other functions in form design in detail.

outline

Form field column property

Column English name describe
name English name
caption Chinese name
autoIncrement Self growth
description describe
displayOrder Sequence number, order displayed in UI
dataType Data type, such as string, integer, etc
seqId Serial number ID, used to set serial number
indexName Index name
indexStorage Index storage, supporting BTREE and HASH
indexType Index type, supporting PRIMARY, UNIQUE, INDEX, FULLTEXT
length length
precision Precision, precision (precision), indicating the number of significant digits of the field
scale Scale and numerical range, indicating the decimal places of the field
nullable Can it be blank
unsigned Is it unsigned
insertable Is it pluggable
queryable Can I query
systemable System field
updatable Modifiable
createdDate Creation time
lastModifiedDate Modification time

Not all of the above attributes are valid at the same time. For example, unsigned is valid only when dataType is a number and ignored when dataType is a string. Other situations are similar.

System field


When creating a form, five system fields will be added by default, namely number, id, name, full-text index, fullTextBody, creation time createdDate and modification time lastModifiedDate. Taking customer as an example, the content of the system field json is as follows:

[{
    "autoIncrement": true,
    "caption": "number",
    "createdDate": 1613181300985,
    "dataType": "BIGINT",
    "description": "Primary key",
    "displayOrder": 0,
    "id": 253,
    "indexType": "PRIMARY",
    "insertable": false,
    "lastModifiedDate": 1613182114133,
    "length": 20,
    "name": "id",
    "nullable": false,
    "queryable": false,
    "systemable": true,
    "unsigned": true,
    "updatable": false
}, {
    "autoIncrement": false,
    "caption": "name",
    "createdDate": 1613181300985,
    "dataType": "VARCHAR",
    "description": "name",
    "displayOrder": 1,
    "id": 254,
    "insertable": true,
    "lastModifiedDate": 1613182114133,
    "length": 200,
    "name": "name",
    "nullable": false,
    "queryable": true,
    "systemable": true,
    "unsigned": false,
    "updatable": true
}, {
    "autoIncrement": false,
    "caption": "Full text index",
    "createdDate": 1613181300985,
    "dataType": "TEXT",
    "description": "Full text index",
    "displayOrder": 2,
    "id": 255,
    "indexName": "ft_fulltext_body",
    "indexType": "FULLTEXT",
    "insertable": false,
    "lastModifiedDate": 1613182114133,
    "name": "fullTextBody",
    "nullable": true,
    "queryable": false,
    "systemable": true,
    "unsigned": false,
    "updatable": false
}, {
    "autoIncrement": false,
    "caption": "Creation time",
    "createdDate": 1613181300985,
    "dataType": "DATETIME",
    "description": "Creation time",
    "displayOrder": 3,
    "id": 256,
    "insertable": false,
    "lastModifiedDate": 1613182114133,
    "name": "createdDate",
    "nullable": false,
    "queryable": false,
    "systemable": true,
    "unsigned": false,
    "updatable": false
}]

Unique index

Index types include primary key, full-text, ordinary and unique. Full-text index has been introduced before. Ordinary index is mainly to improve query efficiency. Here we mainly introduce unique index

Create a unique index for the mobile phone field in the customer table, indicating that duplicate mobile phone numbers are not allowed


When adding a customer, enter and add the existing mobile phone number to prompt the repetition error, which is consistent with the expectation. The uniqueness index can prevent data duplication.

Joint index

If the index has only one field, set it directly when setting column properties. If it is a joint index of multiple fields, it needs to be set separately. Here, you can create common or only two types of joint indexes, and select multiple fields through the drop-down box.

For example, set a joint index for customer, and the resulting index function is similar to the previous single field index.

enclosure

The attachment type field supports saving attachments, mainly documents, pictures, etc


Set the url link field property of the file table to ATTACHMENT


When entering data, the attachment field can upload files. If it is a picture, it can be previewed.

Form design API


Form design provides API. If the background management UI provided by default is not suitable, you can redevelop and redesign the UI to manage forms through API. The API documents are as follows:
https://demo.crudapi.cn/swagger-ui.html


Postman queries the customer table cell data.

Summary

This paper introduces the complete function of form design, which can be realized through UI configuration or secondary development through API.

demo attached

The system is a product level zero code platform, which is different from the automatic code generator. It does not need to generate business codes such as Controller, Service, Repository and Entity. The program can be used when running. The real 0 code can cover the basic CRUD RESTful API irrelevant to the business.

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

Tags: api CRUD

Posted by garrywinkler on Thu, 14 Apr 2022 15:21:55 +0930