修复/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 @Slf4j
public class ExceptionController { public class ExceptionController {
@ExceptionHandler(Exception.class) // @ExceptionHandler(Exception.class)
public JsonResponse exceptionHandler(Exception e) { // public JsonResponse exceptionHandler(Exception e) {
log.error(e.getMessage()); // log.error(e.getMessage());
return JsonResponse.error("系统错误", 500); // return JsonResponse.error("系统错误", 500);
} // }
@ExceptionHandler(ServiceException.class) @ExceptionHandler(ServiceException.class)
public JsonResponse serviceExceptionHandler(ServiceException e) { public JsonResponse serviceExceptionHandler(ServiceException e) {

View File

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

View File

@ -172,10 +172,13 @@
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`
<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 WHERE `course_department`.`course_id` IS NULL
AND `courses`.`is_show` = 1 AND `courses`.`is_show` = 1
<if test="categoryId != null and categoryId > 0"> <if test="categoryId != null and categoryId > 0">
AND `course_department`.`caetgory_id` = #{categoryId} AND `resource_course_category`.`category_id` = #{categoryId}
</if> </if>
LIMIT #{limit} LIMIT #{limit}
</select> </select>