|
|
@@ -5,10 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.hz.pm.api.common.util.StrUtils; |
|
|
|
import com.hz.pm.api.external.model.enumeration.MhUnitTypeEnum; |
|
|
|
import com.hz.pm.api.user.helper.MhUnitCache; |
|
|
|
import com.hz.pm.api.user.model.dto.UnitDTO; |
|
|
|
import com.hz.pm.api.user.model.dto.MhUnitTreeDTO; |
|
|
|
import com.hz.pm.api.user.model.dto.MhUnitUserTreeDTO; |
|
|
|
import com.hz.pm.api.user.model.dto.UnitDTO; |
|
|
|
import com.hz.pm.api.user.model.entity.MhUnit; |
|
|
|
import com.hz.pm.api.user.model.entity.UserInfo; |
|
|
|
import com.hz.pm.api.user.model.enumeration.UnitUserNodeType; |
|
|
@@ -26,6 +27,7 @@ import org.springframework.stereotype.Component; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* <p> |
|
|
@@ -45,7 +47,11 @@ public class MhUnitManage { |
|
|
|
|
|
|
|
public List<MhUnitTreeDTO> getMhUnitTree() { |
|
|
|
List<UnitDTO> allUnits = mhUnitCache.all(); |
|
|
|
List<MhUnitTreeDTO> nodes = BeanUtil.copyToList(allUnits, MhUnitTreeDTO.class); |
|
|
|
List<MhUnitTreeDTO> nodes = allUnits.stream().map(w -> { |
|
|
|
MhUnitTreeDTO node = BeanUtil.copyProperties(w, MhUnitTreeDTO.class); |
|
|
|
node.setStrip(node.getStrip()); |
|
|
|
return node; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
return TreeUtil.convertToTree(nodes, 0L); |
|
|
|
} |
|
|
|
|
|
|
@@ -56,7 +62,16 @@ public class MhUnitManage { |
|
|
|
if (page.getTotal() == 0) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
List<MhUnitListVO> records = BeanUtil.copyToList(page.getRecords(), MhUnitListVO.class); |
|
|
|
List<MhUnitListVO> records = page.getRecords().stream().map(w -> { |
|
|
|
MhUnitListVO unit = BeanUtil.copyProperties(w, MhUnitListVO.class, "type"); |
|
|
|
MhUnitTypeEnum.getByCode(w.getType()).ifPresent(type -> { |
|
|
|
unit.setType(type); |
|
|
|
unit.setStrip(type.getStrip()); |
|
|
|
unit.setTypeName(type.getVal()); |
|
|
|
unit.setStripName(type.getStrip().getName()); |
|
|
|
}); |
|
|
|
return unit; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
return PageVo.of(records, page.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|