提交 6146e96f authored 作者: 任建宇's avatar 任建宇

feat: 检索

1.resource
上级 d4a7fcb2
...@@ -98,7 +98,7 @@ public class DiyTypeController { ...@@ -98,7 +98,7 @@ public class DiyTypeController {
entity.setCode(UUIDUtil.newCodeOfThree(code)); entity.setCode(UUIDUtil.newCodeOfThree(code));
} else { } else {
//没有查询到子分类,获取父类code 拼接 001 //没有查询到子分类,获取父类code 拼接 001
if (!entity.getParentId().equals("0")) { if (entity.getParentId() != 0) {
entity.setCode(service.getById(entity.getParentId()).getCode() + "001"); entity.setCode(service.getById(entity.getParentId()).getCode() + "001");
} else { } else {
entity.setCode("001"); entity.setCode("001");
...@@ -180,7 +180,7 @@ public class DiyTypeController { ...@@ -180,7 +180,7 @@ public class DiyTypeController {
@GetMapping(value = "/{oid}") @GetMapping(value = "/{oid}")
public CallBack<DiyType> getById(@PathVariable Integer oid) { public CallBack<DiyType> getById(@PathVariable Integer oid) {
DiyType diyType = service.getById(oid); DiyType diyType = service.getById(oid);
if (!diyType.getParentId().equals("0")) { if (diyType.getParentId() != 0) {
DiyType parentDiyType = service.getById(diyType.getParentId()); DiyType parentDiyType = service.getById(diyType.getParentId());
diyType.setParentName(parentDiyType.getTypeName()); diyType.setParentName(parentDiyType.getTypeName());
} }
...@@ -267,7 +267,7 @@ public class DiyTypeController { ...@@ -267,7 +267,7 @@ public class DiyTypeController {
} }
PageHelper.orderBy("sort desc,createdTime desc"); PageHelper.orderBy("sort desc,createdTime desc");
List<DiyType> list = service.list(diyTypeLambdaQueryWrapper); List<DiyType> list = service.list(diyTypeLambdaQueryWrapper);
List<DiyTypeVO> voList = Copy.copyList(list , DiyTypeVO.class, obj -> obj.getParentId().equals("0")); List<DiyTypeVO> voList = Copy.copyList(list , DiyTypeVO.class, obj -> obj.getParentId().intValue() == 0);
tree(list,voList); tree(list,voList);
return CallBack.success(voList); return CallBack.success(voList);
} }
...@@ -305,7 +305,7 @@ public class DiyTypeController { ...@@ -305,7 +305,7 @@ public class DiyTypeController {
PageHelper.orderBy("sort desc,createdTime desc"); PageHelper.orderBy("sort desc,createdTime desc");
List<DiyType> list = service.list(diyTypeLambdaQueryWrapper); List<DiyType> list = service.list(diyTypeLambdaQueryWrapper);
// 获取一级分类 // 获取一级分类
List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class, obj -> name.equals(obj.getTypeName()) && obj.getParentId().equals("0")); List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class, obj -> name.equals(obj.getTypeName()) && obj.getParentId() == 0);
tree(list, voList); tree(list, voList);
return CallBack.success(convertAllToOne(voList, vos)); return CallBack.success(convertAllToOne(voList, vos));
...@@ -314,7 +314,7 @@ public class DiyTypeController { ...@@ -314,7 +314,7 @@ public class DiyTypeController {
public List<DiyTypeVO> tree(List<DiyType> list, List<DiyTypeVO> voList) { public List<DiyTypeVO> tree(List<DiyType> list, List<DiyTypeVO> voList) {
voList.forEach(entity -> { voList.forEach(entity -> {
//第一次设置 一级分类的子类 后续递归设置 子类的子类 //第一次设置 一级分类的子类 后续递归设置 子类的子类
entity.setList(Copy.copyList(list, DiyTypeVO.class, obj -> obj.getParentId().equals(entity.getId()))); entity.setList(Copy.copyList(list, DiyTypeVO.class, obj -> obj.getParentId().intValue() == entity.getId().intValue()));
//当前分类存在子类 开始递归子类 //当前分类存在子类 开始递归子类
if (entity.getList().size() > 0) { if (entity.getList().size() > 0) {
tree(list, entity.getList()); tree(list, entity.getList());
...@@ -362,15 +362,15 @@ public class DiyTypeController { ...@@ -362,15 +362,15 @@ public class DiyTypeController {
List<DiyType> list = call.getData(); List<DiyType> list = call.getData();
List<DiyTypeVO> newTree = new ArrayList<>(); List<DiyTypeVO> newTree = new ArrayList<>();
// 获取一级分类 // 获取一级分类
List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class, obj -> search.equals(obj.getTypeName()) && !obj.getParentId().equals("0")); List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class, obj -> search.equals(obj.getTypeName()) && obj.getParentId() != 0);
if (!voList.isEmpty()) { if (!voList.isEmpty()) {
String id = voList.get(0).getParentId(); Integer id = voList.get(0).getParentId();
List<DiyType> diyList = new ArrayList<>(); List<DiyType> diyList = new ArrayList<>();
do { do {
DiyType diyType = service.getById(id); DiyType diyType = service.getById(id);
id = diyType.getParentId(); id = diyType.getParentId();
diyList.add(diyType); diyList.add(diyType);
} while (!id.equals("0")); } while (id != 0);
List<DiyTypeVO> fathor = getDiyTypeVO(diyList); List<DiyTypeVO> fathor = getDiyTypeVO(diyList);
List<DiyTypeVO> child = tree(list, voList); List<DiyTypeVO> child = tree(list, voList);
newTree = connect(fathor, child); newTree = connect(fathor, child);
...@@ -389,7 +389,7 @@ public class DiyTypeController { ...@@ -389,7 +389,7 @@ public class DiyTypeController {
} }
public List<DiyTypeVO> getDiyTypeVO(List<DiyType> list) { public List<DiyTypeVO> getDiyTypeVO(List<DiyType> list) {
List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class, obj -> obj.getParentId().equals("0")); List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class, obj -> obj.getParentId() == 0);
tree(list, voList); tree(list, voList);
return voList; return voList;
} }
...@@ -464,7 +464,7 @@ public class DiyTypeController { ...@@ -464,7 +464,7 @@ public class DiyTypeController {
} }
} }
list.forEach(f -> { list.forEach(f -> {
if (!f.getParentId().equals("0")) { if (f.getParentId() != 0) {
DiyType parentDiyType = service.getById(f.getParentId()); DiyType parentDiyType = service.getById(f.getParentId());
if (parentDiyType != null) { if (parentDiyType != null) {
f.setParentName(parentDiyType.getTypeName()); f.setParentName(parentDiyType.getTypeName());
...@@ -473,7 +473,7 @@ public class DiyTypeController { ...@@ -473,7 +473,7 @@ public class DiyTypeController {
}); });
// 获取一级分类 // 获取一级分类
List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class, obj -> form.getName().equals(obj.getTypeName()) && obj.getParentId().equals("0")); List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class, obj -> form.getName().equals(obj.getTypeName()) && obj.getParentId() == 0);
tree(list, voList); tree(list, voList);
voList.forEach(f -> f.getList().forEach(ff -> { voList.forEach(f -> f.getList().forEach(ff -> {
Integer resourceNum = service.selectResourceNum(ff.getCode()); Integer resourceNum = service.selectResourceNum(ff.getCode());
......
...@@ -102,7 +102,7 @@ public class DiyTypeController { ...@@ -102,7 +102,7 @@ public class DiyTypeController {
//PageHelper.orderBy("sort desc,createdTime desc"); //PageHelper.orderBy("sort desc,createdTime desc");
PageHelper.orderBy("sort asc"); PageHelper.orderBy("sort asc");
List<DiyType> list = service.list(diyTypeLambdaQueryWrapper); List<DiyType> list = service.list(diyTypeLambdaQueryWrapper);
List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class, obj -> obj.getParentId().equals("0")); List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class, obj -> obj.getParentId() == 0);
tree(list, voList); tree(list, voList);
return CallBack.success(voList); return CallBack.success(voList);
} }
...@@ -120,7 +120,7 @@ public class DiyTypeController { ...@@ -120,7 +120,7 @@ public class DiyTypeController {
PageHelper.orderBy("sort asc"); PageHelper.orderBy("sort asc");
List<DiyType> list = service.list(diyTypeLambdaQueryWrapper); List<DiyType> list = service.list(diyTypeLambdaQueryWrapper);
list.forEach(f -> { list.forEach(f -> {
if (!f.getParentId().equals("0")) { if (f.getParentId() != 0) {
DiyType parentDiyType = service.getById(f.getParentId()); DiyType parentDiyType = service.getById(f.getParentId());
if (parentDiyType != null) { if (parentDiyType != null) {
f.setParentName(parentDiyType.getTypeName()); f.setParentName(parentDiyType.getTypeName());
...@@ -128,7 +128,7 @@ public class DiyTypeController { ...@@ -128,7 +128,7 @@ public class DiyTypeController {
} }
}); });
// 获取一级分类 // 获取一级分类
List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class, obj -> name.equals(obj.getTypeName()) && obj.getParentId().equals("0")); List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class, obj -> name.equals(obj.getTypeName()) && obj.getParentId() == 0);
tree(list, voList); tree(list, voList);
voList.forEach(f -> f.getList().forEach(ff -> { voList.forEach(f -> f.getList().forEach(ff -> {
Integer resourceNum = service.selectResourceNum(ff.getCode()); Integer resourceNum = service.selectResourceNum(ff.getCode());
...@@ -182,7 +182,7 @@ public class DiyTypeController { ...@@ -182,7 +182,7 @@ public class DiyTypeController {
public List<DiyTypeVO> tree(List<DiyType> list, List<DiyTypeVO> voList) { public List<DiyTypeVO> tree(List<DiyType> list, List<DiyTypeVO> voList) {
voList.forEach(entity -> { voList.forEach(entity -> {
//第一次设置 一级分类的子类 后续递归设置 子类的子类 //第一次设置 一级分类的子类 后续递归设置 子类的子类
entity.setList(Copy.copyList(list, DiyTypeVO.class, obj -> obj.getParentId().equals(entity.getId()))); entity.setList(Copy.copyList(list, DiyTypeVO.class, obj -> obj.getParentId().intValue() == entity.getId().intValue()));
Integer resourceNum = service.selectResourceNum(entity.getCode()); Integer resourceNum = service.selectResourceNum(entity.getCode());
entity.setResourceNum(resourceNum); entity.setResourceNum(resourceNum);
//当前分类存在子类 开始递归子类 //当前分类存在子类 开始递归子类
...@@ -218,7 +218,7 @@ public class DiyTypeController { ...@@ -218,7 +218,7 @@ public class DiyTypeController {
List<String> codes = facet.getValues().stream().map(FacetField.Count:: getName).collect(Collectors.toList()); List<String> codes = facet.getValues().stream().map(FacetField.Count:: getName).collect(Collectors.toList());
// 保证一级分类始终显示(无论是否有数据) // 保证一级分类始终显示(无论是否有数据)
oldVos.stream().forEach(oldVo -> { oldVos.stream().forEach(oldVo -> {
if(oldVo.getParentId().equals("0")){ if(oldVo.getParentId() == 0){
codes.add(oldVo.getCode()); codes.add(oldVo.getCode());
} }
}); });
......
...@@ -16,15 +16,15 @@ import java.util.Date; ...@@ -16,15 +16,15 @@ import java.util.Date;
@TableName("res_diy_type") @TableName("res_diy_type")
public class DiyType { public class DiyType {
@TableId(value = "id", type = IdType.ASSIGN_UUID) @TableId(value = "id", type = IdType.AUTO)
@ApiModelProperty("自定义分类id,新增时不需要填写") @ApiModelProperty("自定义分类id,新增时不需要填写")
private String id; private Integer id;
@ApiModelProperty(value = "自定义分类名称", required = true) @ApiModelProperty(value = "自定义分类名称", required = true)
private String typeName; private String typeName;
@ApiModelProperty(value = "显示名称", required = true) @ApiModelProperty(value = "显示名称", required = true)
private String showName; private String showName;
@ApiModelProperty(value = "父类id", required = true) @ApiModelProperty(value = "父类id", required = true)
private String parentId; private Integer parentId;
@ApiModelProperty(value = "排序号") @ApiModelProperty(value = "排序号")
private Integer sort; private Integer sort;
@ApiModelProperty(value = "分类编号", required = true) @ApiModelProperty(value = "分类编号", required = true)
......
...@@ -10,9 +10,9 @@ import java.util.List; ...@@ -10,9 +10,9 @@ import java.util.List;
@Data @Data
public class DiyTypeVO { public class DiyTypeVO {
@ApiModelProperty("自定义分类id") @ApiModelProperty("自定义分类id")
private String id; private Integer id;
@ApiModelProperty(value = "父类id") @ApiModelProperty(value = "父类id")
private String parentId; private Integer parentId;
@ApiModelProperty(value = "排序号") @ApiModelProperty(value = "排序号")
private Integer sort; private Integer sort;
@ApiModelProperty(value = "自定义分类名称") @ApiModelProperty(value = "自定义分类名称")
......
...@@ -9,9 +9,9 @@ import java.util.List; ...@@ -9,9 +9,9 @@ import java.util.List;
@Data @Data
public class FgDiyTypeListVo { public class FgDiyTypeListVo {
@ApiModelProperty("自定义分类id") @ApiModelProperty("自定义分类id")
private String id; private Integer id;
@ApiModelProperty(value = "父类id") @ApiModelProperty(value = "父类id")
private String parentId; private Integer parentId;
@ApiModelProperty(value = "排序号") @ApiModelProperty(value = "排序号")
private Integer sort; private Integer sort;
@ApiModelProperty(value = "显示名称") @ApiModelProperty(value = "显示名称")
......
...@@ -12,9 +12,9 @@ import java.util.List; ...@@ -12,9 +12,9 @@ import java.util.List;
public class FgDiyTypeVo { public class FgDiyTypeVo {
@ApiModelProperty("自定义分类id") @ApiModelProperty("自定义分类id")
private String id; private Integer id;
@ApiModelProperty(value = "父类id") @ApiModelProperty(value = "父类id")
private String parentId; private Integer parentId;
@ApiModelProperty(value = "排序号") @ApiModelProperty(value = "排序号")
private Integer sort; private Integer sort;
@ApiModelProperty(value = "自定义分类名称", required = true) @ApiModelProperty(value = "自定义分类名称", required = true)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论