优化教师信息查询,新增用户角色静态常量类RoleConstants

master
Alan 4 months ago
parent c1da086cb0
commit 5c99839296
  1. 7
      src/main/java/com/teaching/backend/constant/RoleConstants.java
  2. 2
      src/main/java/com/teaching/backend/controller/umsAdmin/UmsUserController.java
  3. 4
      src/main/java/com/teaching/backend/model/vo/courses/TeacherInfVO.java
  4. 2
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  5. 17
      src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsUserServiceImpl.java

@ -0,0 +1,7 @@
package com.teaching.backend.constant;
public class RoleConstants {
public static final Long TEACHER_ROLE = 1L;
public static final Long STUDENT_ROLE = 2L;
public static final Long ADMIN_ROLE = 3L;
}

@ -179,7 +179,7 @@ public class UmsUserController {
return CommonResult.failed();
}
@ApiOperation("获取教师信息列表,关联教师的username和name")
@ApiOperation("获取教师信息列表,关联教师的userId和name")
@GetMapping("/get_teacherinf_list")
public BaseResponse<List<TeacherInfVO>> getTeacherInfList(){
List<TeacherInfVO> teacherInfVO = umsUserService.getTeacherInfList();

@ -12,8 +12,8 @@ public class TeacherInfVO {
/**
* 教师username
*/
@ApiModelProperty("教师username")
private String username;
@ApiModelProperty("教师userId")
private Long userId;
/**
* 课程封面
*/

@ -42,6 +42,8 @@ import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import static com.teaching.backend.constant.RoleConstants.TEACHER_ROLE;
/**
* <p>
* 服务实现类

@ -42,6 +42,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static com.teaching.backend.constant.RoleConstants.TEACHER_ROLE;
@Service
@Slf4j
public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> implements UmsUserService {
@ -377,18 +379,17 @@ public class UmsUserServiceImpl extends ServiceImpl<UmsUserMapper, UmsUser> impl
}
throw new UsernameNotFoundException("用户名或密码错误");
}
@Override
public List<TeacherInfVO> getTeacherInfList() {
List<UmsTeacher> umsTeachers = umsTeacherMapper.selectList(new LambdaQueryWrapper<UmsTeacher>());
List<UmsUser> umsUserTeachers = query().eq("role_id", TEACHER_ROLE).list();
TeacherInfVO teacherInfVO = null;
List<TeacherInfVO> teacherInfList = new ArrayList<>();;
for (UmsTeacher umsTeacher : umsTeachers) {
List<TeacherInfVO> teacherInfList = new ArrayList<>();
for (UmsUser umsUserTeacher : umsUserTeachers) {
teacherInfVO = new TeacherInfVO();
UmsUser umsUser = umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
.eq(UmsUser::getId, umsTeacher.getUserId()));
teacherInfVO.setName(umsTeacher.getName());
teacherInfVO.setUsername(umsUser.getUsername());
String teacherName = umsTeacherMapper.selectOne(new LambdaQueryWrapper<>(UmsTeacher.class)
.eq(UmsTeacher::getUserId, umsUserTeacher.getId())).getName();
teacherInfVO.setName(teacherName);
teacherInfVO.setUserId(umsUserTeacher.getId());
teacherInfList.add(teacherInfVO);
}
return teacherInfList;

Loading…
Cancel
Save