|
@@ -80,51 +80,6 @@ public class TableServiceCmdService {
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(TableServiceCmdService.class);
|
|
|
|
|
|
-// private BaseTableDTO packTableDTO(BaseTableSaveDTO baseTableSaveDTO) {
|
|
|
-// BaseTableDTO baseTableDTO = new BaseTableDTO();
|
|
|
-// baseTableDTO.setFixedData(baseTableSaveDTO.getFixedData());
|
|
|
-// baseTableDTO.setObjId(baseTableSaveDTO.getObjId());
|
|
|
-// baseTableDTO.setTable(baseTableSaveDTO.getTable());
|
|
|
-// return baseTableDTO;
|
|
|
-// }
|
|
|
-
|
|
|
-// public final AjaxResult objectSave(BaseTableSaveDTO baseTableSaveDTO) {
|
|
|
-// AjaxResult result = AjaxResult.success();
|
|
|
-// BaseTableDTO baseTableDTO = packTableDTO(baseTableSaveDTO);
|
|
|
-// TableServiceContext context = TableServiceContext.createFrom(baseTableDTO);
|
|
|
-// // 拿到pkName和maxId
|
|
|
-// List<GenTableColumn> columns = context.getTable().getColumns();
|
|
|
-// String pkName = IdUtils.getPkName(columns);
|
|
|
-// requireNonNull(pkName, "主键名称为空");
|
|
|
-//
|
|
|
-// // 新增
|
|
|
-// if (ObjectUtils.ltZero(baseTableDTO.getObjId())) {
|
|
|
-// Long maxId = IdUtils.getMaxId(baseTableDTO.getTable(), pkName);
|
|
|
-// RowResult rowResult = saveService.insertRow(context.getRealTableName(), pkName, maxId, context.getRows().get(0), columns);
|
|
|
-// if (RowResult.checkSuccess(rowResult)) {
|
|
|
-// LOGGER.info("保存成功,封装到数据库的数据为: {}", JSON.toJSONString(rowResult.getData()));
|
|
|
-// } else {
|
|
|
-// LOGGER.error("保存失败,保持的原始数据为: {}", JSON.toJSONString(baseTableSaveDTO));
|
|
|
-// result = AjaxResult.error();
|
|
|
-// }
|
|
|
-// }else {
|
|
|
-// JSONObject commitData = context.getRows().get(0).getCommitData();
|
|
|
-//
|
|
|
-// // 编辑
|
|
|
-// int effective = updateService.updateByIdList(context, pkName
|
|
|
-// , Collections.singletonList(baseTableDTO.getObjId()), commitData);
|
|
|
-// if (effective > 0) {
|
|
|
-// LOGGER.info("修改成功,封装到数据库的数据为: {}", JSON.toJSONString(context.getRows().get(0).getCommitData()));
|
|
|
-// } else {
|
|
|
-// LOGGER.error("修改失败,前台传来的原始数据为: {}", JSON.toJSONString(context.getRows().get(0).getCommitData()));
|
|
|
-// result = AjaxResult.error();
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// return result;
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
public final AjaxResult objectSave(BaseTableSaveDTO dto) {
|
|
|
AjaxResult result = AjaxResult.success();
|
|
|
|
|
@@ -226,11 +181,11 @@ public class TableServiceCmdService {
|
|
|
// 拿到每个字段对应的查询类型,=、 like、 >、 <
|
|
|
GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, dto.getTable());
|
|
|
JSONObject fixedData = dto.getFixedData();
|
|
|
- checkColumn(fixedData, genTable.getColumns());
|
|
|
fixedData = ifNullSetEmpty(fixedData);
|
|
|
|
|
|
// 查询条件
|
|
|
JSONObject condition = ifNullSetEmpty(fixedData.getJSONObject(CONDITION));
|
|
|
+ checkColumn(condition, genTable.getColumns());
|
|
|
List<GenTableColumn> columns = genTable.getColumns();
|
|
|
// 封装好以后的查询条件
|
|
|
JSONObject packCondition = ifNullSetEmpty(packColCondition(columns, condition));
|
|
@@ -275,7 +230,7 @@ public class TableServiceCmdService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 功能描述: 处理外键
|
|
|
+ * 功能描述: 处理外键 todo 待优化
|
|
|
*
|
|
|
* @param result result
|
|
|
* @param columns 该表对应的所有的列
|
|
@@ -354,8 +309,13 @@ public class TableServiceCmdService {
|
|
|
for (GenTableColumn column : columns) {
|
|
|
String dictType = column.getDictType();
|
|
|
if (isNotEmpty(dictType) && jsonObject.containsKey(column.getColumnName())) {
|
|
|
- String dictLabel = remoteDictDataService.selectDictLabel(dictType, jsonObject.getString(column.getColumnName()));
|
|
|
- jsonObject.put(column.getColumnName(), dictLabel);
|
|
|
+ String dictLabel = null;
|
|
|
+ try {
|
|
|
+ dictLabel = remoteDictDataService.selectDictLabel(dictType, jsonObject.getString(column.getColumnName()));
|
|
|
+ jsonObject.put(column.getColumnName(), dictLabel);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|