|
@@ -28,6 +28,7 @@ import com.boman.web.core.service.update.IBaseUpdateService;
|
|
|
import com.boman.web.core.utils.IdUtils;
|
|
|
import com.google.common.base.Strings;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import org.apache.commons.collections4.MapUtils;
|
|
|
import org.apache.commons.lang3.BooleanUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -282,10 +283,46 @@ public class TableServiceCmdService {
|
|
|
fixedData = ifNullSetEmpty(fixedData);
|
|
|
Long id = fixedData.getLong(FormDataConstant.ID);
|
|
|
requireNonNull(id);
|
|
|
-
|
|
|
+ List<GenTableColumn> columns = genTable.getColumns();
|
|
|
// 默认查所有字段,不支持自定义
|
|
|
JSONObject jsonObject = selectService.selectById(genTable.getTableName(), pkName, id);
|
|
|
- return AjaxResult.success(jsonObject);
|
|
|
+ // name=username, value=zhangsan, type=input, types=[{},{}]
|
|
|
+ handlerDate(Collections.singletonList(jsonObject), columns);
|
|
|
+ List<JSONObject> result = packSingleObj(jsonObject, columns);
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 功能描述: 单对象查询,封装成此类型返给前台:name=username, value=zhangsan, type=input, types=[{},{}]
|
|
|
+ *
|
|
|
+ * @param jsonObject 数据库查出的字段名称对应字段值
|
|
|
+ * @param columns 该表对应的所有的字段的信息
|
|
|
+ * @return java.util.List<com.alibaba.fastjson.JSONObject>
|
|
|
+ */
|
|
|
+ private List<JSONObject> packSingleObj(JSONObject jsonObject, List<GenTableColumn> columns) {
|
|
|
+ if (MapUtils.isEmpty(jsonObject)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<JSONObject> result = Lists.newArrayListWithCapacity(jsonObject.size());
|
|
|
+ for (GenTableColumn column : columns) {
|
|
|
+ JSONObject map = new JSONObject();
|
|
|
+ for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
|
|
|
+ if (column.getColumnName().equalsIgnoreCase(entry.getKey())) {
|
|
|
+ map.put(SINGLE_OBJ_NAME, column.getColumnName());
|
|
|
+ map.put(SINGLE_OBJ_VALUE, entry.getValue());
|
|
|
+ String htmlType = column.getHtmlType();
|
|
|
+ map.put(SINGLE_OBJ_TYPE, htmlType);
|
|
|
+ if (NEED_QUERY_DICT_LIST.contains(htmlType)) {
|
|
|
+ map.put(SINGLE_OBJ_TYPES, remoteDictDataService.listByType(column.getDictType()));
|
|
|
+ }
|
|
|
+
|
|
|
+ result.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|