|
@@ -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;
|
|
@@ -204,7 +206,7 @@ public class TableServiceCmdService {
|
|
|
public AjaxResult objectLogicDelete(FormDataDto dto) {
|
|
|
requireNonNull(dto.getTable(), "tableName = [" + dto.getTable() + "] 此表不存在");
|
|
|
Long[] idArr = CollectionUtils.listToArray(dto.getIdList());
|
|
|
- requireNonNull(idArr);
|
|
|
+ requireNonNull(idArr, "objectLogicDelete idArr is empty");
|
|
|
|
|
|
// 拿到pkName
|
|
|
GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, dto.getTable());
|
|
@@ -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));
|
|
@@ -517,7 +539,7 @@ public class TableServiceCmdService {
|
|
|
List<Long> idList = map(commitData, jsonObject -> jsonObject.getLong(FormDataConstant.ID));
|
|
|
|
|
|
List<JSONObject> beforeList = selectService.selectByIdList(tableName, pkName, idList, Lists.newArrayList(pkName, STATUS));
|
|
|
- requireNonNull(beforeList);
|
|
|
+ requireNonNull(beforeList, "beforeList is empty");
|
|
|
|
|
|
for (JSONObject commitDatum : commitData) {
|
|
|
String dbStatus = getStatusFromFormData(commitDatum, beforeList);
|
|
@@ -581,8 +603,8 @@ public class TableServiceCmdService {
|
|
|
* @return 结果
|
|
|
*/
|
|
|
public List<JSONObject> isCustomized(String tableName, List<JSONObject> result, String action) {
|
|
|
- requireNonNull(tableName);
|
|
|
- requireNonNull(action);
|
|
|
+ requireNonNull(tableName, "tableName is empty");
|
|
|
+ requireNonNull(action, "action is empty");
|
|
|
if (result != null && result.size() > 0) {
|
|
|
//获取到服务名称
|
|
|
String triggerName = getTriggerName(tableName, action);
|
|
@@ -603,7 +625,7 @@ public class TableServiceCmdService {
|
|
|
*/
|
|
|
private String getTriggerName(String tableName, String action) {
|
|
|
GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, tableName);
|
|
|
- requireNonNull(genTable);
|
|
|
+ requireNonNull(genTable, "genTable empty");
|
|
|
if (action.equals(TriggerActionConstant.ACTION_CREATE)) {
|
|
|
return genTable.getTriggerCreate();
|
|
|
} else if (action.equals(TriggerActionConstant.ACTION_RETRIEVE)) {
|
|
@@ -627,7 +649,7 @@ public class TableServiceCmdService {
|
|
|
*/
|
|
|
public GenTable getTableFromRedisByTableName(String redisKeyPrefix, String tableName) {
|
|
|
tableName = tableName.trim().toLowerCase();
|
|
|
- String key = requireNonNull(redisKeyPrefix) + requireNonNull(tableName);
|
|
|
+ String key = requireNonNull(redisKeyPrefix, "redisKeyPrefix is empty") + requireNonNull(tableName, "tableName is empty");
|
|
|
GenTable genTable = redisService.getCacheObject(key);
|
|
|
if (ObjectUtils.isEmpty(genTable)) {
|
|
|
genTable = remoteGenTableService.getByTableName(tableName);
|