mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-21 01:10:39 +08:00
登陆过期重新登录跳回原来页面;管理员后台文件详情页面文件详情和关联文件对象
This commit is contained in:
@@ -472,7 +472,7 @@
|
||||
// console.log(dom);
|
||||
return dom;
|
||||
}
|
||||
getRequest("/file/getFile", { bookId: bookId })
|
||||
getRequest("/file/getFileByBookId", { bookId: bookId })
|
||||
.then(function (response) {
|
||||
var axiosData = response.data;
|
||||
var status = axiosData.status;
|
||||
|
@@ -1,19 +1,19 @@
|
||||
<style>
|
||||
/* 限制 来源 列的宽度 */
|
||||
tr>*:nth-child(8),
|
||||
td>*:nth-child(8) {
|
||||
tr>*:nth-child(7),
|
||||
td>*:nth-child(7) {
|
||||
max-width: 100px;
|
||||
}
|
||||
|
||||
/* 限制 哈希 列的宽度 */
|
||||
tr>*:nth-child(10),
|
||||
td>*:nth-child(10) {
|
||||
tr>*:nth-child(9),
|
||||
td>*:nth-child(9) {
|
||||
max-width: 100px;
|
||||
}
|
||||
|
||||
/* 限制 时间 列的宽度 */
|
||||
tr>*:nth-child(11),
|
||||
td>*:nth-child(11) {
|
||||
tr>*:nth-child(10),
|
||||
td>*:nth-child(10) {
|
||||
max-width: 100px;
|
||||
}
|
||||
</style>
|
||||
@@ -67,7 +67,7 @@
|
||||
创建: ${new Date(element.fileCreateAt).toLocaleString()}<br>
|
||||
修改: ${new Date(element.fileModifiedAt).toLocaleString()}
|
||||
</nobr></span>`,
|
||||
管理: `<span class="overflow-omit" style="margin: 0 auto;">
|
||||
管理: `<span style="margin: 0 auto;">
|
||||
<a href="<%= pageUrl %>detail?id=${element.id}">详情(TODO)</a>
|
||||
<a href="javascript:deleteBook(${element.id});">删除(TODO)</a>
|
||||
</span>`,
|
||||
|
@@ -1,5 +1,112 @@
|
||||
<p>
|
||||
<h3>文件详情</h3>
|
||||
<hr>
|
||||
<h3>关联文件对象</h3>
|
||||
</p>
|
||||
<h3>文件详情</h3>
|
||||
<div id="file-detail-container">
|
||||
</div>
|
||||
<hr>
|
||||
<h3>关联文件对象</h3>
|
||||
<div id="file-object-container">
|
||||
|
||||
</div>
|
||||
|
||||
<!-- 获取参数 -->
|
||||
<script src="/assets/javascripts/getParams.js"></script>
|
||||
<script>
|
||||
var requestParams = getParams();
|
||||
var fileId = Number(requestParams["id"]) ?? "";
|
||||
if (fileId === "") {
|
||||
location.href = "<%= pageUrl %>../";
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
// 获取文件信息
|
||||
function getFileInfo() {
|
||||
function stringifyFileSize(nBytes = 0) {
|
||||
// 美化输出文件大小
|
||||
let sOutput = nBytes + " bytes";
|
||||
const aMultiples = ["KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||
for (nMultiple = 0, nApprox = nBytes / 1024; nApprox > 1; nApprox /= 1024, nMultiple++) {
|
||||
sOutput = nApprox.toFixed(2) + " " + aMultiples[nMultiple];
|
||||
}
|
||||
return sOutput;
|
||||
}
|
||||
getRequest("/file/getFileById", { fileId: fileId })
|
||||
.then(function (response) {
|
||||
var axiosData = response.data;
|
||||
var status = axiosData.status;
|
||||
var data = axiosData.data;
|
||||
if (status === "success") {
|
||||
console.log("file", data);
|
||||
document.getElementById("file-detail-container").innerHTML =
|
||||
`<table border="1" style="margin: 0 auto;">
|
||||
<tr><th>key</th><th>value</th></tr>
|
||||
<tr><td>文件名</td><td>${data.fileName}</td></tr>
|
||||
<tr><td>文件扩展名</td><td>${data.fileExt}</td></tr>
|
||||
<tr><td>文件大小</td><td>${stringifyFileSize(data.fileSize)}</td></tr>
|
||||
<tr><td>SHA1</td><td>${data.fileSha1}</td></tr>
|
||||
<tr><td>文件Id</td><td>${data.id}</td></tr>
|
||||
<tr><td>关联书籍Id</td><td>${data.bookId}</td></tr>
|
||||
<tr><td>是否有广告</td><td>${data.advertising ? "是" : "否"}</td></tr>
|
||||
<tr><td>是否有水印</td><td>${data.watermark ? "是" : "否"}</td></tr>
|
||||
<tr><td>文件创建日期</td><td>${data.fileCreateAt}</td></tr>
|
||||
<tr><td>文件修改日期</td><td>${data.fileModifiedAt}</td></tr>
|
||||
<tr><td>页数</td><td>${data.numberOfPages}</td></tr>
|
||||
<tr><td>来源信息</td><td>${data.source}</td></tr>
|
||||
</table>`;
|
||||
|
||||
} else {
|
||||
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
|
||||
}
|
||||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
alert("无法连接到服务器,请检查网络连接!");
|
||||
});
|
||||
}
|
||||
getFileInfo();
|
||||
|
||||
|
||||
// 获取文件对象信息
|
||||
function getFileObjectInfo() {
|
||||
getRequest("/file/object/getByFileId", { fileId: fileId })
|
||||
.then(function (response) {
|
||||
var axiosData = response.data;
|
||||
var status = axiosData.status;
|
||||
var data = axiosData.data;
|
||||
if (status === "success") {
|
||||
console.log("fileObject", data);
|
||||
|
||||
var items = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var item = data[i];
|
||||
items.push(`<tr>
|
||||
<td>${item.id}</td>
|
||||
<td>${item.lastModified === 0 ? "未知" : new Date(item.lastModified).toISOString().replace(/T/, ' ').replace(/\..+/, '')}</td>
|
||||
<td>${item.storageMedium}</td>
|
||||
<td>${item.filePwd}</td>
|
||||
<td>${item.fileShareCode}</td>
|
||||
<td>${(item.uploadStatus ? item.uploadStatus : "<span style='color: grey; font-weight: bold;'>未知</span>")
|
||||
.replace("SUCCESS", "<span style='color: green; font-weight: bold;'>成功</span>")
|
||||
.replace("UPLOADING", "<span style='color: orange; font-weight: bold;'>正在上传</span>")
|
||||
.replace("NOT_EXIST", "<span style='color: red; font-weight: bold;'>不存在</span>")}</td>
|
||||
</tr>`);
|
||||
}
|
||||
document.getElementById("file-object-container").innerHTML =
|
||||
`<table border="1" style="margin: 0 auto;">
|
||||
<tr>
|
||||
<th>文件对象Id</th>
|
||||
<th>文件修改日期</th>
|
||||
<th>存储介质</th>
|
||||
<th>文件密码</th>
|
||||
<th>提取码</th>
|
||||
<th>状态</th>
|
||||
</tr>
|
||||
${items.join("")}
|
||||
</table>`;
|
||||
} else {
|
||||
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
|
||||
}
|
||||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
alert("无法连接到服务器,请检查网络连接!");
|
||||
});
|
||||
}
|
||||
getFileObjectInfo();
|
||||
</script>
|
@@ -29,9 +29,6 @@
|
||||
修改日期: element.lastModified === 0 ? "未知" : `<span class="overflow-omit" style="font-size: 12px; line-height: 1.2em; display: block;"><nobr>
|
||||
${new Date(element.lastModified).toISOString().replace(/T/, ' ').replace(/\..+/, '')}
|
||||
</nobr></span>`,
|
||||
格式: `<span class="overflow-omit" style="font-size: 12px; line-height: 1.2em; display: block;"><nobr>
|
||||
${element.fileType ? element.fileType : "未知"}
|
||||
</nobr></span>`,
|
||||
密码: `<span class="overflow-omit" style="font-size: 12px; line-height: 1.2em; display: block;"><nobr>
|
||||
文件密码: ${element.filePwd}<br>
|
||||
提取码: ${element.fileShareCode}
|
||||
@@ -47,7 +44,7 @@
|
||||
<a href="javascript:refreshFileObjectStatus(${element.id});">刷新状态</a>
|
||||
<a href="<%= pageUrl %>../object-detail?id=${element.id}">修改(TODO)</a>
|
||||
<a href="javascript:deleteBook(${element.id});">删除(TODO)</a>
|
||||
</span > `,
|
||||
</span >`,
|
||||
})
|
||||
});
|
||||
if (renderData.length == 0) {
|
||||
|
@@ -54,7 +54,7 @@
|
||||
} else {
|
||||
if(data.errCode == "20004") { // 登录过期
|
||||
localStorageUtils.userLogout();
|
||||
window.location.href = "/login";
|
||||
window.location.href = "/login?redirect=" + encodeURIComponent(location.pathname + location.search);
|
||||
}
|
||||
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
|
||||
}
|
||||
|
@@ -137,7 +137,7 @@
|
||||
if (data.errCode == "20004") {
|
||||
// 登录过期
|
||||
localStorageUtils.userLogout();
|
||||
location.href = "/login";
|
||||
location.href = "/login?redirect=" + encodeURIComponent(location.pathname + location.search);
|
||||
}
|
||||
}
|
||||
}).catch(function (error) {
|
||||
|
@@ -55,11 +55,11 @@ public class FileController extends BaseController {
|
||||
VisitorFingerprintLogServiceImpl visitorFingerprintLogService;
|
||||
|
||||
@ApiOperation(value = "书籍下载页面获取文件提供的下载方式", notes = "")
|
||||
@RequestMapping(value = "getFile", method = {RequestMethod.GET})
|
||||
@RequestMapping(value = "getFileByBookId", method = {RequestMethod.GET})
|
||||
@ResponseBody
|
||||
public CommonReturnType getFile(@RequestParam(value = "bookId", required = false) Integer bookId) throws BusinessException, InvocationTargetException, IllegalAccessException {
|
||||
public CommonReturnType getFileByBookId(@RequestParam(value = "bookId", required = false) Integer bookId) throws BusinessException, InvocationTargetException, IllegalAccessException {
|
||||
|
||||
List<FileModel> fileModels = fileService.getFile(bookId);
|
||||
List<FileModel> fileModels = fileService.getFileByBookId(bookId);
|
||||
List<FileVO> fileVOS = new ArrayList<>();
|
||||
for (FileModel fileModel : fileModels) {
|
||||
FileVO fileVO = convertFileVOFromModel(fileModel);
|
||||
@@ -80,6 +80,15 @@ public class FileController extends BaseController {
|
||||
return CommonReturnType.create(map);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过 fileId 获取文件信息", notes = "")
|
||||
@RequestMapping(value = "getFileById", method = {RequestMethod.GET})
|
||||
@ResponseBody
|
||||
public CommonReturnType getFileById(@RequestParam(value = "fileId", required = false) Integer fileId) throws BusinessException, InvocationTargetException, IllegalAccessException {
|
||||
FileModel fileModel = fileService.getFileById(fileId);
|
||||
FileVO fileVO = convertFileVOFromModel(fileModel);
|
||||
return CommonReturnType.create(fileVO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "【管理员】查询文件列表", notes = "查询文件列表")
|
||||
@RequestMapping(value = "list", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
|
||||
@ResponseBody
|
||||
|
@@ -112,6 +112,20 @@ public class FileObjectController extends BaseController {
|
||||
return CommonReturnType.create(fileObjectVOS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询指定文件的文件对象列表", notes = "传入文件Id,返回文件对象列表")
|
||||
@RequestMapping(value = "getByFileId", method = {RequestMethod.GET})
|
||||
@ResponseBody
|
||||
public CommonReturnType getFileObjectByFileId(@RequestParam(value = "fileId", required = false) Integer fileId) throws InvocationTargetException, IllegalAccessException, BusinessException {
|
||||
|
||||
List<FileObjectModel> fileObjectModels = fileObjectService.getFileObjectListByFileId(fileId);
|
||||
List<FileObjectVO> fileObjectVOS = new ArrayList<>();
|
||||
for (FileObjectModel fileObjectModel : fileObjectModels) {
|
||||
FileObjectVO fileObjectVO = convertFileObjectVOFromModel(fileObjectModel);
|
||||
fileObjectVOS.add(fileObjectVO);
|
||||
}
|
||||
return CommonReturnType.create(fileObjectVOS);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "【管理员】更新文件对象上传状态", notes = "重新从 COS 对象存储中获取文件对象上传状态")
|
||||
@RequestMapping(value = "refreshFileObjectStatus", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
|
||||
@ResponseBody
|
||||
|
@@ -68,6 +68,14 @@ public interface FileObjectDOMapper {
|
||||
*/
|
||||
FileObjectDO selectByFilePath(String filePath);
|
||||
|
||||
/**
|
||||
* 通过文件路径获取文件
|
||||
*
|
||||
* @param fileId 文件Id
|
||||
* @return
|
||||
*/
|
||||
FileObjectDO[] selectByFileId(Integer fileId);
|
||||
|
||||
/**
|
||||
* 通过书本Id获取关联文件,进而获取所有关联文件对应的文件对象
|
||||
*
|
||||
|
@@ -233,4 +233,23 @@ public class FileObjectServiceImpl implements FileObjectService {
|
||||
FileObjectModel fileObjectModel = convertFromDataObject(fileObjectDO);
|
||||
return fileObjectModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出指定文件的所有文件对象
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<FileObjectModel> getFileObjectListByFileId(Integer fileId) throws InvocationTargetException, IllegalAccessException, BusinessException {
|
||||
|
||||
FileObjectDO[] fileObjectDOS = fileObjectDOMapper.selectByFileId(fileId);
|
||||
|
||||
List<FileObjectModel> fileObjectModels = new ArrayList<>();
|
||||
for (FileObjectDO fileObjectDO : fileObjectDOS) {
|
||||
FileObjectModel fileObjectModel = convertFromDataObject(fileObjectDO);
|
||||
fileObjectModels.add(fileObjectModel);
|
||||
}
|
||||
|
||||
return fileObjectModels;
|
||||
}
|
||||
}
|
||||
|
@@ -42,10 +42,12 @@ public class FileServiceImpl implements FileService {
|
||||
/**
|
||||
* 列出文件支持的下载方式
|
||||
*
|
||||
* @param bookId
|
||||
* @return
|
||||
* @throws BusinessException
|
||||
*/
|
||||
@Override
|
||||
public List<FileModel> getFile(Integer bookId) throws BusinessException {
|
||||
public List<FileModel> getFileByBookId(Integer bookId) throws BusinessException {
|
||||
|
||||
if (bookId == 0 || bookId == null) {
|
||||
throw new BusinessException(BusinessErrorCode.PARAMETER_VALIDATION_ERROR, "bookId不能为空");
|
||||
@@ -62,6 +64,25 @@ public class FileServiceImpl implements FileService {
|
||||
return fileModels;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件ID获取文件信息
|
||||
*
|
||||
* @param fileId
|
||||
* @return
|
||||
* @throws BusinessException
|
||||
*/
|
||||
@Override
|
||||
public FileModel getFileById(Integer fileId) throws BusinessException {
|
||||
|
||||
if (fileId == 0 || fileId == null) {
|
||||
throw new BusinessException(BusinessErrorCode.PARAMETER_VALIDATION_ERROR, "fileId不能为空");
|
||||
}
|
||||
|
||||
FileDO fileDO = fileDOMapper.selectByPrimaryKey(fileId);
|
||||
FileModel fileModel = convertFromDataObject(fileDO);
|
||||
return fileModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出所有文件
|
||||
*
|
||||
|
@@ -82,4 +82,15 @@ public interface FileObjectService {
|
||||
* @throws IllegalAccessException
|
||||
*/
|
||||
FileObjectModel getFileObjectById(Integer fileObjectId) throws InvocationTargetException, IllegalAccessException;
|
||||
|
||||
/**
|
||||
* 列出指定文件的所有文件对象
|
||||
*
|
||||
* @param fileId
|
||||
* @return
|
||||
* @throws InvocationTargetException
|
||||
* @throws IllegalAccessException
|
||||
* @throws BusinessException
|
||||
*/
|
||||
List<FileObjectModel> getFileObjectListByFileId(Integer fileId) throws InvocationTargetException, IllegalAccessException, BusinessException;
|
||||
}
|
||||
|
@@ -16,7 +16,16 @@ public interface FileService {
|
||||
* @throws IllegalAccessException
|
||||
* @throws BusinessException
|
||||
*/
|
||||
List<FileModel> getFile(Integer bookId) throws InvocationTargetException, IllegalAccessException, BusinessException;
|
||||
List<FileModel> getFileByBookId(Integer bookId) throws InvocationTargetException, IllegalAccessException, BusinessException;
|
||||
|
||||
/**
|
||||
* 根据文件ID获取文件信息
|
||||
*
|
||||
* @param fileId
|
||||
* @return
|
||||
* @throws BusinessException
|
||||
*/
|
||||
FileModel getFileById(Integer fileId) throws BusinessException;
|
||||
|
||||
/**
|
||||
* 列出所有文件
|
||||
|
@@ -176,6 +176,12 @@
|
||||
WHERE file_id IN (SELECT id AS file_id FROM `file_info` WHERE book_id = 1)
|
||||
AND upload_status = 'SUCCESS'
|
||||
</select>
|
||||
<select id="selectByFileId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM `file_object_info`
|
||||
WHERE file_id = #{fileId}
|
||||
</select>
|
||||
<select id="getLastInsertId" resultType="java.lang.Integer">
|
||||
SELECT LAST_INSERT_ID();
|
||||
</select>
|
||||
|
Reference in New Issue
Block a user