feat(情报板协议树列表):

This commit is contained in:
fuhao 2024-09-04 18:30:42 +08:00
parent 1c2a8b9ca4
commit dd55cd3072
No known key found for this signature in database
5 changed files with 50 additions and 2 deletions

View File

@ -88,4 +88,13 @@ public class BoardProtocolController extends BaseController {
public AjaxResult remove(@PathVariable List<Long> ids) {
return toAjax(boardProtocolService.removeByIds(ids));
}
/**
* 获取协议树列表
*/
@PreAuthorize("@ss.hasPermi('plan:type:list')")
@GetMapping("/protocolTree")
public AjaxResult deptTree(BoardProtocol planType) {
return success(boardProtocolService.listProtocolTree(planType));
}
}

View File

@ -13,7 +13,7 @@ import lombok.Data;
@TableName(value = "pub_board_protocol")
public class BoardProtocol {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private Long id;
/**
* 情报板品牌

View File

@ -2,6 +2,10 @@ package com.ruoyi.board.service;
import com.github.yulichang.base.MPJBaseService;
import com.ruoyi.board.domain.BoardProtocol;
import com.ruoyi.common.core.domain.TreeSelect;
import java.util.List;
public interface IBoardProtocolService extends MPJBaseService<BoardProtocol> {
List<TreeSelect> listProtocolTree(BoardProtocol planType);
}

View File

@ -4,9 +4,44 @@ import com.github.yulichang.base.MPJBaseServiceImpl;
import com.ruoyi.board.domain.BoardProtocol;
import com.ruoyi.board.mapper.BoardProtocolMapper;
import com.ruoyi.board.service.IBoardProtocolService;
import com.ruoyi.common.core.domain.TreeSelect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class BoardProtocolServiceImpl extends MPJBaseServiceImpl<BoardProtocolMapper, BoardProtocol> implements IBoardProtocolService {
private static final Logger log = LoggerFactory.getLogger(BoardProtocolServiceImpl.class);
private static final Long DEFAULT_ID = 0L;
@Override
public List<TreeSelect> listProtocolTree(BoardProtocol planType) {
List<BoardProtocol> protocols = list();
Map<String, List<BoardProtocol>> protocolsByBrand = protocols.stream().collect(Collectors.groupingBy(BoardProtocol::getBrand));
List<TreeSelect> treeSelects = new ArrayList<>();
protocolsByBrand.forEach((brand, brandProtocols) -> treeSelects.add(createTreeSelectForBrand(brand, brandProtocols)));
return treeSelects;
}
private TreeSelect createTreeSelectForBrand(String brand, List<BoardProtocol> brandProtocols) {
TreeSelect treeSelect = new TreeSelect();
treeSelect.setLabel(brand);
treeSelect.setId(DEFAULT_ID);
treeSelect.setChildren(brandProtocols.stream().map(this::mapToTreeSelect).collect(Collectors.toList()));
return treeSelect;
}
private TreeSelect mapToTreeSelect(BoardProtocol protocol) {
TreeSelect treeSelect = new TreeSelect();
treeSelect.setId(protocol.getId());
treeSelect.setLabel(protocol.getProtocol());
return treeSelect;
}
}

View File

@ -33,7 +33,7 @@ public class PlanTypeServiceImpl extends MPJBaseServiceImpl<PlanTypeMapper, Plan
treeSelect.setLabel(planType.getTypeName());
treeSelect.setChildren(childTreeSelectList);
return treeSelect;
};
}
private List<PlanType> buildPlanTree(List<PlanType> list) {
List<PlanType> returnList = new ArrayList<>();