|
@@ -3,7 +3,6 @@ package com.boman.web.core.service;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
-import com.boman.common.core.utils.JSONArrayUtils;
|
|
|
|
import com.boman.domain.constant.CacheConstants;
|
|
import com.boman.domain.constant.CacheConstants;
|
|
import com.boman.common.core.utils.SecurityUtils;
|
|
import com.boman.common.core.utils.SecurityUtils;
|
|
import com.boman.common.core.utils.StringUtils;
|
|
import com.boman.common.core.utils.StringUtils;
|
|
@@ -45,6 +44,8 @@ import org.apache.commons.lang3.BooleanUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -154,6 +155,27 @@ public class TableServiceCmdService {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 功能描述: 复杂对象保存(本地事务)
|
|
|
|
+ *
|
|
|
|
+ * @param dto dto
|
|
|
|
+ * @return com.boman.domain.dto.AjaxResult
|
|
|
|
+ */
|
|
|
|
+ @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
|
|
|
|
+ public AjaxResult complexSave(FormDataDto dto) {
|
|
|
|
+ // 取出所有的孩子
|
|
|
|
+ List<FormDataDto> result = Lists.newArrayList(dto);
|
|
|
|
+ recursionAllChildrenFromDto(dto, result);
|
|
|
|
+
|
|
|
|
+ List<AjaxResult> resultList = new ArrayList<>(result.size());
|
|
|
|
+ for (FormDataDto formDataDto : result) {
|
|
|
|
+ AjaxResult ajaxResult = objectSave(formDataDto);
|
|
|
|
+ resultList.add(ajaxResult);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return AjaxResult.success(resultList);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 功能描述: 通用删除接口 (真的删除)
|
|
* 功能描述: 通用删除接口 (真的删除)
|
|
*
|
|
*
|
|
@@ -261,7 +283,7 @@ public class TableServiceCmdService {
|
|
checkColumn(condition, columns);
|
|
checkColumn(condition, columns);
|
|
// 封装好以后的查询条件
|
|
// 封装好以后的查询条件
|
|
JSONObject packCondition = ifNullSetEmpty(selectService.packColCondition(columns, condition));
|
|
JSONObject packCondition = ifNullSetEmpty(selectService.packColCondition(columns, condition));
|
|
- JSONArray showData = fixedData.getJSONArray(SHOW_DATA);
|
|
|
|
|
|
+ List<String> showData = dto.getShowData();
|
|
// 检查列
|
|
// 检查列
|
|
checkColumn(showData, genTable.getColumns());
|
|
checkColumn(showData, genTable.getColumns());
|
|
// 需要返回到前台的列, 需要判断是否是列表展示, 4为判断列表是否可见
|
|
// 需要返回到前台的列, 需要判断是否是列表展示, 4为判断列表是否可见
|
|
@@ -278,7 +300,7 @@ public class TableServiceCmdService {
|
|
return AjaxResult.success(rows);
|
|
return AjaxResult.success(rows);
|
|
}
|
|
}
|
|
|
|
|
|
- List<JSONObject> result = selectService.selectByCondition(tableName, condition, packCondition, JSONArrayUtils.toList(showData), dto);
|
|
|
|
|
|
+ List<JSONObject> result = selectService.selectByCondition(tableName, condition, packCondition, showData, dto);
|
|
result = filter(result, ObjectUtils::isNotEmpty);
|
|
result = filter(result, ObjectUtils::isNotEmpty);
|
|
|
|
|
|
// 查询时为null的列不显示的处理
|
|
// 查询时为null的列不显示的处理
|
|
@@ -998,7 +1020,26 @@ public class TableServiceCmdService {
|
|
}else{
|
|
}else{
|
|
jo.put("valuedata", jsonObject.get(columnName));
|
|
jo.put("valuedata", jsonObject.get(columnName));
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ private void recursionAllChildrenFromDto(FormDataDto dto, List<FormDataDto> result) {
|
|
|
|
+ List<FormDataDto> children = dto.getChildren();
|
|
|
|
+ if (isEmpty(children)) {
|
|
|
|
+ result.add(dto);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (FormDataDto child : children) {
|
|
|
|
+ result.add(child);
|
|
|
|
+ if (hasChild(child)) {
|
|
|
|
+ recursionAllChildrenFromDto(child, result);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean hasChild(FormDataDto dto) {
|
|
|
|
+ return isNotEmpty(dto.getChildren());
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|