|
|
@@ -0,0 +1,38 @@ |
|
|
|
package com.hz.pm.api.user.manage; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.hz.pm.api.common.model.constant.BizConst; |
|
|
|
import com.hz.pm.api.user.model.dto.MhUnitTreeDTO; |
|
|
|
import com.hz.pm.api.user.model.entity.MhUnit; |
|
|
|
import com.hz.pm.api.user.service.IMhUnitService; |
|
|
|
import com.ningdatech.basic.util.TreeUtil; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* <p> |
|
|
|
* MhUnitManage |
|
|
|
* </p> |
|
|
|
* |
|
|
|
* @author WendyYang |
|
|
|
* @since 15:33 2024/1/10 |
|
|
|
*/ |
|
|
|
@Component |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class MhUnitManage { |
|
|
|
|
|
|
|
private final IMhUnitService mhUnitService; |
|
|
|
|
|
|
|
public List<MhUnitTreeDTO> getMhUnitTree() { |
|
|
|
LambdaQueryWrapper<MhUnit> query = Wrappers.lambdaQuery(MhUnit.class) |
|
|
|
.select(MhUnit::getSort, MhUnit::getId, MhUnit::getParentId, MhUnit::getName); |
|
|
|
List<MhUnit> units = mhUnitService.list(query); |
|
|
|
List<MhUnitTreeDTO> nodes = BeanUtil.copyToList(units, MhUnitTreeDTO.class); |
|
|
|
return TreeUtil.convertToTree(nodes, 0L); |
|
|
|
} |
|
|
|
|
|
|
|
} |