From 8b6a9be75df55f1cd7351700af0308b6952b6ede Mon Sep 17 00:00:00 2001
From: lin <sbla5888@163.com>
Date: Tue, 07 May 2024 15:22:14 +0800
Subject: [PATCH] 新增上传附件接口,可指定过滤上传类型
---
src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java | 28 ++++++++++++++
src/main/java/org/springblade/modules/task/entity/TaskNoFraudReportingEntity.java | 75 +++++++++++++++++++++++++++++++++++++
2 files changed, 103 insertions(+), 0 deletions(-)
diff --git a/src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java b/src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
index 5aab59f..08c0bf0 100644
--- a/src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
+++ b/src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
@@ -50,6 +50,8 @@
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
/**
* 对象存储端点
@@ -244,6 +246,32 @@
}
/**
+ * 上传文件指定后缀并保存至附件表
+ *
+ * @param file 文件
+ * @return ObjectStat
+ */
+ @SneakyThrows
+ @PostMapping("/put-file-attach-suffix")
+ public R<BladeFile> putFileAttachSuffix(@RequestParam MultipartFile file, @RequestParam String suffix) {
+ String fileName = file.getOriginalFilename();
+ String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);
+ String[] split = suffix.split(",");
+ List<String> list = Arrays.asList(split);
+ if (list.contains(fileExtension)) {
+ BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream());
+ Long attachId = buildAttach(fileName, file.getSize(), bladeFile);
+ bladeFile.setAttachId(attachId);
+ // 修改link
+ changeLink(bladeFile);
+ // 返回
+ return R.data(bladeFile);
+ } else {
+ return R.fail("上传的附件必须是pdf,ppt,doc,docx格式!");
+ }
+ }
+
+ /**
* 上传文件并保存至附件表
*
* @param fileName 存储桶对象名称
diff --git a/src/main/java/org/springblade/modules/task/entity/TaskNoFraudReportingEntity.java b/src/main/java/org/springblade/modules/task/entity/TaskNoFraudReportingEntity.java
index 6ea0122..c7579ea 100644
--- a/src/main/java/org/springblade/modules/task/entity/TaskNoFraudReportingEntity.java
+++ b/src/main/java/org/springblade/modules/task/entity/TaskNoFraudReportingEntity.java
@@ -101,4 +101,79 @@
@ApiModelProperty(value = "0:否 1:是", example = "")
@TableField("delete_flag")
private Integer deleteFlag;
+
+ /** 1:方式一 2:方式二 */
+ @ApiModelProperty(value = "1:方式一 2:方式二", example = "")
+ @TableField("type")
+ private Integer type;
+
+ /** 场所负责人姓名 */
+ @ApiModelProperty(value = "场所负责人姓名", example = "")
+ @TableField("principal")
+ private String principal;
+
+ /** 场所负责人联系方式 */
+ @ApiModelProperty(value = "场所负责人联系方式", example = "")
+ @TableField("principal_phone")
+ private String principalPhone;
+
+ /** 经度 */
+ @ApiModelProperty(value = "经度", example = "")
+ @TableField("lng")
+ private String lng;
+
+ /** 纬度 */
+ @ApiModelProperty(value = "纬度", example = "")
+ @TableField("lat")
+ private String lat;
+
+ /** 位置 */
+ @ApiModelProperty(value = "位置", example = "")
+ @TableField("location")
+ private String location;
+
+ /** 网格id */
+ @ApiModelProperty(value = "网格id", example = "")
+ @TableField("grid_id")
+ private Integer gridId;
+
+ /** 网格编号 */
+ @ApiModelProperty(value = "网格编号", example = "")
+ @TableField("grid_code")
+ private String gridCode;
+
+ /** 警务网格编号 */
+ @ApiModelProperty(value = "警务网格编号", example = "")
+ @TableField("jw_grid_code")
+ private String jwGridCode;
+
+ /** 派出所编号 */
+ @ApiModelProperty(value = "派出所编号", example = "")
+ @TableField("pcs_code")
+ private String pcsCode;
+
+ /** 派出所名称 */
+ @ApiModelProperty(value = "派出所名称", example = "")
+ @TableField("pcs_name")
+ private String pcsName;
+
+ /** 社区编号 */
+ @ApiModelProperty(value = "社区编号", example = "")
+ @TableField("community_code")
+ private String communityCode;
+
+ /** 社区名称 */
+ @ApiModelProperty(value = "社区名称", example = "")
+ @TableField("community_name")
+ private String communityName;
+
+ /** 文件地址 */
+ @ApiModelProperty(value = "文件地址", example = "")
+ @TableField("file_urls")
+ private String fileUrls;
+
+ /** pdf文件地址 */
+ @ApiModelProperty(value = "pdf文件地址", example = "")
+ @TableField("pdf_urls")
+ private String pdfUrls;
}
--
Gitblit v1.9.3