|
@@ -11,6 +11,7 @@ import com.boman.common.core.web.domain.AjaxResult;
|
|
|
import com.boman.common.redis.RedisKey;
|
|
|
import com.boman.common.redis.service.RedisService;
|
|
|
import com.boman.domain.SysDictData;
|
|
|
+import com.boman.gen.api.RemoteGenTableColumnService;
|
|
|
import com.boman.gen.api.RemoteGenTableService;
|
|
|
import com.boman.gen.controller.MyController;
|
|
|
import com.boman.gen.domain.GenTable;
|
|
@@ -18,6 +19,7 @@ import com.boman.gen.domain.GenTableColumn;
|
|
|
import com.boman.gen.domain.GenTableRelation;
|
|
|
import com.boman.system.api.RemoteDictDataService;
|
|
|
import com.boman.web.core.constant.FormDataConstant;
|
|
|
+import com.boman.web.core.constant.MaskConstant;
|
|
|
import com.boman.web.core.constant.SubmitConstant;
|
|
|
import com.boman.web.core.domain.*;
|
|
|
import com.boman.web.core.service.delete.IBaseDeleteService;
|
|
@@ -25,6 +27,7 @@ import com.boman.web.core.service.save.IBaseSaveService;
|
|
|
import com.boman.web.core.service.select.IBaseSelectService;
|
|
|
import com.boman.web.core.service.submit.IBaseSubmitService;
|
|
|
import com.boman.web.core.service.update.IBaseUpdateService;
|
|
|
+import com.boman.web.core.utils.ColumnUtils;
|
|
|
import com.boman.web.core.utils.IdUtils;
|
|
|
import com.google.common.base.Strings;
|
|
|
import com.google.common.collect.Lists;
|
|
@@ -44,6 +47,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.*;
|
|
|
import static com.boman.web.core.constant.FormDataConstant.*;
|
|
|
+import static com.boman.web.core.utils.ColumnUtils.*;
|
|
|
|
|
|
/**
|
|
|
* @author shiqian
|
|
@@ -71,6 +75,8 @@ public class TableServiceCmdService {
|
|
|
private RemoteDictDataService remoteDictDataService;
|
|
|
@Resource
|
|
|
private RemoteGenTableService remoteGenTableService;
|
|
|
+ @Resource
|
|
|
+ private RemoteGenTableColumnService remoteGenTableColumnService;
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(TableServiceCmdService.class);
|
|
|
|
|
@@ -225,8 +231,9 @@ public class TableServiceCmdService {
|
|
|
List<GenTableColumn> columns = genTable.getColumns();
|
|
|
// 封装好以后的查询条件
|
|
|
JSONObject packCondition = ifNullSetEmpty(packColCondition(columns, condition));
|
|
|
- // 需要返回到前台的列
|
|
|
- JSONArray showData = ifNullSetEmpty(fixedData.getJSONArray(SHOW_DATA));
|
|
|
+ // 需要返回到前台的列, 需要判断是否是列表展示, 4为判断列表是否可见
|
|
|
+ JSONArray showData = filterData(columns, 4, fixedData.getJSONArray(SHOW_DATA), MaskConstant.LIST_VISIBLE::equals);
|
|
|
+
|
|
|
JSONObject rows = new JSONObject();
|
|
|
int total = selectService.countByCondition(genTable.getTableName(), condition, packCondition);
|
|
|
rows.put(FormDataConstant.PAGE_TOTAL, total);
|
|
@@ -237,13 +244,52 @@ public class TableServiceCmdService {
|
|
|
|
|
|
List<JSONObject> result = selectService.selectByCondition(genTable.getTableName(), condition, packCondition
|
|
|
, showData, dto.getOrderBy(), dto.getLimit(), dto.getOffset());
|
|
|
+ // 处理时间
|
|
|
handlerDate(result, columns);
|
|
|
+ // 处理字典值
|
|
|
handlerSysDictData(result, columns);
|
|
|
+ // 处理外键
|
|
|
+ handlerForeignKey(result, columns);
|
|
|
+ // 定制接口
|
|
|
result = isCustomized(dto.getTable(),result,"trigger_retrieve");
|
|
|
+
|
|
|
rows.put(FormDataConstant.PAGE_ROWS, result);
|
|
|
return AjaxResult.success(rows);
|
|
|
}
|
|
|
|
|
|
+ private void handlerForeignKey(List<JSONObject> result, List<GenTableColumn> columns) {
|
|
|
+ if (org.apache.commons.collections4.CollectionUtils.isEmpty(result)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 拿到所有有fk的列
|
|
|
+ columns = filter(columns, col -> ObjectUtils.isNotEmpty(col.getForeignKey()));
|
|
|
+ for (GenTableColumn column : columns) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+// Long selfTableId = column.getTableId();
|
|
|
+ String selfColumnName = column.getColumnName();
|
|
|
+ for (JSONObject json : result) {
|
|
|
+ if (json.containsKey(selfColumnName)) {
|
|
|
+ Object value = json.get(selfColumnName);
|
|
|
+
|
|
|
+ Long fkColumnId = Long.parseLong(column.getForeignKey());
|
|
|
+ GenTableColumn fkTableColumn = remoteGenTableColumnService.getById(fkColumnId);
|
|
|
+ Long fkTableId = fkTableColumn.getTableId();
|
|
|
+ GenTable fkGenTable = remoteGenTableService.getByTableId(fkTableId);
|
|
|
+ String fkTableName= fkGenTable.getTableName();
|
|
|
+
|
|
|
+ // select * from fkTableName where fkTableColumn.columnName = value;
|
|
|
+
|
|
|
+// jsonObject.put(columnName, "");
|
|
|
+// jsonObject.put("columnName", "");
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 功能描述: 把timeStamp转为string
|
|
|
*
|
|
@@ -360,7 +406,7 @@ public class TableServiceCmdService {
|
|
|
|
|
|
/**
|
|
|
* 功能描述: 封装成查询条件 key: 列名, value:查询条件_查询类别
|
|
|
- * eg: [{"config_name":"系统配置_like"}, {"config_name":"_like"}]
|
|
|
+ * eg: [{"config_name": ["系统配置", "EQ", "varchar(100)"]}]
|
|
|
*
|
|
|
* @param columns columns
|
|
|
* @return com.alibaba.fastjson.JSONObject
|
|
@@ -497,9 +543,7 @@ public class TableServiceCmdService {
|
|
|
public List<GenTableColumn> getTableHeadList(GenTable genTable){
|
|
|
List<GenTableColumn> columns = genTable.getColumns();
|
|
|
// 表头
|
|
|
- return columns.stream()
|
|
|
- .filter(genTableColumn -> GenTableColumn.IS_LIST.equals(genTableColumn.getIsList()))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ return filterData(columns, 4, MaskConstant.LIST_VISIBLE::equals);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -742,5 +786,8 @@ public class TableServiceCmdService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public AjaxResult listAllColumnsByTableId(GenTable table) {
|
|
|
+ return remoteGenTableColumnService.listColumnsByTableId(table.getTableId());
|
|
|
+ }
|
|
|
}
|
|
|
|