From 5c998392963fb5f3e5b9fc02a95f6334ec8ae4bd Mon Sep 17 00:00:00 2001 From: Alan <3052806735@qq.com> Date: Fri, 26 Jul 2024 17:30:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=95=99=E5=B8=88=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=9F=A5=E8=AF=A2=EF=BC=8C=E6=96=B0=E5=A2=9E=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=A7=92=E8=89=B2=E9=9D=99=E6=80=81=E5=B8=B8=E9=87=8F?= =?UTF-8?q?=E7=B1=BBRoleConstants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/constant/RoleConstants.java | 7 +++++++ .../controller/umsAdmin/UmsUserController.java | 2 +- .../backend/model/vo/courses/TeacherInfVO.java | 4 ++-- .../impl/courses/CoursesServiceImpl.java | 2 ++ .../umsAdmin/impl/UmsUserServiceImpl.java | 17 +++++++++-------- 5 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/teaching/backend/constant/RoleConstants.java diff --git a/src/main/java/com/teaching/backend/constant/RoleConstants.java b/src/main/java/com/teaching/backend/constant/RoleConstants.java new file mode 100644 index 0000000..4e393bc --- /dev/null +++ b/src/main/java/com/teaching/backend/constant/RoleConstants.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; +} diff --git a/src/main/java/com/teaching/backend/controller/umsAdmin/UmsUserController.java b/src/main/java/com/teaching/backend/controller/umsAdmin/UmsUserController.java index 7a46257..0db9cb4 100644 --- a/src/main/java/com/teaching/backend/controller/umsAdmin/UmsUserController.java +++ b/src/main/java/com/teaching/backend/controller/umsAdmin/UmsUserController.java @@ -179,7 +179,7 @@ public class UmsUserController { return CommonResult.failed(); } - @ApiOperation("获取教师信息列表,关联教师的username和name") + @ApiOperation("获取教师信息列表,关联教师的userId和name") @GetMapping("/get_teacherinf_list") public BaseResponse> getTeacherInfList(){ List teacherInfVO = umsUserService.getTeacherInfList(); diff --git a/src/main/java/com/teaching/backend/model/vo/courses/TeacherInfVO.java b/src/main/java/com/teaching/backend/model/vo/courses/TeacherInfVO.java index 66a317e..a99a24f 100644 --- a/src/main/java/com/teaching/backend/model/vo/courses/TeacherInfVO.java +++ b/src/main/java/com/teaching/backend/model/vo/courses/TeacherInfVO.java @@ -12,8 +12,8 @@ public class TeacherInfVO { /** * 教师username */ - @ApiModelProperty("教师username") - private String username; + @ApiModelProperty("教师userId") + private Long userId; /** * 课程封面 */ diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java index ebc2af3..7dfebdb 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java @@ -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; + /** *

* 服务实现类 diff --git a/src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsUserServiceImpl.java b/src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsUserServiceImpl.java index 410378a..2c496f8 100644 --- a/src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsUserServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/umsAdmin/impl/UmsUserServiceImpl.java @@ -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 implements UmsUserService { @@ -377,18 +379,17 @@ public class UmsUserServiceImpl extends ServiceImpl impl } throw new UsernameNotFoundException("用户名或密码错误"); } - @Override public List getTeacherInfList() { - List umsTeachers = umsTeacherMapper.selectList(new LambdaQueryWrapper()); + List umsUserTeachers = query().eq("role_id", TEACHER_ROLE).list(); TeacherInfVO teacherInfVO = null; - List teacherInfList = new ArrayList<>();; - for (UmsTeacher umsTeacher : umsTeachers) { + List teacherInfList = new ArrayList<>(); + for (UmsUser umsUserTeacher : umsUserTeachers) { teacherInfVO = new TeacherInfVO(); - UmsUser umsUser = umsUserMapper.selectOne(new LambdaQueryWrapper() - .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;