Noy Framework 2 gives ordinary users the permission to add, delete, modify and check menu settings

Continuing with the previous article, the previous article introduced how the Noy framework operates. This article introduces the simple operations of the Noy framework, using the code generator that comes with the framework to do some additions, deletions, modifications and checks. 1.
Currently, the code that the framework can generate is
Insert image description here2. Chapter 2 The first step requires us to create a table in the database, so that we can use the function of the Noy framework to automatically generate the addition, deletion, modification and query functions corresponding to the table we created.
—I created a new teacher table here

CREATE TABLE `teacher` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `teacher_name` varchar(30) DEFAULT '' COMMENT '老师姓名',
  `teacher_num` varchar(30) DEFAULT '' COMMENT '工号',
  `address` varchar(500) DEFAULT '' COMMENT '家庭住址',
  `teacher_age` int(3) DEFAULT NULL COMMENT '年龄',
  `teacher_sex` char(1) DEFAULT '0' COMMENT '性别(0男 1女 2未知)',
  `teacher_birthday` datetime DEFAULT NULL COMMENT '生日',
  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='老师表';

Insert image description here3. We start the project and find the system tools - code generation - import
Insert image description hereand click Edit to change the settings related to the write page button. After setting up, click to generate the code.

Insert image description here

Insert image description here4. As needed, just put the generated code into your own project.
We can create a new folder to store the generated code and try to distinguish it from the system for subsequent development.
According to the official website manual, our service and sql related codes should Stored in the system,
Insert image description herewe can create a new folder to store it to facilitate subsequent modification and search.

Insert image description hereIt should be noted that the system automatically generates the system file. We created the teach file ourselves. The main import needs to be changed.
Insert image description hereInsert image description hereInsert image description here
Continue to change the mapper file. The automatically generated mapper file is stored in
Insert image description herethe path of the class we save in the project. Change
Insert image description here
5, next we integrate the controller part. The official website documents of this department are stored under the admin
Insert image description here. We need to change the import
Insert image description here6. Finally, put our automatically generated front-end page.
Similarly, we also need to change the system for all pages. teach, you can use ctrl+r to replace
Insert image description herethis. We are basically done. Now we log in to add a directory and menu and test it.

New

Insert image description hereThen it refreshes and it comes out

Insert image description hereThen create a new menu to manage the teacher class, that is, do some additions, deletions, modifications, and checks.
The request address and permission identification are as shown in the picture below.

Insert image description here

Insert image description hereFinally, we can add a piece of knowledge in the teacher management menu under the catalog teacher to add, delete, modify and check functions :
Insert image description here
Insert image description here

When we added the menu, we gave the request address, which is easy to understand, and also gave a permission @RequiresPermissions("teach:teacher:view").
This permission is for different logged-in users to restrict them from viewing the teacher directory. This permission is in Insert image description hereOf course, we can also modify user permissions on the database table on the page, such as adding permissions to manage teachers for ordinary users [click Modify to add the corresponding permissions]

Insert image description hereIf the corresponding permissions are added, they will also be reflected in the database table, such as:

Insert image description here

Insert image description hereInsert image description hereInsert image description hereIn the same way, when we perform corresponding operations on the page, its permissions will also be added to the corresponding database. For example:
we add a button under the menu under the teacher directory to query teachers .
Insert image description here
The corresponding database will have one more permission.
Insert image description hereAt this time, we only need If ordinary users are given the query permission, the corresponding database will also be added. At the same time, if we log in as an ordinary user, we can have the teacher's query function.
Insert image description here

At this time, we switch the user to ordinary users, which is perfect. Ordinary users also have the query function.
Insert image description here

Guess you like

Origin blog.csdn.net/qq_40579139/article/details/125638278