简体   繁体   English

JAVA存储选项

[英]JAVA storage options

Ok I have a reservation object which stores all details of event for which the reservation is made. 好的,我有一个保留对象,其中存储了要进行保留的事件的所有详细信息。 Now for an event to be approved, it has to be viewed by three different users. 现在要批准一个事件,必须由三个不同的用户查看。 Each time a reservation is made, those three should be assigned. 每次进行预订时,应分配这三个。 Now when the reservation request is reviewed by any of the three, and a response is given, that user has to be marked that he responded. 现在,当三者中的任何一个审查预订请求并给出响应时,都必须将该用户标记为已响应。

I need to store the following like 我需要存储以下内容

User1 ----> Response & Type & ID
User2 ----> Response & Type & ID
User3 ----> Response & Type & ID

So when user1 for example reviews and accepts, then i access this way 因此,例如当user1审核并接受时,我将以这种方式访问

 reservationInstance.approvers.user1.response(true);

just an example of course and not practical code. 只是一个示例,而不是实用的代码。 What would the best suggestion be? 最好的建议是什么? and can there be code provided for clarification? 是否可以提供代码进行澄清? I will work on its customization 我将致力于其定制

your Reservation doesn't have to have a List/Set of approvers, one is enough. 您的预订不必具有批准者列表/一套,一个就足够了。 since you mentioned: 由于您提到:

Now when the reservation request is reviewed by any of the three, and a response is given, that user has to be marked that he responded. 现在,当三者中的任何一个审查预订请求并给出响应时,都必须将该用户标记为已响应。

Reservation could have an Approver attribute, which would be the Type User, to store which user has reviewed this reservation and gave response. 预订可以具有一个批准者属性,即“类型用户”,以存储哪个用户查看了此预订并给出了响应。 In database layer, this can be a foreign key to User table. 在数据库层中,这可以是User表的外键。

If you want to find out which user (1,2 or3) has viewed. 如果要找出哪个用户(1、2或3)已查看过。 just reservationInstance.getApprover().getUserId() (Assume your User class has a userId property.) 只是reservationInstance.getApprover().getUserId() (假设您的User类具有userId属性。)

EDIT 编辑

to make it clear based on comments: 根据评论明确说明:

you have a Reservation class: 您有一个预订班:

Reservation:
- Integer id
- User approver
- String content
- List<User> recievers
- String (could be enum) status (created, approved...etc.)

You have User class 您有用户类别

User:
- Integer id
- String name
- String foo
- ...

if I understood your requirement right: 如果我理解您的要求权利:

when a reservation instance was created, a set of Users as recievers were set. 创建预订实例时,设置了一组作为接收者的用户。 which means, those users will recieve the reservation. 这意味着这些用户将收到预订。 in your case, maybe 3 users. 在您的情况下,可能有3个用户。 here you sent email, fax, sms whatever to them. 在这里,您向他们发送了电子邮件,传真,短信。

Then, say user2 (id=2), opened it, and approved this reservation. 然后,说出user2(id = 2),打开它,并批准此保留。 The reservation.approver will be set as User object(id=2). Reservation.approver将被设置为User对象(id = 2)。 and status of this reservation (if there was a status requirement) will be changed to "Approved" or "Responsed"... 并且此预订的状态(如果有状态要求)将更改为“已批准”或“已响应” ...

I don't know what's your exact requirement, however hope this helps. 我不知道您的确切要求是什么,但是希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM