From e5bbe7a53ed18464f5c21297d7c252ac2f55ed9e Mon Sep 17 00:00:00 2001 From: mengff <1198151809@qq.com> Date: Fri, 5 Jan 2024 11:56:33 +0800 Subject: [PATCH] =?UTF-8?q?--=E5=A4=84=E7=90=86=E6=B5=81=E7=A8=8B=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=8A=A0=E5=85=A5=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=B1=BB=E5=9E=8B=E6=8E=A5=E6=94=B6=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcEventProcessController.java | 13 +++++++++++-- .../java/com/zc/business/domain/DcEventProcess.java | 12 ++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java b/zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java index f332ebfc..142c5a39 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java @@ -1,8 +1,13 @@ package com.zc.business.controller; +import java.io.IOException; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.exception.file.InvalidExtensionException; +import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.common.utils.file.MimeTypeUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.security.access.prepost.PreAuthorize; @@ -85,8 +90,12 @@ public class DcEventProcessController extends BaseController @PreAuthorize("@ss.hasPermi('system:process:add')") @Log(title = "事件处理流程", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody DcEventProcess dcEventProcess) - { + public AjaxResult add(@RequestBody DcEventProcess dcEventProcess) throws IOException, InvalidExtensionException { + //如果有文件传入 + if(!dcEventProcess.getFile().isEmpty()){ + String address =FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), dcEventProcess.getFile(), MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + dcEventProcess.setContext(address); + } return toAjax(dcEventProcessService.insertDcEventProcess(dcEventProcess)); } diff --git a/zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java b/zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java index 751b51d9..02514610 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java @@ -7,6 +7,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; +import org.springframework.web.multipart.MultipartFile; import javax.validation.constraints.NotBlank; @@ -73,6 +74,17 @@ public class DcEventProcess @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") private String processName; + public MultipartFile getFile() { + return file; + } + + public void setFile(MultipartFile file) { + this.file = file; + } + + @ApiModelProperty("上传文件") + private MultipartFile file; + public void setId(Long id) { this.id = id;