A hierarchical display of the department in which the current user is located. A user can add multiple departments of different levels.

problem description


the environmental background of the problems and what methods you have tried

I have only realized provinces, cities and counties. If there is a town under the county, and there are streets or townships under the town, is there anything that can be achieved without recursion? minimize database operations as far as possible, or take all the data out and use java recursion. Do you have any specific ways to achieve it?

Jun.18,2021

this kind of list that doesn't change often, you can consider caching

. In the case of

recursion, some databases support query statement recursion, and recursion in java is also very simple, but you should consider whether the data you return after recursion is a list or a nested tree.

find out that the cascading data is for display. If it is easy to find a tree plug-in such as ztree, it can help you recurse. The front end renders the father-son relationship, and your background select all is fine.


this is usually done with cache, and the performance is too poor every time

1:Redis
2:ServletContext
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ebac05-4727b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ebac05-4727b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?