mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-29 08:55:23 +08:00
优化资源列表视频资源的读取
This commit is contained in:
parent
d269880986
commit
f6be76b851
@ -43,7 +43,7 @@ public class ResourceController {
|
|||||||
String sortAlgo = MapUtils.getString(params, "sort_algo");
|
String sortAlgo = MapUtils.getString(params, "sort_algo");
|
||||||
String name = MapUtils.getString(params, "name");
|
String name = MapUtils.getString(params, "name");
|
||||||
String type = MapUtils.getString(params, "type");
|
String type = MapUtils.getString(params, "type");
|
||||||
String categoryIdsStr = MapUtils.getString(params, "category_ids");
|
String categoryIds = MapUtils.getString(params, "category_ids");
|
||||||
|
|
||||||
if (type == null || type.trim().length() == 0) {
|
if (type == null || type.trim().length() == 0) {
|
||||||
return JsonResponse.error("请选择资源类型");
|
return JsonResponse.error("请选择资源类型");
|
||||||
@ -53,13 +53,10 @@ public class ResourceController {
|
|||||||
filter.setSortAlgo(sortAlgo);
|
filter.setSortAlgo(sortAlgo);
|
||||||
filter.setSortField(sortField);
|
filter.setSortField(sortField);
|
||||||
filter.setType(type);
|
filter.setType(type);
|
||||||
|
filter.setCategoryIds(categoryIds);
|
||||||
if (name != null && name.length() > 0) {
|
if (name != null && name.length() > 0) {
|
||||||
filter.setName(name);
|
filter.setName(name);
|
||||||
}
|
}
|
||||||
if (categoryIdsStr != null && categoryIdsStr.length() != 0) {
|
|
||||||
Integer[] categoryIds = Arrays.stream(categoryIdsStr.split(",")).map(Integer::valueOf).toArray(Integer[]::new);
|
|
||||||
filter.setCategoryIds(categoryIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
PaginationResult<Resource> result = resourceService.paginate(page, size, filter);
|
PaginationResult<Resource> result = resourceService.paginate(page, size, filter);
|
||||||
|
|
||||||
|
@ -54,12 +54,13 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
|
|||||||
if (filter.getType() != null) {
|
if (filter.getType() != null) {
|
||||||
wrapper.eq("type", filter.getType());
|
wrapper.eq("type", filter.getType());
|
||||||
}
|
}
|
||||||
if (filter.getCategoryIds() != null && filter.getCategoryIds().length > 0) {
|
if (filter.getCategoryIds() != null && filter.getCategoryIds().trim().length() > 0) {
|
||||||
List<Integer> ridArray = relationService.getRidsByCids(Arrays.asList(filter.getCategoryIds()));
|
List<Integer> categoryIds = Arrays.stream(filter.getCategoryIds().split(",")).map(Integer::valueOf).toList();
|
||||||
if (ridArray == null || ridArray.size() == 0) {
|
List<Integer> ids = relationService.getRidsByCids(categoryIds);
|
||||||
ridArray = HelperUtil.zeroIntegerList();
|
if (ids == null || ids.size() == 0) {
|
||||||
|
ids = HelperUtil.zeroIntegerList();
|
||||||
}
|
}
|
||||||
wrapper.in("id", ridArray);
|
wrapper.in("id", ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
String sortFiled = filter.getSortField();
|
String sortFiled = filter.getSortField();
|
||||||
|
@ -6,6 +6,7 @@ import xyz.playedu.api.service.ResourceVideoService;
|
|||||||
import xyz.playedu.api.mapper.ResourceVideoMapper;
|
import xyz.playedu.api.mapper.ResourceVideoMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -34,6 +35,9 @@ public class ResourceVideoServiceImpl extends ServiceImpl<ResourceVideoMapper, R
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ResourceVideo> chunksByRids(List<Integer> resourceIds) {
|
public List<ResourceVideo> chunksByRids(List<Integer> resourceIds) {
|
||||||
|
if (resourceIds == null || resourceIds.size() == 0) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
return list(query().getWrapper().in("rid", resourceIds));
|
return list(query().getWrapper().in("rid", resourceIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public class ResourcePaginateFilter {
|
|||||||
|
|
||||||
private String sortAlgo;
|
private String sortAlgo;
|
||||||
|
|
||||||
private Integer[] categoryIds;
|
private String categoryIds;
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ public class HelperUtil {
|
|||||||
|
|
||||||
|
|
||||||
public static List<Integer> zeroIntegerList() {
|
public static List<Integer> zeroIntegerList() {
|
||||||
List<Integer> list = new ArrayList<>(1);
|
return new ArrayList<>() {{
|
||||||
list.add(0);
|
add(0);
|
||||||
return list;
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String MD5(String text) {
|
public static String MD5(String text) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user