【新增】 通过教师获取教师能够管理得学生

This commit is contained in:
DESKTOP-9ERGOBP\任维炳
2025-11-24 16:24:00 +08:00
parent 2356f3e1aa
commit 1ca1f9c44f
4 changed files with 60 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
package pc.exam.pp.module.system.controller.admin.user.vo.user;
import com.alibaba.excel.annotation.ExcelIgnore;
import pc.exam.pp.framework.excel.core.annotations.DictFormat;
import pc.exam.pp.framework.excel.core.convert.DictConvert;
import pc.exam.pp.module.system.enums.DictTypeConstants;
@@ -38,6 +39,9 @@ public class UserRespVO{
@ExcelProperty("班级名称")
private String className;
@Schema(description = "班级ID")
private Long classId;
@Schema(description = "备注", example = "我是一个用户")
private String remark;

View File

@@ -68,6 +68,18 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
return selectList(AdminUserDO::getDeptId, deptIds);
}
default List<AdminUserDO> selectAllStudents() {
return selectList(new LambdaQueryWrapperX<AdminUserDO>()
.eq(AdminUserDO::getUserType, "2"));
}
default List<AdminUserDO> selectListByClassId(Long classId) {
return selectList(new LambdaQueryWrapperX<AdminUserDO>()
.eq(AdminUserDO::getClassId, classId)
.eq(AdminUserDO::getStatus, 0)
.eq(AdminUserDO::getDeleted, false));
}
List<UserRespVO> selectUserByIdList(@Param("id") Long id);
String selectOneById(Long id);

View File

@@ -288,4 +288,11 @@ public interface AdminUserService {
* @return 全部信息集合
*/
List<SpecialtyQueryVo> getSpeciatListByTenantId();
/**
* 通过教师获取学生信息
*
* @return 学生信息集合
*/
List<UserRespVO> getStudentByTeacherId();
}

View File

@@ -1208,6 +1208,43 @@ public class AdminUserServiceImpl implements AdminUserService {
return specialtyQueryVos;
}
@Override
public List<UserRespVO> getStudentByTeacherId() {
List<UserRespVO> userRespVOS = new ArrayList<>();
// 1、获取登录账号的ID
Long userId = SecurityFrameworkUtils.getLoginUserId();
AdminUserDO adminUserDO = userMapper.selectById(userId);
// 2、判断是管理员还是教师
// 2-1、管理员可以查看全部的学生
if (adminUserDO.getUserType().equals("0")) {
// 查询所有学生
List<AdminUserDO> adminUserDOList = userMapper.selectAllStudents();
List<UserRespVO> userResp = BeanUtils.toBean(adminUserDOList, UserRespVO.class);
for (UserRespVO userRespVO : userResp) {
ClassDO classDO = classMapper.selectById(userRespVO.getClassId());
userRespVO.setClassName(classDO.getName());
userRespVOS.add(userRespVO);
}
}
if (adminUserDO.getUserType().equals("1")) {
// 2-2、教师只能查看自己班级的学生
Set<Long> classIds = adminUserDO.getClassIds();
// 通过班级查询所有学生
for (Long classId : classIds) {
ClassDO classDO = classMapper.selectById(classId);
if (classDO != null) {
List<AdminUserDO> adminUserDOS = userMapper.selectListByClassId(classId);
List<UserRespVO> userResp = BeanUtils.toBean(adminUserDOS, UserRespVO.class);
for (UserRespVO userRespVO : userResp) {
userRespVO.setClassName(classDO.getName());
userRespVOS.add(userRespVO);
}
}
}
}
return userRespVOS;
}
/**
* 对密码进行加密
*