Ejemplo n.º 1
0
 public Page<BlogComment> search(BlogCommentQuery query) {
   EnhancedRule rule = new EnhancedRule();
   setRule(rule, query);
   if (query != null) {
     rule.setOffset(query.getOffset());
     rule.setPageSize(query.pagesize);
   }
   return page(rule);
 }
Ejemplo n.º 2
0
 public EnhancedRule setRule(EnhancedRule rule, BlogCommentQuery query) {
   if (query != null) {
     if (query.name != null) {
       rule.add(Restrictions.like("name", query.name, MatchMode.ANYWHERE));
     }
     if (query.content != null) {
       rule.add(Restrictions.like("content", query.content, MatchMode.ANYWHERE));
     }
     if (query.email != null) {
       rule.add(Restrictions.like("email", query.email, MatchMode.ANYWHERE));
     }
     if (query.im != null) {
       rule.add(Restrictions.like("im", query.im, MatchMode.ANYWHERE));
     }
     if (query.ip != null) {
       rule.add(Restrictions.like("ip", query.ip, MatchMode.ANYWHERE));
     }
     if (query.website != null) {
       rule.add(Restrictions.like("website", query.website, MatchMode.ANYWHERE));
     }
     if (query.userId != null) {
       rule.add(Restrictions.eq("user.id", query.userId));
     }
     if (query.blogId != null) {
       rule.add(Restrictions.eq("blog.id", query.blogId));
     }
     if (query.getOrder() != null) {
       rule.addOrder(query.getDesc() ? Order.desc(query.getOrder()) : Order.asc(query.getOrder()));
     }
   }
   return rule;
 }