|
@@ -1,78 +1,121 @@
|
|
|
package org.springblade.manager.controller;
|
|
|
|
|
|
+import io.swagger.annotations.*;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiImplicitParam;
|
|
|
-import io.swagger.annotations.ApiImplicitParams;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
-import org.springblade.core.boot.ctrl.BladeController;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+
|
|
|
import org.springblade.core.cache.utils.CacheUtil;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
-import org.springblade.core.tool.support.Kv;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.manager.dto.ArchiveTreeDTO;
|
|
|
-import org.springblade.manager.dto.WbsTreeDTO;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springblade.manager.entity.ArchiveTree;
|
|
|
-import org.springblade.manager.entity.WbsTree;
|
|
|
-import org.springblade.manager.service.IArchiveTreeService;
|
|
|
import org.springblade.manager.vo.ArchiveTreeVO;
|
|
|
-import org.springblade.manager.vo.WbsTreeVO;
|
|
|
-import org.springblade.manager.wrapper.ArchiveTreeWrapper;
|
|
|
-import org.springblade.manager.wrapper.WbsTreeWrapper;
|
|
|
-import org.springblade.system.cache.DictCache;
|
|
|
-import org.springblade.system.enums.DictEnum;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springblade.manager.service.IArchiveTreeService;
|
|
|
+import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
-import javax.validation.Valid;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
|
|
|
|
|
/**
|
|
|
- * 归档树节点控制层
|
|
|
+ * 归档树 控制器
|
|
|
*
|
|
|
* @author liuyc
|
|
|
- * @since 2022-05-16
|
|
|
+ * @since 2022-06-29
|
|
|
*/
|
|
|
@RestController
|
|
|
@AllArgsConstructor
|
|
|
@RequestMapping("/archiveTree")
|
|
|
-@Api(value = "归档树配置", tags = "归档树配置接口")
|
|
|
+@Api(value = "归档树管理", tags = "归档树管理接口")
|
|
|
public class ArchiveTreeController extends BladeController {
|
|
|
|
|
|
private final IArchiveTreeService archiveTreeService;
|
|
|
|
|
|
+ /**
|
|
|
+ * 初始化归档树根节点
|
|
|
+ */
|
|
|
+ @PostMapping("/init")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation(value = "初始化归档树根节点")
|
|
|
+ public R<ArchiveTree> init() {
|
|
|
+ boolean b = archiveTreeService.initArchiveTree();
|
|
|
+ if (b) {
|
|
|
+ return R.success("初始化创建成功");
|
|
|
+ }
|
|
|
+ return R.fail(200, "初始化创建失败");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 详情
|
|
|
*/
|
|
|
@GetMapping("/detail")
|
|
|
- @ApiOperationSupport(order = 1)
|
|
|
- @ApiOperation(value = "详情", notes = "传入ArchiveTree,请求头token")
|
|
|
- @ApiImplicitParam(name = "id", value = "id", required = true)
|
|
|
- public R<ArchiveTreeVO> detail(ArchiveTree archiveTree) {
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "详情", notes = "传入archiveTree")
|
|
|
+ public R<ArchiveTree> detail(ArchiveTree archiveTree) {
|
|
|
ArchiveTree detail = archiveTreeService.getOne(Condition.getQueryWrapper(archiveTree));
|
|
|
- if (detail != null) {
|
|
|
- return R.data(ArchiveTreeWrapper.build().entityVO(detail));
|
|
|
+ return R.data(detail);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增
|
|
|
+ */
|
|
|
+ @PostMapping("/save")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation(value = "新增", notes = "传入ArchiveTreeDTO")
|
|
|
+ public R submit(@Valid @RequestBody ArchiveTreeDTO archiveTreeDTO) {
|
|
|
+ if (archiveTreeService.submit(archiveTreeDTO)) {
|
|
|
+ CacheUtil.clear(SYS_CACHE);
|
|
|
+ return R.data(archiveTreeDTO);
|
|
|
}
|
|
|
- return R.fail(200, "未查询到信息");
|
|
|
+ return R.fail(200, "操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改
|
|
|
+ */
|
|
|
+ @PostMapping("/update")
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @ApiOperation(value = "修改", notes = "传入ArchiveTree")
|
|
|
+ public R update(@Valid @RequestBody ArchiveTree archiveTree) {
|
|
|
+ return R.status(archiveTreeService.updateById(archiveTree));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ */
|
|
|
+ @PostMapping("/remove")
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation(value = "逻辑删除", notes = "传入id")
|
|
|
+ public R remove(@ApiParam(value = "id", required = true) @RequestParam String id) {
|
|
|
+ List<ArchiveTree> archiveTrees = archiveTreeService.selectByParentId(id);
|
|
|
+ archiveTrees.stream().forEach(archiveTree -> {
|
|
|
+ if (archiveTree.getParentId() == Long.parseLong(id)) {
|
|
|
+ throw new ServiceException("当前节点下存在子节点,删除失败");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return R.status(archiveTreeService.deleteLogic(Func.toLongList(id)));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 懒加载获取项目节点树形结构
|
|
|
+ * 懒加载树形结构
|
|
|
*/
|
|
|
@GetMapping("/lazy-tree")
|
|
|
- @ApiOperationSupport(order = 1)
|
|
|
- @ApiOperation(value = "懒加载归档节点树形结构", notes = "传入角色类型roleTypeNum,父级parentId,请求头token")
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
+ @ApiOperation(value = "懒加载树形结构", notes = "传入父级id,租户id,token")
|
|
|
@ApiImplicitParams(value = {
|
|
|
- @ApiImplicitParam(name = "roleTypeNum", value = "角色类型", required = true),
|
|
|
@ApiImplicitParam(name = "parentId", value = "父级id", required = true),
|
|
|
@ApiImplicitParam(name = "tenantId", value = "租户id", required = true),
|
|
|
+ @ApiImplicitParam(name = "token", value = "token", required = true)
|
|
|
})
|
|
|
- public R<List<ArchiveTreeVO>> lazyTree(String roleTypeNum, Long parentId, BladeUser bladeUser, String tenantId) {
|
|
|
- List<ArchiveTreeVO> tree = archiveTreeService.lazyTree(roleTypeNum, Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()), parentId);
|
|
|
+ public R<List<ArchiveTreeVO>> lazyTree(Long parentId, BladeUser bladeUser, String tenantId) {
|
|
|
+ List<ArchiveTreeVO> tree = archiveTreeService.lazyTree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()), parentId);
|
|
|
if (tree != null && tree.size() > 0) {
|
|
|
return R.data(tree);
|
|
|
}
|
|
@@ -80,19 +123,19 @@ public class ArchiveTreeController extends BladeController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取项目节点树形结构 (新增、修改加载、分配合同wbs树加载type=1)
|
|
|
- *
|
|
|
- * @return
|
|
|
+ * 全加载树形结构/显示树
|
|
|
*/
|
|
|
@GetMapping("/tree")
|
|
|
- @ApiOperationSupport(order = 2)
|
|
|
- @ApiOperation(value = "归档节点树形结构", notes = "传入租户Id、roleTypeNum、请求头token")
|
|
|
+ @ApiOperationSupport(order = 7)
|
|
|
+ @ApiOperation(value = "全加载树形结构/显示树", notes = "传入租户id、token、或disPlayTree=1加载显示树、nodeType")
|
|
|
@ApiImplicitParams(value = {
|
|
|
+ @ApiImplicitParam(name = "token", value = "token", required = true),
|
|
|
@ApiImplicitParam(name = "tenantId", value = "租户id", required = true),
|
|
|
- @ApiImplicitParam(name = "roleTypeNum", value = "角色类型", required = true)
|
|
|
+ @ApiImplicitParam(name = "disPlayTree", value = "是否加载显示树 'null'=不加载 '1'=加载"),
|
|
|
+ @ApiImplicitParam(name = "nodeType", value = "'null'=全加载 '1'=关联电子原生文件类型树 '2'=文件上传类型树")
|
|
|
})
|
|
|
- public R<List<ArchiveTreeVO>> tree(String roleTypeNum, String tenantId, BladeUser bladeUser) {
|
|
|
- List<ArchiveTreeVO> tree = archiveTreeService.tree(roleTypeNum , Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()));
|
|
|
+ public R<List<ArchiveTreeVO>> tree(String tenantId, BladeUser bladeUser, Integer disPlayTree, Integer nodeType) {
|
|
|
+ List<ArchiveTreeVO> tree = archiveTreeService.tree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()), disPlayTree, nodeType);
|
|
|
if (tree != null && tree.size() > 0) {
|
|
|
return R.data(tree);
|
|
|
}
|
|
@@ -100,19 +143,16 @@ public class ArchiveTreeController extends BladeController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 新增或修改
|
|
|
+ * 保存/修改上传文件显示配置树
|
|
|
*/
|
|
|
- @PostMapping("/submit")
|
|
|
- @ApiOperationSupport(order = 4)
|
|
|
- @ApiOperation(value = "归档树新增或修改", notes = "WbsTreeDTO")
|
|
|
- public R submit(@Valid @RequestBody ArchiveTreeDTO archiveTreeDTO) {
|
|
|
- if (archiveTreeService.submit(archiveTreeDTO)) {
|
|
|
- CacheUtil.clear(SYS_CACHE);
|
|
|
- // 返回懒加载树更新节点所需字段
|
|
|
- Kv kv = Kv.create().set("id", String.valueOf(archiveTreeDTO.getId())).set("tenantId", archiveTreeDTO.getTenantId());
|
|
|
- return R.data(kv);
|
|
|
- }
|
|
|
- return R.fail("操作失败");
|
|
|
+ @PostMapping("/submitDisplayConfigTree")
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @ApiOperation(value = "保存/修改上传文件显示配置树", notes = "传入ids")
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
+ @ApiImplicitParam(name = "ids", value = "ids", required = true)
|
|
|
+ })
|
|
|
+ public R<List<ArchiveTreeVO>> submitDisplayConfigTree(@RequestBody String ids) {
|
|
|
+ return R.status(archiveTreeService.submitDisplayConfigTree(ids));
|
|
|
}
|
|
|
|
|
|
|