首页增加课件数

This commit is contained in:
wsw 2024-06-04 15:25:22 +08:00
parent 6776fecfe9
commit 5b027dfa23
3 changed files with 17 additions and 0 deletions

View File

@ -82,6 +82,16 @@ public class DashboardController {
data.put(
"resource_image_total", resourceService.total(BackendConstant.RESOURCE_TYPE_IMAGE));
List<String> types = new ArrayList<>();
types.add(BackendConstant.RESOURCE_TYPE_PDF);
types.add(BackendConstant.RESOURCE_TYPE_WORD);
types.add(BackendConstant.RESOURCE_TYPE_PPT);
types.add(BackendConstant.RESOURCE_TYPE_EXCEL);
types.add(BackendConstant.RESOURCE_TYPE_ZIP);
types.add(BackendConstant.RESOURCE_TYPE_RAR);
types.add(BackendConstant.RESOURCE_TYPE_TXT);
data.put("resource_file_total", resourceService.total(types));
data.put("user_learn_today", userLearnDurationStatsService.todayTotal());
data.put("user_learn_yesterday", userLearnDurationStatsService.yesterdayTotal());

View File

@ -59,4 +59,6 @@ public interface ResourceService extends IService<Resource> {
void updateNameAndCategoryId(Integer id, String name, Integer categoryId);
List<Integer> categoryIds(Integer resourceId);
Integer total(List<String> types);
}

View File

@ -186,4 +186,9 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource>
.map(ResourceCategory::getCid)
.toList();
}
@Override
public Integer total(List<String> types) {
return Math.toIntExact(count(query().getWrapper().in("type", types).eq("is_hidden", 0)));
}
}