|
@@ -15,6 +15,8 @@ import com.boman.common.redis.service.RedisService;
|
|
import com.boman.domain.GenTable;
|
|
import com.boman.domain.GenTable;
|
|
import com.boman.domain.GenTableColumn;
|
|
import com.boman.domain.GenTableColumn;
|
|
import com.boman.domain.SysDictData;
|
|
import com.boman.domain.SysDictData;
|
|
|
|
+import com.boman.domain.GenTable;
|
|
|
|
+import com.boman.domain.GenTableColumn;
|
|
import com.boman.domain.constant.*;
|
|
import com.boman.domain.constant.*;
|
|
import com.boman.gen.api.RemoteGenTableColumnService;
|
|
import com.boman.gen.api.RemoteGenTableColumnService;
|
|
import com.boman.gen.api.RemoteGenTableService;
|
|
import com.boman.gen.api.RemoteGenTableService;
|
|
@@ -22,6 +24,14 @@ import com.boman.web.core.domain.ActionType;
|
|
import com.boman.web.core.domain.FormDataDto;
|
|
import com.boman.web.core.domain.FormDataDto;
|
|
import com.boman.web.core.domain.RowResult;
|
|
import com.boman.web.core.domain.RowResult;
|
|
import com.boman.web.core.domain.TableContext;
|
|
import com.boman.web.core.domain.TableContext;
|
|
|
|
+import com.boman.system.api.RemoteDeptService;
|
|
|
|
+import com.boman.system.api.RemoteDictDataService;
|
|
|
|
+import com.boman.system.api.RemoteRoleDataService;
|
|
|
|
+import com.boman.system.api.RemoteUserService;
|
|
|
|
+import com.boman.web.core.domain.ActionType;
|
|
|
|
+import com.boman.web.core.domain.FormDataDto;
|
|
|
|
+import com.boman.web.core.domain.RowResult;
|
|
|
|
+import com.boman.web.core.domain.TableContext;
|
|
import com.boman.web.core.service.delete.IBaseDeleteService;
|
|
import com.boman.web.core.service.delete.IBaseDeleteService;
|
|
import com.boman.web.core.service.save.IBaseSaveService;
|
|
import com.boman.web.core.service.save.IBaseSaveService;
|
|
import com.boman.web.core.service.select.IBaseSelectService;
|
|
import com.boman.web.core.service.select.IBaseSelectService;
|
|
@@ -50,6 +60,7 @@ import static com.boman.common.core.constant.GenConstants.HTML_FILE_UPLOAD;
|
|
import static com.boman.common.core.constant.GenConstants.HTML_IMAGE_UPLOAD;
|
|
import static com.boman.common.core.constant.GenConstants.HTML_IMAGE_UPLOAD;
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.*;
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.*;
|
|
import static com.boman.domain.constant.FormDataConstant.*;
|
|
import static com.boman.domain.constant.FormDataConstant.*;
|
|
|
|
+import static com.boman.web.core.utils.AuthUtils.*;
|
|
import static com.boman.web.core.utils.ColumnUtils.*;
|
|
import static com.boman.web.core.utils.ColumnUtils.*;
|
|
import static com.boman.web.core.utils.HandlerFormDataUtils.*;
|
|
import static com.boman.web.core.utils.HandlerFormDataUtils.*;
|
|
import static com.boman.web.core.utils.JSONObjectUtils.containsKeyIgnoreCase;
|
|
import static com.boman.web.core.utils.JSONObjectUtils.containsKeyIgnoreCase;
|
|
@@ -77,6 +88,8 @@ public class TableServiceCmdService {
|
|
@Resource
|
|
@Resource
|
|
private RestTemplate restTemplate;
|
|
private RestTemplate restTemplate;
|
|
@Resource
|
|
@Resource
|
|
|
|
+ private TableContext tableContext;
|
|
|
|
+ @Resource
|
|
private RemoteGenTableService remoteGenTableService;
|
|
private RemoteGenTableService remoteGenTableService;
|
|
@Resource
|
|
@Resource
|
|
private RemoteGenTableColumnService remoteGenTableColumnService;
|
|
private RemoteGenTableColumnService remoteGenTableColumnService;
|
|
@@ -86,7 +99,8 @@ public class TableServiceCmdService {
|
|
public final AjaxResult objectSave(FormDataDto dto) {
|
|
public final AjaxResult objectSave(FormDataDto dto) {
|
|
AjaxResult result = AjaxResult.success();
|
|
AjaxResult result = AjaxResult.success();
|
|
|
|
|
|
- TableContext context = TableContext.createContext(dto);
|
|
|
|
|
|
+ // 权限校验在此方法中
|
|
|
|
+ TableContext context = tableContext.createContext(dto);
|
|
// 拿到pkName和maxId
|
|
// 拿到pkName和maxId
|
|
String pkName = context.getPkName();
|
|
String pkName = context.getPkName();
|
|
JSONObject commitData = context.getCommitData();
|
|
JSONObject commitData = context.getCommitData();
|
|
@@ -124,7 +138,7 @@ public class TableServiceCmdService {
|
|
|
|
|
|
private void handlerInputType(JSONObject commitData, List<GenTableColumn> columns) {
|
|
private void handlerInputType(JSONObject commitData, List<GenTableColumn> columns) {
|
|
for (Map.Entry<String, Object> entry : commitData.entrySet()) {
|
|
for (Map.Entry<String, Object> entry : commitData.entrySet()) {
|
|
- Object value = entry.getValue();
|
|
|
|
|
|
+ Object value =entry.getValue();
|
|
for (GenTableColumn column : columns) {
|
|
for (GenTableColumn column : columns) {
|
|
if (entry.getKey().equals(column.getColumnName())
|
|
if (entry.getKey().equals(column.getColumnName())
|
|
&& ArrayUtils.arraysContains(GenConstants.COLUMNTYPE_NUMBER, getDbType(column.getColumnType()))) {
|
|
&& ArrayUtils.arraysContains(GenConstants.COLUMNTYPE_NUMBER, getDbType(column.getColumnType()))) {
|
|
@@ -159,25 +173,34 @@ public class TableServiceCmdService {
|
|
*/
|
|
*/
|
|
public AjaxResult objectDelete(FormDataDto dto) {
|
|
public AjaxResult objectDelete(FormDataDto dto) {
|
|
requireNonNull(dto.getTable(), "tableName = [" + dto.getTable() + "] 此表不存在");
|
|
requireNonNull(dto.getTable(), "tableName = [" + dto.getTable() + "] 此表不存在");
|
|
- Long[] idArr = CollectionUtils.listToArray(dto.getIdList());
|
|
|
|
- requireNonNull(idArr);
|
|
|
|
- // 拿到pkName
|
|
|
|
|
|
+
|
|
GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, dto.getTable());
|
|
GenTable genTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, dto.getTable());
|
|
String pkName = IdUtils.getPkName(genTable.getColumns());
|
|
String pkName = IdUtils.getPkName(genTable.getColumns());
|
|
|
|
|
|
|
|
+ Long[] idArr = CollectionUtils.listToArray(dto.getIdList());
|
|
|
|
+ requireNonNull(idArr, "删除时,所传idList为空");
|
|
|
|
+
|
|
|
|
+ RowResult rowResult;
|
|
List<RowResult> result = Lists.newArrayListWithCapacity(idArr.length);
|
|
List<RowResult> result = Lists.newArrayListWithCapacity(idArr.length);
|
|
for (Long id : idArr) {
|
|
for (Long id : idArr) {
|
|
- RowResult rowResult = deleteService.deleteById(dto.getTable(), pkName, id);
|
|
|
|
|
|
+ // 校验权限
|
|
|
|
+ if (BooleanUtils.isTrue(checkAuthObjectDelete(genTable, id, pkName))) {
|
|
|
|
+ rowResult = deleteService.deleteById(dto.getTable(), pkName, id);
|
|
|
|
+ if (rowResult.isOk()) {
|
|
|
|
+ LOGGER.info("删除成功, tableName: {}, id: {}, 操作人: {}", tableContext.getTableName(), id, getLoginUser().getUsername());
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ LOGGER.info("删除失败, tableName: {}, id: {}, 操作人: {}", tableContext.getTableName(), id, getLoginUser().getUsername());
|
|
|
|
+ } else {
|
|
|
|
+ rowResult = RowResult.create(RowResult.FAIL, "无操作权限");
|
|
|
|
+ }
|
|
|
|
+
|
|
result.add(rowResult);
|
|
result.add(rowResult);
|
|
- LOGGER.info(rowResult.getMessage() + ", id: {}", id);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- // RowResult rowResult = deleteService.objectDelete(idArr, dto.getTable(), requireNonNull(pkName, "主键名称为空"));
|
|
|
|
-
|
|
|
|
return AjaxResult.success(result);
|
|
return AjaxResult.success(result);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 功能描述: 通用删除接口 (真的删除)
|
|
* 功能描述: 通用删除接口 (真的删除)
|
|
*
|
|
*
|
|
@@ -196,10 +219,22 @@ public class TableServiceCmdService {
|
|
List<RowResult> result = Lists.newArrayListWithCapacity(idArr.length);
|
|
List<RowResult> result = Lists.newArrayListWithCapacity(idArr.length);
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put(dto.getLogicDelName(), dto.getLogicDelValue());
|
|
jsonObject.put(dto.getLogicDelName(), dto.getLogicDelValue());
|
|
|
|
+
|
|
|
|
+ RowResult rowResult;
|
|
for (Long id : idArr) {
|
|
for (Long id : idArr) {
|
|
- RowResult rowResult = deleteService.objectLogicDelete(new Long[]{id}, dto.getTable(), pkName, jsonObject);
|
|
|
|
|
|
+ // 校验权限
|
|
|
|
+ if (BooleanUtils.isTrue(checkAuthObjectDelete(genTable, id, pkName))) {
|
|
|
|
+ rowResult = deleteService.objectLogicDelete(new Long[]{id}, dto.getTable(), pkName, jsonObject);
|
|
|
|
+ if (rowResult.isOk()) {
|
|
|
|
+ LOGGER.info("逻辑删除成功, tableName: {}, id: {}, 操作人: {}", tableContext.getTableName(), id, getLoginUser().getUsername());
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ LOGGER.info("逻辑删除失败, tableName: {}, id: {}, 操作人: {}", tableContext.getTableName(), id, getLoginUser().getUsername());
|
|
|
|
+ } else {
|
|
|
|
+ rowResult = RowResult.create(RowResult.FAIL, "无操作权限");
|
|
|
|
+ }
|
|
|
|
+
|
|
result.add(rowResult);
|
|
result.add(rowResult);
|
|
- LOGGER.info(rowResult.getMessage() + ", id: {}", id);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
return AjaxResult.success(result);
|
|
return AjaxResult.success(result);
|
|
@@ -220,10 +255,12 @@ public class TableServiceCmdService {
|
|
|
|
|
|
// 查询条件
|
|
// 查询条件
|
|
JSONObject condition = ifNullSetEmpty(fixedData.getJSONObject(CONDITION));
|
|
JSONObject condition = ifNullSetEmpty(fixedData.getJSONObject(CONDITION));
|
|
|
|
+ // 权限
|
|
|
|
+ checkAuthQueryList(genTable, condition);
|
|
// 检查列
|
|
// 检查列
|
|
checkColumn(condition, columns);
|
|
checkColumn(condition, columns);
|
|
// 封装好以后的查询条件
|
|
// 封装好以后的查询条件
|
|
- JSONObject packCondition = ifNullSetEmpty(packColCondition(columns, condition));
|
|
|
|
|
|
+ JSONObject packCondition = ifNullSetEmpty(selectService.packColCondition(columns, condition));
|
|
JSONArray showData = fixedData.getJSONArray(SHOW_DATA);
|
|
JSONArray showData = fixedData.getJSONArray(SHOW_DATA);
|
|
// 检查列
|
|
// 检查列
|
|
checkColumn(showData, genTable.getColumns());
|
|
checkColumn(showData, genTable.getColumns());
|
|
@@ -243,10 +280,6 @@ public class TableServiceCmdService {
|
|
|
|
|
|
List<JSONObject> result = selectService.selectByCondition(tableName, condition, packCondition, showData, dto);
|
|
List<JSONObject> result = selectService.selectByCondition(tableName, condition, packCondition, showData, dto);
|
|
result = filter(result, ObjectUtils::isNotEmpty);
|
|
result = filter(result, ObjectUtils::isNotEmpty);
|
|
-
|
|
|
|
- // 查询时为null的列不显示的处理
|
|
|
|
- handleNullColumnValue(result, showData);
|
|
|
|
-
|
|
|
|
// 处理blob
|
|
// 处理blob
|
|
handleBlob(result, genTable.getIsContainsBlob());
|
|
handleBlob(result, genTable.getIsContainsBlob());
|
|
// 处理日期、外键、字典值
|
|
// 处理日期、外键、字典值
|
|
@@ -279,45 +312,29 @@ public class TableServiceCmdService {
|
|
return getByTableName(tableName, columns, isUi);
|
|
return getByTableName(tableName, columns, isUi);
|
|
}
|
|
}
|
|
|
|
|
|
- List<GenTableColumn> updateVisibleColumns = filterData(columns, 2, MaskConstant.UPDATE_VISIBLE::equals);
|
|
|
|
- List<String> showData = map(updateVisibleColumns, GenTableColumn::getColumnName);
|
|
|
|
|
|
+ // 默认查所有字段,不支持自定义
|
|
String pkName = IdUtils.getPkName(genTable.getColumns());
|
|
String pkName = IdUtils.getPkName(genTable.getColumns());
|
|
-
|
|
|
|
- List<JSONObject> jsonList = selectService.selectByIdList(tableName, pkName, Lists.newArrayList(id), showData);
|
|
|
|
- requireNonNull(jsonList, "id 为[" + id + "]的数据不存在, 模块为[" + genTable.getFunctionName() + "]");
|
|
|
|
- // 查询时为null的列不显示的处理
|
|
|
|
- handleNullColumnValue(jsonList, showData);
|
|
|
|
- JSONObject json = jsonList.get(0);
|
|
|
|
-
|
|
|
|
|
|
+ JSONObject json = selectService.selectById(tableName, pkName, id);
|
|
|
|
+ requireNonNull(json, "id 为[" + id + "]的数据不存在, 表名为[" + tableName + "]");
|
|
// 处理blob
|
|
// 处理blob
|
|
- handleBlob(jsonList, genTable.getIsContainsBlob());
|
|
|
|
- List<GenTableColumn> parentColumns = filterHrAndSort(columns);
|
|
|
|
|
|
+ handleBlob(Collections.singletonList(json), genTable.getIsContainsBlob());
|
|
|
|
|
|
- //接收可能存在的cssClass
|
|
|
|
- String cssClass = null;
|
|
|
|
|
|
+ List<GenTableColumn> parentColumns = filterHrAndSort(columns);
|
|
// 处理成hr的形式
|
|
// 处理成hr的形式
|
|
for (GenTableColumn hrColumn : parentColumns) {
|
|
for (GenTableColumn hrColumn : parentColumns) {
|
|
List<GenTableColumn> children = Lists.newArrayListWithCapacity(16);
|
|
List<GenTableColumn> children = Lists.newArrayListWithCapacity(16);
|
|
- for (GenTableColumn column : updateVisibleColumns) {
|
|
|
|
|
|
+ for (GenTableColumn column : columns) {
|
|
if (hrColumn.getId().equals(column.getHrParentId())) {
|
|
if (hrColumn.getId().equals(column.getHrParentId())) {
|
|
String columnName = column.getColumnName();
|
|
String columnName = column.getColumnName();
|
|
String columnType = column.getColumnType();
|
|
String columnType = column.getColumnType();
|
|
String htmlType = column.getHtmlType();
|
|
String htmlType = column.getHtmlType();
|
|
String dictType = column.getDictType();
|
|
String dictType = column.getDictType();
|
|
if (containsKeyIgnoreCase(json, columnName)) {
|
|
if (containsKeyIgnoreCase(json, columnName)) {
|
|
- column.setColumnValue(json.get(columnName));
|
|
|
|
// sysDict
|
|
// sysDict
|
|
if (isNotEmpty(dictType)) {
|
|
if (isNotEmpty(dictType)) {
|
|
- String value = json.getString(columnName);
|
|
|
|
- List<SysDictData> sysDictData = column.getSysDictData();
|
|
|
|
- if (sysDictData != null && sysDictData.size() > 0) {
|
|
|
|
- for (SysDictData sysDictDatum : sysDictData) {
|
|
|
|
- if (sysDictDatum.getDictValue().equals(value)) {
|
|
|
|
- cssClass = sysDictDatum.getCssClass();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // 既要sysDictData还得要columnValue
|
|
|
|
+ column.setSysDictData(listSysDictDataByType(dictType));
|
|
|
|
+ column.setColumnValue(json.get(columnName));
|
|
}
|
|
}
|
|
// dateTime
|
|
// dateTime
|
|
if (NEED_CONVERT_DATE_LIST.contains(columnType)) {
|
|
if (NEED_CONVERT_DATE_LIST.contains(columnType)) {
|
|
@@ -331,7 +348,8 @@ public class TableServiceCmdService {
|
|
if (HTML_IMAGE_UPLOAD.equalsIgnoreCase(htmlType) || HTML_FILE_UPLOAD.equalsIgnoreCase(htmlType)) {
|
|
if (HTML_IMAGE_UPLOAD.equalsIgnoreCase(htmlType) || HTML_FILE_UPLOAD.equalsIgnoreCase(htmlType)) {
|
|
column.setAnnex(getAnnex(json.getString(columnName)));
|
|
column.setAnnex(getAnnex(json.getString(columnName)));
|
|
}
|
|
}
|
|
- //column.setReadonly(SubmitConstant.STATUS.equals(columnName));
|
|
|
|
|
|
+
|
|
|
|
+ column.setReadonly(SubmitConstant.STATUS.equals(columnName));
|
|
}
|
|
}
|
|
|
|
|
|
children.add(column);
|
|
children.add(column);
|
|
@@ -340,12 +358,6 @@ public class TableServiceCmdService {
|
|
hrColumn.setHrChildren(children);
|
|
hrColumn.setHrChildren(children);
|
|
}
|
|
}
|
|
|
|
|
|
- //给基本属性和日志信息添加上cssClass
|
|
|
|
- if (StringUtils.isNotBlank(cssClass)){
|
|
|
|
- for (GenTableColumn parentColumn : parentColumns) {
|
|
|
|
- parentColumn.setCssClass(cssClass);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
result.put(SHOW_DATA, parentColumns);
|
|
result.put(SHOW_DATA, parentColumns);
|
|
result.put(BUTTON_LIST, getButton(tableName));
|
|
result.put(BUTTON_LIST, getButton(tableName));
|