【新增】学生账号,判断是否为考试模式,如果是考试模式,菜单返回null,代表只有考试模式

This commit is contained in:
任维炳
2025-04-24 14:54:21 +08:00
parent 27c636ce9c
commit 6635acb723

View File

@@ -7,6 +7,8 @@ import pc.exam.pp.framework.common.enums.UserTypeEnum;
import pc.exam.pp.framework.common.pojo.CommonResult;
import pc.exam.pp.framework.security.config.SecurityProperties;
import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils;
import pc.exam.pp.module.infra.dal.dataobject.config.ConfigDO;
import pc.exam.pp.module.infra.service.config.ConfigService;
import pc.exam.pp.module.system.controller.admin.auth.vo.*;
import pc.exam.pp.module.system.convert.auth.AuthConvert;
import pc.exam.pp.module.system.dal.dataobject.permission.MenuDO;
@@ -66,6 +68,9 @@ public class AuthController {
@Resource
private SecurityProperties securityProperties;
@Resource
private ConfigService configService;
@PostMapping("/login")
@PermitAll
@Operation(summary = "使用账号密码登录")
@@ -110,7 +115,6 @@ public class AuthController {
if (user == null) {
return success(null);
}
// 1.2 获得角色列表
Set<Long> roleIds = permissionService.getUserRoleIdListByUserId(getLoginUserId());
if (CollUtil.isEmpty(roleIds)) {
@@ -122,8 +126,19 @@ public class AuthController {
// 1.3 获得菜单列表
Set<Long> menuIds = permissionService.getRoleMenuListByRoleId(convertSet(roles, RoleDO::getId));
List<MenuDO> menuList = menuService.getMenuList(menuIds);
menuList = menuService.filterDisableMenus(menuList);
// 1.4 判断是否为学生,并且是否为考试模式
if (user.getUserType().equals("2")) {
// 获取考试模式数据
ConfigDO config = configService.getConfigByKey("student_login");
if (config.getValue().equals("0")) {
// 考试模式菜单返回为空
menuList = null;
} else {
menuList = menuService.filterDisableMenus(menuList);
}
} else {
menuList = menuService.filterDisableMenus(menuList);
}
// 2. 拼接结果返回
return success(AuthConvert.INSTANCE.convert(user, roles, menuList));
}