我需要遍历组列表中的用户列表,如果用户列表中有组(来自组列表),我需要从用户列表中删除它。我试过以下但是没有用
def groupsList = entity.companyContainer.groups
groupsList.each { g ->
g.users.each { u ->
if( u.groups.find( g ) ) {
u.groups.remove( g )
entityService.update( u )
}
}
entityService.delete(g)
}
例外:
ERROR | com.core.common.controller.impl.BaseMultiActionController | groovy.lang.MissingMethodException:
No signature of method:
com.core.configuration.persistence.ListWithPersistentSetPropertyAccessor$ListWithPersistentSet.find()
is applicable for argument types: (com.core.security.model.impl.Group) values: [LFO Super Users_Lawfirm]
Possible solutions: find(groovy.lang.Closure),
find(groovy.lang.Closure),
min(),
min(groovy.lang.Closure),
min(java.util.Comparator),
size()
答案 0 :(得分:1)
虽然我不清楚逻辑的完整上下文,但你可以使用find{}
作为闭包操作得到你需要的东西,如下所示:
def groupsList = entity.companyContainer.groups
groupsList.each{ g ->
g.users.each {u ->
if(u.groups.find{it.id == g.id}) {
u.groups.remove(g)
entityService.update(u)
}
}
entityService.delete(g)
}