grails中的条件动态查找器

Conditional Dynamic finder in grails

所以我需要像动态查找器这样的东西应该根据条件改变,让我用代码解释我的意思

下面的代码按状态和最后参加日期查找所有员工

    def employee = Employee.findAllByStatusAndLastDateAttended("INA",dateObject)

现在我在 Employee LastDateAttended 和 LastDateSigned 中有两个字段,现在我希望如果记录没有 LastDateAttended,那么它应该通过 LastDateSigned 找到,否则是 LastDateAttended,所以另一个条件就像

      def employee = Employee.findAllByStatusAndLastDateAttended("INA",dateObject)

我想加入并使用基于条件的查询,可以实现吗?如果可能请帮助

我认为条件查询在这里很有意义,如下所示

Employee.createCriteria().list{
 and{
     eq('status','INA')
     or {
        eq('lastDateAttended',dateObject)
        eq('lastDateSigned',dateObject)
     }
  }    
}
Employee.findAllByStatusOrLastDateAttendedOrStatusAndLastDateAttended("INA",dateObject)
Employee.list().findAll { emp-> 
     emp.status == "INA" && ( emp.lastDateAttended!=null?
         emp.lastDateAttended.equals(dateObject):emp.lastDateSigned.equals(dateObject)
       ) 
}