From 34981c30a78e8bbd7791131059a9210f9928b62c Mon Sep 17 00:00:00 2001
From: 刘光辉 <347230014@qq.com>
Date: 星期四, 17 九月 2026 09:24:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master

---
 jnpf-app/jnpf-app-controller/src/main/java/jnpf/controller/AppMenuController.java |  131 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 131 insertions(+), 0 deletions(-)

diff --git a/jnpf-app/jnpf-app-controller/src/main/java/jnpf/controller/AppMenuController.java b/jnpf-app/jnpf-app-controller/src/main/java/jnpf/controller/AppMenuController.java
new file mode 100644
index 0000000..5ced833
--- /dev/null
+++ b/jnpf-app/jnpf-app-controller/src/main/java/jnpf/controller/AppMenuController.java
@@ -0,0 +1,131 @@
+package jnpf.controller;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jnpf.base.ActionResult;
+import jnpf.base.Page;
+import jnpf.base.SystemApi;
+import jnpf.base.UserInfo;
+import jnpf.base.model.base.SystemBaeModel;
+import jnpf.base.model.module.ModuleModel;
+import jnpf.base.vo.ListVO;
+import jnpf.constant.JnpfConst;
+import jnpf.model.AppMenuListVO;
+import jnpf.model.UserMenuModel;
+import jnpf.model.login.UserSystemVO;
+import jnpf.permission.AuthorizeApi;
+import jnpf.permission.model.authorize.AuthorizeVO;
+import jnpf.util.JsonUtil;
+import jnpf.util.StringUtil;
+import jnpf.util.UserProvider;
+import jnpf.util.context.RequestContext;
+import jnpf.util.treeutil.ListToTreeUtil;
+import jnpf.util.treeutil.SumTree;
+import jnpf.util.treeutil.newtreeutil.TreeDotUtils;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * app搴旂敤
+ *
+ * @author JNPF寮�鍙戝钩鍙扮粍
+ * @version V3.1.0
+ * @copyright 寮曡繄淇℃伅鎶�鏈湁闄愬叕鍙革紙https://www.jnpfsoft.com锛�
+ * @date 2021-07-08
+ */
+@Tag(name = "app搴旂敤", description = "Menu")
+@RestController
+@RequestMapping("/Menu")
+@RequiredArgsConstructor
+public class AppMenuController {
+
+    private final AuthorizeApi authorizeService;
+
+
+    /**
+     * 鑾峰彇鑿滃崟鍒楄〃
+     *
+     * @param page 鍒嗛〉妯″瀷
+     * @return
+     */
+    @Operation(summary = "鑾峰彇鑿滃崟鍒楄〃")
+    @GetMapping
+    public ActionResult<ListVO<AppMenuListVO>> list(Page page) {
+        AuthorizeVO authorizeModel = authorizeService.getAuthorize(false, RequestContext.getAppCode(), 0);
+        List<ModuleModel> buttonListAll = authorizeModel.getModuleList().stream().filter(t ->
+                JnpfConst.APP.equals(t.getCategory())
+                        && !Objects.equals(t.getNoShow(), 1)
+                        && !JnpfConst.MODULE_CODE.contains(t.getEnCode())).collect(Collectors.toList());
+        // 閫氳繃绯荤粺id鎹炲彇鐩稿簲鐨勮彍鍗�
+        buttonListAll = buttonListAll.stream().filter(t -> UserProvider.getUser().getAppSystemId() != null && UserProvider.getUser().getAppSystemId().equals(t.getSystemId())).collect(Collectors.toList());
+        List<ModuleModel> buttonList = buttonListAll;
+        if (StringUtil.isNotEmpty(page.getKeyword())) {
+            buttonList = buttonListAll.stream().filter(t -> t.getFullName().contains(page.getKeyword())).collect(Collectors.toList());
+        }
+        List<UserMenuModel> list = JsonUtil.getJsonToList(ListToTreeUtil.treeWhere(buttonList, buttonListAll), UserMenuModel.class);
+        List<SumTree<UserMenuModel>> menuAll = TreeDotUtils.convertListToTreeDot(list, "-1");
+        List<AppMenuListVO> data = JsonUtil.getJsonToList(menuAll, AppMenuListVO.class);
+        ListVO<AppMenuListVO> listVO = new ListVO<>();
+        listVO.setList(data);
+        return ActionResult.success(listVO);
+    }
+
+    /**
+     * 鑾峰彇瀛愰泦鑿滃崟
+     *
+     * @return
+     */
+    @Operation(summary = "鑾峰彇瀛愰泦鑿滃崟")
+    @GetMapping("/getChildList/{id}")
+    public ActionResult<List<AppMenuListVO>> getChildList(@PathVariable("id") String id) {
+        AuthorizeVO authorizeModel = authorizeService.getAuthorize(false, RequestContext.getAppCode(), 0);
+        List<ModuleModel> buttonListAll = authorizeModel.getModuleList().stream().filter(t -> JnpfConst.APP.equals(t.getCategory())).collect(Collectors.toList());
+        // 閫氳繃绯荤粺id鎹炲彇鐩稿簲鐨勮彍鍗�
+        buttonListAll = buttonListAll.stream().filter(t -> UserProvider.getUser().getAppSystemId() != null && UserProvider.getUser().getAppSystemId().equals(t.getSystemId())).collect(Collectors.toList());
+        Set<ModuleModel> models = new HashSet<>();
+        next(buttonListAll, id, models);
+        List<UserMenuModel> list = JsonUtil.getJsonToList(models, UserMenuModel.class);
+        List<SumTree<UserMenuModel>> menuAll = TreeDotUtils.convertListToTreeDot(list);
+        List<AppMenuListVO> data = JsonUtil.getJsonToList(menuAll, AppMenuListVO.class);
+        return ActionResult.success(data);
+    }
+
+    private void next(List<ModuleModel> buttonListAll, String parentId, Set<ModuleModel> list) {
+        List<ModuleModel> menuList = buttonListAll.stream().filter(t -> t.getId().equals(parentId) || t.getParentId().equals(parentId)).collect(Collectors.toList());
+        for (ModuleModel model : menuList) {
+            if (!list.contains(model)) {
+                list.add(model);
+                next(buttonListAll, model.getId(), list);
+            }
+        }
+    }
+
+    @Operation(summary = "鑾峰彇搴旂敤鍒楄〃")
+    @GetMapping("/sys")
+    public ActionResult<List<UserSystemVO>> listSys() {
+        AuthorizeVO authorizeModel = authorizeService.getAuthorizeByUser(false);
+        List<SystemBaeModel> systemList = authorizeModel.getSystemList();
+        UserInfo userInfo = UserProvider.getUser();
+        List<UserSystemVO> jsonToList1 = new ArrayList<>();
+        systemList.forEach(t -> {
+            UserSystemVO systemVO = new UserSystemVO();
+            systemVO.setId(t.getId());
+            systemVO.setName(t.getFullName());
+            systemVO.setIcon(t.getIcon());
+            if (userInfo.getAppSystemId().equals(t.getId())) {
+                systemVO.setCurrentSystem(true);
+            }
+            systemVO.setEnCode(t.getEnCode());
+            jsonToList1.add(systemVO);
+        });
+        return ActionResult.success(jsonToList1);
+    }
+
+}

--
Gitblit v1.8.0