
net.codebuilders.mybusiness.BlogService.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mybusiness Show documentation
Show all versions of mybusiness Show documentation
MyBusiness - a Grails 4.1 plugin for E-Commerce
The newest version!
package net.codebuilders.mybusiness
import org.springframework.transaction.annotation.Transactional
@Transactional(rollbackFor = Throwable.class, readOnly = true)
class BlogService {
List recentPosts(Integer resultsLimit = null) {
List> blogEntries = BlogEntry.withCriteria {
eq('published', true)
order("dateCreated", "desc")
if (resultsLimit) {
maxResults(resultsLimit)
}
projections {
property "title"
property "author"
property "dateCreated"
}
cache true
}
blogEntries.collect {
new BlogPostSummary(title: it[0], author: it[1], publishedOn: it[2])
}
}
}
class BlogPostSummary {
String title
String author
Date publishedOn
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy