diff --git a/hxhq-api/hxhq-api-system/src/main/java/com/hxhq/system/api/model/LoginUser.java b/hxhq-api/hxhq-api-system/src/main/java/com/hxhq/system/api/model/LoginUser.java index 62c1f6f..b8d1a8b 100644 --- a/hxhq-api/hxhq-api-system/src/main/java/com/hxhq/system/api/model/LoginUser.java +++ b/hxhq-api/hxhq-api-system/src/main/java/com/hxhq/system/api/model/LoginUser.java @@ -58,6 +58,11 @@ public class LoginUser implements Serializable */ private SysUser sysUser; + /** + * 默认url + */ + private String defaultUrl; + public String getToken() { return token; @@ -147,4 +152,12 @@ public class LoginUser implements Serializable { this.sysUser = sysUser; } + + public String getDefaultUrl() { + return defaultUrl; + } + + public void setDefaultUrl(String defaultUrl) { + this.defaultUrl = defaultUrl; + } } diff --git a/hxhq-common/hxhq-common-security/src/main/java/com/hxhq/common/security/service/TokenService.java b/hxhq-common/hxhq-common-security/src/main/java/com/hxhq/common/security/service/TokenService.java index ef306ae..f0b2925 100644 --- a/hxhq-common/hxhq-common-security/src/main/java/com/hxhq/common/security/service/TokenService.java +++ b/hxhq-common/hxhq-common-security/src/main/java/com/hxhq/common/security/service/TokenService.java @@ -74,6 +74,7 @@ public class TokenService Map rspMap = new HashMap(16); rspMap.put("access_token", JwtUtils.createToken(claimsMap)); rspMap.put("expires_in", TOKEN_EXPIRE_TIME); + rspMap.put("defaultUrl", loginUser.getDefaultUrl()); return rspMap; } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java index 2f0aaa9..a0ce4a9 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java @@ -16,7 +16,7 @@ import com.hxhq.business.service.IStudyService; import com.hxhq.common.core.utils.ServletUtils; import com.hxhq.system.dto.UserExportDto; import com.hxhq.system.form.UserSaveForm; -import com.hxhq.system.service.ISysConfigService; +import com.hxhq.system.service.*; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; @@ -47,11 +47,6 @@ import com.hxhq.system.api.domain.SysDept; import com.hxhq.system.api.domain.SysRole; import com.hxhq.system.api.domain.SysUser; import com.hxhq.system.api.model.LoginUser; -import com.hxhq.system.service.ISysDeptService; -import com.hxhq.system.service.ISysPermissionService; -import com.hxhq.system.service.ISysPostService; -import com.hxhq.system.service.ISysRoleService; -import com.hxhq.system.service.ISysUserService; /** * 用户信息 @@ -84,6 +79,8 @@ public class SysUserController extends BaseController private TokenService tokenService; @Autowired private IStudyService studyService; + @Autowired + private ISysMenuService sysMenuService; /** * 获取用户列表 @@ -174,6 +171,7 @@ public class SysUserController extends BaseController sysUserVo.setSysUser(sysUser); sysUserVo.setRoles(roles); sysUserVo.setPermissions(permissions); + sysUserVo.setDefaultUrl(sysMenuService.getUserFirstUrl(sysUser.getUserId())); return R.ok(sysUserVo); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysMenuService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysMenuService.java index 28121fa..93d79a9 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysMenuService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysMenuService.java @@ -142,4 +142,11 @@ public interface ISysMenuService * @return 结果 */ public boolean checkMenuNameUnique(SysMenu menu); + + /** + * 获取第一个子菜单 + * @param userId + * @return + */ + public String getUserFirstUrl(Long userId); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysMenuServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysMenuServiceImpl.java index 24e3b2e..0851c13 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysMenuServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysMenuServiceImpl.java @@ -623,5 +623,22 @@ public class SysMenuServiceImpl implements ISysMenuService return log; } + @Override + public String getUserFirstUrl(Long userId) { + List menus = selectMenuTreeByUserId(userId); + List urlList = new ArrayList<>(); + urlList = getChildUrl(urlList,menus); + return urlList.size()>0 ? String.join("/",urlList) : "/user/work"; + } + List getChildUrl(List urlList,List menus){ + if(menus!=null && menus.size()>0){ + SysMenu firstMenu = menus.get(0); + urlList.add(firstMenu.getPath()); + if(!firstMenu.getMenuType().equals("C")){ + urlList = getChildUrl(urlList,firstMenu.getChildren()); + } + } + return urlList; + } }