コード例 #1
0
  @Override
  public EasyuiDataGridJson datagrid(EasyuiDataGrid dg, String learningcenterId) {
    EasyuiDataGridJson listjson = new EasyuiDataGridJson();

    Example example = new Example(YztChoicenesscontentPic.class);
    Example.Criteria criteria = example.createCriteria();

    criteria.andEqualTo("yztChoicenesscontentId", learningcenterId);

    listjson.setTotal(selectCountByExample(example));
    // 分页查询
    PageHelper.startPage(dg.getPage(), dg.getRows());
    listjson.setRows(selectByExample(example));

    return listjson;
  }
コード例 #2
0
  @Override
  public EasyuiDataGridJson datagrid(EasyuiDataGrid dg, String learningcenterId) {
    EasyuiDataGridJson listjson = new EasyuiDataGridJson();

    Example example = new Example(YztLearningcenterComment.class);
    Example.Criteria criteria = example.createCriteria();

    criteria.andEqualTo("yztLearningcenterId", learningcenterId);
    // criteria.andEqualTo("parentid","0");

    String filterRules = dg.getFilterRules();
    if (filterRules != null && !"[]".equals(filterRules)) {
      List<FieldFilter> filtersr = JSON.parseArray(filterRules, FieldFilter.class);
      for (FieldFilter ft : filtersr) {
        // postparam.append(" and "+ft.getField()+" like '%"+ft.getValue().trim().replace(" ",
        // "%")+"%'  ");
        criteria.andLike(ft.getField(), "%" + ft.getValue().trim().replaceAll(" ", "%") + "%");
      }
    }
    // 加入排序
    if (dg.getSort() != null && dg.getOrder() != null) {
      String orderby = "";
      String[] order = dg.getSort().split(",");
      String[] sort = dg.getOrder().split(",");
      for (int i = 0; i < order.length; i++) {
        orderby += order[i] + " " + sort[i] + ",";
      }
      orderby = StringUtils.substringBeforeLast(orderby, ",");
      example.setOrderByClause(orderby);
    } else {
      example.setOrderByClause(" createtime desc ");
    }
    listjson.setTotal(selectCountByExample(example));
    // 分页查询
    PageHelper.startPage(dg.getPage(), dg.getRows());
    listjson.setRows(selectByExample(example));

    return listjson;
  }