Top n 动态查询
- 作者: 邢一珊的经纪人
- 来源: 51数据库
- 2022-08-17
def bjSectionInstance = BjSection.get(params.id)
if (!bjSectionInstance) {
flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'bjSection.label', default: 'BjSection'), params.id])}"
redirect(action: "list")
}
else {
bjSectionInstance.bjSubjects.each {
//查询效率??? n+1 ~
it.bjArticles = BjArticle.findAllByAuditAndBjSubject('true',it, [max:10,order:'asc' ,sort: 'dateIssued'])
}
[bjSectionInstance: bjSectionInstance]
}
推荐阅读
