This commit is contained in:
parent
9f345c1ac9
commit
c71da50c6c
|
|
@ -8,11 +8,13 @@ import com.bonus.business.service.DocumentScreenService;
|
|||
import com.bonus.common.core.controller.BaseController;
|
||||
import com.bonus.common.core.domain.AjaxResult;
|
||||
import com.bonus.common.core.page.TableDataInfo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -33,6 +35,9 @@ public class DocumentScreenController extends BaseController {
|
|||
@PreAuthorize("@ss.hasPermi('tb:document:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(TbFolderFileVo vo) {
|
||||
if("2".equals(vo.getType())){
|
||||
vo.setId(vo.getId().split("_")[2]);
|
||||
}
|
||||
startPage();
|
||||
List<TbFolderFileVo> list = service.getFileFolderList(vo);
|
||||
return getDataTable(list);
|
||||
|
|
@ -93,4 +98,46 @@ public class DocumentScreenController extends BaseController {
|
|||
return service.delete(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据共享
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/share")
|
||||
public AjaxResult share(@RequestBody TbFolderFileVo vo) {
|
||||
return service.share(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重命名
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/updateName")
|
||||
public AjaxResult updateName(@RequestBody TbFolderFileVo vo) {
|
||||
return service.updateName(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加副本
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/copy")
|
||||
public AjaxResult copy(@RequestBody TbFolderFileVo vo) {
|
||||
return service.copy(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件下载
|
||||
*
|
||||
* TODO
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/downLoad")
|
||||
public void downLoad(HttpServletResponse response , @RequestBody TbFolderFileVo dto) {
|
||||
service.downLoad(response,dto);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class TbDocumentFolder extends BaseEntity
|
|||
|
||||
/** 节点层级 */
|
||||
@Excel(name = "节点层级")
|
||||
private int level;
|
||||
private String level;
|
||||
|
||||
/** 文件夹名称 */
|
||||
@Excel(name = "文件夹名称")
|
||||
|
|
|
|||
|
|
@ -2,11 +2,31 @@ package com.bonus.business.domain;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class TbFolderFileVo {
|
||||
|
||||
private String downIds;
|
||||
|
||||
/**
|
||||
* 文件后缀
|
||||
*/
|
||||
private String fileSuffix;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 等级
|
||||
*/
|
||||
private String level;
|
||||
|
||||
private String newId;
|
||||
/**
|
||||
* 新的夫节点id
|
||||
*/
|
||||
|
|
@ -89,6 +109,20 @@ public class TbFolderFileVo {
|
|||
private String shareUserId;
|
||||
|
||||
private String parentIds;
|
||||
/**
|
||||
* 共享人员数据集合
|
||||
*/
|
||||
private String userIds;
|
||||
/**
|
||||
* 更新人员名称
|
||||
*/
|
||||
private String updateUser;
|
||||
|
||||
private List<TbFolderFileVo> child;
|
||||
|
||||
private String toType;
|
||||
|
||||
private String toId;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -94,4 +94,44 @@ public interface DocumentScreenMapper {
|
|||
* @param vo
|
||||
*/
|
||||
void deleteDocumentParentId(TbFolderFileVo vo);
|
||||
|
||||
/**
|
||||
* 查看数据进行添加
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
int getLookNum(TbFolderFileVo vo);
|
||||
|
||||
/**
|
||||
* 跟新读次数
|
||||
* @param vo
|
||||
*/
|
||||
void updateLookNum(TbFolderFileVo vo);
|
||||
|
||||
/**
|
||||
* 重命名
|
||||
* @param vo
|
||||
*/
|
||||
void updateName(TbFolderFileVo vo);
|
||||
|
||||
/**
|
||||
* 查询指定数据集合
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
List<TbFolderFileVo> getList(@Param("list") List<String> ids);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param vo2
|
||||
* @return
|
||||
*/
|
||||
List<TbFolderFileVo> getChilderList(TbFolderFileVo vo2);
|
||||
|
||||
/**
|
||||
* 查询标签数据结婚
|
||||
* @param vo2
|
||||
* @return
|
||||
*/
|
||||
List<TbUserLabel> getLabelsList(TbFolderFileVo vo2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.bonus.business.domain.TbUserFiles;
|
|||
import com.bonus.common.core.domain.AjaxResult;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
public interface DocumentScreenService {
|
||||
|
|
@ -53,4 +54,32 @@ public interface DocumentScreenService {
|
|||
* @return
|
||||
*/
|
||||
AjaxResult delete(TbFolderFileVo vo);
|
||||
|
||||
/**
|
||||
* 共享
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult share(TbFolderFileVo vo);
|
||||
|
||||
/**
|
||||
* 重命名
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult updateName(TbFolderFileVo vo);
|
||||
|
||||
/**
|
||||
* 添加副本
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult copy(TbFolderFileVo vo);
|
||||
|
||||
/**
|
||||
* 文件下载
|
||||
* @param response
|
||||
* @param dto
|
||||
*/
|
||||
void downLoad(HttpServletResponse response, TbFolderFileVo dto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,18 @@ 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.minio.MinioUtil;
|
||||
import com.bonus.file.service.FileUploadService;
|
||||
import com.bonus.file.vo.UploadFileVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -27,6 +32,12 @@ public class DocumentScreenImpl implements DocumentScreenService {
|
|||
@Autowired
|
||||
private FileUploadService service;
|
||||
|
||||
@Autowired
|
||||
private MinioUtil minioUtil;
|
||||
|
||||
|
||||
protected String dataIds=",companyDocument,myDocument,myShare,otherShare,share,";
|
||||
|
||||
protected String day= DateUtils.getCurrentDay();
|
||||
|
||||
protected String month=DateUtils.getCurrentMonth();
|
||||
|
|
@ -209,6 +220,11 @@ public class DocumentScreenImpl implements DocumentScreenService {
|
|||
public List<TbFolderFileVo> getFileFolderList(TbFolderFileVo vo) {
|
||||
try{
|
||||
List<TbFolderFileVo> list=mapper.getFileFolderList(vo);
|
||||
//进行数据查看进行插入数据
|
||||
int num=mapper.getLookNum(vo);
|
||||
num++;
|
||||
vo.setReadNum(num+"");
|
||||
mapper.updateLookNum(vo);
|
||||
return list;
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
|
|
@ -264,9 +280,9 @@ public class DocumentScreenImpl implements DocumentScreenService {
|
|||
*/
|
||||
@Override
|
||||
public AjaxResult delete(TbFolderFileVo vo) {
|
||||
|
||||
try{
|
||||
//父节点更新
|
||||
vo.setParentIds(vo.getParentIds().replace(","+vo.getParentId()+",",","+vo.getNewParentId()+","));
|
||||
String userId=SecurityUtils.getUserId().toString();
|
||||
vo.setUserId(userId);
|
||||
if("1".equals(vo.getType())){
|
||||
|
|
@ -281,12 +297,7 @@ public class DocumentScreenImpl implements DocumentScreenService {
|
|||
return AjaxResult.success("共享及分享的文件夹不允许删除");
|
||||
}
|
||||
mapper.deleteDocumentReal(data);
|
||||
// TbDocumentFolder documentFolder = getTbDocumentFolder(vo, data);
|
||||
// mapper.addDocumentRealUser(documentFolder);
|
||||
}else{
|
||||
/**
|
||||
* 更新夫节点id
|
||||
*/
|
||||
mapper.deleteDocumentParentId(vo);
|
||||
}
|
||||
}
|
||||
|
|
@ -298,6 +309,284 @@ public class DocumentScreenImpl implements DocumentScreenService {
|
|||
return AjaxResult.error("删除失败");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult share(TbFolderFileVo vo) {
|
||||
try{
|
||||
//父节点更新
|
||||
String userId=SecurityUtils.getUserId().toString();
|
||||
vo.setUserId(userId);
|
||||
if("1".equals(vo.getType())){
|
||||
return AjaxResult.success("当前文件夹没权限共享");
|
||||
}else{
|
||||
//
|
||||
vo.setId(vo.getId().split("_")[2]);
|
||||
TbDocumentFolder documentFolder=new TbDocumentFolder();
|
||||
String[] ids=vo.getUserIds().split(",");
|
||||
//共享文件夹创建
|
||||
for(String id:ids){
|
||||
documentFolder.setDataType("3");
|
||||
documentFolder.setPublicFolderId("otherShare");
|
||||
documentFolder.setUserId(id);
|
||||
documentFolder.setId(vo.getId());
|
||||
documentFolder.setAuth(vo.getAuth());
|
||||
documentFolder.setShareUserId(userId);
|
||||
mapper.addDocumentRealUser(documentFolder);
|
||||
|
||||
}
|
||||
//自己共享文件夹创建
|
||||
documentFolder.setDataType("2");
|
||||
documentFolder.setPublicFolderId("myShare");
|
||||
documentFolder.setUserId(userId);
|
||||
documentFolder.setId(vo.getId());
|
||||
documentFolder.setAuth(vo.getAuth());
|
||||
documentFolder.setShareUserId(userId);
|
||||
Integer num= mapper.addDocumentRealUser(documentFolder);
|
||||
if(num!=null && num>0){
|
||||
return AjaxResult.success("共享成功");
|
||||
}
|
||||
}
|
||||
return AjaxResult.success("共享失败");
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return AjaxResult.error("共享失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件夹重命名
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult updateName(TbFolderFileVo vo) {
|
||||
try{
|
||||
//父节点更新
|
||||
String userId=SecurityUtils.getUserId().toString();
|
||||
vo.setUserId(userId);
|
||||
if("1".equals(vo.getType())){
|
||||
return AjaxResult.success("当前文件夹没有权限重命名");
|
||||
}else{
|
||||
//
|
||||
vo.setId(vo.getId().split("_")[2]);
|
||||
vo.setUpdateUser(userId);
|
||||
//如果是初始化节点
|
||||
mapper.updateName(vo);
|
||||
}
|
||||
return AjaxResult.success("删除成功");
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
|
||||
return AjaxResult.error("删除失败");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 添加副本
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult copy(TbFolderFileVo vo) {
|
||||
try{
|
||||
//父节点更新
|
||||
String userId=SecurityUtils.getUserId().toString();
|
||||
vo.setUserId(userId);
|
||||
if(dataIds.contains(vo.getToId())){
|
||||
return AjaxResult.success("目标文件夹不允许创建副本");
|
||||
}
|
||||
if("1".equals(vo.getType())){
|
||||
return AjaxResult.success("当前文件夹不允许添加副本");
|
||||
}else{
|
||||
|
||||
vo.setId(vo.getId().split("_")[2]);
|
||||
//查询当前节点下全部信息
|
||||
//重新添加头部信息
|
||||
getTreeList(vo);
|
||||
}
|
||||
return AjaxResult.success("添加副本成功");
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return AjaxResult.error("副本添加失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件打包下载
|
||||
* @param response
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public void downLoad(HttpServletResponse response, TbFolderFileVo dto) {
|
||||
try{
|
||||
List<TbFolderFileVo> list=new ArrayList<>();
|
||||
String ids=dto.getDownIds();
|
||||
List<String> idList= Arrays.asList(ids.split(","));
|
||||
List<TbFolderFileVo> treeList=mapper.getList(idList);
|
||||
for (TbFolderFileVo vo2 : treeList) {
|
||||
String uuid=StringUtils.randomUUID();
|
||||
vo2.setNewId(uuid);
|
||||
List<TbFolderFileVo> childer= getChilderList(vo2,list);
|
||||
vo2.setChild(childer);
|
||||
}
|
||||
//全部数据集合--treeList 需要创建文件夹及文件
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//图片压缩包
|
||||
List<UploadFileVo> fileVoList=new ArrayList<>();
|
||||
String packageName =DateUtils.getYMDDate()+ "下载压缩包.zip";
|
||||
// String url=minioUtil.downloadFilesAsZip(null,fileVoList,packageName);
|
||||
minioUtil.fileDownload("",response);
|
||||
//删除指定文件
|
||||
minioUtil.deleteObject("");
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 依据id 查询全部子节点数据
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
private void getTreeList(TbFolderFileVo vo) {
|
||||
//子数据集合
|
||||
List<TbFolderFileVo> list=new ArrayList<>();
|
||||
String ids=vo.getId();
|
||||
List<String> idList= Arrays.asList(ids.split(","));
|
||||
List<TbFolderFileVo> treeList=mapper.getList(idList);
|
||||
for (TbFolderFileVo vo2 : treeList) {
|
||||
String uuid=StringUtils.randomUUID();
|
||||
vo2.setNewId(uuid);
|
||||
List<TbFolderFileVo> childer= getChilderList(vo2,list);
|
||||
vo2.setChild(childer);
|
||||
}
|
||||
//第一节点直接存储到父节点
|
||||
if("1".equals(vo.getToType())){
|
||||
TbDocumentFolder tbDocumentFolder=new TbDocumentFolder();
|
||||
for (TbFolderFileVo vo2 : treeList) {
|
||||
tbDocumentFolder.setId(vo2.getNewId());
|
||||
tbDocumentFolder.setLevel(vo2.getLevel());
|
||||
tbDocumentFolder.setParentId("0");
|
||||
tbDocumentFolder.setParentIds("0,");
|
||||
tbDocumentFolder.setFileType(vo2.getFileType());
|
||||
tbDocumentFolder.setRemark(vo2.getRemark());
|
||||
tbDocumentFolder.setFilePath(vo2.getFilePath());
|
||||
tbDocumentFolder.setFolderName(vo2.getName()+"_副本");
|
||||
tbDocumentFolder.setFileSuffix(vo2.getFileSuffix());
|
||||
tbDocumentFolder.setLabels(vo2.getLabName());
|
||||
tbDocumentFolder.setCreateUser(vo2.getCreateUser());
|
||||
tbDocumentFolder.setUpdateUser(vo2.getUpdateUser());
|
||||
mapper.addDocumentCompany(tbDocumentFolder);
|
||||
//如果文件 需要copy标签
|
||||
if("1".equals(vo2.getFileType())){
|
||||
List<TbUserLabel> labList=mapper.getLabelsList(vo2);
|
||||
mapper.addDocumentLabels(labList);
|
||||
}
|
||||
//添加关联数据
|
||||
tbDocumentFolder.setAuthType("4");
|
||||
tbDocumentFolder.setDataType("1");
|
||||
mapper.addDocumentRealUser(tbDocumentFolder);
|
||||
}
|
||||
for (TbFolderFileVo vo2 : list) {
|
||||
tbDocumentFolder.setId(vo2.getNewId());
|
||||
tbDocumentFolder.setLevel(vo2.getLevel());
|
||||
tbDocumentFolder.setParentId(vo2.getNewParentId());
|
||||
tbDocumentFolder.setParentIds(vo2.getParentIds()+vo2.getNewParentId()+",");
|
||||
tbDocumentFolder.setFileType(vo2.getFileType());
|
||||
tbDocumentFolder.setRemark(vo2.getRemark());
|
||||
tbDocumentFolder.setFilePath(vo2.getFilePath());
|
||||
tbDocumentFolder.setFolderName(vo2.getName()+"_副本");
|
||||
tbDocumentFolder.setFileSuffix(vo2.getFileSuffix());
|
||||
tbDocumentFolder.setLabels(vo2.getLabName());
|
||||
tbDocumentFolder.setCreateUser(vo2.getCreateUser());
|
||||
tbDocumentFolder.setUpdateUser(vo2.getUpdateUser());
|
||||
mapper.addDocumentCompany(tbDocumentFolder);
|
||||
//如果文件 需要copy标签
|
||||
if("1".equals(vo2.getFileType())){
|
||||
List<TbUserLabel> labList=mapper.getLabelsList(vo2);
|
||||
mapper.addDocumentLabels(labList);
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
//目标路径
|
||||
String parentId=vo.getToId();
|
||||
TbDocumentFolder tbDocumentFolder=new TbDocumentFolder();
|
||||
for (TbFolderFileVo vo2 : treeList) {
|
||||
tbDocumentFolder.setId(vo2.getNewId());
|
||||
tbDocumentFolder.setLevel(vo2.getLevel());
|
||||
tbDocumentFolder.setParentId(parentId);
|
||||
tbDocumentFolder.setParentIds(vo2.getParentIds()+parentId+",");
|
||||
tbDocumentFolder.setFileType(vo2.getFileType());
|
||||
tbDocumentFolder.setRemark(vo2.getRemark());
|
||||
tbDocumentFolder.setFilePath(vo2.getFilePath());
|
||||
tbDocumentFolder.setFolderName(vo2.getName()+"_副本");
|
||||
tbDocumentFolder.setFileSuffix(vo2.getFileSuffix());
|
||||
tbDocumentFolder.setLabels(vo2.getLabName());
|
||||
tbDocumentFolder.setCreateUser(vo2.getCreateUser());
|
||||
tbDocumentFolder.setUpdateUser(vo2.getUpdateUser());
|
||||
mapper.addDocumentCompany(tbDocumentFolder);
|
||||
//如果文件 需要copy标签
|
||||
if("1".equals(vo2.getFileType())){
|
||||
List<TbUserLabel> labList=mapper.getLabelsList(vo2);
|
||||
mapper.addDocumentLabels(labList);
|
||||
}
|
||||
}
|
||||
for (TbFolderFileVo vo2 : list) {
|
||||
tbDocumentFolder.setId(vo2.getNewId());
|
||||
tbDocumentFolder.setLevel(vo2.getLevel());
|
||||
tbDocumentFolder.setParentId(vo2.getNewParentId());
|
||||
tbDocumentFolder.setParentIds(vo2.getParentIds()+vo2.getNewParentId()+",");
|
||||
tbDocumentFolder.setFileType(vo2.getFileType());
|
||||
tbDocumentFolder.setRemark(vo2.getRemark());
|
||||
tbDocumentFolder.setFilePath(vo2.getFilePath());
|
||||
tbDocumentFolder.setFolderName(vo2.getName()+"_副本");
|
||||
tbDocumentFolder.setFileSuffix(vo2.getFileSuffix());
|
||||
tbDocumentFolder.setLabels(vo2.getLabName());
|
||||
tbDocumentFolder.setCreateUser(vo2.getCreateUser());
|
||||
tbDocumentFolder.setUpdateUser(vo2.getUpdateUser());
|
||||
mapper.addDocumentCompany(tbDocumentFolder);
|
||||
//如果文件 需要copy标签
|
||||
if("1".equals(vo2.getFileType())){
|
||||
List<TbUserLabel> labList=mapper.getLabelsList(vo2);
|
||||
mapper.addDocumentLabels(labList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据集合
|
||||
* @param vo2
|
||||
* @return
|
||||
*/
|
||||
private List<TbFolderFileVo> getChilderList(TbFolderFileVo vo2, List<TbFolderFileVo> list) {
|
||||
List<TbFolderFileVo> childer= mapper.getChilderList(vo2);
|
||||
if(childer!=null && !childer.isEmpty()){
|
||||
list.addAll(childer);
|
||||
for (TbFolderFileVo vo : childer) {
|
||||
String uuid=StringUtils.randomUUID();
|
||||
vo.setNewId(uuid);
|
||||
getChilderList(vo,list);
|
||||
}
|
||||
vo2.setChild(childer);
|
||||
}
|
||||
return childer;
|
||||
}
|
||||
|
||||
private TbDocumentFolder getTbDocumentFolder(TbFolderFileVo vo, TbFolderFileVo data) {
|
||||
TbDocumentFolder documentFolder=new TbDocumentFolder();
|
||||
documentFolder.setPublicFolderId(vo.getNewParentId());
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class DocumentServiceImpl implements DocumentService {
|
|||
return AjaxResult.error("文件夹名称已存在");
|
||||
}
|
||||
//默认层级
|
||||
vo.setLevel(2);
|
||||
vo.setLevel("2");
|
||||
vo.setParentId("companyDocument");
|
||||
vo.setParentIds(vo.getParentIds()+"companyDocument,");
|
||||
vo.setCreateUser(SecurityUtils.getUserId().toString());
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</select>
|
||||
<select id="getUserList" resultType="com.bonus.business.domain.TbDocumentFolderAuth">
|
||||
select tdf.user_id createUser,su.user_name userName
|
||||
select tdf.user_id userId,su.user_name userName
|
||||
from tb_public_folder_auth tdf
|
||||
left join sys_user su on su.user_id=tdf.user_id
|
||||
where tdf.folder_id=#{id}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<delete id="deleteDocumentParentId">
|
||||
update tb_user_document_folder set from del_flag=1 where id=#{id}
|
||||
</delete>
|
||||
<insert id="addDocumnetLables">
|
||||
<insert id="addDocumentLabels">
|
||||
insert into tb_document_files_label( file_id, label_id, label_name)values (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.fileId},#{item.labelId},#{item.labelName}
|
||||
|
|
@ -41,18 +41,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
)values (#{publicFolderId},#{userId},#{id},#{auth},#{shareUserId},#{dataType})
|
||||
</insert>
|
||||
<!--添加文件-->
|
||||
<update id="addDocumentLabels">
|
||||
update tb_user_document_folder set from del_flag=1
|
||||
where id in (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
)
|
||||
</update>
|
||||
<update id="updateDocumentParentId">
|
||||
update tb_user_document_folder set parent_id=#{parentId},parent_ids=#{parentIds}
|
||||
where id=#{id}
|
||||
</update>
|
||||
<update id="updateLookNum">
|
||||
<if test='type=="1" or type==1 '>
|
||||
update tb_public_folder set see_times=#{readNum} where id=#{parentId}
|
||||
</if>
|
||||
<if test='type=="2" or type==2 '>
|
||||
update tb_user_document_folder set see_times=#{readNum} where id=#{parentId}
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateName">
|
||||
update tb_user_document_folder set folder_name=#{name}, update_time=now(),update_user=#{updateUser}
|
||||
where id=#{id}
|
||||
</update>
|
||||
<select id="getPublicFolderList" resultType="com.bonus.business.domain.DocumentTreeVo">
|
||||
select tpf.id,level,tpf.folder_name name,tpf.parent_id parentId,tpf.parent_ids parentIds,1 type
|
||||
from tb_public_folder tpf
|
||||
|
|
@ -118,7 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
left join sys_user su on su.user_id=tudf.create_user
|
||||
where tudf.del_flag=0 and tpru.public_folder_id=#{parentId}
|
||||
</if>
|
||||
<if test='type=="1" or type==1 '>
|
||||
<if test='type=="2" or type==2 '>
|
||||
SELECT tudf.id, tudf.folder_name name,tudf.parent_id parentId,tudf.parent_ids,2 type ,tudf.down_times downNum,
|
||||
tudf.labels labName,
|
||||
tudf.file_type fileType,tudf.file_suffix fileSuffix,
|
||||
|
|
@ -136,5 +140,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
from tb_public_real_user
|
||||
where public_folder_id=#{parentId} and user_id=#{userId} and user_folder_id=#{id}
|
||||
</select>
|
||||
<!--数量-->
|
||||
<select id="getLookNum" resultType="java.lang.Integer">
|
||||
<if test='type=="1" or type==1 '>
|
||||
select tpf.see_times readNum
|
||||
from tb_public_folder tpf
|
||||
where tpf.del_flag=0 and tpf.id=#{parentId}
|
||||
</if>
|
||||
<if test='type=="2" or type==2 '>
|
||||
SELECT tudf.see_times readNum
|
||||
FROM tb_user_document_folder tudf
|
||||
where tudf.del_flag=0 and tudf.id=#{parentId}
|
||||
</if>
|
||||
|
||||
</select>
|
||||
<select id="getList" resultType="com.bonus.business.domain.TbFolderFileVo">
|
||||
select id, level, folder_name, parent_id, file_type, remark, parent_ids, file_path, file_id,
|
||||
#{newId} newParentId,
|
||||
down_times, see_times, file_suffix, labels, create_user, create_time,
|
||||
update_user, update_time, del_flag
|
||||
from tb_user_document_folder
|
||||
where id in(
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
<!--查询子数据-->
|
||||
<select id="getChilderList" resultType="com.bonus.business.domain.TbFolderFileVo">
|
||||
select id, level, folder_name, parent_id, file_type, remark, parent_ids, file_path, file_id,
|
||||
#{newId} newParentId,
|
||||
down_times, see_times, file_suffix, labels, create_user, create_time,
|
||||
update_user, update_time, del_flag
|
||||
from tb_user_document_folder
|
||||
where parent_id=#{id}
|
||||
</select>
|
||||
<select id="getLabelsList" resultType="com.bonus.business.domain.TbUserLabel">
|
||||
select #{newId} fileId, lable_id labelId, lable_name labelName
|
||||
from tb_document_files_label
|
||||
WHERE file_id=#{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -28,7 +28,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
public static final String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||
|
||||
public static final String YYYYMMDD = "yyyyMMdd";
|
||||
private static final String[] PARSE_PATTERNS = {
|
||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||
|
|
@ -42,7 +42,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|||
public static Date getNowDate() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
public static String getYMDDate() {
|
||||
return dateTimeNow(YYYYMMDD);
|
||||
}
|
||||
/**
|
||||
* 获取当前日期,格式为 yyyy-MM-dd
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
|
@ -240,6 +241,7 @@ public class MinioUtil {
|
|||
|
||||
// 压缩每个文件
|
||||
for (String objectName : objectNames) {
|
||||
|
||||
try (InputStream inputStream = minioClient.getObject(GetObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(objectName)
|
||||
|
|
@ -456,7 +458,58 @@ public class MinioUtil {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
* @param fileName
|
||||
* @param response
|
||||
*/
|
||||
public void fileDownload(String fileName, HttpServletResponse response) {
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
if (com.bonus.common.utils.StringUtils.isBlank(fileName)) {
|
||||
response.setHeader("Content-type", "text/html;charset=UTF-8");
|
||||
String data = "文件下载失败";
|
||||
OutputStream ps = response.getOutputStream();
|
||||
ps.write(data.getBytes(StandardCharsets.UTF_8));
|
||||
return;
|
||||
}
|
||||
outputStream = response.getOutputStream();
|
||||
// 获取文件对象
|
||||
inputStream= minioClient.getObject(GetObjectArgs.builder().bucket(minioConfig.getBucketName()).object(fileName).build());
|
||||
byte[] buf = new byte[1024];
|
||||
int length = 0;
|
||||
response.reset();
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" +
|
||||
URLEncoder.encode(fileName.substring(fileName.lastIndexOf("/") + 1), "UTF-8"));
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
// 输出文件
|
||||
while ((length = inputStream.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, length);
|
||||
}
|
||||
System.out.println("下载成功");
|
||||
inputStream.close();
|
||||
} catch (Throwable ex) {
|
||||
response.setHeader("Content-type", "text/html;charset=UTF-8");
|
||||
String data = "文件下载失败";
|
||||
try {
|
||||
OutputStream ps = response.getOutputStream();
|
||||
ps.write(data.getBytes(StandardCharsets.UTF_8));
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
assert outputStream != null;
|
||||
outputStream.close();
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 删除指定路径的所有对象,从而删除整个文件夹及其子文件夹。
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue