diff --git a/bonus-base/src/main/java/com/bonus/base/controller/system/SysLoginController.java b/bonus-base/src/main/java/com/bonus/base/controller/system/SysLoginController.java index 1e29231..c4d03b5 100644 --- a/bonus-base/src/main/java/com/bonus/base/controller/system/SysLoginController.java +++ b/bonus-base/src/main/java/com/bonus/base/controller/system/SysLoginController.java @@ -65,7 +65,6 @@ public class SysLoginController String token; String permissions; //权限字符 String username= Sm4Utils.decrypt(loginBody.getUsername()); // 解密 - AjaxResult ajax = AjaxResult.success(); if("2".equals(loginBody.getLoginType())){ token = loginService.login(loginBody.getUsername(), loginBody.getCode()); @@ -102,6 +101,7 @@ public class SysLoginController tokenService.refreshToken(loginUser); } AjaxResult ajax = AjaxResult.success(); + user.setPassword(""); ajax.put("user", user); ajax.put("roles", roles); ajax.put("permissions", permissions); diff --git a/bonus-base/src/main/resources/application.yml b/bonus-base/src/main/resources/application.yml index 7e9d035..7933d36 100644 --- a/bonus-base/src/main/resources/application.yml +++ b/bonus-base/src/main/resources/application.yml @@ -120,7 +120,7 @@ pagehelper: # Swagger配置 swagger: # 是否开启swagger - enabled: true + enabled: false # 请求前缀 pathMapping: /dev-api @@ -140,3 +140,12 @@ minio: accessKey: minio secretKey: bonus@admin123 bucketName: product +management: + server: + port: -1 # 禁用独立管理端口(与业务端口共用) + endpoints: + enabled-by-default: false # 全局禁用所有端点(默认值为 true) + endpoint: + # 即使全局禁用后,若需单独启用某个端点,可在此配置(当前需求为关闭全部,故无需配置) + # 例如:health: + # enabled: true # 单独启用健康检查端点(此处不需要) \ No newline at end of file diff --git a/bonus-business/src/main/java/com/bonus/business/controller/DocumentController.java b/bonus-business/src/main/java/com/bonus/business/controller/DocumentController.java index 1ffb9cb..18ee731 100644 --- a/bonus-business/src/main/java/com/bonus/business/controller/DocumentController.java +++ b/bonus-business/src/main/java/com/bonus/business/controller/DocumentController.java @@ -53,7 +53,7 @@ public class DocumentController extends BaseController { /** - * 新增文件夹 + * 修改文件夹 * @param vo * @return */ diff --git a/bonus-business/src/main/java/com/bonus/business/controller/DocumentScreenController.java b/bonus-business/src/main/java/com/bonus/business/controller/DocumentScreenController.java new file mode 100644 index 0000000..9084d71 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/controller/DocumentScreenController.java @@ -0,0 +1,57 @@ +package com.bonus.business.controller; + +import com.bonus.business.domain.DocumentTreeVo; +import com.bonus.business.domain.TbDocumentFolder; +import com.bonus.business.domain.TbUserFiles; +import com.bonus.business.service.DocumentScreenService; +import com.bonus.common.core.controller.BaseController; +import com.bonus.common.core.domain.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * 文档中心管理 + */ +@RestController +@RequestMapping("/screen/document/") +public class DocumentScreenController extends BaseController { + + @Autowired + private DocumentScreenService service; + + + /** + * 查询文档树 + * @param vo + * @return + */ + @PostMapping("/getDocumentTree") + public AjaxResult getDocumentTree(DocumentTreeVo vo) { + return service.getDocumentTree(vo); + } + + + /** + * 新增文档 + * @param vo + * @return + */ + @PostMapping("/addDocument") + public AjaxResult addDocument(TbDocumentFolder vo) { + return service.addDocument(vo); + } + + /** + * 新增文档 + * @param vo + * @return + */ + @PostMapping("/importFile") + public AjaxResult importFile(@RequestParam(value = "files",required = false) MultipartFile[] file, TbUserFiles vo) { + return service.importFile(file,vo); + } +} diff --git a/bonus-business/src/main/java/com/bonus/business/controller/DownloadController.java b/bonus-business/src/main/java/com/bonus/business/controller/DownloadController.java index 1ae97b7..5007551 100644 --- a/bonus-business/src/main/java/com/bonus/business/controller/DownloadController.java +++ b/bonus-business/src/main/java/com/bonus/business/controller/DownloadController.java @@ -35,6 +35,8 @@ public class DownloadController { @Resource private MinioClient minioClient; + + /** * 下载文件 根据文件名 * @param filePath diff --git a/bonus-business/src/main/java/com/bonus/business/controller/VideoToMp4Converter.java b/bonus-business/src/main/java/com/bonus/business/controller/VideoToMp4Converter.java deleted file mode 100644 index 9598eee..0000000 --- a/bonus-business/src/main/java/com/bonus/business/controller/VideoToMp4Converter.java +++ /dev/null @@ -1,61 +0,0 @@ -//package com.bonus.business.controller; -// -//import org.bytedeco.javacv.FFmpegFrameGrabber; -//import org.bytedeco.javacv.FFmpegFrameRecorder; -//import org.bytedeco.javacv.Frame; -// -//public class VideoToMp4Converter { -// -// /** -// * 将视频文件转换为MP4格式 -// * @param inputPath 输入视频文件路径 -// * @param outputPath 输出MP4文件路径 -// * @throws Exception 转换过程中的异常 -// */ -// public static void convertToMp4(String inputPath, String outputPath) throws Exception { -// // 创建FFmpegFrameGrabber对象,读取输入视频 -// FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(inputPath); -// grabber.start(); -// -// // 创建FFmpegFrameRecorder对象,设置输出视频参数 -// FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(outputPath, -// grabber.getImageWidth(), -// grabber.getImageHeight()); -// -// // 设置视频编码为H.264 -// recorder.setVideoCodec(org.bytedeco.ffmpeg.global.avcodec.AV_CODEC_ID_H264); -// // 设置输出格式为MP4 -// recorder.setFormat("mp4"); -// // 设置帧率与原视频保持一致 -// recorder.setFrameRate(grabber.getFrameRate()); -// // 设置音频通道数 -// recorder.setAudioChannels(grabber.getAudioChannels()); -// // 设置音频编码 -// recorder.setAudioCodec(org.bytedeco.ffmpeg.global.avcodec.AV_CODEC_ID_AAC); -// -// recorder.start(); -// -// // 循环读取视频帧并进行录制 -// Frame frame; -// while ((frame = grabber.grabFrame()) != null) { -// recorder.record(frame); -// } -// -// // 关闭抓取器和录制器 -// recorder.stop(); -// grabber.stop(); -// -// System.out.println("视频转换完成!输出文件:" + outputPath); -// } -// -// // 测试方法 -// public static void main(String[] args) { -// try { -// String inputVideo = "input_video.flv"; // 输入视频文件,可以是任何格式 -// String outputMp4 = "output_video.mp4"; // 输出MP4文件 -// convertToMp4(inputVideo, outputMp4); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } -//} \ No newline at end of file diff --git a/bonus-business/src/main/java/com/bonus/business/domain/DocumentTreeVo.java b/bonus-business/src/main/java/com/bonus/business/domain/DocumentTreeVo.java new file mode 100644 index 0000000..496ec36 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/domain/DocumentTreeVo.java @@ -0,0 +1,47 @@ +package com.bonus.business.domain; + +import lombok.Data; + +import java.util.List; + +@Data +public class DocumentTreeVo { + /** + * 主键 + */ + private String id; + /** + * 上级节点id + */ + private String parentId; + /** + * 上级节点ids + */ + private String parentIds; + /** + * 名称 + */ + private String name; + /** + * 类型 + */ + private String type; + /** + * 用户id + */ + private String userId; + /** + * 是否是管理员 + */ + private String isAdmin; + /** + * 权限 + */ + private String auth; + /** + *子集合 + */ + private List childTree; + + +} diff --git a/bonus-business/src/main/java/com/bonus/business/domain/TbDocumentFolder.java b/bonus-business/src/main/java/com/bonus/business/domain/TbDocumentFolder.java index bb082a8..2974d3a 100644 --- a/bonus-business/src/main/java/com/bonus/business/domain/TbDocumentFolder.java +++ b/bonus-business/src/main/java/com/bonus/business/domain/TbDocumentFolder.java @@ -64,6 +64,10 @@ public class TbDocumentFolder extends BaseEntity * 备注 */ private String remark; + + private String type; + + private String userId; /** * 权限集合 */ diff --git a/bonus-business/src/main/java/com/bonus/business/domain/TbUserFiles.java b/bonus-business/src/main/java/com/bonus/business/domain/TbUserFiles.java index f2436a4..b8f48e5 100644 --- a/bonus-business/src/main/java/com/bonus/business/domain/TbUserFiles.java +++ b/bonus-business/src/main/java/com/bonus/business/domain/TbUserFiles.java @@ -4,6 +4,7 @@ import java.util.Date; import com.bonus.common.core.domain.BaseEntity; import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.bonus.common.annotation.Excel; @@ -14,16 +15,17 @@ import com.bonus.common.annotation.Excel; * @author 黑子 * @date 2025-09-10 */ +@Data public class TbUserFiles extends BaseEntity { private static final long serialVersionUID = 1L; /** 主键 */ - private Long id; + private String id; /** 文件夹id */ @Excel(name = "文件夹id") - private Long folderId; + private String folderId; /** 源文件名称 */ @Excel(name = "源文件名称") @@ -55,181 +57,49 @@ public class TbUserFiles extends BaseEntity /** 上传时间 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "上传时间", width = 30, dateFormat = "yyyy-MM-dd") - private Date uploadTime; + private String uploadTime; /** 上传人 */ @Excel(name = "上传人") - private Long uploadUser; + private String uploadUser; /** 下载次数 */ @Excel(name = "下载次数") - private Long downTimes; + private int downTimes; /** 预览次数 */ @Excel(name = "预览次数") - private Long seeTimes; + private int seeTimes; /** 文档标签 */ @Excel(name = "文档标签") private String labels; - public void setId(Long id) - { - this.id = id; - } + /** + * 桶名称 + */ + private String bucketName; + /** + * 创建人 + */ + private String createUser; + /** + * 数据类型 + */ + private String type; + /** + * 文件夹副节点集合 + */ + private String parentIds; + /** + * 标签数据id + */ + private String labelIds; + /** + * 重复的是否跳过 1跳过 2 覆盖 + */ + private String repeatType; - public Long getId() - { - return id; - } - public void setFolderId(Long folderId) - { - this.folderId = folderId; - } - public Long getFolderId() - { - return folderId; - } - - public void setOriginalName(String originalName) - { - this.originalName = originalName; - } - - public String getOriginalName() - { - return originalName; - } - - public void setFileSuffix(String fileSuffix) - { - this.fileSuffix = fileSuffix; - } - - public String getFileSuffix() - { - return fileSuffix; - } - - public void setFileSize(String fileSize) - { - this.fileSize = fileSize; - } - - public String getFileSize() - { - return fileSize; - } - - public void setFilePath(String filePath) - { - this.filePath = filePath; - } - - public String getFilePath() - { - return filePath; - } - - public void setFileName(String fileName) - { - this.fileName = fileName; - } - - public String getFileName() - { - return fileName; - } - - public void setFileUrl(String fileUrl) - { - this.fileUrl = fileUrl; - } - - public String getFileUrl() - { - return fileUrl; - } - - public void setDelFlag(String delFlag) - { - this.delFlag = delFlag; - } - - public String getDelFlag() - { - return delFlag; - } - - public void setUploadTime(Date uploadTime) - { - this.uploadTime = uploadTime; - } - - public Date getUploadTime() - { - return uploadTime; - } - - public void setUploadUser(Long uploadUser) - { - this.uploadUser = uploadUser; - } - - public Long getUploadUser() - { - return uploadUser; - } - - public void setDownTimes(Long downTimes) - { - this.downTimes = downTimes; - } - - public Long getDownTimes() - { - return downTimes; - } - - public void setSeeTimes(Long seeTimes) - { - this.seeTimes = seeTimes; - } - - public Long getSeeTimes() - { - return seeTimes; - } - - public void setLabels(String labels) - { - this.labels = labels; - } - - public String getLabels() - { - return labels; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("folderId", getFolderId()) - .append("originalName", getOriginalName()) - .append("fileSuffix", getFileSuffix()) - .append("fileSize", getFileSize()) - .append("filePath", getFilePath()) - .append("fileName", getFileName()) - .append("fileUrl", getFileUrl()) - .append("delFlag", getDelFlag()) - .append("uploadTime", getUploadTime()) - .append("uploadUser", getUploadUser()) - .append("downTimes", getDownTimes()) - .append("seeTimes", getSeeTimes()) - .append("labels", getLabels()) - .toString(); - } } diff --git a/bonus-business/src/main/java/com/bonus/business/domain/TbUserLabel.java b/bonus-business/src/main/java/com/bonus/business/domain/TbUserLabel.java new file mode 100644 index 0000000..a5d16f2 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/domain/TbUserLabel.java @@ -0,0 +1,31 @@ +package com.bonus.business.domain; + +import com.bonus.common.core.domain.BaseEntity; +import lombok.Data; +import com.bonus.common.annotation.Excel; +import lombok.EqualsAndHashCode; + +/** + * 个人文档标签记录对象 tb_user_lable + * + * @author 黑子 + * @date 2025-09-10 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class TbUserLabel extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 文件id */ + private String fileId; + + /** 标签id */ + private String labelId; + + /** 标签名称 */ + @Excel(name = "标签名称") + private String labelName; + + +} diff --git a/bonus-business/src/main/java/com/bonus/business/domain/TbUserLable.java b/bonus-business/src/main/java/com/bonus/business/domain/TbUserLable.java deleted file mode 100644 index adc1ce0..0000000 --- a/bonus-business/src/main/java/com/bonus/business/domain/TbUserLable.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.bonus.business.domain; - -import com.bonus.common.core.domain.BaseEntity; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.bonus.common.annotation.Excel; - -/** - * 个人文档标签记录对象 tb_user_lable - * - * @author 黑子 - * @date 2025-09-10 - */ -public class TbUserLable extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 文件id */ - private Long fileId; - - /** 标签id */ - private Long lableId; - - /** 标签名称 */ - @Excel(name = "标签名称") - private String lableName; - - public void setFileId(Long fileId) - { - this.fileId = fileId; - } - - public Long getFileId() - { - return fileId; - } - - public void setLableId(Long lableId) - { - this.lableId = lableId; - } - - public Long getLableId() - { - return lableId; - } - - public void setLableName(String lableName) - { - this.lableName = lableName; - } - - public String getLableName() - { - return lableName; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("fileId", getFileId()) - .append("lableId", getLableId()) - .append("lableName", getLableName()) - .toString(); - } -} diff --git a/bonus-business/src/main/java/com/bonus/business/domain/TreeBuild.java b/bonus-business/src/main/java/com/bonus/business/domain/TreeBuild.java new file mode 100644 index 0000000..ec00d3d --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/domain/TreeBuild.java @@ -0,0 +1,77 @@ +package com.bonus.business.domain; + +import java.util.ArrayList; +import java.util.List; + +/** + * BuildTree 构建树形结构 + */ +public class TreeBuild { + + // 保存参与构建树形的所有数据(通常数据库查询结果) + public List nodeList = new ArrayList<>(); + + /** + * 构造方法 + * @param nodeList 将数据集合赋值给nodeList,即所有数据作为所有节点。 + */ + public TreeBuild(List nodeList){ + this.nodeList = nodeList; + } + + /** + * 获取需构建的所有根节点(顶级节点) "0" + * @return 所有根节点List集合 + */ + public List getRootNode(String parentId){ + // 保存所有根节点(所有根节点的数据) + List rootNodeList = new ArrayList<>(); + // treeNode:查询出的每一条数据(节点) + for (DocumentTreeVo treeNode : nodeList){ + // 判断当前节点是否为根节点,此处注意:若parentId类型是String,则要采用equals()方法判断。 + if (parentId.equals(treeNode.getParentId()) ) { + // 是,添加 + rootNodeList.add(treeNode); + } + } + return rootNodeList; + } + + /** + * 根据每一个顶级节点(根节点)进行构建树形结构 + * @return 构建整棵树 + */ + public List buildTree(String parentId){ + // treeNodes:保存一个顶级节点所构建出来的完整树形 + List treeNodes = new ArrayList(); + // getRootNode():获取所有的根节点 + for (DocumentTreeVo treeRootNode : getRootNode(parentId)) { + // 将顶级节点进行构建子树 + treeRootNode = buildChildTree(treeRootNode); + // 完成一个顶级节点所构建的树形,增加进来 + treeNodes.add(treeRootNode); + } + return treeNodes; + } + + /** + * 递归-----构建子树形结构 + * @param pNode 根节点(顶级节点) + * @return 整棵树 + */ + public DocumentTreeVo buildChildTree(DocumentTreeVo pNode){ + List childTree = new ArrayList(); + // nodeList:所有节点集合(所有数据) + for (DocumentTreeVo treeNode : nodeList) { + // 判断当前节点的父节点ID是否等于根节点的ID,即当前节点为其下的子节点 + if (treeNode.getParentId().equals(pNode.getId())) { + // 再递归进行判断当前节点的情况,调用自身方法 + childTree.add(buildChildTree(treeNode)); + } + } + // for循环结束,即节点下没有任何节点,树形构建结束,设置树结果 + pNode.setChildTree(childTree); + return pNode; + } + +} \ No newline at end of file diff --git a/bonus-business/src/main/java/com/bonus/business/mapper/DocumentScreenMapper.java b/bonus-business/src/main/java/com/bonus/business/mapper/DocumentScreenMapper.java new file mode 100644 index 0000000..203891a --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/mapper/DocumentScreenMapper.java @@ -0,0 +1,109 @@ +package com.bonus.business.mapper; + +import com.bonus.business.domain.*; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.security.core.parameters.P; + +import java.util.List; + +@Mapper +public interface DocumentScreenMapper { + + /** + * 查询文档库数据 + * @param vo + * @return + */ + List getCompanyChildList(DocumentTreeVo vo); + + /** + * 查询每个人自己的文档数据 + * @param vo + * @return + */ + List getMyChildList(DocumentTreeVo vo); + + /** + * 查询其他人共享给我的 + * @param vo + * @return + */ + List getOtherShare(DocumentTreeVo vo); + + /** + * 查询我分享出去的文档 + * @param vo + * @return + */ + List getMyShareList(DocumentTreeVo vo); + + /** + * 查询全部数据 + * @param vo + * @return + */ + List getDocumentList(DocumentTreeVo vo); + + /** + * 新增公司文档 + * @param vo + */ + Integer addDocumentCompany(TbDocumentFolder vo); + + /** + * 新增文件夹权限数据 + * @param auth + */ + void addDocumentAuth(TbDocumentFolderAuth auth); + + /** + * 新增个人文档文件夹 + * @param vo + */ + void addDocumentUser(TbDocumentFolder vo); + + /** + * 插入图片-个人 + * @param productCaseImage + */ + void insertUserFile(TbUserFiles productCaseImage); + + /** + * 插入文档-公司 + * @param productCaseImage + */ + void insertCompanyFile(TbUserFiles productCaseImage); + + /** + * + * @param list + * @param id + */ + void addFileLabel(@Param("list") List list, @Param("id") String id); + + /** + * 文件标签 + * @param list + * @param id + */ + void addUserFileLabel(List list, String id); + + /** + * 查询文件夹下存在的文件 + * @param vo + * @return + */ + List getCompanyFileList(TbUserFiles vo); + + /** + * 查询个人文件数据集合 + * @param vo + * @return + */ + List getUserFileList(TbUserFiles vo); + + void deleteCompanyFile(@Param("list") List delete); + + void deleteUserFile(@Param("list")List delete); +} diff --git a/bonus-business/src/main/java/com/bonus/business/service/DocumentScreenService.java b/bonus-business/src/main/java/com/bonus/business/service/DocumentScreenService.java new file mode 100644 index 0000000..ca2aa59 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/service/DocumentScreenService.java @@ -0,0 +1,31 @@ +package com.bonus.business.service; + +import com.bonus.business.domain.DocumentTreeVo; +import com.bonus.business.domain.TbDocumentFolder; +import com.bonus.business.domain.TbUserFiles; +import com.bonus.common.core.domain.AjaxResult; +import org.springframework.web.multipart.MultipartFile; + +public interface DocumentScreenService { + /** + * 查询 文档中心 树 + * @param vo + * @return + */ + AjaxResult getDocumentTree(DocumentTreeVo vo); + + /** + * 新增文档 + * @param vo + * @return + */ + AjaxResult addDocument(TbDocumentFolder vo); + + /** + * 文件导入 + * @param file + * @param vo + * @return + */ + AjaxResult importFile(MultipartFile[] file, TbUserFiles vo); +} diff --git a/bonus-business/src/main/java/com/bonus/business/service/impl/DocumentScreenImpl.java b/bonus-business/src/main/java/com/bonus/business/service/impl/DocumentScreenImpl.java new file mode 100644 index 0000000..9032e25 --- /dev/null +++ b/bonus-business/src/main/java/com/bonus/business/service/impl/DocumentScreenImpl.java @@ -0,0 +1,387 @@ +package com.bonus.business.service.impl; + +import cn.hutool.db.handler.StringHandler; +import com.bonus.business.domain.*; +import com.bonus.business.mapper.DocumentScreenMapper; +import com.bonus.business.service.DocumentScreenService; +import com.bonus.common.core.domain.AjaxResult; +import com.bonus.common.utils.DateUtils; +import com.bonus.common.utils.SecurityUtils; +import com.bonus.common.utils.StringUtils; +import com.bonus.file.service.FileUploadService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +@Service +public class DocumentScreenImpl implements DocumentScreenService { + + @Autowired + private DocumentScreenMapper mapper; + + @Autowired + private FileUploadService service; + + public String day= DateUtils.getCurrentDay(); + + public String month=DateUtils.getCurrentMonth(); + + public String year=DateUtils.getCurrentYear(); + /** + * 查询文档中心树 + * @param vo + * @return + */ + @Override + public AjaxResult getDocumentTree(DocumentTreeVo vo) { + List list=new ArrayList<>(); + try{ + String userId= SecurityUtils.getUserId().toString(); + vo.setUserId(userId); + // 是否是管理员 + boolean administrator=SecurityUtils.hasRole("administrator"); + boolean admin=SecurityUtils.hasRole("admin"); + //管理员 + if(administrator || admin){ + vo.setIsAdmin("1"); + }else{ + //查询共享文档 + //个人需要查询 + DocumentTreeVo shareDocument=getShareDocument(vo); + list.add(shareDocument); + } + + //查询我的文档 + DocumentTreeVo myDocument=getMyChildList(vo); + list.add(myDocument); + //查询公共文档数据集合 + DocumentTreeVo companyList=getCompanyChildList(vo); + list.add(companyList); + }catch (Exception e){ + log.error(e.getMessage()); + } + return AjaxResult.success(list); + } + + /** + * 新建文件夹 + * @param vo + * @return + */ + @Override + public AjaxResult addDocument(TbDocumentFolder vo) { + try{ + String userId=SecurityUtils.getUserId().toString(); + vo.setCreateUser(userId); + vo.setUpdateUser(userId); + vo.setId(StringUtils.randomUUID()); + //类型 + String type=vo.getType(); + //文档库 + vo.setParentIds(vo.getParentIds()+","+vo.getParentId()+","); + if("1".equals(type)){ + Integer num= mapper.addDocumentCompany(vo); + if(num!=null && num>0){ + TbDocumentFolderAuth auth=new TbDocumentFolderAuth(); + auth.setFolderId(vo.getId()); + auth.setUserId(userId); + auth.setFolderType("1"); + auth.setFolderSource("0"); + auth.setFolderAuth("4"); + auth.setIsShare("0"); + //新增数据 + mapper.addDocumentAuth(auth); + }else{ + return AjaxResult.error("添加失败"); + } + }else{ + mapper.addDocumentUser(vo); + } + return AjaxResult.success("添加成功"); + }catch (Exception e){ + log.error(e.getMessage()); + } + return AjaxResult.error("添加失败"); + } + + /** + * 导入文件 + * @param file + * @param vo + * @return + */ + @Override + public AjaxResult importFile(MultipartFile[] file, TbUserFiles vo) { + try{ + if(file==null ||file.length==0){ + return AjaxResult.error("请上传附件"); + } + if(StringUtils.isEmpty(vo.getFolderId())){ + return AjaxResult.error("选择文件夹"); + } + if(StringUtils.isEmpty(vo.getType())){ + return AjaxResult.error("文件夹类型不能为空"); + } + + vo.setUploadUser(SecurityUtils.getUserId().toString()); + vo.setCreateUser(SecurityUtils.getUserId().toString()); + String repeatType=vo.getRepeatType(); + // + List list; + if("1".equals(vo.getType())){ + list=mapper.getCompanyFileList(vo); + }else{ + list=mapper.getUserFileList(vo); + } + List fileList=new ArrayList<>(list.size()); + List delete=new ArrayList<>(); + + //覆盖 覆盖会删除之前的数据 + if("1".equals(repeatType)){ + //跳过 + for (MultipartFile multipartFile : file) { + String originFileName = multipartFile.getOriginalFilename(); + boolean iscz = true; + for (TbUserFiles tbUserFiles : list) { + assert originFileName != null; + if (originFileName.equals(tbUserFiles.getOriginalName())) { + iscz = false; + break; + } + } + if (iscz) { + fileList.add(multipartFile); + } + } + }else{ + //覆盖 + for (MultipartFile multipartFile : file) { + String originFileName = multipartFile.getOriginalFilename(); + for (TbUserFiles tbUserFiles : list) { + fileList.add(multipartFile); + assert originFileName != null; + if (originFileName.equals(tbUserFiles.getOriginalName())) { + delete.add(tbUserFiles); + break; + } + } + } + for (TbUserFiles tbUserFiles : delete) { + //删除文件 + service.delFile(tbUserFiles.getFilePath()); + } + //个人及公司 + if("1".equals(vo.getType())){ + mapper.deleteCompanyFile(delete); + }else{ + mapper.deleteUserFile(delete); + } + } + + // 文件上传 + AjaxResult result=uploadFile(fileList,vo); + if(result.isError()){ + return result; + } + return AjaxResult.success("上传成功"); + }catch (Exception e){ + log.error(e.getMessage()); + } + return AjaxResult.error("文件上传失败"); + } + /** + * 上传附件 + * @param + * @return + */ + public AjaxResult uploadFile(List multipartFileList,TbUserFiles files){ + String type=files.getType(); + String filePath ; + if("1".equals(type)){ + filePath = "document/company/"+files.getUploadUser() + "/" + + year + "/" + month + "/" + day + "/" ; + }else{ + filePath = "document/user/" + files.getUploadUser()+"/" + + year + "/" + month + "/" + day + "/" ; + } + String[] ids=files.getLabelIds().split(","); + String[] name= files.getLabels().split(","); + List list=new ArrayList(); + TbUserLabel vo=new TbUserLabel(); + for (int i = 0; i list=getShareList(vo); + vo1.setChildTree(list); + return vo1; + } + + /** + * 查询共享文档数据集合 + * @param vo + * @return + */ + private List getShareList(DocumentTreeVo vo) { + List allShareList=mapper.getDocumentList(vo); + List list=new ArrayList<>(); + DocumentTreeVo vo1=new DocumentTreeVo(); + vo1.setId("myShare"); + vo1.setParentId("share"); + vo1.setName("我共享的"); + vo1.setType("31"); + //我共享出去的文档查询 + List childerList=getMyShareList(vo,allShareList); + vo1.setChildTree(childerList); + DocumentTreeVo vo2=new DocumentTreeVo(); + vo2.setId("otherShare"); + vo2.setParentId("share"); + vo2.setName("与我共享"); + vo2.setType("32"); + List childList2=getOtherShare(vo,allShareList); + vo2.setChildTree(childList2); + list.add(vo1); + list.add(vo2); + return list; + } + + /** + * 其他人共享给我的 + * @param vo + * @return + */ + private List getOtherShare(DocumentTreeVo vo, List allShareList) { + //查询他人分享的 -数据源是 文档库 + TreeBuild treeBuild = new TreeBuild(allShareList); + List shareList=mapper.getOtherShare(vo); + for(DocumentTreeVo share:allShareList){ + List list=treeBuild.buildTree(share.getId()); + share.setChildTree(list); + } + return shareList; + } + + /** + * 查询分享给我的文件夹 + * @param vo + * @return + */ + private List getMyShareList(DocumentTreeVo vo, List allShareList) { + //查询我共享出去的文件夹及文件 + TreeBuild treeBuild = new TreeBuild(allShareList); + List shareList=mapper.getMyShareList(vo); + for(DocumentTreeVo share:allShareList){ + List list=treeBuild.buildTree(share.getId()); + share.setChildTree(list); + } + return shareList; + } + + /** + * 查询我的文档数据集合1 + * @param vo + * @return + */ + private DocumentTreeVo getMyChildList(DocumentTreeVo vo) { + DocumentTreeVo vo1=new DocumentTreeVo(); + vo1.setId("myDocument"); + vo1.setParentId("0"); + vo1.setName("我的文档"); + vo1.setType("2"); + List childeList=mapper.getMyChildList(vo); + TreeBuild treeBuild = new TreeBuild(childeList); + List list=treeBuild.buildTree("myDocument"); + vo1.setChildTree(list); + return vo1; + + } + + + /** + * 公共服务文档数据集合 + * @param vo + * @return + */ + public DocumentTreeVo getCompanyChildList(DocumentTreeVo vo){ + //查询 文档库集合 + DocumentTreeVo vo1=new DocumentTreeVo(); + vo1.setId("companyDocument"); + vo1.setParentId("0"); + vo1.setName("文档库"); + vo1.setType("1"); + List childeList=mapper.getCompanyChildList(vo); + TreeBuild treeBuild = new TreeBuild(childeList); + List list=treeBuild.buildTree("companyDocument"); + vo1.setChildTree(list); + return vo1; + + } + + + + + + + +} diff --git a/bonus-business/src/main/java/com/bonus/business/service/impl/DocumentServiceImpl.java b/bonus-business/src/main/java/com/bonus/business/service/impl/DocumentServiceImpl.java index 9e57e57..b9eed56 100644 --- a/bonus-business/src/main/java/com/bonus/business/service/impl/DocumentServiceImpl.java +++ b/bonus-business/src/main/java/com/bonus/business/service/impl/DocumentServiceImpl.java @@ -62,10 +62,11 @@ public class DocumentServiceImpl implements DocumentService { } //默认层级 vo.setLevel(1); - vo.setParentId("0"); - vo.setParentIds("0,"); + vo.setParentId("companyDocument"); + vo.setParentIds("companyDocument,"); vo.setCreateUser(SecurityUtils.getUserId().toString()); vo.setUpdateUser(SecurityUtils.getUserId().toString()); + vo.setId(StringUtils.randomUUID()); int num =mapper.addDocument(vo); if(num<1){ return AjaxResult.error("文件夹创建失败"); @@ -130,7 +131,6 @@ public class DocumentServiceImpl implements DocumentService { public AjaxResult getAjaxResult(TbDocumentFolder vo, String userId) { List ids= Arrays.asList(userId.split(",")); - int addIds= mapper.addDocumentAuth(ids,vo.getId()); if(addIds!=ids.size()){ return AjaxResult.error("文件夹授权失败"); diff --git a/bonus-business/src/main/java/com/bonus/business/service/impl/ProductServiceImpl.java b/bonus-business/src/main/java/com/bonus/business/service/impl/ProductServiceImpl.java index e16f9a6..068bdc1 100644 --- a/bonus-business/src/main/java/com/bonus/business/service/impl/ProductServiceImpl.java +++ b/bonus-business/src/main/java/com/bonus/business/service/impl/ProductServiceImpl.java @@ -48,7 +48,7 @@ public class ProductServiceImpl implements ProductService { public FileServiceUtils fileServiceUtils; - public String day= DateUtils.getCurrentYear(); + public String day= DateUtils.getCurrentDay(); public String month=DateUtils.getCurrentMonth(); diff --git a/bonus-business/src/main/resources/mapper/business/DocumentMappper.xml b/bonus-business/src/main/resources/mapper/business/DocumentMappper.xml index 4f2573f..7368c9d 100644 --- a/bonus-business/src/main/resources/mapper/business/DocumentMappper.xml +++ b/bonus-business/src/main/resources/mapper/business/DocumentMappper.xml @@ -5,23 +5,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - insert into tb_document_folder( + insert into tb_document_folder(id, level,folder_name,parent_id, create_time, create_user, update_time,update_user, file_type, del_flag,parent_ids - )values (#{level},#{folderName},#{parentId},now(),#{createUser},now(),#{updateUser},#{fileType},0,#{parentIds}) + )values (#{id},#{level},#{folderName},#{parentId},now(),#{createUser},now(),#{updateUser},#{fileType},0,#{parentIds}) insert into tb_document_folder(folder_id, user_id,folder_type, folder_source, folder_auth, is_share) value - #{id},#{item},0,1,0,1, + #{id},#{item},0,4,2,0 update tb_document_folder set folder_name=#{folderName},update_time=#{updateTime} ,update_user=#{updateUser} where id=#{id} - where - delete from tb_document_folder_auth WHERE folder_id=#{id} @@ -43,7 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" su.user_name createUser from tb_document_folder tdf left join sys_user su on su.user_id=tdf.create_user - where tdf.parent_id=0 and tdf.del_flag=0 + where tdf.parent_id='companyDocument' and tdf.del_flag=0 and tdf.folder_name like concat('%',#{folderName},'%') @@ -69,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" \ No newline at end of file diff --git a/bonus-business/src/main/resources/mapper/business/DocumentScreenMapper.xml b/bonus-business/src/main/resources/mapper/business/DocumentScreenMapper.xml new file mode 100644 index 0000000..f7d5e07 --- /dev/null +++ b/bonus-business/src/main/resources/mapper/business/DocumentScreenMapper.xml @@ -0,0 +1,136 @@ + + + + + insert into tb_document_folder(id, + level,folder_name,parent_id, create_time, create_user, update_time,update_user, file_type, del_flag,parent_ids + )values (#{id},#{level},#{folderName},#{parentId},now(),#{createUser},now(),#{updateUser},#{fileType},0,#{parentIds}) + + + + insert into tb_document_folder_auth( + folder_id, user_id,folder_type,folder_source,folder_auth,is_share + )values (#{folderId},#{userId},#{folderType},#{folderSource},#{folderAuth},#{isShare} ) + + + + insert into tb_user_folder( + id,parent_id, level, folder_name, + create_user, create_time, is_share, del_flag,update_time, + update_user, parent_ids, + )values (#{id},#{parentId},#{level},#{folderName},#{userId},now(),0,0,now(),#{userId},#{parentIds}) + + + INSERT INTO tb_user_files( + folder_id,original_name,file_suffix,file_size, + file_path,file_name,del_flag,upload_time,upload_user, + down_times,see_times,labels,parent_ids + )values (#{folderId},#{originalName},#{fileSuffix},#{fileSize},#{filePath},#{fileName}, + #{delFlag},now(),#{uploadUser},#{downTimes},#{seeTimes},#{labels},#{parentIds}) + + + + insert into tb_document_files( + folder_id, folder_ids, original_name, + file_suffix, file_size, file_path, file_name, upload_time, + upload_user, down_times, see_times, labels, del_flag + )values (#{folderId},#{parentIds},#{originalName},#{fileSuffix}, + #{fileSize},#{filePath},#{fileName},now(),#{uploadUser},#{downTimes},#{seeTimes},#{labels},#{delFlag}) + + + + insert into tb_document_files_label( file_id, label_id, label_name)values ( + + #{id},#{item.labelId},#{item.labelName} + + ) + + + insert into tb_user_label(file_id, label_id, label_name )values ( + + #{id},#{item.labelId},#{item.labelName} + + ) + + + update tb_document_files set del_flag=1 where id IN + ( + + #{item} + + ) + + + update tb_user_files set del_flag=1 where id IN + ( + + #{item} + + ) + + + + + + + + + + + + + \ No newline at end of file diff --git a/bonus-common/pom.xml b/bonus-common/pom.xml index a3bf8e8..2b43d23 100644 --- a/bonus-common/pom.xml +++ b/bonus-common/pom.xml @@ -49,12 +49,6 @@ 8.2.1 - - - com.github.pagehelper - pagehelper-spring-boot-starter - - org.springframework.boot @@ -72,7 +66,12 @@ com.fasterxml.jackson.core jackson-databind - + + + com.github.pagehelper + pagehelper-spring-boot-starter + ${pagehelper.boot.version} + com.alibaba.fastjson2 diff --git a/bonus-common/src/main/java/com/bonus/common/core/page/TableSupport.java b/bonus-common/src/main/java/com/bonus/common/core/page/TableSupport.java index 61e3588..940a655 100644 --- a/bonus-common/src/main/java/com/bonus/common/core/page/TableSupport.java +++ b/bonus-common/src/main/java/com/bonus/common/core/page/TableSupport.java @@ -41,8 +41,10 @@ public class TableSupport public static PageDomain getPageDomain() { PageDomain pageDomain = new PageDomain(); - pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1)); - pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10)); + int pageNum=Integer.parseInt(ServletUtils.getParameter(PAGE_NUM)); + int pageSize=Integer.parseInt(ServletUtils.getParameter(PAGE_SIZE)); + pageDomain.setPageNum(Convert.toInt(pageNum, 1)); + pageDomain.setPageSize(Convert.toInt(pageSize, 10)); pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN)); pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC)); pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE)); diff --git a/bonus-common/src/main/java/com/bonus/common/encryption/Sm4Utils.java b/bonus-common/src/main/java/com/bonus/common/encryption/Sm4Utils.java index 7bdf2c2..66538e2 100644 --- a/bonus-common/src/main/java/com/bonus/common/encryption/Sm4Utils.java +++ b/bonus-common/src/main/java/com/bonus/common/encryption/Sm4Utils.java @@ -57,7 +57,7 @@ public class Sm4Utils { // 测试方法,演示加密和解密过程 public static void main(String[] args) { - String plainText = "18226653236"; + String plainText = "15755022653"; System.out.println("原文: " + plainText); // 加密明文 diff --git a/bonus-common/src/main/java/com/bonus/common/utils/PhoneUtils.java b/bonus-common/src/main/java/com/bonus/common/utils/PhoneUtils.java index 15ccb30..52f8c76 100644 --- a/bonus-common/src/main/java/com/bonus/common/utils/PhoneUtils.java +++ b/bonus-common/src/main/java/com/bonus/common/utils/PhoneUtils.java @@ -1,7 +1,6 @@ package com.bonus.common.utils; import cn.hutool.http.HttpRequest; -import com.sun.org.apache.bcel.internal.generic.NEW; import org.hibernate.validator.internal.util.StringHelper; import java.util.HashMap; @@ -79,7 +78,6 @@ public class PhoneUtils { ; map.put("code","200"); map.put("msg","发送成功"); } - return map; } diff --git a/bonus-file/src/main/java/com/bonus/file/minio/MinioUtil.java b/bonus-file/src/main/java/com/bonus/file/minio/MinioUtil.java index f8eef2a..3454c53 100644 --- a/bonus-file/src/main/java/com/bonus/file/minio/MinioUtil.java +++ b/bonus-file/src/main/java/com/bonus/file/minio/MinioUtil.java @@ -111,7 +111,6 @@ public class MinioUtil { } else { uploadLargeFile(folderPath, file); } - return SysFile.builder() .name(file.getOriginalFilename()) .url(folderPath).build(); @@ -130,9 +129,7 @@ public class MinioUtil { List partNames = new ArrayList<>(); // 创建线程池 ExecutorService executor = Executors.newFixedThreadPool(5); - List> futures = new ArrayList<>(); - // 上传每个分片 for (int i = 0; i < partCount; i++) { long offset = i * PART_SIZE;