feat: 附件上传

This commit is contained in:
2025-11-19 16:45:26 +08:00
parent dd3fd18132
commit 5af4d27532
17 changed files with 576 additions and 21 deletions

View File

@@ -14,7 +14,9 @@ package org.nl.dev.modular.file.provider;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.annotation.Resource;
import org.nl.dev.modular.file.entity.DevFile;
import org.nl.dev.modular.file.enums.DevFileEngineTypeEnum;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@@ -81,4 +83,12 @@ public class DevFileApiProvider implements DevFileApi {
.map(JSONUtil::parseObj)
.orElse(new JSONObject());
}
@Override
public JSONObject getFileInfoByUrl(String fileAddress) {
return Optional.ofNullable(devFileService.getOne(new LambdaQueryWrapper<DevFile>()
.eq(DevFile::getDownloadPath, fileAddress)))
.map(JSONUtil::parseObj)
.orElse(new JSONObject());
}
}

View File

@@ -31,6 +31,11 @@
<groupId>org.nl</groupId>
<artifactId>nl-plugin-sys-api</artifactId>
</dependency>
<dependency>
<groupId>org.nl</groupId>
<artifactId>nl-plugin-dev-api</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -18,6 +18,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.nl.common.pojo.SelectListItem;
import org.nl.pmm.modular.project.entity.vo.ProjectAttachmentVo;
import org.nl.pmm.modular.project.entity.vo.ProjectRequestVo;
import org.nl.pmm.modular.project.entity.vo.ProjectVo;
import org.nl.pmm.modular.project.param.*;
@@ -130,12 +131,24 @@ public class ProjectController {
*/
@Operation(summary = "获取项目需求信息详情")
// @SaCheckPermission("/pmm/project/request-detail")
@SaIgnore
@GetMapping("/pmm/project/requestDetail")
public CommonResult<List<ProjectRequestVo>> requestDetail(@Valid ProjectIdParam projectIdParam) {
return CommonResult.data(projectService.requestDetail(projectIdParam));
}
/**
* 获取项目附件
*
* @author liyongde
* @date 2025/11/11 20:13
*/
@Operation(summary = "获取项目需求信息详情")
// @SaCheckPermission("/pmm/project/request-detail")
@GetMapping("/pmm/project/getAttachment")
public CommonResult<List<ProjectAttachmentVo>> getAttachment(@Valid ProjectIdParam projectIdParam) {
return CommonResult.data(projectService.getAttachment(projectIdParam));
}
/**
* 获取xx组用户
*

View File

@@ -0,0 +1,16 @@
package org.nl.pmm.modular.project.entity.vo;
import lombok.Data;
/**
* @Author: lyd
* @Date: 2025/11/19
*/
@Data
public class ProjectAttachmentVo {
private String id;
private String name;
private String suffix;
private String downloadPath;
private String thumbnail;
}

View File

@@ -16,6 +16,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.common.pojo.SelectListItem;
import org.nl.pmm.modular.project.entity.Project;
import org.nl.pmm.modular.project.entity.vo.ProjectAttachmentVo;
import org.nl.pmm.modular.project.entity.vo.ProjectRequestVo;
import org.nl.pmm.modular.project.entity.vo.ProjectVo;
import org.nl.pmm.modular.project.param.ProjectAddParam;
@@ -92,4 +93,11 @@ public interface ProjectService extends IService<Project> {
* @return
*/
List<ProjectRequestVo> requestDetail(ProjectIdParam projectIdParam);
/**
* 获取项目附件
* @param projectIdParam
* @return
*/
List<ProjectAttachmentVo> getAttachment(ProjectIdParam projectIdParam);
}

View File

@@ -22,8 +22,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.nl.common.pojo.SelectListItem;
import org.nl.common.util.CommonTimeFormatUtil;
import org.nl.pmm.modular.project.entity.vo.ProjectAttachmentVo;
import org.nl.pmm.modular.project.entity.vo.ProjectRequestVo;
import org.nl.pmm.modular.project.entity.vo.ProjectVo;
import org.nl.pmm.modular.projectfile.service.ProjectFileService;
import org.nl.pmm.modular.projectstage.entity.ProjectStage;
import org.nl.pmm.modular.projectstage.service.ProjectStageService;
import org.nl.pmm.modular.stagedetail.entity.StageDetail;
@@ -63,6 +65,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
private ProjectStageService projectStageService;
@Resource
private StageDetailService stageDetailService;
@Resource
private ProjectFileService projectFileService;
@Override
public Page<ProjectVo> page(ProjectPageParam projectPageParam) {
@@ -176,4 +180,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
}
return result;
}
@Override
public List<ProjectAttachmentVo> getAttachment(ProjectIdParam projectIdParam) {
// 获取项目附件
List<ProjectAttachmentVo> files = projectFileService.getFileByProjectId(projectIdParam.getProjectId());
return files;
}
}

View File

@@ -13,9 +13,11 @@
package org.nl.pmm.modular.projectfile.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaIgnore;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.nl.pmm.modular.projectfile.param.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@@ -24,10 +26,6 @@ import org.springframework.web.bind.annotation.RestController;
import org.nl.common.annotation.CommonLog;
import org.nl.common.pojo.CommonResult;
import org.nl.pmm.modular.projectfile.entity.ProjectFile;
import org.nl.pmm.modular.projectfile.param.ProjectFileAddParam;
import org.nl.pmm.modular.projectfile.param.ProjectFileEditParam;
import org.nl.pmm.modular.projectfile.param.ProjectFileIdParam;
import org.nl.pmm.modular.projectfile.param.ProjectFilePageParam;
import org.nl.pmm.modular.projectfile.service.ProjectFileService;
import jakarta.annotation.Resource;
@@ -107,6 +105,21 @@ public class ProjectFileController {
projectFileService.delete(projectFileIdParamList);
return CommonResult.ok();
}
/**
* 删除项目附件表
*
* @author liyongde
* @date 2025/11/17 20:24
*/
@Operation(summary = "保存项目附件表")
@CommonLog("保存项目附件表")
@SaIgnore
// @SaCheckPermission("/pmm/projectfile/bindProjectFile")
@PostMapping("/pmm/projectfile/bindProjectFile")
public CommonResult<String> bindProjectFile(@RequestBody ProjectFileAddParam projectFileIdParam) {
projectFileService.bindProjectFile(projectFileIdParam);
return CommonResult.ok();
}
/**
* 获取项目附件表详情

View File

@@ -13,8 +13,11 @@
package org.nl.pmm.modular.projectfile.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.nl.pmm.modular.project.entity.vo.ProjectAttachmentVo;
import org.nl.pmm.modular.projectfile.entity.ProjectFile;
import java.util.List;
/**
* 项目附件表Mapper接口
*
@@ -22,4 +25,5 @@ import org.nl.pmm.modular.projectfile.entity.ProjectFile;
* @date 2025/11/17 20:24
**/
public interface ProjectFileMapper extends BaseMapper<ProjectFile> {
List<ProjectAttachmentVo> getFileByProjectId(String projectId);
}

View File

@@ -2,4 +2,14 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.nl.pmm.modular.projectfile.mapper.ProjectFileMapper">
</mapper>
<select id="getFileByProjectId" resultType="org.nl.pmm.modular.project.entity.vo.ProjectAttachmentVo">
SELECT df.ID,
df.`NAME`,
df.SUFFIX,
df.DOWNLOAD_PATH
FROM dev_file df
WHERE df.ID IN (SELECT pf.file_id
FROM `pmm_project_file` pf
WHERE pf.project_id = #{projectId})
</select>
</mapper>

View File

@@ -0,0 +1,19 @@
package org.nl.pmm.modular.projectfile.param;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @Author: lyd
* @Date: 2025/11/19
*/
@Data
public class ProjectFileBindParam {
/** 项目id */
@Schema(description = "项目id")
private String projectId;
/** 文件地址 */
@Schema(description = "文件地址")
private String fileUrl;
}

View File

@@ -14,11 +14,9 @@ package org.nl.pmm.modular.projectfile.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.pmm.modular.project.entity.vo.ProjectAttachmentVo;
import org.nl.pmm.modular.projectfile.entity.ProjectFile;
import org.nl.pmm.modular.projectfile.param.ProjectFileAddParam;
import org.nl.pmm.modular.projectfile.param.ProjectFileEditParam;
import org.nl.pmm.modular.projectfile.param.ProjectFileIdParam;
import org.nl.pmm.modular.projectfile.param.ProjectFilePageParam;
import org.nl.pmm.modular.projectfile.param.*;
import java.util.List;
@@ -77,4 +75,8 @@ public interface ProjectFileService extends IService<ProjectFile> {
* @date 2025/11/17 20:24
**/
ProjectFile queryEntity(String id);
List<ProjectAttachmentVo> getFileByProjectId(String projectId);
void bindProjectFile(ProjectFileAddParam param);
}

View File

@@ -16,14 +16,16 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollStreamUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import org.nl.common.enums.CommonSortOrderEnum;
import org.nl.common.exception.CommonException;
import org.nl.common.page.CommonPageRequest;
import org.nl.dev.api.DevFileApi;
import org.nl.pmm.modular.project.entity.vo.ProjectAttachmentVo;
import org.nl.pmm.modular.projectfile.entity.ProjectFile;
import org.nl.pmm.modular.projectfile.mapper.ProjectFileMapper;
import org.nl.pmm.modular.projectfile.param.ProjectFileAddParam;
@@ -31,6 +33,8 @@ import org.nl.pmm.modular.projectfile.param.ProjectFileEditParam;
import org.nl.pmm.modular.projectfile.param.ProjectFileIdParam;
import org.nl.pmm.modular.projectfile.param.ProjectFilePageParam;
import org.nl.pmm.modular.projectfile.service.ProjectFileService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -43,6 +47,9 @@ import java.util.List;
@Service
public class ProjectFileServiceImpl extends ServiceImpl<ProjectFileMapper, ProjectFile> implements ProjectFileService {
@Resource
private DevFileApi devFileApi;
@Override
public Page<ProjectFile> page(ProjectFilePageParam projectFilePageParam) {
QueryWrapper<ProjectFile> queryWrapper = new QueryWrapper<ProjectFile>().checkSqlInjection();
@@ -91,4 +98,17 @@ public class ProjectFileServiceImpl extends ServiceImpl<ProjectFileMapper, Proje
}
return projectFile;
}
@Override
public List<ProjectAttachmentVo> getFileByProjectId(String projectId) {
return this.baseMapper.getFileByProjectId(projectId);
}
@Override
public void bindProjectFile(ProjectFileAddParam param) {
JSONObject file = devFileApi.getFileInfoByUrl(param.getFileAddress());
param.setFileId(file.getStr("id"));
param.setFileAddress(file.getStr("downloadPath"));
add(param);
}
}