|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.boman.common.core.constant.GenConstants;
|
|
|
import com.boman.common.core.utils.SecurityUtils;
|
|
|
+import com.boman.common.core.utils.StringUtils;
|
|
|
import com.boman.common.core.utils.array.ArrayUtils;
|
|
|
import com.boman.common.core.utils.collection.CollectionUtils;
|
|
|
import com.boman.common.core.utils.obj.ObjectUtils;
|
|
@@ -13,6 +14,7 @@ import com.boman.common.redis.RedisKey;
|
|
|
import com.boman.common.redis.service.RedisService;
|
|
|
import com.boman.domain.GenTable;
|
|
|
import com.boman.domain.GenTableColumn;
|
|
|
+import com.boman.domain.SysDictData;
|
|
|
import com.boman.domain.constant.*;
|
|
|
import com.boman.domain.dto.RoleMenuDto;
|
|
|
import com.boman.domain.exception.NoSuchFunctionException;
|
|
@@ -274,6 +276,10 @@ public class TableServiceCmdService {
|
|
|
|
|
|
List<JSONObject> result = selectService.selectByCondition(tableName, condition, packCondition, showData, dto);
|
|
|
result = filter(result, ObjectUtils::isNotEmpty);
|
|
|
+
|
|
|
+ // 查询时为null的列不显示的处理
|
|
|
+ handleNullColumnValue(result, showData);
|
|
|
+
|
|
|
// 处理blob
|
|
|
handleBlob(result, genTable.getIsContainsBlob());
|
|
|
// 处理日期、外键、字典值
|
|
@@ -306,34 +312,45 @@ public class TableServiceCmdService {
|
|
|
return getByTableName(tableName, columns, isUi);
|
|
|
}
|
|
|
|
|
|
- // 权限
|
|
|
- if (BooleanUtils.isFalse(checkAuthGetObject (genTable, id))) {
|
|
|
- throw new NoSuchFunctionException("不好意思,您无权限操作该条数据");
|
|
|
- }
|
|
|
-
|
|
|
- // 默认查所有字段,不支持自定义
|
|
|
+ List<GenTableColumn> updateVisibleColumns = filterData(columns, 2, MaskConstant.UPDATE_VISIBLE::equals);
|
|
|
+ List<String> showData = map(updateVisibleColumns, GenTableColumn::getColumnName);
|
|
|
String pkName = IdUtils.getPkName(genTable.getColumns());
|
|
|
- JSONObject json = selectService.selectById(tableName, pkName, id);
|
|
|
- requireNonNull(json, "id 为[" + id + "]的数据不存在, 表名为[" + tableName + "]");
|
|
|
- // 处理blob
|
|
|
- handleBlob(Collections.singletonList(json), genTable.getIsContainsBlob());
|
|
|
|
|
|
+ List<JSONObject> jsonList = selectService.selectByIdList(tableName, pkName, Lists.newArrayList(id), showData);
|
|
|
+ requireNonNull(jsonList, "id 为[" + id + "]的数据不存在, 模块为[" + genTable.getFunctionName() + "]");
|
|
|
+ // 查询时为null的列不显示的处理
|
|
|
+ handleNullColumnValue(jsonList, showData);
|
|
|
+ JSONObject json = jsonList.get(0);
|
|
|
+
|
|
|
+ // 处理blob
|
|
|
+ handleBlob(jsonList, genTable.getIsContainsBlob());
|
|
|
List<GenTableColumn> parentColumns = filterHrAndSort(columns);
|
|
|
+
|
|
|
+ //接收可能存在的cssClass
|
|
|
+ String cssClass = null;
|
|
|
// 处理成hr的形式
|
|
|
for (GenTableColumn hrColumn : parentColumns) {
|
|
|
List<GenTableColumn> children = Lists.newArrayListWithCapacity(16);
|
|
|
- for (GenTableColumn column : columns) {
|
|
|
+ for (GenTableColumn column : updateVisibleColumns) {
|
|
|
if (hrColumn.getId().equals(column.getHrParentId())) {
|
|
|
String columnName = column.getColumnName();
|
|
|
String columnType = column.getColumnType();
|
|
|
String htmlType = column.getHtmlType();
|
|
|
String dictType = column.getDictType();
|
|
|
if (containsKeyIgnoreCase(json, columnName)) {
|
|
|
+ column.setColumnValue(json.get(columnName));
|
|
|
// sysDict
|
|
|
if (isNotEmpty(dictType)) {
|
|
|
- // 既要sysDictData还得要columnValue
|
|
|
- column.setSysDictData(listSysDictDataByType(dictType));
|
|
|
- column.setColumnValue(json.get(columnName));
|
|
|
+ String value = json.getString(columnName);
|
|
|
+ List<SysDictData> sysDictData = column.getSysDictData();
|
|
|
+ if (sysDictData != null && sysDictData.size() > 0) {
|
|
|
+ for (SysDictData sysDictDatum : sysDictData) {
|
|
|
+ if (sysDictDatum.getDictValue().equals(value)) {
|
|
|
+ cssClass = sysDictDatum.getCssClass();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
// dateTime
|
|
|
if (NEED_CONVERT_DATE_LIST.contains(columnType)) {
|
|
@@ -347,8 +364,7 @@ public class TableServiceCmdService {
|
|
|
if (HTML_IMAGE_UPLOAD.equalsIgnoreCase(htmlType) || HTML_FILE_UPLOAD.equalsIgnoreCase(htmlType)) {
|
|
|
column.setAnnex(getAnnex(json.getString(columnName)));
|
|
|
}
|
|
|
-
|
|
|
- column.setReadonly(SubmitConstant.STATUS.equals(columnName));
|
|
|
+ //column.setReadonly(SubmitConstant.STATUS.equals(columnName));
|
|
|
}
|
|
|
|
|
|
children.add(column);
|
|
@@ -357,6 +373,12 @@ public class TableServiceCmdService {
|
|
|
hrColumn.setHrChildren(children);
|
|
|
}
|
|
|
|
|
|
+ //给基本属性和日志信息添加上cssClass
|
|
|
+ if (StringUtils.isNotBlank(cssClass)){
|
|
|
+ for (GenTableColumn parentColumn : parentColumns) {
|
|
|
+ parentColumn.setCssClass(cssClass);
|
|
|
+ }
|
|
|
+ }
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put(SHOW_DATA, parentColumns);
|
|
|
result.put(BUTTON_LIST, getButton(tableName));
|