mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-07-22 17:20:05 +08:00
删除资源分类的资源数量计算
This commit is contained in:
parent
debf6c65fb
commit
9a3b8138f5
@ -75,7 +75,6 @@ public class CourseController {
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
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);
|
||||
|
@ -77,7 +77,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)) {
|
||||
|
@ -17,8 +17,6 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface CourseMapper extends BaseMapper<Course> {
|
||||
|
||||
List<CourseCategoryCountMapper> getCategoryCount();
|
||||
|
||||
List<Course> paginate(CoursePaginateFiler filer);
|
||||
|
||||
Long paginateCount(CoursePaginateFiler filer);
|
||||
|
@ -18,10 +18,6 @@ import java.util.Map;
|
||||
@Mapper
|
||||
public interface ResourceMapper extends BaseMapper<Resource> {
|
||||
|
||||
List<ResourceCategoryCountMapper> getCategoryCount(String type);
|
||||
|
||||
Integer getNunCategoryCount(String type);
|
||||
|
||||
List<Resource> paginate(ResourcePaginateFilter filter);
|
||||
|
||||
Long paginateCount(ResourcePaginateFilter filter);
|
||||
|
@ -44,8 +44,6 @@ public interface CourseService extends IService<Course> {
|
||||
|
||||
List<Course> chunks(List<Integer> ids);
|
||||
|
||||
Map<Integer, Integer> getCategoryCount();
|
||||
|
||||
Integer total();
|
||||
|
||||
List<Course> openCoursesAndShow(Integer limit);
|
||||
|
@ -30,8 +30,6 @@ public interface ResourceService extends IService<Resource> {
|
||||
|
||||
List<Resource> chunks(List<Integer> ids, List<String> fields);
|
||||
|
||||
Map<Integer, Integer> getCategoryCount(String type);
|
||||
|
||||
Integer total(String type);
|
||||
|
||||
Integer duration(Integer id);
|
||||
|
@ -169,11 +169,6 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
||||
return list(query().getWrapper().in("id", ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, Integer> getCategoryCount() {
|
||||
return getBaseMapper().getCategoryCount().stream().collect(Collectors.toMap(CourseCategoryCountMapper::getCid, CourseCategoryCountMapper::getTotal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer total() {
|
||||
return Math.toIntExact(count());
|
||||
|
@ -112,13 +112,6 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
|
||||
return list(query().getWrapper().in("id", ids).select(fields));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, Integer> getCategoryCount(String type) {
|
||||
Map<Integer, Integer> data = getBaseMapper().getCategoryCount(type).stream().collect(Collectors.toMap(ResourceCategoryCountMapper::getCid, ResourceCategoryCountMapper::getTotal));
|
||||
data.put(0, getBaseMapper().getNunCategoryCount(type));
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer total(String type) {
|
||||
return Math.toIntExact(count(query().getWrapper().eq("type", type).eq("is_hidden", 0)));
|
||||
|
@ -8,6 +8,7 @@
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="title" column="title" jdbcType="VARCHAR"/>
|
||||
<result property="thumb" column="thumb" jdbcType="VARCHAR"/>
|
||||
<result property="shortDesc" column="short_desc" jdbcType="VARCHAR"/>
|
||||
<result property="charge" column="charge" jdbcType="INTEGER"/>
|
||||
<result property="classHour" column="class_hour" jdbcType="INTEGER"/>
|
||||
<result property="isShow" column="is_show" jdbcType="TINYINT"/>
|
||||
@ -18,18 +19,12 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,title,thumb,
|
||||
id,title,thumb,short_desc,
|
||||
charge,class_hour,is_show,
|
||||
is_required,created_at,updated_at,
|
||||
deleted_at
|
||||
</sql>
|
||||
|
||||
<select id="getCategoryCount" resultType="xyz.playedu.api.types.mapper.CourseCategoryCountMapper">
|
||||
SELECT `resource_course_category`.`category_id` as `cid`, count(*) as `total`
|
||||
FROM `resource_course_category`
|
||||
GROUP BY `resource_course_category`.`category_id`;
|
||||
</select>
|
||||
|
||||
<select id="paginate" resultType="xyz.playedu.api.domain.Course">
|
||||
SELECT `courses`.*
|
||||
FROM `courses`
|
||||
|
@ -29,24 +29,6 @@
|
||||
is_hidden
|
||||
</sql>
|
||||
|
||||
<select id="getCategoryCount" resultType="xyz.playedu.api.types.mapper.ResourceCategoryCountMapper">
|
||||
SELECT `resource_category`.`cid` as `cid`, count(*) as `total`
|
||||
FROM `resources`
|
||||
INNER JOIN `resource_category` ON `resource_category`.`rid` = `resources`.`id`
|
||||
WHERE `resources`.`type` = #{type}
|
||||
AND `resources`.`is_hidden` = 0
|
||||
GROUP BY `resource_category`.`cid`;
|
||||
</select>
|
||||
|
||||
<select id="getNunCategoryCount" resultType="java.lang.Integer">
|
||||
SELECT count(1) AS `total`
|
||||
FROM `resources`
|
||||
LEFT JOIN `resource_category` ON `resource_category`.`rid` = `resources`.`id`
|
||||
WHERE `resources`.`type` = #{type}
|
||||
AND `resources`.`is_hidden` = 0
|
||||
AND `resource_category`.`rid` IS NULL;
|
||||
</select>
|
||||
|
||||
<select id="paginate" resultType="xyz.playedu.api.domain.Resource">
|
||||
SELECT `resources`.*
|
||||
FROM `resources`
|
||||
|
Loading…
x
Reference in New Issue
Block a user