获取详情树
This commit is contained in:
parent
9370ecf4cc
commit
44a328edce
@ -57,5 +57,5 @@ public interface FeatureResourceApi {
|
||||
|
||||
/** 菜单详情 **/
|
||||
@PostMapping("/api/featureResource/detail")
|
||||
ApiResult<FeatureResourceDetailResp> detail(@RequestParam Long featureId);
|
||||
ApiResult<FeatureResourceTreeNode> detail(@RequestParam Long featureId);
|
||||
}
|
||||
|
||||
@ -76,8 +76,8 @@ public class FeatureResourceController implements FeatureResourceApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<FeatureResourceDetailResp> detail(Long featureId) {
|
||||
return null;
|
||||
public ApiResult<FeatureResourceTreeNode> detail(Long featureId) {
|
||||
return ApiResult.ok(featureResourceService.getTreeFeatureDescendant(featureId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
package cn.axzo.tyr.server.model.convert;
|
||||
|
||||
import cn.axzo.maokai.api.vo.request.UpdateNodeWorkerReq;
|
||||
import cn.axzo.tyr.client.model.res.FeatureResourceTreeNode;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeatureResource;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface SaasFeatureResourceConvert {
|
||||
|
||||
SaasFeatureResourceConvert INSTANCE = Mappers.getMapper(SaasFeatureResourceConvert.class);
|
||||
|
||||
FeatureResourceTreeNode convert(SaasFeatureResource req);
|
||||
}
|
||||
@ -23,6 +23,8 @@ public interface SaasFeatureResourceService {
|
||||
/**递归的**/
|
||||
List<SaasFeatureResource> listDescendant(Long featureId);
|
||||
|
||||
FeatureResourceTreeNode getTreeFeatureDescendant(Long featureId);
|
||||
|
||||
/**删除指定菜单**/
|
||||
void deleteMenuFeature(Long featureId, Long operatorId);
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.tyr.server.service.impl;
|
||||
|
||||
import cn.axzo.basics.auth.vo.resp.SaasFeatureTreeResp;
|
||||
import cn.axzo.basics.common.BeanMapper;
|
||||
import cn.axzo.basics.common.util.StopWatchUtil;
|
||||
import cn.axzo.basics.common.util.TreeUtil;
|
||||
@ -15,6 +16,7 @@ import cn.axzo.tyr.client.model.res.FeatureResourceDTO;
|
||||
import cn.axzo.tyr.client.model.res.FeatureResourceTreeNode;
|
||||
import cn.axzo.tyr.server.model.ResourcePermission;
|
||||
import cn.axzo.tyr.server.model.ResourcePermissionQueryDTO;
|
||||
import cn.axzo.tyr.server.model.convert.SaasFeatureResourceConvert;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasFeatureResourceDao;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeatureResource;
|
||||
import cn.axzo.tyr.server.service.SaasFeatureResourceService;
|
||||
@ -30,6 +32,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@ -158,6 +161,23 @@ public class SaasFeatureResourceServiceImpl implements SaasFeatureResourceServic
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureResourceTreeNode getTreeFeatureDescendant(Long featureId) {
|
||||
List<SaasFeatureResource> descendants = featureResourceDao.lambdaQuery()
|
||||
.eq(BaseEntity::getIsDelete,0)
|
||||
.apply("FIND_IN_SET('" + featureId + "', path)")
|
||||
.list();
|
||||
if (CollectionUtil.isEmpty(descendants)) {
|
||||
return null;
|
||||
}
|
||||
List<FeatureResourceTreeNode> treeList = TreeUtil.buildTree(descendants.stream()
|
||||
.map(SaasFeatureResourceConvert.INSTANCE::convert)
|
||||
.sorted(Comparator.comparing(FeatureResourceDTO::getDisplayOrder))
|
||||
.collect(Collectors.toList()));
|
||||
return treeList.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CacheEvict(value = SaasFeatureResourceCacheService.CACHE_FEATURE_RESOURCE_TREE,allEntries = true)
|
||||
public void saveOrUpdateMenu(FeatureResourceTreeSaveReq req) {
|
||||
SaasFeatureResource baseResource = BeanMapper.copyBean(req, SaasFeatureResource.class);
|
||||
@ -180,7 +200,7 @@ public class SaasFeatureResourceServiceImpl implements SaasFeatureResourceServic
|
||||
List<FeatureComponentSaveReq> components = req.getComponentSaveReqList();
|
||||
for (int i = 0; i < components.size(); i++) {
|
||||
FeatureComponentSaveReq childComponent = components.get(i);
|
||||
if (childComponent.getParentId() != null) {
|
||||
if (childComponent.getParentId() == null) {
|
||||
childComponent.setParentId(baseResource.getId());
|
||||
}
|
||||
// 递归新增修改删除子节点
|
||||
@ -209,9 +229,6 @@ public class SaasFeatureResourceServiceImpl implements SaasFeatureResourceServic
|
||||
} else {
|
||||
saasFeatureResource.setCreateBy(operatorId);
|
||||
newResource(saasFeatureResource, parentPath);
|
||||
// featureResourceDao.save(saasFeatureResource);
|
||||
// saasFeatureResource.setPath(parentPath + "," + saasFeatureResource.getId());
|
||||
// featureResourceDao.updateById(saasFeatureResource);
|
||||
}
|
||||
|
||||
List<FeatureComponentSaveReq> children = featureComponentSaveReq.getChildren();
|
||||
@ -357,4 +374,6 @@ public class SaasFeatureResourceServiceImpl implements SaasFeatureResourceServic
|
||||
|
||||
return rootNodes;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user