|
@@ -1,6 +1,5 @@
|
|
|
package com.gis.db.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
@@ -13,6 +12,7 @@ import com.gis.common.constant.ErrorEnum;
|
|
|
import com.gis.common.util.BaseUtil;
|
|
|
import com.gis.common.util.Result;
|
|
|
import com.gis.db.entity.dto.FieldDto;
|
|
|
+import com.gis.db.entity.dto.FieldPageDto;
|
|
|
import com.gis.db.entity.dto.IdsDto;
|
|
|
import com.gis.db.entity.po.FieldEntity;
|
|
|
import com.gis.db.entity.po.TableEntity;
|
|
@@ -80,30 +80,7 @@ public class FieldServiceImpl extends ServiceImpl<FieldMapper, FieldEntity> impl
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Result getFieldData(Long tableId, PageDto param) {
|
|
|
- BaseUtil.startPage(param);
|
|
|
- IPage<Map> page = new Page<>(param.getPageNum() , param.getPageSize());
|
|
|
- TableEntity tableEntity = tableService.getById(tableId);
|
|
|
- BaseRuntimeException.isNull(tableEntity, ErrorEnum.FAILURE_CODE_3001);
|
|
|
- IPage<Map> resPage = getBaseMapper().page(tableEntity.getName(), getFileNames(tableId), page);
|
|
|
-
|
|
|
- Map resultMap = new HashMap();
|
|
|
- resultMap.put("fieldNames", getResultByTableId(tableId));
|
|
|
- resultMap.put("fieldData", resPage);
|
|
|
-
|
|
|
- return Result.success(resultMap);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result detail(Long tableId, Long id) {
|
|
|
- TableEntity tableEntity = tableService.getById(tableId);
|
|
|
- BaseRuntimeException.isNull(tableEntity, ErrorEnum.FAILURE_CODE_3001);
|
|
|
|
|
|
- Map dataMap = getBaseMapper().detail(tableEntity.getName(), getFileNames(tableId), id);
|
|
|
-
|
|
|
- return Result.success(dataMap);
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 根据表id批量删除字段(逻辑删除)
|
|
@@ -122,6 +99,7 @@ public class FieldServiceImpl extends ServiceImpl<FieldMapper, FieldEntity> impl
|
|
|
|
|
|
/**
|
|
|
* todo 需要校验appId
|
|
|
+ * 删除字段
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
@@ -133,13 +111,43 @@ public class FieldServiceImpl extends ServiceImpl<FieldMapper, FieldEntity> impl
|
|
|
|
|
|
// 删除表字段
|
|
|
|
|
|
+ List<Integer> ids = param.getIds();
|
|
|
+ List<String> fieldNames = getFieldName(ids);
|
|
|
|
|
|
- List<String> fieldNames = getFieldName(param.getIds());
|
|
|
+ String tableName = getTableNameByFieldId(ids.get(0));
|
|
|
+
|
|
|
+ for (String name : fieldNames) {
|
|
|
+ // 检查字段是否存在
|
|
|
+ Integer integer = ddlMapper.existColumn(tableName, name);
|
|
|
+ if (integer > 0){
|
|
|
+ // 真删除字段
|
|
|
+ ddlMapper.delField(tableName, name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // ddlMapper.delFields(tableName, fieldNames);
|
|
|
+ // 逻辑删除字段记录
|
|
|
+ this.removeByIds(ids);
|
|
|
+
|
|
|
+
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
|
|
|
- String tableName = "ts_cc";
|
|
|
- ddlMapper.delFields(tableName, fieldNames);
|
|
|
+ private String getTableNameByFieldId(Integer id) {
|
|
|
+ return getBaseMapper().getTableNameByFieldId(id);
|
|
|
+ }
|
|
|
|
|
|
- return null;
|
|
|
+ @Override
|
|
|
+ public Result getList(FieldPageDto param) {
|
|
|
+ BaseUtil.startPage(param);
|
|
|
+ IPage<FieldEntity> page = new Page<>(param.getPageNum() , param.getPageSize());
|
|
|
+ LambdaQueryWrapper<FieldEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(FieldEntity::getTableId, param.getTableId());
|
|
|
+ String searchKey = param.getSearchKey();
|
|
|
+ wrapper.like(StrUtil.isNotBlank(searchKey), FieldEntity::getName, searchKey);
|
|
|
+ wrapper.orderByDesc(FieldEntity::getCreateTime);
|
|
|
+ IPage<FieldEntity> iPage = this.page(page, wrapper);
|
|
|
+ return Result.success(iPage);
|
|
|
}
|
|
|
|
|
|
private List<String> getFieldName(List<Integer> ids){
|
|
@@ -208,4 +216,30 @@ public class FieldServiceImpl extends ServiceImpl<FieldMapper, FieldEntity> impl
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result getFieldData(Long tableId, PageDto param) {
|
|
|
+ BaseUtil.startPage(param);
|
|
|
+ IPage<Map> page = new Page<>(param.getPageNum() , param.getPageSize());
|
|
|
+ TableEntity tableEntity = tableService.getById(tableId);
|
|
|
+ BaseRuntimeException.isNull(tableEntity, ErrorEnum.FAILURE_CODE_3001);
|
|
|
+ IPage<Map> resPage = getBaseMapper().page(tableEntity.getName(), getFileNames(tableId), page);
|
|
|
+
|
|
|
+ Map resultMap = new HashMap();
|
|
|
+ resultMap.put("fieldNames", getResultByTableId(tableId));
|
|
|
+ resultMap.put("fieldData", resPage);
|
|
|
+
|
|
|
+ return Result.success(resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result detail(Long tableId, Long id) {
|
|
|
+ TableEntity tableEntity = tableService.getById(tableId);
|
|
|
+ BaseRuntimeException.isNull(tableEntity, ErrorEnum.FAILURE_CODE_3001);
|
|
|
+
|
|
|
+ Map dataMap = getBaseMapper().detail(tableEntity.getName(), getFileNames(tableId), id);
|
|
|
+
|
|
|
+ return Result.success(dataMap);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|