#tips : Before learning this tutorial, you have already set up the development environment by default
GitHub: https://github.com/YaoApp/demo-lms
Infra one-click deployment: https://letsinfra.com/openapp/demo-lms
yao init
The directory structure at this time is:├─apis├─data├─db├─flows├─libs├─logs├─models├─scripts├─tables├─ui└─yao└─icons
.env
file:# database configurationYAO_DB_AESKEY="KBPdcRn44LzykphsVM\*y"YAO_DB_DRIVER=mysqlYAO_DB_PRIMARY="root:123456@tcp(127.0.0.1:3306)/test?charset=utf8mb4&parseTime=True&loc=Local" # Main library connectionYAO_DB_SECONDARY="root:123456@tcp(127.0.0.1.100:3306)/test?charset=utf8mb4&parseTime=True&loc=Local" # Main library connection
Database field meaning: YAO_DB_PRIMARY=username:password@tcp(database ip:port)/database name??charset=utf8mb4&parseTime=True&loc=Local
After the configuration modification is completed, execute yao migrate
to see if an error is reported. If no error is reported, the connection is successful!
models/ccategory.mod.json
file and write the following content:models/book.mod.json
model file and associate the model category category
:yao migrate
command to migrate the data table, the following results appear, and you can see the corresponding data table in the database:Update schema model: category (category)Update schema model: xiang.user (xiang_user)Update schema model: xiang.menu (xiang_menu)Update schema model: xiang.workflow (xiang_workflow)Update schema model: book (book)✨DONE✨
/flows/menu.flow.json
:yao run flows.menu
and the following results appear, and you can see the corresponding data table in the database:Run: flows.menu--------------------------------------flows.menu Response--------------------------------------"done"--------------------------------------✨DONE✨
/app.json
file "admin": "/table/book"
, and change the first menu displayed after login to the book list:{"name": "Yao","short": "Yao","description": "Another yao app","option": {"nav_user": "xiang.user","nav_menu": "xiang.menu","hide_user": false,"hide_menu": false,"login": {"entry": {"admin": "/table/book"}}}}
tables/book.tab.json
The code is as follows:yao start
to see that the project has started running:WebSocket(0)---------------------------------Yao development---------------------------------Root /mnt/shared/testFrontend http://127.0.0.1:5099/Dashboard http://127.0.0.1:5099/xiang/login/adminAPI http://127.0.0.1:5099/apiListening 127.0.0.1:5099Watching: /mnt/shared/test/modelsWatching: /mnt/shared/test/scriptsWatching: /mnt/shared/test/apisWatching: /mnt/shared/test/libs✨LISTENING✨Watching: /mnt/shared/test/flowsWatching: /mnt/shared/test/tables
Open the browser to visit: http://127.0.0.1:5099/xiang/login/admin
Enter the default account xiang@iqka.com
and password A123456p+
to log in to the background to see the book list renderings:
tables/category.tab.json
code:Use ctrl+C
on the command line to stop the Yao service, then execute yao start
to restart the service, open the browser to refresh the page, and click the category menu:
apis/select.http.json
:{"name": "Drop down search","version": "1.0.0","description": "Drop down search","guard": "bearer-jwt","group": "select","paths": [{"path": "/category","method": "GET","process": "flows.category","in": [],"out": {"status": 200,"type": "application/json"}}]}
flows/category.flow.json
file:{"label": "Category Tree","version": "1.0.0","description": "Category Tree","nodes": [{"name": "Category","engine": "xiang","query": {"select": ["id", "name", "name as label", "id as value", "parent_id"],"wheres": [{ ":deleted_at": "deleted", "=": null }],"from": "category","limit": 1000}},{"name": "Category Tree","process": "xiang.helper.ArrayTree","args": ["{{$res.category}}", { "parent": "parent_id" }]}],"output": "{{$res.category tree}}"}
tables/book.tab.json
, and adjust the layout of forms and add pages:#tips : Before learning this tutorial, you have already set up the development environment by default
GitHub: https://github.com/YaoApp/demo-lms
Infra one-click deployment: https://letsinfra.com/openapp/demo-lms
yao init
The directory structure at this time is:├─apis├─data├─db├─flows├─libs├─logs├─models├─scripts├─tables├─ui└─yao└─icons
.env
file:# database configurationYAO_DB_AESKEY="KBPdcRn44LzykphsVM\*y"YAO_DB_DRIVER=mysqlYAO_DB_PRIMARY="root:123456@tcp(127.0.0.1:3306)/test?charset=utf8mb4&parseTime=True&loc=Local" # Main library connectionYAO_DB_SECONDARY="root:123456@tcp(127.0.0.1.100:3306)/test?charset=utf8mb4&parseTime=True&loc=Local" # Main library connection
Database field meaning: YAO_DB_PRIMARY=username:password@tcp(database ip:port)/database name??charset=utf8mb4&parseTime=True&loc=Local
After the configuration modification is completed, execute yao migrate
to see if an error is reported. If no error is reported, the connection is successful!
models/ccategory.mod.json
file and write the following content:models/book.mod.json
model file and associate the model category category
:yao migrate
command to migrate the data table, the following results appear, and you can see the corresponding data table in the database:Update schema model: category (category)Update schema model: xiang.user (xiang_user)Update schema model: xiang.menu (xiang_menu)Update schema model: xiang.workflow (xiang_workflow)Update schema model: book (book)✨DONE✨
/flows/menu.flow.json
:yao run flows.menu
and the following results appear, and you can see the corresponding data table in the database:Run: flows.menu--------------------------------------flows.menu Response--------------------------------------"done"--------------------------------------✨DONE✨
/app.json
file "admin": "/table/book"
, and change the first menu displayed after login to the book list:{"name": "Yao","short": "Yao","description": "Another yao app","option": {"nav_user": "xiang.user","nav_menu": "xiang.menu","hide_user": false,"hide_menu": false,"login": {"entry": {"admin": "/table/book"}}}}
tables/book.tab.json
The code is as follows:yao start
to see that the project has started running:WebSocket(0)---------------------------------Yao development---------------------------------Root /mnt/shared/testFrontend http://127.0.0.1:5099/Dashboard http://127.0.0.1:5099/xiang/login/adminAPI http://127.0.0.1:5099/apiListening 127.0.0.1:5099Watching: /mnt/shared/test/modelsWatching: /mnt/shared/test/scriptsWatching: /mnt/shared/test/apisWatching: /mnt/shared/test/libs✨LISTENING✨Watching: /mnt/shared/test/flowsWatching: /mnt/shared/test/tables
Open the browser to visit: http://127.0.0.1:5099/xiang/login/admin
Enter the default account xiang@iqka.com
and password A123456p+
to log in to the background to see the book list renderings:
tables/category.tab.json
code:Use ctrl+C
on the command line to stop the Yao service, then execute yao start
to restart the service, open the browser to refresh the page, and click the category menu:
apis/select.http.json
:{"name": "Drop down search","version": "1.0.0","description": "Drop down search","guard": "bearer-jwt","group": "select","paths": [{"path": "/category","method": "GET","process": "flows.category","in": [],"out": {"status": 200,"type": "application/json"}}]}
flows/category.flow.json
file:{"label": "Category Tree","version": "1.0.0","description": "Category Tree","nodes": [{"name": "Category","engine": "xiang","query": {"select": ["id", "name", "name as label", "id as value", "parent_id"],"wheres": [{ ":deleted_at": "deleted", "=": null }],"from": "category","limit": 1000}},{"name": "Category Tree","process": "xiang.helper.ArrayTree","args": ["{{$res.category}}", { "parent": "parent_id" }]}],"output": "{{$res.category tree}}"}
tables/book.tab.json
, and adjust the layout of forms and add pages: