mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-07-26 03:49:31 +08:00
学员全部课程api增加分类过滤
This commit is contained in:
parent
4c4046dff5
commit
2bb9e7491b
@ -106,6 +106,8 @@ public class UserController {
|
|||||||
return JsonResponse.error("请选择部门");
|
return JsonResponse.error("请选择部门");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Integer categoryId = MapUtils.getInteger(params, "category_id");
|
||||||
|
|
||||||
List<Integer> userJoinDepIds = userService.getDepIdsByUserId(FCtx.getId());
|
List<Integer> userJoinDepIds = userService.getDepIdsByUserId(FCtx.getId());
|
||||||
if (userJoinDepIds == null) {
|
if (userJoinDepIds == null) {
|
||||||
return JsonResponse.error("当前学员未加入任何部门");
|
return JsonResponse.error("当前学员未加入任何部门");
|
||||||
@ -126,9 +128,10 @@ public class UserController {
|
|||||||
{
|
{
|
||||||
add(depId);
|
add(depId);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
categoryId);
|
||||||
// 全部部门课
|
// 全部部门课
|
||||||
List<Course> openCourses = courseService.getOpenCoursesAndShow(500);
|
List<Course> openCourses = courseService.getOpenCoursesAndShow(500, categoryId);
|
||||||
// 汇总到一个list中
|
// 汇总到一个list中
|
||||||
if (depCourses != null && depCourses.size() > 0) {
|
if (depCourses != null && depCourses.size() > 0) {
|
||||||
courses.addAll(depCourses);
|
courses.addAll(depCourses);
|
||||||
|
@ -36,5 +36,5 @@ public interface CourseMapper extends BaseMapper<Course> {
|
|||||||
|
|
||||||
Long paginateCount(CoursePaginateFiler filer);
|
Long paginateCount(CoursePaginateFiler filer);
|
||||||
|
|
||||||
List<Course> openCoursesAndShow(Integer limit);
|
List<Course> openCoursesAndShow(Integer limit, Integer categoryId);
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,12 @@ public interface CourseService extends IService<Course> {
|
|||||||
|
|
||||||
List<Course> getOpenCoursesAndShow(Integer limit);
|
List<Course> getOpenCoursesAndShow(Integer limit);
|
||||||
|
|
||||||
|
List<Course> getOpenCoursesAndShow(Integer limit, Integer categoryId);
|
||||||
|
|
||||||
List<Course> getDepCoursesAndShow(List<Integer> depIds);
|
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>> getCategoryIdsGroup(List<Integer> courseIds);
|
||||||
|
|
||||||
Map<Integer, List<Integer>> getDepIdsGroup(List<Integer> courseIds);
|
Map<Integer, List<Integer>> getDepIdsGroup(List<Integer> courseIds);
|
||||||
|
@ -209,7 +209,41 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Course> getOpenCoursesAndShow(Integer limit) {
|
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
|
@Override
|
||||||
|
@ -171,9 +171,12 @@
|
|||||||
<select id="openCoursesAndShow" resultType="xyz.playedu.api.domain.Course">
|
<select id="openCoursesAndShow" resultType="xyz.playedu.api.domain.Course">
|
||||||
SELECT `courses`.*
|
SELECT `courses`.*
|
||||||
FROM `courses`
|
FROM `courses`
|
||||||
LEFT JOIN `course_department` ON `course_department`.`course_id` = `courses`.`id`
|
LEFT JOIN `course_department` ON `course_department`.`course_id` = `courses`.`id`
|
||||||
WHERE `course_department`.`course_id` IS NULL
|
WHERE `course_department`.`course_id` IS NULL
|
||||||
AND `courses`.`is_show` = 1
|
AND `courses`.`is_show` = 1
|
||||||
LIMIT #{limit}
|
<if test="categoryId != null and categoryId > 0">
|
||||||
|
AND `course_department`.`caetgory_id` = #{categoryId}
|
||||||
|
</if>
|
||||||
|
LIMIT #{limit}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user