mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-22 11:52:43 +08:00
增加资源无分类查询
This commit is contained in:
parent
b95cd7fbab
commit
06bc8c639c
@ -75,7 +75,6 @@ public class CourseController {
|
||||
data.put("data", result.getData());
|
||||
data.put("total", result.getTotal());
|
||||
data.put("category_count", courseService.getCategoryCount());
|
||||
data.put("pure_total", courseService.total());
|
||||
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
@ -78,7 +78,6 @@ public class ResourceController {
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("result", result);
|
||||
data.put("category_count", resourceService.getCategoryCount(type));
|
||||
data.put("pure_total", resourceService.total(type));
|
||||
|
||||
if (type.equals(BackendConstant.RESOURCE_TYPE_VIDEO)) {
|
||||
List<ResourceVideo> resourceVideos = resourceVideoService.chunksByRids(result.getData().stream().map(Resource::getId).toList());
|
||||
|
@ -18,6 +18,7 @@ public interface CourseMapper extends BaseMapper<Course> {
|
||||
|
||||
List<CourseCategoryCountMapper> getCategoryCount();
|
||||
|
||||
Integer getNoneCategoryCount();
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,6 +19,8 @@ public interface ResourceMapper extends BaseMapper<Resource> {
|
||||
|
||||
List<ResourceCategoryCountMapper> getCategoryCount(String type);
|
||||
|
||||
Integer getNoneCategoryCount(String type);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -210,7 +210,9 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
||||
|
||||
@Override
|
||||
public Map<Integer, Integer> getCategoryCount() {
|
||||
return getBaseMapper().getCategoryCount().stream().collect(Collectors.toMap(CourseCategoryCountMapper::getCid, CourseCategoryCountMapper::getTotal));
|
||||
Map<Integer, Integer> data = getBaseMapper().getCategoryCount().stream().collect(Collectors.toMap(CourseCategoryCountMapper::getCid, CourseCategoryCountMapper::getTotal));
|
||||
data.put(0, getBaseMapper().getNoneCategoryCount());
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -157,7 +157,9 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
|
||||
|
||||
@Override
|
||||
public Map<Integer, Integer> getCategoryCount(String type) {
|
||||
return getBaseMapper().getCategoryCount(type).stream().collect(Collectors.toMap(ResourceCategoryCountMapper::getCid, ResourceCategoryCountMapper::getTotal));
|
||||
Map<Integer, Integer> data = getBaseMapper().getCategoryCount(type).stream().collect(Collectors.toMap(ResourceCategoryCountMapper::getCid, ResourceCategoryCountMapper::getTotal));
|
||||
data.put(0, getBaseMapper().getNoneCategoryCount(type));
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,4 +27,11 @@
|
||||
FROM `resource_course_category`
|
||||
GROUP BY `resource_course_category`.`category_id`;
|
||||
</select>
|
||||
|
||||
<select id="getNoneCategoryCount" resultType="java.lang.Integer">
|
||||
SELECT count(DISTINCT `courses`.`id`) AS `total`
|
||||
FROM `courses`
|
||||
LEFT JOIN `resource_course_category` ON `resource_course_category`.`course_id` = `courses`.`id`
|
||||
WHERE `resource_course_category`.`course_id` IS NULL;
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -36,4 +36,12 @@
|
||||
GROUP BY `resource_category`.`cid`;
|
||||
</select>
|
||||
|
||||
<select id="getNoneCategoryCount" resultType="java.lang.Integer">
|
||||
SELECT count(DISTINCT `resources`.`id`) AS `total`
|
||||
FROM `resources`
|
||||
LEFT JOIN `resource_category` ON `resource_category`.`rid` = `resources`.`id`
|
||||
WHERE `resources`.`type` = #{type}
|
||||
AND `resource_category`.`cid` IS NULL;
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
Loading…
x
Reference in New Issue
Block a user