|
@@ -26,6 +26,7 @@ import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.requireNonNull;
|
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.requiredNonNull;
|
|
@@ -141,9 +142,18 @@ public class TableServiceCmdService {
|
|
|
JSONObject packCondition = packColCondition(columns, condition);
|
|
|
// 需要返回到前台的列
|
|
|
JSONArray showData = fixedData.getJSONArray(SHOW_DATA);
|
|
|
+ JSONObject rows = new JSONObject();
|
|
|
+ int total = selectService.countByCondition(genTable.getTableName(), condition, packCondition);
|
|
|
+ rows.put(FormDataConstant.PAGE_TOTAL, total);
|
|
|
+ if (total <= 0) {
|
|
|
+ rows.put(FormDataConstant.PAGE_ROWS, null);
|
|
|
+ return AjaxResult.success(rows);
|
|
|
+ }
|
|
|
+
|
|
|
List<JSONObject> result = selectService.selectByCondition(genTable.getTableName(), condition, packCondition
|
|
|
, showData, dto.getOrderBy(), dto.getLimit(), dto.getOffset());
|
|
|
- return AjaxResult.success(result);
|
|
|
+ rows.put(FormDataConstant.PAGE_ROWS, result);
|
|
|
+ return AjaxResult.success(rows);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -198,7 +208,7 @@ public class TableServiceCmdService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 功能描述: 获取表单查询字段和按钮
|
|
|
+ * 功能描述: 获取表单查询字段、按钮、表头
|
|
|
* 注意: 都是从redis中拿的,如果数据库和redis不一致,则需刷新一下redis
|
|
|
* 刷新的入口为 {@link MyController#loadTable(com.boman.gen.domain.GenTable)}
|
|
|
*
|
|
@@ -214,6 +224,7 @@ public class TableServiceCmdService {
|
|
|
|
|
|
List<GenTableColumn> columns = genTable.getColumns();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
+ // 查询字段
|
|
|
ArrayList<GenTableColumn> queryList = Lists.newArrayListWithCapacity(16);
|
|
|
for (GenTableColumn column : columns) {
|
|
|
if (GenTableColumn.IS_QUERY.equalsIgnoreCase(column.getIsQuery())) {
|
|
@@ -224,6 +235,12 @@ public class TableServiceCmdService {
|
|
|
jsonObject.put(FormDataConstant.QUERY_LIST, queryList);
|
|
|
// genTable.getMenuRole() 暂时数据库没有数据,
|
|
|
jsonObject.put(FormDataConstant.BUTTON_LIST, genTable.getMenuRole());
|
|
|
+
|
|
|
+ // 表头
|
|
|
+ List<GenTableColumn> tableHeadList = columns.stream()
|
|
|
+ .filter(genTableColumn -> GenTableColumn.IS_LIST.equals(genTableColumn.getIsList()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ jsonObject.put(FormDataConstant.TABLE_HEAD_LIST, tableHeadList);
|
|
|
return AjaxResult.success(jsonObject);
|
|
|
}
|
|
|
|