1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-09-01 22:53:29 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

书籍页添加下载部分;获取URL参数考虑带#锚点情况;解决页面重复获取压缩字体问题

This commit is contained in:
2022-04-16 20:34:25 +08:00
parent af5e0a50d7
commit 30c557d046
10 changed files with 317 additions and 14 deletions

View File

@@ -50,6 +50,20 @@ public class FileController extends BaseController {
@Autowired
FileObjectServiceImpl fileObjectService;
@ApiOperation(value = "书籍下载页面获取文件提供的下载方式", notes = "")
@RequestMapping(value = "getFile", method = {RequestMethod.GET})
@ResponseBody
public CommonReturnType getFile(@RequestParam(value = "bookId", required = false) Integer bookId) throws BusinessException {
List<FileModel> fileModels = fileService.getFile(bookId);
List<FileVO> fileVOS = new ArrayList<>();
for (FileModel fileModel : fileModels) {
FileVO fileVO = convertFileVOFromModel(fileModel);
fileVOS.add(fileVO);
}
return CommonReturnType.create(fileVOS);
}
@ApiOperation(value = "【管理员】查询文件列表", notes = "查询文件列表")
@RequestMapping(value = "list", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
@ResponseBody

View File

@@ -60,6 +60,13 @@ public interface FileDOMapper {
*/
FileDO[] selectAll();
/**
* 列出文件支持的下载方式
*
* @return
*/
FileDO[] selectAvailableByBookId(Integer bookId);
/**
* 获取上一次插入的主键Id
*

View File

@@ -4,6 +4,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import plus.bookshelf.Common.Error.BusinessErrorCode;
import plus.bookshelf.Common.Error.BusinessException;
import plus.bookshelf.Config.QCloudCosConfig;
import plus.bookshelf.Dao.DO.FileDO;
@@ -39,6 +40,29 @@ public class FileServiceImpl implements FileService {
@Autowired
CosPresignedUrlGenerateLogService cosPresignedUrlGenerateLogService;
/**
* 列出文件支持的下载方式
*
* @return
*/
@Override
public List<FileModel> getFile(Integer bookId) throws BusinessException {
if (bookId == 0 || bookId == null) {
throw new BusinessException(BusinessErrorCode.PARAMETER_VALIDATION_ERROR, "bookId不能为空");
}
FileDO[] fileDOS = fileDOMapper.selectAvailableByBookId(bookId);
List<FileModel> fileModels = new ArrayList<>();
for (FileDO fileDO : fileDOS) {
FileModel fileModel = convertFromDataObject(fileDO);
fileModels.add(fileModel);
}
return fileModels;
}
/**
* 列出所有文件
*
@@ -62,7 +86,7 @@ public class FileServiceImpl implements FileService {
}
private FileModel convertFromDataObject(FileDO fileDO) {
if(fileDO == null) {
if (fileDO == null) {
return null;
}
FileModel fileModel = new FileModel();

View File

@@ -7,6 +7,17 @@ import java.lang.reflect.InvocationTargetException;
import java.util.List;
public interface FileService {
/**
* 列出文件支持的下载方式
*
* @param bookId
* @return
* @throws InvocationTargetException
* @throws IllegalAccessException
* @throws BusinessException
*/
List<FileModel> getFile(Integer bookId) throws InvocationTargetException, IllegalAccessException, BusinessException;
/**
* 列出所有文件
*