修复/user/courses 接口category_id参数过滤报错

This commit is contained in:
none 2023-05-08 17:08:35 +08:00
parent dbae07de95
commit af913bf4e4
3 changed files with 13 additions and 11 deletions

View File

@ -37,11 +37,11 @@ import java.util.List;
@Slf4j
public class ExceptionController {
@ExceptionHandler(Exception.class)
public JsonResponse exceptionHandler(Exception e) {
log.error(e.getMessage());
return JsonResponse.error("系统错误", 500);
}
// @ExceptionHandler(Exception.class)
// public JsonResponse exceptionHandler(Exception e) {
// log.error(e.getMessage());
// return JsonResponse.error("系统错误", 500);
// }
@ExceptionHandler(ServiceException.class)
public JsonResponse serviceExceptionHandler(ServiceException e) {

View File

@ -237,11 +237,10 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
if (tmpCourseIds == null || tmpCourseIds.size() == 0) {
return new ArrayList<>();
}
// 取交集
courseIds.retainAll(tmpCourseIds);
}
if (courseIds.size() == 0) {
return new ArrayList<>();
courseIds = courseIds.stream().filter(tmpCourseIds::contains).toList();
if (courseIds.size() == 0) {
return new ArrayList<>();
}
}
return list(query().getWrapper().in("id", courseIds).eq("is_show", 1));
}

View File

@ -172,10 +172,13 @@
SELECT `courses`.*
FROM `courses`
LEFT JOIN `course_department` ON `course_department`.`course_id` = `courses`.`id`
<if test="categoryId != null and categoryId > 0">
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 `course_department`.`caetgory_id` = #{categoryId}
AND `resource_course_category`.`category_id` = #{categoryId}
</if>
LIMIT #{limit}
</select>