This commit is contained in:
parent
a1cf2d1033
commit
9daaeaa415
|
|
@ -10,7 +10,6 @@ import com.bonus.common.core.page.TableDataInfo;
|
|||
import com.bonus.common.enums.BusinessType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
@ -24,6 +23,16 @@ public class DocumentController extends BaseController {
|
|||
@Autowired
|
||||
private DocumentService service;
|
||||
|
||||
/**
|
||||
* 分页查询标签列表
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getUserList")
|
||||
public AjaxResult getUserList() {
|
||||
List<TbDocumentFolder> list = service.getUserListData();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询标签列表
|
||||
|
|
|
|||
|
|
@ -39,13 +39,14 @@ public class DocumentScreenController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询文档树
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getDocumentTree")
|
||||
public AjaxResult getDocumentTree(DocumentTreeVo vo) {
|
||||
public AjaxResult getDocumentTree(@RequestBody DocumentTreeVo vo) {
|
||||
return service.getDocumentTree(vo);
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +57,7 @@ public class DocumentScreenController extends BaseController {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping("/addDocument")
|
||||
public AjaxResult addDocument(TbDocumentFolder vo) {
|
||||
public AjaxResult addDocument(@RequestBody TbDocumentFolder vo) {
|
||||
return service.addDocument(vo);
|
||||
}
|
||||
|
||||
|
|
@ -71,5 +72,25 @@ public class DocumentScreenController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增文档
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/move")
|
||||
public AjaxResult moveFile(@RequestBody TbFolderFileVo vo) {
|
||||
return service.moveFile(vo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增文档
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public AjaxResult delete(@RequestBody TbFolderFileVo vo) {
|
||||
return service.delete(vo);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,10 @@ public class TbDocumentFolder extends BaseEntity
|
|||
* 文件路径
|
||||
*/
|
||||
private String filePath;
|
||||
/**
|
||||
* 数据权限
|
||||
*/
|
||||
private String auth;
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -7,7 +7,13 @@ import lombok.Data;
|
|||
*/
|
||||
@Data
|
||||
public class TbFolderFileVo {
|
||||
|
||||
/**
|
||||
* 新的夫节点id
|
||||
*/
|
||||
private String newParentId;
|
||||
/**
|
||||
* 夫节点id
|
||||
*/
|
||||
private String parentId;
|
||||
/**
|
||||
* 主键
|
||||
|
|
@ -57,4 +63,34 @@ public class TbFolderFileVo {
|
|||
* 数据类型 1文件夹 2 文件
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* fileType 0文件夹 1文件
|
||||
*/
|
||||
private String fileType;
|
||||
|
||||
/**
|
||||
* 公共文件夹id
|
||||
*/
|
||||
private String publicFolderId;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
/**
|
||||
* 文件夹id
|
||||
*/
|
||||
private String folderId;
|
||||
/**
|
||||
* 数据权限
|
||||
*/
|
||||
private String auth;
|
||||
|
||||
private String shareUserId;
|
||||
|
||||
private String parentIds;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,4 +71,10 @@ public interface DocumentMapper {
|
|||
* @param vo
|
||||
*/
|
||||
void delDocument(TbDocumentFolder vo);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TbDocumentFolder> getUserListData();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,6 @@ import java.util.List;
|
|||
@Mapper
|
||||
public interface DocumentScreenMapper {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询公共
|
||||
* @param vo
|
||||
|
|
@ -66,4 +63,29 @@ public interface DocumentScreenMapper {
|
|||
* @return
|
||||
*/
|
||||
List<TbFolderFileVo> getFileFolderList(TbFolderFileVo vo);
|
||||
|
||||
/**
|
||||
* 新增文件标签
|
||||
* @param list
|
||||
*/
|
||||
void addDocumentLabels(@Param("list") List<TbUserLabel> list);
|
||||
|
||||
/**
|
||||
* 查询关联节点数据
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
TbFolderFileVo getDocumentRealData(TbFolderFileVo vo);
|
||||
|
||||
/**
|
||||
* 删除关联数据
|
||||
* @param data
|
||||
*/
|
||||
void deleteDocumentReal(TbFolderFileVo data);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param vo
|
||||
*/
|
||||
void updateDocumentParentId(TbFolderFileVo vo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,4 +39,18 @@ public interface DocumentScreenService {
|
|||
*/
|
||||
|
||||
List<TbFolderFileVo> getFileFolderList(TbFolderFileVo vo);
|
||||
|
||||
/**
|
||||
* 移动文件或文件夹
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult moveFile(TbFolderFileVo vo);
|
||||
|
||||
/**
|
||||
* 删除文件及文件夹
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult delete(TbFolderFileVo vo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,4 +33,10 @@ public interface DocumentService {
|
|||
* @return
|
||||
*/
|
||||
AjaxResult delDocument(TbDocumentFolder vo);
|
||||
|
||||
/**
|
||||
* 查询用户数据集合
|
||||
* @return
|
||||
*/
|
||||
List<TbDocumentFolder> getUserListData();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
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;
|
||||
|
|
@ -28,13 +27,13 @@ public class DocumentScreenImpl implements DocumentScreenService {
|
|||
@Autowired
|
||||
private FileUploadService service;
|
||||
|
||||
public String day= DateUtils.getCurrentDay();
|
||||
protected String day= DateUtils.getCurrentDay();
|
||||
|
||||
public String month=DateUtils.getCurrentMonth();
|
||||
protected String month=DateUtils.getCurrentMonth();
|
||||
|
||||
public String year=DateUtils.getCurrentYear();
|
||||
protected String year=DateUtils.getCurrentYear();
|
||||
|
||||
public static String file_path="/";
|
||||
protected String separator="/";
|
||||
/**
|
||||
* 查询文档中心树
|
||||
* @param vo
|
||||
|
|
@ -117,7 +116,7 @@ public class DocumentScreenImpl implements DocumentScreenService {
|
|||
|
||||
return AjaxResult.success("添加成功");
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage());
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return AjaxResult.error("添加失败");
|
||||
}
|
||||
|
|
@ -131,7 +130,6 @@ public class DocumentScreenImpl implements DocumentScreenService {
|
|||
@Override
|
||||
public AjaxResult importFile(MultipartFile[] file, TbUserFiles vo) {
|
||||
try{
|
||||
String type=vo.getType();
|
||||
if(file==null ||file.length==0){
|
||||
return AjaxResult.error("请上传附件");
|
||||
}
|
||||
|
|
@ -141,7 +139,9 @@ public class DocumentScreenImpl implements DocumentScreenService {
|
|||
if(StringUtils.isEmpty(vo.getType())){
|
||||
return AjaxResult.error("文件夹类型不能为空");
|
||||
}
|
||||
|
||||
if("2".equals(vo.getType())){
|
||||
vo.setId(vo.getId().split("_")[2]);
|
||||
}
|
||||
vo.setUploadUser(SecurityUtils.getUserId().toString());
|
||||
vo.setCreateUser(SecurityUtils.getUserId().toString());
|
||||
String repeatType=vo.getRepeatType();
|
||||
|
|
@ -195,7 +195,7 @@ public class DocumentScreenImpl implements DocumentScreenService {
|
|||
}
|
||||
return AjaxResult.success("上传成功");
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage());
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return AjaxResult.error("文件上传失败");
|
||||
}
|
||||
|
|
@ -208,29 +208,77 @@ public class DocumentScreenImpl implements DocumentScreenService {
|
|||
@Override
|
||||
public List<TbFolderFileVo> getFileFolderList(TbFolderFileVo vo) {
|
||||
try{
|
||||
|
||||
List<TbFolderFileVo> list=mapper.getFileFolderList(vo);
|
||||
// 文件夹类型
|
||||
String type=vo.getType();
|
||||
if("1".equals(type)){
|
||||
//公司文档 公共的查询全部
|
||||
|
||||
|
||||
|
||||
}else {
|
||||
|
||||
|
||||
|
||||
//自己的文档
|
||||
|
||||
}
|
||||
|
||||
return list;
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage());
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动文件/文件夹
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult moveFile(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())){
|
||||
return AjaxResult.success("当前文件件不允许移动");
|
||||
}else{
|
||||
//
|
||||
vo.setId(vo.getId().split("_")[2]);
|
||||
//如果是初始化节点
|
||||
if ("0".equals(vo.getParentId())) {
|
||||
TbFolderFileVo data=mapper.getDocumentRealData(vo);
|
||||
if("1".equals(data.getDataType())){
|
||||
return AjaxResult.success("共享及分享的文件夹不允许移动");
|
||||
}
|
||||
mapper.deleteDocumentReal(data);
|
||||
TbDocumentFolder documentFolder = getTbDocumentFolder(vo, data);
|
||||
mapper.addDocumentRealUser(documentFolder);
|
||||
}else{
|
||||
/**
|
||||
* 更新夫节点id
|
||||
*/
|
||||
mapper.updateDocumentParentId(vo);
|
||||
}
|
||||
}
|
||||
return AjaxResult.success("移动成功");
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
|
||||
return AjaxResult.error("移动失败");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult delete(TbFolderFileVo vo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private TbDocumentFolder getTbDocumentFolder(TbFolderFileVo vo, TbFolderFileVo data) {
|
||||
TbDocumentFolder documentFolder=new TbDocumentFolder();
|
||||
documentFolder.setPublicFolderId(vo.getNewParentId());
|
||||
documentFolder.setAuthType(data.getAuth());
|
||||
documentFolder.setUserId(data.getUserId());
|
||||
documentFolder.setId(data.getFolderId());
|
||||
documentFolder.setAuth(data.getAuth());
|
||||
documentFolder.setShareUserId(data.getShareUserId());
|
||||
documentFolder.setDataType(data.getDataType());
|
||||
return documentFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传附件
|
||||
* @param
|
||||
|
|
@ -238,12 +286,13 @@ public class DocumentScreenImpl implements DocumentScreenService {
|
|||
*/
|
||||
public AjaxResult uploadFile(List<MultipartFile> multipartFileList,TbUserFiles files){
|
||||
String type=files.getType();
|
||||
String filePath = "document/file/"+files.getUploadUser() +file_path +
|
||||
year + file_path + month + file_path + day +file_path ;
|
||||
String filePath = "document/file/"+files.getUploadUser() +separator +
|
||||
year + separator + month + separator + day +separator ;
|
||||
TbDocumentFolder documentFolder=new TbDocumentFolder();
|
||||
//文件类型
|
||||
String documentId=StringUtils.randomUUID();
|
||||
documentFolder.setFileType("1");
|
||||
documentFolder.setId(StringUtils.randomUUID());
|
||||
documentFolder.setId(documentId);
|
||||
documentFolder.setPublicFolderId(documentFolder.getParentId());
|
||||
if("1".equals(type)){
|
||||
documentFolder.setParentId("0");
|
||||
|
|
@ -251,14 +300,13 @@ public class DocumentScreenImpl implements DocumentScreenService {
|
|||
documentFolder.setParentId(files.getParentId());
|
||||
}
|
||||
documentFolder.setParentIds(documentFolder.getParentIds()+documentFolder.getParentId()+",");
|
||||
|
||||
//
|
||||
String[] ids=files.getLabelIds().split(",");
|
||||
String[] name= files.getLabels().split(",");
|
||||
List<TbUserLabel> list=new ArrayList<TbUserLabel>();
|
||||
TbUserLabel vo=new TbUserLabel();
|
||||
for (int i = 0; i <ids.length ; i++) {
|
||||
vo.setFileId(files.getFolderId());
|
||||
vo.setFileId(documentId);
|
||||
vo.setLabelId(ids[i]);
|
||||
vo.setLabelName(name[i]);
|
||||
list.add(vo);
|
||||
|
|
@ -295,6 +343,9 @@ public class DocumentScreenImpl implements DocumentScreenService {
|
|||
documentFolder.setUpdateUser(userId);
|
||||
//新增文档
|
||||
Integer num=mapper.addDocumentCompany(documentFolder);
|
||||
//新增文档标签
|
||||
mapper.addDocumentLabels(list);
|
||||
|
||||
if("1".equals(type)){
|
||||
documentFolder.setAuthType("4");
|
||||
//创建的都是4
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
|
@ -129,6 +130,20 @@ public class DocumentServiceImpl implements DocumentService {
|
|||
return AjaxResult.error("添加失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户数据集合
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<TbDocumentFolder> getUserListData() {
|
||||
try{
|
||||
return mapper.getUserListData();
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public AjaxResult getAjaxResult(TbDocumentFolder vo, String userId) {
|
||||
List<String> ids= Arrays.asList(userId.split(","));
|
||||
int addIds= mapper.addDocumentAuth(ids,vo.getId());
|
||||
|
|
|
|||
|
|
@ -68,4 +68,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
|
||||
</select>
|
||||
<select id="getUserListData" resultType="com.bonus.business.domain.TbDocumentFolder">
|
||||
select user_id userId,user_name useName
|
||||
from sys_user
|
||||
where status=0 AND del_flag=0
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -13,13 +13,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{labels},#{createUser},now(),#{updateUser},now(),0
|
||||
)
|
||||
</insert>
|
||||
<!--删除文件-->
|
||||
<update id="deleteCompanyFile">
|
||||
update tb_user_document_folder set from del_flag=1
|
||||
where id in (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
)
|
||||
</update>
|
||||
<delete id="deleteDocumentReal">
|
||||
delete from tb_public_real_user where public_folder_id=#{parentId} and user_id=#{userId} and user_folder_id=#{id}
|
||||
</delete>
|
||||
<insert id="addDocumnetLables">
|
||||
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}
|
||||
</foreach>
|
||||
)
|
||||
</insert>
|
||||
<insert id="addDocumentRealUser">
|
||||
replace into tb_public_real_user(
|
||||
public_folder_id, user_id, user_folder_id,auth, share_user_id, data_type
|
||||
)values (#{publicFolderId},#{userId},#{id},#{auth},#{shareUserId},#{dataType})
|
||||
|
||||
</insert>
|
||||
<update id="deleteCompanyFile">
|
||||
<!--添加文件-->
|
||||
<update id="addDocumentLabels">
|
||||
update tb_user_document_folder set from del_flag=1
|
||||
where id in (
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
|
|
@ -27,6 +46,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
)
|
||||
</update>
|
||||
<update id="updateDocumentParentId">
|
||||
update tb_user_document_folder set parent_id=#{parentId},parent_ids=#{parentIds}
|
||||
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
|
||||
|
|
@ -75,8 +98,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
<!--查询文件数据集合-->
|
||||
<select id="getFileFolderList" resultType="com.bonus.business.domain.TbFolderFileVo">
|
||||
|
||||
|
||||
<if test='type=="1" or type==1 '>
|
||||
select tpf.id,tpf.folder_name name ,tpf.parent_id parentId,tpf.parent_ids,1 type ,tpf.down_times downNum,0 fileType, '文件夹' fileSuffix,
|
||||
'' labName,
|
||||
tpf.see_times readNum,tpf.create_user,tpf.create_time createTime,tpf.update_time updateTime,su.user_name createUser
|
||||
from tb_public_folder tpf
|
||||
left join sys_user su on su.user_id=tpf.create_user
|
||||
where tpf.del_flag=0 and tpf.parent_id=#{parentId}
|
||||
union ALL
|
||||
SELECT
|
||||
tudf.id, tudf.folder_name,tudf.parent_id,tudf.parent_ids,2 type ,tudf.down_times,tudf.file_type fileType,tudf.file_suffix fileSuffix,
|
||||
tudf.labels labName,
|
||||
tudf.see_times, tudf.create_user,tudf.create_time,tudf.update_time,su.user_name
|
||||
FROM tb_public_real_user tpru
|
||||
left join tb_user_document_folder tudf on tpru.user_folder_id=tudf.id
|
||||
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 '>
|
||||
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,
|
||||
tudf.see_times readNum, tudf.create_user,tudf.create_time createTime,tudf.update_time updateTime,su.user_name createUser
|
||||
FROM tb_user_document_folder tudf
|
||||
left join tb_public_real_user tpru on tpru.user_folder_id=tudf.id
|
||||
left join sys_user su on su.user_id=tudf.create_user
|
||||
where tudf.del_flag=0 and tudf.parent_id=#{parentId}
|
||||
</if>
|
||||
</select>
|
||||
<select id="getDocumentRealData" resultType="com.bonus.business.domain.TbFolderFileVo">
|
||||
select
|
||||
public_folder_id publicFolderId,user_id userId, user_folder_id folderId,
|
||||
auth, share_user_id shareUserId, data_type dataType
|
||||
from tb_public_real_user
|
||||
where public_folder_id=#{parentId} and user_id=#{userId} and user_folder_id=#{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue