mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-22 18:29:51 +08:00
资源增加admin_id
This commit is contained in:
@@ -6,8 +6,6 @@ import xyz.playedu.api.exception.NotFoundException;
|
||||
import xyz.playedu.api.types.paginate.PaginationResult;
|
||||
import xyz.playedu.api.types.paginate.ResourcePaginateFilter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
* @description 针对表【resources】的数据库操作Service
|
||||
@@ -17,7 +15,7 @@ public interface ResourceService extends IService<Resource> {
|
||||
|
||||
PaginationResult<Resource> paginate(int page, int size, ResourcePaginateFilter filter);
|
||||
|
||||
Resource create(String categoryIds, String type, String filename, String ext, Long size, String disk, String fileId, String path, String url);
|
||||
Resource create(Integer adminId, String categoryIds, String type, String filename, String ext, Long size, String disk, String fileId, String path, String url);
|
||||
|
||||
Resource findOrFail(Integer id) throws NotFoundException;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import xyz.playedu.api.exception.ServiceException;
|
||||
* @create 2023/3/8 14:02
|
||||
*/
|
||||
public interface UploadService {
|
||||
Resource storeMinio(MultipartFile file, String categoryIds) throws ServiceException;
|
||||
Resource storeMinio(Integer adminId, MultipartFile file, String categoryIds) throws ServiceException;
|
||||
|
||||
Resource storeBase64Image(String content, String categoryIds) throws ServiceException;
|
||||
Resource storeBase64Image(Integer adminId, String content, String categoryIds) throws ServiceException;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,9 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
|
||||
if (filter.getType() != null) {
|
||||
wrapper.eq("type", filter.getType());
|
||||
}
|
||||
if (filter.getAdminId() != null && !filter.getAdminId().equals(0)) {
|
||||
wrapper.eq("admin_id", filter.getAdminId());
|
||||
}
|
||||
if (filter.getCategoryIds() != null && filter.getCategoryIds().trim().length() > 0) {
|
||||
List<Integer> categoryIds = Arrays.stream(filter.getCategoryIds().split(",")).map(Integer::valueOf).toList();
|
||||
List<Integer> ids = relationService.getRidsByCids(categoryIds);
|
||||
@@ -89,8 +92,9 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Resource create(String categoryIds, String type, String filename, String ext, Long size, String disk, String fileId, String path, String url) {
|
||||
public Resource create(Integer adminId, String categoryIds, String type, String filename, String ext, Long size, String disk, String fileId, String path, String url) {
|
||||
Resource resource = new Resource();
|
||||
resource.setAdminId(adminId);
|
||||
resource.setType(type);
|
||||
resource.setName(filename);
|
||||
resource.setExtension(ext);
|
||||
|
||||
@@ -8,14 +8,11 @@ import xyz.playedu.api.constant.BackendConstant;
|
||||
import xyz.playedu.api.domain.Resource;
|
||||
import xyz.playedu.api.exception.ServiceException;
|
||||
import xyz.playedu.api.service.MinioService;
|
||||
import xyz.playedu.api.service.ResourceCategoryService;
|
||||
import xyz.playedu.api.service.ResourceService;
|
||||
import xyz.playedu.api.service.UploadService;
|
||||
import xyz.playedu.api.util.Base64Util;
|
||||
import xyz.playedu.api.util.HelperUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author 杭州白书科技有限公司
|
||||
* @create 2023/3/8 14:02
|
||||
@@ -31,7 +28,7 @@ public class UploadServiceImpl implements UploadService {
|
||||
private MinioService minioService;
|
||||
|
||||
@Override
|
||||
public Resource storeMinio(MultipartFile file, String categoryIds) throws ServiceException {
|
||||
public Resource storeMinio(Integer adminId, MultipartFile file, String categoryIds) throws ServiceException {
|
||||
if (file == null || file.isEmpty() || file.getOriginalFilename() == null) {
|
||||
throw new ServiceException("请上传文件");
|
||||
}
|
||||
@@ -53,11 +50,11 @@ public class UploadServiceImpl implements UploadService {
|
||||
// 保存文件
|
||||
String url = minioService.saveFile(file, savePath, BackendConstant.RESOURCE_EXT_2_CONTENT_TYPE.get(ext));
|
||||
// 上传记录
|
||||
return resourceService.create(categoryIds, type, oFilename, ext, file.getSize(), BackendConstant.STORAGE_DRIVER_MINIO, "", savePath, url);
|
||||
return resourceService.create(adminId, categoryIds, type, oFilename, ext, file.getSize(), BackendConstant.STORAGE_DRIVER_MINIO, "", savePath, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource storeBase64Image(String content, String categoryIds) throws ServiceException {
|
||||
public Resource storeBase64Image(Integer adminId, String content, String categoryIds) throws ServiceException {
|
||||
// data:image/jpeg;base64,
|
||||
String[] base64Rows = content.split(",");
|
||||
// 解析出content-type
|
||||
@@ -78,6 +75,6 @@ public class UploadServiceImpl implements UploadService {
|
||||
// 保存文件
|
||||
String url = minioService.saveBytes(binary, savePath, BackendConstant.RESOURCE_EXT_2_CONTENT_TYPE.get(ext));
|
||||
// 上传记录
|
||||
return resourceService.create(categoryIds, type, filename, ext, (long) binary.length, BackendConstant.STORAGE_DRIVER_MINIO, "", savePath, url);
|
||||
return resourceService.create(adminId, categoryIds, type, filename, ext, (long) binary.length, BackendConstant.STORAGE_DRIVER_MINIO, "", savePath, url);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user