[英]How to implement sharing ability in a Spring web app?
Kind of a higher level question here.I've got a web application that is fairly simple. 这里有一个更高级别的问题。我有一个相当简单的Web应用程序。 There are three seperate "objects" in the application.
应用程序中有三个单独的“对象”。 A Filter, an Authorization, and a Job.
过滤器,授权和作业。 Each Job has to have a Filter and an Authorization to run.
每个作业都必须有一个过滤器和一个授权来运行。
Now a user of this application can create any of these objects and they are all linked to that specific user. 现在,此应用程序的用户可以创建任何这些对象,并且它们都链接到该特定用户。 Now however, the requirements state that they'd like to implement sharing.
然而,现在,要求声明他们想要实现共享。 So a user can share their created items with other users.
因此,用户可以与其他用户共享他们创建的项目。 Honestly I'm just not sure of the best method to implement such a feature and am hoping someone can provide some ideas.
老实说,我只是不确定实现这样一个功能的最佳方法,并希望有人可以提供一些想法。
In the DB, each record has a user column that identifies the user who created it. 在DB中,每个记录都有一个用户列,用于标识创建它的用户。 I initially thought of adding a shareUser column, but that wouldn't really work since each record could be shared with multiple users.
我最初想过添加一个shareUser列,但由于每个记录可以与多个用户共享,所以这不会真正起作用。 I'm just not sure the best way to tie these all together.
我只是不确定将这些结合在一起的最佳方法。 Do I need an entirely new table in the DB that link's users to shared records?
在数据库中是否需要一个将用户链接到共享记录的全新表?
Any thoughts on this would be appreciated. 对此的任何想法将不胜感激。 Thank you.
谢谢。
Yes, you do need a new table for each type of record you need to be "owned". 是的,您需要为您需要“拥有”的每种类型的记录创建一个新表。 You should use cross reference tables for this case.
对于这种情况,您应该使用交叉引用表。
something like: 就像是:
userFilter
- userId
- filterId
If a user can only share a record they exist, you should have a createdByUserId
column on the particular table. 如果用户只能共享它们存在的记录,则应在特定表上具有
createdByUserId
列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.