mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-07-13 01:35:03 +08:00
视频资源列表返回时长
This commit is contained in:
parent
0118e0a164
commit
2ea4166fab
@ -12,6 +12,7 @@ import xyz.playedu.api.config.MinioConfig;
|
|||||||
import xyz.playedu.api.constant.BackendConstant;
|
import xyz.playedu.api.constant.BackendConstant;
|
||||||
import xyz.playedu.api.domain.Resource;
|
import xyz.playedu.api.domain.Resource;
|
||||||
import xyz.playedu.api.domain.ResourceCategory;
|
import xyz.playedu.api.domain.ResourceCategory;
|
||||||
|
import xyz.playedu.api.domain.ResourceVideo;
|
||||||
import xyz.playedu.api.exception.NotFoundException;
|
import xyz.playedu.api.exception.NotFoundException;
|
||||||
import xyz.playedu.api.request.backend.ResourceRequest;
|
import xyz.playedu.api.request.backend.ResourceRequest;
|
||||||
import xyz.playedu.api.service.ResourceCategoryService;
|
import xyz.playedu.api.service.ResourceCategoryService;
|
||||||
@ -22,6 +23,7 @@ import xyz.playedu.api.types.paginate.PaginationResult;
|
|||||||
import xyz.playedu.api.types.paginate.ResourcePaginateFilter;
|
import xyz.playedu.api.types.paginate.ResourcePaginateFilter;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author 杭州白书科技有限公司
|
* @Author 杭州白书科技有限公司
|
||||||
@ -75,7 +77,16 @@ public class ResourceController {
|
|||||||
|
|
||||||
PaginationResult<Resource> result = resourceService.paginate(page, size, filter);
|
PaginationResult<Resource> result = resourceService.paginate(page, size, filter);
|
||||||
|
|
||||||
return JsonResponse.data(result);
|
HashMap<String, Object> data = new HashMap<>();
|
||||||
|
data.put("result", result);
|
||||||
|
|
||||||
|
if (type.equals(BackendConstant.RESOURCE_TYPE_VIDEO)) {
|
||||||
|
List<ResourceVideo> resourceVideos = resourceVideoService.chunksByResourceIds(result.getData().stream().map(Resource::getId).collect(Collectors.toList()));
|
||||||
|
Map<Integer, Integer> resourceVideosMap = resourceVideos.stream().collect(Collectors.toMap(ResourceVideo::getRid, ResourceVideo::getDuration));
|
||||||
|
data.put("video_duration", resourceVideosMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
return JsonResponse.data(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/create")
|
@GetMapping("/create")
|
||||||
|
@ -3,14 +3,19 @@ package xyz.playedu.api.service;
|
|||||||
import xyz.playedu.api.domain.ResourceVideo;
|
import xyz.playedu.api.domain.ResourceVideo;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tengteng
|
* @author tengteng
|
||||||
* @description 针对表【resource_videos】的数据库操作Service
|
* @description 针对表【resource_videos】的数据库操作Service
|
||||||
* @createDate 2023-03-02 15:13:03
|
* @createDate 2023-03-02 15:13:03
|
||||||
*/
|
*/
|
||||||
public interface ResourceVideoService extends IService<ResourceVideo> {
|
public interface ResourceVideoService extends IService<ResourceVideo> {
|
||||||
|
|
||||||
void create(Integer resourceId, Integer duration);
|
void create(Integer resourceId, Integer duration);
|
||||||
|
|
||||||
void removeByRid(Integer resourceId);
|
void removeByRid(Integer resourceId);
|
||||||
|
|
||||||
|
List<ResourceVideo> chunksByResourceIds(List<Integer> resourceIds);
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,16 @@ import xyz.playedu.api.mapper.ResourceVideoMapper;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tengteng
|
* @author tengteng
|
||||||
* @description 针对表【resource_videos】的数据库操作Service实现
|
* @description 针对表【resource_videos】的数据库操作Service实现
|
||||||
* @createDate 2023-03-02 15:13:03
|
* @createDate 2023-03-02 15:13:03
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ResourceVideoServiceImpl extends ServiceImpl<ResourceVideoMapper, ResourceVideo>
|
public class ResourceVideoServiceImpl extends ServiceImpl<ResourceVideoMapper, ResourceVideo> implements ResourceVideoService {
|
||||||
implements ResourceVideoService{
|
|
||||||
@Override
|
@Override
|
||||||
public void create(Integer resourceId, Integer duration) {
|
public void create(Integer resourceId, Integer duration) {
|
||||||
ResourceVideo video = new ResourceVideo();
|
ResourceVideo video = new ResourceVideo();
|
||||||
@ -29,6 +30,11 @@ public class ResourceVideoServiceImpl extends ServiceImpl<ResourceVideoMapper, R
|
|||||||
public void removeByRid(Integer resourceId) {
|
public void removeByRid(Integer resourceId) {
|
||||||
remove(query().getWrapper().eq("rid", resourceId));
|
remove(query().getWrapper().eq("rid", resourceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ResourceVideo> chunksByResourceIds(List<Integer> resourceIds) {
|
||||||
|
return list(query().getWrapper().in("rid", resourceIds));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user