Prechádzať zdrojové kódy

web 模块更改为 restful 服务

reghao 3 mesiacov pred
rodič
commit
c8a5df6a80
17 zmenil súbory, kde vykonal 189 pridanie a 530 odobranie
  1. 19 40
      web/src/main/java/cn/reghao/bnt/web/admin/controller/AccountPageController.java
  2. 8 22
      web/src/main/java/cn/reghao/bnt/web/admin/controller/MenuController.java
  3. 0 82
      web/src/main/java/cn/reghao/bnt/web/admin/controller/MenuPageController.java
  4. 5 9
      web/src/main/java/cn/reghao/bnt/web/admin/controller/RoleController.java
  5. 0 83
      web/src/main/java/cn/reghao/bnt/web/admin/controller/RolePageController.java
  6. 10 30
      web/src/main/java/cn/reghao/bnt/web/admin/controller/SysController.java
  7. 13 18
      web/src/main/java/cn/reghao/bnt/web/admin/controller/SysNotifyController.java
  8. 41 44
      web/src/main/java/cn/reghao/bnt/web/admin/controller/UserController.java
  9. 0 158
      web/src/main/java/cn/reghao/bnt/web/admin/controller/UserPageController.java
  10. 1 3
      web/src/main/java/cn/reghao/bnt/web/admin/model/dto/AccountRole.java
  11. 34 0
      web/src/main/java/cn/reghao/bnt/web/admin/model/vo/ResourceTree.java
  12. 11 1
      web/src/main/java/cn/reghao/bnt/web/admin/security/MyAuthenticationEntryPoint.java
  13. 10 2
      web/src/main/java/cn/reghao/bnt/web/admin/security/handler/LogoutSuccessHandlerImpl.java
  14. 2 0
      web/src/main/java/cn/reghao/bnt/web/admin/service/MenuService.java
  15. 8 1
      web/src/main/java/cn/reghao/bnt/web/admin/service/impl/AccountServiceImpl.java
  16. 26 0
      web/src/main/java/cn/reghao/bnt/web/admin/service/impl/MenuServiceImpl.java
  17. 1 37
      web/src/main/java/cn/reghao/bnt/web/config/AccessInterceptor.java

+ 19 - 40
web/src/main/java/cn/reghao/bnt/web/admin/controller/AccountPageController.java

@@ -2,10 +2,10 @@ package cn.reghao.bnt.web.admin.controller;
 
 import cn.reghao.bnt.web.admin.model.dto.UpdatePasswordDto;
 import cn.reghao.bnt.web.admin.model.dto.UpdateUsernameDto;
-import cn.reghao.bnt.web.admin.model.po.User;
 import cn.reghao.bnt.web.admin.model.po.UserMessage;
 import cn.reghao.bnt.web.admin.model.vo.LoginRecordInfo;
 import cn.reghao.bnt.web.admin.service.*;
+import cn.reghao.jutil.jdk.web.db.PageList;
 import cn.reghao.jutil.jdk.web.result.Result;
 import cn.reghao.jutil.jdk.web.result.ResultStatus;
 import cn.reghao.jutil.web.WebResult;
@@ -13,12 +13,10 @@ import io.swagger.v3.oas.annotations.tags.Tag;
 import io.swagger.v3.oas.annotations.Operation;
 import org.springframework.data.domain.Page;
 import org.springframework.http.MediaType;
-import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Collections;
 import java.util.List;
 
 /**
@@ -26,13 +24,14 @@ import java.util.List;
  * @date 2024-08-30 17:52:34
  */
 @Tag(name = "用户帐号页面")
-@Controller
-@RequestMapping("/bg/user")
+@RestController
+@RequestMapping("/api/devops/account")
 public class AccountPageController {
     private final AccountService accountService;
     private final AccountSessionService accountSessionService;
     private final UserMessageService userMessageService;
     private final LoginAttemptService loginAttemptService;
+    private final int pageSize = 10;
 
     public AccountPageController(AccountService accountService, AccountSessionService accountSessionService,
                                  UserMessageService userMessageService, LoginAttemptService loginAttemptService) {
@@ -42,23 +41,8 @@ public class AccountPageController {
         this.loginAttemptService = loginAttemptService;
     }
 
-    @Operation(summary = "用户信息页面", description = "N")
-    @GetMapping("/profile")
-    public String userInfoPage(Model model) {
-        User user = UserContext.getUser();
-        model.addAttribute("user", user);
-        return "/admin/user/profile";
-    }
-
-    @Operation(summary = "修改帐号页面", description = "N")
-    @GetMapping(value = "/profile/update/username")
-    public String updateUsernamePage(Model model) {
-        return "/admin/user/update_username";
-    }
-
     @Operation(summary = "修改帐号", description = "N")
     @PostMapping(value = "/profile/update/username", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
     public String updateUsername(@Validated UpdateUsernameDto updateUsernameDto) {
         Result result = accountService.updateMyUsername(updateUsernameDto);
         if (result.getCode() == ResultStatus.SUCCESS.getCode()) {
@@ -68,16 +52,8 @@ public class AccountPageController {
         return WebResult.result(result);
     }
 
-    @Operation(summary = "修改密码页面", description = "N")
-    @GetMapping("/profile/update/passwd")
-    public String updatePasswdPage(Model model) {
-        model.addAttribute("userRoles", Collections.emptySet());
-        return "/admin/user/update_passwd";
-    }
-
     @Operation(summary = "修改密码", description = "N")
     @PostMapping(value = "/profile/update/passwd", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
     public String updatePasswd(@Validated UpdatePasswordDto updatePasswordDto) {
         Result result = accountService.updateMyPassword(updatePasswordDto);
         if (result.getCode() == ResultStatus.SUCCESS.getCode()) {
@@ -91,13 +67,11 @@ public class AccountPageController {
     @GetMapping("/record")
     public String loginRecordPage(Model model) {
         List<LoginRecordInfo> list = loginAttemptService.getActiveLogin();
-        model.addAttribute("list", list);
-        return "/admin/user/login_record";
+        return WebResult.success(list);
     }
 
     @Operation(summary = "登出会话", description = "N")
     @PostMapping(value = "/logout", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
     public String logout(String loginId) {
         accountSessionService.deactivateUserLogin(loginId);
         return WebResult.success();
@@ -105,28 +79,33 @@ public class AccountPageController {
 
     @Operation(summary = "用户消息列表页面", description = "N")
     @GetMapping("/message")
-    public String messagePage(Model model) {
-        Page<UserMessage> page = userMessageService.getMessages(1, 10);
-        model.addAttribute("page", page);
-        return "/admin/user/msglist";
+    public String messagePage(@RequestParam("pn") int pageNumber) {
+        Page<UserMessage> page = userMessageService.getMessages(pageNumber, pageSize);
+        PageList<UserMessage> pageList = getPageList(page);
+        return WebResult.success(pageList);
+    }
+
+    private PageList<UserMessage> getPageList(Page<UserMessage> page) {
+        int pageNumber = page.getNumber() + 1;
+        int pageSize = page.getSize();
+        long total = page.getTotalElements();
+        List<UserMessage> list = page.getContent();
+        return PageList.pageList(pageNumber, pageSize, (int) total, list);
     }
 
     @Operation(summary = "用户消息内容页面", description = "N")
     @GetMapping("/message/detail")
-    public String messageDetail(@RequestParam("id") int id, Model model) {
+    public String messageDetail(@RequestParam("id") int id) {
         UserMessage userMessage = userMessageService.getMessage(id);
         String content = "";
         if (userMessage != null) {
             content = userMessage.getContent();
         }
-
-        model.addAttribute("content", content);
-        return "/admin/user/msgdetail";
+        return WebResult.success(content);
     }
 
     @Operation(summary = "删除用户所有消息", description = "N")
     @PostMapping(value = "/message/clear", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
     public String clearUserMessage() {
         userMessageService.clearUserMessage();
         return WebResult.success();

+ 8 - 22
web/src/main/java/cn/reghao/bnt/web/admin/controller/MenuController.java

@@ -5,20 +5,19 @@ import cn.reghao.bnt.web.admin.model.dto.MenuDto;
 import cn.reghao.bnt.web.admin.model.po.Menu;
 import cn.reghao.bnt.web.admin.model.po.Role;
 import cn.reghao.bnt.web.admin.model.vo.MenuTree;
+import cn.reghao.bnt.web.admin.model.vo.ResourceTree;
 import cn.reghao.bnt.web.admin.service.MenuService;
 import cn.reghao.bnt.web.admin.service.RoleService;
 import cn.reghao.bnt.web.admin.service.UserContext;
 import cn.reghao.jutil.jdk.web.result.Result;
 import cn.reghao.jutil.web.WebResult;
-import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Operation;
 import org.springframework.http.MediaType;
-import org.springframework.ui.Model;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
 
 /**
  * @author reghao
@@ -38,29 +37,16 @@ public class MenuController {
         this.roleService = roleService;
     }
 
-    @Operation(summary = "资源列表页面", description = "N")
-    @GetMapping(value = "")
-    public String menuPage(Model model) {
-        return "/admin/rbac/menu/menulist";
-    }
-
-    @Operation(summary = "资源更新页面", description = "N")
-    @GetMapping("/edit")
-    public String toEdit(@RequestParam("id") Menu menu, Model model) {
-        model.addAttribute("menu", menu);
-        return "/admin/rbac/menu/menuedit";
-    }
-
     @Operation(summary = "可访问资源的角色列表页面", description = "N")
     @GetMapping("/roles")
-    public String roleListWithResource(@RequestParam("id") Integer id, Model model) {
+    public String roleListWithResource(@RequestParam("id") Integer id) {
         Menu menu = menuRepository.getById(id);
         List<Role> list = new ArrayList<>(menu.getRoles());
 
         String resource = String.format("%s %s", menu.getType(), menu.getUrl());
-        model.addAttribute("url", resource);
-        model.addAttribute("list", list);
-        return WebResult.success(list);
+        /*model.addAttribute("url", resource);
+        model.addAttribute("list", list);*/
+        return WebResult.success();
     }
 
     @Operation(summary = "修改资源", description = "N")
@@ -74,7 +60,7 @@ public class MenuController {
     @GetMapping(value = "/ztree", produces = MediaType.APPLICATION_JSON_VALUE)
     public String list() {
         Role role = roleService.getRolesByUser(UserContext.getUserId()).get(0);
-        List<MenuTree> list = menuService.getMenuTreeByRole(role);
+        List<ResourceTree> list = menuService.getMenuTreeByRole1(role);
         return WebResult.success(list);
     }
 }

+ 0 - 82
web/src/main/java/cn/reghao/bnt/web/admin/controller/MenuPageController.java

@@ -1,82 +0,0 @@
-package cn.reghao.bnt.web.admin.controller;
-
-import cn.reghao.bnt.web.admin.db.repository.MenuRepository;
-import cn.reghao.bnt.web.admin.model.dto.MenuDto;
-import cn.reghao.bnt.web.admin.model.po.Menu;
-import cn.reghao.bnt.web.admin.model.po.Role;
-import cn.reghao.bnt.web.admin.model.vo.MenuTree;
-import cn.reghao.bnt.web.admin.service.MenuService;
-import cn.reghao.bnt.web.admin.service.RoleService;
-import cn.reghao.bnt.web.admin.service.UserContext;
-import cn.reghao.jutil.jdk.web.result.Result;
-import cn.reghao.jutil.web.WebResult;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import io.swagger.v3.oas.annotations.Operation;
-import org.springframework.http.MediaType;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.*;
-
-/**
- * @author reghao
- * @date 2021-04-04 21:24:18
- */
-@Tag(name = "资源页面")
-@RequestMapping("/bg/rbac/menu")
-@Controller
-public class MenuPageController {
-    private final MenuService menuService;
-    private final MenuRepository menuRepository;
-    private final RoleService roleService;
-
-    public MenuPageController(MenuService menuService, MenuRepository menuRepository, RoleService roleService) {
-        this.menuService = menuService;
-        this.menuRepository = menuRepository;
-        this.roleService = roleService;
-    }
-
-    @Operation(summary = "资源列表页面", description = "N")
-    @GetMapping(value = "")
-    public String menuPage(Model model) {
-        return "/admin/rbac/menu/menulist";
-    }
-
-    @Operation(summary = "资源更新页面", description = "N")
-    @GetMapping("/edit")
-    public String toEdit(@RequestParam("id") Menu menu, Model model) {
-        model.addAttribute("menu", menu);
-        return "/admin/rbac/menu/menuedit";
-    }
-
-    @Operation(summary = "可访问资源的角色列表页面", description = "N")
-    @GetMapping("/roles")
-    public String roleListWithResource(@RequestParam("id") Integer id, Model model) {
-        Menu menu = menuRepository.getById(id);
-        List<Role> list = new ArrayList<>(menu.getRoles());
-
-        String resource = String.format("%s %s", menu.getType(), menu.getUrl());
-        model.addAttribute("url", resource);
-        model.addAttribute("list", list);
-        return "/admin/rbac/menu/roles";
-    }
-
-    @Operation(summary = "修改资源", description = "N")
-    @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
-    public String updateMenu(@Validated MenuDto menuDto) {
-        Result result = menuService.updateMenu(menuDto);
-        return WebResult.result(result);
-    }
-
-    @Operation(summary = "获取 ztree 形式的资源", description = "N")
-    @GetMapping(value = "/ztree", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
-    public String list() {
-        Role role = roleService.getRolesByUser(UserContext.getUserId()).get(0);
-        List<MenuTree> list = menuService.getMenuTreeByRole(role);
-        return WebResult.success(list);
-    }
-}

+ 5 - 9
web/src/main/java/cn/reghao/bnt/web/admin/controller/RoleController.java

@@ -9,8 +9,8 @@ import cn.reghao.bnt.web.admin.service.AccountService;
 import cn.reghao.bnt.web.admin.service.MenuService;
 import cn.reghao.bnt.web.admin.service.RoleService;
 import cn.reghao.jutil.web.WebResult;
-import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Operation;
 import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.*;
 
@@ -37,27 +37,22 @@ public class RoleController {
     }
 
     @Operation(summary = "角色列表页面", description = "N")
-    @GetMapping
+    @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
     public String rolePage() {
         List<RoleVO> list = roleService.getAllRoles();
         return WebResult.success(list);
     }
 
     @Operation(summary = "拥有角色的所有用户页面", description = "N")
-    @GetMapping("/users")
+    @GetMapping(value = "/users", produces = MediaType.APPLICATION_JSON_VALUE)
     public String userListWithRole(@RequestParam("roleId") Integer roleId) {
         List<User> list = accountService.getUsersByRole(roleId, 1);
         return WebResult.success(list);
     }
 
-    @Operation(summary = "设置角色可访问的资源页面", description = "N")
-    @GetMapping("/grant")
-    public String menusPage(@RequestParam(value = "id") Integer id){
-        return WebResult.success();
-    }
-
     @Operation(summary = "获取角色可访问的资源", description = "N")
     @GetMapping(value = "/menus", produces = MediaType.APPLICATION_JSON_VALUE)
+    @ResponseBody
     public String getRoleMenus(@RequestParam("id") Role role) {
         List<MenuTree> allMenus = menuService.getMenuTreeByRole(role);
         return WebResult.success(allMenus);
@@ -65,6 +60,7 @@ public class RoleController {
 
     @Operation(summary = "设置角色可访问的资源", description = "N")
     @PostMapping(value = "/menus", produces = MediaType.APPLICATION_JSON_VALUE)
+    @ResponseBody
     public String setRoleMenus(@RequestParam(value = "id") Integer roleId,
                                @RequestParam(value = "menuId", required = false) Set<Menu> menus) {
         if (menus == null) {

+ 0 - 83
web/src/main/java/cn/reghao/bnt/web/admin/controller/RolePageController.java

@@ -1,83 +0,0 @@
-package cn.reghao.bnt.web.admin.controller;
-
-import cn.reghao.bnt.web.admin.model.po.Menu;
-import cn.reghao.bnt.web.admin.model.po.Role;
-import cn.reghao.bnt.web.admin.model.po.User;
-import cn.reghao.bnt.web.admin.model.vo.MenuTree;
-import cn.reghao.bnt.web.admin.model.vo.RoleVO;
-import cn.reghao.bnt.web.admin.service.AccountService;
-import cn.reghao.bnt.web.admin.service.MenuService;
-import cn.reghao.bnt.web.admin.service.RoleService;
-import cn.reghao.jutil.web.WebResult;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import io.swagger.v3.oas.annotations.Operation;
-import org.springframework.http.MediaType;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author reghao
- * @date 2021-04-04 21:24:18
- */
-@Tag(name = "角色页面")
-@RequestMapping("/bg/rbac/role")
-@Controller
-public class RolePageController {
-    private final RoleService roleService;
-    private final MenuService menuService;
-    private final AccountService accountService;
-
-    public RolePageController(RoleService roleService, MenuService menuService, AccountService accountService) {
-        this.roleService = roleService;
-        this.menuService = menuService;
-        this.accountService = accountService;
-    }
-
-    @Operation(summary = "角色列表页面", description = "N")
-    @GetMapping
-    public String rolePage(Model model) {
-        List<RoleVO> list = roleService.getAllRoles();
-        model.addAttribute("list", list);
-        return "/admin/rbac/role/rolelist";
-    }
-
-    @Operation(summary = "拥有角色的所有用户页面", description = "N")
-    @GetMapping("/users")
-    public String userListWithRole(@RequestParam("roleId") Integer roleId, Model model) {
-        List<User> list = accountService.getUsersByRole(roleId, 1);
-        model.addAttribute("list", list);
-        return "/admin/rbac/role/users";
-    }
-
-    @Operation(summary = "设置角色可访问的资源页面", description = "N")
-    @GetMapping("/grant")
-    public String menusPage(@RequestParam(value = "id") Integer id, Model model){
-        model.addAttribute("roleId", id);
-        return "/admin/rbac/role/menus";
-    }
-
-    @Operation(summary = "获取角色可访问的资源", description = "N")
-    @GetMapping(value = "/menus", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
-    public String getRoleMenus(@RequestParam("id") Role role) {
-        List<MenuTree> allMenus = menuService.getMenuTreeByRole(role);
-        return WebResult.success(allMenus);
-    }
-
-    @Operation(summary = "设置角色可访问的资源", description = "N")
-    @PostMapping(value = "/menus", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
-    public String setRoleMenus(@RequestParam(value = "id") Integer roleId,
-                               @RequestParam(value = "menuId", required = false) Set<Menu> menus) {
-        if (menus == null) {
-            menus = Collections.emptySet();
-        }
-        roleService.updateRoleMenus(roleId, menus);
-        return WebResult.success();
-    }
-}

+ 10 - 30
web/src/main/java/cn/reghao/bnt/web/admin/controller/SysPageController.java → web/src/main/java/cn/reghao/bnt/web/admin/controller/SysController.java

@@ -12,8 +12,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.data.domain.Page;
 import org.springframework.http.MediaType;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -22,37 +20,27 @@ import org.springframework.web.bind.annotation.*;
  * @date 2021-04-04 21:24:18
  */
 @Tag(name = "系统相关页面和接口")
-@Controller
-@RequestMapping("/bg/sys")
+@RestController
+@RequestMapping("/api/devops/sys")
 @Slf4j
-public class SysPageController {
+public class SysController {
     private final SiteOptionService siteOptionService;
     private final LogService logService;
 
-    public SysPageController(SiteOptionService siteOptionService, LogService logService) {
+    public SysController(SiteOptionService siteOptionService, LogService logService) {
         this.siteOptionService = siteOptionService;
         this.logService = logService;
     }
 
     @Operation(summary = "站点配置页面", description = "N")
     @GetMapping("/site")
-    public String siteOptionPage(Model model) {
+    public String siteOptionPage() {
         Page<SiteOption> page = siteOptionService.getAll();
-        model.addAttribute("page", page);
-        model.addAttribute("list", page.getContent());
-        return "/admin/sys/siteoption";
-    }
-
-    @Operation(summary = "站点配置编辑页面", description = "N")
-    @GetMapping("/site/update")
-    public String updateSiteOptionPage(@RequestParam("id") SiteOption siteOption, Model model) {
-        model.addAttribute("siteOption", siteOption);
-        return "/admin/sys/siteoption_edit";
+        return WebResult.success(page.getContent());
     }
 
     @Operation(summary = "站点配置更新接口", description = "N")
     @PostMapping(value = "/site/update", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
     public String updateSiteOption(@Validated SiteOption siteOption) {
         siteOptionService.updateSiteOption(siteOption);
         return WebResult.success();
@@ -60,18 +48,14 @@ public class SysPageController {
 
     @Operation(summary = "系统访问日志页面", description = "N")
     @GetMapping("/log/access")
-    public String accessLogPage(Model model) {
+    public String accessLogPage() {
         int pageNumber = Integer.parseInt(ServletUtil.getRequestParam("pageNo", "1"));
         Page<AccessLogInfo> page = logService.getAccessLogs(pageNumber);
-
-        model.addAttribute("total", page.getTotalElements());
-        model.addAttribute("page", page);
         return "/admin/sys/access_log";
     }
 
     @Operation(summary = "清空系统访问日志", description = "N")
     @PostMapping(value = "/log/access/erase", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
     public String eraseAccessLog() {
         logService.eraseAccessLog();
         return WebResult.success();
@@ -79,18 +63,14 @@ public class SysPageController {
 
     @Operation(summary = "系统运行日志页面", description = "N")
     @GetMapping("/log/runtime")
-    public String runtimeLogPage(Model model) {
+    public String runtimeLogPage() {
         int pageNumber = Integer.parseInt(ServletUtil.getRequestParam("pageNo", "1"));
         Page<RuntimeLogInfo> page = logService.getRuntimeLogs(pageNumber);
-
-        model.addAttribute("total", page.getTotalElements());
-        model.addAttribute("page", page);
         return "/admin/sys/runtime_log";
     }
 
     @Operation(summary = "清空系统运行日志", description = "N")
     @PostMapping(value = "/log/runtime/erase", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
     public String eraseRuntimeLog() {
         logService.eraseRuntimeLog();
         return WebResult.success();
@@ -98,13 +78,13 @@ public class SysPageController {
 
     @Operation(summary = "系统实时日志页面", description = "N")
     @GetMapping("/log/realtime")
-    public String realtimeLogPage(Model model) {
+    public String realtimeLogPage() {
         return "/admin/sys/realtime_log";
     }
 
     @Operation(summary = "状态监控页面", description = "N")
     @GetMapping("/log/monitor")
-    public String monitorPage(Model model) {
+    public String monitorPage() {
         return "/admin/sys/monitor";
     }
 }

+ 13 - 18
web/src/main/java/cn/reghao/bnt/web/admin/controller/SysNotifyPageController.java → web/src/main/java/cn/reghao/bnt/web/admin/controller/SysNotifyController.java

@@ -12,8 +12,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.http.MediaType;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -22,31 +20,30 @@ import org.springframework.web.bind.annotation.*;
  * @date 2021-04-04 21:24:18
  */
 @Tag(name = "系统通知配置页面和接口")
-@Controller
-@RequestMapping("/bg/sys/notify")
+@RestController
+@RequestMapping("/api/devops/sys/notify/webhook")
 @Slf4j
-public class SysNotifyPageController {
+public class SysNotifyController {
     private final WebhookRepository webhookRepository;
     private final NotifyService notifyService;
 
-    public SysNotifyPageController(WebhookRepository webhookRepository, NotifyService notifyService) {
+    public SysNotifyController(WebhookRepository webhookRepository, NotifyService notifyService) {
         this.webhookRepository = webhookRepository;
         this.notifyService = notifyService;
     }
 
     @Operation(summary = "webhook 通知列表页面", description = "N")
-    @GetMapping("/webhook")
-    public String receiverIndex(Model model) throws Exception {
-        PageRequest pageRequest = PageRequest.of(0, 100);
+    @GetMapping("")
+    public String receiverIndex() {
+        int pageNumber = 1;
+        int pageSize = 10;
+        PageRequest pageRequest = PageRequest.of(pageNumber-1, pageSize);
         Page<Webhook> page = webhookRepository.findAll(pageRequest);
-        model.addAttribute("page", page);
-        model.addAttribute("list", page.getContent());
-        return "/admin/sys/webhook_list";
+        return WebResult.success(page.getContent());
     }
 
     @Operation(summary = "添加 webhook 通知接口", description = "N")
-    @PostMapping(value = "/webhook", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
+    @PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
     public String addWebhook(@Validated Webhook webhook) {
         String name = webhook.getName();
         Webhook webhookEntity = webhookRepository.findByName(name);
@@ -59,8 +56,7 @@ public class SysNotifyPageController {
     }
 
     @Operation(summary = "删除 webhook 通知接口", description = "N")
-    @PostMapping(value = "/webhook/delete", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
+    @PostMapping(value = "/delete", produces = MediaType.APPLICATION_JSON_VALUE)
     public String deleteReceiver(Integer id) {
         Webhook webhook = webhookRepository.getById(id);
         if (webhook != null) {
@@ -72,8 +68,7 @@ public class SysNotifyPageController {
     }
 
     @Operation(summary = "测试 webhook 是否可用", description = "N")
-    @PostMapping(value = "/webhook/test", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
+    @PostMapping(value = "/test", produces = MediaType.APPLICATION_JSON_VALUE)
     public String testWebhook(Integer id) {
         Webhook webhook = webhookRepository.getById(id);
         DingMsg dingMsg = new DingTestMsg().dingMsg();

+ 41 - 44
web/src/main/java/cn/reghao/bnt/web/admin/controller/UserController.java

@@ -4,27 +4,26 @@ import cn.reghao.bnt.web.admin.model.dto.AccountPassword;
 import cn.reghao.bnt.web.admin.model.dto.AccountRole;
 import cn.reghao.bnt.web.admin.model.dto.CreateAccountDto;
 import cn.reghao.bnt.web.admin.model.po.Role;
-import cn.reghao.bnt.web.admin.model.po.User;
 import cn.reghao.bnt.web.admin.model.vo.RoleVO;
 import cn.reghao.bnt.web.admin.model.vo.UserSession;
 import cn.reghao.bnt.web.admin.model.vo.UserVO;
 import cn.reghao.bnt.web.admin.service.AccountService;
 import cn.reghao.bnt.web.admin.service.AccountSessionService;
+import cn.reghao.bnt.web.admin.model.po.User;
 import cn.reghao.bnt.web.admin.service.RoleService;
+import cn.reghao.jutil.jdk.web.db.PageList;
 import cn.reghao.jutil.jdk.web.result.Result;
 import cn.reghao.jutil.jdk.web.result.ResultStatus;
 import cn.reghao.jutil.web.WebResult;
-import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Operation;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.http.MediaType;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -38,7 +37,7 @@ public class UserController {
     private final AccountService accountService;
     private final RoleService roleService;
     private final AccountSessionService accountSessionService;
-    private int pageSize = 100;
+    private int pageSize = 10;
 
     public UserController(AccountService accountService, RoleService roleService,
                           AccountSessionService accountSessionService) {
@@ -48,8 +47,8 @@ public class UserController {
     }
 
     @Operation(summary = "帐号列表页面", description = "N")
-    @GetMapping(value = "")
-    public String userPage(Model model) {
+    @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String userPage() {
         PageRequest pageRequest = PageRequest.of(0, pageSize);
         Page<UserVO> page = accountService.getUserVOByPage(pageRequest);
         page.getContent().forEach(userVO -> {
@@ -62,29 +61,28 @@ public class UserController {
             }
         });
 
-        return WebResult.success(page.getContent());
+        PageList<UserVO> pageList = getPageList(page);
+        return WebResult.success(pageList);
     }
 
-    @Operation(summary = "新增帐号页面", description = "N")
-    @GetMapping("/add")
-    public String addUserPage(Model model) {
-        List<RoleVO> allRoles = roleService.getAllRoles();
-        model.addAttribute("list", allRoles);
-        return "/admin/rbac/user/useradd";
+    private PageList<UserVO> getPageList(Page<UserVO> page) {
+        int pageNumber = page.getNumber() + 1;
+        int pageSize = page.getSize();
+        long total = page.getTotalElements();
+        List<UserVO> list = page.getContent();
+        return PageList.pageList(pageNumber, pageSize, (int) total, list);
     }
 
-    @Operation(summary = "重置帐号密码页面", description = "N")
-    @GetMapping("/reset_passwd")
-    public String updatePasswordPage(@RequestParam("id") Integer userId, Model model) {
-        User user = accountService.getById(userId);
-        model.addAttribute("username", user.getUsername());
-        model.addAttribute("userId", userId);
-        return "/admin/rbac/user/resetpasswd";
+    @Operation(summary = "新增帐号页面", description = "N")
+    @GetMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String addUserPage() {
+        List<String> allRoles = roleService.getAllRoles().stream().map(RoleVO::getName).collect(Collectors.toList());
+        return WebResult.success(allRoles);
     }
 
     @Operation(summary = "用户会话列表页面", description = "N")
     @GetMapping("/session")
-    public String userSessionPage(@RequestParam("id") Integer userId, Model model) {
+    public String userSessionPage(@RequestParam("id") Integer userId) {
         User user = accountService.getById(userId);
         List<UserSession> userSessionList = accountSessionService.getUserSession(userId);
         return WebResult.success(userSessionList);
@@ -92,18 +90,28 @@ public class UserController {
 
     @Operation(summary = "帐号角色分配页面", description = "N")
     @GetMapping("/role")
-    public String updateRolePage(@RequestParam("id") Integer userId, Model model) {
-        User user = accountService.getById(userId);
-        List<RoleVO> allRoles = roleService.getAllRoles();
-        List<Integer> userRoleIds = roleService.getRolesByUser(userId).stream()
-                .map(Role::getId)
+    public String updateRolePage(@RequestParam("userId") Integer userId) {
+        List<String> allRoles = roleService.getAllRoles().stream()
+                .map(RoleVO::getName)
                 .collect(Collectors.toList());
+        List<String> userRoles = roleService.getRolesByUser(userId).stream()
+                .map(role -> role.getName().replace("ROLE_", "").toLowerCase(Locale.ROOT))
+                .collect(Collectors.toList());
+        Map<String, Object> map = new HashMap<>();
+        map.put("allRoles", allRoles);
+        map.put("userRoles", userRoles);
+        return WebResult.success(map);
+    }
 
-        model.addAttribute("username", user.getUsername());
-        model.addAttribute("userId", userId);
-        model.addAttribute("allRoles", allRoles);
-        model.addAttribute("userRoleIds", userRoleIds);
-        return "/admin/rbac/user/update_role";
+    @Operation(summary = "分配帐号角色", description = "N")
+    @PostMapping(value = "/role", produces = MediaType.APPLICATION_JSON_VALUE)
+    public String updateRole(@Validated AccountRole accountRole) {
+        Result result = accountService.updateAccountRole(accountRole);
+        if (result.getCode() == ResultStatus.SUCCESS.getCode()) {
+            // 登出当前会话
+            accountSessionService.deactivateUserSession(accountRole.getUserId());
+        }
+        return WebResult.result(result);
     }
 
     @Operation(summary = "创建帐号", description = "N")
@@ -134,15 +142,4 @@ public class UserController {
         accountSessionService.deactivateUserSession(userId);
         return WebResult.success();
     }
-
-    @Operation(summary = "分配帐号角色", description = "N")
-    @PostMapping(value = "/role", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String updateRole(@Validated AccountRole accountRole) {
-        Result result = accountService.updateAccountRole(accountRole);
-        if (result.getCode() == ResultStatus.SUCCESS.getCode()) {
-            // 登出当前会话
-            accountSessionService.deactivateUserSession(accountRole.getUserId());
-        }
-        return WebResult.result(result);
-    }
 }

+ 0 - 158
web/src/main/java/cn/reghao/bnt/web/admin/controller/UserPageController.java

@@ -1,158 +0,0 @@
-package cn.reghao.bnt.web.admin.controller;
-
-import cn.reghao.bnt.web.admin.model.dto.AccountPassword;
-import cn.reghao.bnt.web.admin.model.dto.AccountRole;
-import cn.reghao.bnt.web.admin.model.dto.CreateAccountDto;
-import cn.reghao.bnt.web.admin.model.po.Role;
-import cn.reghao.bnt.web.admin.model.vo.RoleVO;
-import cn.reghao.bnt.web.admin.model.vo.UserSession;
-import cn.reghao.bnt.web.admin.model.vo.UserVO;
-import cn.reghao.bnt.web.admin.service.AccountService;
-import cn.reghao.bnt.web.admin.service.AccountSessionService;
-import cn.reghao.bnt.web.admin.model.po.User;
-import cn.reghao.bnt.web.admin.service.RoleService;
-import cn.reghao.bnt.web.admin.service.UserContext;
-import cn.reghao.jutil.jdk.web.result.Result;
-import cn.reghao.jutil.jdk.web.result.ResultStatus;
-import cn.reghao.jutil.web.WebResult;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import io.swagger.v3.oas.annotations.Operation;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.http.MediaType;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * @author reghao
- * @date 2021-04-04 21:24:18
- */
-@Tag(name = "帐号管理页面")
-@RequestMapping("/bg/rbac/user")
-@Controller
-public class UserPageController {
-    private final AccountService accountService;
-    private final RoleService roleService;
-    private final AccountSessionService accountSessionService;
-    private int pageSize = 100;
-
-    public UserPageController(AccountService accountService, RoleService roleService,
-                              AccountSessionService accountSessionService) {
-        this.accountService = accountService;
-        this.roleService = roleService;
-        this.accountSessionService = accountSessionService;
-    }
-
-    @Operation(summary = "帐号列表页面", description = "N")
-    @GetMapping(value = "")
-    public String userPage(Model model) {
-        PageRequest pageRequest = PageRequest.of(0, pageSize);
-        Page<UserVO> page = accountService.getUserVOByPage(pageRequest);
-        page.getContent().forEach(userVO -> {
-            int userId = userVO.getUserId();
-            List<UserSession> userSessionList = accountSessionService.getUserSession(userId);
-            if (!userSessionList.isEmpty()) {
-                UserSession userSession = userSessionList.get(0);
-                userVO.setLastAccess(userSession.getLastRequestAt());
-                userVO.setSessionCount(userSessionList.size());
-            }
-        });
-
-        model.addAttribute("page", page);
-        model.addAttribute("list", page.getContent());
-        return "/admin/rbac/user/userlist";
-    }
-
-    @Operation(summary = "新增帐号页面", description = "N")
-    @GetMapping("/add")
-    public String addUserPage(Model model) {
-        List<RoleVO> allRoles = roleService.getAllRoles();
-        model.addAttribute("list", allRoles);
-        return "/admin/rbac/user/useradd";
-    }
-
-    @Operation(summary = "重置帐号密码页面", description = "N")
-    @GetMapping("/reset_passwd")
-    public String updatePasswordPage(@RequestParam("id") Integer userId, Model model) {
-        User user = accountService.getById(userId);
-        model.addAttribute("username", user.getUsername());
-        model.addAttribute("userId", userId);
-        return "/admin/rbac/user/resetpasswd";
-    }
-
-    @Operation(summary = "用户会话列表页面", description = "N")
-    @GetMapping("/session")
-    public String userSessionPage(@RequestParam("id") Integer userId, Model model) {
-        User user = accountService.getById(userId);
-        List<UserSession> userSessionList = accountSessionService.getUserSession(userId);
-
-        model.addAttribute("username", user.getUsername());
-        model.addAttribute("list", userSessionList);
-        return "/admin/rbac/user/user_session";
-    }
-
-    @Operation(summary = "帐号角色分配页面", description = "N")
-    @GetMapping("/role")
-    public String updateRolePage(@RequestParam("id") Integer userId, Model model) {
-        User user = accountService.getById(userId);
-        List<RoleVO> allRoles = roleService.getAllRoles();
-        List<Integer> userRoleIds = roleService.getRolesByUser(userId).stream()
-                .map(Role::getId)
-                .collect(Collectors.toList());
-
-        model.addAttribute("username", user.getUsername());
-        model.addAttribute("userId", userId);
-        model.addAttribute("allRoles", allRoles);
-        model.addAttribute("userRoleIds", userRoleIds);
-        return "/admin/rbac/user/update_role";
-    }
-
-    @Operation(summary = "创建帐号", description = "N")
-    @PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
-    public String createUser(@Validated CreateAccountDto createAccountDto) {
-        Result result = accountService.createAccount(createAccountDto);
-        return WebResult.result(result);
-    }
-
-    @Operation(summary = "删除帐号", description = "N")
-    @PostMapping(value = "/delete", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
-    public String deleteAccount(Integer userId) {
-        Result result = accountService.deleteAccount(userId);
-        if (result.getCode() == ResultStatus.SUCCESS.getCode()) {
-            // 登出当前会话
-            accountSessionService.deactivateUserSession(userId);
-        }
-        return WebResult.result(result);
-    }
-
-    @Operation(summary = "修改帐号密码", description = "N")
-    @PostMapping(value = "/passwd", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
-    public String updatePassword(@Validated AccountPassword accountPassword) {
-        int userId = accountPassword.getUserId();
-        String password = accountPassword.getPassword();
-        accountService.updateAccountPassword(userId, password);
-        // 登出当前会话
-        accountSessionService.deactivateUserSession(userId);
-        return WebResult.success();
-    }
-
-    @Operation(summary = "分配帐号角色", description = "N")
-    @PostMapping(value = "/role", produces = MediaType.APPLICATION_JSON_VALUE)
-    @ResponseBody
-    public String updateRole(@Validated AccountRole accountRole) {
-        Result result = accountService.updateAccountRole(accountRole);
-        if (result.getCode() == ResultStatus.SUCCESS.getCode()) {
-            // 登出当前会话
-            accountSessionService.deactivateUserSession(accountRole.getUserId());
-        }
-        return WebResult.result(result);
-    }
-}

+ 1 - 3
web/src/main/java/cn/reghao/bnt/web/admin/model/dto/AccountRole.java

@@ -16,7 +16,5 @@ public class AccountRole {
     private Integer userId;
     @NotNull(message = "用户角色不能为 NULL")
     @Size(min = 1, max = 10, message = "用户角色数量为 1~10")
-    private Set<Integer> roles;
-/*    @NotNull(message = "role 不能为 NULL")
-    private Integer role;*/
+    private Set<String> roles;
 }

+ 34 - 0
web/src/main/java/cn/reghao/bnt/web/admin/model/vo/ResourceTree.java

@@ -0,0 +1,34 @@
+package cn.reghao.bnt.web.admin.model.vo;
+
+import cn.reghao.bnt.web.admin.model.po.Menu;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author reghao
+ * @date 2025-12-01 11:09:19
+ */
+@Setter
+@Getter
+public class ResourceTree {
+    private int pid;
+    private int id;
+    private String name;
+    private int pos;
+    private List<ResourceTree> children;
+    private String label;
+    private int value;
+
+    public ResourceTree(Menu menu) {
+        this.pid = menu.getPid();
+        this.id = menu.getId();
+        this.name = menu.getName();
+        this.pos = menu.getPos();
+        this.children = new ArrayList<>();
+        this.value = menu.getId();
+        this.label = menu.getName();
+    }
+}

+ 11 - 1
web/src/main/java/cn/reghao/bnt/web/admin/security/MyAuthenticationEntryPoint.java

@@ -1,5 +1,6 @@
 package cn.reghao.bnt.web.admin.security;
 
+import cn.reghao.jutil.web.WebResult;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.web.AuthenticationEntryPoint;
@@ -8,6 +9,7 @@ import jakarta.servlet.ServletException;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.io.PrintWriter;
 
 /**
  * 在 WebSecurityConfig 中配置的需要认证的接口没有获取到请求中的认证信息时会转到此处进行处理
@@ -22,7 +24,15 @@ public class MyAuthenticationEntryPoint implements AuthenticationEntryPoint {
             throws IOException, ServletException {
         String uri = request.getRequestURI();
         log.error("请求 {} 接口认证失败...", uri);
+
+        /*String body = String.format("%s, %s need authenticate", exception.getMessage(), uri);
+        response.sendRedirect("/bg/login");*/
+
         String body = String.format("%s, %s need authenticate", exception.getMessage(), uri);
-        response.sendRedirect("/bg/login");
+        String retJson = WebResult.failWithMsg(body);
+        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+        response.setContentType("application/json; charset=utf-8");
+        PrintWriter printWriter = response.getWriter();
+        printWriter.write(retJson);
     }
 }

+ 10 - 2
web/src/main/java/cn/reghao/bnt/web/admin/security/handler/LogoutSuccessHandlerImpl.java

@@ -1,5 +1,6 @@
 package cn.reghao.bnt.web.admin.security.handler;
 
+import cn.reghao.jutil.jdk.web.result.WebResult;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
 import org.springframework.stereotype.Component;
@@ -8,6 +9,7 @@ import jakarta.servlet.ServletException;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.io.PrintWriter;
 
 /**
  * 账号登出成功后的处理, 使用此类后不再调用 logoutSuccessUrl, 在此类中直接返回给客户端
@@ -21,7 +23,13 @@ public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler {
     @Override
     public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication auth)
             throws IOException, ServletException {
-        String redirectPath = "/bg/login";
-        response.sendRedirect(redirectPath);
+        /*String redirectPath = "/bg/login";
+        response.sendRedirect(redirectPath);*/
+
+        String redirectPath = "/login";
+        String retJson = WebResult.success(redirectPath);
+        response.setContentType("application/json; charset=utf-8");
+        PrintWriter printWriter = response.getWriter();
+        printWriter.write(retJson);
     }
 }

+ 2 - 0
web/src/main/java/cn/reghao/bnt/web/admin/service/MenuService.java

@@ -4,6 +4,7 @@ import cn.reghao.bnt.web.admin.model.dto.MenuDto;
 import cn.reghao.bnt.web.admin.model.po.Menu;
 import cn.reghao.bnt.web.admin.model.po.Role;
 import cn.reghao.bnt.web.admin.model.vo.MenuTree;
+import cn.reghao.bnt.web.admin.model.vo.ResourceTree;
 import cn.reghao.jutil.jdk.web.result.Result;
 
 import java.util.List;
@@ -16,6 +17,7 @@ public interface MenuService {
     Result updateMenu(MenuDto menuDto);
     Result deleteMenu(Integer menuId);
     List<MenuTree> getMenuTreeByRole(Role role);
+    List<ResourceTree> getMenuTreeByRole1(Role role);
     List<MenuTree> getDirMenus();
     /**
      * 获取 url 对应的 Role, 不需要认证的 url 则返回空集合

+ 8 - 1
web/src/main/java/cn/reghao/bnt/web/admin/service/impl/AccountServiceImpl.java

@@ -105,8 +105,15 @@ public class AccountServiceImpl implements AccountService {
         }
 
         Set<String> roleNames = accountRole.getRoles().stream()
-                .map(roleId0 -> roleRepository.getById(roleId0).getName())
+                .map(roleName -> {
+                    Role role = roleRepository.findByName("ROLE_" + roleName.toUpperCase(Locale.ROOT));
+                    return role != null ? role.getName() : null;
+                })
+                .filter(Objects::nonNull)
                 .collect(Collectors.toSet());
+        if (roleNames.isEmpty()) {
+            return Result.fail("角色不存在");
+        }
 
         if (roleNames.contains(RoleType.ROLE_ADMIN.name()) && countUsersByRole(adminRoleId) >= 2) {
             return Result.fail("系统最多允许 2 个用户拥有 admin role");

+ 26 - 0
web/src/main/java/cn/reghao/bnt/web/admin/service/impl/MenuServiceImpl.java

@@ -8,6 +8,7 @@ import cn.reghao.bnt.web.admin.model.po.Role;
 import cn.reghao.bnt.web.admin.db.repository.MenuRepository;
 import cn.reghao.bnt.web.admin.db.repository.RoleRepository;
 import cn.reghao.bnt.web.admin.model.vo.MenuTree;
+import cn.reghao.bnt.web.admin.model.vo.ResourceTree;
 import cn.reghao.bnt.web.admin.service.MenuService;
 import cn.reghao.bnt.web.admin.service.UserContext;
 import cn.reghao.jutil.jdk.web.result.Result;
@@ -117,6 +118,31 @@ public class MenuServiceImpl implements MenuService {
         return getSortedZTree(allMenus, role);
     }
 
+    public List<ResourceTree> getMenuTreeByRole1(Role role) {
+        List<Menu> allMenus = menuRepository.findAllByDeleted(false);
+        Map<Integer, List<ResourceTree>> groupMap = allMenus.stream()
+                .map(ResourceTree::new)
+                .collect(Collectors.groupingBy(ResourceTree::getPid));
+
+        int id = 0;
+        List<ResourceTree> list = groupMap.remove(id);
+        if (list != null) {
+            for (ResourceTree resourceTree : list) {
+                id = resourceTree.getId();
+                List<ResourceTree> list1 = groupMap.remove(id);
+                if (list1 != null) {
+                    resourceTree.getChildren().addAll(list1);
+                }
+            }
+        } else {
+            list = new ArrayList<>();
+        }
+
+        return list.stream()
+                .sorted(Comparator.comparingInt(ResourceTree::getPos))
+                .collect(Collectors.toList());
+    }
+
     @Override
     public List<MenuTree> getDirMenus() {
         List<Menu> allMenus = menuRepository.findByDeletedIsFalseAndType(MenuType.DIR.name());

+ 1 - 37
web/src/main/java/cn/reghao/bnt/web/config/AccessInterceptor.java

@@ -1,9 +1,7 @@
 package cn.reghao.bnt.web.config;
 
-import cn.reghao.bnt.web.admin.model.dto.AccountInfo;
 import cn.reghao.bnt.web.admin.service.*;
 import cn.reghao.jutil.jdk.http.HeaderNames;
-import cn.reghao.jutil.web.ServletUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.lang.Nullable;
 import org.springframework.stereotype.Component;
@@ -12,7 +10,6 @@ import org.springframework.web.servlet.ModelAndView;
 
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
-import java.util.Set;
 import java.util.UUID;
 
 /**
@@ -24,17 +21,10 @@ import java.util.UUID;
 @Slf4j
 @Component
 public class AccessInterceptor implements HandlerInterceptor {
-    private final AccountService accountService;
     private final LogService logService;
-    private final UserMessageService userMessageService;
-    private final SiteOptionService siteOptionService;
 
-    public AccessInterceptor(AccountService accountService, LogService logService,
-                             UserMessageService userMessageService, SiteOptionService siteOptionService) {
-        this.accountService = accountService;
+    public AccessInterceptor(LogService logService) {
         this.logService = logService;
-        this.userMessageService = userMessageService;
-        this.siteOptionService = siteOptionService;
     }
 
     @Override
@@ -44,38 +34,12 @@ public class AccessInterceptor implements HandlerInterceptor {
         request.setAttribute(HeaderNames.XRequestId, requestId);
         long startTime = System.currentTimeMillis();
         request.setAttribute(HeaderNames.XRequestTime, startTime);
-
-        String uri = request.getRequestURI();
-        String method = request.getMethod();
-        String host = request.getHeader("host");
-        // 后台访问
-        Set<String> backgroundDomainSet = siteOptionService.getBackgroundDomain();
-        if (uri.startsWith("/api") || (uri.startsWith("/bg") && backgroundDomainSet.contains(host))) {
-            return true;
-        } else {
-            log.info("url {} return 404...", uri);
-            response.setStatus(HttpServletResponse.SC_NOT_FOUND);
-        }
-
-        logService.saveAccessLog();
         return true;
     }
 
     @Override
     public void postHandle(HttpServletRequest request, HttpServletResponse response,
                            Object handler, @Nullable ModelAndView modelAndView) throws Exception {
-        String uri = request.getRequestURI();
-        if (uri.startsWith("/bg") && !uri.startsWith("/bg/api/oss/")) {
-            // 后台访问
-            AccountInfo accountInfo = accountService.getAccountInfo();
-            if (accountInfo != null) {
-                String msgCount = userMessageService.getUnreadCount();
-                accountInfo.setMsgCount(msgCount);
-                //ServletUtil.getSession().setAttribute("profile", accountInfo);
-                modelAndView.addObject("profile", accountInfo);
-            }
-        }
-
         logService.saveAccessLog();
     }