|
@@ -55,35 +55,28 @@ public class TableContext {
|
|
|
private List<GenTableColumn> columns;
|
|
|
|
|
|
public TableContext createContext(FormDataDto dto) {
|
|
|
- TableContext context = new TableContext();
|
|
|
+ this.actionType = ltZero(dto.getObjId()) ? ActionType.INSERT : ActionType.UPDATE;
|
|
|
+ this.id = dto.getObjId();
|
|
|
|
|
|
- context.setActionType(ltZero(dto.getObjId()) ? ActionType.INSERT : ActionType.UPDATE);
|
|
|
-
|
|
|
- context.setId(dto.getObjId());
|
|
|
- context.setFunctionName(table.getFunctionName());
|
|
|
+ RedisService redisService = SpringUtils.getBean(RedisService.class);
|
|
|
String tableName = requireNonNull(dto.getTable(), "tableName is empty");
|
|
|
- context.setTableName(tableName);
|
|
|
+ this.tableName = tableName;
|
|
|
|
|
|
- RedisService redisService = SpringUtils.getBean(RedisService.class);
|
|
|
GenTable table = redisService.getCacheObject(RedisKey.TABLE_INFO + tableName);
|
|
|
- context.setTable(requireNonNull(table, "redis中没有此表,表名: " + tableName));
|
|
|
+ this.table = requireNonNull(table, "redis中没有此表,表名: " + tableName);
|
|
|
+ this.functionName = table.getFunctionName();
|
|
|
|
|
|
JSONObject fixedData = requireNonNull(dto.getFixedData(), "fixedData is empty");
|
|
|
- context.setFixedData(fixedData);
|
|
|
+ this.fixedData = fixedData;
|
|
|
|
|
|
List<GenTableColumn> columns = table.getColumns();
|
|
|
- context.setColumns(columns);
|
|
|
-
|
|
|
- String pkName = IdUtils.getPkName(columns);
|
|
|
- context.setPkName(pkName);
|
|
|
+ this.columns = columns;
|
|
|
+ this.pkName = IdUtils.getPkName(columns);
|
|
|
|
|
|
// 检查权限
|
|
|
- checkAuthObjectSave(context);
|
|
|
-
|
|
|
- JSONObject commitData = new JSONObject();
|
|
|
- packCommitData(context, columns, fixedData, commitData);
|
|
|
- context.setCommitData(commitData);
|
|
|
+ checkAuthObjectSave(this);
|
|
|
|
|
|
+ this.commitData = packCommitData(this, columns, fixedData);
|
|
|
return this;
|
|
|
|
|
|
}
|
|
@@ -110,7 +103,8 @@ public class TableContext {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private static void packCommitData(TableContext context, List<GenTableColumn> columns, JSONObject fixedData, JSONObject commitData) {
|
|
|
+ private static JSONObject packCommitData(TableContext context, List<GenTableColumn> columns, JSONObject fixedData) {
|
|
|
+ JSONObject commitData = new JSONObject();
|
|
|
// 过滤掉hr字段
|
|
|
columns = withoutHr(columns);
|
|
|
for (GenTableColumn column : columns) {
|
|
@@ -141,6 +135,8 @@ public class TableContext {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ return commitData;
|
|
|
}
|
|
|
|
|
|
/** get and set **/
|