0

我需要遍历组列表中的用户列表,如果用户列表有组(来自组列表),我需要从用户列表中删除它。我尝试了以下但它不工作

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$ListWit‌​hPersistentSet.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()
4

1 回答 1

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)
}
于 2013-11-13T00:26:33.707 回答