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

feat: 检索

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