更新数据同步
@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -46,7 +48,7 @@ public class BizFiles implements Serializable {
|
||||
* 文件大小(字节)
|
||||
*/
|
||||
@TableField("file_size")
|
||||
private Long fileSize;
|
||||
private String fileSize;
|
||||
|
||||
/**
|
||||
* 文件类型(如:image/jpeg、application/pdf)
|
||||
@@ -64,7 +66,7 @@ public class BizFiles implements Serializable {
|
||||
* 上传人ID(关联用户表)
|
||||
*/
|
||||
@TableField("creator_id")
|
||||
private Integer creatorId;
|
||||
private String creatorId;
|
||||
|
||||
/**
|
||||
* 上传时间
|
||||
|
||||
@@ -19,7 +19,6 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mini.capi.biz;
|
||||
|
||||
import com.mini.capi.biz.domain.BizFileFolders;
|
||||
import com.mini.capi.biz.domain.BizFiles;
|
||||
import com.mini.capi.biz.domain.BizHomeUser;
|
||||
import com.mini.capi.biz.domain.BizSubTask;
|
||||
import com.mini.capi.biz.service.BizFileFoldersService;
|
||||
import com.mini.capi.biz.service.BizFilesService;
|
||||
@@ -12,6 +13,7 @@ import com.mini.capi.model.info.TodoHandleDTO;
|
||||
import com.mini.capi.utils.FileUtils;
|
||||
import com.mini.capi.utils.vId;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -89,10 +91,10 @@ public class workController {
|
||||
|
||||
|
||||
@PostMapping("uploadFiles")
|
||||
public ResponseEntity<Map<String, Object>> uploadFiles(
|
||||
@RequestParam(value = "folderId") String folderId,
|
||||
@RequestParam("files") MultipartFile[] files) {
|
||||
// 响应结果集
|
||||
public ResponseEntity<Map<String, Object>> uploadFiles(HttpSession session,
|
||||
@RequestParam(value = "folderId") String folderId,
|
||||
@RequestParam("files") MultipartFile[] files) {
|
||||
BizHomeUser user = (BizHomeUser) session.getAttribute("currentUser");
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Path basePath = Paths.get(UPLOAD_PATH + folderId);
|
||||
FileUtils.checkDirExists(basePath.toString());
|
||||
@@ -115,10 +117,10 @@ public class workController {
|
||||
file.transferTo(filePath.toFile());
|
||||
bizFiles.setFileName(originalFilename);
|
||||
bizFiles.setFolderId(folderId);
|
||||
bizFiles.setFileSize(file.getSize());
|
||||
bizFiles.setFileSize(FileUtils.formatFileSize(file.getSize()));
|
||||
bizFiles.setFileType(fileType);
|
||||
bizFiles.setFilePath(filePath.toString());
|
||||
bizFiles.setCreatorId(0);
|
||||
bizFiles.setCreatorId(user.getUserId());
|
||||
bizFiles.setIsDeleted(0);
|
||||
bizFilesService.save(bizFiles);
|
||||
successCount++;
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
package com.mini.capi.utils;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FileUtils {
|
||||
|
||||
// 附件根目录(需求指定)
|
||||
public static final String ATTACHMENT_ROOT_DIR = "/ogsapp/mailFiles";
|
||||
|
||||
/**
|
||||
* 检查目录是否存在,不存在则创建
|
||||
*/
|
||||
@@ -41,7 +34,6 @@ public class FileUtils {
|
||||
try (OutputStream os = new FileOutputStream(savePath);
|
||||
BufferedInputStream bis = new BufferedInputStream(inputStream);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(os)) {
|
||||
|
||||
byte[] buffer = new byte[1024 * 8];
|
||||
int len;
|
||||
while ((len = bis.read(buffer)) != -1) {
|
||||
@@ -53,23 +45,6 @@ public class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成32位随机文件名(UUID去掉横线)+ 原始文件后缀
|
||||
*
|
||||
* @param originalFileName 原始文件名
|
||||
* @return 32位随机文件名(如:a1b2c3d4...1234.txt)
|
||||
*/
|
||||
public static String generate32RandomFileName(String originalFileName) {
|
||||
// 获取文件后缀(如.txt)
|
||||
String suffix = "";
|
||||
if (StringUtils.hasText(originalFileName) && originalFileName.contains(".")) {
|
||||
suffix = originalFileName.substring(originalFileName.lastIndexOf("."));
|
||||
}
|
||||
// 生成32位UUID(去掉横线)
|
||||
String random32Str = UUID.randomUUID().toString().replace("-", "");
|
||||
return random32Str + suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件大小(字节)
|
||||
*/
|
||||
|
||||
BIN
src/main/resources/static/images/docx.png
Normal file
|
After Width: | Height: | Size: 9.7 KiB |
BIN
src/main/resources/static/images/gz.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
src/main/resources/static/images/pdf.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
src/main/resources/static/images/pptx.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
src/main/resources/static/images/py.png
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
src/main/resources/static/images/sql.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
src/main/resources/static/images/wps.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
src/main/resources/static/images/xlsx.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
src/main/resources/static/images/zip.png
Normal file
|
After Width: | Height: | Size: 8.0 KiB |
@@ -203,8 +203,9 @@
|
||||
th:each="file : ${files}">
|
||||
<!-- 文件图标与信息区域 -->
|
||||
<div class="flex items-start mb-3">
|
||||
<img src="https://p3-doubao-search-sign.byteimg.com/labis/fc16ba2cc6e083aacff2c3629bd48364~tplv-be4g95zd3a-image.jpeg?rk3s=542c0f93&x-expires=1779099593&x-signature=ZOIIEOF4OonT%2B1U3qJMy0ggfOwM%3D"
|
||||
alt="文档" class="file-icon mr-3">
|
||||
<img th:src="@{/images/{type}.png(type=${file.getFileType()})}"
|
||||
alt="文档"
|
||||
class="file-icon mr-3">
|
||||
<div class="flex-grow min-w-0">
|
||||
<h3 class="font-medium text-gray-800 w-full whitespace-nowrap overflow-hidden text-ellipsis px-1"
|
||||
th:text="${file.getFileName()}"
|
||||
|
||||