mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-22 18:29:51 +08:00
优化资源删除
This commit is contained in:
@@ -2,6 +2,7 @@ package xyz.playedu.api.service;
|
||||
|
||||
import xyz.playedu.api.domain.Resource;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import xyz.playedu.api.exception.NotFoundException;
|
||||
import xyz.playedu.api.types.paginate.PaginationResult;
|
||||
import xyz.playedu.api.types.paginate.ResourcePaginateFilter;
|
||||
|
||||
@@ -16,4 +17,6 @@ public interface ResourceService extends IService<Resource> {
|
||||
|
||||
Resource create(Integer categoryId, String type, String filename, String ext, Long size, String disk, String fileId, String path, String url);
|
||||
|
||||
Resource findOrFail(Integer id) throws NotFoundException;
|
||||
|
||||
}
|
||||
|
||||
@@ -11,4 +11,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
public interface ResourceVideoService extends IService<ResourceVideo> {
|
||||
|
||||
void create(Integer resourceId, Integer duration);
|
||||
|
||||
void removeByRid(Integer resourceId);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import xyz.playedu.api.domain.Resource;
|
||||
import xyz.playedu.api.exception.NotFoundException;
|
||||
import xyz.playedu.api.service.ResourceService;
|
||||
import xyz.playedu.api.mapper.ResourceMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -83,6 +84,15 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
|
||||
save(resource);
|
||||
return resource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource findOrFail(Integer id) throws NotFoundException {
|
||||
Resource resource = getById(id);
|
||||
if (resource == null) {
|
||||
throw new NotFoundException("资源不存在");
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,11 @@ public class ResourceVideoServiceImpl extends ServiceImpl<ResourceVideoMapper, R
|
||||
video.setCreatedAt(new Date());
|
||||
save(video);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeByRid(Integer resourceId) {
|
||||
remove(query().getWrapper().eq("rid", resourceId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user