App游客时正常展示页面
This commit is contained in:
+10
-1
@@ -87,13 +87,22 @@ public class AppMenuApplicationService {
|
|||||||
if (StringUtils.isBlank(appMenuDO.getAppPackage()) || StringUtils.isBlank(appMenuDO.getAppLocationCode())){
|
if (StringUtils.isBlank(appMenuDO.getAppPackage()) || StringUtils.isBlank(appMenuDO.getAppLocationCode())){
|
||||||
throw new ServiceException("app包名或app位置不能为空");
|
throw new ServiceException("app包名或app位置不能为空");
|
||||||
}
|
}
|
||||||
|
// 判断是否为已登录用户(小程序未登录访问时,getLoginUser/getUserPo 可能为空)
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
boolean isLogin = loginUser != null && loginUser.getUserPo() != null;
|
||||||
|
if (isLogin) {
|
||||||
if (appMenuDO.getUserId() == null){
|
if (appMenuDO.getUserId() == null){
|
||||||
appMenuDO.setUserId(SecurityUtils.getUserId());
|
appMenuDO.setUserId(SecurityUtils.getUserId());
|
||||||
}
|
}
|
||||||
if (appMenuDO.getTopOrganizationId() == null){
|
if (appMenuDO.getTopOrganizationId() == null){
|
||||||
appMenuDO.setTopOrganizationId(SecurityUtils.getLoginUser().getUserPo().getTopOrganizationId());
|
appMenuDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// 未登录(游客):userId/topOrganizationId 保持为空,走公共菜单查询,返回该 app 全部菜单
|
||||||
List<MenuPo> menuPos = appMenuDomainService.queryMenuListByApp(appMenuDO);
|
List<MenuPo> menuPos = appMenuDomainService.queryMenuListByApp(appMenuDO);
|
||||||
|
if (!isLogin) {
|
||||||
|
return menuPos != null ? menuPos : new ArrayList<>();
|
||||||
|
}
|
||||||
// 获取用户角色 → 查角色APP菜单权限 → 取交集去重
|
// 获取用户角色 → 查角色APP菜单权限 → 取交集去重
|
||||||
List<UserRoleMenuPO> userRoles = userFeignService.selectUserRoles(appMenuDO.getUserId());
|
List<UserRoleMenuPO> userRoles = userFeignService.selectUserRoles(appMenuDO.getUserId());
|
||||||
menuPos = filterMenuByUserRole(menuPos, userRoles);
|
menuPos = filterMenuByUserRole(menuPos, userRoles);
|
||||||
|
|||||||
@@ -18,18 +18,18 @@ spring:
|
|||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
discovery:
|
discovery:
|
||||||
server-addr: 127.0.0.1:8848
|
# server-addr: 127.0.0.1:8848
|
||||||
# server-addr: 10.33.0.129:6010
|
# server-addr: 10.33.0.129:6010
|
||||||
# server-addr: 10.102.192.31:6848
|
server-addr: 10.102.192.30:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
#线上正式环境
|
#线上正式环境
|
||||||
# server-addr: 10.33.0.129:6010
|
# server-addr: 10.33.0.129:6010
|
||||||
#
|
#
|
||||||
config:
|
config:
|
||||||
server-addr: 127.0.0.1:8848
|
# server-addr: 127.0.0.1:8848
|
||||||
# server-addr: 10.33.0.129:6010
|
# server-addr: 10.33.0.129:6010
|
||||||
# server-addr: 10.102.192.31:6848
|
server-addr: 10.102.192.30:6848
|
||||||
username: nacos
|
username: nacos
|
||||||
password: manhuoda@2023
|
password: manhuoda@2023
|
||||||
#线上正式环境
|
#线上正式环境
|
||||||
|
|||||||
@@ -99,7 +99,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
and me.menu_show = 1
|
and me.menu_show = 1
|
||||||
and co.app_package = #{appPackage}
|
and co.app_package = #{appPackage}
|
||||||
and me.app_location_code = #{appLocationCode}
|
and me.app_location_code = #{appLocationCode}
|
||||||
|
<!-- 未登录(游客)时不传组织,返回该 app 全部公共菜单 -->
|
||||||
|
<if test="topOrganizationId != null">
|
||||||
and me.top_organization_id = #{topOrganizationId}
|
and me.top_organization_id = #{topOrganizationId}
|
||||||
|
</if>
|
||||||
order by me.menu_sort,me.create_time asc
|
order by me.menu_sort,me.create_time asc
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user