|
@@ -1,5 +1,6 @@
|
|
|
package com.gis.db.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -13,6 +14,7 @@ import com.gis.common.base.service.IBaseService;
|
|
|
import com.gis.common.constant.ErrorEnum;
|
|
|
import com.gis.common.util.BaseUtil;
|
|
|
import com.gis.common.util.RedisUtil;
|
|
|
+import com.gis.common.util.RegexUtil;
|
|
|
import com.gis.common.util.Result;
|
|
|
import com.gis.db.entity.dto.FieldDto;
|
|
|
import com.gis.db.entity.dto.FieldPageDto;
|
|
@@ -76,11 +78,15 @@ public class FieldServiceImpl extends ServiceImpl<FieldMapper, FieldEntity> impl
|
|
|
ArrayList<FieldEntity> list = new ArrayList<>();
|
|
|
for (FieldDto dto : param) {
|
|
|
|
|
|
+
|
|
|
+ String name = dto.getName();
|
|
|
+ // 校验字符
|
|
|
+ checkName(name);
|
|
|
// 驼峰转下划线
|
|
|
String underLineCase = StrUtil.toUnderlineCase(dto.getName());
|
|
|
dto.setName(underLineCase);
|
|
|
|
|
|
- BaseRuntimeException.isTrue(isExistByTableIdAndName(dto.getTableId(), dto.getName()), null, "字段重复添加");
|
|
|
+ BaseRuntimeException.isTrue(isExistByTableIdAndName(dto.getTableId(), name), null, "字段重复添加");
|
|
|
entity = new FieldEntity();
|
|
|
BeanUtils.copyProperties(dto, entity);
|
|
|
entity.setCreatorId(baseService.getUserId());
|
|
@@ -104,6 +110,14 @@ public class FieldServiceImpl extends ServiceImpl<FieldMapper, FieldEntity> impl
|
|
|
return Result.success();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private void checkName(String str){
|
|
|
+ boolean character = RegexUtil.isCharacter(str);
|
|
|
+ BaseRuntimeException.isTrue(character, null, "字段不能包含中文或非法字符");
|
|
|
+ boolean startWithNumber = RegexUtil.isStartWithNumber(str);
|
|
|
+ BaseRuntimeException.isTrue(startWithNumber, null, "字段不能以数字开头");
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Result testSql() {
|
|
|
String sql = "alter table ts_aa add age_1 varchar(255)";
|
|
@@ -199,7 +213,8 @@ public class FieldServiceImpl extends ServiceImpl<FieldMapper, FieldEntity> impl
|
|
|
Map<String, Object> record = param.getRecord();
|
|
|
// 固定添加这两个字段值
|
|
|
record.put("creator_id", userId);
|
|
|
- record.put("uuid", IdUtil.simpleUUID());
|
|
|
+ String uuid = IdUtil.simpleUUID();
|
|
|
+ record.put("uuid", uuid);
|
|
|
// 字段
|
|
|
List<String> fieldList = new ArrayList<>();
|
|
|
// 字段对应的值
|
|
@@ -210,13 +225,13 @@ public class FieldServiceImpl extends ServiceImpl<FieldMapper, FieldEntity> impl
|
|
|
|
|
|
}
|
|
|
|
|
|
- Integer id = ddlMapper.insertRecord(tableName, fieldList, fieldData);
|
|
|
- log.info("返回值id: {}", id);
|
|
|
+ ddlMapper.insertRecord(tableName, fieldList, fieldData);
|
|
|
|
|
|
//查询新增数据 todo
|
|
|
-// this.detail(tableId, )
|
|
|
+ Map res = this.findByUuid(tableId, uuid);
|
|
|
+
|
|
|
|
|
|
- return Result.success(id);
|
|
|
+ return Result.success(res);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -366,5 +381,15 @@ public class FieldServiceImpl extends ServiceImpl<FieldMapper, FieldEntity> impl
|
|
|
return Result.success(dataMap);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map findByUuid(String tableId, String uuid) {
|
|
|
+ TableEntity tableEntity = tableService.getById(tableId);
|
|
|
+ BaseRuntimeException.isNull(tableEntity, ErrorEnum.FAILURE_CODE_3001);
|
|
|
+
|
|
|
+ Map dataMap = getBaseMapper().findByUuid(tableEntity.getNameTable(), getFileNames(Long.valueOf(tableId)), uuid);
|
|
|
+
|
|
|
+ return dataMap;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|