Create Module
Since the new project already contains the module
test-party
, taketest-todo
as an example to demonstratecreate module
. The moduletest-party
will still be used as an example for subsequent demonstrations
If you want to create a new module test todo
, you can enter the project path and run the scaffold command:
$ cd cabloy-demo
$ npm init cabloy src/module/test-todo --type=module-business
Two module templates
are currently available:
Name | Description |
---|---|
module-business | this template creates business-related code that greatly simplifies the workload |
module | this template contains only the basic skeleton code files |
Naming Convention
In order to increase the business modules continuously and achieve a highly reusable effect, the namespace of all modules must be fully isolated, to avoid mutual pollution and conflict. Thus the naming convention is as follows:
egg-born-module-{providerId}-{moduleName}
Name | Description |
---|---|
providerId | the unique id of provider: Github’s Username is strongly recommended to ensure that modules contributed to the community do not conflict |
moduleName | the name of module |
Based on this naming convention, module-related resources are referenced at the frontend and backend as follows:
Module egg-born-module-test-party
as example:
Name | Description |
---|---|
providerId | test |
moduleName | party |
fullName | egg-born-module-test-party |
relativeName | test-party |
frontend page route url | /test/party/{page} |
backend api route url | /test/party/{controller}/{action} |
Restart Services
$ npm run dev:backend
$ npm run dev:front
Effect
Now the project has realized the features of create, delete, update, select and search
of Party
. It also has realized the features of star
and label
. At the same time, it has realized two menu items of Create Party
and Party List
, and had assigned the corresponding menu and data permissions to the user root
Next
Next, we gradually introduce some basic features and usage of the framework on the basis of the module test-party
Then we will go back and introduce how the features of create, delete, update, select and search
of Party
are realized, and how to add new features on this basis
Comments: