学员全部课程api增加分类过滤

This commit is contained in:
none
2023-05-08 10:41:55 +08:00
parent 4c4046dff5
commit 2bb9e7491b
5 changed files with 51 additions and 7 deletions

View File

@@ -77,8 +77,12 @@ public interface CourseService extends IService<Course> {
List<Course> getOpenCoursesAndShow(Integer limit);
List<Course> getOpenCoursesAndShow(Integer limit, Integer categoryId);
List<Course> getDepCoursesAndShow(List<Integer> depIds);
List<Course> getDepCoursesAndShow(List<Integer> depIds, Integer categoryId);
Map<Integer, List<Integer>> getCategoryIdsGroup(List<Integer> courseIds);
Map<Integer, List<Integer>> getDepIdsGroup(List<Integer> courseIds);

View File

@@ -209,7 +209,41 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
@Override
public List<Course> getOpenCoursesAndShow(Integer limit) {
return getBaseMapper().openCoursesAndShow(limit);
return getBaseMapper().openCoursesAndShow(limit, 0);
}
@Override
public List<Course> getOpenCoursesAndShow(Integer limit, Integer categoryId) {
return getBaseMapper().openCoursesAndShow(limit, categoryId);
}
@Override
public List<Course> getDepCoursesAndShow(List<Integer> depIds, Integer categoryId) {
if (depIds == null || depIds.size() == 0) {
return new ArrayList<>();
}
List<Integer> courseIds = courseDepartmentService.getCourseIdsByDepIds(depIds);
if (courseIds == null || courseIds.size() == 0) {
return new ArrayList<>();
}
if (categoryId != null && categoryId > 0) {
List<Integer> tmpCourseIds =
courseCategoryService.getCourseIdsByCategoryIds(
new ArrayList<>() {
{
add(categoryId);
}
});
if (tmpCourseIds == null || tmpCourseIds.size() == 0) {
return new ArrayList<>();
}
// 取交集
courseIds.retainAll(tmpCourseIds);
}
if (courseIds.size() == 0) {
return new ArrayList<>();
}
return list(query().getWrapper().in("id", courseIds).eq("is_show", 1));
}
@Override