From 86b40e1fe59e32d4cf256ed0a6a0e27660cdc41f Mon Sep 17 00:00:00 2001 From: GPU is all you need <2778335106@qq.com> Date: Sun, 22 May 2022 15:33:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4ResultUtils=E7=B1=BB,Result?= =?UTF-8?q?=E7=B1=BB=E9=87=8D=E5=91=BD=E5=90=8D=E4=B8=BAR=E5=B9=B6?= =?UTF-8?q?=E5=85=B7=E6=9C=89ResultUtils=E7=9A=84=E6=89=80=E6=9C=89?= =?UTF-8?q?=E5=8A=9F=E8=83=BD,=E4=BF=AE=E5=A4=8DCustomUserCache=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=BD=93=E5=89=8D=E7=94=A8=E6=88=B7=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?,=E7=9B=B4=E6=8E=A5=E8=BF=94=E5=9B=9E,=E7=8E=B0=E5=9C=A8?= =?UTF-8?q?=E6=98=AF=E5=8E=BB=E6=95=B0=E6=8D=AE=E5=BA=93=E6=9F=A5,?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD=E5=9F=BA?= =?UTF-8?q?=E6=9C=AC=E5=AE=8C=E6=88=90,=E7=8E=B0=E5=9C=A8DataBaseUrl?= =?UTF-8?q?=E6=8A=95=E7=A5=A8=E5=99=A8,=E5=92=8CLoginFilter=E6=94=B9?= =?UTF-8?q?=E6=88=90=E6=96=B9=E4=BE=BF=E8=B0=83=E8=AF=95,=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E9=AA=8C=E8=AF=81=E7=A0=81=E5=8A=9F=E8=83=BD,?= =?UTF-8?q?=E5=92=8C=E9=89=B4=E6=9D=83=E5=8A=9F=E8=83=BD,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/controller/BaseController.java | 5 +- .../config/security/CustomUserCache.java | 9 + .../config/security/DataBaseUrlVoter.java | 120 +- .../award/config/security/SecurityConfig.java | 6 +- .../security/filter/AuthCheckFilter.java | 5 +- .../config/security/filter/LoginFilter.java | 23 +- .../ncst/award/controller/MenuController.java | 152 +- .../java/edu/ncst/award/domain/RoleMenu.java | 34 + .../edu/ncst/award/mapper/MenuMapper.java | 15 +- .../edu/ncst/award/mapper/RoleMenuMapper.java | 13 + .../edu/ncst/award/model/system/Menu.java | 13 +- .../edu/ncst/award/model/system/Role.java | 8 + .../edu/ncst/award/service/IMenuService.java | 83 +- .../service/impl/system/MenuServiceImpl.java | 139 +- .../src/main/resources/5-12-interface.json | 2939 ----------------- .../src/main/resources/mapper/MenuMapper.xml | 34 +- .../edu/ncst/award/TestSystemMenuService.java | 34 +- 17 files changed, 503 insertions(+), 3129 deletions(-) create mode 100644 awardBE/src/main/java/edu/ncst/award/domain/RoleMenu.java create mode 100644 awardBE/src/main/java/edu/ncst/award/mapper/RoleMenuMapper.java delete mode 100644 awardBE/src/main/resources/5-12-interface.json diff --git a/awardBE/src/main/java/edu/ncst/award/common/core/controller/BaseController.java b/awardBE/src/main/java/edu/ncst/award/common/core/controller/BaseController.java index 56a34bb..475ca32 100644 --- a/awardBE/src/main/java/edu/ncst/award/common/core/controller/BaseController.java +++ b/awardBE/src/main/java/edu/ncst/award/common/core/controller/BaseController.java @@ -1,6 +1,5 @@ package edu.ncst.award.common.core.controller; -import edu.ncst.award.utils.ResultUtils; import edu.ncst.award.domain.vo.R; /** @@ -17,7 +16,7 @@ public class BaseController { * @return 操作结果 */ protected R toAjax(int rows) { - return rows > 0 ? ResultUtils.ok() : ResultUtils.fail(); + return rows > 0 ? R.ok() : R.fail(); } /** @@ -27,7 +26,7 @@ public class BaseController { * @return 操作结果 */ protected R toAjax(boolean result) { - return result ? ResultUtils.ok() : ResultUtils.fail(); + return result ? R.ok() : R.fail(); } } diff --git a/awardBE/src/main/java/edu/ncst/award/config/security/CustomUserCache.java b/awardBE/src/main/java/edu/ncst/award/config/security/CustomUserCache.java index 5baa206..e53f637 100644 --- a/awardBE/src/main/java/edu/ncst/award/config/security/CustomUserCache.java +++ b/awardBE/src/main/java/edu/ncst/award/config/security/CustomUserCache.java @@ -2,9 +2,12 @@ package edu.ncst.award.config.security; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.spring.SpringUtil; import cn.hutool.json.JSONUtil; import edu.ncst.award.model.system.User; import edu.ncst.award.domain.vo.result.UserInfoVO; +import edu.ncst.award.service.IUserService; +import edu.ncst.award.service.impl.system.UserServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.security.core.context.SecurityContextHolder; @@ -12,6 +15,8 @@ import org.springframework.security.core.userdetails.UserCache; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Component; +import javax.annotation.Resource; + @Slf4j @Component @@ -87,6 +92,10 @@ public class CustomUserCache implements UserCache { if (ObjectUtil.isNotNull(userInfoVO) && ObjectUtil.isNull(userInfoVO.getUsername())) { currentUser = (User) getUserFromCache(userInfoVO.getUsername()); } + if (currentUser == null){ + currentUser = (User) SpringUtil.getBean(UserServiceImpl.class).loadUserByUsername(userInfoVO.getUsername()); + putUserInCache(currentUser); + } return currentUser; } } diff --git a/awardBE/src/main/java/edu/ncst/award/config/security/DataBaseUrlVoter.java b/awardBE/src/main/java/edu/ncst/award/config/security/DataBaseUrlVoter.java index f27a324..11a62e1 100644 --- a/awardBE/src/main/java/edu/ncst/award/config/security/DataBaseUrlVoter.java +++ b/awardBE/src/main/java/edu/ncst/award/config/security/DataBaseUrlVoter.java @@ -38,65 +38,69 @@ public class DataBaseUrlVoter implements AccessDecisionVoter { @Override public int vote(Authentication authentication, FilterInvocation fi, Collection attributes) { - if (authentication == null) { - return ACCESS_DENIED; // 反对票 - } - String url = fi.getRequestUrl(); // 当前请求的URL - String urlWithoutQueryString = URLUtils.removeQueryString(url); - - // Current User Info - Object details = authentication.getDetails(); - - if (details instanceof UserInfoVO) { - UserInfoVO userInfoVO = (UserInfoVO) details; - AntPathMatcher antPathMatcher = new AntPathMatcher(); - - //获取不限用户角色的资源 - List permitAllResourceURLs = resourceService.getPermitAllResourceURLs(); - // Permit All Resource - for (String permitUrl : permitAllResourceURLs) { - boolean match = antPathMatcher.match(permitUrl, urlWithoutQueryString); - if (match) { - return ACCESS_GRANTED; // 赞同票 - } - } - - // 判断用户角色信息 - // 反对票:1、没有角色信息 2、角色未绑定该资源 - // 赞成票:用户是超级管理员 - - List roles = userInfoVO.getRoles(); - if (roles == null || roles.isEmpty()) { - return ACCESS_DENIED; // 反对票 - } - - List roleNames = roles.stream().map(Role::getName).collect(Collectors.toList()); - - // Super Admin User Always Pass - if (roleNames.contains("SUPER_ADMIN")) { - return ACCESS_GRANTED; // 赞同票 - } - - List rolesResourceList = resourceService.getUserScopeResourceList(roleNames);//获取目标角色绑定的资源 - - - // Role Resource - if (rolesResourceList == null || rolesResourceList.size() <=0) { - return ACCESS_DENIED; // 反对票 - } - - // 当方法和url都匹配上才匹配成功 - for (Resource resource : rolesResourceList) { - boolean match = antPathMatcher.match(resource.getUrl(), urlWithoutQueryString) - && fi.getHttpRequest().getMethod().equals(resource.getMethod()); - if (match) { - return ACCESS_GRANTED; // 赞同票 - } - } - } - - return ACCESS_DENIED; + // 方便测试 + return ACCESS_GRANTED; + +// if (authentication == null) { +// return ACCESS_DENIED; // 反对票 +// } +// +// String url = fi.getRequestUrl(); // 当前请求的URL +// String urlWithoutQueryString = URLUtils.removeQueryString(url); +// +// // Current User Info +// Object details = authentication.getDetails(); +// +// if (details instanceof UserInfoVO) { +// UserInfoVO userInfoVO = (UserInfoVO) details; +// AntPathMatcher antPathMatcher = new AntPathMatcher(); +// +// //获取不限用户角色的资源 +// List permitAllResourceURLs = resourceService.getPermitAllResourceURLs(); +// // Permit All Resource +// for (String permitUrl : permitAllResourceURLs) { +// boolean match = antPathMatcher.match(permitUrl, urlWithoutQueryString); +// if (match) { +// return ACCESS_GRANTED; // 赞同票 +// } +// } +// +// // 判断用户角色信息 +// // 反对票:1、没有角色信息 2、角色未绑定该资源 +// // 赞成票:用户是超级管理员 +// +// List roles = userInfoVO.getRoles(); +// if (roles == null || roles.isEmpty()) { +// return ACCESS_DENIED; // 反对票 +// } +// +// List roleNames = roles.stream().map(Role::getName).collect(Collectors.toList()); +// +// // Super Admin User Always Pass +// if (roleNames.contains("SUPER_ADMIN")) { +// return ACCESS_GRANTED; // 赞同票 +// } +// +// List rolesResourceList = resourceService.getUserScopeResourceList(roleNames);//获取目标角色绑定的资源 +// +// +// // Role Resource +// if (rolesResourceList == null || rolesResourceList.size() <=0) { +// return ACCESS_DENIED; // 反对票 +// } +// +// // 当方法和url都匹配上才匹配成功 +// for (Resource resource : rolesResourceList) { +// boolean match = antPathMatcher.match(resource.getUrl(), urlWithoutQueryString) +// && fi.getHttpRequest().getMethod().equals(resource.getMethod()); +// if (match) { +// return ACCESS_GRANTED; // 赞同票 +// } +// } +// } +// +// return ACCESS_DENIED; } Collection extractAuthorities( diff --git a/awardBE/src/main/java/edu/ncst/award/config/security/SecurityConfig.java b/awardBE/src/main/java/edu/ncst/award/config/security/SecurityConfig.java index 06a23ef..fa2939e 100644 --- a/awardBE/src/main/java/edu/ncst/award/config/security/SecurityConfig.java +++ b/awardBE/src/main/java/edu/ncst/award/config/security/SecurityConfig.java @@ -3,10 +3,10 @@ package edu.ncst.award.config.security; import com.fasterxml.jackson.databind.ObjectMapper; import edu.ncst.award.config.security.filter.AuthCheckFilter; import edu.ncst.award.config.security.filter.LoginFilter; +import edu.ncst.award.domain.vo.R; import edu.ncst.award.exception.CodeMsg; import edu.ncst.award.service.ILoginLogService; import edu.ncst.award.service.impl.system.UserServiceImpl; -import edu.ncst.award.utils.ResultUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; @@ -161,7 +161,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { response.setContentType("application/json;charset=utf-8"); PrintWriter out = response.getWriter(); - out.write(new ObjectMapper().writeValueAsString(ResultUtils.fail(CodeMsg.USER_NEED_LOGIN))); + out.write(new ObjectMapper().writeValueAsString(R.fail(CodeMsg.USER_NEED_LOGIN))); out.flush(); out.close(); })); @@ -173,7 +173,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { .logoutSuccessHandler(((request, response, authentication) -> { PrintWriter out = response.getWriter(); response.setContentType("application/json"); - out.write(new ObjectMapper().writeValueAsString(ResultUtils.ok("注销成功"))); + out.write(new ObjectMapper().writeValueAsString(R.ok("注销成功"))); out.flush(); out.close(); })); diff --git a/awardBE/src/main/java/edu/ncst/award/config/security/filter/AuthCheckFilter.java b/awardBE/src/main/java/edu/ncst/award/config/security/filter/AuthCheckFilter.java index 8d3cb98..70ebcca 100644 --- a/awardBE/src/main/java/edu/ncst/award/config/security/filter/AuthCheckFilter.java +++ b/awardBE/src/main/java/edu/ncst/award/config/security/filter/AuthCheckFilter.java @@ -5,7 +5,6 @@ import edu.ncst.award.config.security.token.JwtAuthenticationToken; import edu.ncst.award.exception.CodeMsg; import edu.ncst.award.model.system.Role; import edu.ncst.award.utils.ResponseUtils; -import edu.ncst.award.utils.ResultUtils; import edu.ncst.award.domain.vo.R; import edu.ncst.award.domain.vo.result.UserInfoVO; import io.jsonwebtoken.Claims; @@ -78,7 +77,7 @@ public class AuthCheckFilter extends OncePerRequestFilter { if (jwtToken == null || "".equals(jwtToken)) { log.error("鉴权TOKEN:未获取,用户需要登录"); - R r = ResultUtils.fail(CodeMsg.USER_NEED_LOGIN); + R r = R.fail(CodeMsg.USER_NEED_LOGIN); ResponseUtils.output(response, r); } else { log.info("鉴权TOKEN:" + "Bearer " + jwtToken); @@ -115,7 +114,7 @@ public class AuthCheckFilter extends OncePerRequestFilter { JwtAuthenticationToken token = new JwtAuthenticationToken(userName, authorities, userInfoVO); SecurityContextHolder.getContext().setAuthentication(token); } catch (ExpiredJwtException e) { - R r = ResultUtils.fail(CodeMsg.USER_TOKEN_EXPIRED);// 用户凭证过期 + R r = R.fail(CodeMsg.USER_TOKEN_EXPIRED);// 用户凭证过期 ResponseUtils.output(response, r); } finally { filterChain.doFilter(request, response); diff --git a/awardBE/src/main/java/edu/ncst/award/config/security/filter/LoginFilter.java b/awardBE/src/main/java/edu/ncst/award/config/security/filter/LoginFilter.java index 809ae77..b6b0dd2 100644 --- a/awardBE/src/main/java/edu/ncst/award/config/security/filter/LoginFilter.java +++ b/awardBE/src/main/java/edu/ncst/award/config/security/filter/LoginFilter.java @@ -7,7 +7,6 @@ import edu.ncst.award.exception.CodeMsg; import edu.ncst.award.model.system.Role; import edu.ncst.award.model.system.User; import edu.ncst.award.service.ILoginLogService; -import edu.ncst.award.utils.ResultUtils; import edu.ncst.award.domain.vo.R; import edu.ncst.award.domain.vo.param.UserLoginDTO; import edu.ncst.award.domain.vo.result.UserInfoVO; @@ -162,7 +161,7 @@ public class LoginFilter extends AbstractAuthenticationProcessingFilter {//OnceP loginLogService.addLoginLog(userInfoVO.getId(), true); // 返回结果 - R result = ResultUtils.ok("登录成功", jwt); + R result = R.ok("登录成功", jwt); response.setContentType("application/json;charset=utf-8"); Cookie cookieToken = new Cookie("SYS_TOKEN", jwt); cookieToken.setHttpOnly(true); @@ -218,37 +217,37 @@ public class LoginFilter extends AbstractAuthenticationProcessingFilter {//OnceP R r = new R<>(); log.debug("登录失败:" + failed); if (failed instanceof LockedException) { - r = ResultUtils.fail(CodeMsg.USER_IS_LOCKED); + r = R.fail(CodeMsg.USER_IS_LOCKED); } else if (failed instanceof CredentialsExpiredException) { if (failed.getMessage() != null) { - r = ResultUtils.fail(failed.getMessage()); + r = R.fail(failed.getMessage()); } - r = ResultUtils.fail(CodeMsg.USER_CREDENTIALS_EXPIRED); + r = R.fail(CodeMsg.USER_CREDENTIALS_EXPIRED); } else if (failed instanceof AccountExpiredException) { - r = ResultUtils.fail(CodeMsg.USER_ACCOUNT_EXPIRED); + r = R.fail(CodeMsg.USER_ACCOUNT_EXPIRED); } else if (failed instanceof DisabledException) { - r = ResultUtils.fail(CodeMsg.USER_IS_DISABLED); + r = R.fail(CodeMsg.USER_IS_DISABLED); } else if (failed instanceof AuthenticationException) { if (failed instanceof BusinessException) { stringRedisTemplate.delete("captcha:" + tempToken); BusinessException businessException = (BusinessException) failed; - r = ResultUtils.fail(businessException.getError()); + r = R.fail(businessException.getError()); } else { Throwable cause = failed.getCause(); if (cause instanceof BusinessException) { BusinessException businessException = (BusinessException) cause; - r = ResultUtils.fail(businessException.getError()); + r = R.fail(businessException.getError()); } else { if (failed instanceof UsernameNotFoundException) { - r = ResultUtils.fail(failed.getMessage(), false); + r = R.fail(failed.getMessage(), false); } else { - r = ResultUtils.fail(CodeMsg.USER_BAD_CREDENTIALS); + r = R.fail(CodeMsg.USER_BAD_CREDENTIALS); } } } } else { - r = ResultUtils.fail(CodeMsg.LOGIN_FAIL); + r = R.fail(CodeMsg.LOGIN_FAIL); } // 拦截后直接将错误信息反馈给前端,不经过全局异常处理器(GlobalExceptionHandler)处理 diff --git a/awardBE/src/main/java/edu/ncst/award/controller/MenuController.java b/awardBE/src/main/java/edu/ncst/award/controller/MenuController.java index adb418c..da0ed8e 100644 --- a/awardBE/src/main/java/edu/ncst/award/controller/MenuController.java +++ b/awardBE/src/main/java/edu/ncst/award/controller/MenuController.java @@ -1,18 +1,26 @@ package edu.ncst.award.controller; +import cn.hutool.core.lang.tree.Tree; +import edu.ncst.award.common.annotation.Log; +import edu.ncst.award.common.annotation.enums.BusinessType; +import edu.ncst.award.common.constant.UserConstants; +import edu.ncst.award.common.core.controller.BaseController; import edu.ncst.award.domain.vo.R; import edu.ncst.award.model.system.Menu; import edu.ncst.award.service.IMenuService; import edu.ncst.award.service.IUserService; +import edu.ncst.award.utils.StringUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** @@ -23,7 +31,7 @@ import java.util.List; @RequiredArgsConstructor @RestController @RequestMapping("/api/menu") -public class MenuController { +public class MenuController extends BaseController { private final IMenuService menuService; private final IUserService userService; @@ -38,25 +46,88 @@ public class MenuController { return R.ok(menus); } -// -// public MenuController(IMenuService menuService) { -// this.menuService = menuService; -// } -// -// @ApiOperation("获取菜单列表") -// @GetMapping("/list") -// public ResultVO> getMenuList(Query query) { -// ListResultVO menuList = menuService.getMenuList(query); -// -// return ResultUtils.success("ok", menuList); -// } -// -// @ApiOperation("获取菜单树") -// @GetMapping("/tree") -// public ResultVO> getMenuTree() { -// List menuTree = menuService.getMenuTree(); -// return ResultUtils.success("ok", menuTree); -// } + /** + * 根据菜单编号获取详细信息 + */ + @ApiOperation("根据菜单编号获取详细信息") + @GetMapping(value = "/{menuId}") + public R getInfo(@ApiParam("菜单ID") @PathVariable Long menuId) { + return R.ok(menuService.selectMenuById(menuId)); + } + + /** + * 获取菜单下拉树列表 + */ + @ApiOperation("获取菜单下拉树列表") + @GetMapping("/treeSelect") + public R>> treeSelect(Menu menu) { + List menus = menuService.selectMenuList(menu, userService.getCurrentUser().getId()); + return R.ok(menuService.buildMenuTreeSelect(menus)); + } + + + /** + * 加载对应角色菜单列表树 + */ + @ApiOperation("加载对应角色菜单列表树") + @GetMapping(value = "/roleMenuTreeSelect/{roleId}") + public R> roleMenuTreeSelect(@ApiParam("角色ID") @PathVariable("roleId") Long roleId) { + List menus = menuService.selectMenuList(userService.getCurrentUser().getId()); + Map ajax = new HashMap<>(); + ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); + ajax.put("menus", menuService.buildMenuTreeSelect(menus)); + return R.ok(ajax); + } + + /** + * 新增菜单 + */ + @ApiOperation("新增菜单") + @Log(title = "菜单管理", businessType = BusinessType.INSERT) + @PostMapping + public R add(@Validated @RequestBody Menu menu) { + if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { + return R.fail("新增菜单'" + menu.getName() + "'失败,菜单名称已存在"); + } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getRoutePath())) { + return R.fail("新增菜单'" + menu.getName() + "'失败,地址必须以http(s)://开头"); + } + return toAjax(menuService.insertMenu(menu)); + } + + /** + * 修改菜单 + */ + @ApiOperation("修改菜单") + @Log(title = "菜单管理", businessType = BusinessType.UPDATE) + @PutMapping + public R edit(@Validated @RequestBody Menu menu) { + if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { + return R.fail("修改菜单'" + menu.getName() + "'失败,菜单名称已存在"); + } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getRoutePath())) { + return R.fail("修改菜单'" + menu.getName() + "'失败,地址必须以http(s)://开头"); + } else if (menu.getId().equals(menu.getParentId())) { + return R.fail("修改菜单'" + menu.getName() + "'失败,上级菜单不能选择自己"); + } + return toAjax(menuService.updateMenu(menu)); + } + + /** + * 删除菜单 + */ + @ApiOperation("删除菜单") + @Log(title = "菜单管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{menuId}") + public R remove(@ApiParam("菜单ID") @PathVariable("menuId") Long menuId) { + if (menuService.hasChildByMenuId(menuId)) { + return R.fail("存在子菜单,不允许删除"); + } + if (menuService.checkMenuExistRole(menuId)) { + return R.fail("菜单已分配,不允许删除"); + } + return toAjax(menuService.deleteMenuById(menuId)); + } + + // // @ApiOperation("获取指定角色能够访问的菜单ID列表") // @GetMapping("/ids/role") @@ -64,40 +135,7 @@ public class MenuController { // List menuIds = menuService.getRoleMenuIds(roleId,true); // return ResultUtils.success("ok", menuIds); // } -// -// @ApiOperation("获取菜单详情") -// @PostMapping("/detail") -// public ResultVO getMenuDetail(@RequestParam Integer id) { -// Menu menuDetail = menuService.getMenuDetail(id); -// -// return ResultUtils.success("ok", menuDetail); -// } -// -// @ApiOperation("添加菜单") -// @PostMapping("/add") -// public ResultVO addMenu(@RequestBody Menu menu) { -// log.info("将要添加的菜单:" + menu); -// Menu result = menuService.addMenu(menu); -// -// return ResultUtils.success("ok", result); -// } -// -// @ApiOperation("修改菜单") -// @PostMapping("/modify") -// public ResultVO modifyMenu(@RequestBody Menu menu) { -// Menu result = menuService.modifyMenu(menu); -// -// return ResultUtils.success("ok", result); -// } -// -// @ApiOperation("删除菜单") -// @PostMapping("/delete") -// public ResultVO deleteMenu(@RequestParam Integer id) { -// menuService.deleteMenu(id); -// -// return ResultUtils.success("ok", null); -// } -// + // // @ApiOperation("获取指定用户可访问的菜单列表") // @GetMapping("/user/{userId}") diff --git a/awardBE/src/main/java/edu/ncst/award/domain/RoleMenu.java b/awardBE/src/main/java/edu/ncst/award/domain/RoleMenu.java new file mode 100644 index 0000000..87ed170 --- /dev/null +++ b/awardBE/src/main/java/edu/ncst/award/domain/RoleMenu.java @@ -0,0 +1,34 @@ +package edu.ncst.award.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 角色和菜单关联 sys_role_menu + * + * @author Lion Li + */ + +@Data +@TableName("sys_role_menu") +@ApiModel("角色和菜单关联") +public class RoleMenu { + + /** + * 角色ID + */ + @TableId(type = IdType.INPUT) + @ApiModelProperty(value = "角色ID") + private Long roleId; + + /** + * 菜单ID + */ + @ApiModelProperty(value = "角色ID") + private Long menuId; + +} diff --git a/awardBE/src/main/java/edu/ncst/award/mapper/MenuMapper.java b/awardBE/src/main/java/edu/ncst/award/mapper/MenuMapper.java index 18f765b..5267f6a 100644 --- a/awardBE/src/main/java/edu/ncst/award/mapper/MenuMapper.java +++ b/awardBE/src/main/java/edu/ncst/award/mapper/MenuMapper.java @@ -21,9 +21,18 @@ public interface MenuMapper extends BaseMapper { List getMenuTree(@Param("parentId") Integer parentId); - List selectMenuByUserId(Integer userId); - - List selectMenuListByUserId(Menu menu, Long userId); + List selectMenuByUserId(@Param("userId") Integer userId); + + List selectMenuListByUserId(@Param("menu") Menu menu, @Param("userId") Long userId); + + /** + * 根据角色ID查询菜单树信息 + * + * @param roleId 角色ID + * @param menuCheckStrictly 菜单树选择项是否关联显示 + * @return 选中菜单列表 + */ + List selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly); // // 清空菜单项 // int removeAllMenuItem(); diff --git a/awardBE/src/main/java/edu/ncst/award/mapper/RoleMenuMapper.java b/awardBE/src/main/java/edu/ncst/award/mapper/RoleMenuMapper.java new file mode 100644 index 0000000..2450a92 --- /dev/null +++ b/awardBE/src/main/java/edu/ncst/award/mapper/RoleMenuMapper.java @@ -0,0 +1,13 @@ +package edu.ncst.award.mapper; + +import edu.ncst.award.common.mapper.BaseMapperPlus; +import edu.ncst.award.domain.RoleMenu; + +/** + * 角色与菜单关联表 数据层 + * + * @author Lion Li + */ +public interface RoleMenuMapper extends BaseMapperPlus { + +} diff --git a/awardBE/src/main/java/edu/ncst/award/model/system/Menu.java b/awardBE/src/main/java/edu/ncst/award/model/system/Menu.java index 5c3e8b8..cbd22d6 100644 --- a/awardBE/src/main/java/edu/ncst/award/model/system/Menu.java +++ b/awardBE/src/main/java/edu/ncst/award/model/system/Menu.java @@ -62,7 +62,7 @@ public class Menu extends TreeNode implements Serializable { @ApiModelProperty(value = "是否显示在菜单上") private Boolean showInMenu = true; - @ApiModelProperty(value = "显示排序") + @ApiModelProperty(value = "排序权重") private Integer sort = 0; @ApiModelProperty(value = "备注") @@ -72,6 +72,17 @@ public class Menu extends TreeNode implements Serializable { @TableLogic private Date deleteTime; + @ApiModelProperty(value = "是否启用") + private Boolean status; + + /** + * 是否为外链(0是 1否) + */ + @ApiModelProperty(value = "是否为外链(0是 1否)") + @TableField(exist = false) + private String isFrame; + + @ApiModelProperty(value = "菜单树路径") @TableField(exist = false) private String treePath; diff --git a/awardBE/src/main/java/edu/ncst/award/model/system/Role.java b/awardBE/src/main/java/edu/ncst/award/model/system/Role.java index c809f3d..d3f2e77 100644 --- a/awardBE/src/main/java/edu/ncst/award/model/system/Role.java +++ b/awardBE/src/main/java/edu/ncst/award/model/system/Role.java @@ -32,6 +32,14 @@ public class Role extends BaseEntity { @ApiModelProperty(value = "显示文本") private String label; + /** + * 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) + */ + @ApiModelProperty(value = "菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)") + @TableField(exist = false) + private boolean menuCheckStrictly; + + @ApiModelProperty(value = "是否启用") private Boolean enable; diff --git a/awardBE/src/main/java/edu/ncst/award/service/IMenuService.java b/awardBE/src/main/java/edu/ncst/award/service/IMenuService.java index 9828d08..ae70342 100644 --- a/awardBE/src/main/java/edu/ncst/award/service/IMenuService.java +++ b/awardBE/src/main/java/edu/ncst/award/service/IMenuService.java @@ -1,8 +1,9 @@ package edu.ncst.award.service; +import cn.hutool.core.lang.tree.Tree; import com.baomidou.mybatisplus.extension.service.IService; -import edu.ncst.award.model.system.Menu; import edu.ncst.award.domain.vo.RouterVo; +import edu.ncst.award.model.system.Menu; import java.util.List; @@ -11,13 +12,14 @@ import java.util.List; */ public interface IMenuService extends IService { + /** * 根据用户查询系统菜单列表 * - * @param menu 菜单信息 + * @param userId 用户ID * @return 菜单列表 */ - List selectMenuList(Menu menu); + List selectMenuList(Long userId); /** * 根据用户查询系统菜单列表 @@ -28,6 +30,80 @@ public interface IMenuService extends IService { */ List selectMenuList(Menu menu, Long userId); + /** + * 根据角色ID查询菜单树信息 + * + * @param roleId 角色ID + * @return 选中菜单列表 + */ + List selectMenuListByRoleId(Long roleId); + + + /** + * 根据菜单ID查询信息 + * + * @param menuId 菜单ID + * @return 菜单信息 + */ + Menu selectMenuById(Long menuId); + + /** + * 构建前端所需要下拉树结构 + * + * @param menus 菜单列表 + * @return 下拉树结构列表 + */ + List> buildMenuTreeSelect(List menus); + + /** + * 校验菜单名称是否唯一 + * + * @param menu 菜单信息 + * @return 结果 + */ + String checkMenuNameUnique(Menu menu); + + + /** + * 新增保存菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + int insertMenu(Menu menu); + + /** + * 修改菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + int updateMenu(Menu menu); + + /** + * 是否存在菜单子节点 + * + * @param menuId 菜单ID + * @return 结果 true 存在 false 不存在 + */ + boolean hasChildByMenuId(Long menuId); + + /** + * 查询菜单是否存在角色 + * + * @param menuId 菜单ID + * @return 结果 true 存在 false 不存在 + */ + boolean checkMenuExistRole(Long menuId); + + /** + * 删除菜单管理信息 + * + * @param menuId 菜单ID + * @return 结果 + */ + int deleteMenuById(Long menuId); + // // 获取菜单列表 // ListResultVO getMenuList(Query query); // @@ -76,6 +152,7 @@ public interface IMenuService extends IService { /** * 获取当前用户能够访问的路由菜单列表 + * * @param userId 用户id */ List selectMenuByUserId(Integer userId); diff --git a/awardBE/src/main/java/edu/ncst/award/service/impl/system/MenuServiceImpl.java b/awardBE/src/main/java/edu/ncst/award/service/impl/system/MenuServiceImpl.java index bd8f0ac..884c5b3 100644 --- a/awardBE/src/main/java/edu/ncst/award/service/impl/system/MenuServiceImpl.java +++ b/awardBE/src/main/java/edu/ncst/award/service/impl/system/MenuServiceImpl.java @@ -1,16 +1,26 @@ package edu.ncst.award.service.impl.system; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.tree.Tree; +import cn.hutool.core.lang.tree.TreeUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import edu.ncst.award.common.constant.UserConstants; import edu.ncst.award.common.util.treeUtils.TreeUtils; +import edu.ncst.award.domain.RoleMenu; +import edu.ncst.award.domain.vo.RouterVo; import edu.ncst.award.mapper.MenuMapper; +import edu.ncst.award.mapper.RoleMapper; +import edu.ncst.award.mapper.RoleMenuMapper; import edu.ncst.award.model.system.Menu; +import edu.ncst.award.model.system.Role; import edu.ncst.award.service.IMenuService; -import edu.ncst.award.domain.vo.RouterVo; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import java.util.*; +import java.util.List; /** * 菜单 服务实现类 @@ -21,6 +31,8 @@ import java.util.*; public class MenuServiceImpl extends ServiceImpl implements IMenuService { private final MenuMapper menuMapper; + private final RoleMapper roleMapper; + private final RoleMenuMapper roleMenuMapper; /** * 获取当前用户能够访问的路由菜单列表 @@ -61,16 +73,33 @@ public class MenuServiceImpl extends ServiceImpl implements IM return menuMapper.selectMenuByUserId(0); } - /** * 根据用户查询系统菜单列表 * - * @param menu 菜单信息 + * @param userId 用户ID * @return 菜单列表 */ @Override - public List selectMenuList(Menu menu) { - return null; + public List selectMenuList(Long userId) { + return selectMenuList(new Menu(), userId); + } + + /** + * 校验菜单名称是否唯一 + * + * @param menu 菜单信息 + * @return 结果 + */ + @Override + public String checkMenuNameUnique(Menu menu) { + boolean exist = baseMapper.exists(new LambdaQueryWrapper() + .eq(Menu::getName, menu.getName()) + .eq(Menu::getParentId, menu.getParentId()) + .ne(ObjectUtil.isNotNull(menu.getId()), Menu::getId, menu.getId())); + if (exist) { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; } /** @@ -82,8 +111,104 @@ public class MenuServiceImpl extends ServiceImpl implements IM */ @Override public List selectMenuList(Menu menu, Long userId) { - return baseMapper.selectMenuListByUserId(menu,userId); + return baseMapper.selectMenuListByUserId(menu, userId); + } + + /** + * 根据角色ID查询菜单树信息 + * + * @param roleId 角色ID + * @return 选中菜单列表 + */ + @Override + public List selectMenuListByRoleId(Long roleId) { + Role role = roleMapper.selectById(roleId); + return baseMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly()); + } + + /** + * 根据菜单ID查询信息 + * + * @param menuId 菜单ID + * @return 菜单信息 + */ + @Override + public Menu selectMenuById(Long menuId) { + return baseMapper.selectById(menuId); + } + + + /** + * 构建前端所需要下拉树结构 + * + * @param menus 菜单列表 + * @return 下拉树结构列表 + */ + @Override + public List> buildMenuTreeSelect(List menus) { + if (CollUtil.isEmpty(menus)) { + return CollUtil.newArrayList(); + } + return TreeUtil.build(menus, 0, (menu, tree) -> + tree.setId(menu.getId()) + .setParentId(menu.getParentId()) + .setName(menu.getName()) + .setWeight(menu.getSort())); } + /** + * 新增保存菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + @Override + public int insertMenu(Menu menu) { + return baseMapper.insert(menu); + } + + /** + * 修改菜单信息 + * + * @param menu 菜单信息 + * @return 结果 + */ + @Override + public int updateMenu(Menu menu) { + return baseMapper.updateById(menu); + } + + /** + * 是否存在菜单子节点 + * + * @param menuId 菜单ID + * @return 结果 true 存在 false 不存在 + */ + @Override + public boolean hasChildByMenuId(Long menuId) { + return baseMapper.exists(new LambdaQueryWrapper().eq(Menu::getParentId, menuId)); + } + + /** + * 查询菜单是否存在角色 + * + * @param menuId 菜单ID + * @return 结果 true 存在 false 不存在 + */ + @Override + public boolean checkMenuExistRole(Long menuId) { + return roleMenuMapper.exists(new LambdaQueryWrapper().eq(RoleMenu::getMenuId, menuId)); + } + + /** + * 删除菜单管理信息 + * + * @param menuId 菜单ID + * @return 结果 + */ + @Override + public int deleteMenuById(Long menuId){ + return baseMapper.deleteById(menuId); + } } diff --git a/awardBE/src/main/resources/5-12-interface.json b/awardBE/src/main/resources/5-12-interface.json deleted file mode 100644 index 0fde81e..0000000 --- a/awardBE/src/main/resources/5-12-interface.json +++ /dev/null @@ -1,2939 +0,0 @@ -{ - "openapi": "3.0.3", - "info": { - "title": "Swagger3接口文档", - "description": "Rabbit用Swagger3.0。", - "contact": { - "name": "Rabbit", - "url": "https://swagger.io/", - "email": "362250024@qq.com" - }, - "version": "1.0" - }, - "servers": [ - { - "url": "http://localhost:8083", - "description": "Inferred Url" - } - ], - "tags": [ - { - "name": "AuthController", - "description": "Login Controller" - }, - { - "name": "MenuController", - "description": "Menu Controller" - }, - { - "name": "ProjectController", - "description": "Project Controller" - }, - { - "name": "TestController", - "description": "Test Controller" - }, - { - "name": "UserController", - "description": "User Controller" - }, - { - "name": "captcha-controller", - "description": "Captcha Controller" - }, - { - "name": "dict-country-controller", - "description": "Dict Country Controller" - }, - { - "name": "dict-evaluate-level-controller", - "description": "Dict Evaluate Level Controller" - } - ], - "paths": { - "/api/captcha.jpg": { - "get": { - "tags": [ - "captcha-controller" - ], - "summary": "getCaptcha", - "operationId": "getCaptchaUsingGET", - "responses": { - "200": { - "description": "OK" - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/api/dict/country": { - "get": { - "tags": [ - "dict-country-controller" - ], - "summary": "getAllCountry", - "operationId": "getAllCountryUsingGET", - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ResultVO«List«DictCountry对象»»" - } - } - } - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/dict/evaluate-level-entity": { - "get": { - "tags": [ - "dict-evaluate-level-controller" - ], - "summary": "getAllCountry", - "operationId": "getAllCountryUsingGET_1", - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ResultVO«List«DictEvaluateLevel对象»»" - } - } - } - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/api/getCurrentUser": { - "get": { - "tags": [ - "AuthController" - ], - "summary": "获取当前用户信息", - "operationId": "getRoutersUsingGET", - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/UserDetails" - } - } - } - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/api/logout": { - "get": { - "tags": [ - "AuthController" - ], - "summary": "注销登录", - "operationId": "logoutUsingGET", - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ResultVO«object»" - } - } - } - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/api/menu/getRouters/{userId}": { - "get": { - "tags": [ - "MenuController" - ], - "summary": "获取路由信息", - "operationId": "getRoutersUsingGET_1", - "parameters": [ - { - "name": "userId", - "in": "path", - "description": "userId", - "required": true, - "style": "simple", - "schema": { - "type": "integer", - "format": "int32" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ResultVO«List«路由配置信息»»" - } - } - } - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/api/project": { - "post": { - "tags": [ - "ProjectController" - ], - "summary": "保存project数据", - "operationId": "saveProjectUsingPOST", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProjectEntity对象" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ProjectEntity对象" - } - } - } - }, - "201": { - "description": "Created" - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/test/user/detail": { - "get": { - "tags": [ - "TestController" - ], - "summary": "get传参,简单类型,requestParam注解", - "operationId": "getUserInfoUsingGET", - "parameters": [ - { - "name": "phone", - "in": "query", - "description": "phone", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "name", - "in": "query", - "description": "name", - "required": true, - "style": "form", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ResponseEntity" - } - } - } - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/test/user/detail00": { - "post": { - "tags": [ - "TestController" - ], - "summary": "post传参,简单类型,requestParam注解", - "operationId": "getUserInfo00UsingPOST", - "parameters": [ - { - "name": "param", - "in": "query", - "description": "param", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "name", - "in": "query", - "description": "name", - "required": true, - "style": "form", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ResponseEntity" - } - } - } - }, - "201": { - "description": "Created" - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/test/user/detail1": { - "get": { - "tags": [ - "TestController" - ], - "summary": "get方法传参,类接收,无注解", - "operationId": "getUserInfo1UsingGET", - "parameters": [ - { - "name": "name", - "in": "query", - "description": "姓名", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "phone", - "in": "query", - "description": "手机号", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/UserInfoVO" - } - } - } - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/test/user/detail11": { - "post": { - "tags": [ - "TestController" - ], - "summary": "post方法传参,类接收,无注解", - "operationId": "getUserInfo11UsingPOST", - "parameters": [ - { - "name": "name", - "in": "query", - "description": "姓名", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "phone", - "in": "query", - "description": "手机号", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/UserInfoVO" - } - } - } - }, - "201": { - "description": "Created" - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/test/user/detail2": { - "get": { - "tags": [ - "TestController" - ], - "summary": "get方法传参,类接收,requestparam注解", - "operationId": "getUserInfo2UsingGET", - "parameters": [ - { - "name": "param", - "in": "query", - "description": "param", - "required": true, - "style": "form", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/UserInfoVO" - } - } - } - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/test/user/detail22": { - "post": { - "tags": [ - "TestController" - ], - "summary": "post方法传参,类接收,requestparam注解", - "operationId": "getUserInfo22UsingPOST", - "parameters": [ - { - "name": "param", - "in": "query", - "description": "param", - "required": true, - "style": "form", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/UserInfoVO" - } - } - } - }, - "201": { - "description": "Created" - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/test/user/detail3": { - "get": { - "tags": [ - "TestController" - ], - "summary": "get方法传参,类接收,requestbody注解", - "operationId": "getUserInfo3UsingGET", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserQuery" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/UserInfoVO" - } - } - } - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/test/user/detail4": { - "post": { - "tags": [ - "TestController" - ], - "summary": "post方法传参,类接收,requestbody注解", - "operationId": "getUserInfo4UsingPOST", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserQuery" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/UserInfoVO" - } - } - } - }, - "201": { - "description": "Created" - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/test/user/detail5": { - "post": { - "tags": [ - "TestController" - ], - "summary": "post方法传参,类接收,requestbody注解", - "operationId": "getUserInfo5UsingPOST", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/MajorCategory" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ListResultVO«MajorCategory»" - } - } - } - }, - "201": { - "description": "Created" - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/test/user/detailResource": { - "post": { - "tags": [ - "TestController" - ], - "summary": "post方法传参,类接收,requestbody注解", - "operationId": "getUserInfoResourceUsingPOST", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SysResourceEntity对象" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ResultVO«SysResourceEntity对象»" - } - } - } - }, - "201": { - "description": "Created" - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/api/user": { - "put": { - "tags": [ - "UserController" - ], - "summary": "修改用户", - "operationId": "editUsingPUT", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserReq" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ResultVO«Void»" - } - } - } - }, - "201": { - "description": "Created" - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - }, - "post": { - "tags": [ - "UserController" - ], - "summary": "处理新增用户请求", - "operationId": "listUsingPOST", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserReq" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ResultVO«Void»" - } - } - } - }, - "201": { - "description": "Created" - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/api/user/": { - "get": { - "tags": [ - "UserController" - ], - "summary": "根据用户编号获取详细信息", - "operationId": "getInfoUsingGET", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "用户ID", - "required": true, - "style": "simple", - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ResultVO«Map«string,object»»" - } - } - } - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/api/user/current": { - "get": { - "tags": [ - "UserController" - ], - "summary": "获取当前用户信息", - "operationId": "getCurrentUserUsingGET", - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "type": "object" - } - } - } - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/api/user/list": { - "get": { - "tags": [ - "UserController" - ], - "summary": "获取用户列表", - "operationId": "listUsingGET", - "parameters": [ - { - "name": "accountNonExpired", - "in": "query", - "required": false, - "style": "form", - "schema": { - "type": "boolean" - } - }, - { - "name": "accountNonLocked", - "in": "query", - "required": false, - "style": "form", - "schema": { - "type": "boolean" - } - }, - { - "name": "address", - "in": "query", - "description": "通讯地址", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "admin", - "in": "query", - "description": "是否超级管理员", - "required": false, - "style": "form", - "schema": { - "type": "boolean" - } - }, - { - "name": "authorities[0].authority", - "in": "query", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "birthArea", - "in": "query", - "description": "出生地", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "birthDate", - "in": "query", - "description": "出生日期", - "required": false, - "style": "form", - "schema": { - "type": "string", - "format": "date" - } - }, - { - "name": "college", - "in": "query", - "description": "毕业学校", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "country", - "in": "query", - "description": "国籍", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "createTime", - "in": "query", - "description": "创建时间", - "required": false, - "style": "form", - "schema": { - "type": "string", - "format": "date-time" - } - }, - { - "name": "createUserId", - "in": "query", - "description": "创建人", - "required": false, - "style": "form", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "credentialsNonExpired", - "in": "query", - "required": false, - "style": "form", - "schema": { - "type": "boolean" - } - }, - { - "name": "degree", - "in": "query", - "description": "最高学位{0:博士;1:硕士;2:学士;3:专科;4:其他}", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "delFlag", - "in": "query", - "description": "是否删除 2:删除 0:未删除", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "deleteUserId", - "in": "query", - "description": "删除者", - "required": false, - "style": "form", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "deptId", - "in": "query", - "description": "二级单位(部门)ID", - "required": false, - "style": "form", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "education", - "in": "query", - "description": "最高学历{0:研究生;1:本科;2:专科;3:其他}", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "email", - "in": "query", - "description": "电子邮箱", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "enable", - "in": "query", - "description": "是否启用 1:启用 0:禁用", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "enabled", - "in": "query", - "required": false, - "style": "form", - "schema": { - "type": "boolean" - } - }, - { - "name": "fullName", - "in": "query", - "description": "真实姓名", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "graduateDate", - "in": "query", - "description": "毕业日期", - "required": false, - "style": "form", - "schema": { - "type": "string", - "format": "date" - } - }, - { - "name": "id", - "in": "query", - "description": "用户ID", - "required": false, - "style": "form", - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "idCard", - "in": "query", - "description": "身份证号", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "isAbroad", - "in": "query", - "description": "是否归国人员", - "required": false, - "style": "form", - "schema": { - "type": "boolean" - } - }, - { - "name": "isAsc", - "in": "query", - "description": "排序的方向", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "lastModifyTime", - "in": "query", - "description": "最后更新时间", - "required": false, - "style": "form", - "schema": { - "type": "string", - "format": "date-time" - } - }, - { - "name": "lastModifyUserId", - "in": "query", - "description": "最后更新者", - "required": false, - "style": "form", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "major", - "in": "query", - "description": "所学专业", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "mobilePhone", - "in": "query", - "description": "手机号", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "nation", - "in": "query", - "description": "民族", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "nickname", - "in": "query", - "description": "用户昵称", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "officePhone", - "in": "query", - "description": "办公电话", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "orderByColumn", - "in": "query", - "description": "排序列", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "pageNum", - "in": "query", - "description": "当前页数", - "required": false, - "style": "form", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "pageSize", - "in": "query", - "description": "分页大小", - "required": false, - "style": "form", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "params", - "in": "query", - "description": "请求参数", - "required": false, - "style": "form", - "schema": { - "type": "object" - } - }, - { - "name": "party", - "in": "query", - "description": "党派", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "password", - "in": "query", - "description": "密码", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "position", - "in": "query", - "description": "行政职务", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "postal", - "in": "query", - "description": "邮编", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "returnDate", - "in": "query", - "description": "归国日期", - "required": false, - "style": "form", - "schema": { - "type": "string", - "format": "date" - } - }, - { - "name": "roles[0].admin", - "in": "query", - "description": "是否是管理员", - "required": false, - "style": "form", - "schema": { - "type": "boolean" - } - }, - { - "name": "roles[0].createTime", - "in": "query", - "description": "创建时间", - "required": false, - "style": "form", - "schema": { - "type": "string", - "format": "date-time" - } - }, - { - "name": "roles[0].createUserId", - "in": "query", - "description": "创建人", - "required": false, - "style": "form", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "roles[0].delFlag", - "in": "query", - "description": "是否删除 2:删除 0:未删除", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "roles[0].deleteTime", - "in": "query", - "description": "删除时间", - "required": false, - "style": "form", - "schema": { - "type": "string", - "format": "date-time" - } - }, - { - "name": "roles[0].deleteUserId", - "in": "query", - "description": "删除者", - "required": false, - "style": "form", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "roles[0].enable", - "in": "query", - "description": "是否启用", - "required": false, - "style": "form", - "schema": { - "type": "boolean" - } - }, - { - "name": "roles[0].label", - "in": "query", - "description": "显示文本", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "roles[0].lastModifyTime", - "in": "query", - "description": "最后更新时间", - "required": false, - "style": "form", - "schema": { - "type": "string", - "format": "date-time" - } - }, - { - "name": "roles[0].lastModifyUserId", - "in": "query", - "description": "最后更新者", - "required": false, - "style": "form", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "roles[0].name", - "in": "query", - "description": "角色名称", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "roles[0].params", - "in": "query", - "description": "请求参数", - "required": false, - "style": "form", - "schema": { - "type": "object" - } - }, - { - "name": "roles[0].roleId", - "in": "query", - "description": "角色ID", - "required": false, - "style": "form", - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "sex", - "in": "query", - "description": "性别", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "sign", - "in": "query", - "description": "个人签名图片id", - "required": false, - "style": "form", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "title", - "in": "query", - "description": "技术职称", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - }, - { - "name": "unitId", - "in": "query", - "description": "工作单位ID", - "required": false, - "style": "form", - "schema": { - "type": "integer", - "format": "int32" - } - }, - { - "name": "username", - "in": "query", - "description": "用户名", - "required": false, - "style": "form", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/分页响应对象«User»" - } - } - } - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/api/user/{id}": { - "get": { - "tags": [ - "UserController" - ], - "summary": "根据用户编号获取详细信息", - "operationId": "getInfoUsingGET_1", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "用户ID", - "required": true, - "style": "simple", - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ResultVO«Map«string,object»»" - } - } - } - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/api/user/{userIds}": { - "delete": { - "tags": [ - "UserController" - ], - "summary": "删除用户", - "operationId": "removeUsingDELETE", - "parameters": [ - { - "name": "userIds", - "in": "path", - "description": "角色ID串", - "required": true, - "style": "simple", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserReq" - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/ResultVO«Void»" - } - } - } - }, - "204": { - "description": "No Content" - }, - "401": { - "description": "Unauthorized" - }, - "403": { - "description": "Forbidden" - } - } - } - } - }, - "components": { - "schemas": { - "DictCountry对象": { - "title": "DictCountry对象", - "type": "object", - "properties": { - "enable": { - "type": "boolean", - "description": "是否启用", - "example": false - }, - "id": { - "type": "integer", - "description": "ID", - "format": "int32" - }, - "label": { - "type": "string", - "description": "显示文本" - }, - "sort": { - "type": "integer", - "description": "排序", - "format": "int32" - }, - "value": { - "type": "string", - "description": "符号" - } - }, - "description": "职位" - }, - "DictEvaluateLevel对象": { - "title": "DictEvaluateLevel对象", - "type": "object", - "properties": { - "enable": { - "type": "boolean", - "description": "是否启用", - "example": false - }, - "id": { - "type": "integer", - "description": "ID", - "format": "int32" - }, - "label": { - "type": "string", - "description": "显示文本" - }, - "sort": { - "type": "integer", - "description": "排序", - "format": "int32" - }, - "value": { - "type": "string", - "description": "符号" - } - }, - "description": "职位" - }, - "GrantedAuthority": { - "title": "GrantedAuthority", - "type": "object", - "properties": { - "authority": { - "type": "string" - } - } - }, - "ListResultVO«MajorCategory»": { - "title": "ListResultVO«MajorCategory»", - "type": "object", - "properties": { - "current": { - "type": "integer", - "description": "当前页码", - "format": "int64" - }, - "list": { - "type": "array", - "description": "列表数据", - "items": { - "$ref": "#/components/schemas/MajorCategory" - } - }, - "pageSize": { - "type": "integer", - "description": "每页记录数", - "format": "int64" - }, - "total": { - "type": "integer", - "description": "记录总数", - "format": "int64" - } - }, - "description": "分页列表数据" - }, - "MajorCategory": { - "title": "MajorCategory", - "type": "object", - "properties": { - "children": { - "type": "array", - "description": "下级分类列表", - "items": { - "$ref": "#/components/schemas/MajorCategory" - } - }, - "code": { - "type": "string", - "description": "分类编码" - }, - "createTime": { - "type": "string", - "description": "创建时间", - "format": "date-time" - }, - "createUserId": { - "type": "integer", - "description": "创建人", - "format": "int32" - }, - "deleteUserId": { - "type": "integer", - "description": "删除者", - "format": "int32" - }, - "enable": { - "type": "boolean", - "description": "是否启用", - "example": false - }, - "id": { - "type": "integer", - "description": "分类ID", - "format": "int32" - }, - "lastModifyTime": { - "type": "string", - "description": "最后更新时间", - "format": "date-time" - }, - "lastModifyUserId": { - "type": "integer", - "description": "最后更新者", - "format": "int32" - }, - "level": { - "type": "integer", - "description": "分类级别", - "format": "int32" - }, - "name": { - "type": "string", - "description": "分类名称" - }, - "params": { - "type": "object", - "description": "请求参数" - }, - "parentId": { - "type": "integer", - "description": "上级分类ID", - "format": "int32" - }, - "remark": { - "type": "string", - "description": "备注" - } - }, - "description": "专业分类" - }, - "ProjectEntity对象": { - "title": "ProjectEntity对象", - "type": "object", - "properties": { - "achieveCode": { - "type": "string", - "description": "成果登记号" - }, - "appDate": { - "type": "string", - "description": "应用日期", - "format": "date" - }, - "appField": { - "type": "string", - "description": "应用领域 A、民用 B、军民通用\t" - }, - "applicationSummary": { - "type": "string", - "description": "应用推广情况概述" - }, - "awardType": { - "type": "integer", - "description": "奖励类别\tAPP_TECH:应用技术成果 \tBASIC_TECH:基础技术成果 \tEXTENSION:推广成果 \tTECH_BASIC:技术基础成果 \tSOFT_TECH:软科学成果 \tOTHER:其他", - "format": "int32" - }, - "chnName": { - "type": "string", - "description": "项目中文名" - }, - "createTime": { - "type": "string", - "description": "创建时间", - "format": "date-time" - }, - "createUserId": { - "type": "integer", - "description": "创建者", - "format": "int32" - }, - "deleteTime": { - "type": "string", - "description": "删除时间", - "format": "date" - }, - "deleteUserId": { - "type": "integer", - "description": "删除者", - "format": "int32" - }, - "departmentId": { - "type": "integer", - "description": "主管部门", - "format": "int32" - }, - "directBenifit": { - "type": "string", - "description": "直接经济效益概述" - }, - "engName": { - "type": "string", - "description": "项目英文名" - }, - "evaluateDate": { - "type": "string", - "description": "评价日期", - "format": "date" - }, - "evaluateLevel": { - "type": "integer", - "description": "评价水平", - "format": "int32" - }, - "evaluateOrgId": { - "type": "integer", - "description": "成果评价机构", - "format": "int32" - }, - "id": { - "type": "integer", - "description": "项目ID", - "format": "int64" - }, - "indirectBenifit": { - "type": "string", - "description": "间接经济效益概述" - }, - "intellectualProperty": { - "type": "integer", - "description": "授权的其他知识产权", - "format": "int32" - }, - "inventionPatent": { - "type": "integer", - "description": "授权发明专利", - "format": "int32" - }, - "lastModifyTime": { - "type": "string", - "description": "最后修改时间", - "format": "date-time" - }, - "lastModifyUserId": { - "type": "integer", - "description": "最后修改者", - "format": "int32" - }, - "majorCategoryId": { - "type": "integer", - "description": "专业分类", - "format": "int32" - }, - "plan": { - "type": "string", - "description": "计划名称" - }, - "planCode": { - "type": "string", - "description": "计划编号" - }, - "projectEndTime": { - "type": "string", - "description": "项目终止日期", - "format": "date" - }, - "projectInfo": { - "type": "string", - "description": "项目简介" - }, - "projectStartTime": { - "type": "string", - "description": "项目开始日期", - "format": "date" - }, - "recomendLevel": { - "type": "integer", - "description": "推荐等级", - "format": "int32" - }, - "recomendUnitId": { - "type": "integer", - "description": "推荐单位", - "format": "int32" - }, - "recommendDate": { - "type": "string", - "description": "推荐日期", - "format": "date" - }, - "remark": { - "type": "string", - "description": "项目备注" - }, - "responsePersonId": { - "type": "integer", - "description": "主要完成人", - "format": "int64" - }, - "secretLevel": { - "type": "integer", - "description": "密级", - "format": "int32" - }, - "socialBenifit": { - "type": "string", - "description": "社会效益概述" - }, - "status": { - "type": "integer", - "description": "项目状态 {0:保存;1:提交;2::已分配专家;3:专家评审通过;4:已通过;6:专家评审未通过;7:打回修改;8:已拒绝;-1:无效项目", - "format": "int32" - }, - "taskSource": { - "type": "string", - "description": "任务来源 A、国家计划 B、省部级计划、集团公司计划 C、计划外\t" - }, - "techInnovation": { - "type": "string", - "description": "技术创新" - }, - "techLimitation": { - "type": "string", - "description": "技术局限性" - }, - "theme": { - "type": "string", - "description": "主题词" - }, - "thirdEvaluation": { - "type": "string", - "description": "第三方评价描述" - }, - "unitContribution": { - "type": "string", - "description": "完成单位贡献情况阐述" - }, - "unitId": { - "type": "integer", - "description": "主要完成单位", - "format": "int32" - } - } - }, - "ResponseEntity": { - "title": "ResponseEntity", - "type": "object", - "properties": { - "body": { - "type": "object" - }, - "statusCode": { - "type": "string", - "enum": [ - "ACCEPTED", - "ALREADY_REPORTED", - "BAD_GATEWAY", - "BAD_REQUEST", - "BANDWIDTH_LIMIT_EXCEEDED", - "CHECKPOINT", - "CONFLICT", - "CONTINUE", - "CREATED", - "DESTINATION_LOCKED", - "EXPECTATION_FAILED", - "FAILED_DEPENDENCY", - "FORBIDDEN", - "FOUND", - "GATEWAY_TIMEOUT", - "GONE", - "HTTP_VERSION_NOT_SUPPORTED", - "IM_USED", - "INSUFFICIENT_SPACE_ON_RESOURCE", - "INSUFFICIENT_STORAGE", - "INTERNAL_SERVER_ERROR", - "I_AM_A_TEAPOT", - "LENGTH_REQUIRED", - "LOCKED", - "LOOP_DETECTED", - "METHOD_FAILURE", - "METHOD_NOT_ALLOWED", - "MOVED_PERMANENTLY", - "MOVED_TEMPORARILY", - "MULTIPLE_CHOICES", - "MULTI_STATUS", - "NETWORK_AUTHENTICATION_REQUIRED", - "NON_AUTHORITATIVE_INFORMATION", - "NOT_ACCEPTABLE", - "NOT_EXTENDED", - "NOT_FOUND", - "NOT_IMPLEMENTED", - "NOT_MODIFIED", - "NO_CONTENT", - "OK", - "PARTIAL_CONTENT", - "PAYLOAD_TOO_LARGE", - "PAYMENT_REQUIRED", - "PERMANENT_REDIRECT", - "PRECONDITION_FAILED", - "PRECONDITION_REQUIRED", - "PROCESSING", - "PROXY_AUTHENTICATION_REQUIRED", - "REQUESTED_RANGE_NOT_SATISFIABLE", - "REQUEST_ENTITY_TOO_LARGE", - "REQUEST_HEADER_FIELDS_TOO_LARGE", - "REQUEST_TIMEOUT", - "REQUEST_URI_TOO_LONG", - "RESET_CONTENT", - "SEE_OTHER", - "SERVICE_UNAVAILABLE", - "SWITCHING_PROTOCOLS", - "TEMPORARY_REDIRECT", - "TOO_EARLY", - "TOO_MANY_REQUESTS", - "UNAUTHORIZED", - "UNAVAILABLE_FOR_LEGAL_REASONS", - "UNPROCESSABLE_ENTITY", - "UNSUPPORTED_MEDIA_TYPE", - "UPGRADE_REQUIRED", - "URI_TOO_LONG", - "USE_PROXY", - "VARIANT_ALSO_NEGOTIATES" - ] - }, - "statusCodeValue": { - "type": "integer", - "format": "int32" - } - } - }, - "ResultVO«List«DictCountry对象»»": { - "title": "ResultVO«List«DictCountry对象»»", - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "data": { - "type": "object", - "description": "数据" - }, - "msg": { - "type": "string" - } - }, - "description": "返回信息" - }, - "ResultVO«List«DictEvaluateLevel对象»»": { - "title": "ResultVO«List«DictEvaluateLevel对象»»", - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "data": { - "type": "object", - "description": "数据" - }, - "msg": { - "type": "string" - } - }, - "description": "返回信息" - }, - "ResultVO«List«路由配置信息»»": { - "title": "ResultVO«List«路由配置信息»»", - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "data": { - "type": "object", - "description": "数据" - }, - "msg": { - "type": "string" - } - }, - "description": "返回信息" - }, - "ResultVO«Map«string,object»»": { - "title": "ResultVO«Map«string,object»»", - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "data": { - "type": "object", - "description": "数据" - }, - "msg": { - "type": "string" - } - }, - "description": "返回信息" - }, - "ResultVO«SysResourceEntity对象»": { - "title": "ResultVO«SysResourceEntity对象»", - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "data": { - "type": "object", - "description": "数据" - }, - "msg": { - "type": "string" - } - }, - "description": "返回信息" - }, - "ResultVO«Void»": { - "title": "ResultVO«Void»", - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "msg": { - "type": "string" - } - }, - "description": "返回信息" - }, - "ResultVO«object»": { - "title": "ResultVO«object»", - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32" - }, - "data": { - "type": "object", - "description": "数据" - }, - "msg": { - "type": "string" - } - }, - "description": "返回信息" - }, - "Role": { - "title": "Role", - "type": "object", - "properties": { - "createTime": { - "type": "string", - "description": "创建时间", - "format": "date-time" - }, - "createUserId": { - "type": "integer", - "description": "创建人", - "format": "int32" - }, - "delFlag": { - "type": "string", - "description": "是否删除 2:删除 0:未删除" - }, - "deleteUserId": { - "type": "integer", - "description": "删除者", - "format": "int32" - }, - "enable": { - "type": "boolean", - "description": "是否启用", - "example": false - }, - "label": { - "type": "string", - "description": "显示文本" - }, - "lastModifyTime": { - "type": "string", - "description": "最后更新时间", - "format": "date-time" - }, - "lastModifyUserId": { - "type": "integer", - "description": "最后更新者", - "format": "int32" - }, - "name": { - "type": "string", - "description": "角色名称" - }, - "params": { - "type": "object", - "description": "请求参数" - }, - "roleId": { - "type": "integer", - "description": "角色ID", - "format": "int64" - } - }, - "description": "角色" - }, - "SysResourceEntity对象": { - "title": "SysResourceEntity对象", - "type": "object", - "properties": { - "createTime": { - "type": "string", - "description": "创建时间", - "format": "date-time" - }, - "createUserId": { - "type": "integer", - "description": "创建者", - "format": "int32" - }, - "deleteTime": { - "type": "string", - "description": "删除时间", - "format": "date" - }, - "deleteUserId": { - "type": "integer", - "description": "删除者", - "format": "int32" - }, - "enable": { - "type": "boolean", - "description": "启用与否", - "example": false - }, - "id": { - "type": "integer", - "description": "资源ID", - "format": "int32" - }, - "label": { - "type": "string", - "description": "显示文本" - }, - "lastModifyTime": { - "type": "string", - "description": "最后修改时间", - "format": "date-time" - }, - "lastModifyUserId": { - "type": "integer", - "description": "最后修改者", - "format": "int32" - }, - "method": { - "type": "string", - "description": "请求方法" - }, - "name": { - "type": "string", - "description": "资源名称" - }, - "parentId": { - "type": "integer", - "description": "上级资源ID", - "format": "int32" - }, - "permitAll": { - "type": "boolean", - "description": "允许所有访问", - "example": false - }, - "sort": { - "type": "integer", - "description": "排序", - "format": "int32" - }, - "url": { - "type": "string", - "description": "路径" - } - } - }, - "TreeNode": { - "title": "TreeNode", - "type": "object", - "properties": { - "children": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TreeNode" - } - }, - "id": { - "type": "integer", - "format": "int32" - }, - "parentId": { - "type": "integer", - "format": "int32" - } - } - }, - "UserDetails": { - "title": "UserDetails", - "type": "object", - "properties": { - "accountNonExpired": { - "type": "boolean" - }, - "accountNonLocked": { - "type": "boolean" - }, - "authorities": { - "type": "array", - "items": { - "$ref": "#/components/schemas/GrantedAuthority" - } - }, - "credentialsNonExpired": { - "type": "boolean" - }, - "enabled": { - "type": "boolean" - }, - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - } - }, - "UserInfoVO": { - "title": "UserInfoVO", - "type": "object", - "properties": { - "address": { - "type": "string", - "description": "地址信息" - }, - "enable": { - "type": "boolean", - "description": "是否启用", - "example": false - }, - "fullName": { - "type": "string", - "description": "用户真实名" - }, - "id": { - "type": "integer", - "description": "用户id", - "format": "int32" - }, - "loginType": { - "type": "string", - "description": "登录方式" - }, - "phone": { - "type": "string", - "description": "手机号" - }, - "roles": { - "type": "array", - "description": "角色列表", - "items": { - "$ref": "#/components/schemas/Role" - } - }, - "unitId": { - "type": "integer", - "description": "所属单位", - "format": "int32" - }, - "username": { - "type": "string", - "description": "用户名" - } - }, - "description": "用户信息" - }, - "UserQuery": { - "title": "UserQuery", - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "姓名" - }, - "phone": { - "type": "string", - "description": "手机号" - } - }, - "description": "用户信息查询" - }, - "UserReq": { - "title": "UserReq", - "type": "object", - "properties": { - "address": { - "type": "string", - "description": "通讯地址" - }, - "birthArea": { - "type": "string", - "description": "出生地" - }, - "birthDate": { - "type": "string", - "description": "出生日期", - "format": "date" - }, - "college": { - "type": "string", - "description": "毕业学校" - }, - "country": { - "type": "string", - "description": "国籍" - }, - "createTime": { - "type": "string", - "description": "创建时间", - "format": "date-time" - }, - "createUserId": { - "type": "integer", - "description": "创建人", - "format": "int32" - }, - "degree": { - "type": "string", - "description": "最高学位{0:博士;1:硕士;2:学士;3:专科;4:其他}" - }, - "delFlag": { - "type": "string", - "description": "是否删除 2:删除 0:未删除" - }, - "deleteUserId": { - "type": "integer", - "description": "删除者", - "format": "int32" - }, - "deptId": { - "type": "integer", - "description": "二级单位(部门)ID", - "format": "int32" - }, - "education": { - "type": "string", - "description": "最高学历{0:研究生;1:本科;2:专科;3:其他}" - }, - "email": { - "type": "string", - "description": "电子邮箱" - }, - "enable": { - "type": "string", - "description": "是否启用 1:启用 0:禁用" - }, - "fullName": { - "type": "string", - "description": "真实姓名" - }, - "graduateDate": { - "type": "string", - "description": "毕业日期", - "format": "date" - }, - "id": { - "type": "integer", - "description": "用户ID", - "format": "int64" - }, - "idCard": { - "type": "string", - "description": "身份证号" - }, - "isAbroad": { - "type": "boolean", - "description": "是否归国人员", - "example": false - }, - "lastModifyTime": { - "type": "string", - "description": "最后更新时间", - "format": "date-time" - }, - "lastModifyUserId": { - "type": "integer", - "description": "最后更新者", - "format": "int32" - }, - "major": { - "type": "string", - "description": "所学专业" - }, - "mobilePhone": { - "type": "string", - "description": "手机号" - }, - "nation": { - "type": "string", - "description": "民族" - }, - "nickname": { - "type": "string", - "description": "用户昵称" - }, - "officePhone": { - "type": "string", - "description": "办公电话" - }, - "params": { - "type": "object", - "description": "请求参数" - }, - "party": { - "type": "string", - "description": "党派" - }, - "password": { - "type": "string", - "description": "密码" - }, - "position": { - "type": "string", - "description": "行政职务" - }, - "postal": { - "type": "string", - "description": "邮编" - }, - "returnDate": { - "type": "string", - "description": "归国日期", - "format": "date" - }, - "roles": { - "type": "array", - "description": "角色列表", - "items": { - "$ref": "#/components/schemas/Role" - } - }, - "sex": { - "type": "string", - "description": "性别" - }, - "sign": { - "type": "integer", - "description": "个人签名图片id", - "format": "int32" - }, - "title": { - "type": "string", - "description": "技术职称" - }, - "unitId": { - "type": "integer", - "description": "工作单位ID", - "format": "int32" - }, - "username": { - "type": "string", - "description": "用户名" - } - }, - "description": "用户" - }, - "UserRes": { - "title": "UserRes", - "type": "object", - "properties": { - "address": { - "type": "string", - "description": "通讯地址" - }, - "admin": { - "type": "boolean", - "description": "是否超级管理员", - "example": false - }, - "authorities": { - "type": "array", - "items": { - "$ref": "#/components/schemas/GrantedAuthority" - } - }, - "birthArea": { - "type": "string", - "description": "出生地" - }, - "birthDate": { - "type": "string", - "description": "出生日期", - "format": "date" - }, - "college": { - "type": "string", - "description": "毕业学校" - }, - "country": { - "type": "string", - "description": "国籍" - }, - "createTime": { - "type": "string", - "description": "创建时间", - "format": "date-time" - }, - "createUserId": { - "type": "integer", - "description": "创建人", - "format": "int32" - }, - "degree": { - "type": "string", - "description": "最高学位{0:博士;1:硕士;2:学士;3:专科;4:其他}" - }, - "delFlag": { - "type": "string", - "description": "是否删除 2:删除 0:未删除" - }, - "deleteUserId": { - "type": "integer", - "description": "删除者", - "format": "int32" - }, - "deptId": { - "type": "integer", - "description": "二级单位(部门)ID", - "format": "int32" - }, - "education": { - "type": "string", - "description": "最高学历{0:研究生;1:本科;2:专科;3:其他}" - }, - "email": { - "type": "string", - "description": "电子邮箱" - }, - "enable": { - "type": "string", - "description": "是否启用 1:启用 0:禁用" - }, - "enabled": { - "type": "boolean" - }, - "fullName": { - "type": "string", - "description": "真实姓名" - }, - "graduateDate": { - "type": "string", - "description": "毕业日期", - "format": "date" - }, - "id": { - "type": "integer", - "description": "用户ID", - "format": "int64" - }, - "idCard": { - "type": "string", - "description": "身份证号" - }, - "isAbroad": { - "type": "boolean", - "description": "是否归国人员", - "example": false - }, - "lastModifyTime": { - "type": "string", - "description": "最后更新时间", - "format": "date-time" - }, - "lastModifyUserId": { - "type": "integer", - "description": "最后更新者", - "format": "int32" - }, - "major": { - "type": "string", - "description": "所学专业" - }, - "mobilePhone": { - "type": "string", - "description": "手机号" - }, - "nation": { - "type": "string", - "description": "民族" - }, - "nickname": { - "type": "string", - "description": "用户昵称" - }, - "officePhone": { - "type": "string", - "description": "办公电话" - }, - "params": { - "type": "object", - "description": "请求参数" - }, - "party": { - "type": "string", - "description": "党派" - }, - "password": { - "type": "string", - "description": "密码" - }, - "position": { - "type": "string", - "description": "行政职务" - }, - "postal": { - "type": "string", - "description": "邮编" - }, - "returnDate": { - "type": "string", - "description": "归国日期", - "format": "date" - }, - "roles": { - "type": "array", - "description": "角色列表", - "items": { - "$ref": "#/components/schemas/Role" - } - }, - "sex": { - "type": "string", - "description": "性别" - }, - "sign": { - "type": "integer", - "description": "个人签名图片id", - "format": "int32" - }, - "title": { - "type": "string", - "description": "技术职称" - }, - "unitId": { - "type": "integer", - "description": "工作单位ID", - "format": "int32" - }, - "username": { - "type": "string", - "description": "用户名" - } - }, - "description": "用户" - }, - "分页响应对象«User»": { - "title": "分页响应对象«User»", - "type": "object", - "properties": { - "code": { - "type": "integer", - "description": "消息状态码", - "format": "int32" - }, - "current": { - "type": "integer", - "description": "当前页码", - "format": "int64" - }, - "data": { - "type": "array", - "description": "列表数据", - "items": { - "$ref": "#/components/schemas/UserRes" - } - }, - "msg": { - "type": "string", - "description": "消息内容" - }, - "pageSize": { - "type": "integer", - "description": "单页记录数", - "format": "int64" - }, - "success": { - "type": "boolean", - "description": "success", - "example": false - }, - "total": { - "type": "integer", - "description": "总记录数", - "format": "int64" - } - } - }, - "路由配置信息": { - "title": "路由配置信息", - "type": "object", - "properties": { - "alwaysShow": { - "type": "boolean", - "description": "当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面", - "example": false - }, - "children": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TreeNode" - } - }, - "component": { - "type": "string", - "description": "组件地址" - }, - "hidden": { - "type": "boolean", - "description": "是否隐藏路由,当设置 true 的时候该路由不会再侧边栏出现", - "example": false - }, - "id": { - "type": "integer", - "format": "int32" - }, - "name": { - "type": "string", - "description": "路由名字" - }, - "parentId": { - "type": "integer", - "format": "int32" - }, - "path": { - "type": "string", - "description": "路由地址" - }, - "query": { - "type": "string", - "description": "路由参数:如 {\"id\": 1, \"name\": \"ry\"}" - }, - "redirect": { - "type": "string", - "description": "重定向地址,当设置 noRedirect 的时候该路由在面包屑导航中不可被点击" - } - } - } - } - } -} \ No newline at end of file diff --git a/awardBE/src/main/resources/mapper/MenuMapper.xml b/awardBE/src/main/resources/mapper/MenuMapper.xml index 5a5d8b4..109cf70 100644 --- a/awardBE/src/main/resources/mapper/MenuMapper.xml +++ b/awardBE/src/main/resources/mapper/MenuMapper.xml @@ -2,12 +2,6 @@ + \ No newline at end of file diff --git a/awardBE/src/test/java/edu/ncst/award/TestSystemMenuService.java b/awardBE/src/test/java/edu/ncst/award/TestSystemMenuService.java index aa93b1c..98c9b2b 100644 --- a/awardBE/src/test/java/edu/ncst/award/TestSystemMenuService.java +++ b/awardBE/src/test/java/edu/ncst/award/TestSystemMenuService.java @@ -1,21 +1,11 @@ package edu.ncst.award; -import cn.hutool.json.JSONUtil; -import edu.ncst.award.common.util.treeUtils.TreeNode; -import edu.ncst.award.common.util.treeUtils.TreeNodeConfig; -import edu.ncst.award.common.util.treeUtils.TreeNodeMap; -import edu.ncst.award.common.util.treeUtils.TreeUtils; -import edu.ncst.award.model.system.Menu; import edu.ncst.award.service.impl.system.MenuServiceImpl; -import lombok.RequiredArgsConstructor; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.security.core.context.SecurityContextHolder; -import java.util.ArrayList; -import java.util.List; - @SpringBootTest public class TestSystemMenuService { int i = 1; @@ -25,30 +15,8 @@ public class TestSystemMenuService { @Test - public void getCurrentUser(){ + public void getCurrentUser() { SecurityContextHolder.getContext().getAuthentication().getDetails(); } - - @Test - public void buildMenus() { - menuService.buildMenus(menuService.getAllMenusById(0)); - } - - @Test - public void buildByList() { - List menus = menuService.getAllMenusById(0); - TreeNodeConfig treeNodeConfig = new TreeNodeConfig(); - treeNodeConfig.setIdKey("nihao"); -// List treeNodes = TreeUtils.build(0, menus, (menu, treeNode) -> { -// treeNode.setId(menu.getId()); -// treeNode.setParentId(menu.getParentId()); -// treeNode.setName(menu.getName()); -// treeNode.extra("nihao","woshi yly"); -// }); -// System.out.println(JSONUtil.formatJsonStr(JSONUtil.toJsonStr(treeNodes))); - System.out.println("你哦安徽"); - } - - }