完善[报表列表接口]功能,增加返回标签列表功能,增加按标签查询功能
This commit is contained in:
+1
-1
@@ -54,7 +54,7 @@ public class TreeLabelManagerController {
|
||||
@ApiOperation("获取当前标签的父级路径")
|
||||
@GetMapping("/labelList/{id}")
|
||||
public ResponseMessage parentLabelList(@PathVariable String id) {
|
||||
List<String> labelList = iTreeLabelService.getLabelList(id);
|
||||
List<String> labelList = iTreeLabelService.getParentLabelList(id);
|
||||
return Result.success(labelList);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @Author doudxw
|
||||
@@ -17,11 +18,13 @@ public interface ReportDao extends BaseMapper<ReportEntity> {
|
||||
|
||||
/**
|
||||
* 报告列表
|
||||
*
|
||||
* @param page
|
||||
* @param vo
|
||||
* @param idSet
|
||||
* @return
|
||||
*/
|
||||
IPage<ReportVo> list(IPage page, @Param("Vo") ReportQueryVo vo);
|
||||
IPage<ReportVo> list(IPage page, @Param("Vo") ReportQueryVo vo, @Param("idSet") Set<String> idSet);
|
||||
|
||||
/**
|
||||
* 报告日期列表
|
||||
|
||||
@@ -50,4 +50,12 @@ public interface ITreeLabelService extends IService<TreeLabelEntity> {
|
||||
* @return
|
||||
*/
|
||||
List<String> getLabelList(String id);
|
||||
|
||||
/**
|
||||
* 获取当前标签的路径(不包括自己)
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<String> getParentLabelList(String id);
|
||||
}
|
||||
|
||||
@@ -216,7 +216,11 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
|
||||
|
||||
IPage<ReportVo> list = reportDao.list(page, vo, idSet);
|
||||
|
||||
IPage<ReportVo> list = reportDao.list(page, vo);
|
||||
|
||||
//获取所有报告的labelId
|
||||
list.getRecords().forEach((reportVo) -> {
|
||||
reportVo.setLabelList(findLabelList(reportVo.getId()));
|
||||
});
|
||||
list.getRecords().forEach(c -> {
|
||||
FileEntity fileEntity = Optional.ofNullable(fileDao.selectById(c.getFileId())).orElse(new FileEntity());
|
||||
if (StringUtils.isEmpty(fileEntity.getFileType())) {
|
||||
@@ -253,6 +257,22 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<String> findLabelList(String id) {
|
||||
LambdaQueryWrapper<ReportLabelEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ReportLabelEntity::getReportId, id);
|
||||
List<ReportLabelEntity> reportLabelEntities = iReportLabelService.list(wrapper);
|
||||
//找出所有路径
|
||||
List<List<String>> labelList = new ArrayList<>();
|
||||
for (ReportLabelEntity entity : reportLabelEntities) {
|
||||
labelList.add(iTreeLabelService.getLabelList(entity.getLabelId()));
|
||||
}
|
||||
//返回最长的那条路径
|
||||
labelList = labelList.stream()
|
||||
.sorted(Comparator.comparingInt(List<String>::size).reversed())
|
||||
.collect(Collectors.toList());
|
||||
return labelList.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 报告删除
|
||||
*
|
||||
|
||||
@@ -164,6 +164,20 @@ public class ITreeLabelServiceImpl extends ServiceImpl<TreeLabelDao, TreeLabelEn
|
||||
|
||||
@Override
|
||||
public List<String> getLabelList(String id) {
|
||||
List<String> labelList = new ArrayList<>();
|
||||
TreeLabelEntity treeLabelEntity = getById(id);
|
||||
while (!TreeLabelConstants.ROOT_TAG_PARENT_ID.equals(treeLabelEntity.getParentId())) {
|
||||
labelList.add(treeLabelEntity.getId());
|
||||
treeLabelEntity = getById(treeLabelEntity.getParentId());
|
||||
}
|
||||
TreeLabelEntity root = getById(TreeLabelConstants.ROOT_LABEL_ID);
|
||||
labelList.add(root.getId());
|
||||
Collections.reverse(labelList);
|
||||
return labelList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getParentLabelList(String id) {
|
||||
List<String> labelList = new ArrayList<>();
|
||||
TreeLabelEntity treeLabelEntity = getById(id);
|
||||
//获取上层标签
|
||||
|
||||
Reference in New Issue
Block a user