元數(shù)據(jù)管理—?jiǎng)討B(tài)表單設(shè)計(jì)器在crudapi系統(tǒng)中完整實(shí)現(xiàn)
表單設(shè)計(jì)
在前面文章中,我們通過(guò)一系列案例介紹了表單設(shè)計(jì)的一些基本功能,表單設(shè)計(jì)起到非常重要作用,也是crudapi核心,所以本文會(huì)詳細(xì)介紹表單設(shè)計(jì)中一些其它功能。
#
概要
#
表單字段column屬性
列英文名稱描述name英文名稱caption中文名稱autoIncrement是否自增長(zhǎng)description描述displayOrder序號(hào),UI中顯示的順序dataType數(shù)據(jù)類型,比如字符串、整數(shù)等seqId序列號(hào)ID,用于設(shè)置流水號(hào)indexName索引名稱indexStorage索引存儲(chǔ), 支持BTREE、HASHindexType索引類型,支持PRIMARY, UNIQUE, INDEX, FULLTEXTlength長(zhǎng)度precision精密度、精確(精度),表示該字段的有效數(shù)字位數(shù)scale刻度、數(shù)值范圍,表示該字段的小數(shù)位數(shù)nullable是否可為空unsigned是否無(wú)符號(hào)insertable是否可插入queryable是否可查詢systemable是否系統(tǒng)字段updatable是否可修改createdDate創(chuàng)建時(shí)間lastModifiedDate修改時(shí)間
以上屬性不是所有的都同時(shí)有效,比如unsigned只有在dataType為數(shù)字的時(shí)候才有效,為字符串的時(shí)候會(huì)忽略,其它情況的類似。
#
系統(tǒng)字段
?創(chuàng)建表單的時(shí)候會(huì)默認(rèn)添加5個(gè)系統(tǒng)字段,分別是編號(hào)id,名稱name,全文索引fullTextBody,創(chuàng)建時(shí)間 createdDate和修改時(shí)間lastModifiedDate,以customer為例,系統(tǒng)字段json內(nèi)容如下:
[{
"autoIncrement": true,
"caption": "編號(hào)",
"createdDate": 1613181300985,
"dataType": "BIGINT",
"description": "主鍵",
"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": "名稱",
"createdDate": 1613181300985,
"dataType": "VARCHAR",
"description": "名稱",
"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": "全文索引",
"createdDate": 1613181300985,
"dataType": "TEXT",
"description": "全文索引",
"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": "創(chuàng)建時(shí)間",
"createdDate": 1613181300985,
"dataType": "DATETIME",
"description": "創(chuàng)建時(shí)間",
"displayOrder": 3,
"id": 256,
"insertable": false,
"lastModifiedDate": 1613182114133,
"name": "createdDate",
"nullable": false,
"queryable": false,
"systemable": true,
"unsigned": false,
"updatable": false
}]
#
唯一性索引
索引類型包括主鍵、全文、普通、唯一,全文索引之前已經(jīng)介紹過(guò)了,普通索引主要是為了提高查詢效率,這里主要介紹一下唯一性索引?
?客戶表mobile手機(jī)字段創(chuàng)建唯一性索引,表示手機(jī)號(hào)不允許重復(fù)
?添加客戶時(shí),錄入添加已經(jīng)存在的手機(jī)號(hào),提示重復(fù)錯(cuò)誤,和期望的一致,唯一性索引可以防止數(shù)據(jù)重復(fù)。
#
聯(lián)合索引
如果索引只有一個(gè)字段,在設(shè)置列屬性的時(shí)候直接設(shè)置。如果是多個(gè)字段聯(lián)合索引,就需要單獨(dú)設(shè)置了。這里可以創(chuàng)建普通或唯一兩種類型的聯(lián)合索引,通過(guò)下拉框選擇多個(gè)字段。?
?比如給customer設(shè)置一個(gè)聯(lián)合索引,最終得到的索引功能和之前單個(gè)字段索引類似。
#
附件
附件類型字段支持保存附件,主要是文檔、圖片等
?設(shè)置文件file表的url鏈接字段屬性為ATTACHMENT
?錄入數(shù)據(jù)時(shí)候,附件字段可以上傳文件,如果是圖片可以預(yù)覽。
#
表單設(shè)計(jì)API
?表單設(shè)計(jì)提供了API,如果默認(rèn)提供的后臺(tái)管理UI不適合,可以二次開(kāi)發(fā),重新設(shè)計(jì)UI,通過(guò)API管理表單,API文檔如下:
https://demo.crudapi.cn/swagger-ui.html(opens new window)
?Postman查詢customer表單元數(shù)據(jù)。
#
小結(jié)
本文介紹了表單設(shè)計(jì)完整功能,既可以通過(guò)UI配置實(shí)現(xiàn),也可以通過(guò)API進(jìn)行二次開(kāi)發(fā)。
#
附demo演示
本系統(tǒng)屬于產(chǎn)品級(jí)的零代碼平臺(tái),不同于自動(dòng)代碼生成器,不需要生成Controller、Service、Repository、Entity等業(yè)務(wù)代碼,程序運(yùn)行起來(lái)就可以使用,真正0代碼,可以覆蓋基本的和業(yè)務(wù)無(wú)關(guān)的CRUD RESTful API。
官網(wǎng)地址:https://crudapi.cn
測(cè)試地址:https://demo.crudapi.cn/crudapi/login
