Commit 4a59a5df by ljb

增加元数据目录树形查询

parent 1dd2675f
package org.spiderflow.controller; package org.spiderflow.controller;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import lombok.RequiredArgsConstructor; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.spiderflow.entity.MetaDataCategory; import org.spiderflow.entity.MetaDataCategory;
import org.spiderflow.service.MetaDataCategoryService; import org.spiderflow.service.MetaDataCategoryService;
import org.spiderflow.util.AssertUtils; import org.spiderflow.util.AssertUtils;
...@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
@Api(tags = "元数据目录")
@RestController @RestController
@RequestMapping(value = "/spiderflow/metadataCategory") @RequestMapping(value = "/spiderflow/metadataCategory")
public class MetaDataCategoryController { public class MetaDataCategoryController {
...@@ -58,7 +60,7 @@ public class MetaDataCategoryController { ...@@ -58,7 +60,7 @@ public class MetaDataCategoryController {
public ResultVo add(@RequestBody MetaDataCategory metaDataCategory) { public ResultVo add(@RequestBody MetaDataCategory metaDataCategory) {
AssertUtils.notNull(metaDataCategory.getCategoryName(), "缺少类别目录名称"); AssertUtils.notNull(metaDataCategory.getCategoryName(), "缺少类别目录名称");
AssertUtils.notNull(metaDataCategory.getStandardLevel(), "缺少类别目录级别"); AssertUtils.notNull(metaDataCategory.getStandardLevel(), "缺少类别目录级别");
metaDataCategory.setCategoryCode(IdUtil.fastSimpleUUID()); metaDataCategory.setCategoryCode(IdUtil.simpleUUID());
boolean b = metaDataCategoryService.save(metaDataCategory); boolean b = metaDataCategoryService.save(metaDataCategory);
return b ? ResultVo.success("操作成功!") : ResultVo.fail("操作失败"); return b ? ResultVo.success("操作成功!") : ResultVo.fail("操作失败");
} }
...@@ -98,4 +100,11 @@ public class MetaDataCategoryController { ...@@ -98,4 +100,11 @@ public class MetaDataCategoryController {
boolean b = metaDataCategoryService.removeById(id); boolean b = metaDataCategoryService.removeById(id);
return b ? ResultVo.success("操作成功!") : ResultVo.fail("操作失败!"); return b ? ResultVo.success("操作成功!") : ResultVo.fail("操作失败!");
} }
@ApiOperation("树形查询目录")
@GetMapping("/tree")
public ResultVo getCategoryTree(@RequestParam(value = "categoryCode", required = false) Integer categoryCode,
@RequestParam(value = "currentLevel", defaultValue = "0") Integer currentLevel){
return ResultVo.success(metaDataCategoryService.getCategoryTree(categoryCode, currentLevel));
}
} }
\ No newline at end of file
...@@ -35,9 +35,14 @@ public class MetaDataCategory { ...@@ -35,9 +35,14 @@ public class MetaDataCategory {
private String categoryCode; private String categoryCode;
/** /**
* 游戏品种名称 * 目录级别(顶级:0)
*/ */
private String standardLevel; private Integer standardLevel;
/**
* 子目录数
*/
private Integer subCount;
/** /**
* createTime * createTime
......
...@@ -11,6 +11,8 @@ import org.spiderflow.vo.PageVo; ...@@ -11,6 +11,8 @@ import org.spiderflow.vo.PageVo;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Service @Service
public class MetaDataCategoryService extends ServiceImpl<MetaDataCategoryDao, MetaDataCategory> { public class MetaDataCategoryService extends ServiceImpl<MetaDataCategoryDao, MetaDataCategory> {
...@@ -22,4 +24,14 @@ public class MetaDataCategoryService extends ServiceImpl<MetaDataCategoryDao, Me ...@@ -22,4 +24,14 @@ public class MetaDataCategoryService extends ServiceImpl<MetaDataCategoryDao, Me
LambdaQueryWrapper<MetaDataCategory> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<MetaDataCategory> wrapper = new LambdaQueryWrapper<>();
return PagingUtils.paging(req, metaDataCategoryDao, wrapper, MetaDataCategory.class); return PagingUtils.paging(req, metaDataCategoryDao, wrapper, MetaDataCategory.class);
} }
public List<MetaDataCategory> getCategoryTree(Integer categoryCode, Integer currentLevel){
List<MetaDataCategory> list;
if(null == categoryCode){
list = lambdaQuery().eq(MetaDataCategory::getStandardLevel, 0).list();
}else {
list = lambdaQuery().eq(MetaDataCategory::getCategoryCode, categoryCode).eq(MetaDataCategory::getStandardLevel, ++currentLevel).orderByAsc(MetaDataCategory::getId).list();
}
return list;
}
} }
\ No newline at end of file
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