[英]Class diagram and administrator rights
As an exercise, I would like to create a forum in Java EE, using JSF. 作为练习,我想使用JSF在Java EE中创建一个论坛。
I'm a total nooby in class diagram. 我在课堂图中总是很高兴。
I can't figure out if I need to create a class for the administrators. 我无法弄清楚是否需要为管理员创建一个类。
For example, having a class User, then the admin class by inheritance. 例如,拥有类User,然后通过继承管理类。 In that way, admins could do everything users do.
通过这种方式,管理员可以完成用户所做的一切。 But my issue is that I want different level of admin.
但我的问题是我想要不同级别的管理员。 Let's say, moderator, super admin etc... So I could create a role attribute saying which rights within the admin he has.
让我们说,主持人,超级管理员等...所以我可以创建一个角色属性,说明他拥有的管理员中的权利。
But in that case, is it useful to create an admin class, I could just make a user class with this role attribute which will say if user or admin and which admin etc. 但是在这种情况下,创建一个管理类是否有用,我可以创建一个具有此角色属性的用户类,该用户类将说明用户或管理员以及哪个管理员等。
I'm a bit lost. 我有点迷茫。
Why do you need a different class? 你为什么需要一个不同的课程? The most usual approach is just have a
User
class (call it something else because many DB don't like it), and each user have several Roles
or Permissions
. 最常用的方法是拥有一个
User
类(称之为别的,因为许多DB不喜欢它),并且每个用户都有几个Roles
或Permissions
。
That said, most probably you should not deal with this from within your application. 也就是说,很可能你不应该在你的应用程序中处理这个问题。 Use the
JAAS
model and let the container deal with; 使用
JAAS
模型让容器处理; your only use in the application could be assigning roles to users. 您在应用程序中的唯一用途可能是为用户分配角色。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.