|
@@ -9,7 +9,7 @@ import com.boman.common.core.utils.SecurityUtils;
|
|
|
import com.boman.common.core.utils.StringUtils;
|
|
|
import com.boman.common.core.utils.collection.CollectionUtils;
|
|
|
import com.boman.common.core.utils.obj.ObjectUtils;
|
|
|
-import com.boman.domain.dto.AjaxResult;
|
|
|
+import com.boman.domain.dto.*;
|
|
|
import com.boman.common.redis.RedisKey;
|
|
|
import com.boman.common.redis.service.RedisService;
|
|
|
import com.boman.common.security.service.TokenService;
|
|
@@ -17,18 +17,14 @@ import com.boman.domain.GenTable;
|
|
|
import com.boman.domain.GenTableColumn;
|
|
|
import com.boman.domain.SysDictData;
|
|
|
import com.boman.domain.constant.*;
|
|
|
-import com.boman.domain.dto.ProcessDto;
|
|
|
-import com.boman.domain.dto.RoleMenuDto;
|
|
|
import com.boman.domain.exception.NoSuchFunctionException;
|
|
|
import com.boman.gen.api.RemoteGenTableColumnService;
|
|
|
import com.boman.gen.api.RemoteGenTableService;
|
|
|
import com.boman.jflow.api.RemoteJflowProcessService;
|
|
|
-import com.boman.jflow.api.RemoteJflowTaskService;
|
|
|
import com.boman.system.api.RemoteMenuService;
|
|
|
import com.boman.domain.SysMenu;
|
|
|
import com.boman.system.api.model.LoginUser;
|
|
|
import com.boman.web.core.domain.ActionType;
|
|
|
-import com.boman.domain.dto.FormDataDto;
|
|
|
import com.boman.web.core.domain.RowResult;
|
|
|
import com.boman.web.core.domain.TableContext;
|
|
|
import com.boman.web.core.service.delete.IBaseDeleteService;
|
|
@@ -125,7 +121,7 @@ public class TableServiceCmdService {
|
|
|
if (ActionType.INSERT.equals(context.getActionType())) {
|
|
|
List<GenTableColumn> columns = context.getColumns();
|
|
|
Long maxId = IdUtils.getMaxId(dto.getTable(), pkName);
|
|
|
- ColumnUtils.packUpdateByAndTime(columns, commitData, new Timestamp(System.currentTimeMillis()), true);
|
|
|
+ packUpdateByAndTime(columns, commitData, new Timestamp(System.currentTimeMillis()), true);
|
|
|
// 处理默认值
|
|
|
handlerDefaultValue(commitData, columns);
|
|
|
// 如果有单据、按照单据编号规则
|
|
@@ -212,17 +208,14 @@ public class TableServiceCmdService {
|
|
|
List<RowResult> result = Lists.newArrayListWithCapacity(idArr.length);
|
|
|
for (Long id : idArr) {
|
|
|
// 校验权限
|
|
|
- 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 {
|
|
|
+ if (BooleanUtils.isFalse(checkAuthObjectDelete(genTable, id, pkName))) {
|
|
|
rowResult = RowResult.create(RowResult.FAIL, "无操作权限");
|
|
|
+ result.add(rowResult);
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
+ rowResult = deleteService.deleteById(dto.getTable(), pkName, id);
|
|
|
+ LOGGER.info("删除" + (rowResult.isOk() ? "成功" : "失败") + ", tableName: {}, id: {}, 操作人: {}", tableContext.getTableName(), id, getLoginUser().getUsername());
|
|
|
result.add(rowResult);
|
|
|
}
|
|
|
|
|
@@ -445,6 +438,110 @@ public class TableServiceCmdService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public AjaxResult getComplexObject(PrimaryTableDto dto) {
|
|
|
+ String primaryTableName = requireNonNull(dto.getPrimaryTableName(), "primaryTableName is empty");
|
|
|
+ Long id = requireNonNull(dto.getItemId(), "itemId is empty");
|
|
|
+
|
|
|
+ GenTable primaryGenTable = getTableFromRedisByTableName(RedisKey.TABLE_INFO, primaryTableName);
|
|
|
+ if (BooleanUtils.isFalse(checkAuthGetObject(primaryGenTable, id))) {
|
|
|
+ throw new NoSuchFunctionException("不好意思,您无权限操作");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<GenTableColumn> primaryColumns = primaryGenTable.getColumns();
|
|
|
+ // id = -1时,查询该表单对应的字段名称
|
|
|
+ if (ltZero(id)) {
|
|
|
+ return AjaxResult.error("when invoke getComplexObject param(id) must be gt 0, but id = " + id + " now");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<PrimaryTableDto.DeputyTableDto> deputyTableList = dto.getDeputyTableList();
|
|
|
+ for (PrimaryTableDto.DeputyTableDto tableDto : deputyTableList) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // extend的字段标记为true
|
|
|
+ markTrueByExtend(primaryColumns);
|
|
|
+ List<GenTableColumn> updateVisibleColumns = filterData(primaryColumns, 2, UPDATE_VISIBLE::equals);
|
|
|
+ List<String> showData = map(updateVisibleColumns, GenTableColumn::getColumnName);
|
|
|
+ String pkName = IdUtils.getPkName(primaryColumns);
|
|
|
+
|
|
|
+ List<JSONObject> jsonList = selectService.selectByIdList(primaryTableName, pkName, Lists.newArrayList(id), showData);
|
|
|
+ requireNonNull(jsonList, "id 为[" + id + "]的数据不存在, 模块为[" + primaryGenTable.getFunctionName() + "]");
|
|
|
+ // 查询时为null的列不显示的处理
|
|
|
+ handleNullColumnValue(jsonList, showData);
|
|
|
+ JSONObject json = jsonList.get(0);
|
|
|
+
|
|
|
+ // 处理blob
|
|
|
+ handleBlob(jsonList, primaryGenTable.getIsContainsBlob());
|
|
|
+ List<GenTableColumn> parentColumns = filterHrAndSort(primaryColumns);
|
|
|
+ removeColumnsByMask(parentColumns, 2, UPDATE_NOT_VISIBLE::equals);
|
|
|
+
|
|
|
+ //接收可能存在的cssClass
|
|
|
+ String cssClass = null;
|
|
|
+ // 处理成hr的形式
|
|
|
+ for (GenTableColumn hrColumn : parentColumns) {
|
|
|
+ List<GenTableColumn> children = Lists.newArrayListWithCapacity(16);
|
|
|
+ for (GenTableColumn column : updateVisibleColumns) {
|
|
|
+ if (!hrColumn.getId().equals(column.getHrParentId())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String columnName = column.getColumnName(), columnType = column.getColumnType(), htmlType = column.getHtmlType(), dictType = column.getDictType();
|
|
|
+ if (!json.containsKey(columnName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ Object value = json.get(columnName);
|
|
|
+ column.setColumnValue(value);
|
|
|
+ // sysDict
|
|
|
+ if (isNotEmpty(dictType)) {
|
|
|
+ List<SysDictData> sysDictData = column.getSysDictData();
|
|
|
+ if (sysDictData != null && sysDictData.size() > 0) {
|
|
|
+ for (SysDictData sysDictDatum : sysDictData) {
|
|
|
+ if (sysDictDatum.getDictValue().equals(value)) {
|
|
|
+ cssClass = sysDictDatum.getCssClass();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // dateTime
|
|
|
+ if (NEED_CONVERT_DATE_LIST.contains(columnType)) {
|
|
|
+ assert value instanceof Timestamp;
|
|
|
+ column.setColumnValue(getStrDate((Timestamp)value));
|
|
|
+ }
|
|
|
+ // fk
|
|
|
+ if (isNotEmpty(column.getForeignKey())) {
|
|
|
+ column.setFkInfo(getFkInfoForGetObject(column.getFkInfo(), value));
|
|
|
+ // 转换类型
|
|
|
+ column.setColumnValue(castNumberValue(primaryColumns, columnName, value));
|
|
|
+ }
|
|
|
+ // annex
|
|
|
+ if (HTML_IMAGE_UPLOAD.equalsIgnoreCase(htmlType) || HTML_FILE_UPLOAD.equalsIgnoreCase(htmlType)) {
|
|
|
+ column.setAnnex(getAnnex((String)value));
|
|
|
+ }
|
|
|
+
|
|
|
+ children.add(column);
|
|
|
+ }
|
|
|
+ hrColumn.setHrChildren(children);
|
|
|
+ }
|
|
|
+
|
|
|
+ //给基本属性和日志信息添加上cssClass
|
|
|
+ if (StringUtils.isNotBlank(cssClass)) {
|
|
|
+ for (GenTableColumn parentColumn : parentColumns) {
|
|
|
+ parentColumn.setCssClass(cssClass);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.put(SHOW_DATA, removeHr(parentColumns));
|
|
|
+ result.put(BUTTON_LIST, getButton(primaryTableName, json.getString(SubmitConstant.STATUS)));
|
|
|
+ Integer tableColumn = primaryGenTable.getTableColumn();
|
|
|
+ if (tableColumn != null) {
|
|
|
+ result.put(TABLE_COLUMN, tableColumn);
|
|
|
+ }
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 功能描述: 获取单表单所有数据
|
|
|
*
|