feat(情报板协议树列表):
This commit is contained in:
parent
1c2a8b9ca4
commit
dd55cd3072
|
@ -88,4 +88,13 @@ public class BoardProtocolController extends BaseController {
|
||||||
public AjaxResult remove(@PathVariable List<Long> ids) {
|
public AjaxResult remove(@PathVariable List<Long> ids) {
|
||||||
return toAjax(boardProtocolService.removeByIds(ids));
|
return toAjax(boardProtocolService.removeByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取协议树列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('plan:type:list')")
|
||||||
|
@GetMapping("/protocolTree")
|
||||||
|
public AjaxResult deptTree(BoardProtocol planType) {
|
||||||
|
return success(boardProtocolService.listProtocolTree(planType));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import lombok.Data;
|
||||||
@TableName(value = "pub_board_protocol")
|
@TableName(value = "pub_board_protocol")
|
||||||
public class BoardProtocol {
|
public class BoardProtocol {
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
private Integer id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 情报板品牌
|
* 情报板品牌
|
||||||
|
|
|
@ -2,6 +2,10 @@ package com.ruoyi.board.service;
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseService;
|
import com.github.yulichang.base.MPJBaseService;
|
||||||
import com.ruoyi.board.domain.BoardProtocol;
|
import com.ruoyi.board.domain.BoardProtocol;
|
||||||
|
import com.ruoyi.common.core.domain.TreeSelect;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface IBoardProtocolService extends MPJBaseService<BoardProtocol> {
|
public interface IBoardProtocolService extends MPJBaseService<BoardProtocol> {
|
||||||
|
List<TreeSelect> listProtocolTree(BoardProtocol planType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,44 @@ import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||||
import com.ruoyi.board.domain.BoardProtocol;
|
import com.ruoyi.board.domain.BoardProtocol;
|
||||||
import com.ruoyi.board.mapper.BoardProtocolMapper;
|
import com.ruoyi.board.mapper.BoardProtocolMapper;
|
||||||
import com.ruoyi.board.service.IBoardProtocolService;
|
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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class BoardProtocolServiceImpl extends MPJBaseServiceImpl<BoardProtocolMapper, BoardProtocol> implements IBoardProtocolService {
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class PlanTypeServiceImpl extends MPJBaseServiceImpl<PlanTypeMapper, Plan
|
||||||
treeSelect.setLabel(planType.getTypeName());
|
treeSelect.setLabel(planType.getTypeName());
|
||||||
treeSelect.setChildren(childTreeSelectList);
|
treeSelect.setChildren(childTreeSelectList);
|
||||||
return treeSelect;
|
return treeSelect;
|
||||||
};
|
}
|
||||||
|
|
||||||
private List<PlanType> buildPlanTree(List<PlanType> list) {
|
private List<PlanType> buildPlanTree(List<PlanType> list) {
|
||||||
List<PlanType> returnList = new ArrayList<>();
|
List<PlanType> returnList = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in New Issue