Commit 793ce0b5 by wqc

添加批量元数据修改

parent d109ad43
...@@ -18,8 +18,8 @@ public class PageReqVo { ...@@ -18,8 +18,8 @@ public class PageReqVo {
*/ */
private static final int DEFAULT_SIZE = 20; private static final int DEFAULT_SIZE = 20;
@ApiModelProperty(value = "当前页码, 首页为1", example = "1") @ApiModelProperty("当前页码, 首页为1")
private int page = 1; private int page;
@ApiModelProperty("每页记录条数") @ApiModelProperty("每页记录条数")
private int size = DEFAULT_SIZE; private int size = DEFAULT_SIZE;
......
...@@ -170,8 +170,8 @@ public class MetaDataController { ...@@ -170,8 +170,8 @@ public class MetaDataController {
@ApiOperation("批量添加元数据") @ApiOperation("批量添加元数据")
@PostMapping("/addALLMetas") @PostMapping("/addALLMetas")
public ResultVo addALLMetas(@RequestBody List<MetaDataVo> vos,@RequestBody String tableName){ public ResultVo addALLMetas(@RequestBody List<MetaDataVo> vos){
AssertUtils.notNull(vos,"选择字段不能为空"); AssertUtils.notNull(vos,"选择字段不能为空");
return ResultVo.success(metaDataService.addALLMetas(vos,tableName)); return ResultVo.success(metaDataService.addALLMetas(vos));
} }
} }
...@@ -48,48 +48,36 @@ public class MetaDataService extends ServiceImpl<MetaDataDao, MetaData> { ...@@ -48,48 +48,36 @@ public class MetaDataService extends ServiceImpl<MetaDataDao, MetaData> {
// return metaDataDao.selectList(new LambdaQueryWrapper<MetaData>().eq(MetaData::getCategoryId, categoryId)); // return metaDataDao.selectList(new LambdaQueryWrapper<MetaData>().eq(MetaData::getCategoryId, categoryId));
// } // }
public PageVo<MetaDataVo> getPageByCategoryId(MetaDataReq req) { public PageVo<MetaData> getPageByCategoryId(MetaDataReq req) {
// 获取类别目录id参数 // 获取类别目录id参数
Long categoryId = req.getCategoryId(); Long categoryId = req.getCategoryId();
// 获取模糊查询的条件 // 获取模糊查询的条件
String metaName = req.getMetaName(); String metaName = req.getMetaName();
LambdaQueryWrapper<MetaData> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<MetaData> wrapper = new LambdaQueryWrapper<>();
// wrapper.eq(MetaData::getCategoryId, categoryId).last("LIMIT 10"); wrapper.eq(MetaData::getCategoryId, categoryId);
// 判断模糊查询的条件是否为空或空字符串 // 判断模糊查询的条件是否为空或空字符串
if (StringUtils.isNotBlank(metaName)) { if (StringUtils.isNotBlank(metaName)) {
// 如果不为空或空字符串,添加一个模糊查询的条件 // 如果不为空或空字符串,添加一个模糊查询的条件
wrapper.like(MetaData::getMetaName, metaName); wrapper.like(MetaData::getMetaName, metaName);
} }
return PagingUtils.paging(req,metaDataDao,wrapper,MetaData.class);
List<MetaDataVo> pageList = metaDataDao.getPageList(req);
int start = 0; // List<MetaDataVo> pageList = metaDataDao.getPageList(req);
PageVo<MetaDataVo> pageVo = new PageVo<>(); // int start = 0;
if (req.getPage() - 1 == 0) { // PageVo<MetaDataVo> pageVo = new PageVo<>();
pageVo.setStart(0); // if (req.getPage() - 1 == 0) {
start = 0; // pageVo.setStart(0);
} else { // start = 0;
pageVo.setStart((req.getPage() - 1) * req.getSize()); // } else {
start = (req.getPage() - 1) * req.getSize(); // pageVo.setStart((req.getPage() - 1) * req.getSize());
} // start = (req.getPage() - 1) * req.getSize();
pageVo.setPage(req.getPage());
pageVo.setSize(req.getSize());
pageVo.setRows(pageList);
pageVo.setTotal(pageList.size());
return pageVo;
// LambdaQueryWrapper<MetaDataMapping> mappingWrapper = new LambdaQueryWrapper<>();
// List<MetaData> metaDatas = metaDataDao.selectList(wrapper.eq(MetaData::getCategoryId, categoryId));
// MetaDataReq metaDataReq = new MetaDataReq();
// ArrayList<Object> list = new ArrayList<>();
// for (MetaData metaData : metaDatas) {
// BeanUtil.copyProperties(metaData, metaDataReq);
// List<MetaDataMapping> metaDataMappings = metaDataMappingDao.selectList(mappingWrapper.eq(MetaDataMapping::getMetadataId, metaData.getId()));
// for (MetaDataMapping mapping : metaDataMappings) {
// Long queryDbId = mapping.getQueryDbId();
// metaDataReq.setQueryDbId(queryDbId);
// }
// list.add(metaDataReq);
// } // }
// return list; // pageVo.setPage(req.getPage());
// pageVo.setSize(req.getSize());
// pageVo.setRows(pageList);
// pageVo.setTotal(pageList.size());
// return pageVo;
} }
...@@ -186,40 +174,40 @@ public class MetaDataService extends ServiceImpl<MetaDataDao, MetaData> { ...@@ -186,40 +174,40 @@ public class MetaDataService extends ServiceImpl<MetaDataDao, MetaData> {
} }
public ResultVo addALLMetas(List<MetaDataVo> vos,String tableName) { public ResultVo addALLMetas(List<MetaDataVo> vos) {
MetaData builder = null;
MetaDataCategory parent = null;
MetaDataCategory metaDataCategory = new MetaDataCategory(); MetaDataCategory metaDataCategory = new MetaDataCategory();
MetaDataCategory parent = metaDataCategoryService.getOne(new LambdaQueryWrapper<MetaDataCategory>()
.eq(MetaDataCategory::getId, vos.get(1).getCategoryId()));
if (parent != null) {
metaDataCategory.setCategoryCode(parent.getId());
// 更新其subCount字段为原来的值加一
parent.setSubCount(parent.getSubCount() + 1);
parent.setStandardLevel(Integer.valueOf(vos.get(1).getDataLevel()));
}
// 如果存在记录,获取其id,并设置为新记录的parentId
BeanUtil.copyProperties(parent, metaDataCategory);
metaDataCategory.setCategoryType(1);
metaDataCategory.setCategoryName(vos.get(1).getTableName());
metaDataCategoryService.save(metaDataCategory);
MetaData builder = null;
for (MetaDataVo metaVo : vos) { for (MetaDataVo metaVo : vos) {
builder = MetaData.builder() builder = MetaData.builder()
.metaName(metaVo.getMetaName()) .metaName(metaVo.getMetaName())
.dataType(metaVo.getDataType()) .dataType(metaVo.getDataType())
.dataLength(metaVo.getDataLength()) .dataLength(metaVo.getDataLength())
.fieldPrecision(metaVo.getFieldPrecision()) .fieldPrecision(metaVo.getFieldPrecision())
.dataCode(tableName + "_" + metaVo.getMetaName()) .dataCode(metaVo.getTableName() + "_" + metaVo.getMetaName())
.englishName(metaVo.getEnglishName()) .englishName(metaVo.getEnglishName())
.dataLevel(metaVo.getDataLevel()) .dataLevel(metaVo.getDataLevel())
.notNull(metaVo.getNotNull()) .notNull(metaVo.getNotNull())
.categoryId(metaVo.getCategoryId()) .categoryId(metaDataCategory.getId())
.mutiMetaFlag(metaVo.getMutiMetaFlag()) .mutiMetaFlag(metaVo.getMutiMetaFlag())
.mutiMetaExpress(metaVo.getMutiMetaExpress()) .mutiMetaExpress(metaVo.getMutiMetaExpress())
.createTime(DateUtil.date()).build(); .createTime(DateUtil.date()).build();
metaDataDao.insert(builder); metaDataDao.insert(builder);
parent = metaDataCategoryService.getOne(new LambdaQueryWrapper<MetaDataCategory>()
.eq(MetaDataCategory::getId, metaVo.getCategoryId()));
if (parent != null) {
metaDataCategory.setCategoryCode(parent.getId());
// 更新其subCount字段为原来的值加一
parent.setSubCount(parent.getSubCount() + 1);
parent.setStandardLevel(Integer.valueOf(metaVo.getDataLevel()));
}
} }
// 如果存在记录,获取其id,并设置为新记录的parentId
BeanUtil.copyProperties(parent, metaDataCategory);
metaDataCategory.setCategoryType(1);
metaDataCategory.setCategoryName(tableName);
metaDataCategoryService.save(metaDataCategory);
return ResultVo.success(builder); return ResultVo.success(builder);
} }
} }
...@@ -89,4 +89,6 @@ public class MetaDataVo { ...@@ -89,4 +89,6 @@ public class MetaDataVo {
private Date updateTime; private Date updateTime;
private String categoryName; private String categoryName;
private String tableName;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment