Explorar el Código

feat: file and folder crud

Blizzard hace 1 año
padre
commit
b5f8f6033a
Se han modificado 31 ficheros con 1040 adiciones y 29 borrados
  1. 1 1
      blade-common/src/main/java/org/springblade/common/constant/LauncherConstant.java
  2. 0 7
      blade-service-api/wt-okr-api/pom.xml
  3. 4 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/dto/ProjectPageDTO.java
  4. 33 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/dto/UploadFileDTO.java
  5. 1 1
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/DeptToDept.java
  6. 57 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/FileAndFolder.java
  7. 31 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/FileAndFolderHistory.java
  8. 8 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/Project.java
  9. 31 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/vo/FileAndFolderVO.java
  10. 19 0
      blade-service/wt-okr/pom.xml
  11. 18 0
      blade-service/wt-okr/src/main/java/com/wtkj/config/FeignConfig.java
  12. 2 1
      blade-service/wt-okr/src/main/java/com/wtkj/controller/CommonController.java
  13. 153 0
      blade-service/wt-okr/src/main/java/com/wtkj/controller/FileAndFolderController.java
  14. 19 2
      blade-service/wt-okr/src/main/java/com/wtkj/controller/ProjectController.java
  15. 17 0
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/FileAndFolderHistoryMapper.java
  16. 13 0
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/FileAndFolderHistoryMapper.xml
  17. 26 0
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/FileAndFolderMapper.java
  18. 55 0
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/FileAndFolderMapper.xml
  19. 4 0
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectStageMapper.java
  20. 3 0
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectStageMapper.xml
  21. 21 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/ICommonService.java
  22. 17 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/IFileAndFolderHistoryService.java
  23. 37 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/IFileAndFolderService.java
  24. 3 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/IProjectStageService.java
  25. 179 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/CommonServiceImpl.java
  26. 7 3
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/DeptToDeptServiceImpl.java
  27. 25 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/FileAndFolderHistoryServiceImpl.java
  28. 166 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/FileAndFolderServiceImpl.java
  29. 4 14
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectServiceImpl.java
  30. 6 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectStageServiceImplService.java
  31. 80 0
      blade-service/wt-okr/src/main/java/com/wtkj/wrapper/FileAndFolderWrapper.java

+ 1 - 1
blade-common/src/main/java/org/springblade/common/constant/LauncherConstant.java

@@ -72,7 +72,7 @@ public interface LauncherConstant {
 	/**
 	 * seata dev 地址
 	 */
-	String SEATA_DEV_ADDR = "127.0.0.1:8091";
+	String SEATA_DEV_ADDR = "192.168.31.181:8091";
 
 	/**
 	 * seata prod 地址

+ 0 - 7
blade-service-api/wt-okr-api/pom.xml

@@ -13,11 +13,4 @@
 
     <name>wt-okr-api</name>
 
-    <dependencies>
-        <dependency>
-            <groupId>org.springblade</groupId>
-            <artifactId>blade-system-api</artifactId>
-            <version>2.9.1.RELEASE</version>
-        </dependency>
-    </dependencies>
 </project>

+ 4 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/dto/ProjectPageDTO.java

@@ -43,5 +43,9 @@ public class ProjectPageDTO implements Serializable {
 	@NotNull(message = "size不可为空")
 	private int size;
 
+	@ApiModelProperty(value = "当前登录用户的顶级机构id")
+	@NotNull(message = "topDept不可为空")
+	private Long topDept;
+
 
 }

+ 33 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/dto/UploadFileDTO.java

@@ -0,0 +1,33 @@
+package com.wtkj.dto;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 15:19
+ * @describe
+ */
+@Data
+public class UploadFileDTO implements Serializable {
+
+	@NotNull(message = "projectId不可为空")
+	@JsonSerialize(using = ToStringSerializer.class)
+	private Long projectId;
+
+	@JsonSerialize(using = ToStringSerializer.class)
+	@NotNull(message = "stageId不可为空")
+	private Long stageId;
+
+	@JsonSerialize(using = ToStringSerializer.class)
+	@NotNull(message = "parentId不可为空")
+	private Long parentId = 0L;
+
+	@JsonSerialize(using = ToStringSerializer.class)
+	@NotNull(message = "bladeFileId不可为空")
+	private Long bladeFileId;
+}

+ 1 - 1
blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/DeptToDept.java

@@ -26,8 +26,8 @@ public class DeptToDept extends BaseEntity {
 
 	@ApiModelProperty("租户ID")
 	private String tenantId;
-	@JsonSerialize(using = ToStringSerializer.class)
 
+	@JsonSerialize(using = ToStringSerializer.class)
 	@ApiModelProperty("父主键")
 	private Long parentId;
 

+ 57 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/FileAndFolder.java

@@ -0,0 +1,57 @@
+package com.wtkj.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 14:38
+ * @describe
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@TableName("blade_file_and_folder")
+public class FileAndFolder extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	@JsonSerialize(using = ToStringSerializer.class)
+	@TableField("project_id")
+	private Long projectId;
+
+	@JsonSerialize(using = ToStringSerializer.class)
+	@TableField("stage_id")
+	private Long stageId;
+
+	@JsonSerialize(using = ToStringSerializer.class)
+	@TableField("parent_id")
+	private Long parentId = 0L;
+
+	@TableField("title")
+	private String title;
+
+	@TableField("type")
+	@ApiModelProperty(value = "1:文件 2:文件夹")
+	@NotNull(message = "type不可为空")
+	private Integer type;
+
+	@JsonSerialize(using = ToStringSerializer.class)
+	@TableField("blade_file_id")
+	private Long bladeFileId;
+
+	@TableField("is_private")
+	@ApiModelProperty(value = "是否私有 1:是 0:否 默认否")
+	private Integer isPrivate = 0;
+
+	@TableField("private_user")
+	@JsonSerialize(using = ToStringSerializer.class)
+	private Long privateUser;
+}

+ 31 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/FileAndFolderHistory.java

@@ -0,0 +1,31 @@
+package com.wtkj.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 15:44
+ * @describe
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@TableName("blade_file_and_folder_history")
+public class FileAndFolderHistory extends BaseEntity {
+
+
+	//blade_file的主键id
+	@JsonSerialize(using = ToStringSerializer.class)
+	@TableField("latest_id")
+	private Long latestId;
+
+	//blade_file的主键id
+	@JsonSerialize(using = ToStringSerializer.class)
+	@TableField("history_id")
+	private Long historyId;
+}

+ 8 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/Project.java

@@ -44,6 +44,9 @@ public class Project extends BaseEntity {
 	@TableField("total_amount")
 	private BigDecimal totalAmount;
 
+	@TableField("construct_content")
+	private String constructContent;
+
 	@TableField("area_code")
 	@NotNull(message = "areaCode不可为空")
 	@ApiModelProperty(value = "地区编码")
@@ -65,6 +68,11 @@ public class Project extends BaseEntity {
 	@ApiModelProperty(value = "行业分类")
 	private Long industryId;
 
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
+	@ApiModelProperty(value = "开始时间")
+	private Date startTime;
+
 	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
 	@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
 	@ApiModelProperty(value = "截止时间")

+ 31 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/vo/FileAndFolderVO.java

@@ -0,0 +1,31 @@
+package com.wtkj.vo;
+
+import com.wtkj.entity.FileAndFolder;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 17:14
+ * @describe
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class FileAndFolderVO extends FileAndFolder {
+
+	private static final long serialVersionUID = 1L;
+
+	@ApiModelProperty(value = "权限 0:无 1:有")
+	private Integer auth = 0;
+
+	private String uploadUser;
+
+	private String uploadDept;
+
+	private Integer fileAmount;
+
+	private String volume;
+
+	private String url;
+}

+ 19 - 0
blade-service/wt-okr/pom.xml

@@ -13,6 +13,10 @@
 
 
     <dependencies>
+        <dependency>
+            <groupId>com.wtkj</groupId>
+            <artifactId>blade-common</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-boot</artifactId>
@@ -31,12 +35,27 @@
             <artifactId>blade-user-api</artifactId>
             <version>2.9.1.RELEASE</version>
         </dependency>
+        <dependency>
+            <groupId>org.springblade</groupId>
+            <artifactId>blade-system-api</artifactId>
+            <version>2.9.1.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>com.wtkj</groupId>
+            <artifactId>wutong-file-api</artifactId>
+            <version>2.9.1.RELEASE</version>
+        </dependency>
 
         <!--        分布式事务-->
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-starter-transaction</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+        </dependency>
     </dependencies>
 
 

+ 18 - 0
blade-service/wt-okr/src/main/java/com/wtkj/config/FeignConfig.java

@@ -0,0 +1,18 @@
+package com.wtkj.config;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-15 09:20
+ * @describe
+ */
+@Configuration
+@ComponentScan({"org.springblade", "com.wutong"})
+@EnableFeignClients({"org.springblade", "com.wutong"})
+@MapperScan({"org.springblade.**.mapper.**", "com.wtkj.**.mapper.**"})
+public class FeignConfig {
+}

+ 2 - 1
blade-service/wt-okr/src/main/java/com/wtkj/controller/CommonController.java

@@ -11,6 +11,7 @@ import org.springblade.core.tool.api.R;
 import org.springblade.system.entity.Dept;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
 import java.util.List;
 
 /**
@@ -42,7 +43,7 @@ public class CommonController {
 	@PostMapping("/sava-dept")
 	@ApiOperation(value = "新建政府机构", notes = "传入DeptToDept")
 	@ApiOperationSupport(order = 2)
-	public R<Boolean> createDept(@RequestBody DeptToDept dept) {
+	public R<Boolean> createDept(@RequestBody @Valid DeptToDept dept) {
 		return R.status(deptToDeptService.saveOrUpdate(dept));
 	}
 

+ 153 - 0
blade-service/wt-okr/src/main/java/com/wtkj/controller/FileAndFolderController.java

@@ -0,0 +1,153 @@
+package com.wtkj.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.wtkj.dto.UploadFileDTO;
+import com.wtkj.entity.FileAndFolder;
+import com.wtkj.service.ICommonService;
+import com.wtkj.service.IFileAndFolderService;
+import com.wtkj.vo.FileAndFolderVO;
+import com.wtkj.wrapper.FileAndFolderWrapper;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+import java.util.Objects;
+
+import static com.wtkj.config.MagicValue.ONE;
+import static com.wtkj.config.MagicValue.TWO;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 15:06
+ * @describe
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/file-and-folder")
+@Api(value = "文件和文件夹模块", tags = "文件和文件夹模块")
+public class FileAndFolderController {
+
+	private final IFileAndFolderService fileAndFolderService;
+
+	private final ICommonService commonService;
+
+
+	/**
+	 * 新建文件夹
+	 */
+	@PostMapping("/submit")
+	@ApiOperation(value = "创建修改文件夹或者文件", notes = "")
+	@ApiOperationSupport(order = 1)
+	public R<Boolean> createFolder(@RequestBody FileAndFolder folder) {
+		LambdaQueryWrapper<FileAndFolder> lqw = new LambdaQueryWrapper<>();
+		lqw.eq(FileAndFolder::getStageId, folder.getStageId());
+		lqw.eq(FileAndFolder::getTitle, folder.getTitle());
+		if (Objects.equals(folder.getType(), ONE)) {
+			lqw.eq(FileAndFolder::getType, ONE);
+			long cnt = fileAndFolderService.count(lqw);
+			if (cnt > 0L) {
+				throw new ServiceException("此项目阶段下已经存在同名文件夹");
+			}
+		} else if (Objects.equals(folder.getType(), TWO)) {
+			lqw.eq(FileAndFolder::getType, TWO);
+			long cnt = fileAndFolderService.count(lqw);
+			if (cnt > 0L) {
+				throw new ServiceException("此项目阶段下已经存在同名文件夹");
+			}
+		}
+		return R.status(fileAndFolderService.saveOrUpdate(folder));
+	}
+
+	/**
+	 * 上传文件
+	 */
+	@PostMapping("/upload-file")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "上传文件提示覆盖", notes = "")
+	public R<Boolean> uploadFile(@Valid @RequestBody List<UploadFileDTO> files) {
+		//判断是否存在重名文件
+		boolean isExist = fileAndFolderService.isExistSameName(files);
+		if (isExist) {
+			//存同名文件 提示
+			return R.fail("存在重名文件,是否覆盖");
+		} else {
+			//不存在同名文件 直接上传
+			return R.status(commonService.uploadFile(files));
+		}
+	}
+
+	/**
+	 * 文件覆盖
+	 */
+	@PostMapping("/cover-file")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "上传直接覆盖同名文件", notes = "")
+	public R<Boolean> coverFile(@Valid @RequestBody List<UploadFileDTO> files) {
+		return R.status(commonService.coverFile(files));
+	}
+
+	/**
+	 * 阶段下的文件夹和文件
+	 */
+	@GetMapping("/page-by-stage")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "阶段下的顶级文件和文件夹", notes = "")
+	public R<IPage<FileAndFolderVO>> pageByStage(@RequestParam("stageId") Long stageId, Query query) {
+		IPage<FileAndFolder> page = fileAndFolderService.pageByStageId(stageId, Condition.getPage(query));
+		return R.data(FileAndFolderWrapper.build().pageVO(page));
+	}
+
+	/**
+	 * 文件夹下的文件和文件夹
+	 */
+	@GetMapping("/page-by-parent")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "文件夹下的文件和文件夹", notes = "")
+	public R<IPage<FileAndFolderVO>> pageByParentId(@RequestParam("parentId") Long parentId, Query query) {
+		IPage<FileAndFolder> page = fileAndFolderService.pageByParentId(parentId, Condition.getPage(query));
+		return R.data(FileAndFolderWrapper.build().pageVO(page));
+	}
+
+	/**
+	 * 文件夹下的文件数量  页码数量
+	 */
+	@GetMapping("/file-and-page-amount")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "文夹下的文件数量", notes = "传入文件夹主键id")
+	public R<JSONObject> getPageAmount(@RequestParam Long stageId, @RequestParam Long parentId) {
+		return R.data(fileAndFolderService.getPageAndFileAmount(stageId, parentId));
+	}
+
+	/**
+	 * 删除文件/文件夹
+	 */
+	@GetMapping("/remove")
+	@ApiOperationSupport(order = 7)
+	@ApiOperation(value = "删除文件夹或文件", notes = "")
+	public R<Boolean> delete(@RequestParam String ids) {
+		return R.status(commonService.remove(Func.toLongList(ids)));
+	}
+
+	/**
+	 * 文件或者文件夹移动
+	 */
+	@GetMapping("/move")
+	@ApiOperationSupport(order = 8)
+	@ApiOperation(value = "移动文件或者文件夹", notes = "")
+	public R<Boolean> move(String ids, Long stageId, Long parentId) {
+		return R.status(commonService.move(ids, stageId, parentId));
+	}
+
+
+}

+ 19 - 2
blade-service/wt-okr/src/main/java/com/wtkj/controller/ProjectController.java

@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.wtkj.dto.ProjectPageDTO;
 import com.wtkj.entity.Project;
+import com.wtkj.entity.ProjectStage;
 import com.wtkj.service.IAsyncService;
 import com.wtkj.service.IProjectService;
+import com.wtkj.service.IProjectStageService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
@@ -15,6 +17,9 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
+import java.util.List;
+
 /**
  * @author Blizzard
  * @create at 2023-09-13 15:50
@@ -30,13 +35,15 @@ public class ProjectController {
 
 	private final IAsyncService asyncService;
 
+	private final IProjectStageService stageService;
+
 	/**
 	 * 创建/修改项目
 	 */
 	@PostMapping("/submit")
 	@ApiOperation(value = "新建或者修改项目", notes = "传入project")
 	@ApiOperationSupport(order = 1)
-	public R<Boolean> create(@RequestBody Project project) {
+	public R<Boolean> create(@RequestBody @Valid Project project) {
 		return R.status(projectService.submit(project));
 	}
 
@@ -46,7 +53,7 @@ public class ProjectController {
 	@PostMapping("/page")
 	@ApiOperation(value = "分页", notes = "")
 	@ApiOperationSupport(order = 2)
-	public R page(@RequestBody ProjectPageDTO dto) {
+	public R page(@RequestBody @Valid ProjectPageDTO dto) {
 		Query query = new Query();
 		query.setCurrent(dto.getCurrent());
 		query.setSize(dto.getSize());
@@ -69,4 +76,14 @@ public class ProjectController {
 		return R.status(b);
 	}
 
+	/**
+	 * 项目下的所有阶段
+	 */
+	@GetMapping("/stage-list")
+	@ApiOperation(value = "项目下的所有阶段", notes = "传入projectId")
+	@ApiOperationSupport(order = 7)
+	public R<List<ProjectStage>> stageList(Long projectId) {
+		return R.data(stageService.listByProjectId(projectId));
+	}
+
 }

+ 17 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/FileAndFolderHistoryMapper.java

@@ -0,0 +1,17 @@
+package com.wtkj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.wtkj.entity.FileAndFolderHistory;
+
+import java.util.List;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 16:12
+ * @describe
+ */
+public interface FileAndFolderHistoryMapper extends BaseMapper<FileAndFolderHistory> {
+	List<FileAndFolderHistory> selectByLatestId(Long bladeFileId);
+
+
+}

+ 13 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/FileAndFolderHistoryMapper.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.wtkj.mapper.FileAndFolderHistoryMapper">
+
+
+    <select id="selectByLatestId" resultType="com.wtkj.entity.FileAndFolderHistory">
+        select * from blade_file_and_folder_history where is_deleted = 0 and latest_id = #{param}
+    </select>
+
+    <select id="getFileAmountByFolderId" resultType="java.lang.Integer">
+        select count(id) from blade_file_folder where is_deleted = 0 and parent_id = #{param1} and type = 1
+    </select>
+</mapper>

+ 26 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/FileAndFolderMapper.java

@@ -0,0 +1,26 @@
+package com.wtkj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.wtkj.entity.FileAndFolder;
+
+import java.util.List;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 15:03
+ * @describe
+ */
+public interface FileAndFolderMapper extends BaseMapper<FileAndFolder> {
+	List<FileAndFolder> selectByStage(Long stageId, IPage<FileAndFolder> page);
+
+	Integer getFileAmountByFolderId(Long stageId, Long folderId);
+
+	List<FileAndFolder> getChildrenFolderList(Long stageId, Long folderId);
+
+	List<FileAndFolder> selectByParent(Long parentId, IPage<FileAndFolder> page);
+
+	List<FileAndFolder> getChildrenFileList(Long stageId, Long parentId);
+
+	List<FileAndFolder> getChildren(Long stageId, Long parentId);
+}

+ 55 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/FileAndFolderMapper.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.wtkj.mapper.FileAndFolderMapper">
+
+
+    <select id="selectByStage" resultType="com.wtkj.entity.FileAndFolder">
+        select * from blade_file_and_folder where is_deleted = 0 and parent_id = 0 and stage_id = #{param1}
+        order by type desc, is_private
+    </select>
+
+    <select id="getFileAmountByFolderId" resultType="java.lang.Integer">
+        select count(id) from blade_file_and_folder where is_deleted = 0 and type = 1
+        <if test="param1 != null">
+            and stage_id = #{param1}
+        </if>
+        <if test="param2 != null">
+            and parent_id = #{param2}
+        </if>
+    </select>
+
+    <select id="getChildrenFolderList" resultType="com.wtkj.entity.FileAndFolder">
+        select * from blade_file_and_folder where is_deleted = 0 and type = 2
+        <if test="param1 != null">
+            and stage_id = #{param1}
+        </if>
+        <if test="param2 != null">
+            and parent_id = #{param2}
+        </if>
+    </select>
+
+    <select id="selectByParent" resultType="com.wtkj.entity.FileAndFolder">
+        select * from blade_file_and_folder where is_deleted = 0 and parent_id = #{param1}
+        order by type desc, is_private
+    </select>
+
+    <select id="getChildrenFileList" resultType="com.wtkj.entity.FileAndFolder">
+        select * from blade_file_and_folder where is_deleted = 0 and type = 1
+        <if test="param1 != null">
+            stage_id = #{param1}
+        </if>
+        <if test="param2 != null">
+            and parent_id = #{param2}
+        </if>
+    </select>
+
+    <select id="getChildren" resultType="com.wtkj.entity.FileAndFolder">
+        select * from blade_file_and_folder where is_deleted = 0
+        <if test="param1 != null">
+            and stage_id = #{param1}
+        </if>
+        <if test="param2 != null">
+            and parent_id = #{param2}
+        </if>
+    </select>
+</mapper>

+ 4 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectStageMapper.java

@@ -3,10 +3,14 @@ package com.wtkj.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.wtkj.entity.ProjectStage;
 
+import java.util.List;
+
 /**
  * @author Blizzard
  * @create at 2023-09-13 16:46
  * @describe
  */
 public interface ProjectStageMapper extends BaseMapper<ProjectStage> {
+	List<ProjectStage> selectByProjectId(Long projectId);
+
 }

+ 3 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectStageMapper.xml

@@ -3,4 +3,7 @@
 <mapper namespace="com.wtkj.mapper.ProjectStageMapper">
 
 
+    <select id="selectByProjectId" resultType="com.wtkj.entity.ProjectStage">
+        select * from blade_project_stage where is_deleted = 0 and project_id = #{param}
+    </select>
 </mapper>

+ 21 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/ICommonService.java

@@ -0,0 +1,21 @@
+package com.wtkj.service;
+
+import com.wtkj.dto.UploadFileDTO;
+
+import java.util.List;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 16:07
+ * @describe 公共service 避免本类调用事务失效的问题
+ */
+public interface ICommonService {
+
+	boolean uploadFile(List<UploadFileDTO> files);
+
+	boolean coverFile(List<UploadFileDTO> files);
+
+	boolean remove(List<Long> ids);
+
+	boolean move(String ids, Long stageId, Long parentId);
+}

+ 17 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/IFileAndFolderHistoryService.java

@@ -0,0 +1,17 @@
+package com.wtkj.service;
+
+import com.wtkj.entity.FileAndFolderHistory;
+import org.springblade.core.mp.base.BaseService;
+
+import java.util.List;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 16:13
+ * @describe
+ */
+public interface IFileAndFolderHistoryService extends BaseService<FileAndFolderHistory> {
+	List<FileAndFolderHistory> getByLatestId(Long bladeFileId);
+
+
+}

+ 37 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/IFileAndFolderService.java

@@ -0,0 +1,37 @@
+package com.wtkj.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.wtkj.dto.UploadFileDTO;
+import com.wtkj.entity.FileAndFolder;
+import org.springblade.core.mp.base.BaseService;
+
+import java.util.List;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 15:04
+ * @describe
+ */
+public interface IFileAndFolderService extends BaseService<FileAndFolder> {
+	boolean isExistSameName(List<UploadFileDTO> files);
+
+	IPage<FileAndFolder> pageByStageId(Long stageId, IPage<FileAndFolder> page);
+
+	/**
+	 * 文件夹下的文件数量
+	 */
+	Integer getFileAmountByFolderId(Long stageId, Long parentId);
+
+	IPage<FileAndFolder> pageByParentId(Long parentId, IPage<FileAndFolder> page);
+
+	JSONObject getPageAndFileAmount(Long stageId, Long parentId);
+
+	List<FileAndFolder> getChildrenFilesByFolderId(Long stageId, Long parentId);
+
+	List<FileAndFolder> getChildrenFolderByFolderId(Long stageId, Long parentId);
+
+	List<FileAndFolder> getChildren(Long stageId, Long parentId);
+
+
+}

+ 3 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/IProjectStageService.java

@@ -3,10 +3,13 @@ package com.wtkj.service;
 import com.wtkj.entity.ProjectStage;
 import org.springblade.core.mp.base.BaseService;
 
+import java.util.List;
+
 /**
  * @author Blizzard
  * @create at 2023-09-13 16:49
  * @describe
  */
 public interface IProjectStageService extends BaseService<ProjectStage> {
+	List<ProjectStage> listByProjectId(Long projectId);
 }

+ 179 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/CommonServiceImpl.java

@@ -0,0 +1,179 @@
+package com.wtkj.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.wtkj.dto.UploadFileDTO;
+import com.wtkj.entity.FileAndFolder;
+import com.wtkj.entity.FileAndFolderHistory;
+import com.wtkj.service.ICommonService;
+import com.wtkj.service.IFileAndFolderHistoryService;
+import com.wtkj.service.IFileAndFolderService;
+import com.wutong.file.feign.IFileClient;
+import com.wutong.file.vo.FileVO;
+import lombok.AllArgsConstructor;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.StringUtil;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+import static com.wtkj.config.MagicValue.TWO;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 16:07
+ * @describe
+ */
+@Service
+@AllArgsConstructor
+public class CommonServiceImpl implements ICommonService {
+
+	private final IFileClient fileClient;
+	private final IFileAndFolderService fileAndFolderService;
+	private final IFileAndFolderHistoryService historyService;
+
+
+	@Override
+	public boolean uploadFile(List<UploadFileDTO> files) {
+		boolean flag = false;
+		List<FileAndFolder> fileList = new ArrayList<>();
+		if (!CollectionUtils.isEmpty(files)) {
+			Long projectId = files.get(0).getProjectId();
+			Long parentId = files.get(0).getParentId();
+			Long stageId = files.get(0).getStageId();
+			files.forEach(file -> {
+				Long fileId = file.getBladeFileId();
+				R<FileVO> rpc = fileClient.findById(fileId);
+				if (rpc.isSuccess()) {
+					FileAndFolder newFile = new FileAndFolder();
+					newFile.setProjectId(projectId);
+					newFile.setStageId(stageId);
+					newFile.setParentId(parentId);
+					newFile.setBladeFileId(file.getBladeFileId());
+					newFile.setType(1);
+					newFile.setTitle(rpc.getData().getOriginalFileName());
+					if (parentId != null && parentId > 0L) {
+						FileAndFolder folder = fileAndFolderService.getById(parentId);
+						if (folder != null) {
+							newFile.setIsPrivate(folder.getIsPrivate());
+							newFile.setPrivateUser(folder.getPrivateUser());
+						}
+					}
+					fileList.add(newFile);
+				}
+			});
+
+			flag = fileAndFolderService.saveBatch(fileList);
+		}
+		return flag;
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public boolean coverFile(List<UploadFileDTO> files) {
+		boolean flag = false;
+		List<FileAndFolder> fileList = new ArrayList<>();
+		List<FileAndFolderHistory> histories = new ArrayList<>();
+		if (!CollectionUtils.isEmpty(files)) {
+			Long projectId = files.get(0).getProjectId();
+			Long parentId = files.get(0).getParentId();
+			Long stageId = files.get(0).getStageId();
+			files.forEach(file -> {
+				Long fileId = file.getBladeFileId();
+				R<FileVO> rpc = fileClient.findById(fileId);
+				if (rpc.isSuccess()) {
+					//是否存在同名文件
+					LambdaQueryWrapper<FileAndFolder> lqw = Wrappers.lambdaQuery();
+					lqw.eq(FileAndFolder::getParentId, parentId);
+					lqw.eq(FileAndFolder::getTitle, rpc.getData().getOriginalFileName());
+					FileAndFolder old = fileAndFolderService.getOne(lqw);
+					if (old != null) {
+						//存在同名文件
+						//此处不删除旧的同名文件,直接修改值 ---> 再保存历史记录信息  修改已存在的的数据 更新url 文件大小等信息
+						//先根据旧的fileId判断是否存在历史记录
+						List<FileAndFolderHistory> hisList = historyService.getByLatestId(old.getBladeFileId());
+						if (!CollectionUtils.isEmpty(hisList)) {
+							histories.forEach(h -> {
+								h.setLatestId(fileId);
+								histories.add(h);
+							});
+						}
+						//历史文件和新上传文件不是同一个的时候才保存
+						if (!fileId.equals(old.getBladeFileId())) {
+							FileAndFolderHistory his = new FileAndFolderHistory();
+							his.setLatestId(fileId);
+							his.setHistoryId(old.getBladeFileId());
+							hisList.add(his);
+						}
+						old.setBladeFileId(fileId);
+					} else {
+						FileAndFolder newFile = new FileAndFolder();
+						newFile.setProjectId(projectId);
+						newFile.setStageId(stageId);
+						newFile.setParentId(parentId);
+						newFile.setBladeFileId(file.getBladeFileId());
+						newFile.setType(1);
+						newFile.setTitle(rpc.getData().getOriginalFileName());
+						if (parentId != null && parentId > 0L) {
+							FileAndFolder folder = fileAndFolderService.getById(parentId);
+							if (folder != null) {
+								newFile.setIsPrivate(folder.getIsPrivate());
+								newFile.setPrivateUser(folder.getPrivateUser());
+							}
+						}
+						fileList.add(newFile);
+					}
+				}
+			});
+			if (!CollectionUtils.isEmpty(histories)) {
+				historyService.saveOrUpdateBatch(histories);
+			}
+			flag = fileAndFolderService.saveOrUpdateBatch(fileList);
+		}
+		return flag;
+	}
+
+	@Override
+	public boolean remove(List<Long> ids) {
+		boolean flag = false;
+		if (!CollectionUtils.isEmpty(ids)) {
+			ids.forEach(id -> {
+				FileAndFolder byId = fileAndFolderService.getById(id);
+				//如果是文件夹
+				if (Objects.equals(byId.getType(), TWO)) {
+					List<FileAndFolder> children = fileAndFolderService.getChildren(null, id);
+					if (!CollectionUtils.isEmpty(children)) {
+						throw new ServiceException("删除文件夹失败:请先删除下级");
+					}
+				}
+			});
+			flag = fileAndFolderService.removeByIds(ids);
+		}
+		return flag;
+	}
+
+	@Override
+	public boolean move(String ids, Long stageId, Long parentId) {
+		boolean flag = false;
+		if (StringUtil.isNotBlank(ids)) {
+			List<FileAndFolder> list = new ArrayList<>();
+			List<Long> idList = Func.toLongList(ids);
+			idList.forEach(id -> {
+				FileAndFolder byId = fileAndFolderService.getById(id);
+				if (byId != null) {
+					byId.setStageId(stageId);
+					byId.setParentId(parentId);
+					list.add(byId);
+				}
+			});
+			flag = fileAndFolderService.updateBatchById(list);
+		}
+		return flag;
+	}
+}

+ 7 - 3
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/DeptToDeptServiceImpl.java

@@ -32,7 +32,7 @@ import static com.wtkj.config.MagicValue.ZERO;
 @AllArgsConstructor
 public class DeptToDeptServiceImpl extends BaseServiceImpl<DeptToDeptMapper, DeptToDept> implements IDeptToDeptService {
 
-	private ISysClient sysClient;
+	private final ISysClient sysClient;
 
 	@Override
 	public AuthUserInfo userInfo() {
@@ -48,8 +48,12 @@ public class DeptToDeptServiceImpl extends BaseServiceImpl<DeptToDeptMapper, Dep
 					// ancestors 0,1689540492698267649
 					if (ancestors != null && ancestors.contains(String.valueOf(ZERO))) {
 						List<Long> longList = Func.toLongList(ancestors);
-						if (!CollectionUtils.isEmpty(longList) && longList.size() > 2) {
-							userInfo.setTopDept(longList.get(1));
+						if (!CollectionUtils.isEmpty(longList)) {
+							if (longList.size() > 2) {
+								userInfo.setTopDept(longList.get(1));
+							} else {
+								userInfo.setTopDept(Long.valueOf(deptIdStr));
+							}
 						}
 					}
 				}

+ 25 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/FileAndFolderHistoryServiceImpl.java

@@ -0,0 +1,25 @@
+package com.wtkj.service.impl;
+
+import com.wtkj.entity.FileAndFolderHistory;
+import com.wtkj.mapper.FileAndFolderHistoryMapper;
+import com.wtkj.service.IFileAndFolderHistoryService;
+import lombok.AllArgsConstructor;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 16:14
+ * @describe
+ */
+@Service
+@AllArgsConstructor
+public class FileAndFolderHistoryServiceImpl extends BaseServiceImpl<FileAndFolderHistoryMapper, FileAndFolderHistory> implements IFileAndFolderHistoryService {
+	@Override
+	public List<FileAndFolderHistory> getByLatestId(Long bladeFileId) {
+		return baseMapper.selectByLatestId(bladeFileId);
+	}
+
+}

+ 166 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/FileAndFolderServiceImpl.java

@@ -0,0 +1,166 @@
+package com.wtkj.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.wtkj.dto.UploadFileDTO;
+import com.wtkj.entity.FileAndFolder;
+import com.wtkj.mapper.FileAndFolderMapper;
+import com.wtkj.service.IFileAndFolderService;
+import com.wutong.file.feign.IFileClient;
+import com.wutong.file.vo.FileVO;
+import lombok.AllArgsConstructor;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.core.tool.api.R;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 15:05
+ * @describe
+ */
+@Service
+@AllArgsConstructor
+public class FileAndFolderServiceImpl extends BaseServiceImpl<FileAndFolderMapper, FileAndFolder> implements IFileAndFolderService {
+
+	private final IFileClient fileClient;
+
+	@Override
+	public boolean isExistSameName(List<UploadFileDTO> files) {
+		boolean flag = false;
+		List<FileAndFolder> isExists = new ArrayList<>();
+		if (!CollectionUtils.isEmpty(files)) {
+			files.forEach(f -> {
+				Long fileId = f.getBladeFileId();
+				R<FileVO> rpc = fileClient.findById(fileId);
+				if (rpc.isSuccess()) {
+					Long parentId = f.getParentId();
+					//是否存在重名文件
+					LambdaQueryWrapper<FileAndFolder> lqw = new LambdaQueryWrapper<>();
+					lqw.eq(FileAndFolder::getStageId, f.getStageId());
+					lqw.eq(FileAndFolder::getParentId, parentId);
+					lqw.eq(FileAndFolder::getTitle, rpc.getData().getOriginalFileName());
+					List<FileAndFolder> list = this.list(lqw);
+					if (!CollectionUtils.isEmpty(list)) {
+						isExists.addAll(list);
+					}
+				}
+			});
+		}
+		if (!CollectionUtils.isEmpty(isExists)) {
+			flag = true;
+		}
+		return flag;
+	}
+
+	@Override
+	public IPage<FileAndFolder> pageByStageId(Long stageId, IPage<FileAndFolder> page) {
+		return page.setRecords(baseMapper.selectByStage(stageId, page));
+	}
+
+	@Override
+	public Integer getFileAmountByFolderId(Long stageId, Long parentId) {
+		//递归子级文件夹 获取文件个数
+		return getChildrenFileAmountByFolderId(0, stageId, parentId);
+	}
+
+	@Override
+	public IPage<FileAndFolder> pageByParentId(Long parentId, IPage<FileAndFolder> page) {
+		return page.setRecords(baseMapper.selectByParent(parentId, page));
+	}
+
+	@Override
+	public JSONObject getPageAndFileAmount(Long stageId, Long parentId) {
+		JSONObject result = new JSONObject();
+		//文件数量
+		Integer fileAmount = this.getFileAmountByFolderId(stageId, parentId);
+		result.put("amount", fileAmount);
+		//文件
+		int totalPage = 0;
+		int volume = 0;
+		List<FileAndFolder> files = this.getChildrenFilesByFolderId(stageId, parentId);
+		if (!CollectionUtils.isEmpty(files)) {
+			totalPage = files.stream().filter(f -> f.getBladeFileId() != null).map(f -> fileClient.findImageList(f.getBladeFileId())).filter(rpc -> rpc.isSuccess() && rpc.getData() != null).map(R::getData).mapToInt(List::size).sum();
+			volume = files.stream().filter(f -> f.getBladeFileId() != null).map(f -> fileClient.findById(f.getBladeFileId())).filter(rpc -> rpc.isSuccess() && rpc.getData() != null).map(R::getData).map(FileVO::getVolume).mapToInt(Integer::parseInt).sum();
+		}
+		result.put("totalPage", totalPage);
+		result.put("volume", volume);
+		int folderAmount = 0;
+		List<FileAndFolder> folders = this.getChildrenFolderByFolderId(stageId, parentId);
+		if (!CollectionUtils.isEmpty(folders)) {
+			folderAmount = folders.size();
+		}
+		result.put("folderAmount", folderAmount);
+		return result;
+	}
+
+	@Override
+	public List<FileAndFolder> getChildrenFilesByFolderId(Long stageId, Long parentId) {
+		return getChildrenFileByFolderId(new ArrayList<>(), stageId, parentId);
+	}
+
+	@Override
+	public List<FileAndFolder> getChildrenFolderByFolderId(Long stageId, Long parentId) {
+		return baseMapper.getChildrenFolderList(stageId, parentId);
+	}
+
+	@Override
+	public List<FileAndFolder> getChildren(Long stageId, Long parentId) {
+		return getChildrenByFolderId(new ArrayList<>(), stageId, parentId);
+	}
+
+
+	private List<FileAndFolder> getChildrenByFolderId(ArrayList<FileAndFolder> result, Long stageId, Long parentId) {
+		//文件下的文件和文件夹
+		List<FileAndFolder> children = baseMapper.getChildren(stageId, parentId);
+		if (!org.springframework.util.CollectionUtils.isEmpty(children)) {
+			result.addAll(children);
+		}
+		//本级的文件夹
+		List<FileAndFolder> childrenFolder = baseMapper.getChildrenFolderList(stageId, parentId);
+		if (!org.springframework.util.CollectionUtils.isEmpty(childrenFolder)) {
+			for (FileAndFolder folder : childrenFolder) {
+				getChildrenByFolderId(result, folder.getStageId(), folder.getId());
+			}
+		}
+		return result;
+	}
+
+	private List<FileAndFolder> getChildrenFileByFolderId(ArrayList<FileAndFolder> result, Long stageId, Long parentId) {
+		//本级下的文件
+		List<FileAndFolder> files = baseMapper.getChildrenFileList(stageId, parentId);
+		if (!org.springframework.util.CollectionUtils.isEmpty(files)) {
+			result.addAll(files);
+		}
+		//本级的文件夹
+		List<FileAndFolder> childrenFolder = baseMapper.getChildrenFolderList(stageId, parentId);
+		//递归出口,子集不为空时,一直去遍历
+		if (!CollectionUtils.isEmpty(childrenFolder)) {
+			for (FileAndFolder folder : childrenFolder) {
+				getChildrenFileByFolderId(result, folder.getStageId(), folder.getId());
+			}
+		}
+		return result;
+	}
+
+
+	private Integer getChildrenFileAmountByFolderId(int count, Long stageId, Long folderId) {
+		//本级下的文件数量
+		count = count + baseMapper.getFileAmountByFolderId(stageId, folderId);
+		//本级下的文件夹
+		List<FileAndFolder> children = baseMapper.getChildrenFolderList(stageId, folderId);
+		//递归出口,子集不为空时,一直去遍历
+		if (children != null && !children.isEmpty()) {
+			for (FileAndFolder child : children) {
+				int cnt = getChildrenFileAmountByFolderId(0, child.getStageId(), child.getId());
+				count = cnt + count;
+			}
+		}
+		return count;
+	}
+
+}

+ 4 - 14
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectServiceImpl.java

@@ -14,7 +14,6 @@ import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.secure.BladeUser;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
-import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.system.entity.Dept;
 import org.springblade.system.feign.ISysClient;
@@ -26,7 +25,6 @@ import java.util.Set;
 import java.util.stream.Collectors;
 
 import static com.wtkj.config.MagicValue.STAFF_ADMIN;
-import static com.wtkj.config.MagicValue.ZERO;
 
 /**
  * @author Blizzard
@@ -83,18 +81,10 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, Project>
 				//如果不是业主 ---> 判断是否是服务商的管理员  服务商管理员可以查看所有的项目
 				String userRole = AuthUtil.getUserRole();
 				if (userRole != null && userRole.equals(STAFF_ADMIN)) {
-					String ancestors = rpc.getData().getAncestors();
-					// ancestors 0,1689540492698267649
-					if (ancestors != null && ancestors.contains(String.valueOf(ZERO))) {
-						List<Long> longList = Func.toLongList(ancestors);
-						if (!CollectionUtils.isEmpty(longList) && longList.size() > 2) {
-							Long topDept = longList.get(1);
-							List<ProjectAuth> auths = projectAuthService.getByTopDept(topDept, null);
-							if (!CollectionUtils.isEmpty(auths)) {
-								Set<Long> projectIds = auths.stream().map(ProjectAuth::getProjectId).collect(Collectors.toSet());
-								lqw.in(Project::getId, projectIds);
-							}
-						}
+					List<ProjectAuth> auths = projectAuthService.getByTopDept(dto.getTopDept(), null);
+					if (!CollectionUtils.isEmpty(auths)) {
+						Set<Long> projectIds = auths.stream().map(ProjectAuth::getProjectId).collect(Collectors.toSet());
+						lqw.in(Project::getId, projectIds);
 					}
 				} else {
 					//不是服务机构管理员 则会是项目经理或者任务执行人  从项目权限表里取

+ 6 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectStageServiceImplService.java

@@ -7,6 +7,8 @@ import lombok.AllArgsConstructor;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @author Blizzard
  * @create at 2023-09-13 16:50
@@ -15,4 +17,8 @@ import org.springframework.stereotype.Service;
 @Service
 @AllArgsConstructor
 public class ProjectStageServiceImplService extends BaseServiceImpl<ProjectStageMapper, ProjectStage> implements IProjectStageService {
+	@Override
+	public List<ProjectStage> listByProjectId(Long projectId) {
+		return baseMapper.selectByProjectId(projectId);
+	}
 }

+ 80 - 0
blade-service/wt-okr/src/main/java/com/wtkj/wrapper/FileAndFolderWrapper.java

@@ -0,0 +1,80 @@
+package com.wtkj.wrapper;
+
+import com.wtkj.entity.FileAndFolder;
+import com.wtkj.service.IFileAndFolderService;
+import com.wtkj.vo.FileAndFolderVO;
+import com.wutong.file.feign.IFileClient;
+import com.wutong.file.vo.FileVO;
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.SpringUtil;
+import org.springblade.system.entity.Dept;
+import org.springblade.system.feign.ISysClient;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.feign.IUserClient;
+
+import java.util.Objects;
+
+import static com.wtkj.config.MagicValue.ONE;
+import static com.wtkj.config.MagicValue.TWO;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-14 17:17
+ * @describe
+ */
+public class FileAndFolderWrapper extends BaseEntityWrapper<FileAndFolder, FileAndFolderVO> {
+
+	private static IUserClient userClient;
+	private static ISysClient sysClient;
+	private static IFileAndFolderService fileAndFolderService;
+	private static IFileClient fileClient;
+
+	public static FileAndFolderWrapper build() {
+		userClient = SpringUtil.getBean(IUserClient.class);
+		sysClient = SpringUtil.getBean(ISysClient.class);
+		fileAndFolderService = SpringUtil.getBean(IFileAndFolderService.class);
+		fileClient = SpringUtil.getBean(IFileClient.class);
+		return new FileAndFolderWrapper();
+	}
+
+	@Override
+	public FileAndFolderVO entityVO(FileAndFolder entity) {
+		FileAndFolderVO vo = Objects.requireNonNull(BeanUtil.copy(entity, FileAndFolderVO.class));
+		//创建人
+		Long createUser = vo.getCreateUser();
+		R<User> userR = userClient.userInfoById(createUser);
+		if (userR.isSuccess()) {
+			vo.setUploadUser(userR.getData().getName());
+		}
+		//创建机构
+		Long createDept = vo.getCreateDept();
+		R<Dept> deptR = sysClient.getDept(createDept);
+		if (deptR.isSuccess()) {
+			vo.setUploadDept(deptR.getData().getDeptName());
+		}
+		//如果是文件夹  展示文件夹下文件数量 如果是文件 展示大小和url
+		if (vo.getType() != null && vo.getType().equals(TWO)) {
+			Integer fileAmount = fileAndFolderService.getFileAmountByFolderId(null, vo.getId());
+			vo.setFileAmount(fileAmount);
+		} else if (vo.getType() != null && vo.getType().equals(ONE)) {
+			R<FileVO> rpc = fileClient.findById(vo.getBladeFileId());
+			if (rpc.isSuccess()) {
+				vo.setVolume(rpc.getData().getVolume());
+				vo.setUrl(rpc.getData().getFilePath());
+			}
+		}
+		//权限
+		Integer isPrivate = vo.getIsPrivate();
+		Long privateUser = vo.getPrivateUser();
+		if (Objects.equals(isPrivate, ONE)) {
+			Long userId = AuthUtil.getUserId();
+			if (userId.equals(privateUser)) {
+				vo.setAuth(ONE);
+			}
+		}
+		return vo;
+	}
+}