|
|
@ -13,6 +13,7 @@ import com.teaching.backend.exception.BusinessException; |
|
|
|
import com.teaching.backend.mapper.chapter.ChapterMapper; |
|
|
|
import com.teaching.backend.mapper.chapter.ChapterMapper; |
|
|
|
import com.teaching.backend.mapper.courses.*; |
|
|
|
import com.teaching.backend.mapper.courses.*; |
|
|
|
import com.teaching.backend.mapper.records.LearningRecordsMapper; |
|
|
|
import com.teaching.backend.mapper.records.LearningRecordsMapper; |
|
|
|
|
|
|
|
import com.teaching.backend.mapper.umsAdmin.UmsStudentMapper; |
|
|
|
import com.teaching.backend.mapper.umsAdmin.UmsTeacherMapper; |
|
|
|
import com.teaching.backend.mapper.umsAdmin.UmsTeacherMapper; |
|
|
|
import com.teaching.backend.mapper.umsAdmin.UmsUserMapper; |
|
|
|
import com.teaching.backend.mapper.umsAdmin.UmsUserMapper; |
|
|
|
import com.teaching.backend.model.dto.courses.CoursesDTO; |
|
|
|
import com.teaching.backend.model.dto.courses.CoursesDTO; |
|
|
@ -20,11 +21,13 @@ import com.teaching.backend.model.dto.courses.PageDTO; |
|
|
|
import com.teaching.backend.model.entity.chapter.Chapter; |
|
|
|
import com.teaching.backend.model.entity.chapter.Chapter; |
|
|
|
import com.teaching.backend.model.entity.courses.*; |
|
|
|
import com.teaching.backend.model.entity.courses.*; |
|
|
|
import com.teaching.backend.model.entity.records.LearningRecords; |
|
|
|
import com.teaching.backend.model.entity.records.LearningRecords; |
|
|
|
|
|
|
|
import com.teaching.backend.model.entity.umsAdmin.UmsStudent; |
|
|
|
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher; |
|
|
|
import com.teaching.backend.model.entity.umsAdmin.UmsTeacher; |
|
|
|
import com.teaching.backend.model.entity.umsAdmin.UmsUser; |
|
|
|
import com.teaching.backend.model.entity.umsAdmin.UmsUser; |
|
|
|
import com.teaching.backend.model.query.CourseQuery; |
|
|
|
import com.teaching.backend.model.query.CourseQuery; |
|
|
|
import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO; |
|
|
|
import com.teaching.backend.model.vo.courses.CourseObjectivesTreeVO; |
|
|
|
import com.teaching.backend.model.vo.courses.CoursesVO; |
|
|
|
import com.teaching.backend.model.vo.courses.CoursesVO; |
|
|
|
|
|
|
|
import com.teaching.backend.model.vo.umsAdmin.UmsStudentVO; |
|
|
|
import com.teaching.backend.service.courses.ICoursesService; |
|
|
|
import com.teaching.backend.service.courses.ICoursesService; |
|
|
|
import com.teaching.backend.utils.CourseCode; |
|
|
|
import com.teaching.backend.utils.CourseCode; |
|
|
|
import com.teaching.backend.utils.knowGraph.AddNeoKnowByCourse; |
|
|
|
import com.teaching.backend.utils.knowGraph.AddNeoKnowByCourse; |
|
|
@ -43,6 +46,8 @@ import java.time.LocalDateTime; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.teaching.backend.constant.RoleConstants.TEACHER_ROLE; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* 服务实现类 |
|
|
|
* 服务实现类 |
|
|
@ -76,6 +81,8 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
UmsTeacherMapper umsTeacherMapper; |
|
|
|
UmsTeacherMapper umsTeacherMapper; |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
|
|
|
|
UmsStudentMapper umsStudentMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
StudentCoursesMapper studentCoursesMapper; |
|
|
|
StudentCoursesMapper studentCoursesMapper; |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
ObjectiveContentKnowMapper objectiveContentKnowMapper; |
|
|
|
ObjectiveContentKnowMapper objectiveContentKnowMapper; |
|
|
@ -146,10 +153,14 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public PageDTO<CoursesVO> queryCourses(CourseQuery courseQuery) { |
|
|
|
public PageDTO<CoursesVO> queryCourses(CourseQuery courseQuery) { |
|
|
|
int roleId = Integer.parseInt(umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>() |
|
|
|
// int roleId = Integer.parseInt(umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
|
|
|
|
.eq(UmsUser::getUsername, courseQuery.getUsername())).getRoleId()); |
|
|
|
// .eq(UmsUser::getUsername, courseQuery.getUsername())).getRoleId());
|
|
|
|
|
|
|
|
UmsUser umsUser = umsUserMapper.selectById(courseQuery.getUserId()); |
|
|
|
|
|
|
|
if (umsUser == null){ |
|
|
|
|
|
|
|
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int roleId = Integer.parseInt(umsUser.getRoleId()); |
|
|
|
PageDTO<CoursesVO> coursesVOPageDTO; |
|
|
|
PageDTO<CoursesVO> coursesVOPageDTO; |
|
|
|
|
|
|
|
|
|
|
|
switch (roleId) { |
|
|
|
switch (roleId) { |
|
|
|
//教师--也是管理员--但是只能看自己的课程,有搜索功能
|
|
|
|
//教师--也是管理员--但是只能看自己的课程,有搜索功能
|
|
|
|
case 1: |
|
|
|
case 1: |
|
|
@ -174,7 +185,7 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl |
|
|
|
Page<Courses> page = courseQuery.toMpPageDefaultSortByCreateTime(); |
|
|
|
Page<Courses> page = courseQuery.toMpPageDefaultSortByCreateTime(); |
|
|
|
Page<Courses> p = lambdaQuery() |
|
|
|
Page<Courses> p = lambdaQuery() |
|
|
|
.like(courseQuery.getName() != null, Courses::getName, courseQuery.getName()) |
|
|
|
.like(courseQuery.getName() != null, Courses::getName, courseQuery.getName()) |
|
|
|
.apply("FIND_IN_SET({0}, teacher)", courseQuery.getUsername()) |
|
|
|
.apply("FIND_IN_SET({0}, teacher)", courseQuery.getUserId()) |
|
|
|
.eq(courseQuery.getCategory() != null && !courseQuery.getCategory().isEmpty(), Courses::getCategory, courseQuery.getCategory()) |
|
|
|
.eq(courseQuery.getCategory() != null && !courseQuery.getCategory().isEmpty(), Courses::getCategory, courseQuery.getCategory()) |
|
|
|
.eq(courseQuery.getNature() != null && !courseQuery.getNature().isEmpty(), Courses::getNature, courseQuery.getNature()) |
|
|
|
.eq(courseQuery.getNature() != null && !courseQuery.getNature().isEmpty(), Courses::getNature, courseQuery.getNature()) |
|
|
|
.eq(courseQuery.getAssessmenttype() != null &&!courseQuery.getAssessmenttype().isEmpty(), Courses::getAssessmenttype, courseQuery.getAssessmenttype()) |
|
|
|
.eq(courseQuery.getAssessmenttype() != null &&!courseQuery.getAssessmenttype().isEmpty(), Courses::getAssessmenttype, courseQuery.getAssessmenttype()) |
|
|
@ -184,11 +195,10 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl |
|
|
|
|
|
|
|
|
|
|
|
private PageDTO<CoursesVO> queryForStudent(CourseQuery courseQuery) { |
|
|
|
private PageDTO<CoursesVO> queryForStudent(CourseQuery courseQuery) { |
|
|
|
List<StudentCourses> studentCourses = studentCoursesMapper.selectList(new LambdaQueryWrapper<StudentCourses>() |
|
|
|
List<StudentCourses> studentCourses = studentCoursesMapper.selectList(new LambdaQueryWrapper<StudentCourses>() |
|
|
|
.eq(StudentCourses::getStudent, courseQuery.getUsername())); |
|
|
|
.eq(StudentCourses::getStudent, courseQuery.getUserId())); |
|
|
|
List<String> coursesList = studentCourses.stream() |
|
|
|
List<String> coursesList = studentCourses.stream() |
|
|
|
.map(StudentCourses::getCourse) |
|
|
|
.map(StudentCourses::getCourse) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
Page<Courses> page = courseQuery.toMpPageDefaultSortByCreateTime(); |
|
|
|
Page<Courses> page = courseQuery.toMpPageDefaultSortByCreateTime(); |
|
|
|
Page<Courses> p = lambdaQuery() |
|
|
|
Page<Courses> p = lambdaQuery() |
|
|
|
.like(courseQuery.getName() != null, Courses::getName, courseQuery.getName()) |
|
|
|
.like(courseQuery.getName() != null, Courses::getName, courseQuery.getName()) |
|
|
@ -196,7 +206,6 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl |
|
|
|
.page(page); |
|
|
|
.page(page); |
|
|
|
return PageDTO.of(p, CoursesVO.class); |
|
|
|
return PageDTO.of(p, CoursesVO.class); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private PageDTO<CoursesVO> queryForAdmin(CourseQuery courseQuery) { |
|
|
|
private PageDTO<CoursesVO> queryForAdmin(CourseQuery courseQuery) { |
|
|
|
Page<Courses> page = courseQuery.toMpPageDefaultSortByCreateTime(); |
|
|
|
Page<Courses> page = courseQuery.toMpPageDefaultSortByCreateTime(); |
|
|
|
Page<Courses> p = lambdaQuery() |
|
|
|
Page<Courses> p = lambdaQuery() |
|
|
@ -212,17 +221,16 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl |
|
|
|
private void populateTeacherNames(List<CoursesVO> courseList) { |
|
|
|
private void populateTeacherNames(List<CoursesVO> courseList) { |
|
|
|
for (CoursesVO coursesVO : courseList) { |
|
|
|
for (CoursesVO coursesVO : courseList) { |
|
|
|
List<String> teacherNameList = new ArrayList<>(); |
|
|
|
List<String> teacherNameList = new ArrayList<>(); |
|
|
|
String[] teacherIds = coursesVO.getTeacher().split(","); |
|
|
|
String[] teacherUserIds = coursesVO.getTeacher().split(","); |
|
|
|
for (String teacherId : teacherIds) { |
|
|
|
for (String teacherId : teacherUserIds) { |
|
|
|
UmsUser umsUserTea = umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>() |
|
|
|
// UmsUser umsUserTea = umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
|
|
|
|
.eq(UmsUser::getUsername, teacherId)); |
|
|
|
// .eq(UmsUser::getUsername, teacherId));
|
|
|
|
if (umsUserTea == null) { |
|
|
|
// if (umsUserTea == null) {
|
|
|
|
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); |
|
|
|
// throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
// System.out.println(umsAdminTea);
|
|
|
|
// System.out.println(umsAdminTea);
|
|
|
|
UmsTeacher umsTeacher = umsTeacherMapper.selectOne(new LambdaQueryWrapper<UmsTeacher>() |
|
|
|
UmsTeacher umsTeacher = umsTeacherMapper.selectOne(new LambdaQueryWrapper<UmsTeacher>() |
|
|
|
.eq(UmsTeacher::getUserId, umsUserTea.getId())); |
|
|
|
.eq(UmsTeacher::getUserId,teacherId)); |
|
|
|
// System.out.println(umsTeacher);
|
|
|
|
|
|
|
|
if (umsTeacher == null){ |
|
|
|
if (umsTeacher == null){ |
|
|
|
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); |
|
|
|
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS); |
|
|
|
} |
|
|
|
} |
|
|
@ -332,6 +340,22 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public HashSet<UmsStudent> queryStudentList(CourseQuery courseQuery) { |
|
|
|
|
|
|
|
PageDTO<CoursesVO> queryCourses = queryCourses(courseQuery); |
|
|
|
|
|
|
|
List<CoursesVO> coursesList = queryCourses.getList(); |
|
|
|
|
|
|
|
List<String> courseIds = coursesList.stream().map(CoursesVO::getId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
HashSet<UmsStudent> studentNameList = new HashSet<>(); |
|
|
|
|
|
|
|
for (String courseId : courseIds) { |
|
|
|
|
|
|
|
List<StudentCourses> studentUsernames = studentCoursesMapper.selectBatchSomeStudent(courseId); |
|
|
|
|
|
|
|
for (StudentCourses studentUsername : studentUsernames) { |
|
|
|
|
|
|
|
UmsStudent umsStudent = umsStudentMapper.selectByUserId(Integer.valueOf(studentUsername.getStudent())); |
|
|
|
|
|
|
|
studentNameList.add(umsStudent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return studentNameList; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<CoursesVO> getPagePageSize(int page, int pageSize) { |
|
|
|
public List<CoursesVO> getPagePageSize(int page, int pageSize) { |
|
|
|
int startIndex = (page-1) * pageSize; |
|
|
|
int startIndex = (page-1) * pageSize; |
|
|
|