Grails:如何使用@BindUsing进行属具属性

时间:2018-07-13 08:03:38

标签: grails

我有一个域对象,其结构如下-

`

class TaxPlan {

    String taxCode
    String description
    Double taxRate
    Timestamp dateCreated
    Timestamp lastUpdated

    static belongsTo = [location: Location]
}

我想优化“位置”属性以使用bindUsing注释。我怎么做?我想要类似下面的代码-

class TaxPlan {

    String taxCode
    String description
    Double taxRate
    Timestamp dateCreated
    Timestamp lastUpdated
    @BindUsing({
        obj, source ->

        Location.findByStoreNumber(source['location'])?:RequestContextHolder.currentRequestAttributes()?.session.location

    })
    static belongsTo = [location: Location]
}

0 个答案:

没有答案