mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-10-26 22:51:36 +08:00
1.根据部门ID获取所有父级部门的课程
后管-学员--学习课程列表、学员-部门学习进度及导出 pc-课程首页 2.根据分类ID获取所有子分类的课程 pc-课程首页
This commit is contained in:
@@ -36,5 +36,5 @@ public interface CourseMapper extends BaseMapper<Course> {
|
||||
|
||||
Long paginateCount(CoursePaginateFiler filer);
|
||||
|
||||
List<Course> openCoursesAndShow(Integer limit, Integer categoryId);
|
||||
List<Course> openCoursesAndShow(Integer limit, List<Integer> categoryIds);
|
||||
}
|
||||
|
||||
@@ -80,11 +80,11 @@ public interface CourseService extends IService<Course> {
|
||||
|
||||
List<Course> getOpenCoursesAndShow(Integer limit);
|
||||
|
||||
List<Course> getOpenCoursesAndShow(Integer limit, Integer categoryId);
|
||||
List<Course> getOpenCoursesAndShow(Integer limit, List<Integer> categoryIds);
|
||||
|
||||
List<Course> getDepCoursesAndShow(List<Integer> depIds);
|
||||
|
||||
List<Course> getDepCoursesAndShow(List<Integer> depIds, Integer categoryId);
|
||||
List<Course> getDepCoursesAndShow(List<Integer> depIds, List<Integer> categoryIds);
|
||||
|
||||
Map<Integer, List<Integer>> getCategoryIdsGroup(List<Integer> courseIds);
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ package xyz.playedu.course.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -24,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import xyz.playedu.common.exception.NotFoundException;
|
||||
import xyz.playedu.common.types.paginate.CoursePaginateFiler;
|
||||
import xyz.playedu.common.types.paginate.PaginationResult;
|
||||
import xyz.playedu.common.util.StringUtil;
|
||||
import xyz.playedu.course.domain.Course;
|
||||
import xyz.playedu.course.domain.CourseCategory;
|
||||
import xyz.playedu.course.domain.CourseDepartment;
|
||||
@@ -217,36 +220,36 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
||||
|
||||
@Override
|
||||
public List<Course> getOpenCoursesAndShow(Integer limit) {
|
||||
return getBaseMapper().openCoursesAndShow(limit, 0);
|
||||
return getBaseMapper().openCoursesAndShow(limit, new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Course> getOpenCoursesAndShow(Integer limit, Integer categoryId) {
|
||||
return getBaseMapper().openCoursesAndShow(limit, categoryId);
|
||||
public List<Course> getOpenCoursesAndShow(Integer limit, List<Integer> categoryIds) {
|
||||
return getBaseMapper().openCoursesAndShow(limit, categoryIds);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public List<Course> getDepCoursesAndShow(List<Integer> depIds, Integer categoryId) {
|
||||
if (depIds == null || depIds.size() == 0) {
|
||||
public List<Course> getDepCoursesAndShow(List<Integer> depIds, List<Integer> categoryIds) {
|
||||
if (StringUtil.isEmpty(depIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// 获取部门课程ID
|
||||
List<Integer> courseIds = courseDepartmentService.getCourseIdsByDepIds(depIds);
|
||||
if (courseIds == null || courseIds.size() == 0) {
|
||||
if (StringUtil.isEmpty(courseIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
if (categoryId != null && categoryId > 0) {
|
||||
List<Integer> tmpCourseIds =
|
||||
courseCategoryService.getCourseIdsByCategoryIds(
|
||||
new ArrayList<>() {
|
||||
{
|
||||
add(categoryId);
|
||||
}
|
||||
});
|
||||
if (tmpCourseIds == null || tmpCourseIds.size() == 0) {
|
||||
|
||||
if (StringUtil.isNotEmpty(categoryIds)) {
|
||||
// 获取分类课程ID
|
||||
List<Integer> catCourseIds =
|
||||
courseCategoryService.getCourseIdsByCategoryIds(categoryIds);
|
||||
if (StringUtil.isEmpty(catCourseIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
courseIds = courseIds.stream().filter(tmpCourseIds::contains).toList();
|
||||
if (courseIds.size() == 0) {
|
||||
// 求课程ID交集
|
||||
courseIds = courseIds.stream().filter(catCourseIds::contains).toList();
|
||||
if (StringUtil.isEmpty(courseIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -255,11 +258,12 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
||||
|
||||
@Override
|
||||
public List<Course> getDepCoursesAndShow(List<Integer> depIds) {
|
||||
if (depIds == null || depIds.size() == 0) {
|
||||
if (StringUtil.isEmpty(depIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// 获取部门课程ID
|
||||
List<Integer> courseIds = courseDepartmentService.getCourseIdsByDepIds(depIds);
|
||||
if (courseIds == null || courseIds.size() == 0) {
|
||||
if (StringUtil.isEmpty(courseIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return list(query().getWrapper().in("id", courseIds).eq("is_show", 1));
|
||||
|
||||
@@ -192,13 +192,15 @@
|
||||
SELECT `courses`.*
|
||||
FROM `courses`
|
||||
LEFT JOIN `course_department` ON `course_department`.`course_id` = `courses`.`id`
|
||||
<if test="categoryId != null and categoryId > 0">
|
||||
<if test="categoryIds != null and !categoryIds.isEmpty()">
|
||||
INNER JOIN `resource_course_category` ON `resource_course_category`.`course_id` = `courses`.`id`
|
||||
</if>
|
||||
WHERE `course_department`.`course_id` IS NULL
|
||||
AND `courses`.`is_show` = 1
|
||||
<if test="categoryId != null and categoryId > 0">
|
||||
AND `resource_course_category`.`category_id` = #{categoryId}
|
||||
<if test="categoryIds != null and !categoryIds.isEmpty()">
|
||||
AND `resource_course_category`.`category_id` IN (<foreach collection="categoryIds" item="tmpId"
|
||||
separator=",">
|
||||
#{tmpId}</foreach>)
|
||||
</if>
|
||||
LIMIT #{limit}
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user