In development, it is very common to display corresponding data according to different departments or companies, but how to filter in jeesite4? In fact, the author has also considered in this respect. The official documents are directly encapsulated. Please refer to: Data Permission Call . The document also clearly points out that this is to give access permissions by checking in the background management system. This is a comparison. It's easy, create roles, set access permissions, assign users... What you need in the Java code is also mentioned in the documentation. Below I put my code map below
In the controller, add the filter before dropping the findList or get method (you have to add each):
Rewrite the addDataSccopeFilter method in the service:
In entity
It can be seen that he is associated with js_sys_employee. The associated key is the create_by field and emp_code in js_sys_employee. At the same time, js_sys_employee is also associated with js_sys_office and js_sys_company. The organization table and company table can be filtered according to these two. Here I give an example for the company to remember (create_by, update_by, create_time, update_time, status, remarks must be added when creating the table, and then generate the code) when you save the data, the framework will automatically automatically Save it in the create_by field. After the code is written like this, return to the management system, create a company or organization, create a role, assign users, and give user data permissions (our company or this organization). it is helpful for you