This commit is contained in:
haozq 2025-11-03 09:18:44 +08:00
parent e6b36012f1
commit 8de1f747f8
10 changed files with 236 additions and 185 deletions

View File

@ -2,17 +2,19 @@ package com.bonus.business.controller;
import com.bonus.business.domain.DocumentTreeVo;
import com.bonus.business.domain.TbDocumentFolder;
import com.bonus.business.domain.TbFolderFileVo;
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 com.bonus.common.core.page.TableDataInfo;
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.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* 文档中心管理
*/
@ -23,6 +25,19 @@ public class DocumentScreenController extends BaseController {
@Autowired
private DocumentScreenService service;
/**
* 依据文件夹查询数据集合
* @param vo
* @return
*/
@PreAuthorize("@ss.hasPermi('tb:document:list')")
@GetMapping("/list")
public TableDataInfo list(TbFolderFileVo vo) {
startPage();
List<TbFolderFileVo> list = service.getFileFolderList(vo);
return getDataTable(list);
}
/**
* 查询文档树
@ -54,4 +69,7 @@ public class DocumentScreenController extends BaseController {
public AjaxResult importFile(@RequestParam(value = "files",required = false) MultipartFile[] file, TbUserFiles vo) {
return service.importFile(file,vo);
}
}

View File

@ -34,6 +34,10 @@ public class DocumentTreeVo {
* 是否是管理员
*/
private String isAdmin;
/**
* 等级
*/
private String level;
/**
* 权限
*/

View File

@ -68,6 +68,12 @@ public class TbDocumentFolder extends BaseEntity
private String type;
private String userId;
private String sourceId;
/**
* 分享人id
*/
private String shareUserId;
/**
* 权限集合
*/

View File

@ -0,0 +1,60 @@
package com.bonus.business.domain;
import lombok.Data;
/**
*
*/
@Data
public class TbFolderFileVo {
private String parentId;
/**
* 主键
*/
private String id;
/**
* 名称
*/
private String name;
/**
* 文件类型
*/
private String typeName;
/**
* 分类
*/
private String type;
/**
* 标签名称
*/
private String labName;
/**
* 创建人
*/
private String createUser;
/**
* 创建时间
*/
private String createTime;
/**
* 更新时间
*/
private String updateTime;
/**
* 下载次数
*/
private String downNum;
/**
* 阅读次数
*/
private String readNum;
/**
* 文件路径
*/
private String filePath;
/**
* 数据类型 1文件夹 2 文件
*/
private String dataType;
}

View File

@ -103,7 +103,45 @@ public interface DocumentScreenMapper {
*/
List<TbUserFiles> getUserFileList(TbUserFiles vo);
/**
* 删除公司下文件
* @param delete
*/
void deleteCompanyFile(@Param("list") List<TbUserFiles> delete);
/**
* 删除用户文件
* @param delete
*/
void deleteUserFile(@Param("list")List<TbUserFiles> delete);
/**
* 获取 公司文件夹下文件及
* @param vo
* @return
*/
List<TbFolderFileVo> getCompanyUserFileList(TbFolderFileVo vo);
/**
* 个人 文件夹下 的文件夹及我呢见
* @param vo
* @return
*/
List<TbFolderFileVo> getMyUserFileList(TbFolderFileVo vo);
/**
* 查询公共
* @param vo
* @return
*/
List<DocumentTreeVo> getPublicFolderList(DocumentTreeVo vo);
/**
* 查询用户文件夹数据集合
* @param vo
* @return
*/
List<DocumentTreeVo> getUserFolderList(DocumentTreeVo vo);
}

View File

@ -2,10 +2,13 @@ package com.bonus.business.service;
import com.bonus.business.domain.DocumentTreeVo;
import com.bonus.business.domain.TbDocumentFolder;
import com.bonus.business.domain.TbFolderFileVo;
import com.bonus.business.domain.TbUserFiles;
import com.bonus.common.core.domain.AjaxResult;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
public interface DocumentScreenService {
/**
* 查询 文档中心
@ -28,4 +31,12 @@ public interface DocumentScreenService {
* @return
*/
AjaxResult importFile(MultipartFile[] file, TbUserFiles vo);
/**
* 查询 文件及文件夹集合
* @param vo
* @return
*/
List<TbFolderFileVo> getFileFolderList(TbFolderFileVo vo);
}

View File

@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Slf4j
@ -32,6 +33,8 @@ public class DocumentScreenImpl implements DocumentScreenService {
public String month=DateUtils.getCurrentMonth();
public String year=DateUtils.getCurrentYear();
public static String file_path="/";
/**
* 查询文档中心树
* @param vo
@ -39,7 +42,7 @@ public class DocumentScreenImpl implements DocumentScreenService {
*/
@Override
public AjaxResult getDocumentTree(DocumentTreeVo vo) {
List<DocumentTreeVo> list=new ArrayList<>();
try{
String userId= SecurityUtils.getUserId().toString();
vo.setUserId(userId);
@ -49,23 +52,17 @@ public class DocumentScreenImpl implements DocumentScreenService {
//管理员
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);
List<DocumentTreeVo> allList=mapper.getPublicFolderList(vo);
List<DocumentTreeVo> childeList=mapper.getUserFolderList(vo);
//查询 子节点集合
TreeBuild treeBuild = new TreeBuild(allList);
List<DocumentTreeVo> list=treeBuild.buildTree("0");
return AjaxResult.success(list);
}catch (Exception e){
log.error(e.getMessage());
log.error(e.toString(),e);
}
return AjaxResult.success(list);
return AjaxResult.success(new ArrayList<>());
}
/**
@ -194,6 +191,31 @@ public class DocumentScreenImpl implements DocumentScreenService {
}
return AjaxResult.error("文件上传失败");
}
/**
*
* @param vo
* @return
*/
@Override
public List<TbFolderFileVo> getFileFolderList(TbFolderFileVo vo) {
try{
// 文件夹类型
String type=vo.getType();
if("1".equals(type)){
//公司文档
return mapper.getCompanyUserFileList(vo);
}else if("2".equals(type)){
//自己的文档
return mapper.getMyUserFileList(vo);
}
}catch (Exception e){
log.error(e.getMessage());
}
return Collections.emptyList();
}
/**
* 上传附件
* @param
@ -201,13 +223,13 @@ public class DocumentScreenImpl implements DocumentScreenService {
*/
public AjaxResult uploadFile(List<MultipartFile> multipartFileList,TbUserFiles files){
String type=files.getType();
String filePath ;
String filePath="" ;
if("1".equals(type)){
filePath = "document/company/"+files.getUploadUser() + "/" +
year + "/" + month + "/" + day + "/" ;
filePath = "document/company/"+files.getUploadUser() +file_path +
year + file_path + month + file_path + day +file_path ;
}else{
filePath = "document/user/" + files.getUploadUser()+"/" +
year + "/" + month + "/" + day + "/" ;
filePath = "document/user/" + files.getUploadUser()+file_path +
year + file_path + month + file_path + day +file_path ;
}
String[] ids=files.getLabelIds().split(",");
String[] name= files.getLabels().split(",");
@ -271,6 +293,7 @@ public class DocumentScreenImpl implements DocumentScreenService {
DocumentTreeVo vo1=new DocumentTreeVo();
vo1.setId("share");
vo1.setParentId("0");
vo1.setParentIds("0,");
vo1.setName("共享文档");
vo1.setType("3");
List<DocumentTreeVo> list=getShareList(vo);
@ -289,6 +312,7 @@ public class DocumentScreenImpl implements DocumentScreenService {
DocumentTreeVo vo1=new DocumentTreeVo();
vo1.setId("myShare");
vo1.setParentId("share");
vo1.setParentIds("share");
vo1.setName("我共享的");
vo1.setType("31");
//我共享出去的文档查询
@ -297,6 +321,7 @@ public class DocumentScreenImpl implements DocumentScreenService {
DocumentTreeVo vo2=new DocumentTreeVo();
vo2.setId("otherShare");
vo2.setParentId("share");
vo2.setParentIds("share");
vo2.setName("与我共享");
vo2.setType("32");
List<DocumentTreeVo> childList2=getOtherShare(vo,allShareList);

View File

@ -61,17 +61,17 @@ public class DocumentServiceImpl implements DocumentService {
return AjaxResult.error("文件夹名称已存在");
}
//默认层级
vo.setLevel(1);
vo.setLevel(2);
vo.setParentId("companyDocument");
vo.setParentIds("companyDocument,");
vo.setParentIds(vo.getParentIds()+"companyDocument,");
vo.setCreateUser(SecurityUtils.getUserId().toString());
vo.setUpdateUser(SecurityUtils.getUserId().toString());
vo.setId(StringUtils.randomUUID());
vo.setUserId(SecurityUtils.getUserId().toString());
int num =mapper.addDocument(vo);
if(num<1){
return AjaxResult.error("文件夹创建失败");
}
return getAjaxResult(vo, userId);
}catch (Exception e){
log.error(e.toString(),e);

View File

@ -5,66 +5,64 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.bonus.business.mapper.DocumentMapper">
<!--新增文档内容-->
<insert id="addDocument" useGeneratedKeys="true" keyProperty="id">
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_public_folder(
id, level, folder_name, parent_id, file_type,
remark, parent_ids, down_times, see_times,
create_user, create_time, update_user, update_time, del_flag
)values (#{id},#{level},#{folderName},#{parentId},#{fileType},#{remark},#{parentIds},0,0,
#{createUser},now(),#{updateUser},now(),0)
</insert>
<!--新增菜单权限-->
<insert id="addDocumentAuth">
insert into tb_document_folder(folder_id, user_id,folder_type, folder_source, folder_auth, is_share) value
insert into tb_document_folder(folder_id, user_id) value
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{id},#{item},0,4,2,0
#{id},#{item}
</foreach>
</insert>
<update id="updateDocument">
update tb_document_folder set
folder_name=#{folderName},update_time=#{updateTime} ,update_user=#{updateUser}
folder_name=#{folderName},update_time=#{updateTime} ,update_user=#{updateUser},remark=#{remark},
file_type=#{fileType}
where id=#{id}
</update>
<delete id="deleteAuth">
delete from tb_document_folder_auth WHERE folder_id=#{id}
delete from tb_public_folder_auth WHERE folder_id=#{id}
</delete>
<!--已删除的数据-->
<delete id="delDocument">
update tb_document_folder set del_flag= where parent_ids like concat('%',#{parentIds},'%')
update tb_public_folder set del_flag=1 where id=#{id}
</delete>
<delete id="delDocumentFile">
update tb_document_files set del_flag= where parent_ids like concat('%',#{parentIds},'%')
</delete>
<!--查询文档中心 数据-->
<select id="selectDocumentList" resultType="com.bonus.business.domain.TbDocumentFolder">
select tdf.id, tdf.level, tdf.folder_name folderName,
tdf.parent_id parentId, tdf.create_time createTime,
tdf.update_time, update_user,tdf.file_type fileType ,
su.user_name createUser
from tb_document_folder tdf
left join sys_user su on su.user_id=tdf.create_user
select tdf.id, tdf.level, tdf.folder_name folderName,tdf.remark,tdf.parent_ids parentIds,
tdf.parent_id parentId, tdf.create_time createTime,
tdf.update_time, update_user,tdf.file_type fileType,
su.user_name createUser
from tb_public_folder tdf
left join sys_user su on su.user_id=tdf.create_user
where tdf.parent_id='companyDocument' and tdf.del_flag=0
<if test="folderName!=null and folderName!=''">
and tdf.folder_name like concat('%',#{folderName},'%')
</if>
<if test="fileType!=null and fileType!=''">
and tdf.file_type=#{fileType}
</if>
<if test="folderName!=null and folderName!=''">
and tdf.folder_name like concat('%',#{folderName},'%')
</if>
<if test="fileType!=null and fileType!=''">
and tdf.file_type=#{fileType}
</if>
</select>
<select id="getUserList" resultType="com.bonus.business.domain.TbDocumentFolderAuth">
select dfa.user_id createUser,su.user_name userName,
from tb_document_folder_auth
left join sys_user su on su.user_id=dfa.user_id
WHERE dfa.folder_id=#{id}
select tdf.user_id createUser,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}
</select>
<select id="getDocumentByName" resultType="java.lang.String">
select id
from tb_document_folder
where del_flag =0 and folder_name=#{folderName}
from tb_public_folder
where del_flag =0 and folder_name=#{folderName} and parent_id='companyDocument'
<if test="id!=null and id!=''">
and id !=#{id}
</if>
limit 1
</select>
<select id="getChildNum" resultType="java.lang.Integer">

View File

@ -3,134 +3,25 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.business.mapper.DocumentScreenMapper">
<insert id="addDocumentCompany">
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>
<insert id="addDocumentAuth">
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>
<insert id="addDocumentUser" keyProperty="id" useGeneratedKeys="true" >
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>
<insert id="insertUserFile" keyProperty="id" useGeneratedKeys="true" >
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>
<insert id="insertCompanyFile">
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>
<!--添加文件-->
<insert id="addFileLabel">
insert into tb_document_files_label( file_id, label_id, label_name)values (
<foreach collection="list" item="item" separator=",">
#{id},#{item.labelId},#{item.labelName}
</foreach>
)
</insert>
<insert id="addUserFileLabel">
insert into tb_user_label(file_id, label_id, label_name )values (
<foreach collection="list" item="item" separator=",">
#{id},#{item.labelId},#{item.labelName}
</foreach>
)
</insert>
<update id="deleteCompanyFile">
update tb_document_files set del_flag=1 where id IN
(
<foreach collection="list" separator="," item="item">
#{item}
</foreach>
)
</update>
<update id="deleteUserFile">
update tb_user_files set del_flag=1 where id IN
(
<foreach collection="list" separator="," item="item">
#{item}
</foreach>
)
</update>
<select id="getCompanyChildList" resultType="com.bonus.business.domain.DocumentTreeVo">
select fdf.id id, fdf.parent_id parentId, fdf.parent_ids parentIds, fdf.folder_name name,1 type
from tb_document_folder fdf
<if test='isAdmin!=1 or isAdmin!="1"'>
left join tb_document_folder_auth fdfa on fdfa.folder_id=fdf.id
<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
<if test='isAdmin!="1" or isAdmin!=1 '>
left join tb_public_folder_auth auth on auth.folder_id=tpf.id
</if>
<where >
tdfa.folder_source !='1' --去除他人分享的
<if test='isAdmin!=1 or isAdmin!="1"'>
and fdfa.user_id=#{userId}
</if>
</where>
</select>
<!--查询自己的文档数据-->
<select id="getMyChildList" resultType="com.bonus.business.domain.DocumentTreeVo">
select fuf.id,fuf.parent_id parentId,fuf.folder_name name,2 type
from tb_user_folder fuf
where create_user=#{userId}
</select>
<select id="getOtherShare" resultType="com.bonus.business.domain.DocumentTreeVo">
select tdf.id ,tdf.folder_name name,'otherShare' parentId,tdfa.is_share,1 type,tdfa.folder_auth auth
from tb_document_folder tdf
left join tb_document_folder_auth tdfa on tdf.id=tdfa.folder_id
where tdfa.user_id=#{userId}
and tdfa.folder_source=1 -- 数据源是他人分享而来的
union ALL
select tuf.id,tuf.folder_name,'otherShare' parentId,tuf.is_share,2 type,tfs.share_type auth
from tb_user_folder tuf
left join tb_files_share tfs on tfs.folder_id=tuf.id
where tfs.user_id=#{userId} -- 数据源是他人分享而来的
where tpf.del_flag=0
<!--非管理员-->
<if test='isAdmin!="1" or isAdmin!=1 '>
and (auth.user_id=#{userId} or tpf.id in('myShare', 'otherShare','share','companyDocument' ,'myDocument') )
</if>
<if test='isAdmin=="1" or isAdmin==1 '>
and tpf.id not in('myShare', 'otherShare','share')
</if>
ORDER BY tpf.create_time ASC
</select>
<!--查询用户文件夹结合-->
<select id="getUserFolderList" resultType="com.bonus.business.domain.DocumentTreeVo">
<select id="getMyShareList" resultType="com.bonus.business.domain.DocumentTreeVo">
select tdf.id ,tdf.folder_name name,'myShare' parentId,tdfa.is_share,1 type,
from tb_document_folder tdf
left join tb_document_folder_auth tdfa on tdf.id=tdfa.folder_id
where tdfa.is_share=1 -- 查询分项出去的
and tdfa.user_id=#{userId}
union ALL
select tuf.id,tuf.folder_name,'myShare' parentId,tuf.is_share,2 type
from tb_user_folder tuf
where tuf.is_share=1
and tuf.create_user=#{userId} -- 查询分项出去的
</select>
<select id="getDocumentList" resultType="com.bonus.business.domain.DocumentTreeVo">
select tdf.id ,tdf.folder_name name,parent_id parentId,1 type
from tb_document_folder tdf
union ALL
select tuf.id,tuf.folder_name,parent_id parentId,2 type
from tb_user_folder tuf
</select>
<!--查询存在为文件-->
<select id="getCompanyFileList" resultType="com.bonus.business.domain.TbUserFiles">
SELECT id,original_name originalName,file_path filePath
FROM tb_document_files
where folder_id=#{folderId} and del_flag=0
</select>
<select id="getUserFileList" resultType="com.bonus.business.domain.TbUserFiles">
SELECT id,original_name originalName,file_path filePath
FROM tb_user_files
where folder_id=#{folderId} and del_flag=0
</select>
</mapper>