|
@@ -10,7 +10,6 @@ import com.boman.common.core.utils.number.NumberUtils;
|
|
|
import com.boman.common.core.utils.obj.ObjectUtils;
|
|
|
import com.boman.common.redis.RedisKey;
|
|
|
import com.boman.common.redis.service.RedisService;
|
|
|
-import com.boman.common.security.service.TokenService;
|
|
|
import com.boman.domain.GenTable;
|
|
|
import com.boman.domain.GenTableColumn;
|
|
|
import com.boman.domain.SysDictData;
|
|
@@ -22,7 +21,6 @@ import com.boman.gen.api.RemoteGenTableColumnService;
|
|
|
import com.boman.gen.api.RemoteGenTableService;
|
|
|
import com.boman.jflow.api.RemoteJflowProcessService;
|
|
|
import com.boman.system.api.RemoteMenuService;
|
|
|
-import com.boman.system.api.model.LoginUser;
|
|
|
import com.boman.web.core.domain.ActionType;
|
|
|
import com.boman.web.core.domain.RowResult;
|
|
|
import com.boman.web.core.domain.TableContext;
|
|
@@ -31,7 +29,6 @@ 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.BillRuleUtils;
|
|
|
import com.boman.web.core.utils.ColumnUtils;
|
|
|
import com.boman.web.core.utils.IdUtils;
|
|
|
import com.google.common.base.Strings;
|
|
@@ -292,7 +289,7 @@ public class TableServiceCmdService {
|
|
|
// 检查列
|
|
|
checkColumn(condition, columns);
|
|
|
// 封装好以后的查询条件
|
|
|
- JSONObject packCondition = ifNullSetEmpty(selectService.packColCondition(columns, condition));
|
|
|
+ JSONObject packCondition = ifNullSetEmpty(packColCondition(columns, condition));
|
|
|
List<String> showData = dto.getShowData();
|
|
|
// 检查列
|
|
|
checkColumn(showData, genTable.getColumns());
|
|
@@ -330,6 +327,74 @@ public class TableServiceCmdService {
|
|
|
return AjaxResult.success(rows);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 功能描述: 获取单表单数据
|
|
|
+ *
|
|
|
+ * @param queryBySql queryBySql
|
|
|
+ * @return com.boman.domain.dto.AjaxResult
|
|
|
+ */
|
|
|
+ public AjaxResult queryListBySql(QueryBySqlDto queryBySql) {
|
|
|
+ String primaryTableName = queryBySql.getPrimaryTableName();
|
|
|
+ String deputyTableName = queryBySql.getDeputyTableName();
|
|
|
+ String primaryTableNameRelKey = queryBySql.getPrimaryTableNameRelKey();
|
|
|
+ String deputyTableNameRelKey = queryBySql.getDeputyTableNameRelKey();
|
|
|
+ requireNonNull(primaryTableName, String.format("tableName = [%s] , 此表不存在", primaryTableName));
|
|
|
+ requireNonNull(deputyTableName, String.format("tableName = [%s] , 此表不存在", deputyTableName));
|
|
|
+ requireNonNull(primaryTableNameRelKey, String.format("主表和子表 关联字段名称不存在, name = [%s]", primaryTableNameRelKey));
|
|
|
+ requireNonNull(deputyTableNameRelKey, String.format("子表和主表 关联字段名称不存在, name = [%s]", deputyTableNameRelKey));
|
|
|
+
|
|
|
+ GenTable primaryGenTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, primaryTableName);
|
|
|
+ List<GenTableColumn> columns = primaryGenTable.getColumns();
|
|
|
+ GenTable deputyGenTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, deputyTableName);
|
|
|
+ List<GenTableColumn> deputyColumns = deputyGenTable.getColumns();
|
|
|
+ columns.addAll(deputyColumns);
|
|
|
+ // 查询条件
|
|
|
+ JSONObject condition = queryBySql.getCondition();
|
|
|
+ // 权限
|
|
|
+ checkAuthQueryList(primaryGenTable, condition);
|
|
|
+ // 检查列
|
|
|
+ checkLeftJoinColumn(condition.keySet(), columns);
|
|
|
+ // 封装好以后的查询条件
|
|
|
+ JSONObject packCondition = ifNullSetEmpty(ColumnUtils.packColCondition(columns, condition));
|
|
|
+
|
|
|
+ JSONObject rows = new JSONObject();
|
|
|
+ int total = selectService.countByLeftJoinCondition(packCondition, queryBySql);
|
|
|
+ rows.put(FormDataConstant.PAGE_TOTAL, total);
|
|
|
+ rows.put(TABLE_HEAD_LIST, getTableHeadList(primaryGenTable));
|
|
|
+ if (total <= 0) {
|
|
|
+ rows.put(FormDataConstant.PAGE_ROWS, new ArrayList<>());
|
|
|
+ return AjaxResult.success(rows);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> showData = queryBySql.getShowData();
|
|
|
+ // 检查列
|
|
|
+ checkColumn(showData, columns);
|
|
|
+ // 需要返回到前台的列, 需要判断是否是列表展示, 4为判断列表是否可见
|
|
|
+ showData = filterData(columns, 4, showData, MaskConstant.LIST_VISIBLE::equals);
|
|
|
+ // 表的id单独处理,不管mask,都查出来返给前台
|
|
|
+ IdUtils.putIfNotContains(showData, IdUtils.getPkName(columns));
|
|
|
+ List<JSONObject> result = selectService.selectByLeftJoinCondition(queryBySql, packCondition, showData);
|
|
|
+// result = filter(result, ObjectUtils::isNotEmpty);
|
|
|
+//
|
|
|
+// // 查询时为null的列不显示的处理
|
|
|
+// handleNullColumnValue(result, showData);
|
|
|
+//
|
|
|
+// // 处理blob
|
|
|
+// handleBlob(result, genTable.getIsContainsBlob());
|
|
|
+// // 处理日期、外键、字典值
|
|
|
+// handleDictForQueryList(result, columns);
|
|
|
+// handleDateTimeForQueryList(result, columns);
|
|
|
+// handleFkForQueryList(result, columns);
|
|
|
+//
|
|
|
+// // 定制接口
|
|
|
+// result = isCustomized(dto.getTable(), result, "trigger_retrieve");
|
|
|
+//
|
|
|
+// rows.put(PAGE_ROWS, result);
|
|
|
+// return AjaxResult.success(rows);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 功能描述: 获取单表单数据
|
|
|
*
|
|
@@ -670,7 +735,8 @@ public class TableServiceCmdService {
|
|
|
List<String> permses = map(menus, SysMenu::getPerms);
|
|
|
List<String> btns = Lists.newArrayListWithCapacity(permses.size());
|
|
|
for (String perms : permses) {
|
|
|
- if (perms.contains(tableName)) {
|
|
|
+ String[] split = perms.split(":");
|
|
|
+ if (split[0].equals(tableName)) {
|
|
|
btns.add(RoleMenuDto.getBtnFromPerms(perms));
|
|
|
}
|
|
|
}
|
|
@@ -1056,49 +1122,6 @@ public class TableServiceCmdService {
|
|
|
return ajaxResult;
|
|
|
}
|
|
|
|
|
|
- /**P
|
|
|
- * 功能描述: 新增的时候处理默认值, 从redis中拿到存在token中的userEnv对象,根据数据库中存的默认值的key,和userEnv中的key做比对,
|
|
|
- * 从中取出作为字段的默认值,redis中存userEnv的位置:{@link TokenService#packUserEnv(com.boman.system.api.model.LoginUser))}
|
|
|
- *
|
|
|
- * @param commitData commitData
|
|
|
- * @param columns 所有的列
|
|
|
- */
|
|
|
- private void handlerDefaultValue(JSONObject commitData, List<GenTableColumn> columns) {
|
|
|
- String token = SecurityUtils.getToken();
|
|
|
- LoginUser loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token);
|
|
|
- JSONObject userEnv = loginUser.getUserEnv();
|
|
|
- for (GenTableColumn column : columns) {
|
|
|
- // 有默认值的列, 并且前台传过来的key中不包含
|
|
|
- if (isNotEmpty(column.getDefaultValue()) && !commitData.containsKey(column.getColumnName())) {
|
|
|
- String dbDefaultValue = column.getDefaultValue();
|
|
|
- String defaultValue = ColumnUtils.parseVariables(dbDefaultValue);
|
|
|
- String variables = dbDefaultValue.equalsIgnoreCase(defaultValue) ? dbDefaultValue : userEnv.getString(defaultValue);
|
|
|
- commitData.put(column.getColumnName(), variables);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /*
|
|
|
- * 功能描述: 单据规则
|
|
|
- *
|
|
|
- * @param commitData commitData
|
|
|
- * @param allColumns allColumns
|
|
|
- * @return void
|
|
|
- */
|
|
|
- private void buildBillRule(String tableName, JSONObject commitData, List<GenTableColumn> allColumns) {
|
|
|
- requireNonNull(tableName, "tableName is empty");
|
|
|
- for (GenTableColumn column : allColumns) {
|
|
|
- String columnName = column.getColumnName();
|
|
|
- String seqName = column.getSeqName();
|
|
|
- if (isEmpty(seqName)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- String rule = BillRuleUtils.getRules(tableName, seqName, columnName);
|
|
|
- commitData.put(columnName, rule);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private void addOtherColumn(List<GenTableColumn> columns, String other) {
|
|
|
if(StringUtils.isEmpty(other)) {
|
|
|
return;
|