mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-09-01 22:53:29 +08:00
添加文件修改日期字段;前端列表小调整
This commit is contained in:
@@ -43,7 +43,7 @@
|
||||
console.log(element);
|
||||
renderData.push({
|
||||
编号: `${element.id}`,
|
||||
关联书籍: `<span class="overflow-omit" style="margin: 0 auto;">
|
||||
关联书籍: element.bookId === 0 ? "未关联书籍" : `<span class="overflow-omit" style="margin: 0 auto;">
|
||||
ID: ${element.bookId}
|
||||
<a href="/book?id=${element.bookId}">查看</a>
|
||||
<a href="/dashboard/admin/book-manage/detail?id=${element.bookId}">修改</a>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<style>
|
||||
/* 限制 哈希 列的宽度 */
|
||||
tr>*:nth-child(7),
|
||||
td>*:nth-child(7) {
|
||||
tr>*:nth-child(8),
|
||||
td>*:nth-child(8) {
|
||||
max-width: 100px;
|
||||
}
|
||||
</style>
|
||||
@@ -33,18 +33,23 @@
|
||||
编号: `${element.id}`,
|
||||
关联文件: `<span class="overflow-omit" style="margin: 0 auto;">
|
||||
ID: ${element.fileId}
|
||||
<a href="<%= pageUrl %>../detail?id=${element.bookId}">查看</a>
|
||||
<a href="<%= pageUrl %>../detail?id=${element.fileId}">查看</a>
|
||||
</span>`,
|
||||
文件名: `${element.fileName}`,
|
||||
格式: `${element.fileType}`,
|
||||
修改日期: 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}
|
||||
</nobr></span>`,
|
||||
// 文件密码: `${element.filePwd}`,
|
||||
// 提取码: `${element.fileShareCode}`,
|
||||
存储介质: `${element.storageMediumType}`,
|
||||
"哈希(双击全选)": `<span class="overflow-omit" style="font-size: 10px;">${element.fileSha1}</span>`,
|
||||
存储介质: `<span class="overflow-omit" style="font-size: 12px; line-height: 1.2em; display: block;"><nobr>
|
||||
${element.storageMediumType}
|
||||
</nobr></span>`,
|
||||
"哈希(双击全选)": `<span class="overflow-omit" style="font-size: 10px;">${element.fileSha1 ? element.fileSha1 : "未知"}</span>`,
|
||||
状态: `${(element.uploadStatus ? element.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>")
|
||||
|
@@ -104,6 +104,7 @@
|
||||
文件扩展名:<span id="file-ext"></span><br>
|
||||
文件名(不含扩展名):<span id="file-name-no-ext"></span><br>
|
||||
文件大小: <span id="file-size"></span><br>
|
||||
修改日期: <span id="file-lastModified"></span><br>
|
||||
文件SHA1: <span id="file-sha1"></span><br>
|
||||
</p>
|
||||
<p>计算文件哈希进度</p>
|
||||
@@ -135,6 +136,7 @@
|
||||
fileName: "",
|
||||
fileSize: 0,
|
||||
fileType: "",
|
||||
lastModified: "",
|
||||
fileSha1: "",
|
||||
fileExt: "",
|
||||
fileNameWithoutExt: "",
|
||||
@@ -196,6 +198,7 @@
|
||||
fileInfo.fileName = file.name;
|
||||
fileInfo.fileSize = file.size;
|
||||
fileInfo.fileType = file.type;
|
||||
fileInfo.lastModified = file.lastModified;
|
||||
// 获取文件扩展名:首先按照 . 拆分,然后删掉第一个元素(考虑无扩展名文件),再取出最后一个元素
|
||||
let fileNameSplit = file.name.split(".");
|
||||
fileNameSplit.shift();
|
||||
@@ -208,6 +211,7 @@
|
||||
document.getElementById("file-ext").innerHTML = fileInfo.fileExt;
|
||||
document.getElementById("file-name-no-ext").innerHTML = fileInfo.fileNameWithoutExt;
|
||||
document.getElementById("file-size").innerHTML = sOutput;
|
||||
document.getElementById("file-lastModified").innerHTML = new Date(fileInfo.lastModified).toISOString().replace(/T/, ' ').replace(/\..+/, '');
|
||||
|
||||
// 计算文件哈希
|
||||
let sha1 = await sha1File(file, (file) => {
|
||||
@@ -354,6 +358,7 @@
|
||||
fileName: fileInfo.fileNameWithoutExt,
|
||||
fileSize: fileInfo.fileSize,
|
||||
// fileType: fileInfo.fileType,
|
||||
lastModified: fileInfo.lastModified,
|
||||
fileSha1: fileInfo.fileSha1,
|
||||
fileExt: fileInfo.fileExt,
|
||||
fileId: $("#fileAssociator").val() // 关联的文件ID,创建新文件则为0
|
||||
|
@@ -50,9 +50,6 @@ public class FileController extends BaseController {
|
||||
@Autowired
|
||||
FileObjectServiceImpl fileObjectService;
|
||||
|
||||
// @Autowired
|
||||
// ScheduleTaskServiceImpl scheduleTaskService;
|
||||
|
||||
@ApiOperation(value = "【管理员】查询文件列表", notes = "查询文件列表")
|
||||
@RequestMapping(value = "list", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
|
||||
@ResponseBody
|
||||
@@ -131,6 +128,7 @@ public class FileController extends BaseController {
|
||||
// 以下为 PUT 请求必传参数
|
||||
@RequestParam(value = "fileSize", required = false) Long fileSize,
|
||||
// @RequestParam(value = "fileType", required = false) String fileType,
|
||||
@RequestParam(value = "lastModified", required = false) Long lastModified,
|
||||
@RequestParam(value = "fileSha1", required = false) String fileSha1,
|
||||
@RequestParam(value = "fileExt", required = false) String fileExt,
|
||||
@RequestParam(value = "fileId", required = false) Integer fileId // 关联的文件ID,创建新文件则为0
|
||||
@@ -168,7 +166,7 @@ public class FileController extends BaseController {
|
||||
if (isExist) throw new BusinessException(BusinessErrorCode.PARAMETER_VALIDATION_ERROR, "文件已存在");
|
||||
|
||||
fileObjectService.uploadFile(fileId, fileName, bookSaveFolder + fileName, fileSize,
|
||||
fileSha1, fileExt, fileName, FileStorageMediumEnum.QCLOUD_COS, "");
|
||||
fileSha1, fileExt, fileName, FileStorageMediumEnum.QCLOUD_COS, "", lastModified);
|
||||
break;
|
||||
case GET:
|
||||
if (!isExist) throw new BusinessException(BusinessErrorCode.PARAMETER_VALIDATION_ERROR, "文件不存在");
|
||||
@@ -190,6 +188,7 @@ public class FileController extends BaseController {
|
||||
|
||||
/**
|
||||
* 腾讯云 COS 文件上传成功回调方法
|
||||
*
|
||||
* @param eventStr
|
||||
* @param contextStr
|
||||
* @return
|
||||
|
@@ -33,6 +33,9 @@ public class FileObjectVO {
|
||||
// 文件提取码
|
||||
String fileShareCode;
|
||||
|
||||
// 文件最后修改时间戳
|
||||
Long lastModified;
|
||||
|
||||
// 文件上传状态
|
||||
String uploadStatus;
|
||||
|
||||
|
@@ -100,6 +100,15 @@ public class FileObjectDO {
|
||||
*/
|
||||
private String fileSha1;
|
||||
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
* This field corresponds to the database column file_object_info.last_modified
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
private Long lastModified;
|
||||
|
||||
/**
|
||||
*
|
||||
* This field was generated by MyBatis Generator.
|
||||
@@ -373,6 +382,30 @@ public class FileObjectDO {
|
||||
this.fileSha1 = fileSha1 == null ? null : fileSha1.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method returns the value of the database column file_object_info.last_modified
|
||||
*
|
||||
* @return the value of file_object_info.last_modified
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public Long getLastModified() {
|
||||
return lastModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method sets the value of the database column file_object_info.last_modified
|
||||
*
|
||||
* @param lastModified the value for file_object_info.last_modified
|
||||
*
|
||||
* @mbg.generated
|
||||
*/
|
||||
public void setLastModified(Long lastModified) {
|
||||
this.lastModified = lastModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method was generated by MyBatis Generator.
|
||||
* This method returns the value of the database column file_object_info.additional_fields
|
||||
|
@@ -107,7 +107,7 @@ public class FileObjectServiceImpl implements FileObjectService {
|
||||
@Transactional
|
||||
public Boolean uploadFile(Integer fileId, String fileName, String filePath, Long fileSize, String fileSHA1,
|
||||
String fileExt, String fileNameWithoutExt, FileStorageMediumEnum fileStorageMediumEnum,
|
||||
String bookOrigin
|
||||
String bookOrigin, Long lastModified
|
||||
) throws InvocationTargetException, IllegalAccessException, BusinessException {
|
||||
|
||||
if (fileId == 0) {
|
||||
@@ -153,6 +153,7 @@ public class FileObjectServiceImpl implements FileObjectService {
|
||||
fileObjectModel.setFilePath(filePath);
|
||||
fileObjectModel.setFileSha1(fileSHA1);
|
||||
fileObjectModel.setUploadStatus("UPLOADING");
|
||||
fileObjectModel.setLastModified(lastModified);
|
||||
|
||||
// 其余使用默认设置
|
||||
fileObjectModel.setFilePwd("");
|
||||
|
@@ -33,6 +33,9 @@ public class FileObjectModel {
|
||||
// 文件提取码
|
||||
String fileShareCode;
|
||||
|
||||
// 文件最后修改时间戳
|
||||
Long lastModified;
|
||||
|
||||
// 文件上传状态
|
||||
String uploadStatus;
|
||||
|
||||
|
@@ -45,7 +45,7 @@ public interface FileObjectService {
|
||||
* @throws BusinessException
|
||||
*/
|
||||
@Transactional
|
||||
Boolean uploadFile(Integer fileId, String fileName, String filePath, Long fileSize, String fileSHA1, String fileExt, String fileNameWithoutExt, FileStorageMediumEnum fileStorageMediumEnum, String bookOrigin) throws InvocationTargetException, IllegalAccessException, BusinessException;
|
||||
Boolean uploadFile(Integer fileId, String fileName, String filePath, Long fileSize, String fileSHA1, String fileExt, String fileNameWithoutExt, FileStorageMediumEnum fileStorageMediumEnum, String bookOrigin, Long lastModified) throws InvocationTargetException, IllegalAccessException, BusinessException;
|
||||
|
||||
/**
|
||||
* 修改文件对象上传状态信息
|
||||
|
@@ -17,6 +17,7 @@
|
||||
<result column="file_share_code" jdbcType="VARCHAR" property="fileShareCode" />
|
||||
<result column="upload_status" jdbcType="VARCHAR" property="uploadStatus" />
|
||||
<result column="file_sha1" jdbcType="VARCHAR" property="fileSha1" />
|
||||
<result column="last_modified" jdbcType="BIGINT" property="lastModified" />
|
||||
<result column="additional_fields" jdbcType="VARCHAR" property="additionalFields" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
@@ -25,7 +26,7 @@
|
||||
This element is automatically generated by MyBatis Generator, do not modify.
|
||||
-->
|
||||
id, file_id, file_name, file_size, file_type, storage_medium_type, file_path, file_pwd,
|
||||
file_share_code, upload_status, file_sha1, additional_fields
|
||||
file_share_code, upload_status, file_sha1, last_modified, additional_fields
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
<!--
|
||||
@@ -53,13 +54,13 @@
|
||||
insert into file_object_info (id, file_id, file_name,
|
||||
file_size, file_type, storage_medium_type,
|
||||
file_path, file_pwd, file_share_code,
|
||||
upload_status, file_sha1, additional_fields
|
||||
)
|
||||
upload_status, file_sha1, last_modified,
|
||||
additional_fields)
|
||||
values (#{id,jdbcType=INTEGER}, #{fileId,jdbcType=INTEGER}, #{fileName,jdbcType=VARCHAR},
|
||||
#{fileSize,jdbcType=BIGINT}, #{fileType,jdbcType=VARCHAR}, #{storageMediumType,jdbcType=VARCHAR},
|
||||
#{filePath,jdbcType=VARCHAR}, #{filePwd,jdbcType=VARCHAR}, #{fileShareCode,jdbcType=VARCHAR},
|
||||
#{uploadStatus,jdbcType=VARCHAR}, #{fileSha1,jdbcType=VARCHAR}, #{additionalFields,jdbcType=VARCHAR}
|
||||
)
|
||||
#{uploadStatus,jdbcType=VARCHAR}, #{fileSha1,jdbcType=VARCHAR}, #{lastModified,jdbcType=BIGINT},
|
||||
#{additionalFields,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="plus.bookshelf.Dao.DO.FileObjectDO">
|
||||
<!--
|
||||
@@ -101,6 +102,9 @@
|
||||
<if test="fileSha1 != null">
|
||||
file_sha1,
|
||||
</if>
|
||||
<if test="lastModified != null">
|
||||
last_modified,
|
||||
</if>
|
||||
<if test="additionalFields != null">
|
||||
additional_fields,
|
||||
</if>
|
||||
@@ -139,6 +143,9 @@
|
||||
<if test="fileSha1 != null">
|
||||
#{fileSha1,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="lastModified != null">
|
||||
#{lastModified,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="additionalFields != null">
|
||||
#{additionalFields,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@@ -181,6 +188,9 @@
|
||||
<if test="fileSha1 != null">
|
||||
file_sha1 = #{fileSha1,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="lastModified != null">
|
||||
last_modified = #{lastModified,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="additionalFields != null">
|
||||
additional_fields = #{additionalFields,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@@ -203,6 +213,7 @@
|
||||
file_share_code = #{fileShareCode,jdbcType=VARCHAR},
|
||||
upload_status = #{uploadStatus,jdbcType=VARCHAR},
|
||||
file_sha1 = #{fileSha1,jdbcType=VARCHAR},
|
||||
last_modified = #{lastModified,jdbcType=BIGINT},
|
||||
additional_fields = #{additionalFields,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
|
Reference in New Issue
Block a user