如何管理应用程序中的网络导航信息?

发布于 2024-08-25 12:10:42 字数 317 浏览 3 评论 0原文

我正在构建一个应用程序,其中不同的用户将根据他们支付的费用有不同的菜单项可用。菜单层次结构也将有多个级别。

解决这个问题的最佳方法是什么?

我假设我需要一个表示菜单层次结构的数据库表,包括导航中节点的父子关系以及项目的排序。然后是另一个表,我用它来管理用户是否有权访问该表中的特定项目。

当我渲染视图时,我会引用菜单以及用户的访问权限来输出菜单,并且我还需要一个函数来检查每个控制器的相同授权,以防用户手动输入 URL他们不应该访问的控制器。

这是正确的方法吗?对于缓存此信息以防止不断查找此类信息有什么建议吗?我愿意接受有关您如何满足此类要求的任何建议。

I’m building an application where different users will have different menu items available to them depending on what they’ve paid for. There will also be multiple levels to the menu hierarchy.

What’s the best approach to this problem?

I’m assuming I need a database table that represents the menu hierarchy, including the parent-child relationships of the nodes in the navigation as well as the sorting of the items. Then another table which I use to manage whether a user is authorized to access a particular item in that table.

When I render the view, I’d reference the menus, and the access rights of the user to output the menu, and I’d also need a function to check that same authorization from each controller in case a user manually types in a URL of a controller they’re not supposed to have access to.

Is this the right approach? Any suggestions for caching this to prevent the constant look-ups of this type of info? I’m open to any suggestions on how you may have approached this type of requirement.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹉夏雨初晴づ 2024-09-01 12:10:48

当用户登录时,我会检查当时拥有的所有权限,然后将它们存储到他们的会话中。这样,您只需从数据库中查找它们一次。

否则,您处理菜单和每个控制器页面的方法似乎很好。

When a user logs in, I would check all the rights that have then, then store them into their session. This way, you only have to look them up from the database once.

Otherwise, your approach of handling the menu, and in each controller page, seems fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文