如何在grails中通过userId检查连接table中的一些数据?

How to check some data in a join table by userId in grails?

首先我想说我是 grails 的新手,也许这个问题看起来很简单,但我花了几个小时在这上面。

我正在尝试检查用户的过期数据是否已过期

Date currentDate = new Date(System.currentTimeMillis())
        def authRequest = Authentication.findAllByExpiresLessThan(currentDate)

通过up的方法,我可以得到一个列表中的所有用户,他的expires数据已经过期了。请注意,我得到了一个列表

我的问题来了,因为如果他的expires数据已经过期了,我需要把用户的状态改成REQUESTED => ACTIVE。这就是我不知道如何从我从 authRequest 请求的数据开始检查 grails,因为我可以在调试模式下看到我得到了所有具有对象的列,但不确定如何加入与另一个 table

This is table/domain user:
name|surname|status|user_id
bob   len    REQUESTED asdfwerrg
Marc  Marc   ACTIVE    jryut6u5u

This is table/domain authentication
expires             |  user_id
2016-04-17 11:38:50 | asdfwerrg
2016-05-10 11:38:50 | asdfwerrg

希望解释没问题,提前致谢

您可以使用

def user = User.findAllByUserIdInList(authRequest.userId.toList())

然后

user.each{
     it.status = "ACTIVE"
     it.save(flush:true)
}

详情请见http://grails.github.io/grails-doc/2.1.0/ref/Domain%20Classes/findAllBy.html

谢谢