Create Module

Here take the module test-todo as an example to demonstrate create module. The module test-party will still be used as an example for subsequent demonstrations

If you want to create a new module test-todo, you can go to the project path and run the scaffold command:

  1. 1$ cd /path/to/project
  2. 2$ npm run cli :create:module test-todo -- --template=module-business --suite=
Name Description
moduleName Module Name, such as test-todo
template Template Name, such as module-business
suite Suite Name: A module can belong to a suite or exist independently
  • template: Three module templates are currently available:
Name Description
module-business this template creates business-related code that greatly simplifies the workload
module-business-details files related to master-details business are added on the basis of module-business
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:

  1. 1egg-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

  1. 1$ npm run dev:backend
  2. 2$ 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