fix(2227-baseTree): 增加基准路由查询接口

This commit is contained in:
zhansihu 2024-04-11 17:18:44 +08:00
parent 44d1c21e47
commit dc235edbff
5 changed files with 31 additions and 3 deletions

View File

@ -58,4 +58,8 @@ public interface FeatureResourceApi {
/** 菜单详情 **/
@PostMapping("/api/featureResource/detail")
ApiResult<FeatureResourceTreeNode> detail(@RequestParam Long featureId);
/** 从基准环境查询功能资源树 **/
@PostMapping("/api/featureResource/getBaseTree")
ApiResult<List<FeatureResourceTreeNode>> getBaseTree(@RequestBody @Valid GetFeatureResourceTreeReq req);
}

View File

@ -84,4 +84,9 @@ public class FeatureResourceController implements FeatureResourceApi {
public ApiResult<List<FeatureResourceTreeNode>> getTree(GetFeatureResourceTreeReq req) {
return ApiResult.ok(featureResourceService.getTree(req));
}
@Override
public ApiResult<List<FeatureResourceTreeNode>> getBaseTree(GetFeatureResourceTreeReq req) {
return ApiResult.ok(featureResourceSyncService.getBaseTree(req));
}
}

View File

@ -1,11 +1,16 @@
package cn.axzo.tyr.server.inner.feign;
import cn.axzo.framework.domain.web.result.ApiResult;
import cn.axzo.tyr.client.model.req.GetFeatureResourceTreeReq;
import cn.axzo.tyr.client.model.res.FeatureResourceTreeNode;
import cn.axzo.tyr.client.model.res.NavTreeResp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.Valid;
import java.util.List;
/**
@ -15,12 +20,16 @@ import java.util.List;
* @author: ZhanSiHu
* @date: 2024/4/3 10:25
*/
//@FeignClient(name = "tyr", url = "${axzo.service.base.tyr:https://pre-api.axzo.cn/tyr}")
@FeignClient(name = "tyr", url = "${axzo.service.base.tyr:http://127.0.0.1:8080}")
@FeignClient(name = "tyr", url = "${axzo.service.base.tyr:https://pre-api.axzo.cn/tyr}")
public interface BaseFeatureResourceApi {
/** 从基准环境同步接口功能资源 - 批量限制20条 **/
@PostMapping("/api/featureResource/sync/getTreeById")
@GetMapping("/api/featureResource/sync/getTreeById")
ApiResult<List<FeatureResourceTreeNode>> getSyncTreeById(@RequestParam Long id);
/** 从基准环境拉取资源树 **/
@PostMapping("/api/featureResource/getTree")
ApiResult<List<FeatureResourceTreeNode>> getTree(@RequestBody @Valid GetFeatureResourceTreeReq req);
}

View File

@ -1,5 +1,6 @@
package cn.axzo.tyr.server.service;
import cn.axzo.tyr.client.model.req.GetFeatureResourceTreeReq;
import cn.axzo.tyr.client.model.req.ResourceSyncReq;
import cn.axzo.tyr.client.model.res.FeatureResourceTreeNode;
@ -17,4 +18,6 @@ public interface FeatureResourceSyncService {
List<FeatureResourceTreeNode> getSyncTreeById(Long id);
void syncFromBase(ResourceSyncReq req);
List<FeatureResourceTreeNode> getBaseTree(GetFeatureResourceTreeReq req);
}

View File

@ -3,6 +3,7 @@ package cn.axzo.tyr.server.service.impl;
import cn.axzo.basics.common.BeanMapper;
import cn.axzo.basics.common.util.TreeUtil;
import cn.axzo.tyr.client.common.enums.FeatureResourceType;
import cn.axzo.tyr.client.model.req.GetFeatureResourceTreeReq;
import cn.axzo.tyr.client.model.req.ResourceSyncReq;
import cn.axzo.tyr.client.model.res.FeatureResourceTreeNode;
import cn.axzo.tyr.server.inner.feign.BaseFeatureResourceApi;
@ -75,6 +76,12 @@ public class FeatureResourceSyncServiceImpl implements FeatureResourceSyncServic
}
}
@Override
public List<FeatureResourceTreeNode> getBaseTree(GetFeatureResourceTreeReq req) {
return RpcInternalUtil.rpcProcessor(() -> baseFeatureResourceApi.getTree(req),
"get resource tree from base env", req).getData();
}
private void doSyncFromBase(List<FeatureResourceTreeNode> syncList, Map<Long, String> codeCache, Long operatorId) {
for (FeatureResourceTreeNode treeNode : syncList) {