|
@@ -1,23 +1,26 @@
|
|
|
package com.doc.biz.controller;
|
|
|
|
|
|
import com.doc.biz.domain.DocDir;
|
|
|
+import com.doc.biz.domain.DocDirUser;
|
|
|
import com.doc.biz.domain.DocInfo;
|
|
|
+import com.doc.biz.domain.DocSpace;
|
|
|
import com.doc.biz.service.IDocDirService;
|
|
|
+import com.doc.biz.service.IDocDirUserService;
|
|
|
import com.doc.biz.service.IDocInfoService;
|
|
|
+import com.doc.biz.service.IDocSpaceService;
|
|
|
+import com.doc.biz.vo.TreeVO;
|
|
|
import com.doc.common.annotation.Log;
|
|
|
import com.doc.common.core.controller.BaseController;
|
|
|
import com.doc.common.core.domain.AjaxResult;
|
|
|
import com.doc.common.enums.BusinessType;
|
|
|
import com.doc.common.utils.SecurityUtils;
|
|
|
import com.doc.common.utils.poi.ExcelUtil;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiImplicitParam;
|
|
|
-import io.swagger.annotations.ApiImplicitParams;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.*;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -34,6 +37,83 @@ public class DocDirController extends BaseController {
|
|
|
private IDocDirService docDirService;
|
|
|
@Resource
|
|
|
private IDocInfoService docInfoService;
|
|
|
+ @Resource
|
|
|
+ private IDocSpaceService spaceService;
|
|
|
+ @Resource
|
|
|
+ private IDocDirUserService dirUserService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取目录树
|
|
|
+ */
|
|
|
+ @ApiOperation("目录树")
|
|
|
+ @GetMapping(value = "/dir-tree/{type}")
|
|
|
+ public TreeVO dirTree(@ApiParam(value = "目录类型(1.公共 2.部门 3.个人)", required = true) @PathVariable("type") String type) {
|
|
|
+ return tree(type, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取文件树
|
|
|
+ */
|
|
|
+ @ApiOperation("文件树")
|
|
|
+ @GetMapping(value = "/file-tree/{type}")
|
|
|
+ public TreeVO fileTree(@ApiParam(value = "目录类型(1.公共 2.部门 3.个人)", required = true) @PathVariable("type") String type) {
|
|
|
+ return tree(type, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取树
|
|
|
+ *
|
|
|
+ * @param type 空间类型
|
|
|
+ * @param fileTree 是否文件树 true 文件树,false 目录树
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private TreeVO tree(String type, boolean fileTree) {
|
|
|
+ DocSpace space = spaceService.selectDocSpaceList(type);
|
|
|
+ DocDir docDir = new DocDir();
|
|
|
+ docDir.setSpaceId(space.getSpaceId());
|
|
|
+ docDir.setParentId(0L);
|
|
|
+ List<DocDir> list = docDirService.selectDocDirList(docDir);
|
|
|
+
|
|
|
+ TreeVO vo = getChildren(list.get(0), fileTree);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 递归获取目录树
|
|
|
+ *
|
|
|
+ * @param dir 目录信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private TreeVO getChildren(DocDir dir, boolean fileTree) {
|
|
|
+ TreeVO vo = new TreeVO();
|
|
|
+ vo.setId(dir.getDirId());
|
|
|
+ vo.setLabel(dir.getDirName());
|
|
|
+
|
|
|
+ List<TreeVO> children = new ArrayList<>();
|
|
|
+
|
|
|
+ if (fileTree) {
|
|
|
+ vo.setDisabled(true);
|
|
|
+ DocInfo info = new DocInfo();
|
|
|
+ info.setDirId(dir.getDirId());
|
|
|
+ docInfoService.selectDocInfoList(info).forEach(d -> {
|
|
|
+ TreeVO childVO = new TreeVO();
|
|
|
+ childVO.setId(d.getDocId());
|
|
|
+ childVO.setLabel(d.getFileName());
|
|
|
+ childVO.setDisabled(false);
|
|
|
+ children.add(childVO);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ DocDir dir1 = new DocDir();
|
|
|
+ dir1.setParentId(dir.getDirId());
|
|
|
+ docDirService.selectDocDirList(dir1).forEach(d -> {
|
|
|
+ children.add(getChildren(d, fileTree));
|
|
|
+ });
|
|
|
+
|
|
|
+ vo.setChildren(children);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 查询文档目录管理列表
|
|
@@ -66,7 +146,11 @@ public class DocDirController extends BaseController {
|
|
|
//@PreAuthorize("@ss.hasPermi('biz:dir:query')")
|
|
|
@GetMapping(value = "/{dirId}")
|
|
|
public AjaxResult getInfo(@PathVariable("dirId") Long dirId) {
|
|
|
- return success(docDirService.selectDocDirByDirId(dirId));
|
|
|
+ DocDir dir = docDirService.selectDocDirByDirId(dirId);
|
|
|
+ DocDirUser dirUser = new DocDirUser();
|
|
|
+ dirUser.setDirId(dirId);
|
|
|
+ dir.setUsers(dirUserService.selectDocDirUserList(dirUser));
|
|
|
+ return success(dir);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -77,7 +161,16 @@ public class DocDirController extends BaseController {
|
|
|
@Log(title = "文档目录管理", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
public AjaxResult add(@RequestBody DocDir docDir) {
|
|
|
- return toAjax(docDirService.insertDocDir(docDir));
|
|
|
+ int i = docDirService.insertDocDir(docDir);
|
|
|
+ //如果是部门目录,则需要插入成员
|
|
|
+ String dept = "2";
|
|
|
+ if (dept.equals(docDir.getDirType())) {
|
|
|
+ docDir.getUsers().forEach(u -> {
|
|
|
+ u.setDirId(docDir.getDirId());
|
|
|
+ dirUserService.insertDocDirUser(u);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return toAjax(i);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -102,11 +195,20 @@ public class DocDirController extends BaseController {
|
|
|
/**
|
|
|
* 修改文档目录管理
|
|
|
*/
|
|
|
-// @ApiOperation("修改文档目录管理")
|
|
|
+ @ApiOperation("修改目录信息")
|
|
|
//@PreAuthorize("@ss.hasPermi('biz:dir:edit')")
|
|
|
@Log(title = "文档目录管理", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
public AjaxResult edit(@RequestBody DocDir docDir) {
|
|
|
+ //如果是部门目录,则需要插入成员
|
|
|
+ String dept = "2";
|
|
|
+ dirUserService.deleteDocDirUserByDirId(docDir.getDirId());
|
|
|
+ if (dept.equals(docDir.getDirType())) {
|
|
|
+ docDir.getUsers().forEach(u -> {
|
|
|
+ u.setDirId(docDir.getDirId());
|
|
|
+ dirUserService.insertDocDirUser(u);
|
|
|
+ });
|
|
|
+ }
|
|
|
return toAjax(docDirService.updateDocDir(docDir));
|
|
|
}
|
|
|
|