diff --git a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java index 243ead4..c05c549 100644 --- a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java +++ b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java @@ -66,7 +66,7 @@ public class CoursesController { @ApiOperation("查询课程列表") - @ValidateParams({"username"}) + @ValidateParams({"username","roleId"}) @GetMapping("/page") public BaseResponse> getCourses(CourseQuery courseQuery){ PageDTO coursesList = coursesService.queryCourses(courseQuery); diff --git a/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsTeacherMapper.java b/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsTeacherMapper.java index a5d85b8..04e99e9 100644 --- a/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsTeacherMapper.java +++ b/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsTeacherMapper.java @@ -14,5 +14,5 @@ import com.teaching.backend.model.entity.umsAdmin.UmsTeacher; public interface UmsTeacherMapper extends BaseMapper { boolean updateTeacherInfo(UmsTeacher umsTeacher); - UmsTeacher selectByUserId(Integer userId); + UmsTeacher selectByUserId(Long userId); } diff --git a/src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsTeacher.java b/src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsTeacher.java index 0a185d0..59d04a8 100644 --- a/src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsTeacher.java +++ b/src/main/java/com/teaching/backend/model/entity/umsAdmin/UmsTeacher.java @@ -44,7 +44,7 @@ public class UmsTeacher implements Serializable { private String education; //学位 - private String academicDegree; + private String degree; //职称 private String professionalTitle; @@ -59,7 +59,7 @@ public class UmsTeacher implements Serializable { private String politicalStatus; //user_id - private Integer userId; + private Long userId; } diff --git a/src/main/java/com/teaching/backend/model/query/CourseQuery.java b/src/main/java/com/teaching/backend/model/query/CourseQuery.java index 13dbc8b..b5d0393 100644 --- a/src/main/java/com/teaching/backend/model/query/CourseQuery.java +++ b/src/main/java/com/teaching/backend/model/query/CourseQuery.java @@ -15,6 +15,9 @@ public class CourseQuery extends PageQuery { @ApiModelProperty(value = "用户的username",required = true) private String username; + @ApiModelProperty(value = "用户的角色id",required = true) + private Long roleId; + @ApiModelProperty("课程任课教师") private String teacher; 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 94243f2..531cf8b 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 @@ -158,21 +158,25 @@ public class CoursesServiceImpl extends ServiceImpl impl // throw new BusinessException(ErrorCode.USERNAME_NOT_EXIT); // } - UmsUser umsAdmin = umsUserMapper.selectOne(new LambdaQueryWrapper() - .eq(UmsUser::getUsername, username)); - UmsAdminRoleRelation umsAdminRoleRelation = umsAdminRoleRelationMapper.selectOne(new LambdaQueryWrapper() - .eq(UmsAdminRoleRelation::getAdminId, umsAdmin.getId())); +// UmsUser umsUser = umsUserMapper.selectOne(new LambdaQueryWrapper() +// .eq(UmsUser::getUsername, username)); +// UmsAdminRoleRelation umsAdminRoleRelation = umsAdminRoleRelationMapper.selectOne(new LambdaQueryWrapper() +// .eq(UmsAdminRoleRelation::getAdminId, umsUser.getId())); - int roleId = Math.toIntExact(umsAdminRoleRelation.getRoleId()); +// int roleId = Math.toIntExact(umsAdminRoleRelation.getRoleId()); + int roleId = Math.toIntExact(courseQuery.getRoleId()); PageDTO coursesVOPageDTO; switch (roleId) { + //教师--也是管理员--但是只能看自己的课程,有搜索功能 case 1: coursesVOPageDTO = queryForTeacher(courseQuery, username); break; + //学生 case 2: coursesVOPageDTO = queryForStudent(courseQuery, username); break; + //这个对应的是以后的院系管理员 这个才能看别的教师的课程 case 3: coursesVOPageDTO = queryForAdmin(courseQuery); break; @@ -233,7 +237,7 @@ public class CoursesServiceImpl extends ServiceImpl impl // System.out.println(umsAdminTea); UmsTeacher umsTeacher = umsTeacherMapper.selectOne(new LambdaQueryWrapper() .eq(UmsTeacher::getUserId, umsUserTea.getId())); - System.out.println(umsTeacher); +// System.out.println(umsTeacher); if (umsTeacher == null){ throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); } 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 b5b7ca8..62732d8 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 @@ -375,10 +375,10 @@ public class UmsUserServiceImpl extends ServiceImpl impl List teacherInfList = new ArrayList<>();; for (UmsTeacher umsTeacher : umsTeachers) { teacherInfVO = new TeacherInfVO(); - UmsUser umsAdmin = umsUserMapper.selectOne(new LambdaQueryWrapper() + UmsUser umsUser = umsUserMapper.selectOne(new LambdaQueryWrapper() .eq(UmsUser::getId, umsTeacher.getUserId())); teacherInfVO.setName(umsTeacher.getName()); - teacherInfVO.setUsername(umsAdmin.getUsername()); + teacherInfVO.setUsername(umsUser.getUsername()); teacherInfList.add(teacherInfVO); } return teacherInfList; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 4dac536..8dcd1f6 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -12,6 +12,9 @@ spring: matching-strategy: ant_path_matcher datasource: driver-class-name: com.mysql.cj.jdbc.Driver +# url: jdbc:mysql://127.0.0.1:3306/teaching_db +# username: root +# password: root url: jdbc:mysql://rm-bp189rd5595301145do.mysql.rds.aliyuncs.com:3306/teaching_db username: root123 password: Zjh@111111